I wanted to have a dedicated save and load button on my admin panel, but when you hit save or load it asks for a slot. I really didn't care to have it use more than one slot, so I figured I could go into the code and hack away until it did what I wanted.
Well it actually works. See the before and after snippits from ui.c below. I love it works great, hit the save button saves right away, hit load the load button loads right away. You could still remove the notifications too if you wanted, but I didn't mind that so much, I just wanted to have to only hit one button.
I'm running .133 code, so this is code from that version.
Original code block
/*-------------------------------------------------
handler_load_save - leads the user through
specifying a game to save or load
-------------------------------------------------*/
static UINT32 handler_load_save(running_machine *machine, UINT32 state)
{
char filename[20];
input_code code;
char file = 0;
/* if we're not in the middle of anything, skip */
if (state == LOADSAVE_NONE)
return 0;
/* okay, we're waiting for a key to select a slot; display a message */
if (state == LOADSAVE_SAVE)
ui_draw_message_window("Select position to save to");
else
ui_draw_message_window("Select position to load from");
/* check for cancel key */
if (ui_input_pressed(machine, IPT_UI_CANCEL))
{
/* display a popup indicating things were cancelled */
if (state == LOADSAVE_SAVE)
popmessage("Save cancelled");
else
popmessage("Load cancelled");
/* reset the state */
mame_pause(machine, FALSE);
return UI_HANDLER_CANCEL;
}
/* check for A-Z or 0-9 */
for (code = KEYCODE_A; code <= (input_code)KEYCODE_Z; code++)
if (input_code_pressed_once(code))
file = code - KEYCODE_A + 'a';
if (file == 0)
for (code = KEYCODE_0; code <= (input_code)KEYCODE_9; code++)
if (input_code_pressed_once(code))
file = code - KEYCODE_0 + '0';
if (file == 0)
for (code = KEYCODE_0_PAD; code <= (input_code)KEYCODE_9_PAD; code++)
if (input_code_pressed_once(code))
file = code - KEYCODE_0_PAD + '0';
if (file == 0)
return state;
/* display a popup indicating that the save will proceed */
sprintf(filename, "%c", file);
if (state == LOADSAVE_SAVE)
{
popmessage("Save to position %c", file);
mame_schedule_save(machine, filename);
}
else
{
popmessage("Load from position %c", file);
mame_schedule_load(machine, filename);
}
/* remove the pause and reset the state */
mame_pause(machine, FALSE);
return UI_HANDLER_CANCEL;
}
What I hacked it into (you could probably remove more, like the cancel check probably isnt too relevant now, but I didn't know quite enough about the workings)
/*-------------------------------------------------
handler_load_save - leads the user through
specifying a game to save or load
-------------------------------------------------*/
static UINT32 handler_load_save(running_machine *machine, UINT32 state)
{
char filename[20];
char file = 0;
/* if we're not in the middle of anything, skip */
if (state == LOADSAVE_NONE)
return 0;
/* check for cancel key */
if (ui_input_pressed(machine, IPT_UI_CANCEL))
{
/* display a popup indicating things were cancelled */
if (state == LOADSAVE_SAVE)
popmessage("Save cancelled");
else
popmessage("Load cancelled");
/* reset the state */
mame_pause(machine, FALSE);
return UI_HANDLER_CANCEL;
}
/* display a popup indicating that the save will proceed */
sprintf(filename, "%c", file);
if (state == LOADSAVE_SAVE)
{
popmessage("Save to position %c", file);
mame_schedule_save(machine, filename);
}
else
{
popmessage("Load from position %c", file);
mame_schedule_load(machine, filename);
}
/* remove the pause and reset the state */
mame_pause(machine, FALSE);
return UI_HANDLER_CANCEL;
}