diff --git a/BuGS.xcodeproj/project.pbxproj b/BuGS.xcodeproj/project.pbxproj index aaae76b..fe910f2 100644 --- a/BuGS.xcodeproj/project.pbxproj +++ b/BuGS.xcodeproj/project.pbxproj @@ -78,6 +78,7 @@ 9D3396FF24AED09D003222B3 /* sprites.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = sprites.md; sourceTree = ""; }; 9D33970024AEFBF2003222B3 /* segments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = segments.s; sourceTree = ""; }; 9D33970124AF9D55003222B3 /* sprites.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = sprites.macros; sourceTree = ""; }; + 9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameMushroom.s; sourceTree = ""; }; 9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = ""; }; 9D62AF3F2499CD1E00348F45 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -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 */, diff --git a/BuGS/game.s b/BuGS/game.s index 22882d0..06e0338 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -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 diff --git a/BuGS/gameMushroom.s b/BuGS/gameMushroom.s new file mode 100644 index 0000000..bacd0e4 --- /dev/null +++ b/BuGS/gameMushroom.s @@ -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 diff --git a/BuGS/globals.s b/BuGS/globals.s index ebaddb2..1a78156 100644 --- a/BuGS/globals.s +++ b/BuGS/globals.s @@ -11,8 +11,7 @@ keep globals globals start - rtl - end + end globalData data