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.

This commit is contained in:
Jeremy Rand 2020-11-30 00:11:55 -05:00
parent ae8dde2d87
commit 94c7e3f9e4
4 changed files with 126 additions and 49 deletions

View File

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

View File

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

View File

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

View File

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