mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-01-30 04:30:43 +00:00
Use macros to reduce the copy/pasted code for marking tiles as dirty. Rough out the support for body and head segments.
This commit is contained in:
parent
2b45813cbb
commit
7d7afc908d
@ -87,6 +87,8 @@
|
||||
9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = "<group>"; };
|
||||
9DB1505224C7495400558B87 /* globals.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = globals.s; sourceTree = "<group>"; };
|
||||
9DB1505324C9E54C00558B87 /* gameSpider.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSpider.s; sourceTree = "<group>"; };
|
||||
9DB1505424D3BF6C00558B87 /* gameSegments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; };
|
||||
9DB1505524D3BFCE00558B87 /* global.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = global.macros; sourceTree = "<group>"; };
|
||||
9DC4D7BD24B7652100BACF4B /* ship.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = ship.s; sourceTree = "<group>"; };
|
||||
9DC4D7BE24B80C9600BACF4B /* shot.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = shot.s; sourceTree = "<group>"; };
|
||||
9DC4D7BF24BE9F7100BACF4B /* tiles.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tiles.h; sourceTree = "<group>"; };
|
||||
@ -136,9 +138,11 @@
|
||||
9DB1505024C3801100558B87 /* gameFlea.s */,
|
||||
9DB1505124C6875C00558B87 /* gameScorpion.s */,
|
||||
9DB1505324C9E54C00558B87 /* gameSpider.s */,
|
||||
9DB1505424D3BF6C00558B87 /* gameSegments.s */,
|
||||
9D62AF3B249871A300348F45 /* colour.s */,
|
||||
9D2FF6DA24C4C79A000181E5 /* random.s */,
|
||||
9DB1505224C7495400558B87 /* globals.s */,
|
||||
9DB1505524D3BFCE00558B87 /* global.macros */,
|
||||
9D3396F324AECACC003222B3 /* sprites */,
|
||||
9D1716912491C49300C83148 /* main.rez */,
|
||||
9D1716932491C49300C83148 /* Makefile */,
|
||||
|
@ -54,7 +54,7 @@ REZFLAGS+=
|
||||
MACGENFLAGS+=
|
||||
|
||||
# Add any other macro libraries to include in this variable:
|
||||
MACGENMACROS+=sprites/sprites.macros
|
||||
MACGENMACROS+=sprites/sprites.macros global.macros
|
||||
|
||||
# Add any arguments you want passed to the assembler to this variable:
|
||||
ASMFLAGS+=
|
||||
|
@ -31,9 +31,10 @@ game start
|
||||
|
||||
gameLoop anop
|
||||
jsl drawDirtyGameTiles
|
||||
jsl drawScorpion
|
||||
jsl drawSpider
|
||||
jsl drawScorpion
|
||||
jsl drawFlea
|
||||
jsl drawSegments
|
||||
jsl drawDirtyNonGameTiles
|
||||
|
||||
short i,m
|
||||
@ -45,6 +46,7 @@ gameLoop anop
|
||||
jsl updateScorpion
|
||||
jsl updateSpider
|
||||
jsl updateFlea
|
||||
jsl updateSegments
|
||||
jsl checkKeyboard
|
||||
|
||||
jsl waitForVbl
|
||||
|
@ -33,53 +33,11 @@ drawFlea entry
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
|
||||
ldx fleaTileOffsets
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile1
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
_dirtyGameTile fleaTileOffsets
|
||||
_dirtyGameTile fleaTileOffsets+2
|
||||
_dirtyGameTile fleaTileOffsets+4
|
||||
_dirtyGameTile fleaTileOffsets+6
|
||||
|
||||
drawFlea_skipTile1 anop
|
||||
|
||||
ldx fleaTileOffsets+2
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile2
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
|
||||
drawFlea_skipTile2 anop
|
||||
|
||||
ldx fleaTileOffsets+4
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile3
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
|
||||
drawFlea_skipTile3 anop
|
||||
|
||||
ldx fleaTileOffsets+6
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawFlea_skipTile4
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
|
||||
drawFlea_skipTile4 anop
|
||||
sty numDirtyGameTiles
|
||||
|
||||
drawFlea_done anop
|
||||
|
@ -36,78 +36,10 @@ drawScorpion_cont anop
|
||||
ldx scorpionSprite
|
||||
jsl scorpionJump
|
||||
|
||||
ldx scorpionTileOffsets
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_skipTile1
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame1
|
||||
_dirtyGameOrNonGameTile scorpionTileOffsets
|
||||
_dirtyGameOrNonGameTile scorpionTileOffsets+2
|
||||
_dirtyGameOrNonGameTile scorpionTileOffsets+4
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawScorpion_skipTile1
|
||||
|
||||
drawScorpion_nonGame1 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawScorpion_skipTile1 anop
|
||||
ldx scorpionTileOffsets+2
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_skipTile2
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame2
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawScorpion_skipTile2
|
||||
|
||||
drawScorpion_nonGame2 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawScorpion_skipTile2 anop
|
||||
ldx scorpionTileOffsets+4
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawScorpion_done
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawScorpion_nonGame3
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
rtl
|
||||
|
||||
drawScorpion_nonGame3 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawScorpion_done anop
|
||||
rtl
|
||||
|
||||
|
||||
|
42
BuGS/gameSegments.s
Normal file
42
BuGS/gameSegments.s
Normal file
@ -0,0 +1,42 @@
|
||||
;
|
||||
; gameSegments.s
|
||||
; BuGS
|
||||
;
|
||||
; Created by Jeremy Rand on 2020-07-30.
|
||||
;Copyright © 2020 Jeremy Rand. All rights reserved.
|
||||
;
|
||||
|
||||
case on
|
||||
mcopy gameSegments.macros
|
||||
keep gameSegments
|
||||
|
||||
gameSegments start
|
||||
using globalData
|
||||
|
||||
|
||||
drawSegments entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
updateSegments entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
addBodySegment entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
addHeadSegment entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
shootSegment entry
|
||||
; Write this code...
|
||||
rtl
|
||||
|
||||
|
||||
end
|
@ -71,150 +71,13 @@ drawSpider_cont anop
|
||||
ldx spiderSprite
|
||||
jsl spiderJump
|
||||
|
||||
ldx spiderTileOffsets
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_skipTile1
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame1
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets+2
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets+4
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets+6
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets+8
|
||||
_dirtyGameOrNonGameTile spiderTileOffsets+10
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawSpider_skipTile1
|
||||
|
||||
drawSpider_nonGame1 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_skipTile1 anop
|
||||
ldx spiderTileOffsets+2
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_skipTile2
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame2
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawSpider_skipTile2
|
||||
|
||||
drawSpider_nonGame2 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_skipTile2 anop
|
||||
ldx spiderTileOffsets+4
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_skipTile3
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame3
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawSpider_skipTile3
|
||||
|
||||
drawSpider_nonGame3 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_skipTile3 anop
|
||||
ldx spiderTileOffsets+6
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_skipTile4
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame4
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawSpider_skipTile4
|
||||
|
||||
drawSpider_nonGame4 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_skipTile4 anop
|
||||
ldx spiderTileOffsets+8
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_skipTile5
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame5
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra drawSpider_skipTile5
|
||||
|
||||
drawSpider_nonGame5 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_skipTile5 anop
|
||||
ldx spiderTileOffsets+10
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne drawSpider_done
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge drawSpider_nonGame6
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
rtl
|
||||
|
||||
drawSpider_nonGame6 anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
drawSpider_done anop
|
||||
rtl
|
||||
|
||||
spiderJump entry
|
||||
|
56
BuGS/global.macros
Normal file
56
BuGS/global.macros
Normal file
@ -0,0 +1,56 @@
|
||||
;
|
||||
; global.macros
|
||||
; BuGS
|
||||
;
|
||||
; Created by Jeremy Rand on 2020-07-30.
|
||||
;Copyright © 2020 Jeremy Rand. All rights reserved.
|
||||
;
|
||||
|
||||
|
||||
; Call this with Y already loaded with the numDirtyGameTiles. Also, the new
|
||||
; numDirtyGameTiles is left in Y. The caller must store it.
|
||||
macro
|
||||
_dirtyGameTile &tileOffset
|
||||
|
||||
ldx &tileOffset
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne _dirtyGameTile_skip&SYSCNT
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
|
||||
_dirtyGameTile_skip&SYSCNT anop
|
||||
mend
|
||||
|
||||
|
||||
macro
|
||||
_dirtyGameOrNonGameTile &tileOffset
|
||||
|
||||
ldx &tileOffset
|
||||
lda tiles+TILE_DIRTY_OFFSET,x
|
||||
bne _dirtyGameTile_skip&SYSCNT
|
||||
lda #TILE_STATE_DIRTY
|
||||
sta tiles+TILE_DIRTY_OFFSET,x
|
||||
txa
|
||||
cmp #RHS_FIRST_TILE_OFFSET
|
||||
bge _dirtyGameTile_nonGame&SYSCNT
|
||||
|
||||
ldy numDirtyGameTiles
|
||||
sta dirtyGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyGameTiles
|
||||
bra _dirtyGameTile_skip&SYSCNT
|
||||
|
||||
_dirtyGameTile_nonGame&SYSCNT anop
|
||||
ldy numDirtyNonGameTiles
|
||||
sta dirtyNonGameTiles,y
|
||||
iny
|
||||
iny
|
||||
sty numDirtyNonGameTiles
|
||||
|
||||
_dirtyGameTile_skip&SYSCNT anop
|
||||
mend
|
@ -708,10 +708,10 @@
|
||||
|
||||
tax
|
||||
and &mask
|
||||
beq ~&SYSCNT
|
||||
beq _noCollision_&SYSCNT
|
||||
sta collision
|
||||
|
||||
~&SYSCNT anop
|
||||
_noCollision_&SYSCNT anop
|
||||
txa
|
||||
|
||||
mend
|
||||
|
@ -43,10 +43,9 @@ Each colour is 4 bits wide. All zeros is always black in all the different pall
|
||||
* solid squares (primarily the all black square)
|
||||
|
||||
These sprites generally draw first and overwrite what may have been there before. After the background layer is drawn, other things are drawn in this order:
|
||||
* spiders
|
||||
* spiders/scores
|
||||
* scorpions
|
||||
* fleas
|
||||
* scores
|
||||
* centipede segments
|
||||
* missle
|
||||
* player
|
||||
@ -63,4 +62,4 @@ An exception to the "background is drawn first" rule though is the non-playable
|
||||
|
||||
We also need to clip a flea which is dropping down from the top. The solution there is that the game allocates memory before the SHR page, enough for an extra unseen tile above the screen. A partially obscured flea is drawn offscreen into that part of memory before the SHR page.
|
||||
|
||||
There is a similar problem when the flea reaches the bottom of the screen. I haven't decided how to handle this yet. After the SHR screen are the screen control bytes and the colour palettes so I can't just overwrite that memory with the off-screen flea sprite. I could maybe allow the flea to corrupt this memory and then try to repair it. Or maybe the flea sprite code will need to have special cases for the last few lines of the screen. This problem is still to be solved.
|
||||
There is a similar problem when the flea reaches the bottom of the screen. I have decided to just not handle it. The flea disappears once it reaches the bottom of the screen. It does not scroll off the bottom.
|
||||
|
Loading…
x
Reference in New Issue
Block a user