GSCats/gameobject.s

959 lines
16 KiB
ArmAsm
Raw Normal View History

2017-08-13 22:36:12 +00:00
;
; gameobject
; Code and data structures related to the game objects
;
; Created by Quinn Dunki on 8/13/17
;
GAMEOBJECTWIDTH = 16
GAMEOBJECTHEIGHT = 16
MAXGAMEOBJECTS = 6 ; Size of general purpose object pool
2017-08-13 22:36:12 +00:00
; Base class sample:
;gameobjectData:
; .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 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
GO_POSX = 0 ; Byte offsets into gameobject data structure
GO_POSY = 2
GO_BACKGROUND = 4
2017-08-13 22:36:12 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2023-07-30 22:46:59 +00:00
; terrainHeightAtGameObjectPos
;
; A = GameObject position (left-edge relative)
; A -> Terrain height at that position
;
; Trashes SCRATCHL
;
2023-07-30 22:46:59 +00:00
terrainHeightAtGameObjectPos:
phy
clc ; Map into reversed terrain X space
adc #GAMEOBJECTWIDTH
sta SCRATCHL
lda #TERRAINWIDTH
sec
sbc SCRATCHL
2017-09-13 16:56:34 +00:00
and #$fffe ; Force even
tay
lda terrainData,y
2023-07-30 22:46:59 +00:00
ply
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; placeGameObjectOnTerrainDefault
;
; PARAML0 = Pointer to gameobject data
;
; Trashes SCRATCHL,SCRATCHL2
;
placeGameObjectOnTerrainDefault:
stz placeGameObjectRightOffset
pha
lda #GAMEOBJECTWIDTH
sta placeGameObjectLeftOffset
pla
jmp placeGameObjectOnTerrain
2023-07-30 22:46:59 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; placeGameObjectOnTerrain
;
; PARAML0 = Pointer to gameobject data
; placeGameObjectLeftOffset = Left edge of height to check (default=GAMEOBJECTWIDTH)
; placeGameObjectRightOffset = Right edge of height to check (default=0)
;
2023-07-30 22:46:59 +00:00
; Trashes SCRATCHL,SCRATCHL2
;
placeGameObjectOnTerrain:
SAVE_AY
2023-07-30 22:46:59 +00:00
; Check forwardmost position
ldy #GO_POSX
lda (PARAML0),y
clc
adc placeGameObjectRightOffset
2023-07-30 22:46:59 +00:00
jsr terrainHeightAtGameObjectPos
sta SCRATCHL2
; Check rearmost position
ldy #GO_POSX
lda (PARAML0),y
sec
sbc placeGameObjectLeftOffset
2023-07-30 22:46:59 +00:00
jsr terrainHeightAtGameObjectPos
cmp SCRATCHL2 ; Take higher value
bcc placeGameObjectOnTerrainRear
placeGameObjectOnTerrainDone:
clc
adc #GAMEOBJECTHEIGHT
ldy #GO_POSY
sta (PARAML0),y
RESTORE_AY
rts
2023-07-30 22:46:59 +00:00
placeGameObjectOnTerrainRear:
lda SCRATCHL2
bra placeGameObjectOnTerrainDone
placeGameObjectLeftOffset:
.word GAMEOBJECTWIDTH
placeGameObjectRightOffset:
.word 0
2023-07-30 22:46:59 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; moveGameObjectOnTerrain
;
; PARAML0 = Pointer to gameobject data
; X = Delta in pixels
;
; Trashes SCRATCHL,SCRATCHL2
;
moveGameObjectOnTerrain:
SAVE_AY
stx SCRATCHL2
ldy #GO_POSX
lda (PARAML0),y
clc
adc SCRATCHL2 ; Apply X delta
pha
; Check for impassable gaps
2023-07-30 22:46:59 +00:00
sec
sbc #GAMEOBJECTWIDTH/2
2023-07-30 22:46:59 +00:00
moveGameObjectOnTerrainCheckHeight:
jsr terrainHeightAtGameObjectPos
cmp #0
beq moveGameObjectOnTerrainTooFar
2023-07-30 22:46:59 +00:00
moveGameObjectOnTerrainStore:
ldy #GO_POSX
pla
2023-07-30 22:46:59 +00:00
sta (PARAML0),y
jsr placeGameObjectOnTerrain
moveGameObjectOnTerrainTooDone:
RESTORE_AY
rts
moveGameObjectOnTerrainTooFar:
pla
bra moveGameObjectOnTerrainTooDone
moveGameObjectLeftOffset:
.word 0
moveGameObjectRightOffset:
.word GAMEOBJECTWIDTH
2017-08-13 22:36:12 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; vramPtr
2017-08-13 22:36:12 +00:00
;
; PARAML0 = Pointer to X,Y (16 bits each, Y is bottom relative)
; X => Offset to upper left corner of VRAM, or $ffff if offscreen
2017-08-13 22:36:12 +00:00
;
; Trashes SCRATCHL
2017-10-19 19:59:24 +00:00
;
vramPtr:
SAVE_AY
2017-08-13 22:36:12 +00:00
; X
ldy #GO_POSX
lda (PARAML0),y
2017-08-13 22:36:12 +00:00
lsr
cmp leftScreenEdge
2017-10-19 19:59:24 +00:00
bmi vramPtrSkip ; Gameobject is off left edge of screen
cmp rightScreenEdge
2017-10-19 19:59:24 +00:00
bpl vramPtrSkip ; Gameobject is off right edge of screen
sec ; Convert byte x-pos to screenspace
sbc leftScreenEdge
2017-08-13 22:36:12 +00:00
sta SCRATCHL
; Y
sec
lda #200
ldy #GO_POSY
sbc (PARAML0),y
2017-10-19 19:59:24 +00:00
bmi vramPtrSkip ; Gameobject is off top edge of screen
2017-08-13 22:36:12 +00:00
cmp #200 - GAMEOBJECTHEIGHT
2017-10-19 19:59:24 +00:00
bpl vramPtrSkip ; Gameobject is off bottom edge of screen
2017-08-13 22:36:12 +00:00
asl
tax
lda vramYOffset,x
clc
adc SCRATCHL
adc #$2000
tax ; X now contains the bank address of the upper left corner
2017-10-19 19:59:24 +00:00
bra vramPtrDone
vramPtrSkip:
2019-02-22 23:52:07 +00:00
ldx #$ffff
2017-10-19 19:59:24 +00:00
vramPtrDone:
RESTORE_AY
rts
2017-10-19 19:59:24 +00:00
2017-10-19 19:59:24 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderGameObject
;
; PARAML0 = Pointer to gameobject data
; A = Sprite index
2017-10-19 19:59:24 +00:00
;
; Trashes SCRATCHL
;
renderGameObject:
SAVE_XY
2017-10-19 19:59:24 +00:00
; Find gameobject location in video memory
jsr vramPtr
2019-02-22 23:52:07 +00:00
cpx #$ffff
beq renderGameobjectDone
2017-10-19 19:59:24 +00:00
; Call compiled sprite code
txy
; SAVE_AXY ; DEBUG BOUNDS RENDER
2017-10-19 19:59:24 +00:00
clc
jsr DrawSpriteBank
; RESTORE_AXY ; DEBUG BOUNDS RENDER
; lda #11 ; DEBUG BOUNDS RENDER
; clc ; DEBUG BOUNDS RENDER
; jsr DrawSpriteBank ; DEBUG BOUNDS RENDER
2019-02-22 23:52:07 +00:00
2017-10-19 19:59:24 +00:00
renderGameobjectDone:
RESTORE_XY
rts
2017-10-19 19:59:24 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; protectGameObject
;
; Saves background behind this game object
; PARAML0 = Pointer to gameobject background data
2017-10-19 19:59:24 +00:00
; X = VRAM position of upper left of game object
;
; Trashes PARAML0
2017-10-19 19:59:24 +00:00
;
protectGameObject:
phy
ldy #0
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*2+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*2+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*2+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*3,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*3+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*3+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*3+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*4+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*4+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*4+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*5,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*5+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*5+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*5+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*6+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*6+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*6+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*7,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*7+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*7+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*7+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*8,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*8+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*8+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*8+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*9,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*9+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*9+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*9+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*10,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*10+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*10+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*10+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*11,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*11+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*11+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*11+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*12,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*12+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*12+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*12+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*13,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*13+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*13+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*13+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*14,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*14+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*14+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*14+6,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*15,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*15+2,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*15+4,x
sta (PARAML0),y
iny
iny
2017-10-19 19:59:24 +00:00
lda SHADOWVRAMBANK+160*15+6,x
sta (PARAML0),y
2017-08-13 22:36:12 +00:00
ply
2017-10-19 19:59:24 +00:00
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; unrenderGameObject
;
; PARAML0 = Pointer to gameobject data
; Trashes SCRATCHL
;
unrenderGameObject:
SAVE_AXY
2017-10-19 19:59:24 +00:00
; Find gameobject location in video memory
jsr vramPtr
cpx #$ffff
beq unrenderGameobjectSkip
2017-09-05 19:48:30 +00:00
bra unrenderGameobjectBackground
unrenderGameobjectSkip:
jmp unrenderGameobjectDone
unrenderGameobjectBackground:
ldy #GO_BACKGROUND
2017-10-19 19:59:24 +00:00
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*2+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*2+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*2+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*3,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*3+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*3+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*3+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*4+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*4+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*4+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*5,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*5+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*5+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*5+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*6+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*6+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*6+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*7,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*7+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*7+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*7+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*8,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*8+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*8+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*8+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*9,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*9+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*9+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*9+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*10,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*10+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*10+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*10+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*11,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*11+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*11+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*11+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*12,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*12+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*12+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*12+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*13,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*13+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*13+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*13+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*14,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*14+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*14+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*14+6,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*15,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*15+2,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*15+4,x
iny
iny
lda (PARAML0),y
2017-10-19 19:59:24 +00:00
sta SHADOWVRAMBANK+160*15+6,x
unrenderGameobjectDone:
RESTORE_AXY
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