Many bug fixes to multi-projectile support

This commit is contained in:
blondie7575 2018-12-26 17:10:25 -07:00
parent 35413e6ad0
commit b06048a9d9
5 changed files with 65 additions and 26 deletions

View File

@ -62,6 +62,7 @@ JD_VX = 136
JD_VY = 138 JD_VY = 138
JD_TYPE = 140 JD_TYPE = 140
JD_NEW = 142 JD_NEW = 142
JD_STATIC = 144
MAXPROJECTILES = 3 MAXPROJECTILES = 3

8
fan.s
View File

@ -35,6 +35,9 @@ deployFan:
updateFan: updateFan:
SAVE_AXY SAVE_AXY
lda projectileData+JD_STATIC,y
bne updateFanDone ; We're already static, so no work to do
; Wait for fan to collide with us as it falls from the sky ; Wait for fan to collide with us as it falls from the sky
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
sta rectParams sta rectParams
@ -50,6 +53,11 @@ updateFan:
cmp #0 cmp #0
beq updateFanDone beq updateFanDone
; Once fan is in place, make it static
lda #1
sta projectileData+JD_STATIC,y
jsr endProjectile
updateFanDone: updateFanDone:
RESTORE_AXY RESTORE_AXY

View File

@ -65,7 +65,14 @@ beginGameplay:
gameplayLoop: gameplayLoop:
jsr kbdScan jsr kbdScan
jsr syncVBL ; BORDER_COLOR #$F
jsr nextVBL
; BORDER_COLOR #$0
; Check for pause
lda paused
bne gameplayLoopEndFrame
;;;;;;;;;;; ;;;;;;;;;;;
; Update ; Update
@ -74,16 +81,13 @@ gameplayLoop:
sta projectilesDirty sta projectilesDirty
lda projectileActive lda projectileActive
bpl gameplayLoopShotTracking ; Skip input during shots bpl gameplayLoopShotTracking ; Skip input during shots
; Check for pause
; lda paused
; bne gameplayLoopEndFrame
bra gameplayLoopScroll bra gameplayLoopScroll
gameplayLoopShotTracking: gameplayLoopShotTracking:
jsr trackActiveShot jsr trackActiveShot
; BORDER_COLOR #$1
gameplayLoopScroll: gameplayLoopScroll:
; Scroll map if needed ; Scroll map if needed
@ -108,8 +112,10 @@ gameplayLoopFire:
beq gameplayLoopRender beq gameplayLoopRender
jsr fire jsr fire
; BORDER_COLOR #$2
gameplayLoopRender: gameplayLoopRender:
sta KBDSTROBE ; sta KBDSTROBE
;;;;;;;;;;; ;;;;;;;;;;;
; Render ; Render
@ -126,6 +132,9 @@ gameplayLoopRender:
jsr renderPlayers jsr renderPlayers
gameplayLoopProjectiles: gameplayLoopProjectiles:
; BORDER_COLOR #$3
lda projectilesDirty lda projectilesDirty
beq gameplayLoopProjectilesSkip beq gameplayLoopProjectilesSkip
@ -142,6 +151,8 @@ gameplayLoopProjectilesSkip:
stz inventoryDirty stz inventoryDirty
jsr renderInventory jsr renderInventory
; BORDER_COLOR #$4
gameplayLoopVictoryCondition: gameplayLoopVictoryCondition:
lda gameOver lda gameOver
bmi gameplayEndTurnCondition bmi gameplayEndTurnCondition
@ -168,7 +179,8 @@ gameplayLoopContinue:
; Trashes SCRATCHL ; Trashes SCRATCHL
; ;
trackActiveShot: trackActiveShot:
lda projectileData+JD_PRECISEX ldy projectileActive
lda projectileData+JD_PRECISEX,y
lsr ; Convert to integer and divide by two for byte distance lsr ; Convert to integer and divide by two for byte distance
lsr lsr
lsr lsr
@ -176,7 +188,7 @@ trackActiveShot:
lsr lsr
sta SCRATCHL ; Save this for later sta SCRATCHL ; Save this for later
lda projectileData+JD_VX lda projectileData+JD_VX,y
bmi trackActiveShotNeg bmi trackActiveShotNeg
; Left-to-right ; Left-to-right
@ -369,7 +381,7 @@ currentPlayer:
gameOver: gameOver:
.word -1 ; Player index of winner .word -1 ; Player index of winner
projectileActive: projectileActive:
.word -1 .word -1 ; Y offset of active shot
paused: paused:
.word 0 .word 0

Binary file not shown.

View File

@ -21,8 +21,9 @@ projectileData:
.word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Velocity Y (8.8 fixed point)
.word 0 ; Type .word 0 ; Type
.word 1 ; New? .word 1 ; New?
.word 0 ; Static?
.repeat 112 .repeat 110
.byte 0 ; Padding to 256-byte boundary .byte 0 ; Padding to 256-byte boundary
.endrepeat .endrepeat
@ -41,8 +42,9 @@ projectileData:
.word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Velocity Y (8.8 fixed point)
.word 0 ; Type .word 0 ; Type
.word 1 ; New? .word 1 ; New?
.word 0 ; Static?
.repeat 112 .repeat 110
.byte 0 ; Padding to 256-byte boundary .byte 0 ; Padding to 256-byte boundary
.endrepeat .endrepeat
@ -61,8 +63,9 @@ projectileData:
.word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Velocity Y (8.8 fixed point)
.word 0 ; Type .word 0 ; Type
.word 1 ; New? .word 1 ; New?
.word 0 ; Static?
.repeat 112 .repeat 110
.byte 0 ; Padding to 256-byte boundary .byte 0 ; Padding to 256-byte boundary
.endrepeat .endrepeat
@ -177,7 +180,7 @@ allocProjectileLoop:
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
bmi allocProjectileDone bmi allocProjectileDone
inx inx
cpx MAXPROJECTILES cpx #MAXPROJECTILES
bne allocProjectileLoop bne allocProjectileLoop
ldy #-1 ldy #-1
@ -203,6 +206,9 @@ fireProjectile:
sta projectileData+GO_POSX,y sta projectileData+GO_POSX,y
lda projectileParams+2 ; Y pos lda projectileParams+2 ; Y pos
sta projectileData+GO_POSY,y sta projectileData+GO_POSY,y
lda #0
sta projectileData+JD_STATIC,y
sty projectileActive
lda projectileParams ; Fixed point version of X pos lda projectileParams ; Fixed point version of X pos
asl asl
@ -241,7 +247,6 @@ fireProjectileStandardDeploy:
fireProjectileFinish: fireProjectileFinish:
lda #1 lda #1
sta projectileData+JD_NEW,y sta projectileData+JD_NEW,y
stz projectileActive
fireProjectileDone: fireProjectileDone:
RESTORE_AXY RESTORE_AXY
@ -323,7 +328,12 @@ updateProjectilePhysics:
SAVE_AXY SAVE_AXY
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
bpl updateProjectilePhysicsActive bmi updateProjectilePhysicsSkip ; Not allocated
lda projectileData+JD_STATIC,y
bne updateProjectilePhysicsSkip ; Static
bra updateProjectilePhysicsActive
updateProjectilePhysicsSkip:
jmp updateProjectilePhysicsDone jmp updateProjectilePhysicsDone
updateProjectilePhysicsActive: updateProjectilePhysicsActive:
@ -398,7 +408,7 @@ updateProjectilePhysicsDone:
rts rts
updateProjectilePhysicsDelete: updateProjectilePhysicsDelete:
jsr endProjectile jsr endDeleteProjectile
bra updateProjectilePhysicsDone bra updateProjectilePhysicsDone
updateProjectilePhysicsNormalUpdate: updateProjectilePhysicsNormalUpdate:
@ -437,8 +447,10 @@ updateProjectileCollisions:
SAVE_AXY SAVE_AXY
; Check for player collisions ; Check for player collisions
lda projectileData+JD_STATIC,y
bne updateProjectileCollisionsDone ; Static
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
bmi updateProjectileCollisionsDone ; Projectile not active bmi updateProjectileCollisionsDone ; Not allocated
sta rectParams sta rectParams
lda projectileData+GO_POSY,y lda projectileData+GO_POSY,y
sta rectParams+2 sta rectParams+2
@ -486,26 +498,34 @@ updateProjectileCollisionsDone:
updateProjectileCollisionsPlayerHit: updateProjectileCollisionsPlayerHit:
jsr processPlayerImpact jsr processPlayerImpact
jsr endProjectile jsr endDeleteProjectile
bra updateProjectileCollisionsDone bra updateProjectileCollisionsDone
updateProjectileCollisionsTerrainHit: updateProjectileCollisionsTerrainHit:
jsr processTerrainImpact jsr processTerrainImpact
jsr endProjectile jsr endDeleteProjectile
bra updateProjectileCollisionsDone bra updateProjectileCollisionsDone
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endProjectile ; endDeleteProjectile
; ;
; Trashes A and Y ; Trashes A and Y
; ;
endProjectile: endDeleteProjectile:
lda #projectileData lda #projectileData
sta PARAML0 sta PARAML0
jsr unrenderGameObject jsr unrenderGameObject
ldy #0 ldy projectileActive
jsr deleteProjectile jsr deleteProjectile
bra endProjectile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endProjectile
;
; Trashes A
;
endProjectile:
lda #1 lda #1
sta turnRequested sta turnRequested
lda #-1 lda #-1
@ -516,11 +536,10 @@ endProjectile:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; deleteProjectile ; deleteProjectile
; ;
; Y = Projectile index ; Y = Projectile offset
; Trashes A ; Trashes A
; ;
deleteProjectile: deleteProjectile:
PROJECTILEPTR_Y
lda #-1 lda #-1
sta projectileData+GO_POSX,y sta projectileData+GO_POSX,y
rts rts
@ -611,7 +630,6 @@ renderProjectilesSkip:
renderProjectile: renderProjectile:
SAVE_AXY SAVE_AXY
PROJECTILEPTR_Y
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
bpl renderProjectileDoIt bpl renderProjectileDoIt
jmp renderProjectileDone jmp renderProjectileDone