From 9a34532d77900e28598f42186ad6c936127ae5a9 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Thu, 22 Oct 2020 00:00:16 -0400 Subject: [PATCH] Implement the code to add spiders to the game. From my testing, it looks like 2 seconds after a spider leaves the game (either shot or off the screen), another one is added. Also, once the score is about 5000, the spiders added will be fast. The only spider behaviour I know of which is so far not implemented is as the player reaches higher levels, the spider constrains itself closer and closer to the bottom of the screen. --- BuGS.xcodeproj/project.pbxproj | 2 +- .../xcschemes/xcschememanagement.plist | 4 +- BuGS/game.s | 11 ++--- BuGS/gameSpider.s | 47 +++++++++++++++++-- BuGS/globals.s | 1 + BuGS/score.s | 1 - 6 files changed, 51 insertions(+), 15 deletions(-) diff --git a/BuGS.xcodeproj/project.pbxproj b/BuGS.xcodeproj/project.pbxproj index 84a1603..aaae76b 100644 --- a/BuGS.xcodeproj/project.pbxproj +++ b/BuGS.xcodeproj/project.pbxproj @@ -83,7 +83,7 @@ 9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 9D8AF0B72535542400C10E3C /* level.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = level.s; sourceTree = ""; }; 9D8AF0B82535543000C10E3C /* score.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = score.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; - 9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = ""; }; + 9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; 9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = ""; }; 9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = ""; }; 9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = ""; }; diff --git a/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist b/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist index 0d0faee..1ebd7b3 100644 --- a/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ Binary.xcscheme_^#shared#^_ orderHint - 3 + 1 BuGS.xcscheme_^#shared#^_ @@ -17,7 +17,7 @@ DiskImage.xcscheme_^#shared#^_ orderHint - 1 + 3 doNotBuild.xcscheme_^#shared#^_ diff --git a/BuGS/game.s b/BuGS/game.s index 1a568c2..8b96ffc 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -207,6 +207,7 @@ nextWord anop startGame entry stz gameRunning stz numSegments + jsl spiderInitGame jsl levelInit jmp levelStart @@ -238,7 +239,7 @@ checkKey_loop2 anop beq checkKey_shootScorpion cmp #'p' - beq checkKey_addSpider + beq checkKey_shootSpider cmp #'P' beq checkKey_shootSpider @@ -249,6 +250,7 @@ checkKey_loop2 anop cmp #'g' beq checkKey_game + cmp #'c' beq checkKey_shootCentipede cmp #'C' @@ -269,9 +271,6 @@ checkKey_addScorpion anop checkKey_shootScorpion anop jmp shootScorpion -checkKey_addSpider anop - jmp addSpider - checkKey_shootSpider anop jmp shootSpider @@ -286,16 +285,12 @@ checkKey_fast anop lda #SPRITE_SPEED_FAST jsl setFleaSpeed lda #SPRITE_SPEED_FAST - jsl setSpiderSpeed - lda #SPRITE_SPEED_FAST jmp setScorpionSpeed checkKey_slow anop lda #SPRITE_SPEED_SLOW jsl setFleaSpeed lda #SPRITE_SPEED_SLOW - jsl setSpiderSpeed - lda #SPRITE_SPEED_SLOW jmp setScorpionSpeed checkKey_game anop diff --git a/BuGS/gameSpider.s b/BuGS/gameSpider.s index ee3762d..e8cf211 100644 --- a/BuGS/gameSpider.s +++ b/BuGS/gameSpider.s @@ -60,6 +60,16 @@ SPIDER_LEFT_SCREEN_SHIFT_FAST equ 0 SPIDER_RIGHT_SCREEN_SHIFT_SLOW equ 0 SPIDER_RIGHT_SCREEN_SHIFT_FAST equ 1 +; Two seconds or 120 frames after a spider disappears, a spider is added. +SPIDER_ADD_TIME equ 120 + + +spiderInitGame entry + stz spiderAddTime + stz spiderState + lda #SPRITE_SPEED_SLOW + jmp setSpiderSpeed + drawSpider entry lda spiderState @@ -266,7 +276,23 @@ updateSpider_leftDiagDown_cont anop jmp updateSpider_tilesLeft updateSpider_done anop - rtl + rtl + +updateSpider_maybeAdd anop + lda gameRunning + bne updateSpider_done + lda spiderAddTime + bne updateSpider_waitForAdd + lda #SPIDER_ADD_TIME + sta spiderAddTime + rtl + +updateSpider_waitForAdd anop + dec a + sta spiderAddTime + bne updateSpider_done + jmp addSpider + updateSpider_leftDiagUp anop lda spiderScreenOffset @@ -521,9 +547,21 @@ updateSpider_offScreen anop addSpider entry lda spiderState - beq addSpider_doit + beq addSpider_checkSpeed rtl +addSpider_checkSpeed anop + lda gameScore+2 + bne addSpider_fast + lda gameScore + cmp #5000 + blt addSpider_doit +addSpider_fast anop + lda #SPRITE_SPEED_FAST + cmp spiderSpeed + beq addSpider_doit + jsl setSpiderSpeed + addSpider_doit anop lda spiderStartingShift sta spiderShiftInTile @@ -616,6 +654,7 @@ addSpider_right anop setSpiderSpeed entry + sta spiderSpeed cmp #SPRITE_SPEED_FAST beq setSpiderSpeed_fast @@ -715,11 +754,13 @@ shootSpider_done anop spiderState dc i2'SPIDER_STATE_NONE' +spiderSpeed dc i2'SPRITE_SPEED_SLOW' spiderSprite dc i2'0' spiderSpriteRefresh dc i2'0' spiderScreenOffset dc i2'0' spiderScreenShift dc i2'0' spiderShiftInTile dc i2'0' +spiderAddTime dc i2'0' spiderCurrentRow dc i2'0' spiderTargetRow dc i2'0' @@ -764,7 +805,7 @@ spiderShiftJumpTable dc i4'spider7s' dc i4'spider1s' -spiderUpdateJumpTable dc i2'updateSpider_done' +spiderUpdateJumpTable dc i2'updateSpider_maybeAdd' dc i2'updateSpider_exploding' dc i2'updateSpider_score' dc i2'updateSpider_leftDiagDown' diff --git a/BuGS/globals.s b/BuGS/globals.s index d8d319c..a32a3a7 100644 --- a/BuGS/globals.s +++ b/BuGS/globals.s @@ -138,6 +138,7 @@ VERTICAL_COUNTER gequ $e0c02e gameRunning dc i2'1' numSegments dc i2'0' +gameScore dc i4'0' backupStack dc i2'0' diff --git a/BuGS/score.s b/BuGS/score.s index a628ab1..ab41e80 100644 --- a/BuGS/score.s +++ b/BuGS/score.s @@ -366,6 +366,5 @@ scoreAddOneThousand_skipZeroHundreds anop highScore dc i4'0' -gameScore dc i4'0' end