2017-08-20 22:15:46 +00:00
|
|
|
;
|
|
|
|
; projectile
|
|
|
|
; Code and data structures related to the projectiles
|
|
|
|
;
|
|
|
|
; Created by Quinn Dunki on 8/13/17
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
projectileData:
|
2018-06-10 02:29:00 +00:00
|
|
|
; Gameobject data (we're a subclass, effectively)
|
2017-08-23 03:33:07 +00:00
|
|
|
.word -1 ; Pos X in pixels (from left terrain edge)
|
|
|
|
.word 0 ; Pos Y in pixels (from bottom terrain edge)
|
2017-08-27 05:34:49 +00:00
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
2017-09-30 00:53:05 +00:00
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
2017-08-20 22:15:46 +00:00
|
|
|
|
2017-08-23 03:57:07 +00:00
|
|
|
.word 0 ; Pos X (12.4 fixed point)
|
|
|
|
.word 0 ; Pos Y (12.4 fixed point)
|
2017-08-25 04:45:05 +00:00
|
|
|
.word 0 ; Velocity X (8.8 fixed point)
|
|
|
|
.word 0 ; Velocity Y (8.8 fixed point)
|
2017-09-04 00:20:24 +00:00
|
|
|
.word 0 ; Type
|
2017-09-05 19:48:30 +00:00
|
|
|
.word 1 ; New?
|
2018-12-27 00:10:25 +00:00
|
|
|
.word 0 ; Static?
|
2018-12-29 18:33:08 +00:00
|
|
|
.word 0 ; Owner (player index)
|
|
|
|
.word 0 ; Facing (0,1) = (+X,-X)
|
2018-12-30 00:13:03 +00:00
|
|
|
.word 0 ; Scratch space for subclasses
|
2018-12-30 00:45:40 +00:00
|
|
|
.word 0 ; Age (in turns)
|
2021-07-24 21:41:48 +00:00
|
|
|
.word 0 ; Deployment delay needed?
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2021-07-24 21:41:48 +00:00
|
|
|
.repeat 100
|
2017-09-30 00:53:05 +00:00
|
|
|
.byte 0 ; Padding to 256-byte boundary
|
|
|
|
.endrepeat
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
|
|
|
|
; Gameobject data (we're a subclass, effectively)
|
|
|
|
.word -1 ; Pos X in pixels (from left terrain edge)
|
|
|
|
.word 0 ; Pos Y in pixels (from bottom terrain edge)
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
|
|
|
|
.word 0 ; Pos X (12.4 fixed point)
|
|
|
|
.word 0 ; Pos Y (12.4 fixed point)
|
|
|
|
.word 0 ; Velocity X (8.8 fixed point)
|
|
|
|
.word 0 ; Velocity Y (8.8 fixed point)
|
|
|
|
.word 0 ; Type
|
|
|
|
.word 1 ; New?
|
2018-12-27 00:10:25 +00:00
|
|
|
.word 0 ; Static?
|
2018-12-29 18:33:08 +00:00
|
|
|
.word 0 ; Owner (player index)
|
|
|
|
.word 0 ; Facing (0,1) = (+X,-X)
|
2018-12-30 00:13:03 +00:00
|
|
|
.word 0 ; Scratch space for subclasses
|
2018-12-30 00:45:40 +00:00
|
|
|
.word 0 ; Age (in turns)
|
2018-12-24 00:39:22 +00:00
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
.repeat 102
|
2018-12-24 00:39:22 +00:00
|
|
|
.byte 0 ; Padding to 256-byte boundary
|
|
|
|
.endrepeat
|
|
|
|
|
|
|
|
|
|
|
|
; Gameobject data (we're a subclass, effectively)
|
|
|
|
.word -1 ; Pos X in pixels (from left terrain edge)
|
|
|
|
.word 0 ; Pos Y in pixels (from bottom terrain edge)
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
|
|
|
|
.word 0 ; Pos X (12.4 fixed point)
|
|
|
|
.word 0 ; Pos Y (12.4 fixed point)
|
|
|
|
.word 0 ; Velocity X (8.8 fixed point)
|
|
|
|
.word 0 ; Velocity Y (8.8 fixed point)
|
|
|
|
.word 0 ; Type
|
|
|
|
.word 1 ; New?
|
2018-12-27 00:10:25 +00:00
|
|
|
.word 0 ; Static?
|
2018-12-29 18:33:08 +00:00
|
|
|
.word 0 ; Owner (player index)
|
|
|
|
.word 0 ; Facing (0,1) = (+X,-X)
|
2018-12-30 00:13:03 +00:00
|
|
|
.word 0 ; Scratch space for subclasses
|
2018-12-30 00:45:40 +00:00
|
|
|
.word 0 ; Age (in turns)
|
2018-12-24 00:39:22 +00:00
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
.repeat 102
|
2018-12-24 00:39:22 +00:00
|
|
|
.byte 0 ; Padding to 256-byte boundary
|
|
|
|
.endrepeat
|
|
|
|
|
|
|
|
|
|
|
|
; Byte offsets for that-^ data structure can be found in equates.s
|
2017-08-20 22:15:46 +00:00
|
|
|
|
2018-06-10 02:29:00 +00:00
|
|
|
|
2018-12-30 01:30:51 +00:00
|
|
|
GRAVITY = $fffa ; 8.8 fixed point
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2018-06-10 02:29:00 +00:00
|
|
|
projectileTypes:
|
2018-12-22 18:41:12 +00:00
|
|
|
PT_SPIT = 0
|
|
|
|
PT_BOMB = 1
|
|
|
|
PT_FAN = 2
|
|
|
|
|
2018-06-10 02:29:00 +00:00
|
|
|
; Spit
|
|
|
|
.word 3 ; Damage
|
2018-06-12 00:01:19 +00:00
|
|
|
.word 3 ; Crater radius
|
2018-06-10 02:29:00 +00:00
|
|
|
.word 4 ; Frame 0
|
2018-08-06 20:00:13 +00:00
|
|
|
.word 6 ; Frame 1
|
|
|
|
.word 8 ; Frame 2
|
2018-12-22 18:41:12 +00:00
|
|
|
.addr 0 ; Deploy
|
|
|
|
.addr 0 ; Update
|
|
|
|
.addr 0 ; Render
|
2018-12-30 00:45:40 +00:00
|
|
|
.addr 0 ; Cleanup
|
2018-12-30 01:10:21 +00:00
|
|
|
.word 1 ; Directional
|
2018-06-10 02:29:00 +00:00
|
|
|
|
2018-12-30 01:10:21 +00:00
|
|
|
.repeat 12
|
2018-12-30 00:45:40 +00:00
|
|
|
.byte 0 ; Padding to 32-byte boundary
|
|
|
|
.endrepeat
|
2018-06-10 02:29:00 +00:00
|
|
|
|
|
|
|
; Bomb
|
2017-09-04 00:20:24 +00:00
|
|
|
.word 50 ; Damage
|
2017-10-27 03:15:52 +00:00
|
|
|
.word 10 ; Crater radius
|
2018-06-10 02:29:00 +00:00
|
|
|
.word 3 ; Frame 0
|
|
|
|
.word 3 ; Frame 1
|
|
|
|
.word 3 ; Frame 2
|
2018-12-22 18:41:12 +00:00
|
|
|
.addr 0 ; Deploy
|
|
|
|
.addr 0 ; Update
|
|
|
|
.addr 0 ; Render
|
2018-12-30 00:45:40 +00:00
|
|
|
.addr 0 ; Cleanup
|
2018-12-30 01:10:21 +00:00
|
|
|
.word 0 ; Directional
|
2018-06-10 02:29:00 +00:00
|
|
|
|
2018-12-30 01:10:21 +00:00
|
|
|
.repeat 12
|
2018-12-30 00:45:40 +00:00
|
|
|
.byte 0 ; Padding to 32-byte boundary
|
|
|
|
.endrepeat
|
2017-09-04 00:20:24 +00:00
|
|
|
|
2018-07-30 19:36:44 +00:00
|
|
|
; Fan
|
|
|
|
.word 3 ; Damage
|
|
|
|
.word 3 ; Crater radius
|
2018-08-06 20:00:13 +00:00
|
|
|
.word 12 ; Frame 0
|
|
|
|
.word 12 ; Frame 1
|
|
|
|
.word 12 ; Frame 2
|
2018-12-22 18:41:12 +00:00
|
|
|
.addr deployFan ; Deploy
|
|
|
|
.addr updateFan ; Update
|
2018-12-27 00:29:13 +00:00
|
|
|
.addr renderFan ; Render
|
2018-12-30 00:45:40 +00:00
|
|
|
.addr deleteFan ; Cleanup
|
2018-12-30 01:10:21 +00:00
|
|
|
.word 1 ; Directional
|
2018-07-30 19:36:44 +00:00
|
|
|
|
2018-12-30 01:10:21 +00:00
|
|
|
.repeat 12
|
2018-12-30 00:45:40 +00:00
|
|
|
.byte 0 ; Padding to 32-byte boundary
|
|
|
|
.endrepeat
|
2018-07-30 19:36:44 +00:00
|
|
|
|
2018-06-10 02:29:00 +00:00
|
|
|
|
|
|
|
PT_DAMAGE = 0 ; Byte offsets into projectile type data structure
|
2017-09-13 13:53:40 +00:00
|
|
|
PT_RADIUS = 2
|
2018-06-10 02:29:00 +00:00
|
|
|
PT_FRAME0 = 4
|
|
|
|
PT_FRAME1 = 6
|
|
|
|
PT_FRAME2 = 8
|
2018-12-22 18:41:12 +00:00
|
|
|
PT_DEPLOY = 10
|
|
|
|
PT_UPDATE = 12
|
|
|
|
PT_RENDER = 14
|
2018-12-30 00:45:40 +00:00
|
|
|
PT_CLEANUP = 16
|
2018-12-30 01:10:21 +00:00
|
|
|
PT_DIRECTIONAL = 18
|
2017-08-25 04:45:05 +00:00
|
|
|
|
|
|
|
.macro PROJECTILEPTR_Y
|
2017-08-27 05:34:49 +00:00
|
|
|
tya ; Pointer to projectile structure from index
|
2017-08-25 04:45:05 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2017-09-30 00:53:05 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2017-08-25 04:45:05 +00:00
|
|
|
tay
|
|
|
|
.endmacro
|
|
|
|
|
2017-09-04 00:20:24 +00:00
|
|
|
.macro PROJECTILETYPEPTR_Y
|
|
|
|
tya ; Pointer to projectile type structure from index
|
|
|
|
asl
|
|
|
|
asl
|
2018-06-10 02:29:00 +00:00
|
|
|
asl
|
|
|
|
asl
|
2018-12-30 00:45:40 +00:00
|
|
|
asl
|
2017-09-04 00:20:24 +00:00
|
|
|
tay
|
|
|
|
.endmacro
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
.macro PROJECTILETYPEPTR_X
|
|
|
|
txa ; Pointer to projectile type structure from index
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2018-12-30 00:45:40 +00:00
|
|
|
asl
|
2018-12-24 00:39:22 +00:00
|
|
|
tax
|
|
|
|
.endmacro
|
2017-08-20 22:15:46 +00:00
|
|
|
|
|
|
|
projectileParams:
|
|
|
|
.word 0 ; Starting pos X
|
|
|
|
.word 0 ; Starting pos Y
|
|
|
|
.word 0 ; Initial angle
|
|
|
|
.word 0 ; Initial power
|
2018-06-11 22:00:02 +00:00
|
|
|
.word 0 ; Type
|
2017-08-20 22:15:46 +00:00
|
|
|
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; allocProjectile
|
|
|
|
;
|
|
|
|
; Returns offset of projectile structure in Y, or -1 if none available
|
|
|
|
;
|
|
|
|
allocProjectile:
|
|
|
|
SAVE_AX
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
allocProjectileLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
bmi allocProjectileDone
|
|
|
|
inx
|
2018-12-27 00:10:25 +00:00
|
|
|
cpx #MAXPROJECTILES
|
2018-12-24 00:39:22 +00:00
|
|
|
bne allocProjectileLoop
|
|
|
|
ldy #-1
|
|
|
|
|
|
|
|
allocProjectileDone:
|
|
|
|
RESTORE_AX
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-08-20 22:15:46 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; fireProjectile
|
|
|
|
;
|
|
|
|
;
|
|
|
|
fireProjectile:
|
|
|
|
SAVE_AXY
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
; Allocate a projectile
|
|
|
|
jsr allocProjectile
|
|
|
|
cpy #-1
|
|
|
|
beq fireProjectileDone
|
2017-08-20 22:15:46 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
; Set up projectile structure
|
2017-08-21 00:51:12 +00:00
|
|
|
lda projectileParams ; X pos
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSX,y
|
2017-08-21 00:51:12 +00:00
|
|
|
lda projectileParams+2 ; Y pos
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSY,y
|
2018-12-27 00:10:25 +00:00
|
|
|
lda #0
|
|
|
|
sta projectileData+JD_STATIC,y
|
2018-12-30 00:45:40 +00:00
|
|
|
sta projectileData+JD_AGE,y
|
2018-12-27 00:10:25 +00:00
|
|
|
sty projectileActive
|
2018-12-29 18:33:08 +00:00
|
|
|
lda currentPlayer
|
|
|
|
sta projectileData+JD_OWNER,y
|
2017-08-21 00:51:12 +00:00
|
|
|
|
2018-12-29 18:33:08 +00:00
|
|
|
; 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:
|
2017-08-23 03:33:07 +00:00
|
|
|
lda projectileParams ; Fixed point version of X pos
|
2017-08-23 03:57:07 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+JD_PRECISEX,y
|
2017-08-23 03:33:07 +00:00
|
|
|
|
|
|
|
lda projectileParams+2 ; Fixed point version of Y pos
|
2017-08-23 03:57:07 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+JD_PRECISEY,y
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
lda projectileParams+8 ; Type
|
|
|
|
sta projectileData+JD_TYPE,y
|
|
|
|
|
|
|
|
; Check for special deployment code
|
|
|
|
phy
|
|
|
|
tay ; Find projectile type data
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
|
|
|
|
lda projectileTypes+PT_DEPLOY,y
|
|
|
|
beq fireProjectileStandardDeploy
|
|
|
|
ply
|
|
|
|
JSRA
|
|
|
|
bra fireProjectileFinish
|
|
|
|
|
|
|
|
fireProjectileStandardDeploy:
|
|
|
|
ply
|
|
|
|
|
|
|
|
; Standard physics setup
|
|
|
|
jsr prepareProjectilePhysics
|
|
|
|
|
|
|
|
fireProjectileFinish:
|
|
|
|
lda #1
|
|
|
|
sta projectileData+JD_NEW,y
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
fireProjectileDone:
|
2018-12-22 18:41:12 +00:00
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; prepareProjectilePhysics
|
|
|
|
;
|
|
|
|
; Y: Index to projectile structure
|
|
|
|
;
|
|
|
|
prepareProjectilePhysics:
|
|
|
|
SAVE_AXY
|
|
|
|
|
2017-09-05 19:07:33 +00:00
|
|
|
lda projectileParams+6 ; Convert power to 8.8
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta projectileParams+6
|
|
|
|
|
2017-08-21 00:51:12 +00:00
|
|
|
lda projectileParams+4 ; Convert angle to vector
|
|
|
|
asl
|
|
|
|
tax
|
2017-09-05 19:07:33 +00:00
|
|
|
lda angleToVectorX,x ; Velocity X (unit vector)
|
|
|
|
|
|
|
|
sta PARAML1
|
|
|
|
lda projectileParams+6 ; Scale by power
|
|
|
|
sta PARAML0
|
|
|
|
jsr mult88
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+JD_VX,y
|
2017-08-21 00:51:12 +00:00
|
|
|
|
|
|
|
lda projectileParams+4 ; Convert angle to vector
|
|
|
|
asl
|
|
|
|
tax
|
2017-09-05 19:07:33 +00:00
|
|
|
lda angleToVectorY,x ; Velocity Y (unit vector)
|
|
|
|
sta PARAML1
|
|
|
|
lda projectileParams+6 ; Scale by power
|
|
|
|
sta PARAML0
|
|
|
|
jsr mult88
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+JD_VY,y
|
2017-08-20 22:15:46 +00:00
|
|
|
|
2017-08-23 03:33:07 +00:00
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
2017-08-20 22:15:46 +00:00
|
|
|
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; updateProjectilesPhysics
|
|
|
|
;
|
|
|
|
;
|
|
|
|
updateProjectilesPhysics:
|
|
|
|
SAVE_AXY
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
updateProjectilesPhysicsLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
jsr updateProjectilePhysics
|
|
|
|
|
|
|
|
updateProjectilesPhysicsSkip:
|
|
|
|
inx
|
|
|
|
cpx #MAXPROJECTILES
|
|
|
|
bne updateProjectilesPhysicsLoop
|
|
|
|
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-08-23 03:33:07 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2017-09-13 13:53:40 +00:00
|
|
|
; updateProjectilePhysics
|
2017-08-23 03:33:07 +00:00
|
|
|
;
|
2018-12-24 00:39:22 +00:00
|
|
|
; Y = Offset to projectile structure
|
2017-08-23 03:33:07 +00:00
|
|
|
;
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysics:
|
2018-12-24 00:39:22 +00:00
|
|
|
SAVE_AXY
|
2017-09-13 13:53:40 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
2018-12-29 18:33:08 +00:00
|
|
|
bmi updateProjectilePhysicsDone ; Not allocated
|
2018-12-27 00:10:25 +00:00
|
|
|
lda projectileData+JD_STATIC,y
|
2018-12-29 18:33:08 +00:00
|
|
|
bne updateProjectilePhysicsSpecial ; Static
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysicsActive:
|
2017-08-25 04:45:05 +00:00
|
|
|
; Integrate gravity over velocity
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+JD_VY,y
|
2017-08-25 04:45:05 +00:00
|
|
|
clc
|
|
|
|
adc #GRAVITY
|
2018-12-24 00:39:22 +00:00
|
|
|
sta projectileData+JD_VY,y
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-08-23 03:33:07 +00:00
|
|
|
; Integrate X velocity over position
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+JD_VX,y
|
2017-08-25 04:45:05 +00:00
|
|
|
; Convert 8.8 to 12.4
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
2017-08-23 03:33:07 +00:00
|
|
|
clc
|
2018-12-24 00:39:22 +00:00
|
|
|
adc projectileData+JD_PRECISEX,y
|
2018-12-29 18:33:08 +00:00
|
|
|
adc globalWind ; Add wind
|
2018-12-24 00:39:22 +00:00
|
|
|
sta projectileData+JD_PRECISEX,y
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
; Convert to integer for rendering
|
2017-08-23 03:33:07 +00:00
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
2018-12-24 00:39:22 +00:00
|
|
|
sta projectileData+GO_POSX,y
|
2017-09-13 13:53:40 +00:00
|
|
|
bmi updateProjectilePhysicsDelete
|
2017-08-25 04:45:05 +00:00
|
|
|
cmp #TERRAINWIDTH-GAMEOBJECTWIDTH-1
|
2017-09-13 13:53:40 +00:00
|
|
|
bpl updateProjectilePhysicsDelete
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysicsContinue:
|
2017-08-23 03:33:07 +00:00
|
|
|
; Integrate Y velocity over position
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+JD_VY,y
|
2017-08-25 04:45:05 +00:00
|
|
|
; Convert 8.8 to 12.4
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
|
|
|
cmp #$8000
|
|
|
|
ror
|
2017-08-23 03:33:07 +00:00
|
|
|
clc
|
2018-12-24 00:39:22 +00:00
|
|
|
adc projectileData+JD_PRECISEY,y
|
|
|
|
sta projectileData+JD_PRECISEY,y
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
; Convert to integer for rendering
|
2017-08-23 03:33:07 +00:00
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
2018-12-24 00:39:22 +00:00
|
|
|
sta projectileData+GO_POSY,y
|
2017-08-31 19:55:02 +00:00
|
|
|
cmp #GAMEOBJECTHEIGHT
|
2017-09-13 13:53:40 +00:00
|
|
|
bmi updateProjectilePhysicsDelete
|
|
|
|
|
2018-12-29 18:33:08 +00:00
|
|
|
updateProjectilePhysicsSpecial:
|
2018-12-22 18:41:12 +00:00
|
|
|
; Check for special update code
|
2018-12-24 00:39:22 +00:00
|
|
|
phy
|
2018-12-22 18:41:12 +00:00
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
lda projectileTypes+PT_UPDATE,y
|
2018-12-24 00:39:22 +00:00
|
|
|
beq updateProjectilePhysicsNormalUpdate
|
|
|
|
ply
|
2018-12-22 18:41:12 +00:00
|
|
|
JSRA
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysicsDone:
|
2018-12-24 00:39:22 +00:00
|
|
|
RESTORE_AXY
|
2017-09-13 13:53:40 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
updateProjectilePhysicsDelete:
|
2018-12-30 00:45:40 +00:00
|
|
|
jsr endDeleteCurrProjectile
|
2017-09-13 13:53:40 +00:00
|
|
|
bra updateProjectilePhysicsDone
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
updateProjectilePhysicsNormalUpdate:
|
|
|
|
ply
|
|
|
|
bra updateProjectilePhysicsDone
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; updateProjectilesCollisions
|
|
|
|
;
|
|
|
|
;
|
|
|
|
updateProjectilesCollisions:
|
|
|
|
SAVE_AXY
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
updateProjectilesCollisionsLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
jsr updateProjectileCollisions
|
|
|
|
|
|
|
|
updateProjectilesCollisionsSkip:
|
|
|
|
inx
|
|
|
|
cpx #MAXPROJECTILES
|
|
|
|
bne updateProjectilesCollisionsLoop
|
|
|
|
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; updateProjectileCollisions
|
|
|
|
;
|
2018-12-24 00:39:22 +00:00
|
|
|
; Y = Offset to projectile structure
|
2017-09-13 13:53:40 +00:00
|
|
|
;
|
|
|
|
updateProjectileCollisions:
|
2018-12-24 00:39:22 +00:00
|
|
|
SAVE_AXY
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-09-03 03:52:19 +00:00
|
|
|
; Check for player collisions
|
2018-12-27 00:10:25 +00:00
|
|
|
lda projectileData+JD_STATIC,y
|
|
|
|
bne updateProjectileCollisionsDone ; Static
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
2018-12-27 00:10:25 +00:00
|
|
|
bmi updateProjectileCollisionsDone ; Not allocated
|
2017-09-03 03:52:19 +00:00
|
|
|
sta rectParams
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSY,y
|
2017-09-03 03:52:19 +00:00
|
|
|
sta rectParams+2
|
|
|
|
lda #GAMEOBJECTWIDTH
|
|
|
|
sta rectParams+4
|
|
|
|
lda #GAMEOBJECTHEIGHT
|
|
|
|
sta rectParams+6
|
2018-12-24 00:39:22 +00:00
|
|
|
ldx #0
|
2017-09-03 03:52:19 +00:00
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectileCollisionsPlayerLoop:
|
2018-12-24 00:39:22 +00:00
|
|
|
cpx currentPlayer
|
2017-09-30 00:53:05 +00:00
|
|
|
beq updateProjectileCollisionsPlayerNext
|
|
|
|
|
2017-09-03 03:52:19 +00:00
|
|
|
jsr playerIntersectRect
|
|
|
|
cmp #0
|
2017-09-13 13:53:40 +00:00
|
|
|
bne updateProjectileCollisionsPlayerHit
|
2017-09-03 03:52:19 +00:00
|
|
|
|
2017-09-30 00:53:05 +00:00
|
|
|
updateProjectileCollisionsPlayerNext:
|
2018-12-24 00:39:22 +00:00
|
|
|
inx
|
|
|
|
cpx #NUMPLAYERS
|
2017-09-30 00:53:05 +00:00
|
|
|
bne updateProjectileCollisionsPlayerLoop
|
2017-09-03 03:52:19 +00:00
|
|
|
|
2017-08-31 19:55:02 +00:00
|
|
|
; Check for terrain collisions
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
2017-10-27 03:15:52 +00:00
|
|
|
inc
|
2017-10-27 03:22:12 +00:00
|
|
|
inc
|
2017-08-31 19:55:02 +00:00
|
|
|
sta rectParams
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSY,y
|
2017-10-27 03:15:52 +00:00
|
|
|
clc
|
|
|
|
inc
|
2017-10-27 03:22:12 +00:00
|
|
|
inc
|
2017-08-31 19:55:02 +00:00
|
|
|
sta rectParams+2
|
2017-10-27 03:22:12 +00:00
|
|
|
lda #GAMEOBJECTWIDTH-4
|
2017-08-31 19:55:02 +00:00
|
|
|
sta rectParams+4
|
2017-10-27 03:22:12 +00:00
|
|
|
lda #GAMEOBJECTHEIGHT-4
|
2017-08-31 19:55:02 +00:00
|
|
|
sta rectParams+6
|
|
|
|
|
2017-09-03 03:52:19 +00:00
|
|
|
jsr intersectRectTerrain
|
2017-08-31 19:55:02 +00:00
|
|
|
cmp #0
|
2017-09-13 13:53:40 +00:00
|
|
|
bne updateProjectileCollisionsTerrainHit
|
2017-08-31 19:55:02 +00:00
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectileCollisionsDone:
|
2018-12-24 00:39:22 +00:00
|
|
|
RESTORE_AXY
|
2017-08-25 04:45:05 +00:00
|
|
|
rts
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectileCollisionsPlayerHit:
|
|
|
|
jsr processPlayerImpact
|
2018-12-30 00:45:40 +00:00
|
|
|
jsr endDeleteCurrProjectile
|
2017-09-13 13:53:40 +00:00
|
|
|
bra updateProjectileCollisionsDone
|
|
|
|
|
|
|
|
updateProjectileCollisionsTerrainHit:
|
|
|
|
jsr processTerrainImpact
|
2018-12-30 00:45:40 +00:00
|
|
|
jsr endDeleteCurrProjectile
|
2017-09-13 13:53:40 +00:00
|
|
|
bra updateProjectileCollisionsDone
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2018-12-30 00:45:40 +00:00
|
|
|
; 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
|
2017-09-13 13:53:40 +00:00
|
|
|
;
|
|
|
|
; Trashes A and Y
|
|
|
|
;
|
2018-12-30 00:45:40 +00:00
|
|
|
endDeleteCurrProjectile:
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
2018-12-30 00:13:03 +00:00
|
|
|
clc
|
|
|
|
adc projectileActive
|
2017-10-27 03:15:52 +00:00
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
2018-12-27 00:10:25 +00:00
|
|
|
ldy projectileActive
|
2017-08-25 04:45:05 +00:00
|
|
|
jsr deleteProjectile
|
2018-12-27 00:10:25 +00:00
|
|
|
bra endProjectile
|
|
|
|
|
2018-12-30 00:45:40 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; deleteVisibleProjectile
|
|
|
|
;
|
|
|
|
; Y = Projectile offset
|
|
|
|
; Trashes A
|
|
|
|
;
|
|
|
|
deleteVisibleProjectile:
|
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
|
|
|
bra deleteProjectile
|
|
|
|
|
|
|
|
|
2018-12-27 00:10:25 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; endProjectile
|
|
|
|
;
|
|
|
|
; Trashes A
|
|
|
|
;
|
|
|
|
endProjectile:
|
2017-09-03 00:31:12 +00:00
|
|
|
lda #1
|
|
|
|
sta turnRequested
|
2017-09-05 19:48:30 +00:00
|
|
|
lda #-1
|
|
|
|
sta projectileActive
|
2017-09-13 13:53:40 +00:00
|
|
|
rts
|
2017-09-03 03:52:19 +00:00
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; deleteProjectile
|
|
|
|
;
|
2018-12-27 00:10:25 +00:00
|
|
|
; Y = Projectile offset
|
2017-08-25 04:45:05 +00:00
|
|
|
; Trashes A
|
|
|
|
;
|
|
|
|
deleteProjectile:
|
|
|
|
lda #-1
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSX,y
|
2018-12-30 00:45:40 +00:00
|
|
|
|
|
|
|
; 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:
|
2017-08-25 04:45:05 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-10-22 20:44:05 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; protectProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
protectProjectiles:
|
|
|
|
SAVE_AXY
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
ldx #0
|
2017-10-22 20:44:05 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
protectProjectilesLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
bpl protectProjectilesGotOne
|
|
|
|
|
|
|
|
protectProjectilesContinue:
|
|
|
|
inx
|
|
|
|
cpx #MAXPROJECTILES
|
|
|
|
beq protectProjectilesDone
|
|
|
|
bra protectProjectilesLoop
|
|
|
|
|
|
|
|
protectProjectilesGotOne:
|
|
|
|
lda #projectileData+GO_POSX
|
2017-10-27 03:15:52 +00:00
|
|
|
sta PARAML0
|
2018-12-24 00:39:22 +00:00
|
|
|
clc
|
|
|
|
tya
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
|
|
|
phx
|
2017-10-27 03:15:52 +00:00
|
|
|
jsr vramPtr
|
2019-02-23 00:00:48 +00:00
|
|
|
cpx #$ffff
|
2018-12-24 00:39:22 +00:00
|
|
|
beq protectProjectilesOffscreen
|
2017-10-27 03:15:52 +00:00
|
|
|
|
2017-10-22 20:44:05 +00:00
|
|
|
lda #projectileData+GO_BACKGROUND
|
2018-12-24 00:39:22 +00:00
|
|
|
sta PARAML0
|
|
|
|
clc
|
|
|
|
tya
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
2017-10-22 20:44:05 +00:00
|
|
|
jsr protectGameObject
|
2018-12-24 00:39:22 +00:00
|
|
|
plx
|
|
|
|
bra protectProjectilesContinue
|
2017-10-22 20:44:05 +00:00
|
|
|
|
|
|
|
protectProjectilesDone:
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
protectProjectilesOffscreen:
|
|
|
|
plx
|
|
|
|
bra protectProjectilesContinue
|
2017-10-22 20:44:05 +00:00
|
|
|
|
2017-10-31 19:15:18 +00:00
|
|
|
UPANGLE = $00af
|
|
|
|
DNANGLE = $ffaf
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; renderProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
renderProjectiles:
|
2018-12-24 00:39:22 +00:00
|
|
|
SAVE_AXY
|
|
|
|
ldx #0
|
2018-06-11 22:00:02 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectilesLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
jsr renderProjectile
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectilesSkip:
|
|
|
|
inx
|
|
|
|
cpx #MAXPROJECTILES
|
|
|
|
bne renderProjectilesLoop
|
2018-06-11 22:00:02 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
2018-06-11 22:00:02 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; renderProjectile
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
2018-12-30 01:10:21 +00:00
|
|
|
; Trashes SCRATCHL
|
2018-12-24 00:39:22 +00:00
|
|
|
;
|
|
|
|
renderProjectile:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
bpl renderProjectileDoIt
|
|
|
|
jmp renderProjectileDone
|
|
|
|
|
|
|
|
renderProjectileDoIt:
|
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tax
|
|
|
|
PROJECTILETYPEPTR_X
|
|
|
|
|
|
|
|
lda #projectileData ; Calculate pointer for game object render
|
|
|
|
sta PARAML0
|
|
|
|
clc
|
|
|
|
tya
|
|
|
|
adc PARAML0
|
2017-10-27 03:15:52 +00:00
|
|
|
sta PARAML0
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
; Determine which sprite to use
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+JD_VY,y
|
2017-10-31 19:15:18 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
bmi renderProjectileNegYPosX
|
2017-10-31 19:15:18 +00:00
|
|
|
cmp #UPANGLE
|
2018-12-24 00:39:22 +00:00
|
|
|
bmi renderProjectileFlat
|
2017-10-31 19:15:18 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileUpAngle:
|
|
|
|
lda projectileTypes+PT_FRAME0,x ; Up angle
|
|
|
|
bra renderProjectileGoSprite
|
2017-10-27 03:15:52 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileNegYPosX:
|
2017-10-31 19:15:18 +00:00
|
|
|
cmp #DNANGLE
|
2018-12-24 00:39:22 +00:00
|
|
|
bpl renderProjectileFlat
|
2017-10-31 19:15:18 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileDownAngle:
|
|
|
|
lda projectileTypes+PT_FRAME2,x ; Down angle
|
|
|
|
bra renderProjectileGoSprite
|
2017-10-27 03:15:52 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileFlat:
|
|
|
|
lda projectileTypes+PT_FRAME1,x ; Flat
|
2017-10-27 03:15:52 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileGoSprite:
|
2018-12-30 01:10:21 +00:00
|
|
|
sta SCRATCHL
|
|
|
|
lda projectileTypes+PT_DIRECTIONAL,x
|
|
|
|
beq renderProjectileGoSpriteNormal
|
|
|
|
lda projectileData+JD_FACING,y ; Projectile is directional, so flip sprite if needed
|
|
|
|
beq renderProjectileGoSpriteNormal
|
|
|
|
lda SCRATCHL
|
|
|
|
inc ; Flip it!
|
|
|
|
bra renderProjectileGoSpriteFlipped
|
|
|
|
|
|
|
|
renderProjectileGoSpriteNormal:
|
|
|
|
lda SCRATCHL
|
|
|
|
|
|
|
|
renderProjectileGoSpriteFlipped:
|
2017-10-27 03:15:52 +00:00
|
|
|
jsr renderGameObject
|
2018-12-27 00:29:13 +00:00
|
|
|
|
|
|
|
; Check for special deployment code
|
|
|
|
lda projectileTypes+PT_RENDER,x
|
|
|
|
beq renderProjectileDone
|
|
|
|
JSRA
|
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
renderProjectileDone:
|
|
|
|
RESTORE_AXY
|
2017-08-25 04:45:05 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; unrenderProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
unrenderProjectiles:
|
2018-12-24 00:39:22 +00:00
|
|
|
SAVE_AXY
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
unrenderProjectilesLoop:
|
|
|
|
txy
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
jsr unrenderProjectile
|
|
|
|
|
|
|
|
unrenderProjectilesSkip:
|
|
|
|
inx
|
|
|
|
cpx #MAXPROJECTILES
|
|
|
|
bne unrenderProjectilesLoop
|
|
|
|
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; unrenderProjectile
|
|
|
|
;
|
|
|
|
; Y = Offset to projectile structure
|
|
|
|
;
|
|
|
|
unrenderProjectile:
|
2017-08-25 04:45:05 +00:00
|
|
|
pha
|
2018-12-24 00:39:22 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
bpl unrenderProjectileActive
|
|
|
|
jmp unrenderProjectileDone
|
2017-09-05 19:48:30 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
unrenderProjectileActive:
|
|
|
|
lda projectileData+JD_NEW,y
|
|
|
|
beq unrenderProjectileDoIt
|
|
|
|
lda #0
|
|
|
|
sta projectileData+JD_NEW,y
|
|
|
|
jmp unrenderProjectileDone
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
unrenderProjectileDoIt:
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
2018-12-24 00:39:22 +00:00
|
|
|
clc
|
|
|
|
tya
|
|
|
|
adc PARAML0
|
|
|
|
sta PARAML0
|
2017-10-27 03:15:52 +00:00
|
|
|
jsr unrenderGameObject
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2018-12-24 00:39:22 +00:00
|
|
|
unrenderProjectileDone:
|
2017-08-25 04:45:05 +00:00
|
|
|
pla
|
2017-08-20 22:15:46 +00:00
|
|
|
rts
|
2017-09-04 00:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; processPlayerImpact
|
|
|
|
;
|
2018-12-24 00:39:22 +00:00
|
|
|
; X = Index of player that was hit
|
|
|
|
; Y = Offset to projectile structure
|
2017-09-04 00:20:24 +00:00
|
|
|
;
|
|
|
|
processPlayerImpact:
|
2018-12-24 00:39:22 +00:00
|
|
|
PLAYERPTR_X
|
2017-09-04 00:20:24 +00:00
|
|
|
|
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
|
|
|
|
; Apply damage
|
|
|
|
lda playerData+PD_ANGER,x
|
|
|
|
sec
|
|
|
|
sbc projectileTypes+PT_DAMAGE,y
|
|
|
|
|
|
|
|
; Check for death
|
|
|
|
beq processPlayerImpactDeath
|
|
|
|
bmi processPlayerImpactDeath
|
|
|
|
sta playerData+PD_ANGER,x
|
|
|
|
rts
|
|
|
|
|
|
|
|
processPlayerImpactDeath:
|
|
|
|
lda currentPlayer
|
|
|
|
sta gameOver
|
|
|
|
rts
|
2017-09-13 13:53:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; processTerrainImpact
|
|
|
|
;
|
2020-01-05 23:48:59 +00:00
|
|
|
; Trashes A,Y, SCRATCHL, PARAML0, PARAML1
|
2017-09-13 13:53:40 +00:00
|
|
|
;
|
|
|
|
processTerrainImpact:
|
2019-02-22 23:52:19 +00:00
|
|
|
ldy projectileActive
|
|
|
|
|
|
|
|
; Shift impact point to forward bottom corner according to V
|
|
|
|
lda projectileData+JD_VX,y
|
|
|
|
bmi processTerrainImpactNegative
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
clc
|
2019-12-29 17:26:38 +00:00
|
|
|
adc #GAMEOBJECTWIDTH/2+1 ; A fudge that makes crater location look better in this direction, and tunneling work better
|
2019-02-22 23:52:19 +00:00
|
|
|
bra processTerrainStoreContinue
|
|
|
|
|
|
|
|
processTerrainImpactNegative:
|
|
|
|
lda projectileData+GO_POSX,y
|
2019-12-29 17:26:38 +00:00
|
|
|
clc
|
|
|
|
adc #GAMEOBJECTWIDTH/4-1 ; A fudge that makes crater location look better in this direction, and tunneling work better
|
2019-02-22 23:52:19 +00:00
|
|
|
|
|
|
|
processTerrainStoreContinue:
|
2017-09-13 13:53:40 +00:00
|
|
|
sta PARAML0
|
2020-01-05 23:48:59 +00:00
|
|
|
pha ; Dirt explosion will need this
|
2017-09-13 13:53:40 +00:00
|
|
|
lda projectileData+GO_POSY,y
|
|
|
|
sec
|
2019-12-29 17:26:38 +00:00
|
|
|
sbc #GAMEOBJECTHEIGHT ; This fudge makes tunneling work better
|
2017-09-13 13:53:40 +00:00
|
|
|
sta PARAML1
|
2020-01-05 23:48:59 +00:00
|
|
|
pha ; Dirt explosion will need this
|
2017-09-13 13:53:40 +00:00
|
|
|
|
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
|
|
|
|
lda projectileTypes+PT_RADIUS,y
|
|
|
|
tay
|
2019-12-29 17:26:38 +00:00
|
|
|
phy ; We'll need the radius in a moment
|
2017-09-13 13:53:40 +00:00
|
|
|
|
|
|
|
jsr craterTerrain
|
2020-01-05 23:48:59 +00:00
|
|
|
|
2019-12-29 17:26:38 +00:00
|
|
|
jsr unclipTerrain
|
|
|
|
|
|
|
|
; Recompile the rows affected by the crater
|
|
|
|
clc
|
|
|
|
lda PARAML1 ; Impact point is top row to recompile
|
|
|
|
adc #GAMEOBJECTHEIGHT ; Expand recompile area upwards because of tunneling fudge
|
|
|
|
tax
|
|
|
|
|
|
|
|
clc
|
|
|
|
pla
|
|
|
|
adc #GAMEOBJECTHEIGHT ; Expand "vertical" radius area because of tunneling fudge
|
|
|
|
sta SCRATCHL ; Need radius in a memory location for this math
|
|
|
|
txa
|
|
|
|
sec
|
|
|
|
sbc SCRATCHL
|
|
|
|
tay
|
|
|
|
lda SCRATCHL
|
|
|
|
jsr compileTerrainChunk
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
jsr clipTerrain
|
|
|
|
|
2020-01-05 23:48:59 +00:00
|
|
|
pla
|
|
|
|
sta PARAML1
|
|
|
|
pla
|
|
|
|
sta PARAML0
|
|
|
|
jsr createDirtExplosion
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
rts
|