diff --git a/equates.s b/equates.s index 264ad45..582fa32 100644 --- a/equates.s +++ b/equates.s @@ -63,6 +63,8 @@ JD_VY = 138 JD_TYPE = 140 JD_NEW = 142 JD_STATIC = 144 +JD_OWNER = 146 +JD_FACING = 148 MAXPROJECTILES = 3 diff --git a/fan.s b/fan.s index 2778ee6..3d9d4ec 100644 --- a/fan.s +++ b/fan.s @@ -5,6 +5,10 @@ ; Created by Quinn Dunki on 8/15/18 ; +FANRANGE = 100 ; In pixels +FANMAGNITUDE = $10 ; 12.4 fixed point speed delta, in pixels + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; deployFan ; @@ -36,7 +40,7 @@ updateFan: SAVE_AXY lda projectileData+JD_STATIC,y - bne updateFanDone ; We're already static, so no work to do + bne updateFanWind ; We're set up, so apply our wind ; Wait for fan to collide with us as it falls from the sky lda projectileData+GO_POSX,y @@ -70,6 +74,42 @@ updateFanDone: RESTORE_AXY rts +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 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; renderFan diff --git a/gamemanager.s b/gamemanager.s index 5793d96..6752d41 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -384,7 +384,8 @@ projectileActive: .word -1 ; Y offset of active shot paused: .word 0 - +globalWind: + .word 0 ; 12.4 velocity ; Position of map viewing window. Can be visualized in two ways: ; a) Word-distance from right edge of terrain data (which is in memory right-to-left) to left edge of visible screen diff --git a/gscats.2mg b/gscats.2mg index d459b97..d2c1b25 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/macros.s b/macros.s index 877b385..fe65ea9 100644 --- a/macros.s +++ b/macros.s @@ -233,6 +233,15 @@ jsri_smc: jsr 0 .endmacro +.macro ABSA ; Absolute value of accumulator. Assumes status flags set correctly for accumulator! + .local done + bpl done + eor #$ffff + inc +done: +.endmacro + + ;;;;;;;;;; ; Stack Macros diff --git a/projectile.s b/projectile.s index 2ea0423..7c6a40c 100644 --- a/projectile.s +++ b/projectile.s @@ -22,8 +22,10 @@ projectileData: .word 0 ; Type .word 1 ; New? .word 0 ; Static? + .word 0 ; Owner (player index) + .word 0 ; Facing (0,1) = (+X,-X) - .repeat 110 + .repeat 106 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -43,8 +45,10 @@ projectileData: .word 0 ; Type .word 1 ; New? .word 0 ; Static? + .word 0 ; Owner (player index) + .word 0 ; Facing (0,1) = (+X,-X) - .repeat 110 + .repeat 106 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -64,8 +68,10 @@ projectileData: .word 0 ; Type .word 1 ; New? .word 0 ; Static? + .word 0 ; Owner (player index) + .word 0 ; Facing (0,1) = (+X,-X) - .repeat 110 + .repeat 106 .byte 0 ; Padding to 256-byte boundary .endrepeat @@ -209,7 +215,19 @@ fireProjectile: lda #0 sta projectileData+JD_STATIC,y sty projectileActive + lda currentPlayer + sta projectileData+JD_OWNER,y + ; Set facing. For now assume player orientations are constant + beq fireProjectilePosX + lda #1 + sta projectileData+JD_FACING,y + bra fireProjectileSetup +fireProjectilePosX: + lda #0 + sta projectileData+JD_FACING,y + +fireProjectileSetup: lda projectileParams ; Fixed point version of X pos asl asl @@ -328,13 +346,9 @@ updateProjectilePhysics: SAVE_AXY lda projectileData+GO_POSX,y - bmi updateProjectilePhysicsSkip ; Not allocated + bmi updateProjectilePhysicsDone ; Not allocated lda projectileData+JD_STATIC,y - bne updateProjectilePhysicsSkip ; Static - bra updateProjectilePhysicsActive - -updateProjectilePhysicsSkip: - jmp updateProjectilePhysicsDone + bne updateProjectilePhysicsSpecial ; Static updateProjectilePhysicsActive: ; Integrate gravity over velocity @@ -356,6 +370,7 @@ updateProjectilePhysicsActive: ror clc adc projectileData+JD_PRECISEX,y + adc globalWind ; Add wind sta projectileData+JD_PRECISEX,y ; Convert to integer for rendering @@ -393,6 +408,7 @@ updateProjectilePhysicsContinue: cmp #GAMEOBJECTHEIGHT bmi updateProjectilePhysicsDelete +updateProjectilePhysicsSpecial: ; Check for special update code phy lda projectileData+JD_TYPE,y