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?
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-09-30 00:53:05 +00:00
|
|
|
.repeat 112
|
|
|
|
.byte 0 ; Padding to 256-byte boundary
|
|
|
|
.endrepeat
|
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
; 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
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
GRAVITY = $ffff ; 8.8 fixed point
|
|
|
|
|
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-06-10 02:29:00 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
;.word ; Padding to 16-byte boundary (none needed)
|
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-06-10 02:29:00 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
;.word ; Padding to 16-byte boundary (none needed)
|
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
|
|
|
|
.addr 0 ; Render
|
2018-07-30 19:36:44 +00:00
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
;.word ; Padding to 16-byte boundary (none needed)
|
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
|
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
|
2017-09-04 00:20:24 +00:00
|
|
|
tay
|
|
|
|
.endmacro
|
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; fireProjectile
|
|
|
|
;
|
|
|
|
;
|
|
|
|
fireProjectile:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
; Set up projectile structure
|
2017-08-27 05:34:49 +00:00
|
|
|
ldy #0 ; Only one active at a time for now
|
|
|
|
PROJECTILEPTR_Y
|
2017-08-20 22:15:46 +00:00
|
|
|
|
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
|
2017-08-21 00:51:12 +00:00
|
|
|
|
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
|
|
|
|
stz projectileActive
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
;
|
|
|
|
; Trashes SCRATCHL
|
|
|
|
;
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysics:
|
2017-08-25 04:45:05 +00:00
|
|
|
SAVE_AY
|
2017-09-13 13:53:40 +00:00
|
|
|
|
2017-08-27 05:34:49 +00:00
|
|
|
lda projectileData+GO_POSX
|
2017-09-13 13:53:40 +00:00
|
|
|
bpl updateProjectilePhysicsActive
|
|
|
|
jmp updateProjectilePhysicsDone
|
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
|
|
|
|
lda projectileData+JD_VY
|
|
|
|
clc
|
|
|
|
adc #GRAVITY
|
|
|
|
sta projectileData+JD_VY
|
|
|
|
|
2017-08-23 03:33:07 +00:00
|
|
|
; Integrate X velocity over position
|
2017-08-25 04:45:05 +00:00
|
|
|
lda projectileData+JD_VX
|
|
|
|
; 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
|
2017-08-25 04:45:05 +00:00
|
|
|
adc projectileData+JD_PRECISEX
|
2017-08-23 03:33:07 +00:00
|
|
|
sta projectileData+JD_PRECISEX
|
|
|
|
|
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
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSX
|
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
|
2017-08-25 04:45:05 +00:00
|
|
|
lda projectileData+JD_VY
|
|
|
|
; 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
|
2017-08-25 04:45:05 +00:00
|
|
|
adc projectileData+JD_PRECISEY
|
2017-08-23 03:33:07 +00:00
|
|
|
sta projectileData+JD_PRECISEY
|
|
|
|
|
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
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSY
|
2017-08-31 19:55:02 +00:00
|
|
|
cmp #GAMEOBJECTHEIGHT
|
2017-09-13 13:53:40 +00:00
|
|
|
bmi updateProjectilePhysicsDelete
|
|
|
|
|
2018-12-22 18:41:12 +00:00
|
|
|
; Check for special update code
|
|
|
|
ldy #0
|
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
lda projectileTypes+PT_UPDATE,y
|
|
|
|
beq updateProjectilePhysicsDone
|
|
|
|
JSRA
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectilePhysicsDone:
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
updateProjectilePhysicsDelete:
|
|
|
|
jsr endProjectile
|
|
|
|
bra updateProjectilePhysicsDone
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; updateProjectileCollisions
|
|
|
|
;
|
|
|
|
; Trashes SCRATCHL
|
|
|
|
;
|
|
|
|
updateProjectileCollisions:
|
|
|
|
SAVE_AY
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-09-03 03:52:19 +00:00
|
|
|
; Check for player collisions
|
|
|
|
ldy #0
|
|
|
|
lda projectileData+GO_POSX
|
2017-09-13 13:53:40 +00:00
|
|
|
bmi updateProjectileCollisionsDone ; Projectile not active
|
2017-09-03 03:52:19 +00:00
|
|
|
sta rectParams
|
|
|
|
lda projectileData+GO_POSY
|
|
|
|
sta rectParams+2
|
|
|
|
lda #GAMEOBJECTWIDTH
|
|
|
|
sta rectParams+4
|
|
|
|
lda #GAMEOBJECTHEIGHT
|
|
|
|
sta rectParams+6
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectileCollisionsPlayerLoop:
|
2017-09-03 03:52:19 +00:00
|
|
|
cpy 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:
|
|
|
|
iny
|
|
|
|
cpy #NUMPLAYERS
|
|
|
|
bne updateProjectileCollisionsPlayerLoop
|
2017-09-03 03:52:19 +00:00
|
|
|
|
2017-08-31 19:55:02 +00:00
|
|
|
; Check for terrain collisions
|
|
|
|
lda projectileData+GO_POSX
|
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
|
|
|
|
lda projectileData+GO_POSY
|
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:
|
2017-08-25 04:45:05 +00:00
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
2017-09-13 13:53:40 +00:00
|
|
|
updateProjectileCollisionsPlayerHit:
|
|
|
|
jsr processPlayerImpact
|
|
|
|
jsr endProjectile
|
|
|
|
bra updateProjectileCollisionsDone
|
|
|
|
|
|
|
|
updateProjectileCollisionsTerrainHit:
|
|
|
|
jsr processTerrainImpact
|
|
|
|
jsr endProjectile
|
|
|
|
bra updateProjectileCollisionsDone
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; endProjectile
|
|
|
|
;
|
|
|
|
; Trashes A and Y
|
|
|
|
;
|
|
|
|
endProjectile:
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
2017-08-25 04:45:05 +00:00
|
|
|
ldy #0
|
|
|
|
jsr deleteProjectile
|
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
|
|
|
|
;
|
|
|
|
; Y = Projectile index
|
|
|
|
; Trashes A
|
|
|
|
;
|
|
|
|
deleteProjectile:
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
lda #-1
|
2017-08-27 05:34:49 +00:00
|
|
|
sta projectileData+GO_POSX,y
|
2017-08-25 04:45:05 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-10-22 20:44:05 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; protectProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
protectProjectiles:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
lda projectileData
|
|
|
|
bmi protectProjectilesDone
|
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
|
|
|
jsr vramPtr
|
|
|
|
cpx #0
|
|
|
|
bmi protectProjectilesDone
|
|
|
|
|
2017-10-22 20:44:05 +00:00
|
|
|
lda #projectileData+GO_BACKGROUND
|
|
|
|
jsr protectGameObject
|
|
|
|
|
|
|
|
protectProjectilesDone:
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-10-31 19:15:18 +00:00
|
|
|
UPANGLE = $00af
|
|
|
|
DNANGLE = $ffaf
|
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; renderProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
renderProjectiles:
|
2018-06-11 22:00:02 +00:00
|
|
|
SAVE_AY
|
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
lda projectileData
|
2017-08-27 05:34:49 +00:00
|
|
|
bpl renderProjectilesDoIt
|
|
|
|
jmp renderProjectilesDone
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-08-27 05:34:49 +00:00
|
|
|
renderProjectilesDoIt:
|
2018-06-11 22:00:02 +00:00
|
|
|
|
|
|
|
lda projectileData+JD_TYPE
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
; Determine which sprite to use
|
2017-10-31 19:15:18 +00:00
|
|
|
lda projectileData+JD_VX
|
|
|
|
bmi renderProjectilesNegX
|
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
lda projectileData+JD_VY
|
2017-10-31 19:15:18 +00:00
|
|
|
|
|
|
|
bmi renderProjectilesNegYPosX
|
|
|
|
cmp #UPANGLE
|
2017-10-27 03:15:52 +00:00
|
|
|
bmi renderProjectilesFlat
|
2017-10-31 19:15:18 +00:00
|
|
|
|
|
|
|
renderProjectilesUpAngle:
|
2018-06-11 22:00:02 +00:00
|
|
|
lda projectileTypes+PT_FRAME0,y ; Up angle
|
2017-10-27 03:15:52 +00:00
|
|
|
bra renderProjectilesGoSprite
|
|
|
|
|
2017-10-31 19:15:18 +00:00
|
|
|
renderProjectilesNegYPosX:
|
|
|
|
cmp #DNANGLE
|
2017-10-27 03:15:52 +00:00
|
|
|
bpl renderProjectilesFlat
|
2017-10-31 19:15:18 +00:00
|
|
|
|
|
|
|
renderProjectilesDownAngle:
|
2018-06-11 22:00:02 +00:00
|
|
|
lda projectileTypes+PT_FRAME2,y ; Down angle
|
2017-10-27 03:15:52 +00:00
|
|
|
bra renderProjectilesGoSprite
|
|
|
|
|
2017-10-31 19:15:18 +00:00
|
|
|
renderProjectilesNegX:
|
|
|
|
lda projectileData+JD_VY
|
|
|
|
|
|
|
|
bmi renderProjectilesNegYNegX
|
|
|
|
|
|
|
|
cmp #UPANGLE
|
|
|
|
bmi renderProjectilesFlat
|
|
|
|
bra renderProjectilesDownAngle
|
|
|
|
|
|
|
|
renderProjectilesNegYNegX:
|
|
|
|
cmp #DNANGLE
|
|
|
|
bpl renderProjectilesFlat
|
|
|
|
bra renderProjectilesUpAngle
|
|
|
|
|
2017-10-27 03:15:52 +00:00
|
|
|
renderProjectilesFlat:
|
2018-06-11 22:00:02 +00:00
|
|
|
lda projectileTypes+PT_FRAME1,y ; Flat
|
2017-10-27 03:15:52 +00:00
|
|
|
|
|
|
|
renderProjectilesGoSprite:
|
|
|
|
jsr renderGameObject
|
|
|
|
|
2017-08-25 04:45:05 +00:00
|
|
|
renderProjectilesDone:
|
2018-06-11 22:00:02 +00:00
|
|
|
RESTORE_AY
|
2017-08-25 04:45:05 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; unrenderProjectiles
|
|
|
|
;
|
|
|
|
;
|
|
|
|
unrenderProjectiles:
|
|
|
|
pha
|
|
|
|
lda projectileData
|
2017-09-05 19:48:30 +00:00
|
|
|
bpl unrenderProjectilesActive
|
|
|
|
jmp unrenderProjectilesDone
|
|
|
|
|
|
|
|
unrenderProjectilesActive:
|
|
|
|
lda projectileData+JD_NEW
|
|
|
|
beq unrenderProjectilesDoIt
|
|
|
|
stz projectileData+JD_NEW
|
2017-08-27 05:34:49 +00:00
|
|
|
jmp unrenderProjectilesDone
|
2017-08-25 04:45:05 +00:00
|
|
|
|
2017-08-27 05:34:49 +00:00
|
|
|
unrenderProjectilesDoIt:
|
2017-10-27 03:15:52 +00:00
|
|
|
lda #projectileData
|
|
|
|
sta PARAML0
|
|
|
|
jsr unrenderGameObject
|
2017-08-25 04:45:05 +00:00
|
|
|
|
|
|
|
unrenderProjectilesDone:
|
|
|
|
pla
|
2017-08-20 22:15:46 +00:00
|
|
|
rts
|
2017-09-04 00:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; processPlayerImpact
|
|
|
|
;
|
2017-09-30 00:53:05 +00:00
|
|
|
; Y = Index of player that was hit
|
2017-09-04 00:20:24 +00:00
|
|
|
;
|
|
|
|
processPlayerImpact:
|
2017-09-30 00:53:05 +00:00
|
|
|
PLAYERPTR_Y
|
2017-09-04 00:20:24 +00:00
|
|
|
tyx
|
|
|
|
|
|
|
|
ldy #0 ; Assume projectile 0
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
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
|
|
|
|
;
|
|
|
|
; Trashes A,Y
|
|
|
|
;
|
|
|
|
processTerrainImpact:
|
|
|
|
ldy #0 ; Assume projectile 0
|
|
|
|
PROJECTILEPTR_Y
|
|
|
|
lda projectileData+GO_POSX,y
|
|
|
|
clc
|
|
|
|
adc #GAMEOBJECTWIDTH/2
|
|
|
|
sta PARAML0
|
|
|
|
lda projectileData+GO_POSY,y
|
|
|
|
sec
|
|
|
|
sbc #GAMEOBJECTHEIGHT
|
|
|
|
sta PARAML1
|
|
|
|
|
|
|
|
lda projectileData+JD_TYPE,y
|
|
|
|
tay
|
|
|
|
PROJECTILETYPEPTR_Y
|
|
|
|
|
|
|
|
lda projectileTypes+PT_RADIUS,y
|
|
|
|
tay
|
|
|
|
|
|
|
|
jsr craterTerrain
|
|
|
|
jsr compileTerrain
|
|
|
|
jsr clipTerrain
|
|
|
|
|
|
|
|
rts
|