Add the code to shoot mushrooms and hook up a debug routine to shoot random mushrooms.

This commit is contained in:
Jeremy Rand 2020-10-26 23:26:12 -04:00
parent 0dd8222611
commit 62fcc82790
4 changed files with 82 additions and 3 deletions

View File

@ -78,6 +78,7 @@
9D3396FF24AED09D003222B3 /* sprites.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = sprites.md; sourceTree = "<group>"; };
9D33970024AEFBF2003222B3 /* segments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = segments.s; sourceTree = "<group>"; };
9D33970124AF9D55003222B3 /* sprites.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = sprites.macros; sourceTree = "<group>"; };
9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameMushroom.s; sourceTree = "<group>"; };
9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = "<group>"; };
9D62AF3F2499CD1E00348F45 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@ -141,6 +142,7 @@
9DB1505124C6875C00558B87 /* gameScorpion.s */,
9DB1505324C9E54C00558B87 /* gameSpider.s */,
9DB1505424D3BF6C00558B87 /* gameSegments.s */,
9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */,
9D8AF0B72535542400C10E3C /* level.s */,
9D8AF0B82535543000C10E3C /* score.s */,
9D62AF3B249871A300348F45 /* colour.s */,

View File

@ -242,7 +242,12 @@ checkKey_loop2 anop
beq checkKey_shootSpider
cmp #'P'
beq checkKey_shootSpider
cmp #'m'
beq checkKey_shootMushroom
cmp #'M'
beq checkKey_shootMushroom
cmp #'+'
beq checkKey_scoreAdd
@ -269,6 +274,9 @@ checkKey_shootSpider anop
checkKey_shootCentipede anop
jmp shootRandomSegment
checkKey_shootMushroom anop
jmp shootRandomMushroom
checkKey_scoreAdd anop
jmp scoreAddTwentyThousand

70
BuGS/gameMushroom.s Normal file
View File

@ -0,0 +1,70 @@
;
; gameMushroom.s
; BuGS
;
; Created by Jeremy Rand on 2020-10-26.
;Copyright © 2020 Jeremy Rand. All rights reserved.
;
case on
mcopy gameMushroom.macros
keep gameMushroom
gameMushroom start
using globalData
; Call this with the tile offset of the mushroom being shot in the X register
shootMushroom entry
ldy tileType,x
beq shootMushroom_done
lda #TILE_STATE_DIRTY
sta tileDirty,x
cpy #TILE_POISON_MUSHROOM1
bge shootMushroom_poisoned
tya
sec
sbc #4
sta tileType,x
bne shootMushroom_done
jmp scoreAddOne
shootMushroom_poisoned anop
bne shootMushroom_poisonedNoScore
lda #TILE_EMPTY
sta tileType,x
jmp scoreAddOne
shootMushroom_poisonedNoScore anop
tya
sec
sbc #4
sta tileType,x
shootMushroom_done anop
rtl
shootRandomMushroom entry
lda prevRandomMushroom
cmp #RHS_FIRST_TILE_OFFSET
bge shootRandomMushroom_doRandom
tax
bra shootRandomMushroom_testTile
shootRandomMushroom_doRandom anop
jsl rand0_to_65534
and #1023
cmp #24*25
bge shootRandomMushroom_doRandom
asl a
tax
shootRandomMushroom_testTile anop
lda tileType,x
beq shootRandomMushroom_doRandom
stx prevRandomMushroom
jmp shootMushroom
prevRandomMushroom dc i2'RHS_FIRST_TILE_OFFSET'
end

View File

@ -11,8 +11,7 @@
keep globals
globals start
rtl
end
end
globalData data