From 94c7e3f9e40217c3fb5cd11505dba8c67ecc8c05 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Mon, 30 Nov 2020 00:11:55 -0500 Subject: [PATCH] Add some infrastructure to block the player from passing through mushrooms. The next step will be to code that algorithm. Also, added a build improvement to better handle assembly errors and pass them in to Xcode. --- BuGS/gamePlayer.s | 93 +++++++++++++++++++++------------------- BuGS/make/launchEmulator | 10 +++-- BuGS/make/orca-asm | 27 +++++++++++- BuGS/tileData.pl | 45 +++++++++++++++++++ 4 files changed, 126 insertions(+), 49 deletions(-) diff --git a/BuGS/gamePlayer.s b/BuGS/gamePlayer.s index d25bacd..35fcf84 100644 --- a/BuGS/gamePlayer.s +++ b/BuGS/gamePlayer.s @@ -200,39 +200,21 @@ updatePlayer_noMousePoll anop jmp updatePlayer_skipDeltas updatePlayer_handleDeltas anop -; The X register has the deltaX +; The X and Y register also has a bit in each which indicates whether a +; mouse button is down or not. txa - bit #$40 - bne updatePlayer_negX - and #$3f - inc a - lsr a - cmp #9 - blt updatePlayer_posXNoClamp - lda #8 -updatePlayer_posXNoClamp anop - clc - adc mouseX - cmp #MOUSE_MAX_X - blt updatePlayer_doneX - lda #MOUSE_MAX_X-1 - bra updatePlayer_doneX -updatePlayer_negX anop - ora #$ffc0 - dec a - lsr a - ora #$8000 - cmp #$fff8 - bge updatePlayer_negXNoClamp - lda #$fff8 -updatePlayer_negXNoClamp anop - clc - adc mouseX - bpl updatePlayer_doneX - lda #0 -updatePlayer_doneX anop - sta mouseX - + and #$0080 + beq updatePlayer_mouseDown + tya + and #$0080 + beq updatePlayer_mouseDown + lda #1 + sta mouseDown + bra updatePlayer_doY +updatePlayer_mouseDown anop + stz mouseDown + +updatePlayer_doY anop ; The Y register has the deltaY tya bit #$40 @@ -240,6 +222,7 @@ updatePlayer_doneX anop and #$3f inc a lsr a + beq updatePlayer_doX cmp #9 blt updatePlayer_posYNoClamp lda #8 @@ -266,20 +249,40 @@ updatePlayer_negYNoClamp anop updatePlayer_doneY anop sta mouseY -; The X and Y register also has a bit in each which indicates whether a -; mouse button is down or not. - +updatePlayer_doX anop +; The X register has the deltaX txa - and #$0080 - beq updatePlayer_mouseDown - tya - and #$0080 - beq updatePlayer_mouseDown - lda #1 - sta mouseDown - bra updatePlayer_skipDeltas -updatePlayer_mouseDown anop - stz mouseDown + bit #$40 + bne updatePlayer_negX + and #$3f + inc a + lsr a + beq updatePlayer_skipDeltas + cmp #9 + blt updatePlayer_posXNoClamp + lda #8 +updatePlayer_posXNoClamp anop + clc + adc mouseX + cmp #MOUSE_MAX_X + blt updatePlayer_doneX + lda #MOUSE_MAX_X-1 + bra updatePlayer_doneX +updatePlayer_negX anop + ora #$ffc0 + dec a + lsr a + ora #$8000 + cmp #$fff8 + bge updatePlayer_negXNoClamp + lda #$fff8 +updatePlayer_negXNoClamp anop + clc + adc mouseX + bpl updatePlayer_doneX + lda #0 +updatePlayer_doneX anop + sta mouseX updatePlayer_skipDeltas anop lda mouseDown diff --git a/BuGS/make/launchEmulator b/BuGS/make/launchEmulator index be5dc28..2f4a9be 100755 --- a/BuGS/make/launchEmulator +++ b/BuGS/make/launchEmulator @@ -27,11 +27,15 @@ sed -i "" "s:^s7d1 *=.*$:s7d1 = $DISKIMAGE:" config.txt # This magic ensure that clicking stop in Xcode results in the emulator terminating. +if true +then $EMULATORPATH -fullscreen -mem 1572864 & PID=$! -#cd "/Users/jrand/Library/Application Support/Ample" -#/Applications/Ample.app/Contents/MacOS/mame64 apple2gs -skip_gameinfo -mouse -window -resolution 1408x1056 -ramsize 4M -sl7 cffa202 -hard1 "$DISKIMAGE" & -#PID=$! +else +cd "/Users/jrand/Library/Application Support/Ample" +/Applications/Ample.app/Contents/MacOS/mame64 apple2gs -skip_gameinfo -mouse -window -resolution 1408x1056 -ramsize 4M -sl7 cffa202 -hard1 "$DISKIMAGE" & +PID=$! +fi trap 'kill $PID' SIGTERM SIGINT SIGHUP EXIT wait diff --git a/BuGS/make/orca-asm b/BuGS/make/orca-asm index 43f0cc4..ed41452 100755 --- a/BuGS/make/orca-asm +++ b/BuGS/make/orca-asm @@ -1,6 +1,7 @@ #!/bin/bash TMPFILE=/tmp/orca-macgen.$$ +ERROUTPUT=/tmp/orca-asm-errs.$$ FILENAME="$1" shift @@ -54,15 +55,39 @@ DIRNAME=`dirname $FILENAME` BASENAME=`basename $FILENAME .s` pushd "$DIRNAME" > /dev/null -$ORCA assemble $* keep="${BASENAME}" "${BASENAME}.s" +$ORCA assemble $* keep="${BASENAME}" "${BASENAME}.s" 2> $ERROUTPUT RESULT=$? popd > /dev/null +if [ -s $ERROUTPUT ] +then + RESULT=1 + awk ' + { + print $0 + } + + /^Error /{ + $1="" + $2="" + LINENO=$3 + $3="" + printf("%s/%s:%d:0: error: %s\n", PWD, FILE, LINENO, $0) + } + ' "PWD=`pwd`" "FILE=${BASENAME}.s" $ERROUTPUT +fi +rm -f $ERROUTPUT + if [ "$RESULT" -ne 0 ] then rm -f "$SRCROOTNAME" rm -f "$SRCMACROSNAME" rm -f "$SRCOBJNAME" + rm -f "$DESTROOTNAME" + rm -f "$DESTMACROSNAME" + rm -f "$DESTOBJNAME" + rm -f "$DESTDEPSNAME" + exit 1 fi mkdir -p `dirname "$DESTROOTNAME"` diff --git a/BuGS/tileData.pl b/BuGS/tileData.pl index 2a1d9d8..debbe62 100755 --- a/BuGS/tileData.pl +++ b/BuGS/tileData.pl @@ -95,6 +95,10 @@ our @gDirtyNonGameTiles = ("INVALID_TILE_NUM") x $gEquates{"NUM_NON_GAME_TILES"} our $gNumDirtyNonGameTiles = 0; our @gMouseYAddress = (0) x $gEquates{"MOUSE_MAX_Y"}; +our @gMouseYTileAbove = (0) x $gEquates{"MOUSE_MAX_Y"}; +our @gMouseYTileBelow = (0) x $gEquates{"MOUSE_MAX_Y"}; +our @gMouseXTileLeft = (0) x $gEquates{"MOUSE_MAX_X"}; +our @gMouseXTileRight = (0) x $gEquates{"MOUSE_MAX_X"}; our @gScreenToTileOffset = (0) x ($gEquates{"SCREEN_PIXELS_TALL"} * $gEquates{"SCREEN_BYTES_PER_ROW"} / $gEquates{"SIZEOF_TILE_INFO"}); @@ -360,10 +364,47 @@ sub initTiles # Calculate the memory address of the 0th row of the player's mouse position. $lastOffset = $gEquates{"SCREEN_ADDRESS"} + ($gEquates{"LHS_NUM_TILES_WIDE"} * $gEquates{"TILE_BYTE_WIDTH"}) + (($gEquates{"GAME_NUM_TILES_TALL"} - $gEquates{"PLAYER_TILES_HIGH"}) * $gEquates{"TILE_PIXEL_HEIGHT"} * $gEquates{"SCREEN_BYTES_PER_ROW"}); + $tileX = 0; + $tileY = $gEquates{"GAME_NUM_TILES_TALL"} - $gEquates{"PLAYER_TILES_HIGH"} - 1; for (my $y = 0; $y < $gEquates{"MOUSE_MAX_Y"}; $y++) { $gMouseYAddress[$y] = $lastOffset; $lastOffset += $gEquates{"SCREEN_BYTES_PER_ROW"}; + + if (($y % $gEquates{"TILE_PIXEL_HEIGHT"}) == 0) + { + $tileY++; + } + + $gMouseYTileAbove[$y] = gameXYToTileOffset($tileX, $tileY); + if (($y % $gEquates{"TILE_PIXEL_HEIGHT"}) == 0) + { + $gMouseYTileBelow[$y] = gameXYToTileOffset($tileX, $tileY); + } + else + { + $gMouseYTileBelow[$y] = gameXYToTileOffset($tileX, $tileY + 1); + } + } + + $tileX = -1; + $tileY = 0; + for (my $x = 0; $x < $gEquates{"MOUSE_MAX_X"}; $x++) + { + if (($x % $gEquates{"TILE_PIXEL_WIDTH"}) == 0) + { + $tileX++; + } + + $gMouseXTileLeft[$x] = gameXYToTileOffset($tileX, $tileY); + if (($x % $gEquates{"TILE_PIXEL_WIDTH"}) == 0) + { + $gMouseXTileRight[$x] = gameXYToTileOffset($tileX, $tileY); + } + else + { + $gMouseXTileRight[$x] = gameXYToTileOffset($tileX + 1, $tileY); + } } } @@ -449,6 +490,10 @@ printTileData($fh, "tileBitOffset", @gTileBitOffset); printTileData($fh, "tileBitMask", @gTileBitMask); printTileData($fh, "dirtyNonGameTiles", @gDirtyNonGameTiles); printTileData($fh, "mouseYAddress", @gMouseYAddress); +printTileData($fh, "mouseYTileAbove", @gMouseYTileAbove); +printTileData($fh, "mouseYTileBelow", @gMouseYTileBelow); +printTileData($fh, "mouseXTileLeft", @gMouseXTileLeft); +printTileData($fh, "mouseXTileRight", @gMouseXTileRight); $text = << "EOF";