Basic framework for fan

Also added support for delegate methods in projectiles
This commit is contained in:
blondie7575 2018-12-22 11:41:12 -07:00
parent 67dabb62a9
commit 2e92ac118e
9 changed files with 148 additions and 21 deletions

BIN
Art/013Stand.xcf Normal file

Binary file not shown.

View File

@ -17,6 +17,7 @@
700FFAFB1F40F3BF00A442DE /* font.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = font.s; sourceTree = "<group>"; };
7059502B1F37A0BE00BBE90F /* GenerateVRAMTable.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateVRAMTable.py; sourceTree = "<group>"; };
705AAFA920040B0D001BB0ED /* terrain_e1.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = terrain_e1.s; sourceTree = "<group>"; };
705C54E62124B7F300515A6B /* fan.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = fan.s; sourceTree = "<group>"; };
706DF1641F2D39F700AA6680 /* loader.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = loader.s; sourceTree = "<group>"; };
706DF1651F2D4A8100AA6680 /* terrain.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = terrain.s; sourceTree = "<group>"; };
7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateRenderSpans.py; sourceTree = "<group>"; };
@ -60,6 +61,7 @@
70F0869F1F413A89002446C3 /* player.s */,
700B5E6F2069831000B31C00 /* inventory.s */,
700F21DF1F4A364600D7007D /* projectile.s */,
705C54E62124B7F300515A6B /* fan.s */,
70A80FB01F43D7F200BD34C9 /* gamemanager.s */,
70E554C41F807ADB00F3C871 /* spritebank.s */,
70E9D8611F2BD95400555C19 /* gscats.s */,

View File

@ -22,7 +22,7 @@ SPRITES=SpriteBank
FLIPLIST=$(wildcard Art/*Fan.gif) $(wildcard Art/*Spit*.gif)
REMOTESYMBOLS=-Wl $(shell ./ParseMapFile.py *.map)
all: terrain_e1 $(PGM) loader
all: clean terrain_e1 $(PGM) loader
$(PGM):

View File

@ -53,3 +53,13 @@ terrainData = $f500
; .word 0
; .endrepeat
terrainDataEnd = terrainData + (TERRAINWIDTH/2 * 2)
; projectileData struct offsets
JD_PRECISEX = 132
JD_PRECISEY = 134
JD_VX = 136
JD_VY = 138
JD_TYPE = 140
JD_NEW = 142

57
fan.s Normal file
View File

@ -0,0 +1,57 @@
;
; fan
; Code and data structures related to the special fan weapon
;
; Created by Quinn Dunki on 8/15/18
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; deployFan
;
; Y: Index to projectile structure
;
deployFan:
SAVE_AY
lda #200 ; Drop in from the top of the view
sta projectileData+GO_POSY,y
lda #$c80
sta projectileData+JD_PRECISEY,y
lda #0
sta projectileData+JD_VX,y
sta projectileData+JD_VY,y
RESTORE_AY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; updateFan
;
;
updateFan:
SAVE_AY
; Wait for fan to collide with us as it falls from the sky
ldy #0
lda projectileData+GO_POSX,y
sta rectParams
lda projectileData+GO_POSY,y
sta rectParams+2
lda #GAMEOBJECTWIDTH
sta rectParams+4
lda #GAMEOBJECTHEIGHT
sta rectParams+6
jsr playerIntersectRect
cmp #0
beq updateFanDone
updateFanDone:
RESTORE_AY
rts

Binary file not shown.

View File

@ -46,6 +46,7 @@ quitGame:
.include "tables.s"
.include "gamemanager.s"
.include "input.s"
.include "fan.s"
.include "projectile.s"
.include "inventory.s"

View File

@ -176,6 +176,7 @@
.endmacro
.macro BREAK
.local nobrk
pha
lda breakpoint
beq nobrk
@ -188,6 +189,7 @@ nobrk:
.endmacro
.macro BREAK_NOSTACK
.local nobrk
lda breakpoint
beq nobrk
lda #1
@ -212,6 +214,7 @@ deadlock: jmp deadlock
.macro BREAKLOCK
.local deadlock
pha
lda breakpoint
beq nobrk
@ -223,6 +226,12 @@ nobrk:
.endmacro
.macro JSRA ; Destination in accumulator
.local jsri_smc
sta jsri_smc+1
jsri_smc:
jsr 0
.endmacro
;;;;;;;;;;
; Stack Macros

View File

@ -26,25 +26,27 @@ projectileData:
.byte 0 ; Padding to 256-byte boundary
.endrepeat
JD_PRECISEX = 132 ; Byte offsets into projectile data structure
JD_PRECISEY = 134
JD_VX = 136
JD_VY = 138
JD_TYPE = 140
JD_NEW = 142
; Byte offsets for that ^ data structure can be found in equates.s
GRAVITY = $ffff ; 8.8 fixed point
projectileTypes:
PT_SPIT = 0
PT_BOMB = 1
PT_FAN = 2
; Spit
.word 3 ; Damage
.word 3 ; Crater radius
.word 4 ; Frame 0
.word 6 ; Frame 1
.word 8 ; Frame 2
.addr 0 ; Deploy
.addr 0 ; Update
.addr 0 ; Render
.word 0,0,0 ; Padding to 16-byte boundary
;.word ; Padding to 16-byte boundary (none needed)
; Bomb
.word 50 ; Damage
@ -52,8 +54,11 @@ projectileTypes:
.word 3 ; Frame 0
.word 3 ; Frame 1
.word 3 ; Frame 2
.addr 0 ; Deploy
.addr 0 ; Update
.addr 0 ; Render
.word 0,0,0 ; Padding to 16-byte boundary
;.word ; Padding to 16-byte boundary (none needed)
; Fan
.word 3 ; Damage
@ -61,8 +66,11 @@ projectileTypes:
.word 12 ; Frame 0
.word 12 ; Frame 1
.word 12 ; Frame 2
.addr deployFan ; Deploy
.addr updateFan ; Update
.addr 0 ; Render
.word 0,0,0 ; Padding to 16-byte boundary
;.word ; Padding to 16-byte boundary (none needed)
PT_DAMAGE = 0 ; Byte offsets into projectile type data structure
@ -70,7 +78,9 @@ PT_RADIUS = 2
PT_FRAME0 = 4
PT_FRAME1 = 6
PT_FRAME2 = 8
PT_DEPLOY = 10
PT_UPDATE = 12
PT_RENDER = 14
.macro PROJECTILEPTR_Y
tya ; Pointer to projectile structure from index
@ -107,7 +117,6 @@ projectileParams:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; fireProjectile
;
; Trashes SCRATCHL
;
fireProjectile:
SAVE_AXY
@ -135,6 +144,43 @@ fireProjectile:
asl
sta projectileData+JD_PRECISEY,y
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
lda projectileParams+6 ; Convert power to 8.8
asl
asl
@ -167,13 +213,6 @@ fireProjectile:
jsr mult88
sta projectileData+JD_VY,y
lda projectileParams+8 ; Type
sta projectileData+JD_TYPE,y
lda #1
sta projectileData+JD_NEW,y
stz projectileActive
RESTORE_AXY
rts
@ -212,7 +251,7 @@ updateProjectilePhysicsActive:
adc projectileData+JD_PRECISEX
sta projectileData+JD_PRECISEX
; Convert to integral for rendering
; Convert to integer for rendering
lsr
lsr
lsr
@ -238,7 +277,7 @@ updateProjectilePhysicsContinue:
adc projectileData+JD_PRECISEY
sta projectileData+JD_PRECISEY
; Convert to integral for rendering
; Convert to integer for rendering
lsr
lsr
lsr
@ -247,6 +286,15 @@ updateProjectilePhysicsContinue:
cmp #GAMEOBJECTHEIGHT
bmi updateProjectilePhysicsDelete
; Check for special update code
ldy #0
lda projectileData+JD_TYPE,y
tay
PROJECTILETYPEPTR_Y
lda projectileTypes+PT_UPDATE,y
beq updateProjectilePhysicsDone
JSRA
updateProjectilePhysicsDone:
RESTORE_AY
rts