;; sprite pre-draw
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
checkStartScreenSelector:
LDA update_screen_details
BNE endCheckingStartScreenSelector
;; is special screen:
LDA newScreen
CMP #$01
BEQ endCheckingStartScreenSelector
;; is START SCREEN:
;; positions selection:
LDA #SELECTION_POS_X
STA temp2 ;; coord X position of all selections
LDA #SELECTION_POS_Y ;; coord Y position when selection mode is 0
STA temp1
LDA player2Mode
CLC
BEQ +
;; if not equal to 0, means at least equal to 1
LDA temp1 ;; coord Y position when selection mode is 1
ADC #$08
STA temp1
+
DrawSprite temp2, temp1, #STARTSCREEN_CURSOR_TILE, #%00000000, #$00
UpdateSpritePointer
JMP endCheckingStartScreenSelector
endCheckingStartScreenSelector:
;;=================== Platform engine
;; In our platform engine, the player can shoot from a 'projectile source'.
;; Since this projectile source does not interact with the background in any way,
;; it is really just a sprite extention of the player, and would be truly foolish to waste
;; an object and processing time on it. You can, but it would be wasteful.
;; So what we can do instead is use pre-drawn sprites. If the player is in his attack state,
;; we will check the direction, and then draw the weapon sprite based on which direction he is
;; facing.
;; if a Sprite weapon is set:
LDA #SPRITE_WEAPON_H
BNE +
JMP skipDrawSpriteWeapon
+
LDA #SPRITE_WEAPON_V
BNE +
JMP skipDrawSpriteWeapon
+
;; if weapon unlocked:
LDA weaponsUnlocked
AND #%00000001
BNE +
JMP skipDrawSpriteWeapon
+
;LDX player1_object ;; we are going to check some player 1 things.
;;; but getting current action type will set x to this automatically
doDrawSpriteWeapon:
TXA
STA tempxxx
LDX player1_object
CPX #$FF
BEQ +
TXA
STA playerX_object
JSR doPreDrawPlayerX
+
LDX player2_object
CPX #$FF
BEQ +
TXA
STA playerX_object
JSR doPreDrawPlayerX
+
LDX tempxxx
JMP skipDrawSpriteWeapon
doPreDrawPlayerX:
GetCurrentActionType playerX_object ;; what object is the current player
;; because if it's attack (2), we should draw weapon.
CMP #$02
BEQ +
JMP notAttackingSoDontDrawWeapon
+
;;attacking, so draw weapon.
LDA Object_movement,x
AND #%00000111
TAY ;; now y contains direction, so we can figure out position offset
;CMP #RIGHT
;BNE directionIsNotRightForDrawingWeapon
;;; direction is right.
LDA Object_x_hi,x
;;; offset x for creation
CLC
ADC weaponOffsetTableX,y
SEC
SBC #$08 ;; width of gun
STA temp
LDA Object_y_hi,x
CLC
ADC weaponOffsetTableY,y
sec
sbc #$08 ;; height of gun
STA temp1
CPY #RIGHT
BNE directionIsNotRightForDrawingWeapon
;; it is right, which means draw without flip
LDA #%00000001
STA temp2
LDA #SPRITE_WEAPON_H
STA temp3
JMP doDrawWeapon
directionIsNotRightForDrawingWeapon:
CPY #LEFT
BNE directionIsNotLeftForDrawingWeapon
LDA #%01000001
STA temp2
LDA #SPRITE_WEAPON_H
STA temp3
JMP doDrawWeapon
directionIsNotLeftForDrawingWeapon:
CPY #UP
BNE directionIsNotUPForDrawingWeapon
LDA #%00000001
STA temp2
LDA #SPRITE_WEAPON_V
STA temp3
JMP doDrawWeapon
directionIsNotUPForDrawingWeapon:
;; direction must be down.
;; need to add cases for diagonals if you want to use diagonals.
LDA #%10000001
STA temp2
LDA #SPRITE_WEAPON_V
STA temp3
doDrawWeapon:
DrawSprite temp, temp1, temp3, temp2, spriteOffset
JMP doneDrawingWeaponSprite
doneDrawingWeaponSprite:
UpdateSpritePointer
notAttackingSoDontDrawWeapon:
skipDrawSpriteWeapon: