diff --git a/BuGS.xcodeproj/project.pbxproj b/BuGS.xcodeproj/project.pbxproj index 957e79c..17777b3 100644 --- a/BuGS.xcodeproj/project.pbxproj +++ b/BuGS.xcodeproj/project.pbxproj @@ -78,8 +78,9 @@ 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 = ""; }; - 9D47CC14254A698900CDA5CB /* gamePlayer.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gamePlayer.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; + 9D47CC14254A698900CDA5CB /* gamePlayer.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gamePlayer.s; sourceTree = ""; }; 9D47CCBA25525C1A00CDA5CB /* tileData.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = tileData.pl; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.perl; }; + 9D53E5B32562320300E10169 /* gameShot.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameShot.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 = ""; }; @@ -143,6 +144,7 @@ 9DB1505424D3BF6C00558B87 /* gameSegments.s */, 9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */, 9D47CC14254A698900CDA5CB /* gamePlayer.s */, + 9D53E5B32562320300E10169 /* gameShot.s */, 9D8AF0B72535542400C10E3C /* level.s */, 9D8AF0B82535543000C10E3C /* score.s */, 9D62AF3B249871A300348F45 /* colour.s */, diff --git a/BuGS/game.s b/BuGS/game.s index b923a85..b855fd1 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -106,6 +106,7 @@ gameLoop anop long i,m jsl updatePlayer + jsl updateShot jsl updateScorpion jsl updateSpider jsl updateFlea @@ -219,6 +220,7 @@ startLevel entry jsl scorpionInitLevel jsl spiderInitLevel jsl fleaInitLevel + jsl shotInitLevel jsl playerLevelStart jmp levelStart diff --git a/BuGS/gamePlayer.s b/BuGS/gamePlayer.s index e8530c1..5f2c62e 100644 --- a/BuGS/gamePlayer.s +++ b/BuGS/gamePlayer.s @@ -221,11 +221,16 @@ updatePlayer_negY anop updatePlayer_doneY anop sta mouseY -; The Y register also has a bit in it which indicates whether the -; mouse is down or not. +; The X and Y register also has a bit in each which indicates whether a +; mouse button is down or not. + txa + and #$0080 + beq updatePlayer_mouseDown tya and #$0080 - sta mouseDown + bne updatePlayer_skipDeltas +updatePlayer_mouseDown anop + jsl maybeShoot updatePlayer_skipDeltas anop lda mouseY @@ -318,10 +323,6 @@ updatePlayer_tileOffscreen2 anop updatePlayer_done anop rtl -mouseX dc i2'0' -mouseY dc i2'0' -mouseDown dc i2'0' - playerFrameCount dc i2'0' playerExplosionOffset dc i2'0' diff --git a/BuGS/gameShot.s b/BuGS/gameShot.s new file mode 100644 index 0000000..ff32184 --- /dev/null +++ b/BuGS/gameShot.s @@ -0,0 +1,84 @@ +; +; gameShot.s +; BuGS +; +; Created by Jeremy Rand on 2020-11-15. +;Copyright © 2020 Jeremy Rand. All rights reserved. +; + + case on + mcopy gameShot.macros + keep gameShot + +gameShot start + using globalData + using tileData + using screenData + +SHOT_STATE_NONE equ 0 +SHOT_STATE_START_SHOOTING equ 1 +SHOT_STATE_SHOOTING equ 2 + + +shotInitLevel entry + stz shotState + rtl + +maybeShoot entry + lda shotState + bne maybeShoot_alreadyShooting + lda #SHOT_STATE_START_SHOOTING + sta shotState +maybeShoot_alreadyShooting anop + rtl + + +updateShot entry + lda playerState + cmp #PLAYER_STATE_ONSCREEN + beq updateShot_playerOnscreen + rtl +updateShot_playerOnscreen anop + lda shotState + bne updateShot_notNone + lda mouseX + and #1 + bne updateShot_shifted + lda mouseAddress + sec + sbc #$1df + tay + sec + sbc #SCREEN_ADDRESS + and #$fffc + tax + lda >screenToTileOffset,x + tax + lda #TILE_STATE_DIRTY + sta tileDirty,x + jmp >drawHalfShot +updateShot_shifted anop + lda mouseAddress + sec + sbc #$1de + tay + sec + sbc #SCREEN_ADDRESS + and #$fffc + tax + lda >screenToTileOffset,x + tax + lda #TILE_STATE_DIRTY + sta tileDirty,x + jmp >drawHalfShotShift + + +updateShot_notNone anop + rtl + + +shotState dc i2'SHOT_STATE_NONE' +shotShifted dc i2'0' +shotAddress dc i2'0' + + end diff --git a/BuGS/globals.s b/BuGS/globals.s index 6474bff..6769e98 100644 --- a/BuGS/globals.s +++ b/BuGS/globals.s @@ -138,6 +138,8 @@ numInfieldMushrooms dc i2'0' playerState dc i2'PLAYER_STATE_NONE' +mouseX dc i2'0' +mouseY dc i2'0' mouseAddress dc i2'0' backupStack dc i2'0' diff --git a/BuGS/sprites/ship.s b/BuGS/sprites/ship.s index 2b1952d..58601f0 100644 --- a/BuGS/sprites/ship.s +++ b/BuGS/sprites/ship.s @@ -32,19 +32,19 @@ drawShip entry stz collision lda $0,s - _collision #$0c00 + _collision #$0c00,#$0 and #$f0ff ora #$0800 sta $0,s lda $a0,s - _collision #$cc00 + _collision #$cc00,#$a0 and #$00ff ora #$8800 sta $a0,s lda $a2,s - _collision #$00c0 + _collision #$00c0,#$a2 and #$ff0f ora #$0080 sta $a2,s @@ -54,24 +54,24 @@ drawShip entry tcs lda $0,s - _collision #$cc0c + _collision #$cc0c,#$0 and #$00f0 ora #$4804 sta $0,s lda $2,s - _collision #$00cc + _collision #$00cc,#$2 and #$ff00 ora #$0044 sta $2,s lda $a0,s - _collision #$cccc + _collision #$cccc,#$a0 lda #$4884 sta $a0,s lda $a2,s - _collision #$c0cc + _collision #$c0cc,#$a2 and #$0f00 ora #$8044 sta $a2,s @@ -81,24 +81,24 @@ drawShip entry tcs lda $a0,s - _collision #$cccc + _collision #$cccc,#$a0 lda #$8888 sta $0,s lda $2,s - _collision #$c0cc + _collision #$c0cc,#$2 and #$0f00 ora #$8088 sta $2,s lda $a0,s - _collision #$cc0c + _collision #$cc0c,#$a0 and #$00f0 ora #$8808 sta $a0,s lda $a2,s - _collision #$00cc + _collision #$00cc,#$a2 and #$ff00 ora #$0088 sta $a2,s @@ -108,32 +108,33 @@ drawShip entry tcs lda $0,s - _collision #$cc00 + _collision #$cc00,#$0 and #$00ff ora #$8800 sta $0,s lda $2,s - _collision #$00c0 + _collision #$00c0,#$2 and #$ff0f ora #$0080 sta $2,s lda $a0,s - _collision #$cc00 + _collision #$cc00,#$a0 and #$00ff ora #$8800 sta $a0,s lda $a2,s - _collision #$00c0 + _collision #$00c0,#$a2 and #$ff0f ora #$0080 sta $a2,s _spriteFooter - lda collision + ldx collisionAddr + lda collision rtl @@ -156,19 +157,19 @@ drawShipShift entry stz collision lda $2,s - _collision #$00c0 + _collision #$00c0,#$2 and #$ff0f ora #$0080 sta $2,s lda $a0,s - _collision #$0c00 + _collision #$0c00,#$a0 and #$f0ff ora #$0800 sta $a0,s lda $a2,s - _collision #$00cc + _collision #$00cc,#$a2 and #$ff00 ora #$0088 sta $a2,s @@ -178,25 +179,25 @@ drawShipShift entry tcs lda $0,s - _collision #$cc00 + _collision #$cc00,#$0 and #$00ff ora #$4400 sta $0,s lda $2,s - _collision #$c0cc + _collision #$c0cc,#$2 and #$0f00 ora #$4084 sta $2,s lda $a0,s - _collision #$cc0c + _collision #$cc0c,#$a0 and #$00f0 ora #$4408 sta $a0,s lda $a2,s - _collision #$cccc + _collision #$cccc,#$a2 lda #$4884 sta $a2,s @@ -205,24 +206,24 @@ drawShipShift entry tcs lda $0,s - _collision #$cc0c + _collision #$cc0c,#$0 and #$00f0 ora #$8808 sta $0,s lda $2,s - _collision #$cccc + _collision #$cccc,#$2 lda #$8888 sta $2,s lda $a0,s - _collision #$cc00 + _collision #$cc00,#$a0 and #$00ff ora #$8800 sta $a0,s lda $a2,s - _collision #$c0cc + _collision #$c0cc,#$a2 and #$0f00 ora #$8088 sta $a2,s @@ -232,31 +233,32 @@ drawShipShift entry tcs lda $0,s - _collision #$0c00 + _collision #$0c00,#$0 and #$f0ff ora #$0800 sta $0,s lda $2,s - _collision #$00cc + _collision #$00cc,#$2 and #$ff00 ora #$0088 sta $2,s lda $a0,s - _collision #$0c00 + _collision #$0c00,#$a0 and #$f0ff ora #$0800 sta $a0,s lda $a2,s - _collision #$00cc + _collision #$00cc,#$a2 and #$ff00 ora #$0088 sta $a2,s _spriteFooter - + + ldx collisionAddr lda collision rtl @@ -342,5 +344,6 @@ drawPlayer entry collision dc i2'0' +collisionAddr dc i2'0' end diff --git a/BuGS/sprites/shot.s b/BuGS/sprites/shot.s index e969757..20cc65e 100644 --- a/BuGS/sprites/shot.s +++ b/BuGS/sprites/shot.s @@ -20,23 +20,18 @@ drawHalfShot entry ; $4 - Red ; $8 - Off-white ; -; ....|.... -; ....|.... -; ....|.... -; ....|.... -; ....|.... -; ...R|.... -; ...R|.... -; ...R|.... +; .R.. +; .R.. +; .R.. - tsc - adc #$280 - tcs + lda $0,s + and #$fff0 + ora #$0004 + sta $0,s lda $a0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + and #$fff0 + ora #$0004 sta $a0,s tsc @@ -44,20 +39,11 @@ drawHalfShot entry tcs lda $0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + and #$fff0 + ora #$0004 sta $0,s - lda $a0,s - _collision #$0f00 - and #$f0ff - ora #$0400 - sta $a0,s - _spriteFooter - - lda collision rtl @@ -68,44 +54,30 @@ drawHalfShotShift entry ; $4 - Red ; $8 - Off-white ; -; ....|.... -; ....|.... -; ....|.... -; ....|.... -; ....|.... -; ....|R... -; ....|R... -; ....|R... +; R... +; R... +; R... - tsc - adc #$280 - tcs + lda $0,s + and #$ff0f + ora #$0040 + sta $0,s - lda $a2,s - _collision #$00f0 + lda $a0,s and #$ff0f ora #$0040 - sta $a2,s + sta $a0,s tsc adc #$140 tcs - lda $2,s - _collision #$00f0 + lda $0,s and #$ff0f ora #$0040 - sta $2,s - - lda $a2,s - _collision #$00f0 - and #$ff0f - ora #$0040 - sta $a2,s + sta $0,s _spriteFooter - - lda collision rtl @@ -116,29 +88,25 @@ drawShot entry ; $4 - Red ; $8 - Off-white ; -; ....|.... -; ....|.... -; ...R|.... -; ...R|.... -; ...R|.... -; ...R|.... -; ...R|.... -; ...R|.... +; .R.. +; .R.. +; .R.. +; .R.. +; .R.. +; .R.. - tsc - adc #$140 - tcs + stz collision lda $0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$0 + and #$fff0 + ora #$0004 sta $0,s lda $a0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$a0 + and #$fff0 + ora #$0004 sta $a0,s tsc @@ -146,15 +114,15 @@ drawShot entry tcs lda $0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$0 + and #$fff0 + ora #$0004 sta $0,s lda $a0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$a0 + and #$fff0 + ora #$0004 sta $a0,s tsc @@ -162,19 +130,20 @@ drawShot entry tcs lda $0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$0 + and #$fff0 + ora #$0004 sta $0,s lda $a0,s - _collision #$0f00 - and #$f0ff - ora #$0400 + _collision #$000f,#$a0 + and #$fff0 + ora #$0004 sta $a0,s _spriteFooter - + + ldx collisionAddr lda collision rtl @@ -186,69 +155,67 @@ drawShotShift entry ; $4 - Red ; $8 - Off-white ; -; ....|.... -; ....|.... -; ....|R... -; ....|R... -; ....|R... -; ....|R... -; ....|R... -; ....|R... +; R... +; R... +; R... +; R... +; R... +; R... - tsc - adc #$140 - tcs + stz collision - lda $2,s - _collision #$00f0 + lda $0,s + _collision #$00f0,#$0 and #$ff0f ora #$0040 - sta $2,s + sta $0,s - lda $a2,s - _collision #$00f0 + lda $a0,s + _collision #$00f0,#$a0 and #$ff0f ora #$0040 - sta $a2,s + sta $a0,s tsc adc #$140 tcs - lda $2,s - _collision #$00f0 + lda $0,s + _collision #$00f0,#$0 and #$ff0f ora #$0040 - sta $2,s + sta $0,s - lda $a2,s - _collision #$00f0 + lda $a0,s + _collision #$00f0,#$a0 and #$ff0f ora #$0040 - sta $a2,s + sta $a0,s tsc adc #$140 tcs - lda $2,s - _collision #$00f0 + lda $0,s + _collision #$00f0,#$0 and #$ff0f ora #$0040 - sta $2,s + sta $0,s - lda $a2,s - _collision #$00f0 + lda $a0,s + _collision #$00f0,#$a0 and #$ff0f ora #$0040 - sta $a2,s + sta $a0,s _spriteFooter + ldx collisionAddr lda collision rtl collision dc i2'0' +collisionAddr dc i2'0' end diff --git a/BuGS/sprites/sprites.macros b/BuGS/sprites/sprites.macros index 09051c5..7d4c13e 100644 --- a/BuGS/sprites/sprites.macros +++ b/BuGS/sprites/sprites.macros @@ -704,14 +704,18 @@ mend macro - _collision &mask - + _collision &mask,&addr + ldy collision + bne _alreadyCollided_&SYSCNT tax and &mask beq _noCollision_&SYSCNT sta collision - + tsc + clc + adc &addr + sta collisionAddr _noCollision_&SYSCNT anop txa - +_alreadyCollided_&SYSCNT anop mend