mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-01-01 01:30:27 +00:00
More general cleanup and get rid of more magic numbers.
This commit is contained in:
parent
c614164c14
commit
44cb944f22
12
BuGS/game.s
12
BuGS/game.s
@ -56,9 +56,9 @@ dirtyTileLoop anop
|
||||
phy
|
||||
|
||||
ldx dirtyGameTiles,y
|
||||
stz tiles,x
|
||||
ldy tiles+2,x
|
||||
lda tiles+4,x
|
||||
stz tiles+TILE_DIRTY_OFFSET,x
|
||||
ldy tiles+TILE_SCREEN_OFFSET_OFFSET,x
|
||||
lda tiles+TILE_TYPE_OFFSET,x
|
||||
|
||||
jsl drawTile
|
||||
|
||||
@ -78,9 +78,9 @@ dirtyTileLoop2 anop
|
||||
phy
|
||||
|
||||
ldx dirtyNonGameTiles,y
|
||||
stz tiles,x
|
||||
ldy tiles+2,x
|
||||
lda tiles+4,x
|
||||
stz tiles+TILE_DIRTY_OFFSET,x
|
||||
ldy tiles+TILE_SCREEN_OFFSET_OFFSET,x
|
||||
lda tiles+TILE_TYPE_OFFSET,x
|
||||
|
||||
jsl drawTile
|
||||
|
||||
|
@ -18,8 +18,8 @@ FLEA_STATE_FALLING equ 1
|
||||
FLEA_STATE_EXPLODING equ 2
|
||||
|
||||
FLEA_SCREEN_SPEED equ 2*SCREEN_BYTES_PER_ROW
|
||||
FLEA_SLOW_UPDATES_PER_TILE equ 3
|
||||
FLEA_FAST_UPDATES_PER_TILE equ 1
|
||||
FLEA_SLOW_UPDATES_PER_TILE equ TILE_PIXEL_HEIGHT/2-1
|
||||
FLEA_FAST_UPDATES_PER_TILE equ TILE_PIXEL_HEIGHT/4-1
|
||||
|
||||
|
||||
drawFlea entry
|
||||
@ -33,10 +33,10 @@ drawFlea entry
|
||||
ldy numDirtyGameTiles
|
||||
|
||||
ldx fleaTileOffsets
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile1
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles,x
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
@ -45,10 +45,10 @@ drawFlea entry
|
||||
drawFlea_skipTile1 anop
|
||||
|
||||
ldx fleaTileOffsets+2
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile2
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles,x
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
@ -57,10 +57,10 @@ drawFlea_skipTile1 anop
|
||||
drawFlea_skipTile2 anop
|
||||
|
||||
ldx fleaTileOffsets+4
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile3
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles,x
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
@ -69,10 +69,10 @@ drawFlea_skipTile2 anop
|
||||
drawFlea_skipTile3 anop
|
||||
|
||||
ldx fleaTileOffsets+6
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile4
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles,x
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
@ -117,6 +117,7 @@ updateFlea_cont anop
|
||||
; Handle explosion
|
||||
lda fleaSprite
|
||||
beq updateFlea_explosionDone
|
||||
sec
|
||||
sbc #$4
|
||||
sta fleaSprite
|
||||
rtl
|
||||
@ -141,6 +142,7 @@ updateFlea_bottomOfTile anop
|
||||
|
||||
lda fleaSprite
|
||||
beq updateFlea_resetSprite
|
||||
sec
|
||||
sbc #$4
|
||||
sta fleaSprite
|
||||
bra updateFlea_nextAction
|
||||
@ -156,25 +158,25 @@ updateFlea_nextTile anop
|
||||
|
||||
ldx fleaTileOffsets
|
||||
stx fleaTileOffsets+4
|
||||
lda tiles+8,x
|
||||
lda tiles+TILE_BELOW_OFFSET,x
|
||||
cmp #INVALID_TILE_NUM
|
||||
beq updateFlea_bottom
|
||||
sta fleaTileOffsets
|
||||
|
||||
ldx fleaTileOffsets+2
|
||||
stx fleaTileOffsets+6
|
||||
lda tiles+8,x
|
||||
lda tiles+TILE_BELOW_OFFSET,x
|
||||
sta fleaTileOffsets+2
|
||||
|
||||
ldx fleaTileOffsets+4
|
||||
lda tiles+4,x
|
||||
lda tiles+TILE_TYPE_OFFSET,x
|
||||
bne updateFlea_nextAction
|
||||
|
||||
jsl rand65535
|
||||
and #$7
|
||||
bne updateFlea_nextAction
|
||||
lda #TILE_MUSHROOM4
|
||||
sta tiles+4,x
|
||||
sta tiles+TILE_TYPE_OFFSET,x
|
||||
|
||||
bra updateFlea_nextAction
|
||||
|
||||
@ -219,11 +221,11 @@ addFlea entry
|
||||
sta fleaTileOffsets+4
|
||||
|
||||
tax
|
||||
lda tiles+10,x
|
||||
lda tiles+TILE_LEFT_OFFSET,x
|
||||
sta fleaTileOffsets+2
|
||||
sta fleaTileOffsets+6
|
||||
|
||||
lda tiles+2,x
|
||||
lda tiles+TILE_SCREEN_OFFSET_OFFSET,x
|
||||
sec
|
||||
sbc #6*SCREEN_BYTES_PER_ROW+3
|
||||
sta fleaScreenOffset
|
||||
@ -261,6 +263,7 @@ shootFlea_faster anop
|
||||
bcc shootFlea_done
|
||||
|
||||
lda fleaScreenOffset
|
||||
sec
|
||||
sbc #SCREEN_BYTES_PER_ROW
|
||||
sta fleaScreenOffset
|
||||
|
||||
|
@ -14,11 +14,13 @@ gameScorpion start
|
||||
using globalData
|
||||
|
||||
|
||||
scorpionState_none equ 0
|
||||
scorpionState_left equ 1
|
||||
scorpionState_right equ 2
|
||||
scorpionState_exploding equ 3
|
||||
SCORPION_STATE_NONE equ 0
|
||||
SCORPION_STATE_LEFT equ 1
|
||||
SCORPION_STATE_RIGHT equ 2
|
||||
SCORPION_STATE_EXPLODING equ 3
|
||||
|
||||
SCORPION_SLOW_UPDATES_PER_TILE equ TILE_PIXEL_WIDTH-1
|
||||
SCORPION_FAST_UPDATES_PER_TILE equ TILE_PIXEL_WIDTH/2-1
|
||||
|
||||
drawScorpion entry
|
||||
lda scorpionState
|
||||
@ -31,10 +33,10 @@ drawScorpion_cont anop
|
||||
jsl scorpionJump
|
||||
|
||||
ldx scorpionTileOffsets
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_skipTile1
|
||||
lda #$1
|
||||
sta tiles,x
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame1
|
||||
@ -56,10 +58,10 @@ drawScorpion_nonGame1 anop
|
||||
drawScorpion_skipTile1 anop
|
||||
|
||||
ldx scorpionTileOffsets+2
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_skipTile2
|
||||
lda #$1
|
||||
sta tiles,x
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame2
|
||||
@ -81,10 +83,10 @@ drawScorpion_nonGame2 anop
|
||||
drawScorpion_skipTile2 anop
|
||||
|
||||
ldx scorpionTileOffsets+4
|
||||
lda tiles,x
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_done
|
||||
lda #$1
|
||||
sta tiles,x
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame3
|
||||
@ -108,7 +110,7 @@ drawScorpion_done anop
|
||||
|
||||
|
||||
scorpionJump entry
|
||||
cmp #scorpionState_left
|
||||
cmp #SCORPION_STATE_LEFT
|
||||
bne scorpionJump_next
|
||||
|
||||
lda scorpionLeftJumpTable,x
|
||||
@ -119,7 +121,7 @@ scorpionJump entry
|
||||
bra jumpInst
|
||||
|
||||
scorpionJump_next anop
|
||||
cmp #scorpionState_right
|
||||
cmp #SCORPION_STATE_RIGHT
|
||||
bne scorpionJump_explosion
|
||||
|
||||
lda scorpionRightJumpTable,x
|
||||
@ -132,7 +134,7 @@ scorpionJump_next anop
|
||||
scorpionJump_explosion anop
|
||||
tya
|
||||
clc
|
||||
adc #$4
|
||||
adc #TILE_BYTE_WIDTH
|
||||
tay
|
||||
|
||||
lda explosionJumpTable,x
|
||||
@ -150,16 +152,16 @@ updateScorpion entry
|
||||
beq updateScorpion_done
|
||||
|
||||
lda scorpionSprite
|
||||
cmp #$3c
|
||||
beq updateScorpionLeft_resetSprite
|
||||
clc
|
||||
adc #$4
|
||||
sec
|
||||
sbc #$4
|
||||
sta scorpionSprite
|
||||
|
||||
bra updateScorpionLeft_nextAction
|
||||
|
||||
updateScorpionLeft_resetSprite anop
|
||||
stz scorpionSprite
|
||||
lda #SCORPION_SPRITE_LAST_OFFSET
|
||||
sta scorpionSprite
|
||||
|
||||
updateScorpionLeft_nextAction anop
|
||||
lda scorpionShiftInTile
|
||||
@ -174,7 +176,7 @@ updateScorpionLeft_nextAction anop
|
||||
|
||||
updateScorpionLeft_nextTile anop
|
||||
dec scorpionScreenOffset
|
||||
lda #$7
|
||||
lda #SCORPION_SLOW_UPDATES_PER_TILE
|
||||
sta scorpionShiftInTile
|
||||
|
||||
ldx scorpionTileOffsets+2
|
||||
@ -184,7 +186,7 @@ updateScorpionLeft_nextTile anop
|
||||
stx scorpionTileOffsets+4
|
||||
ldx scorpionTileOffsets
|
||||
stx scorpionTileOffsets+2
|
||||
lda tiles+10,x
|
||||
lda tiles+TILE_LEFT_OFFSET,x
|
||||
sta scorpionTileOffsets
|
||||
rtl
|
||||
|
||||
@ -199,25 +201,28 @@ addScorpion entry
|
||||
lda scorpionState
|
||||
bne addScorpion_done
|
||||
|
||||
lda #scorpionState_left
|
||||
lda #SCORPION_STATE_LEFT
|
||||
sta scorpionState
|
||||
|
||||
ldx #24*16
|
||||
ldx #(24+25)*16
|
||||
stx scorpionTileOffsets
|
||||
lda tiles+2,x
|
||||
lda tiles+TILE_SCREEN_OFFSET_OFFSET,x
|
||||
dec a
|
||||
sta scorpionScreenOffset
|
||||
|
||||
lda tiles+12,x
|
||||
lda tiles+TILE_RIGHT_OFFSET,x
|
||||
sta scorpionTileOffsets+2
|
||||
|
||||
tax
|
||||
lda tiles+12,x
|
||||
lda tiles+TILE_RIGHT_OFFSET,x
|
||||
sta scorpionTileOffsets+4
|
||||
|
||||
lda #$7
|
||||
lda #SCORPION_SLOW_UPDATES_PER_TILE
|
||||
sta scorpionShiftInTile
|
||||
|
||||
lda #SCORPION_SPRITE_LAST_OFFSET
|
||||
sta scorpionSprite
|
||||
|
||||
addScorpion_done anop
|
||||
rtl
|
||||
|
||||
@ -226,7 +231,7 @@ shootScorpion entry
|
||||
rtl
|
||||
|
||||
|
||||
scorpionState dc i2'scorpionState_none'
|
||||
scorpionState dc i2'SCORPION_STATE_NONE'
|
||||
scorpionScreenOffset dc i2'0'
|
||||
scorpionTileOffsets dc i2'0'
|
||||
dc i2'0'
|
||||
@ -234,39 +239,42 @@ scorpionTileOffsets dc i2'0'
|
||||
scorpionShiftInTile dc i2'0'
|
||||
scorpionSprite dc i2'0'
|
||||
|
||||
scorpionLeftJumpTable dc i4'leftScorpion1s'
|
||||
|
||||
SCORPION_SPRITE_LAST_OFFSET gequ 15*4
|
||||
scorpionLeftJumpTable dc i4'leftScorpion4'
|
||||
dc i4'leftScorpion4s'
|
||||
dc i4'leftScorpion4'
|
||||
dc i4'leftScorpion4s'
|
||||
dc i4'leftScorpion3'
|
||||
dc i4'leftScorpion3s'
|
||||
dc i4'leftScorpion3'
|
||||
dc i4'leftScorpion3s'
|
||||
dc i4'leftScorpion2'
|
||||
dc i4'leftScorpion2s'
|
||||
dc i4'leftScorpion2'
|
||||
dc i4'leftScorpion2s'
|
||||
dc i4'leftScorpion1'
|
||||
dc i4'leftScorpion1s'
|
||||
dc i4'leftScorpion1'
|
||||
dc i4'leftScorpion2s'
|
||||
dc i4'leftScorpion2'
|
||||
dc i4'leftScorpion2s'
|
||||
dc i4'leftScorpion2'
|
||||
dc i4'leftScorpion3s'
|
||||
dc i4'leftScorpion3'
|
||||
dc i4'leftScorpion3s'
|
||||
dc i4'leftScorpion3'
|
||||
dc i4'leftScorpion4s'
|
||||
dc i4'leftScorpion4'
|
||||
dc i4'leftScorpion4s'
|
||||
dc i4'leftScorpion4'
|
||||
dc i4'leftScorpion1s'
|
||||
|
||||
|
||||
scorpionRightJumpTable dc i4'rightScorpion1s'
|
||||
scorpionRightJumpTable dc i4'rightScorpion4'
|
||||
dc i4'rightScorpion4s'
|
||||
dc i4'rightScorpion4'
|
||||
dc i4'rightScorpion4s'
|
||||
dc i4'rightScorpion3'
|
||||
dc i4'rightScorpion3s'
|
||||
dc i4'rightScorpion3'
|
||||
dc i4'rightScorpion3s'
|
||||
dc i4'rightScorpion2'
|
||||
dc i4'rightScorpion2s'
|
||||
dc i4'rightScorpion2'
|
||||
dc i4'rightScorpion2s'
|
||||
dc i4'rightScorpion1'
|
||||
dc i4'rightScorpion1s'
|
||||
dc i4'rightScorpion1'
|
||||
dc i4'rightScorpion2s'
|
||||
dc i4'rightScorpion2'
|
||||
dc i4'rightScorpion2s'
|
||||
dc i4'rightScorpion2'
|
||||
dc i4'rightScorpion3s'
|
||||
dc i4'rightScorpion3'
|
||||
dc i4'rightScorpion3s'
|
||||
dc i4'rightScorpion3'
|
||||
dc i4'rightScorpion4s'
|
||||
dc i4'rightScorpion4'
|
||||
dc i4'rightScorpion4s'
|
||||
dc i4'rightScorpion4'
|
||||
dc i4'rightScorpion1s'
|
||||
|
||||
|
||||
end
|
||||
|
@ -20,6 +20,11 @@ SCREEN_BYTES_PER_ROW gequ 160
|
||||
|
||||
SIZEOF_TILE_INFO gequ 16
|
||||
|
||||
TILE_PIXEL_WIDTH gequ 8
|
||||
TILE_PIXEL_HEIGHT gequ 8
|
||||
|
||||
TILE_BYTE_WIDTH gequ TILE_PIXEL_WIDTH/2
|
||||
|
||||
GAME_NUM_TILES_WIDE gequ 25
|
||||
GAME_NUM_TILES_TALL gequ 25
|
||||
|
||||
@ -103,9 +108,13 @@ TILE_SOLID3 gequ 51*4
|
||||
|
||||
TILE_PLAYER gequ 52*4
|
||||
|
||||
|
||||
tileState gequ tiles
|
||||
tileScreenOffset gequ tileState+2
|
||||
TILE_DIRTY_OFFSET gequ 0
|
||||
TILE_SCREEN_OFFSET_OFFSET gequ 2
|
||||
TILE_TYPE_OFFSET gequ 4
|
||||
TILE_ABOVE_OFFSET gequ 6
|
||||
TILE_BELOW_OFFSET gequ 8
|
||||
TILE_LEFT_OFFSET gequ 10
|
||||
TILE_RIGHT_OFFSET gequ 12
|
||||
|
||||
|
||||
backupStack dc i2'0'
|
||||
|
Loading…
Reference in New Issue
Block a user