Add code to keep track of two separate screens of mushrooms for player 1 and player 2.

This commit is contained in:
Jeremy Rand 2021-01-17 14:51:36 -05:00
parent 230d1f344c
commit 678a9ee104
4 changed files with 90 additions and 2 deletions

View File

@ -100,7 +100,7 @@
9D6DB18625A411DA00CDBF05 /* BuGS.2mg */ = {isa = PBXFileReference; lastKnownFileType = file; path = BuGS.2mg; sourceTree = "<group>"; };
9D8AF0B72535542400C10E3C /* level.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = level.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9D8AF0B82535543000C10E3C /* score.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = score.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; };
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
9D9F07F92553AB3800875B29 /* TODO.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = TODO.md; sourceTree = "<group>"; };
9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };

View File

@ -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

View File

@ -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

View File

@ -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, $!";