mirror of
https://github.com/blondie7575/GSCats.git
synced 2024-11-22 06:31:48 +00:00
Added game object pool allocator for accessories
This commit is contained in:
parent
32c622afbe
commit
364ae0de32
@ -65,6 +65,7 @@ JD_NEW = 142
|
|||||||
JD_STATIC = 144
|
JD_STATIC = 144
|
||||||
JD_OWNER = 146
|
JD_OWNER = 146
|
||||||
JD_FACING = 148
|
JD_FACING = 148
|
||||||
|
JD_SCRATCH = 150
|
||||||
|
|
||||||
MAXPROJECTILES = 3
|
MAXPROJECTILES = 3
|
||||||
|
|
||||||
|
29
fan.s
29
fan.s
@ -58,17 +58,26 @@ updateFan:
|
|||||||
beq updateFanDone
|
beq updateFanDone
|
||||||
|
|
||||||
; Once fan is in place, make it static
|
; Once fan is in place, make it static
|
||||||
|
lda projectileData+GO_POSY,y
|
||||||
|
inc
|
||||||
|
sta projectileData+GO_POSY,y
|
||||||
lda #1
|
lda #1
|
||||||
sta projectileData+JD_STATIC,y
|
sta projectileData+JD_STATIC,y
|
||||||
jsr endProjectile
|
jsr endProjectile
|
||||||
|
|
||||||
; Now set up the stand
|
; Now set up the stand
|
||||||
|
jsr allocGameObject
|
||||||
|
cpx #-1
|
||||||
|
BREAK
|
||||||
|
beq updateFanDone
|
||||||
|
txa
|
||||||
|
sta projectileData+JD_SCRATCH,y ; Remember where our stand is
|
||||||
lda projectileData+GO_POSX,y
|
lda projectileData+GO_POSX,y
|
||||||
sta standGameObjectData+GO_POSX
|
sta gameObjectPool+GO_POSX,x
|
||||||
lda projectileData+GO_POSY,y
|
lda projectileData+GO_POSY,y
|
||||||
sec
|
sec
|
||||||
sbc #GAMEOBJECTHEIGHT
|
sbc #GAMEOBJECTHEIGHT
|
||||||
sta standGameObjectData+GO_POSY,y
|
sta gameObjectPool+GO_POSY,x
|
||||||
|
|
||||||
updateFanDone:
|
updateFanDone:
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
@ -123,7 +132,11 @@ renderFan:
|
|||||||
beq renderFanDone ; Don't render the stand until we're static
|
beq renderFanDone ; Don't render the stand until we're static
|
||||||
|
|
||||||
; Render the stand under the fan
|
; Render the stand under the fan
|
||||||
lda #standGameObjectData
|
lda projectileData+JD_SCRATCH,y
|
||||||
|
sta PARAML0
|
||||||
|
clc
|
||||||
|
lda #gameObjectPool
|
||||||
|
adc PARAML0
|
||||||
sta PARAML0
|
sta PARAML0
|
||||||
lda #14
|
lda #14
|
||||||
jsr renderGameObject
|
jsr renderGameObject
|
||||||
@ -131,13 +144,3 @@ renderFan:
|
|||||||
renderFanDone:
|
renderFanDone:
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
; Fake game object for rendering the stand
|
|
||||||
standGameObjectData:
|
|
||||||
.word 40 ; X pos in pixels (from right terrain edge)
|
|
||||||
.word 38 ; Y pos 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 64 bytes
|
|
||||||
.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
|
|
||||||
|
134
gameobject.s
134
gameobject.s
@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
GAMEOBJECTWIDTH = 16
|
GAMEOBJECTWIDTH = 16
|
||||||
GAMEOBJECTHEIGHT = 16
|
GAMEOBJECTHEIGHT = 16
|
||||||
|
MAXGAMEOBJECTS = 6 ; Size of general purpose object pool
|
||||||
|
|
||||||
|
|
||||||
; Base class sample:
|
; Base class sample:
|
||||||
;gameobjectData:
|
;gameobjectData:
|
||||||
; .word 40 ; X pos in pixels (from right terrain edge)
|
; .word 40 ; X pos in pixels (from right terrain edge)
|
||||||
; .word 38 ; Y pos in pixels (from bottom terrain edge)
|
; .word 38 ; Y pos 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 64 bytes
|
; .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background 128 bytes
|
||||||
; .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,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
|
||||||
@ -712,3 +714,133 @@ unrenderGameobjectBackground:
|
|||||||
unrenderGameobjectDone:
|
unrenderGameobjectDone:
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
.macro GAMEOBJECTPTR_X
|
||||||
|
txa ; Pointer to game object type structure from index
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; allocGameObject
|
||||||
|
;
|
||||||
|
; Returns offset of gameobject structure in X, or -1 if none available
|
||||||
|
;
|
||||||
|
allocGameObject:
|
||||||
|
SAVE_AY
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
allocGameObjectLoop:
|
||||||
|
tyx
|
||||||
|
GAMEOBJECTPTR_X
|
||||||
|
lda gameObjectPool+GO_POSX,x
|
||||||
|
bmi allocGameObjectDone
|
||||||
|
iny
|
||||||
|
cpy #MAXGAMEOBJECTS
|
||||||
|
bne allocGameObjectLoop
|
||||||
|
ldx #-1
|
||||||
|
|
||||||
|
allocGameObjectDone:
|
||||||
|
RESTORE_AY
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; deleteGameObject
|
||||||
|
;
|
||||||
|
; Deletes the game object at offset X
|
||||||
|
;
|
||||||
|
deleteGameObject:
|
||||||
|
pha
|
||||||
|
lda #-1
|
||||||
|
sta gameObjectPool+GO_POSX,x
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
; A general purpose pool allocator for game objects. Useful
|
||||||
|
; for those times you need an object, but not a full fledged
|
||||||
|
; Player, Projectile, or other subclass.
|
||||||
|
gameObjectPool:
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 128 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 128 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 128 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 128 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 128 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
.word -1 ; X pos in pixels (from right terrain edge)
|
||||||
|
.word 0 ; Y pos 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 64 bytes
|
||||||
|
.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
|
||||||
|
|
||||||
|
.repeat 124
|
||||||
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
11
projectile.s
11
projectile.s
@ -24,8 +24,9 @@ projectileData:
|
|||||||
.word 0 ; Static?
|
.word 0 ; Static?
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
|
.word 0 ; Scratch space for subclasses
|
||||||
|
|
||||||
.repeat 106
|
.repeat 104
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
@ -47,8 +48,9 @@ projectileData:
|
|||||||
.word 0 ; Static?
|
.word 0 ; Static?
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
|
.word 0 ; Scratch space for subclasses
|
||||||
|
|
||||||
.repeat 106
|
.repeat 104
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
@ -70,8 +72,9 @@ projectileData:
|
|||||||
.word 0 ; Static?
|
.word 0 ; Static?
|
||||||
.word 0 ; Owner (player index)
|
.word 0 ; Owner (player index)
|
||||||
.word 0 ; Facing (0,1) = (+X,-X)
|
.word 0 ; Facing (0,1) = (+X,-X)
|
||||||
|
.word 0 ; Scratch space for subclasses
|
||||||
|
|
||||||
.repeat 106
|
.repeat 104
|
||||||
.byte 0 ; Padding to 256-byte boundary
|
.byte 0 ; Padding to 256-byte boundary
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
@ -530,6 +533,8 @@ updateProjectileCollisionsTerrainHit:
|
|||||||
;
|
;
|
||||||
endDeleteProjectile:
|
endDeleteProjectile:
|
||||||
lda #projectileData
|
lda #projectileData
|
||||||
|
clc
|
||||||
|
adc projectileActive
|
||||||
sta PARAML0
|
sta PARAML0
|
||||||
jsr unrenderGameObject
|
jsr unrenderGameObject
|
||||||
ldy projectileActive
|
ldy projectileActive
|
||||||
|
Loading…
Reference in New Issue
Block a user