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: Mame 0187 save and load states and pause  (Read 7772 times)

0 Members and 1 Guest are viewing this topic.

evilsidius

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:December 03, 2017, 10:53:31 pm
  • I want to build my own arcade controls!
Mame 0187 save and load states and pause
« on: July 17, 2017, 06:35:38 pm »
Hello guys, i am new to all this, so sorry if this is a noob question.

Well, for now i use my pc for play. In the future i am thinking to build a arcade. But for now i use my windows 10 with a xbox controller.
I have 3 questions.

1 - What i want is to make the save state and load state more simple using only one button, is that possible? I just want to use position 1. So there is a way to assign one button for save in position 1 and another button to load from position 1?

2 - I want Pause the emulation and save or load and i still want the emulation paused. There is a way?
Let me explain this better, those that use the fusion emulator for mega drive, if you pause emulation and load a state you can notice that the emulation will still be on pause. After you press pause again that the emulation will start on the loaded file. I dont know if i make myself clear. English isnt my first language.

Anyway, hope you can help me, thanks you all.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Mame 0187 save and load states and pause
« Reply #1 on: July 17, 2017, 09:52:16 pm »
You could achive what you want using MAME's Lua plugin system.

I created a basic load/save state plugin you can use a guide.

savestate_plugin.zip

KenToad

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1504
  • Last login:September 17, 2024, 06:05:43 pm
  • Flap Flap Flap
Re: Mame 0187 save and load states and pause
« Reply #2 on: July 17, 2017, 10:07:24 pm »
Doesn't MAME support this natively? It seems to me like I have paused emulation, hit the save state button, then when I load state, it remembers that it was paused. I'm thinking of an older version of MAME.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Mame 0187 save and load states and pause
« Reply #3 on: July 17, 2017, 10:08:51 pm »
Doesn't MAME support this natively? It seems to me like I have paused emulation, hit the save state button, then when I load state, it remembers that it was paused. I'm thinking of an older version of MAME.

You could be right. I just knocked up a plugin as proof-of-concept.

evilsidius

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:December 03, 2017, 10:53:31 pm
  • I want to build my own arcade controls!
Re: Mame 0187 save and load states and pause
« Reply #4 on: July 21, 2017, 09:49:44 pm »
Thanks, when i get home at weekend i will try.
About the pause, when i load here the game starts. Maybe ita a option somewhere?

evilsidius

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:December 03, 2017, 10:53:31 pm
  • I want to build my own arcade controls!
Re: Mame 0187 save and load states and pause
« Reply #5 on: July 24, 2017, 09:00:42 pm »
Doesn't MAME support this natively? It seems to me like I have paused emulation, hit the save state button, then when I load state, it remembers that it was paused. I'm thinking of an older version of MAME.

You could be right. I just knocked up a plugin as proof-of-concept.

Headkaze, your plugin worked. Thanks a lot.
But still, when i pause (P) the emulation and used your plugin to save, automatically the emulation started with the message that save was sucefull in front of the game.

I would like to save and load and the emulation stayed on pause. Or at least didint show any message of save sucefull or load sucefull. There is a option?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19405
  • Last login:September 17, 2024, 05:47:47 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Mame 0187 save and load states and pause
« Reply #6 on: July 25, 2017, 04:06:48 pm »
Mame, unfortunately, isn't made with the user in mind.  The only reason we got save states at all is the fact that they make it easier for devs to troubleshoot bugs. 

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Mame 0187 save and load states and pause
« Reply #7 on: July 25, 2017, 05:13:20 pm »
I would like to save and load and the emulation stayed on pause. Or at least didint show any message of save sucefull or load sucefull. There is a option?

Yes, just add an "emu.pause()" statement after loading/saving the state.

Eg.
Code: [Select]
local function savestate_menu_callback(index, event)
if event == "select" then
local menu_item = savestate_menu[index][1]

if menu_item == "Load State" then manager:machine():load("auto")
elseif menu_item == "Save State" then manager:machine():save("auto")
end

emu.pause()
end
return false
end

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19405
  • Last login:September 17, 2024, 05:47:47 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Mame 0187 save and load states and pause
« Reply #8 on: July 25, 2017, 08:28:13 pm »
Isn't emu.pause a toggle?

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Mame 0187 save and load states and pause
« Reply #9 on: July 26, 2017, 04:45:04 pm »
Isn't emu.pause a toggle?

Nope, as per luaengine.cpp source it's:

Code: [Select]
* emu.pause() - pause emulation
 * emu.unpause() - unpause emulation

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19405
  • Last login:September 17, 2024, 05:47:47 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Mame 0187 save and load states and pause
« Reply #10 on: July 26, 2017, 10:52:32 pm »
Well that's great.  Most emulator lua implementations have pause screwed up in some way.  Thanks for teaching me something yet again.  :)

Fenris891

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:August 08, 2024, 04:23:52 am
  • I want to build my own arcade controls!
Re: Mame 0187 save and load states and pause
« Reply #11 on: August 03, 2024, 12:33:06 pm »
Hi Headkaze, Im interested in the same thing and this is the only post I found about this issue. Could you reupload your plugin please?

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9493
  • Last login:Today at 12:15:29 pm
  • Designated spam hunter
Re: Mame 0187 save and load states and pause
« Reply #12 on: August 03, 2024, 06:00:50 pm »
Could you reupload your plugin please?
It's been a while since he logged in here so here's a backup from archive.org.   :cheers:
https://web.archive.org/web/20220703081902/headsoft.com.au/download/mame/savestate_plugin.zip


Scott

Fenris891

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:August 08, 2024, 04:23:52 am
  • I want to build my own arcade controls!
Re: Mame 0187 save and load states and pause
« Reply #13 on: August 04, 2024, 04:46:15 am »
Thanks, I really appreciate it! In which MAME folder should I need to extract it? "plugin" subfolder maybe? Because there already are tons of init.lua files in different subfolders so I dunno where to put this one. Noob here  ;D
« Last Edit: August 04, 2024, 05:23:28 am by Fenris891 »

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9493
  • Last login:Today at 12:15:29 pm
  • Designated spam hunter
Re: Mame 0187 save and load states and pause
« Reply #14 on: August 04, 2024, 04:15:20 pm »
In which MAME folder should I need to extract it? "plugin" subfolder maybe?
Yes.  Copy the "savestate" folder from the .zip file into the "\mame\plugins\" folder.

To enable the plugin, either:
1. Edit the plugin.ini file so savestate is 1 (enabled) instead of 0. (disabled)
    or
2. Launch MAME, press TAB to bring up the MAME menu system, go into the plugins menu, and switch savestate to ON.

Now that you've enabled the plugin, press Shift-F7 to save the current state or press F7 to restore an already-saved state.

I tested the plugin in MAME0.262 with Asteroids (rev 4) and sometimes it works, but it does not restore the pause status or pause after restoring -- the restore loads and you're off and running.
- If trying to save/restore a state with the plugin causes an error with line 38 or 39, press Enter or ESC to close the error window, press Alt-Enter to restore the display to full screen, and try saving/restoring again close the savestate menu called by pausing, and press Shift-F7 to save or F7 to restore.  The error appears to be frequent but intermittent caused by the savestate menu shown below.   :dizzy:
- IIRC LUA scripting has been updated several times since Headkaze wrote the plugin so not sure if that's causing the errors.

Looking in the init.lua file, the only reference I see to pause is this . . .
Code: [Select]
emu.register_pause(function()
emu.show_menu("SaveState")
end)
. . . which apparently causes the pause function to also bring up the savestate menu.

What I don't see in the script is the "emu.pause()" command that Headkaze mentioned, so you'll need to add it yourself if you want it.
I would like to save and load and the emulation stayed on pause. Or at least didint show any message of save sucefull or load sucefull. There is a option?

Yes, just add an "emu.pause()" statement after loading/saving the state.

Eg.
Code: [Select]
local function savestate_menu_callback(index, event)
if event == "select" then
local menu_item = savestate_menu[index][1]

if menu_item == "Load State" then manager:machine():load("auto")
elseif menu_item == "Save State" then manager:machine():save("auto")
end

emu.pause()
end
return false
end


Scott
EDIT: Did more testing in MAME v0.238 and v0.262.  Errors happen whenever you try to use the savestate menu shown in the attachment to save or restore.  The error doesn't happen if you pause, close that savestate menu, and then save using Shift-F7 or restore using F7.
« Last Edit: August 04, 2024, 06:10:49 pm by PL1 »

Fenris891

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:August 08, 2024, 04:23:52 am
  • I want to build my own arcade controls!
Re: Mame 0187 save and load states and pause
« Reply #15 on: August 05, 2024, 04:57:32 am »
Yeah, indeed I get the error you mentioned whenever I try to use the plugin to save/load my state..it gives me line 38 and 39 error, attempt to call sol.running_MACHINE.
I ve  done all what you said, apart for the fact that I have no plugin.ini in my MAME folder. Maybe this is causing the issue?  Plus shift+f7 does nothing...tried to use f5 and f9, my shortcut to save/load normally but then plugin became useless...  :banghead:
My version of MAME is 0.245