Only show the "enable/disable mouse" option if a mouse is actually present. Force the mouse option on when the options file is upgraded to the latest version. Allow mouse and joystick controls to co-exist. In past versions, the mouse interrupts messed up the joystick measurements but those are now done with interrupts disabled so that isn't a problem now. With this change, the mouse behaves like the mockingboard - it is auto-detected and just used but can be disabled if the user does not want it enabled even though present on the system.

Also bump the version number to 2.4.
This commit is contained in:
Jeremy Rand 2020-03-09 22:59:38 -04:00
parent 20ad7dda1c
commit d3d97db1f6
5 changed files with 26 additions and 30 deletions

View File

@ -5,6 +5,6 @@ This is an implementation of Bejeweled written for the Apple //. It is my HackF
![A2Bejwld Screenshot](/a2bejwld.png "A2Bejwld Screenshot")
[Download a disk image](https://github.com/jeremysrand/a2bejwld/releases/download/2.3/a2bejwld.dsk)
[Download a disk image](https://github.com/jeremysrand/a2bejwld/releases/download/2.4/a2bejwld.dsk)
[Watch the YouTube video](https://youtu.be/yseAGBzREik)

View File

@ -56,6 +56,12 @@ void shutdownMouse(void)
}
bool hasMouse(void)
{
return gMouseInstalled;
}
bool pollMouse(void)
{
static uint16_t mouseDownAtX = 0;

View File

@ -27,6 +27,7 @@ typedef struct tMouseCallbacks {
extern bool initMouse(tMouseCallbacks *callbacks);
extern void shutdownMouse(void);
extern bool hasMouse(void);
extern bool pollMouse(void);
extern void moveMouseToSquare(tSquare square);

View File

@ -26,7 +26,7 @@
// Defines
#define SAVE_OPTIONS_FILE "A2BEJWLD.OPTS"
#define VERSION "v2.4.a3"
#define VERSION "v2.4"
#define OPTIONS_VERSION_UNSAVED 0
#define OPTIONS_VERSION 2
@ -180,12 +180,15 @@ static bool loadOptions(void)
fclose(optionsFile);
// If we are upgrading from v1 of the options file, then:
// - 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.
// - There used to be a tSlot of the mockingboard where we now have the enableMockingboard boolean.
// Overwrite it with true, forcing mockingboard sound to be on if one is detected.
// - There used to be a boolean to enable/disable the speech chip on the mockingboard. It was only
// 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.
if (gGameOptions < OPTIONS_VERSION) {
gGameOptions.enableMouse = true;
gGameOptions.enableMockingboard = true;
gGameOptions.enableMockingboardSpeech = true;
}
@ -196,8 +199,6 @@ static bool loadOptions(void)
static void applyNewOptions(tGameOptions *newOptions)
{
bool oldEnableMouse = gGameOptions.enableMouse;
// If there is no change in game options, then nothing to do.
if (memcmp(newOptions, &gGameOptions, sizeof(gGameOptions)) == 0) {
return;
@ -214,11 +215,6 @@ static void applyNewOptions(tGameOptions *newOptions)
memcpy(&gGameOptions, newOptions, sizeof(gGameOptions));
gGameOptions.optionsVersion = OPTIONS_VERSION_UNSAVED;
if (oldEnableMouse != gGameOptions.enableMouse) {
if (gGameOptions.enableMouse) {
gGameOptions.enableMouse = initMouse(&gMouseCallbacks);
}
}
saveOptions();
}
@ -315,9 +311,12 @@ static void selectOptions(void)
"\n"
" J - Joystick control - ");
printString(newOptions.enableJoystick ? "Enabled\n" : "Disabled\n");
printString(
if (hasMouse())
{
printString(
" M - Mouse control - ");
printString(newOptions.enableMouse ? "Enabled\n" : "Disabled\n");
printString(newOptions.enableMouse ? "Enabled\n" : "Disabled\n");
}
printString(
" S - Sound - ");
printString(newOptions.enableSound ? "Enabled\n" : "Disabled\n");
@ -356,23 +355,20 @@ static void selectOptions(void)
case 'j':
case 'J':
newOptions.enableJoystick = !newOptions.enableJoystick;
if (newOptions.enableJoystick) {
newOptions.enableMouse = false;
}
break;
case 'm':
case 'M':
newOptions.enableMouse = !newOptions.enableMouse;
if (newOptions.enableMouse) {
newOptions.enableJoystick = false;
}
break;
case 's':
case 'S':
getSoundOptions(&newOptions);
break;
case 'm':
case 'M':
if (hasMouse()) {
newOptions.enableMouse = !newOptions.enableMouse;
break;
}
// Fall through. If no mouse, then pressing m is a fall through into the save code.
default:
applyNewOptions(&newOptions);
@ -716,7 +712,6 @@ static void getHint(void)
void initUI(void)
{
bool optionsLoaded;
bool mouseInitialized;
initMachine();
@ -725,14 +720,8 @@ void initUI(void)
soundInit(gGameOptions.enableSound, gGameOptions.enableMockingboard, gGameOptions.enableMockingboardSpeech);
initGameEngine(&gCallbacks);
mouseInitialized = initMouse(&gMouseCallbacks);
// If we couldn't initialize a mouse and it was enabled on the options, then disable it.
if ((!mouseInitialized) &&
(gGameOptions.enableMouse)) {
gGameOptions.enableMouse = false;
gGameOptions.optionsVersion = OPTIONS_VERSION_UNSAVED;
}
initMouse(&gMouseCallbacks);
initJoystick(&gJoyCallbacks);