Add the option to change the keys used to navigate the gem board.

This commit is contained in:
Jeremy Rand 2021-03-12 00:14:05 -05:00
parent ab895a6d88
commit 3861bfc00c
7 changed files with 222 additions and 151 deletions

View File

@ -265,17 +265,6 @@ void swapSquares(tSquare square1, tGemType gemType1, bool starred1,
temp = y2; temp = y2;
y2 = y1; y2 = y1;
y1 = temp; y1 = temp;
#if 0
// We don't need to swap square numbers. The code from here on
// doesn't distinguish between the two square numbers. So, save
// some time and don't swap.
//
// Be careful if this assumption is no longer true.
temp = square2;
square2 = square1;
square1 = temp;
#endif
temp = gemType2; temp = gemType2;
gemType2 = gemType1; gemType2 = gemType1;

View File

@ -32,7 +32,6 @@ static tJoyCallbacks *gJoyCallbacks = NULL;
static tJoyState gJoyState = { static tJoyState gJoyState = {
JOY_POS_CENTER, JOY_POS_CENTER,
false,
false false
}; };
@ -52,17 +51,15 @@ void initJoystick(tJoyCallbacks *callbacks)
} }
bool isButtonPressed(tJoyButtonNum buttonNum) bool isButtonPressed(void)
{ {
if (buttonNum == JOY_BUTTON_0) { __asm__ volatile("LDA %w", BTN0);
__asm__ volatile("LDA %w", BTN0); __asm__ volatile("STA %v", gJoystickTemp);
__asm__ volatile("STA %v", gJoystickTemp); if (gJoystickTemp > 127)
} else if (buttonNum == JOY_BUTTON_1) { return true;
__asm__ volatile("LDA %w", BTN1);
__asm__ volatile("STA %v", gJoystickTemp); __asm__ volatile("LDA %w", BTN1);
} else { __asm__ volatile("STA %v", gJoystickTemp);
return false;
}
return ((gJoystickTemp > 127) ? true : false); return ((gJoystickTemp > 127) ? true : false);
} }
@ -123,8 +120,7 @@ static void readJoystickState(tJoyState *state)
pos = JOY_POS_RIGHT; pos = JOY_POS_RIGHT;
} }
state->button0 = isButtonPressed(0); state->button = isButtonPressed();
state->button1 = isButtonPressed(1);
if (axisUpDown < LOWER_THRESHOLD) { if (axisUpDown < LOWER_THRESHOLD) {
switch (pos) { switch (pos) {
@ -157,8 +153,7 @@ static void readJoystickState(tJoyState *state)
static bool joystickStateChanged(tJoyState *state1, tJoyState *state2) { static bool joystickStateChanged(tJoyState *state1, tJoyState *state2) {
if ((state1->position != state2->position) || if ((state1->position != state2->position) ||
(state1->button0 != state2->button0) || (state1->button != state2->button)) {
(state1->button1 != state2->button1)) {
return true; return true;
} }
return false; return false;

View File

@ -26,21 +26,14 @@
#define JOY_POS_DOWN_RIGHT 8 #define JOY_POS_DOWN_RIGHT 8
#define NUM_JOY_POSITIONS 9 #define NUM_JOY_POSITIONS 9
#define JOY_BUTTON_0 0
#define JOY_BUTTON_1 1
#define NUM_JOY_BUTTONS 2
// Typedefs // Typedefs
typedef int8_t tJoyButtonNum;
typedef int8_t tJoyPos; typedef int8_t tJoyPos;
typedef struct tJoyState { typedef struct tJoyState {
tJoyPos position; tJoyPos position;
bool button0; bool button;
bool button1;
} tJoyState; } tJoyState;
typedef struct tJoyCallbacks { typedef struct tJoyCallbacks {
@ -64,6 +57,6 @@ typedef struct tJoyCallbacks {
extern void initJoystick(tJoyCallbacks *callbacks); extern void initJoystick(tJoyCallbacks *callbacks);
extern bool isButtonPressed(tJoyButtonNum buttonNum); extern bool isButtonPressed(void);
extern bool pollJoystick(void); extern bool pollJoystick(void);

View File

@ -33,21 +33,6 @@ static tMachineGSSpeed gOldSpeed = GS_SPEED_SLOW;
// Implementation // Implementation
static bool machineIs2c(uint8_t machineType)
{
switch (machineType) {
case APPLE_IIC:
case APPLE_IIC35:
case APPLE_IICEXP:
case APPLE_IICREV:
case APPLE_IICPLUS:
return true;
}
return false;
}
static bool machineIs2GS(uint8_t machineType) static bool machineIs2GS(uint8_t machineType)
{ {
switch (machineType) { switch (machineType) {
@ -89,7 +74,11 @@ void initMachine(void)
{ {
uint8_t machineType = get_ostype(); uint8_t machineType = get_ostype();
if (machineIs2c(machineType)) { if ((machineType == APPLE_IIC) ||
(machineType == APPLE_IIC35) ||
(machineType == APPLE_IICEXP) ||
(machineType == APPLE_IICREV) ||
(machineType == APPLE_IICPLUS)) {
gVblWait = vblWait2c; gVblWait = vblWait2c;
} else if (machineIs2GS(machineType)) { } else if (machineIs2GS(machineType)) {
vblInit2gs(); vblInit2gs();

Binary file not shown.

View File

@ -8,6 +8,7 @@
#include <conio.h> #include <conio.h>
#include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -26,20 +27,36 @@
// Defines // Defines
#define SAVE_OPTIONS_FILE "A2BEJWLD.OPTS" #define SAVE_OPTIONS_FILE "A2BEJWLD.OPTS"
#define VERSION "v2.6" #define VERSION "v2.7"
#define OPTIONS_VERSION_UNSAVED 0 #define OPTIONS_VERSION_UNSAVED 0
#define OPTIONS_VERSION 2 #define OPTIONS_VERSION_V2 2
#define OPTIONS_VERSION 3
#define OPTION_JOYSTICK_ENABLED (1 << 0)
#define OPTION_MOUSE_ENABLED (1 << 1)
#define OPTION_SOUND_ENABLED (1 << 2)
#define OPTION_MOCKINGBOARD_ENABLED (1 << 3)
#define OPTION_MOCKINGBOARD_SPEECH_ENABLED (1 << 4)
// Typedefs // Typedefs
typedef struct tGameOptions { typedef struct tGameOptionsV2 {
uint8_t optionsVersion; uint8_t optionsVersion;
bool enableJoystick; bool enableJoystick;
bool enableMouse; bool enableMouse;
bool enableSound; bool enableSound;
bool enableMockingboard; bool enableMockingboard;
bool enableMockingboardSpeech; bool enableMockingboardSpeech;
} tGameOptionsV2;
typedef struct tGameOptions {
uint8_t optionsVersion;
uint8_t flags;
char upChar;
char downChar;
char leftChar;
char rightChar;
} tGameOptions; } tGameOptions;
@ -104,27 +121,32 @@ static bool gShouldSave = false;
static tGameOptions gGameOptions = { static tGameOptions gGameOptions = {
OPTIONS_VERSION_UNSAVED, // optionsVersion OPTIONS_VERSION_UNSAVED, // optionsVersion
false, // enableJoystick (OPTION_MOUSE_ENABLED | OPTION_SOUND_ENABLED | OPTION_MOCKINGBOARD_ENABLED | OPTION_MOCKINGBOARD_SPEECH_ENABLED), // flags
true, // enableMouse 'I', // upChar
true, // enableSound 'M', // downChar
true, // enableMockingboard 'J', // leftChar
true // enableMockingboardSpeech 'K' // rightChar
}; };
// Implementation // Implementation
static void printChar (char ch)
{
if (ch == '\n')
ch = '\r';
ch |= 0x80;
cout(ch);
}
static void printString(char * buffer) static void printString(char * buffer)
{ {
char ch; char ch;
while (*buffer != '\0') { while (*buffer != '\0') {
ch = *buffer; ch = *buffer;
if (ch == '\n') printChar(ch);
ch = '\r';
ch |= 0x80;
cout(ch);
buffer++; buffer++;
} }
} }
@ -140,7 +162,7 @@ static void printInteger(uint16_t val)
static void badThingHappened(void) static void badThingHappened(void)
{ {
if (gGameOptions.enableSound) if ((gGameOptions.flags & OPTION_SOUND_ENABLED) != 0)
printString("\007"); printString("\007");
} }
@ -179,7 +201,7 @@ static bool loadOptions(void)
fclose(optionsFile); fclose(optionsFile);
// If we are upgrading from v1 of the options file, then: // If we are upgrading from v1 to v2 of the options file, then:
// - Force the mouse option on. This option is now only used to disable the mouse when one is // - Force the mouse option on. This option is now only used to disable the mouse when one is
// present. When no mouse is installed, this option does nothing. // present. When no mouse is installed, this option does nothing.
// - There used to be a tSlot of the mockingboard where we now have the enableMockingboard boolean. // - There used to be a tSlot of the mockingboard where we now have the enableMockingboard boolean.
@ -188,9 +210,31 @@ static bool loadOptions(void)
// true if the user enabled it. Now that we can detect the speech chip, the value is default true // true if the user enabled it. Now that we can detect the speech chip, the value is default true
// and the user can disable speech if they want. // and the user can disable speech if they want.
if (gGameOptions < OPTIONS_VERSION) { if (gGameOptions < OPTIONS_VERSION) {
gGameOptions.enableMouse = true; tGameOptionsV2 * oldOptions = (tGameOptionsV2 *)&gGameOptions;
gGameOptions.enableMockingboard = true; if (oldOptions->enableJoystick)
gGameOptions.enableMockingboardSpeech = true; gGameOptions.flags = OPTION_JOYSTICK_ENABLED;
else
gGameOptions.flags = 0;
if (oldOptions->enableMouse)
gGameOptions.flags |= OPTION_MOUSE_ENABLED;
if (oldOptions->enableSound)
gGameOptions.flags |= OPTION_SOUND_ENABLED;
if (oldOptions->enableMockingboard)
gGameOptions.flags |= OPTION_MOCKINGBOARD_ENABLED;
if (oldOptions->enableMockingboardSpeech)
gGameOptions.flags |= OPTION_MOCKINGBOARD_SPEECH_ENABLED;
if (gGameOptions < OPTIONS_VERSION_V2)
gGameOptions.flags |= (OPTION_MOUSE_ENABLED | OPTION_MOCKINGBOARD_ENABLED | OPTION_MOCKINGBOARD_SPEECH_ENABLED);
gGameOptions.upChar = 'I';
gGameOptions.downChar = 'M';
gGameOptions.leftChar = 'J';
gGameOptions.rightChar = 'K';
} }
return true; return true;
@ -206,11 +250,12 @@ static void applyNewOptions(tGameOptions *newOptions)
printString("\n\n\n Saving options..."); printString("\n\n\n Saving options...");
if ((gGameOptions.enableSound != newOptions->enableSound) || if ((gGameOptions.flags & (OPTION_SOUND_ENABLED | OPTION_MOCKINGBOARD_ENABLED | OPTION_MOCKINGBOARD_SPEECH_ENABLED)) !=
(gGameOptions.enableMockingboard != newOptions->enableMockingboard) || (newOptions->flags & (OPTION_SOUND_ENABLED | OPTION_MOCKINGBOARD_ENABLED | OPTION_MOCKINGBOARD_SPEECH_ENABLED))) {
(gGameOptions.enableMockingboardSpeech != newOptions->enableMockingboardSpeech)) {
// If the sound parameters have changed, then re-init sounds // If the sound parameters have changed, then re-init sounds
soundInit(newOptions->enableSound, newOptions->enableMockingboard, newOptions->enableMockingboardSpeech); soundInit(((newOptions->flags & OPTION_SOUND_ENABLED) != 0),
((newOptions->flags & OPTION_MOCKINGBOARD_ENABLED) != 0),
((newOptions->flags & OPTION_MOCKINGBOARD_SPEECH_ENABLED) !=0));
} }
memcpy(&gGameOptions, newOptions, sizeof(gGameOptions)); memcpy(&gGameOptions, newOptions, sizeof(gGameOptions));
@ -228,7 +273,13 @@ static void showCursor(void)
static void replaceCursor(char ch) static void replaceCursor(char ch)
{ {
cout(CH_CURS_LEFT); cout(CH_CURS_LEFT);
cout(ch | 0x80); printChar(ch);
}
static char getKey(void)
{
return toupper(cgetc());
} }
@ -239,16 +290,14 @@ static bool yorn(void)
showCursor(); showCursor();
while (true) { while (true) {
ch = cgetc(); ch = getKey();
if ((ch == 'N') || if (ch == 'N') {
(ch == 'n')) {
result = false; result = false;
break; break;
} }
if ((ch == 'Y') || if (ch == 'Y')
(ch == 'y'))
break; break;
badThingHappened(); badThingHappened();
@ -265,9 +314,12 @@ static void getSoundOptions(tGameOptions *newOptions)
tSlot slot; tSlot slot;
printString("\n\nEnable sounds? (Y/N) "); printString("\n\nEnable sounds? (Y/N) ");
newOptions->enableSound = yorn(); if (yorn()) {
if (!newOptions->enableSound) newOptions->flags |= OPTION_SOUND_ENABLED;
} else {
newOptions->flags &= ~OPTION_SOUND_ENABLED;
return; return;
}
// If no mockingboard present, don't bother to ask whether to enable/disable it. // If no mockingboard present, don't bother to ask whether to enable/disable it.
slot = mockingBoardSlot(); slot = mockingBoardSlot();
@ -277,9 +329,12 @@ static void getSoundOptions(tGameOptions *newOptions)
printString("\nEnable MockingBoard sound found in slot "); printString("\nEnable MockingBoard sound found in slot ");
printInteger(slot); printInteger(slot);
printString("? (Y/N) "); printString("? (Y/N) ");
newOptions->enableMockingboard = yorn(); if (yorn()) {
if (!newOptions->enableMockingboard) newOptions->flags |= OPTION_MOCKINGBOARD_ENABLED;
} else {
newOptions->flags &= ~OPTION_MOCKINGBOARD_ENABLED;
return; return;
}
// If the mockingboard does not have a speech chip, do not prompt whether to // If the mockingboard does not have a speech chip, do not prompt whether to
// enable/disable it. // enable/disable it.
@ -287,7 +342,50 @@ static void getSoundOptions(tGameOptions *newOptions)
return; return;
printString("\nEnable speech on the Mockingboard? (Y/N) "); printString("\nEnable speech on the Mockingboard? (Y/N) ");
newOptions->enableMockingboardSpeech = yorn(); if (yorn()) {
newOptions->flags |= OPTION_MOCKINGBOARD_SPEECH_ENABLED;
} else {
newOptions->flags &= ~OPTION_MOCKINGBOARD_SPEECH_ENABLED;
}
}
static char getKeyDirection(char *dir, char current, char other1, char other2, char other3)
{
char ch;
printString("\nKey for ");
printString(dir);
printString(" movement (current ");
printChar(current);
printString(") ");
showCursor();
while (true) {
ch = getKey();
if ((isalnum(ch)) &&
(ch != 'Q') &&
(ch != 'R') &&
(ch != 'O') &&
(ch != 'H') &&
(ch != other1) &&
(ch != other2) &&
(ch != other3))
break;
badThingHappened();
}
replaceCursor(ch);
return ch;
}
static void getKeyboardOptions(tGameOptions *newOptions)
{
printChar('\n');
newOptions->upChar = getKeyDirection("up", newOptions->upChar, 0, 0, 0);
newOptions->downChar = getKeyDirection("down", newOptions->downChar, newOptions->upChar, 0, 0);
newOptions->leftChar = getKeyDirection("left", newOptions->leftChar, newOptions->upChar, newOptions->downChar, 0);
newOptions->rightChar = getKeyDirection("right", newOptions->rightChar, newOptions->upChar, newOptions->downChar, newOptions->leftChar);
} }
@ -302,6 +400,9 @@ static void selectOptions(void)
memcpy(&newOptions, &gGameOptions, sizeof(newOptions)); memcpy(&newOptions, &gGameOptions, sizeof(newOptions));
while (true) { while (true) {
bool enableSound = ((newOptions.flags & OPTION_SOUND_ENABLED) != 0);
bool enableMockingboard = ((newOptions.flags & OPTION_MOCKINGBOARD_ENABLED) != 0);
clrscr(); clrscr();
printString( printString(
// 0000000001111111111222222222233333333334444444444555555555566666666667 // 0000000001111111111222222222233333333334444444444555555555566666666667
@ -309,19 +410,31 @@ static void selectOptions(void)
" Apple // Bejeweled\n" " Apple // Bejeweled\n"
" Options\n" " Options\n"
"\n" "\n"
" K - Keyboard control - ");
printChar(newOptions.upChar);
printChar('\n');
printString(" ");
printChar(newOptions.leftChar);
printChar(' ');
printChar(newOptions.rightChar);
printChar('\n');
printString(" ");
printChar(newOptions.downChar);
printChar('\n');
printString(
" J - Joystick control - "); " J - Joystick control - ");
printString(newOptions.enableJoystick ? "Enabled\n" : "Disabled\n"); printString(((newOptions.flags & OPTION_JOYSTICK_ENABLED) != 0) ? "Enabled\n" : "Disabled\n");
if (hasMouse()) if (hasMouse())
{ {
printString( printString(
" M - Mouse control - "); " M - Mouse control - ");
printString(newOptions.enableMouse ? "Enabled\n" : "Disabled\n"); printString(((newOptions.flags & OPTION_MOUSE_ENABLED) != 0) ? "Enabled\n" : "Disabled\n");
} }
printString( printString(
" S - Sound - "); " S - Sound - ");
printString(newOptions.enableSound ? "Enabled\n" : "Disabled\n"); printString(enableSound ? "Enabled\n" : "Disabled\n");
if (newOptions.enableSound) { if (enableSound) {
tSlot slot = mockingBoardSlot(); tSlot slot = mockingBoardSlot();
if (slot != 0) { if (slot != 0) {
@ -329,18 +442,18 @@ static void selectOptions(void)
// 0000000001111111111222222222233333333334444444444555555555566666666667 // 0000000001111111111222222222233333333334444444444555555555566666666667
// 1234567890123456789012345678901234567890123456789012345678901234567890 // 1234567890123456789012345678901234567890123456789012345678901234567890
" MockingBoard - "); " MockingBoard - ");
printString(newOptions.enableMockingboard ? "Enabled (Slot " : "Disabled (Slot "); printString(enableMockingboard ? "Enabled (Slot " : "Disabled (Slot ");
printInteger(slot); printInteger(slot);
printString(")\n"); printString(")\n");
if ((newOptions.enableMockingboard) && if ((enableMockingboard) &&
(mockingBoardHasSpeechChip())) (mockingBoardHasSpeechChip()))
{ {
printString( printString(
// 0000000001111111111222222222233333333334444444444555555555566666666667 // 0000000001111111111222222222233333333334444444444555555555566666666667
// 1234567890123456789012345678901234567890123456789012345678901234567890 // 1234567890123456789012345678901234567890123456789012345678901234567890
" Speech - "); " Speech - ");
printString(newOptions.enableMockingboardSpeech ? "Enabled\n" : "Disabled\n"); printString(((newOptions.flags & OPTION_MOCKINGBOARD_SPEECH_ENABLED) != 0) ? "Enabled\n" : "Disabled\n");
} }
} }
} }
@ -351,21 +464,22 @@ static void selectOptions(void)
" Type a letter to change a setting or any other key to save settings\n" " Type a letter to change a setting or any other key to save settings\n"
" and continue"); " and continue");
switch (cgetc()) { switch (getKey()) {
case 'j':
case 'J': case 'J':
newOptions.enableJoystick = !newOptions.enableJoystick; newOptions.flags ^= OPTION_JOYSTICK_ENABLED;
break; break;
case 's':
case 'S': case 'S':
getSoundOptions(&newOptions); getSoundOptions(&newOptions);
break; break;
case 'K':
getKeyboardOptions(&newOptions);
break;
case 'm':
case 'M': case 'M':
if (hasMouse()) { if (hasMouse()) {
newOptions.enableMouse = !newOptions.enableMouse; newOptions.flags ^= OPTION_MOUSE_ENABLED;
break; break;
} }
// Fall through. If no mouse, then pressing m is a fall through into the save code. // Fall through. If no mouse, then pressing m is a fall through into the save code.
@ -392,7 +506,18 @@ void printInstructions(void)
" Apple // Bejeweled (" VERSION ")\n" " Apple // Bejeweled (" VERSION ")\n"
" by Jeremy Rand\n" " by Jeremy Rand\n"
"\n" "\n"
" Use I-J-K-M, the arrow keys, joystick or mouse to move your selection.\n" " Use ");
printChar(gGameOptions.upChar);
printChar('-');
printChar(gGameOptions.leftChar);
printChar('-');
printChar(gGameOptions.rightChar);
printChar('-');
printChar(gGameOptions.downChar);
printString(
" the arrow keys, joystick or mouse to move your selection.\n"
" Hold either apple key, joystick or mouse button and move your selection\n" " Hold either apple key, joystick or mouse button and move your selection\n"
" to swap two jewels and match 3 or more jewels. When you match three\n" " to swap two jewels and match 3 or more jewels. When you match three\n"
" jewels, they disappear and new jewels will drop from the top.\n" " jewels, they disappear and new jewels will drop from the top.\n"
@ -420,8 +545,7 @@ void printInstructions(void)
srand(seed); srand(seed);
switch (cgetc()) { switch (getKey()) {
case 'o':
case 'O': case 'O':
selectOptions(); selectOptions();
break; break;
@ -609,12 +733,6 @@ static bool swapDir(tDirection dir)
} }
static bool isAppleButtonPressed(void)
{
return (isButtonPressed(JOY_BUTTON_0) || isButtonPressed(JOY_BUTTON_1));
}
static void endGame(void) static void endGame(void)
{ {
char ch; char ch;
@ -632,18 +750,15 @@ static void endGame(void)
showCursor(); showCursor();
while (true) { while (true) {
ch = cgetc(); ch = getKey();
switch (ch) { switch (ch) {
case 'y':
case 'Y': case 'Y':
replaceCursor(ch); replaceCursor(ch);
printString("\n"); printString("\n");
return; return;
case 'n':
case 'N': case 'N':
case CH_ESC: case CH_ESC:
case 'q':
case 'Q': case 'Q':
replaceCursor(ch); replaceCursor(ch);
quitGame(); quitGame();
@ -717,7 +832,9 @@ void initUI(void)
optionsLoaded = loadOptions(); optionsLoaded = loadOptions();
soundInit(gGameOptions.enableSound, gGameOptions.enableMockingboard, gGameOptions.enableMockingboardSpeech); soundInit(((gGameOptions.flags & OPTION_SOUND_ENABLED) != 0),
((gGameOptions.flags & OPTION_MOCKINGBOARD_ENABLED) != 0),
((gGameOptions.flags & OPTION_MOCKINGBOARD_SPEECH_ENABLED) != 0));
initGameEngine(&gCallbacks); initGameEngine(&gCallbacks);
@ -789,8 +906,7 @@ static bool joystickChangedCallback(tJoyState *oldState, tJoyState *newState)
if (oldState->position != JOY_POS_CENTER) if (oldState->position != JOY_POS_CENTER)
return false; return false;
if ((newState->button0) || if (newState->button) {
(newState->button1)) {
switch (newState->position) { switch (newState->position) {
case JOY_POS_UP: case JOY_POS_UP:
return swapDir(DIR_UP); return swapDir(DIR_UP);
@ -818,10 +934,7 @@ static bool joystickChangedCallback(tJoyState *oldState, tJoyState *newState)
static bool joystickNoChangeCallback(tJoyState *oldState) static bool joystickNoChangeCallback(tJoyState *oldState)
{ {
if (oldState->button0) if (oldState->button)
return false;
if (oldState->button1)
return false; return false;
joystickMove(oldState->position); joystickMove(oldState->position);
@ -837,60 +950,55 @@ static bool pollKeyboard(void)
if (!kbhit()) if (!kbhit())
return result; return result;
ch = cgetc(); ch = getKey();
if (ch == gGameOptions.upChar)
ch = 0x0b;
else if (ch == gGameOptions.downChar)
ch = 0x0a;
else if (ch == gGameOptions.leftChar)
ch = CH_CURS_LEFT;
else if (ch == gGameOptions.rightChar)
ch = CH_CURS_RIGHT;
if (isButtonPressed())
ch += 128;
switch (ch) { switch (ch) {
case 'i':
case 'I':
// case CH_CURS_UP: // case CH_CURS_UP:
case 0x0b: case 0x0b:
if (!isAppleButtonPressed()) { moveDir(DIR_UP);
moveDir(DIR_UP); break;
break;
}
// Fallthrough...
case 139: case 139:
result = swapDir(DIR_UP); result = swapDir(DIR_UP);
break; break;
case 'j':
case 'J':
case CH_CURS_LEFT: case CH_CURS_LEFT:
if (!isAppleButtonPressed()) { moveDir(DIR_LEFT);
moveDir(DIR_LEFT); break;
break;
}
// Fallthrough...
case 136: case 136:
result = swapDir(DIR_LEFT); result = swapDir(DIR_LEFT);
break; break;
case 'k':
case 'K':
case CH_CURS_RIGHT: case CH_CURS_RIGHT:
if (!isAppleButtonPressed()) { moveDir(DIR_RIGHT);
moveDir(DIR_RIGHT); break;
break;
}
// Fallthrough...
case 149: case 149:
result = swapDir(DIR_RIGHT); result = swapDir(DIR_RIGHT);
break; break;
case 'm':
case 'M':
// case CH_CURS_DOWN: // case CH_CURS_DOWN:
case 0x0a: case 0x0a:
if (!isAppleButtonPressed()) { moveDir(DIR_DOWN);
moveDir(DIR_DOWN); break;
break;
}
// Fallthrough...
case 138: case 138:
result = swapDir(DIR_DOWN); result = swapDir(DIR_DOWN);
break; break;
case CH_ESC: case CH_ESC:
case 'q':
case 'Q': case 'Q':
if (gShouldSave) { if (gShouldSave) {
videomode(0x12); videomode(0x12);
@ -901,21 +1009,18 @@ static bool pollKeyboard(void)
quitGame(); quitGame();
break; break;
case 'r':
case 'R': case 'R':
refreshScore(0); refreshScore(0);
startNewGame(); startNewGame();
gShouldSave = false; gShouldSave = false;
return true; return true;
case 'o':
case 'O': case 'O':
selectOptions(); selectOptions();
showAndClearDblLoRes(); showAndClearDblLoRes();
drawBoard(); drawBoard();
break; break;
case 'h':
case 'H': case 'H':
getHint(); getHint();
break; break;
@ -982,12 +1087,12 @@ void playGame(void)
break; break;
} }
if ((gGameOptions.enableJoystick) && if (((gGameOptions.flags & OPTION_JOYSTICK_ENABLED) != 0) &&
(pollJoystick())) { (pollJoystick())) {
break; break;
} }
if ((gGameOptions.enableMouse) && if (((gGameOptions.flags & OPTION_MOUSE_ENABLED) != 0) &&
(pollMouse())) { (pollMouse())) {
break; break;
} }