;; sprite drawing routine.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; For horizontal scrolling games, extra attention has to be taken to draw
;;; sprites off screen if they are no longer in the camera render area.
LDA gameHandler
AND #%01000000
BEQ doDrawThisSprite
JMP doneDrawingThisSprite
doDrawThisSprite:
;;;; loaded into x is the object drawing this routine.
LDA Object_x_hi,x
STA tempA
LDA Object_y_hi,x
STA tempB
LDA Object_type,x
BEQ +isPlayerObject
JMP +isNotPlayerObject
+isPlayerObject
;;; DRAW PLAYER OBJECT
DrawSprite tempA, tempB, #$00, #%00000000
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$00, #%01000000
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$10, #%00000000
DrawSprite temp1, temp2, #$10, #%01000000
LDA Object_vulnerability,x ;; loads vulnerability byte for Player object
AND #%00001000 ;; checks if "Action Step Flag 02" is checked, assumes this is your invincible toggle;;
;;remember you can relabel these to keep track in Project Settings->project labels->Player Action Step Flags
BNE +MakeShield ;; if invincible, make shield
JMP +canHurtPlayer
;;else skip
+MakeShield
;;; DRAW SHIELD
DrawSprite tempA, tempB, #$13, #%00000000
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$13, #%01000000
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$13, #%10000000
DrawSprite temp1, temp2, #$13, #%11000000
+canHurtPlayer
JMP doneDrawingThisSprite
+isNotPlayerObject
;;; CHECK OTHER OBJECTS.
CMP #$03
BEQ +isLaser
JMP +isNotLaser
+isLaser
LDA vBlankTimer
AND #%00000100
BEQ +isEvenFrame
JMP +isNotEvenFrame
+isEvenFrame
;;; DRAW PROJECTILE
DrawSprite tempA, tempB, #$06, #%00000000
JMP doneDrawingThisSprite
+isNotEvenFrame
DrawSprite tempA, tempB, #$06, #%00000011
JMP doneDrawingThisSprite
+isNotLaser
CMP #$08
BEQ +isMonsterWeapon
JMP +isNotMonsterWeapon
+isMonsterWeapon
LDA vBlankTimer
AND #%00000100
BEQ +isEvenFrame
JMP +isNotEvenFrame
+isEvenFrame
;;; DRAW ENEMY PROJECTILE
DrawSprite tempA, tempB, #$06, #%00000001
JMP doneDrawingThisSprite
+isNotEvenFrame
DrawSprite tempA, tempB, #$06, #%00000010
JMP doneDrawingThisSprite
+isNotMonsterWeapon
CMP #$11
BEQ +isEnemy
JMP +isNotEnemy
+isEnemy
;;; DRAW ENEMY
DrawSprite tempA, tempB, #$85, #%01000010
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$85, #%00000010
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$95, #%01000010
DrawSprite temp1, temp2, #$95, #%00000010
JMP doneDrawingThisSprite
+isNotEnemy
CMP #$02
BEQ +isShield
JMP +isNotShield
+isShield
;;; DRAW SHIELD
DrawSprite tempA, tempB, #$13, #%00000000
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$13, #%01000000
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$13, #%10000000
DrawSprite temp1, temp2, #$13, #%11000000
JMP doneDrawingThisSprite
+isNotShield
CMP #$09
BEQ +isExplode
JMP +isNotExplode
+isExplode
TXA
STA temp
GetActionStep temp
CMP #$00
BEQ +isEvenFrame
JMP +isNotEvenFrame
+isEvenFrame
;;; DRAW EXPLODE
DrawSprite tempA, tempB, #$03, #%00000001
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$03, #%01000001
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$03, #%10000001
DrawSprite temp1, temp2, #$03, #%11000001
JMP doneDrawingThisSprite
+isNotEvenFrame
DrawSprite tempA, tempB, #$05, #%00000001
LDA tempA
CLC
ADC #$08
STA temp1
DrawSprite temp1, tempB, #$05, #%01000001
LDA tempB
CLC
ADC #$08
STA temp2
DrawSprite tempA, temp2, #$05, #%10000001
DrawSprite temp1, temp2, #$05, #%11000001
JMP doneDrawingThisSprite
+isNotExplode
doneDrawingThisSprite:
LDA updateScreenData
AND #%0000100
BEQ +continue
RTS
+continue:
RTS