Added projectile aging and subclass cleanup
This commit is contained in:
parent
364ae0de32
commit
c72e8c125b
|
@ -66,6 +66,7 @@ JD_STATIC = 144
|
||||||
JD_OWNER = 146
|
JD_OWNER = 146
|
||||||
JD_FACING = 148
|
JD_FACING = 148
|
||||||
JD_SCRATCH = 150
|
JD_SCRATCH = 150
|
||||||
|
JD_AGE = 152
|
||||||
|
|
||||||
MAXPROJECTILES = 3
|
MAXPROJECTILES = 3
|
||||||
|
|
||||||
|
|
38
fan.s
38
fan.s
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
FANRANGE = 100 ; In pixels
|
FANRANGE = 100 ; In pixels
|
||||||
FANMAGNITUDE = $10 ; 12.4 fixed point speed delta, in pixels
|
FANMAGNITUDE = $10 ; 12.4 fixed point speed delta, in pixels
|
||||||
|
FAN_AGE = 4
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; deployFan
|
; deployFan
|
||||||
|
@ -39,6 +39,10 @@ deployFan:
|
||||||
updateFan:
|
updateFan:
|
||||||
SAVE_AXY
|
SAVE_AXY
|
||||||
|
|
||||||
|
lda projectileData+JD_AGE,y
|
||||||
|
cmp #FAN_AGE
|
||||||
|
bcs updateFanWornOut
|
||||||
|
|
||||||
lda projectileData+JD_STATIC,y
|
lda projectileData+JD_STATIC,y
|
||||||
bne updateFanWind ; We're set up, so apply our wind
|
bne updateFanWind ; We're set up, so apply our wind
|
||||||
|
|
||||||
|
@ -68,7 +72,6 @@ updateFan:
|
||||||
; Now set up the stand
|
; Now set up the stand
|
||||||
jsr allocGameObject
|
jsr allocGameObject
|
||||||
cpx #-1
|
cpx #-1
|
||||||
BREAK
|
|
||||||
beq updateFanDone
|
beq updateFanDone
|
||||||
txa
|
txa
|
||||||
sta projectileData+JD_SCRATCH,y ; Remember where our stand is
|
sta projectileData+JD_SCRATCH,y ; Remember where our stand is
|
||||||
|
@ -83,6 +86,10 @@ updateFanDone:
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
updateFanWornOut:
|
||||||
|
jsr deleteVisibleProjectile
|
||||||
|
bra updateFanDone
|
||||||
|
|
||||||
updateFanWind:
|
updateFanWind:
|
||||||
lda projectileData+JD_OWNER,y
|
lda projectileData+JD_OWNER,y
|
||||||
cmp currentPlayer ; We're not affected by our own fan
|
cmp currentPlayer ; We're not affected by our own fan
|
||||||
|
@ -144,3 +151,30 @@ renderFan:
|
||||||
renderFanDone:
|
renderFanDone:
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
rts
|
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
|
||||||
|
|
|
@ -235,6 +235,8 @@ endTurn:
|
||||||
sta currentPlayer
|
sta currentPlayer
|
||||||
|
|
||||||
endTurnRefresh:
|
endTurnRefresh:
|
||||||
|
jsr processTurnForProjectiles
|
||||||
|
|
||||||
ldy currentPlayer
|
ldy currentPlayer
|
||||||
beq endTurnFocusPlayer0
|
beq endTurnFocusPlayer0
|
||||||
|
|
||||||
|
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
92
projectile.s
92
projectile.s
|
@ -25,8 +25,9 @@ projectileData:
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
.word 0 ; Scratch space for subclasses
|
.word 0 ; Scratch space for subclasses
|
||||||
|
.word 0 ; Age (in turns)
|
||||||
|
|
||||||
.repeat 104
|
.repeat 102
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
|
@ -49,8 +50,9 @@ projectileData:
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
.word 0 ; Scratch space for subclasses
|
.word 0 ; Scratch space for subclasses
|
||||||
|
.word 0 ; Age (in turns)
|
||||||
|
|
||||||
.repeat 104
|
.repeat 102
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
|
@ -73,8 +75,9 @@ projectileData:
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
.word 0 ; Scratch space for subclasses
|
.word 0 ; Scratch space for subclasses
|
||||||
|
.word 0 ; Age (in turns)
|
||||||
|
|
||||||
.repeat 104
|
.repeat 102
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
|
@ -98,8 +101,11 @@ projectileTypes:
|
||||||
.addr 0 ; Deploy
|
.addr 0 ; Deploy
|
||||||
.addr 0 ; Update
|
.addr 0 ; Update
|
||||||
.addr 0 ; Render
|
.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
|
; Bomb
|
||||||
.word 50 ; Damage
|
.word 50 ; Damage
|
||||||
|
@ -110,8 +116,11 @@ projectileTypes:
|
||||||
.addr 0 ; Deploy
|
.addr 0 ; Deploy
|
||||||
.addr 0 ; Update
|
.addr 0 ; Update
|
||||||
.addr 0 ; Render
|
.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
|
; Fan
|
||||||
.word 3 ; Damage
|
.word 3 ; Damage
|
||||||
|
@ -122,8 +131,11 @@ projectileTypes:
|
||||||
.addr deployFan ; Deploy
|
.addr deployFan ; Deploy
|
||||||
.addr updateFan ; Update
|
.addr updateFan ; Update
|
||||||
.addr renderFan ; Render
|
.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
|
PT_DAMAGE = 0 ; Byte offsets into projectile type data structure
|
||||||
|
@ -134,6 +146,7 @@ PT_FRAME2 = 8
|
||||||
PT_DEPLOY = 10
|
PT_DEPLOY = 10
|
||||||
PT_UPDATE = 12
|
PT_UPDATE = 12
|
||||||
PT_RENDER = 14
|
PT_RENDER = 14
|
||||||
|
PT_CLEANUP = 16
|
||||||
|
|
||||||
.macro PROJECTILEPTR_Y
|
.macro PROJECTILEPTR_Y
|
||||||
tya ; Pointer to projectile structure from index
|
tya ; Pointer to projectile structure from index
|
||||||
|
@ -154,6 +167,7 @@ PT_RENDER = 14
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
|
asl
|
||||||
tay
|
tay
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -163,6 +177,7 @@ PT_RENDER = 14
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
|
asl
|
||||||
tax
|
tax
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -217,6 +232,7 @@ fireProjectile:
|
||||||
sta projectileData+GO_POSY,y
|
sta projectileData+GO_POSY,y
|
||||||
lda #0
|
lda #0
|
||||||
sta projectileData+JD_STATIC,y
|
sta projectileData+JD_STATIC,y
|
||||||
|
sta projectileData+JD_AGE,y
|
||||||
sty projectileActive
|
sty projectileActive
|
||||||
lda currentPlayer
|
lda currentPlayer
|
||||||
sta projectileData+JD_OWNER,y
|
sta projectileData+JD_OWNER,y
|
||||||
|
@ -427,7 +443,7 @@ updateProjectilePhysicsDone:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
updateProjectilePhysicsDelete:
|
updateProjectilePhysicsDelete:
|
||||||
jsr endDeleteProjectile
|
jsr endDeleteCurrProjectile
|
||||||
bra updateProjectilePhysicsDone
|
bra updateProjectilePhysicsDone
|
||||||
|
|
||||||
updateProjectilePhysicsNormalUpdate:
|
updateProjectilePhysicsNormalUpdate:
|
||||||
|
@ -517,21 +533,46 @@ updateProjectileCollisionsDone:
|
||||||
|
|
||||||
updateProjectileCollisionsPlayerHit:
|
updateProjectileCollisionsPlayerHit:
|
||||||
jsr processPlayerImpact
|
jsr processPlayerImpact
|
||||||
jsr endDeleteProjectile
|
jsr endDeleteCurrProjectile
|
||||||
bra updateProjectileCollisionsDone
|
bra updateProjectileCollisionsDone
|
||||||
|
|
||||||
updateProjectileCollisionsTerrainHit:
|
updateProjectileCollisionsTerrainHit:
|
||||||
jsr processTerrainImpact
|
jsr processTerrainImpact
|
||||||
jsr endDeleteProjectile
|
jsr endDeleteCurrProjectile
|
||||||
bra updateProjectileCollisionsDone
|
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
|
; Trashes A and Y
|
||||||
;
|
;
|
||||||
endDeleteProjectile:
|
endDeleteCurrProjectile:
|
||||||
lda #projectileData
|
lda #projectileData
|
||||||
clc
|
clc
|
||||||
adc projectileActive
|
adc projectileActive
|
||||||
|
@ -541,6 +582,24 @@ endDeleteProjectile:
|
||||||
jsr deleteProjectile
|
jsr deleteProjectile
|
||||||
bra endProjectile
|
bra endProjectile
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; deleteVisibleProjectile
|
||||||
|
;
|
||||||
|
; Y = Projectile offset
|
||||||
|
; Trashes A
|
||||||
|
;
|
||||||
|
deleteVisibleProjectile:
|
||||||
|
lda #projectileData
|
||||||
|
sta PARAML0
|
||||||
|
tya
|
||||||
|
clc
|
||||||
|
adc PARAML0
|
||||||
|
sta PARAML0
|
||||||
|
jsr unrenderGameObject
|
||||||
|
bra deleteProjectile
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; endProjectile
|
; endProjectile
|
||||||
;
|
;
|
||||||
|
@ -563,6 +622,17 @@ endProjectile:
|
||||||
deleteProjectile:
|
deleteProjectile:
|
||||||
lda #-1
|
lda #-1
|
||||||
sta projectileData+GO_POSX,y
|
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
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue