mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-08 16:29:27 +00:00
Interface menu changes
* Added an option to set caps lock (basing it off X11's value is not working well) * Added a reboot emulator option (because Ctrl-Alt-End is potentially mapped by the X11 WM. ahem, Xfce...
This commit is contained in:
parent
e54ce95389
commit
78a3b39f6d
1
.apple2
1
.apple2
|
@ -4,6 +4,7 @@ disk path = /usr/local/games/apple2/disks
|
|||
color = interpolated
|
||||
video = 1X
|
||||
volume = 8
|
||||
caps lock = 1
|
||||
joystick = joy keypad
|
||||
system path = /usr/local/games/apple2/rom
|
||||
pc joystick parms = 128 128 255 1 255 1
|
||||
|
|
|
@ -77,7 +77,6 @@ extern unsigned char cpu65_flags_decode[256];
|
|||
|
||||
extern int16_t cpu65_cycle_count;
|
||||
extern int16_t cpu65_cycles_to_execute;
|
||||
extern uint8_t emul_reinitialize;
|
||||
|
||||
#endif /* !__ASSEMBLER__ */
|
||||
|
||||
|
|
161
src/interface.c
161
src/interface.c
|
@ -646,28 +646,32 @@ void c_interface_select_diskette( int drive )
|
|||
typedef enum interface_enum_t {
|
||||
OPT_CPU = 0,
|
||||
OPT_ALTCPU,
|
||||
OPT_QUIT,
|
||||
OPT_REBOOT,
|
||||
OPT_JOYSTICK,
|
||||
OPT_CALIBRATE,
|
||||
OPT_PATH,
|
||||
OPT_COLOR,
|
||||
OPT_VIDEO,
|
||||
OPT_VOLUME,
|
||||
OPT_JOYSTICK,
|
||||
OPT_CALIBRATE,
|
||||
OPT_QUIT,
|
||||
OPT_CAPS,
|
||||
|
||||
NUM_OPTIONS
|
||||
} interface_enum_t;
|
||||
|
||||
static const char *options[] =
|
||||
{
|
||||
" CPU% : ",
|
||||
" CPU% : ",
|
||||
" ALT CPU% : ",
|
||||
" Path : ",
|
||||
" Color : ",
|
||||
" Video : ",
|
||||
" Volume : ",
|
||||
" --> Quit Emulator",
|
||||
" --> Reboot Emulator",
|
||||
" Joystick : ",
|
||||
" Calibrate Joystick...",
|
||||
" Quit Emulator...",
|
||||
" --> Calibrate Joystick",
|
||||
" Path : ",
|
||||
" Color : ",
|
||||
" Video : ",
|
||||
" Volume : ",
|
||||
" CAPSlock : ",
|
||||
};
|
||||
|
||||
#define INTERFACE_PATH_MAX 65
|
||||
|
@ -702,7 +706,7 @@ void c_interface_parameters()
|
|||
"| For interface help press '?' ... ESC exits menu |",
|
||||
"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" };
|
||||
|
||||
#define PARAMS_H 9
|
||||
#define PARAMS_H 9 /* visual height */
|
||||
int i;
|
||||
int ch;
|
||||
static interface_enum_t option = OPT_CPU;
|
||||
|
@ -723,7 +727,7 @@ void c_interface_parameters()
|
|||
{
|
||||
for (i = 0; (i < PARAMS_H) && (i < NUM_OPTIONS); i++)
|
||||
{
|
||||
cur_off = option - PARAMS_H-1;
|
||||
cur_off = (option - PARAMS_H) +1;
|
||||
if (cur_off < 0)
|
||||
{
|
||||
cur_off = 0;
|
||||
|
@ -774,6 +778,11 @@ void c_interface_parameters()
|
|||
sprintf(temp, "%s", (a2_video_mode == VIDEO_1X) ? "1X " : (a2_video_mode == VIDEO_2X) ? "2X " : "Fullscreen");
|
||||
break;
|
||||
|
||||
case OPT_JOYSTICK:
|
||||
snprintf(temp, TEMPSIZE, "%s", (joy_mode == JOY_KPAD) ? "Emulated on Keypad" :
|
||||
(joy_mode == JOY_PCJOY) ? "PC Joystick " : "Off ");
|
||||
break;
|
||||
|
||||
case OPT_VOLUME:
|
||||
if (sound_volume == 0)
|
||||
{
|
||||
|
@ -785,9 +794,15 @@ void c_interface_parameters()
|
|||
}
|
||||
break;
|
||||
|
||||
case OPT_JOYSTICK:
|
||||
snprintf(temp, TEMPSIZE, "%s", (joy_mode == JOY_KPAD) ? "Emulated on Keypad" :
|
||||
(joy_mode == JOY_PCJOY) ? "PC Joystick " : "Off ");
|
||||
case OPT_CAPS:
|
||||
if (caps_lock)
|
||||
{
|
||||
snprintf(temp, TEMPSIZE, "%s", "On ");
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(temp, TEMPSIZE, "%s", "Off ");
|
||||
}
|
||||
break;
|
||||
|
||||
case OPT_CALIBRATE:
|
||||
|
@ -796,13 +811,16 @@ void c_interface_parameters()
|
|||
case OPT_QUIT:
|
||||
break;
|
||||
|
||||
case OPT_REBOOT:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pad_string(temp, ' ', INTERFACE_PATH_MAX+1);
|
||||
int loc = i+cur_off;
|
||||
if ((loc != OPT_PATH) && (loc != OPT_CALIBRATE) && (loc != OPT_QUIT))
|
||||
if ((loc != OPT_PATH) && (loc != OPT_QUIT) && (loc != OPT_REBOOT) && (loc != OPT_CALIBRATE))
|
||||
{
|
||||
c_interface_print(INTERFACE_PATH_MIN, 5 + i, 0, temp);
|
||||
}
|
||||
|
@ -950,6 +968,12 @@ void c_interface_parameters()
|
|||
}
|
||||
break;
|
||||
|
||||
case OPT_CAPS:
|
||||
if (caps_lock) {
|
||||
caps_lock = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case OPT_JOYSTICK:
|
||||
if (joy_mode == JOY_PCJOY)
|
||||
{
|
||||
|
@ -977,6 +1001,9 @@ void c_interface_parameters()
|
|||
case OPT_QUIT:
|
||||
break;
|
||||
|
||||
case OPT_REBOOT:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1046,6 +1073,12 @@ void c_interface_parameters()
|
|||
}
|
||||
break;
|
||||
|
||||
case OPT_CAPS:
|
||||
if (!caps_lock) {
|
||||
caps_lock = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case OPT_JOYSTICK:
|
||||
if (joy_mode == JOY_PCJOY)
|
||||
{
|
||||
|
@ -1073,6 +1106,9 @@ void c_interface_parameters()
|
|||
case OPT_QUIT:
|
||||
break;
|
||||
|
||||
case OPT_REBOOT:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1183,47 +1219,74 @@ void c_interface_parameters()
|
|||
c_interface_print_screen( screen );
|
||||
}
|
||||
|
||||
/* quit apple II simulator */
|
||||
if (ch == 13 && option == OPT_QUIT)
|
||||
{
|
||||
int ch;
|
||||
|
||||
#define QUIT_SUBMENU_H 10
|
||||
#define QUIT_SUBMENU_W 40
|
||||
char submenu[QUIT_SUBMENU_H][QUIT_SUBMENU_W+1] =
|
||||
//1. 5. 10. 15. 20. 25. 30. 35. 40.
|
||||
{ "||||||||||||||||||||||||||||||||||||||||",
|
||||
"| |",
|
||||
"| |",
|
||||
"| |",
|
||||
"| Quit Emulator... |",
|
||||
"| Are you sure? (Y/N) |",
|
||||
"| |",
|
||||
"| |",
|
||||
"| |",
|
||||
"||||||||||||||||||||||||||||||||||||||||" };
|
||||
c_interface_print_submenu_centered(submenu[0], QUIT_SUBMENU_W, QUIT_SUBMENU_H);
|
||||
{
|
||||
char qsubmenu[QUIT_SUBMENU_H][QUIT_SUBMENU_W+1] =
|
||||
//1. 5. 10. 15. 20. 25. 30. 35. 40.
|
||||
{ "||||||||||||||||||||||||||||||||||||||||",
|
||||
"| |",
|
||||
"| |",
|
||||
"| |",
|
||||
"| Quit Emulator... |",
|
||||
"| Are you sure? (Y/N) |",
|
||||
"| |",
|
||||
"| |",
|
||||
"| |",
|
||||
"||||||||||||||||||||||||||||||||||||||||" };
|
||||
|
||||
while ((ch = c_mygetch(1)) == -1)
|
||||
/* quit emulator */
|
||||
if ((ch == 13) && (option == OPT_QUIT))
|
||||
{
|
||||
int ch;
|
||||
c_interface_print_submenu_centered(qsubmenu[0], QUIT_SUBMENU_W, QUIT_SUBMENU_H);
|
||||
|
||||
while ((ch = c_mygetch(1)) == -1)
|
||||
{
|
||||
}
|
||||
|
||||
ch = toupper(ch);
|
||||
if (ch == 'Y')
|
||||
{
|
||||
save_settings();
|
||||
|
||||
c_eject_6( 0 );
|
||||
c_interface_print_screen( screen );
|
||||
c_eject_6( 1 );
|
||||
c_interface_print_screen( screen );
|
||||
c_close_joystick();
|
||||
#ifdef __linux__
|
||||
LOG("Back to Linux, w00t!\n");
|
||||
#endif
|
||||
video_shutdown();
|
||||
//audio_shutdown(); TODO : fixme ...
|
||||
exit( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
ch = toupper(ch);
|
||||
if (ch == 'Y')
|
||||
{
|
||||
save_settings();
|
||||
/* reboot emulator */
|
||||
if ((ch == 13) && (option == OPT_REBOOT)) {
|
||||
int ch;
|
||||
memcpy(qsubmenu[4]+11, "Reboot", 6);
|
||||
c_interface_print_submenu_centered(qsubmenu[0], QUIT_SUBMENU_W, QUIT_SUBMENU_H);
|
||||
|
||||
c_eject_6( 0 );
|
||||
c_interface_print_screen( screen );
|
||||
c_eject_6( 1 );
|
||||
c_interface_print_screen( screen );
|
||||
c_close_joystick();
|
||||
#ifdef __linux__
|
||||
LOG("Back to Linux, w00t!\n");
|
||||
#endif
|
||||
video_shutdown();
|
||||
//audio_shutdown(); TODO : fixme ...
|
||||
exit( 0 );
|
||||
while ((ch = c_mygetch(1)) == -1)
|
||||
{
|
||||
}
|
||||
|
||||
ch = toupper(ch);
|
||||
if (ch == 'Y')
|
||||
{
|
||||
timing_initialize();
|
||||
video_set(0);
|
||||
extern unsigned char joy_button0;
|
||||
joy_button0 = 0xff; // OpenApple
|
||||
cpu65_interrupt(ResetSig);
|
||||
c_initialize_sound_hooks();
|
||||
c_interface_exit(ch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
c_interface_print_screen( screen );
|
||||
|
|
25
src/prefs.c
25
src/prefs.c
|
@ -30,6 +30,7 @@
|
|||
#define PRM_JOY_PC_CALIBRATE 10
|
||||
#define PRM_JOY_KPAD_CALIBRATE 11
|
||||
#define PRM_ROM_PATH 12
|
||||
#define PRM_CAPSLOCK 102
|
||||
|
||||
|
||||
char system_path[SYSSIZE];
|
||||
|
@ -61,6 +62,8 @@ static const struct match_table prefs_table[] =
|
|||
{ "color", PRM_HIRES_COLOR },
|
||||
{ "video", PRM_VIDEO_MODE },
|
||||
{ "volume", PRM_VOLUME },
|
||||
{ "caps_lock", PRM_CAPSLOCK },
|
||||
{ "caps lock", PRM_CAPSLOCK },
|
||||
{ "joystick", PRM_JOY_INPUT },
|
||||
{ "pc joystick parms", PRM_JOY_PC_CALIBRATE },
|
||||
{ "pc_joystick_parms", PRM_JOY_PC_CALIBRATE },
|
||||
|
@ -115,6 +118,12 @@ static const struct match_table volume_table[] =
|
|||
{ 0, 10 },
|
||||
};
|
||||
|
||||
static const struct match_table capslock_table[] =
|
||||
{
|
||||
{ "0", 0 },
|
||||
{ "1", 1 },
|
||||
};
|
||||
|
||||
static const struct match_table joy_input_table[] =
|
||||
{
|
||||
{ "off", JOY_OFF },
|
||||
|
@ -189,7 +198,10 @@ void load_settings(void)
|
|||
strcpy(disk_path, "./disks");
|
||||
strcpy(system_path, "./rom");
|
||||
|
||||
{
|
||||
const char *apple2cfg = getenv("APPLE2IXCFG");
|
||||
if (apple2cfg) {
|
||||
config_filename = strdup(apple2cfg);
|
||||
} else {
|
||||
const char *homedir;
|
||||
|
||||
homedir = getenv("HOME");
|
||||
|
@ -202,18 +214,15 @@ void load_settings(void)
|
|||
}
|
||||
|
||||
{
|
||||
FILE *config_file;
|
||||
char *buffer = 0;
|
||||
size_t size = 0;
|
||||
|
||||
config_file = fopen(config_filename, "r");
|
||||
FILE *config_file = fopen(config_filename, "r");
|
||||
if (config_file == NULL)
|
||||
{
|
||||
ERRLOG(
|
||||
"Warning. Cannot open the .apple2 system defaults file.\n"
|
||||
"Make sure it's readable in your home directory.");
|
||||
ERRLOG("Press RETURN to continue...");
|
||||
getchar(); // HACK FIXME -- this needs to be decoupled from both testing and mobile targets
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -278,6 +287,10 @@ void load_settings(void)
|
|||
sound_volume = match(volume_table, argument);
|
||||
break;
|
||||
|
||||
case PRM_CAPSLOCK:
|
||||
caps_lock = match(capslock_table, argument) ? true : false;
|
||||
break;
|
||||
|
||||
case PRM_JOY_INPUT:
|
||||
joy_mode = match(joy_input_table, argument);
|
||||
break;
|
||||
|
@ -393,6 +406,7 @@ bool save_settings(void)
|
|||
"color = %s\n"
|
||||
"video = %s\n"
|
||||
"volume = %s\n"
|
||||
"caps lock = %s\n"
|
||||
"joystick = %s\n"
|
||||
"system path = %s\n",
|
||||
cpu_scale_factor,
|
||||
|
@ -401,6 +415,7 @@ bool save_settings(void)
|
|||
reverse_match(color_table, color_mode),
|
||||
reverse_match(video_table, a2_video_mode),
|
||||
reverse_match(volume_table, sound_volume),
|
||||
reverse_match(capslock_table, (int)caps_lock),
|
||||
reverse_match(joy_input_table, joy_mode),
|
||||
system_path);
|
||||
anErr = anErr || (err < 0);
|
||||
|
|
|
@ -567,7 +567,8 @@ void video_sync(int block) {
|
|||
// sync to the capslock state (which could be modified outside this app)
|
||||
unsigned int caps_state = 0;
|
||||
XkbGetIndicatorState(display, XkbUseCoreKbd, &caps_state);
|
||||
caps_lock = (caps_state & 0x01);
|
||||
// caps_lock = (caps_state & 0x01); -- NOTE: synching to caps_lock in X11 leads to a broken work flow if switching
|
||||
// between a terminal app and the emulator, so disable this
|
||||
|
||||
bool keyevent = true;
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue
Block a user