Added projectile aging and subclass cleanup

This commit is contained in:
blondie7575 2018-12-29 17:45:40 -07:00
parent 364ae0de32
commit c72e8c125b
5 changed files with 120 additions and 13 deletions

View File

@ -66,6 +66,7 @@ JD_STATIC = 144
JD_OWNER = 146
JD_FACING = 148
JD_SCRATCH = 150
JD_AGE = 152
MAXPROJECTILES = 3

38
fan.s
View File

@ -7,7 +7,7 @@
FANRANGE = 100 ; In pixels
FANMAGNITUDE = $10 ; 12.4 fixed point speed delta, in pixels
FAN_AGE = 4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; deployFan
@ -39,6 +39,10 @@ deployFan:
updateFan:
SAVE_AXY
lda projectileData+JD_AGE,y
cmp #FAN_AGE
bcs updateFanWornOut
lda projectileData+JD_STATIC,y
bne updateFanWind ; We're set up, so apply our wind
@ -68,7 +72,6 @@ updateFan:
; Now set up the stand
jsr allocGameObject
cpx #-1
BREAK
beq updateFanDone
txa
sta projectileData+JD_SCRATCH,y ; Remember where our stand is
@ -83,6 +86,10 @@ updateFanDone:
RESTORE_AXY
rts
updateFanWornOut:
jsr deleteVisibleProjectile
bra updateFanDone
updateFanWind:
lda projectileData+JD_OWNER,y
cmp currentPlayer ; We're not affected by our own fan
@ -144,3 +151,30 @@ renderFan:
renderFanDone:
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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

View File

@ -235,6 +235,8 @@ endTurn:
sta currentPlayer
endTurnRefresh:
jsr processTurnForProjectiles
ldy currentPlayer
beq endTurnFocusPlayer0

Binary file not shown.

View File

@ -25,8 +25,9 @@ projectileData:
.word 0 ; Owner (player index)
.word 0 ; Facing (0,1) = (+X,-X)
.word 0 ; Scratch space for subclasses
.word 0 ; Age (in turns)
.repeat 104
.repeat 102
.byte 0 ; Padding to 256-byte boundary
.endrepeat
@ -49,8 +50,9 @@ projectileData:
.word 0 ; Owner (player index)
.word 0 ; Facing (0,1) = (+X,-X)
.word 0 ; Scratch space for subclasses
.word 0 ; Age (in turns)
.repeat 104
.repeat 102
.byte 0 ; Padding to 256-byte boundary
.endrepeat
@ -73,8 +75,9 @@ projectileData:
.word 0 ; Owner (player index)
.word 0 ; Facing (0,1) = (+X,-X)
.word 0 ; Scratch space for subclasses
.word 0 ; Age (in turns)
.repeat 104
.repeat 102
.byte 0 ; Padding to 256-byte boundary
.endrepeat
@ -98,8 +101,11 @@ projectileTypes:
.addr 0 ; Deploy
.addr 0 ; Update
.addr 0 ; Render
.addr 0 ; Cleanup
;.word ; Padding to 16-byte boundary (none needed)
.repeat 14
.byte 0 ; Padding to 32-byte boundary
.endrepeat
; Bomb
.word 50 ; Damage
@ -110,8 +116,11 @@ projectileTypes:
.addr 0 ; Deploy
.addr 0 ; Update
.addr 0 ; Render
.addr 0 ; Cleanup
;.word ; Padding to 16-byte boundary (none needed)
.repeat 14
.byte 0 ; Padding to 32-byte boundary
.endrepeat
; Fan
.word 3 ; Damage
@ -122,8 +131,11 @@ projectileTypes:
.addr deployFan ; Deploy
.addr updateFan ; Update
.addr renderFan ; Render
.addr deleteFan ; Cleanup
;.word ; Padding to 16-byte boundary (none needed)
.repeat 14
.byte 0 ; Padding to 32-byte boundary
.endrepeat
PT_DAMAGE = 0 ; Byte offsets into projectile type data structure
@ -134,6 +146,7 @@ PT_FRAME2 = 8
PT_DEPLOY = 10
PT_UPDATE = 12
PT_RENDER = 14
PT_CLEANUP = 16
.macro PROJECTILEPTR_Y
tya ; Pointer to projectile structure from index
@ -154,6 +167,7 @@ PT_RENDER = 14
asl
asl
asl
asl
tay
.endmacro
@ -163,6 +177,7 @@ PT_RENDER = 14
asl
asl
asl
asl
tax
.endmacro
@ -217,6 +232,7 @@ fireProjectile:
sta projectileData+GO_POSY,y
lda #0
sta projectileData+JD_STATIC,y
sta projectileData+JD_AGE,y
sty projectileActive
lda currentPlayer
sta projectileData+JD_OWNER,y
@ -427,7 +443,7 @@ updateProjectilePhysicsDone:
rts
updateProjectilePhysicsDelete:
jsr endDeleteProjectile
jsr endDeleteCurrProjectile
bra updateProjectilePhysicsDone
updateProjectilePhysicsNormalUpdate:
@ -517,21 +533,46 @@ updateProjectileCollisionsDone:
updateProjectileCollisionsPlayerHit:
jsr processPlayerImpact
jsr endDeleteProjectile
jsr endDeleteCurrProjectile
bra updateProjectileCollisionsDone
updateProjectileCollisionsTerrainHit:
jsr processTerrainImpact
jsr endDeleteProjectile
jsr endDeleteCurrProjectile
bra updateProjectileCollisionsDone
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endDeleteProjectile
; processTurnForProjectiles
;
;
processTurnForProjectiles:
SAVE_AXY
ldx #0
processTurnForProjectilesLoop:
txy
PROJECTILEPTR_Y
lda projectileData+JD_AGE,y
inc
sta projectileData+JD_AGE,y
processTurnForProjectilesSkip:
inx
cpx #MAXPROJECTILES
bne processTurnForProjectilesLoop
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endDeleteCurrProjectile
;
; Trashes A and Y
;
endDeleteProjectile:
endDeleteCurrProjectile:
lda #projectileData
clc
adc projectileActive
@ -541,6 +582,24 @@ endDeleteProjectile:
jsr deleteProjectile
bra endProjectile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; deleteVisibleProjectile
;
; Y = Projectile offset
; Trashes A
;
deleteVisibleProjectile:
lda #projectileData
sta PARAML0
tya
clc
adc PARAML0
sta PARAML0
jsr unrenderGameObject
bra deleteProjectile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endProjectile
;
@ -563,6 +622,17 @@ endProjectile:
deleteProjectile:
lda #-1
sta projectileData+GO_POSX,y
; Check for special cleanup code
lda projectileData+JD_TYPE,y
tax ; Find projectile type data
PROJECTILETYPEPTR_X
lda projectileTypes+PT_CLEANUP,x
beq deleteProjectileDone
JSRA
deleteProjectileDone:
rts