Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Removing save slot select from save/load  (Read 975 times)

0 Members and 1 Guest are viewing this topic.

syph007

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 598
  • Last login:June 24, 2014, 04:30:03 pm
  • With a router big enough, we can shape the world!
Removing save slot select from save/load
« on: May 11, 2010, 01:13:00 pm »
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;
}