2018-12-22 18:41:12 +00:00
|
|
|
;
|
|
|
|
; fan
|
|
|
|
; Code and data structures related to the special fan weapon
|
|
|
|
;
|
|
|
|
; Created by Quinn Dunki on 8/15/18
|
|
|
|
;
|
|
|
|
|
2018-12-29 18:33:08 +00:00
|
|
|
FANRANGE = 100 ; In pixels
|
2021-07-24 21:00:18 +00:00
|
|
|
FANMAGNITUDE = $20 ; 12.4 fixed point speed delta, in pixels
|
2024-01-21 21:01:10 +00:00
|
|
|
FAN_AGE = 10
|
2021-07-24 21:41:48 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; deployFan
|
|
|
|
;
|
|
|
|
; Y: Index to projectile structure
|
|
|
|
;
|
|
|
|
deployFan:
|
|
|
|
SAVE_AY
|
|
|
|
|
|
|
|
lda #200 ; Drop in from the top of the view
|
|
|
|
sta projectileData+GO_POSY,y
|
|
|
|
|
|
|
|
lda #$c80
|
|
|
|
sta projectileData+JD_PRECISEY,y
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta projectileData+JD_VX,y
|
|
|
|
sta projectileData+JD_VY,y
|
|
|
|
|
2021-07-24 21:41:48 +00:00
|
|
|
lda #1
|
|
|
|
sta projectileData+JD_DEPLOYDELAY,y ; Let player admire new fan
|
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; updateFan
|
|
|
|
;
|
2018-12-24 00:39:22 +00:00
|
|
|
; Y = Offset to projectile structure
|
2018-12-22 18:41:12 +00:00
|
|
|
;
|
|
|
|
updateFan:
|
2018-12-24 00:39:22 +00:00
|
|
|
SAVE_AXY
|
2018-12-22 18:41:12 +00:00
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
lda projectileData+JD_AGE,y
|
|
|
|
cmp #FAN_AGE
|
|
|
|
bcs updateFanWornOut
|
|
|
|
|
2018-12-27 00:10:25 +00:00
|
|
|
lda projectileData+JD_STATIC,y
|
2018-12-29 18:33:08 +00:00
|
|
|
bne updateFanWind ; We're set up, so apply our wind
|
2018-12-27 00:10:25 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
; Wait for fan to collide with us as it falls from the sky
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
sta rectParams
|
|
|
|
lda projectileData+GO_POSY,y
|
|
|
|
sta rectParams+2
|
|
|
|
lda #GAMEOBJECTWIDTH
|
|
|
|
sta rectParams+4
|
|
|
|
lda #GAMEOBJECTHEIGHT
|
|
|
|
sta rectParams+6
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
ldx currentPlayer
|
2018-12-22 18:41:12 +00:00
|
|
|
jsr playerIntersectRect
|
|
|
|
cmp #0
|
|
|
|
beq updateFanDone
|
|
|
|
|
2018-12-27 00:10:25 +00:00
|
|
|
; Once fan is in place, make it static
|
2018-12-30 00:13:03 +00:00
|
|
|
lda projectileData+GO_POSY,y
|
|
|
|
inc
|
2024-01-09 02:53:20 +00:00
|
|
|
inc
|
2018-12-30 00:13:03 +00:00
|
|
|
sta projectileData+GO_POSY,y
|
2018-12-27 00:10:25 +00:00
|
|
|
lda #1
|
|
|
|
sta projectileData+JD_STATIC,y
|
|
|
|
jsr endProjectile
|
|
|
|
|
2018-12-27 00:29:13 +00:00
|
|
|
; Now set up the stand
|
2018-12-30 00:13:03 +00:00
|
|
|
jsr allocGameObject
|
|
|
|
cpx #-1
|
|
|
|
beq updateFanDone
|
|
|
|
txa
|
|
|
|
sta projectileData+JD_SCRATCH,y ; Remember where our stand is
|
2018-12-27 00:29:13 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
2018-12-30 00:13:03 +00:00
|
|
|
sta gameObjectPool+GO_POSX,x
|
2018-12-27 00:29:13 +00:00
|
|
|
lda projectileData+GO_POSY,y
|
|
|
|
sec
|
|
|
|
sbc #GAMEOBJECTHEIGHT
|
2018-12-30 00:13:03 +00:00
|
|
|
sta gameObjectPool+GO_POSY,x
|
2021-07-24 21:41:48 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
updateFanDone:
|
2018-12-24 00:39:22 +00:00
|
|
|
RESTORE_AXY
|
2018-12-27 00:29:13 +00:00
|
|
|
rts
|
2018-12-22 18:41:12 +00:00
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
updateFanWornOut:
|
|
|
|
jsr deleteVisibleProjectile
|
|
|
|
bra updateFanDone
|
|
|
|
|
2018-12-29 18:33:08 +00:00
|
|
|
updateFanWind:
|
|
|
|
lda projectileData+JD_OWNER,y
|
|
|
|
cmp currentPlayer ; We're not affected by our own fan
|
|
|
|
beq updateFanDone
|
|
|
|
|
|
|
|
tyx
|
|
|
|
ldy projectileActive
|
|
|
|
bmi updateFanDone ; No active projectile
|
|
|
|
|
|
|
|
; Calculate distance to fan
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
sta SCRATCHL
|
|
|
|
lda projectileData+GO_POSX,x
|
|
|
|
sec
|
|
|
|
sbc SCRATCHL
|
|
|
|
ABSA
|
|
|
|
cmp #FANRANGE ; Check if we're within range
|
|
|
|
bcs updateFanDone
|
|
|
|
|
|
|
|
; Apply wind
|
|
|
|
lda projectileData+JD_FACING,y
|
|
|
|
bne updateFanWindNeg
|
|
|
|
|
|
|
|
sec
|
|
|
|
lda projectileData+JD_PRECISEX,y
|
|
|
|
sbc #FANMAGNITUDE
|
|
|
|
sta projectileData+JD_PRECISEX,y
|
|
|
|
bra updateFanDone
|
|
|
|
|
|
|
|
updateFanWindNeg:
|
|
|
|
clc
|
|
|
|
lda projectileData+JD_PRECISEX,y
|
|
|
|
adc #FANMAGNITUDE
|
|
|
|
sta projectileData+JD_PRECISEX,y
|
|
|
|
bra updateFanDone
|
|
|
|
|
2018-12-27 00:29:13 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; renderFan
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
|
|
|
;
|
|
|
|
renderFan:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
lda projectileData+JD_STATIC,y
|
|
|
|
beq renderFanDone ; Don't render the stand until we're static
|
|
|
|
|
|
|
|
; Render the stand under the fan
|
2018-12-30 00:13:03 +00:00
|
|
|
lda projectileData+JD_SCRATCH,y
|
|
|
|
sta PARAML0
|
|
|
|
clc
|
|
|
|
lda #gameObjectPool
|
|
|
|
adc PARAML0
|
2018-12-27 00:29:13 +00:00
|
|
|
sta PARAML0
|
|
|
|
lda #14
|
|
|
|
jsr renderGameObject
|
|
|
|
|
2021-07-24 21:41:48 +00:00
|
|
|
; Do deployment delay after first render
|
|
|
|
lda projectileData+JD_DEPLOYDELAY,y
|
|
|
|
beq renderFanDone
|
|
|
|
jsr delayLong
|
|
|
|
lda #0
|
|
|
|
sta projectileData+JD_DEPLOYDELAY,y
|
|
|
|
|
2018-12-27 00:29:13 +00:00
|
|
|
renderFanDone:
|
|
|
|
RESTORE_AXY
|
2018-12-22 18:41:12 +00:00
|
|
|
rts
|
2018-12-30 00:45:40 +00:00
|
|
|
|
|
|
|
|
2024-01-13 21:27:11 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; unrenderFan
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
|
|
|
;
|
|
|
|
unrenderFan:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
; Unrender the stand under the fan
|
|
|
|
lda projectileData+JD_SCRATCH,y
|
|
|
|
sta PARAML0
|
|
|
|
clc
|
|
|
|
lda #gameObjectPool
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
|
|
|
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; protectFan
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
|
|
|
;
|
|
|
|
protectFan:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
; Protect the stand under the fan
|
|
|
|
lda projectileData+JD_SCRATCH,y
|
|
|
|
sta PARAML0
|
|
|
|
clc
|
|
|
|
lda #gameObjectPool
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
|
|
|
jsr vramPtr
|
|
|
|
cpx #$ffff
|
|
|
|
beq protectFanDone
|
|
|
|
|
|
|
|
lda PARAML0
|
|
|
|
clc
|
|
|
|
adc #GO_BACKGROUND
|
|
|
|
sta PARAML0
|
|
|
|
jsr protectGameObject
|
|
|
|
|
|
|
|
protectFanDone:
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; deleteFan
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
|
|
|
;
|
|
|
|
deleteFan:
|
|
|
|
SAVE_AX
|
|
|
|
|
|
|
|
lda projectileData+JD_SCRATCH,y
|
|
|
|
tax
|
|
|
|
|
|
|
|
; Unrender the stand
|
|
|
|
lda #gameObjectPool
|
|
|
|
sta PARAML0
|
|
|
|
txa
|
|
|
|
clc
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
|
|
|
|
|
|
|
jsr deleteGameObject
|
|
|
|
jsr renderPlayers
|
|
|
|
|
|
|
|
RESTORE_AX
|
|
|
|
rts
|