Support for local and global wind

This commit is contained in:
blondie7575 2018-12-29 11:33:08 -07:00
parent c6d1fd00b2
commit 32c622afbe
6 changed files with 79 additions and 11 deletions

View File

@ -63,6 +63,8 @@ JD_VY = 138
JD_TYPE = 140
JD_NEW = 142
JD_STATIC = 144
JD_OWNER = 146
JD_FACING = 148
MAXPROJECTILES = 3

42
fan.s
View File

@ -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

View File

@ -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

Binary file not shown.

View File

@ -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

View File

@ -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