Add some code to support animating fleas in the game.

This commit is contained in:
Jeremy Rand 2020-07-18 22:11:20 -04:00
parent 3c0ac30fcb
commit 0336c692c4
3 changed files with 110 additions and 5 deletions

View File

@ -82,6 +82,7 @@
9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; 9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; }; 9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; };
9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; }; 9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; };
9DC4D7BD24B7652100BACF4B /* ship.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = ship.s; 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>"; }; 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>"; }; 9DC4D7BF24BE9F7100BACF4B /* tiles.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tiles.h; sourceTree = "<group>"; };
@ -128,6 +129,7 @@
9DC4D7C024BE9F7100BACF4B /* tiles.c */, 9DC4D7C024BE9F7100BACF4B /* tiles.c */,
9D8FFC602491CA28005C9327 /* game.s */, 9D8FFC602491CA28005C9327 /* game.s */,
9D8FFC612491CAF0005C9327 /* game.h */, 9D8FFC612491CAF0005C9327 /* game.h */,
9DB1505024C3801100558B87 /* gameFlea.s */,
9D62AF3B249871A300348F45 /* colour.s */, 9D62AF3B249871A300348F45 /* colour.s */,
9D3396F324AECACC003222B3 /* sprites */, 9D3396F324AECACC003222B3 /* sprites */,
9D1716912491C49300C83148 /* main.rez */, 9D1716912491C49300C83148 /* main.rez */,

View File

@ -26,12 +26,20 @@ game start
lda colourPalette lda colourPalette
jsl setColour jsl setColour
gameLoop anop
jsl drawDirtyGameTiles jsl drawDirtyGameTiles
jsl drawFlea
jsl drawDirtyNonGameTiles jsl drawDirtyNonGameTiles
jsl waitForKey jsl updateFlea
jsl checkKeyboard
jsl waitForVbl
lda shouldQuit
bne gameLoop
rtl rtl
@ -624,6 +632,49 @@ nextWord anop
rtl rtl
checkKeyboard entry
checkKey_loop2 anop
short i,m
lda $e0c000
bpl quit
sta $e0c010
long i,m
and #$007f
cmp #'q'
beq checkKey_quit
cmp #'Q'
beq checkKey_quit
cmp #$001b
beq checkKey_quit
cmp #'f'
beq checkKey_addFlea
cmp #'F'
beq checkKey_addFlea
lda colourPalette
inc a
cmp #$000e
blt checkKey_skip
lda #$0000
checkKey_skip anop
sta colourPalette
jsl setColour
rtl
checkKey_addFlea anop
jsl addFlea
rtl
checkKey_quit anop
stz shouldQuit
checkKey_done anop
rtl
waitForKey entry waitForKey entry
loop2 short i,m loop2 short i,m
loop1 anop loop1 anop
@ -632,9 +683,9 @@ loop1 anop
sta $e0c010 sta $e0c010
long i,m long i,m
and #$007f and #$007f
cmp #$0051 cmp #'q'
beq quit beq quit
cmp #$0071 cmp #'Q'
beq quit beq quit
cmp #$001b cmp #$001b
beq quit beq quit
@ -663,6 +714,7 @@ vblLoop2 anop
backupStack dc i2'0' backupStack dc i2'0'
colourPalette dc i2'0' colourPalette dc i2'0'
shouldQuit dc i2'1'
tileJumpTable dc a4'solid0' tileJumpTable dc a4'solid0'
dc a4'mushroom4' dc a4'mushroom4'

51
BuGS/gameFlea.s Normal file
View File

@ -0,0 +1,51 @@
;
; gameFlea.s
; BuGS
;
; Created by Jeremy Rand on 2020-07-18.
;Copyright © 2020 Jeremy Rand. All rights reserved.
;
case on
mcopy gameFlea.macros
keep gameFlea
gameFlea start
fleaState_none equ 0
fleaState_falling equ 1
fleaState_exploding equ 2
drawFlea entry
lda fleaState
beq drawFlea_done
ldy fleaScreenOffset
jsl flea1
ldx fleaTileOffsets
drawFlea_done anop
rtl
updateFlea entry
lda fleaState
beq updateFlea_done
updateFlea_done anop
rtl
addFlea entry
rtl
fleaState dc i2'fleaState_none'
fleaScreenOffset dc i2'0'
fleaTileOffsets dc i2'0'
dc i2'0'
dc i2'0'
dc i2'0'
end