From 678a9ee104f3ca8be2054962ee46789ecb7454ae Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Sun, 17 Jan 2021 14:51:36 -0500 Subject: [PATCH] Add code to keep track of two separate screens of mushrooms for player 1 and player 2. --- BuGS.xcodeproj/project.pbxproj | 2 +- BuGS/Makefile | 2 + BuGS/game.s | 70 +++++++++++++++++++++++++++++++++- BuGS/genData.pl | 18 +++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) diff --git a/BuGS.xcodeproj/project.pbxproj b/BuGS.xcodeproj/project.pbxproj index cb1ea27..7c5f32f 100644 --- a/BuGS.xcodeproj/project.pbxproj +++ b/BuGS.xcodeproj/project.pbxproj @@ -100,7 +100,7 @@ 9D6DB18625A411DA00CDBF05 /* BuGS.2mg */ = {isa = PBXFileReference; lastKnownFileType = file; path = BuGS.2mg; sourceTree = ""; }; 9D8AF0B72535542400C10E3C /* level.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = level.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; 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 = ""; }; 9D9F07F92553AB3800875B29 /* TODO.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = TODO.md; sourceTree = ""; }; 9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; diff --git a/BuGS/Makefile b/BuGS/Makefile index 027923c..9704acc 100644 --- a/BuGS/Makefile +++ b/BuGS/Makefile @@ -124,5 +124,7 @@ $(GENDIR)/tileData.s: genData.pl Makefile genclean: $(RM) $(GENDIR)/tileData.s $(GENDIR)/screenData.s $(GENDIR)/tileData.h +main.rez: $(wildcard sound/*.raw) + # Do not change anything else below here... include make/tail.mk diff --git a/BuGS/game.s b/BuGS/game.s index 5f4bd2e..226598a 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -24,6 +24,7 @@ game start using globalData using tileData + using playerData jsl setupScreen @@ -190,6 +191,15 @@ startGame_notRunning anop stz gameRunning jsl initPlayer jsl scoreStartGame + lda isSinglePlayer + beq startGame_singlePlayer + lda #PLAYER_TWO + sta playerNum + jsl addRandomMushrooms + jsl copyToPlayer2Tiles + lda #PLAYER_ONE + sta playerNum +startGame_singlePlayer anop jsl addRandomMushrooms jsl spiderInitGame jsl levelInit @@ -204,7 +214,65 @@ startLevel entry jsl playerLevelStart jmp levelStart - + +copyToPlayer1Tiles entry + ldx #0 +copyToPlayer1Tiles_loop anop + lda tileData,x + sta >player1Tiles,x + inx + inx + cpx #RHS_FIRST_TILE_OFFSET + blt copyToPlayer1Tiles_loop + rtl + + +copyToPlayer2Tiles entry + ldx #0 +copyToPlayer2Tiles_loop anop + lda tileData,x + sta >player2Tiles,x + inx + inx + cpx #RHS_FIRST_TILE_OFFSET + blt copyToPlayer2Tiles_loop + rtl + + +copyFromPlayer1Tiles entry + ldx #0 +copyFromPlayer1Tiles_loop anop + lda >player1Tiles,x + cmp tileData,x + beq copyFromPlayer1Tiles_skip + sta tileData,x + lda TILE_STATE_DIRTY + sta tileDirty,x +copyFromPlayer1Tiles_skip anop + inx + inx + cpx #RHS_FIRST_TILE_OFFSET + blt copyFromPlayer1Tiles_loop + rtl + + +copyFromPlayer2Tiles entry + ldx #0 +copyFromPlayer2Tiles_loop anop + lda >player2Tiles,x + cmp tileData,x + beq copyFromPlayer2Tiles_skip + sta tileData,x + lda TILE_STATE_DIRTY + sta tileDirty,x +copyFromPlayer2Tiles_skip anop + inx + inx + cpx #RHS_FIRST_TILE_OFFSET + blt copyFromPlayer2Tiles_loop + rtl + + overwriteGameTile entry phy tay diff --git a/BuGS/genData.pl b/BuGS/genData.pl index 9039e74..b2ee871 100755 --- a/BuGS/genData.pl +++ b/BuGS/genData.pl @@ -555,6 +555,24 @@ EOF print $fh $text; close($fh); +# Generate the playerData.s file +open $fh, ">", "$gGenDir/playerData.s" or die "$0: Unable to open $gGenDir/playerData.s for writing, $!"; +my $dataSize = 2 * $gEquates{"NUM_GAME_TILES"}; +$text = << "EOF"; + case on + mcopy playerData.macros + keep playerData + +playerData data playerDataSeg + +player1Tiles ds $dataSize +player2Tiles ds $dataSize + + end +EOF +print $fh $text; +close($fh); + # Generate the tileData.h file open $fh, ">", "$gGenDir/tileData.h" or die "$0: Unable to open $gGenDir/tileData.h for writing, $!";