diff --git a/equates.s b/equates.s index 9ae651b..264ad45 100644 --- a/equates.s +++ b/equates.s @@ -62,6 +62,7 @@ JD_VX = 136 JD_VY = 138 JD_TYPE = 140 JD_NEW = 142 +JD_STATIC = 144 MAXPROJECTILES = 3 diff --git a/fan.s b/fan.s index f2c6fb6..5ae01f2 100644 --- a/fan.s +++ b/fan.s @@ -35,6 +35,9 @@ deployFan: updateFan: 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 lda projectileData+GO_POSX,y sta rectParams @@ -50,6 +53,11 @@ updateFan: cmp #0 beq updateFanDone + ; Once fan is in place, make it static + lda #1 + sta projectileData+JD_STATIC,y + jsr endProjectile + updateFanDone: RESTORE_AXY diff --git a/gamemanager.s b/gamemanager.s index fa2feef..5793d96 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -65,7 +65,14 @@ beginGameplay: gameplayLoop: jsr kbdScan - jsr syncVBL +; BORDER_COLOR #$F + jsr nextVBL + +; BORDER_COLOR #$0 + + ; Check for pause + lda paused + bne gameplayLoopEndFrame ;;;;;;;;;;; ; Update @@ -74,16 +81,13 @@ gameplayLoop: sta projectilesDirty lda projectileActive bpl gameplayLoopShotTracking ; Skip input during shots - - ; Check for pause -; lda paused -; bne gameplayLoopEndFrame - bra gameplayLoopScroll gameplayLoopShotTracking: jsr trackActiveShot +; BORDER_COLOR #$1 + gameplayLoopScroll: ; Scroll map if needed @@ -108,8 +112,10 @@ gameplayLoopFire: beq gameplayLoopRender jsr fire +; BORDER_COLOR #$2 + gameplayLoopRender: - sta KBDSTROBE +; sta KBDSTROBE ;;;;;;;;;;; ; Render @@ -126,6 +132,9 @@ gameplayLoopRender: jsr renderPlayers gameplayLoopProjectiles: + +; BORDER_COLOR #$3 + lda projectilesDirty beq gameplayLoopProjectilesSkip @@ -142,6 +151,8 @@ gameplayLoopProjectilesSkip: stz inventoryDirty jsr renderInventory +; BORDER_COLOR #$4 + gameplayLoopVictoryCondition: lda gameOver bmi gameplayEndTurnCondition @@ -168,7 +179,8 @@ gameplayLoopContinue: ; Trashes SCRATCHL ; trackActiveShot: - lda projectileData+JD_PRECISEX + ldy projectileActive + lda projectileData+JD_PRECISEX,y lsr ; Convert to integer and divide by two for byte distance lsr lsr @@ -176,7 +188,7 @@ trackActiveShot: lsr sta SCRATCHL ; Save this for later - lda projectileData+JD_VX + lda projectileData+JD_VX,y bmi trackActiveShotNeg ; Left-to-right @@ -369,7 +381,7 @@ currentPlayer: gameOver: .word -1 ; Player index of winner projectileActive: - .word -1 + .word -1 ; Y offset of active shot paused: .word 0 diff --git a/gscats.2mg b/gscats.2mg index 857dc3c..5cd9fa0 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/projectile.s b/projectile.s index 8ed0e16..5e8cb6a 100644 --- a/projectile.s +++ b/projectile.s @@ -21,8 +21,9 @@ projectileData: .word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Type .word 1 ; New? + .word 0 ; Static? - .repeat 112 + .repeat 110 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -41,8 +42,9 @@ projectileData: .word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Type .word 1 ; New? + .word 0 ; Static? - .repeat 112 + .repeat 110 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -61,8 +63,9 @@ projectileData: .word 0 ; Velocity Y (8.8 fixed point) .word 0 ; Type .word 1 ; New? + .word 0 ; Static? - .repeat 112 + .repeat 110 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -177,7 +180,7 @@ allocProjectileLoop: lda projectileData+GO_POSX,y bmi allocProjectileDone inx - cpx MAXPROJECTILES + cpx #MAXPROJECTILES bne allocProjectileLoop ldy #-1 @@ -203,6 +206,9 @@ fireProjectile: sta projectileData+GO_POSX,y lda projectileParams+2 ; Y pos sta projectileData+GO_POSY,y + lda #0 + sta projectileData+JD_STATIC,y + sty projectileActive lda projectileParams ; Fixed point version of X pos asl @@ -241,7 +247,6 @@ fireProjectileStandardDeploy: fireProjectileFinish: lda #1 sta projectileData+JD_NEW,y - stz projectileActive fireProjectileDone: RESTORE_AXY @@ -323,7 +328,12 @@ updateProjectilePhysics: SAVE_AXY lda projectileData+GO_POSX,y - bpl updateProjectilePhysicsActive + bmi updateProjectilePhysicsSkip ; Not allocated + lda projectileData+JD_STATIC,y + bne updateProjectilePhysicsSkip ; Static + bra updateProjectilePhysicsActive + +updateProjectilePhysicsSkip: jmp updateProjectilePhysicsDone updateProjectilePhysicsActive: @@ -398,7 +408,7 @@ updateProjectilePhysicsDone: rts updateProjectilePhysicsDelete: - jsr endProjectile + jsr endDeleteProjectile bra updateProjectilePhysicsDone updateProjectilePhysicsNormalUpdate: @@ -437,8 +447,10 @@ updateProjectileCollisions: SAVE_AXY ; Check for player collisions + lda projectileData+JD_STATIC,y + bne updateProjectileCollisionsDone ; Static lda projectileData+GO_POSX,y - bmi updateProjectileCollisionsDone ; Projectile not active + bmi updateProjectileCollisionsDone ; Not allocated sta rectParams lda projectileData+GO_POSY,y sta rectParams+2 @@ -486,26 +498,34 @@ updateProjectileCollisionsDone: updateProjectileCollisionsPlayerHit: jsr processPlayerImpact - jsr endProjectile + jsr endDeleteProjectile bra updateProjectileCollisionsDone updateProjectileCollisionsTerrainHit: jsr processTerrainImpact - jsr endProjectile + jsr endDeleteProjectile bra updateProjectileCollisionsDone ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; endProjectile +; endDeleteProjectile ; ; Trashes A and Y ; -endProjectile: +endDeleteProjectile: lda #projectileData sta PARAML0 jsr unrenderGameObject - ldy #0 + ldy projectileActive jsr deleteProjectile + bra endProjectile + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; endProjectile +; +; Trashes A +; +endProjectile: lda #1 sta turnRequested lda #-1 @@ -516,11 +536,10 @@ endProjectile: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; deleteProjectile ; -; Y = Projectile index +; Y = Projectile offset ; Trashes A ; deleteProjectile: - PROJECTILEPTR_Y lda #-1 sta projectileData+GO_POSX,y rts @@ -611,7 +630,6 @@ renderProjectilesSkip: renderProjectile: SAVE_AXY - PROJECTILEPTR_Y lda projectileData+GO_POSX,y bpl renderProjectileDoIt jmp renderProjectileDone