From fae32b84f9256751a14209f87b6cf64b01541f8c Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Wed, 24 Aug 2016 01:18:19 -0400 Subject: [PATCH] Fix a problem on the GS where the messages on the bottom four lines in mixed text/graphics mode ended up being displayed over the graphics because the text window was setup incorrectly. Move the mouse to the square if the user jumps to another square using keyboard arrow keys or jumping to a hint. --- a2bejwld/dbllores.s | 18 ++++++++++++++++++ a2bejwld/mouseWrapper.c | 22 ++++++++++++++++++++++ a2bejwld/mouseWrapper.h | 1 + a2bejwld/ui.c | 28 ++++++++++++++++------------ 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/a2bejwld/dbllores.s b/a2bejwld/dbllores.s index 88093d7..2d44f7a 100644 --- a/a2bejwld/dbllores.s +++ b/a2bejwld/dbllores.s @@ -66,6 +66,15 @@ gemmask := $8A .proc _showDblLoRes + lda #0 + sta WNDLFT + lda #80 + sta WNDWDTH + lda #0 + sta WNDTOP + lda #24 + sta WNDBTM + lda TXTCLR lda MIXCLR lda SETAN3 @@ -106,6 +115,15 @@ gemmask := $8A cpx #0 bne @L2 + lda #0 + sta WNDLFT + lda #80 + sta WNDWDTH + lda #20 + sta WNDTOP + lda #24 + sta WNDBTM + rts .endproc diff --git a/a2bejwld/mouseWrapper.c b/a2bejwld/mouseWrapper.c index ff03f0e..df2d498 100644 --- a/a2bejwld/mouseWrapper.c +++ b/a2bejwld/mouseWrapper.c @@ -24,6 +24,7 @@ extern char a2e_stdmou_mou; static tMouseCallbacks *gMouseCallbacks = NULL; static bool gMouseInstalled = false; +static bool gMouseInPoll = false; bool initMouse(tMouseCallbacks *callbacks) @@ -65,6 +66,8 @@ bool pollMouse(void) return result; } + gMouseInPoll = true; + mouse_info(&mouseInfo); newMouseDown = (mouseInfo.buttons != 0); @@ -120,6 +123,25 @@ bool pollMouse(void) } } oldMouseDown = newMouseDown; + gMouseInPoll = false; return result; +} + + +void moveMouseToSquare(tSquare square) +{ + uint16_t newX; + uint16_t newY; + + if (!gMouseInstalled) + return; + + if (gMouseInPoll) + return; + + newX = (SQUARE_TO_X(square) * 35) + 18; + newY = (SQUARE_TO_Y(square) * 8) + 4; + + mouse_move(newX, newY); } \ No newline at end of file diff --git a/a2bejwld/mouseWrapper.h b/a2bejwld/mouseWrapper.h index a2c9a0c..a25e255 100644 --- a/a2bejwld/mouseWrapper.h +++ b/a2bejwld/mouseWrapper.h @@ -28,6 +28,7 @@ typedef struct tMouseCallbacks { extern bool initMouse(tMouseCallbacks *callbacks); extern void shutdownMouse(void); extern bool pollMouse(void); +extern void moveMouseToSquare(tSquare square); #endif /* defined(__a2bejwld__mouseWrapper__) */ diff --git a/a2bejwld/ui.c b/a2bejwld/ui.c index bd0e5f4..6b02214 100644 --- a/a2bejwld/ui.c +++ b/a2bejwld/ui.c @@ -321,6 +321,7 @@ static void drawBoard(void) } selectSquare(gSelectedSquare); + moveMouseToSquare(gSelectedSquare); drawScore(gScoreBar); } @@ -378,6 +379,7 @@ static void moveDir(tDirection dir) refreshSquare(oldSquare); selectSquare(gSelectedSquare); + moveMouseToSquare(gSelectedSquare); } @@ -423,6 +425,7 @@ static void moveTwoDirs(tDirection dir1, tDirection dir2) refreshSquare(oldSquare); selectSquare(gSelectedSquare); + moveMouseToSquare(gSelectedSquare); } @@ -481,13 +484,13 @@ static bool isAppleButtonPressed(void) static void endGame(void) { - mixedTextMode(); videomode(VIDEOMODE_80x24); + mixedTextMode(); - printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf(" No more moves - GAME OVER!!\n"); - printf(" You made it to level %u\n\n", getLevel()); - printf(" Play again (Y/N)?"); + cputsxy(0, 0, " No more moves - GAME OVER!!"); + gotoxy(0,1); + cprintf( " You made it to level %u", getLevel()); + cputsxy(0, 3, " Play again (Y/N)?"); while (true) { switch (cgetc()) { @@ -525,12 +528,12 @@ static void refreshLevel(tLevel level) { bool waiting = true; - mixedTextMode(); videomode(VIDEOMODE_80x24); + mixedTextMode(); - printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf(" Completed level %u!!\n", level); - printf(" Press space to continue to the next level..."); + gotoxy(0, 0); + cprintf( " Completed level %u!!", level); + cputsxy(0, 2, " Press space to continue to the next level..."); while (waiting) { switch (cgetc()) { @@ -554,6 +557,7 @@ static void getHint(void) gSelectedSquare = getHintSquare(); selectSquare(gSelectedSquare); + moveMouseToSquare(gSelectedSquare); } @@ -750,10 +754,10 @@ static bool pollKeyboard(void) case 'q': case 'Q': if (gShouldSave) { - mixedTextMode(); videomode(VIDEOMODE_80x24); - gotoxy(0, 20); - cprintf("\n\nSaving your game so you can continue\r\n later..."); + mixedTextMode(); + gotoxy(0, 0); + cprintf("Saving your game so you can continue\r\n later..."); saveGame(); } quitGame();