libretro / px68k-libretro

Portable SHARP X68000 Emulator for Libretro
http://hissorii.blog45.fc2.com
GNU General Public License v2.0
45 stars 41 forks source link

[Enhancement] Support for save states #59

Closed Darknior closed 3 weeks ago

Darknior commented 6 years ago

Hi Is it possible to have Save states on x68000 like on the other LR emulators ? I know it works perfectly on xBox Madmab emulator, it's possible.

gingerbeardman commented 6 years ago

I'll look into this. Not sure at the moment how feasible it is. I'm hopeful.

Darknior commented 6 years ago

The way is to save the x68000 memory to reload it after. I know it's complicated on the Microsoft DOS, not easy to implement, i don't know for x68000. But it save life on many old games so hard ... or so long to end quickly ...

gingerbeardman commented 6 years ago

Yes, save memory and registers.

I will try to figure it out! My C skills are very low 🤣

Darknior commented 6 years ago

Mine are zero :( I only code in PHP and Javascript ... i can't do nothing with this in emulation world :p I can only help in Theming, and beta test ;)

gingerbeardman commented 6 years ago

I think you'd be surprised how much of the source code you can easily read.

usedr commented 6 years ago

My god, do we need this!

Darknior commented 5 years ago

Yes some games are so hard, i pray to have this option one day

Darknior commented 5 years ago

The other options are not really important .... but this one is really. No one is playing this computer because we can't save our game advancement :( We must always start from begining ... and x68000 stay an strange computer no one use .... so bad :(

I have try with Akumaju Dracula yesterday, create a character, play the first level, reboot, and no save in game stored :( Is this emulator store our games advancement with real old save ???

gingerbeardman commented 5 years ago

This emulator works exactly as the original computer. You need to save your game to a blank disk from inside the game.

But, yes, modern save states would be very welcome

Darknior commented 5 years ago

OK thanks for your answer @gingerbeardman. It's what i've think about. Very complicated for common users ... i try to configure this emulator for me, common users and my children. My little girl love video games and has only 6 years old. She can't do so complicated command.

How/Where can i get a blank disk file ? Maybe i can load the game with the blank disk with a M3U ? To make it auto for users ? Is there an easy way for that please. I search the solution for a children, easy, and all with the gamepad. No Keyboard, like a SNES console ... i know x68000 is a computer, a fantastic one ... and i really want more people try it easily ::p

gingerbeardman commented 5 years ago

@Darknior well, again it comes down to how the original machine worked.

You insert a disk and format it to be blank. Note: a blank disk is often called user disk by the game. And a game should offer to create a blank/user disk for you if it offers the ability to save.

Or you can format using command line or an app on the emulated system.

What file to use? Maybe a duplicate of an existing hdm disk image? Of course not a zip file.

Really it is not for here, start a thread in the user support forum.

https://forums.libretro.com/t/px68k-libretro/10113/36

Darknior commented 4 years ago

Hi :) Some news about a savestate support on this core ? Or it's really hard to implement .... Thanks a lot

gingerbeardman commented 4 years ago

I will not be able to do this due to time and new family needs.

Darknior commented 4 years ago

It's normal :) Real life is the most important ;) Maybe we will have a chance some one else have time to do it one day :p

negativeExponent commented 4 years ago

anyone has started anything for this yet?

Darknior commented 4 years ago

@negativeExponent do you think you can do it ?

darksgan commented 1 year ago

I would love to have a save state option. Not only for saving progress (you can save anyway if the game let you do it with an option, but some games, more arcade-like don't)

... I would love to "simulate" a "console" experience with some games (having X6800 some of the best "home-ports")... I mean... for example Super SF II: CE.

It work nice, and I can even correct the aspect ration (I was not able to do it with other standalone emulators, XM6 forks o WinX64k

BUT... I can't save the controllers configurations... Street Fighter uses 6 buttons for playing, right? so I need to change the 2 buttons controller (set by default in the game), to CPSF or CPSF-MD (maybe, this one better, for me).

If I could save the state, I could configure the controllers as CPSF-MD for players 1 and 2, go back to the menu and wait till the intro starts again, right in that moment, I could save the state in one slot (the less used one, for example).

After that, I could launch the emulator using a script (for copying config files, launch the game directly, etc), and calling other scripts from that main script... for example, I could call an Autohotkey script wich could "press F4 automatically" (load the savestate) after launching the game/emulator ... then I would have the controllers or any other option preset as wanted (futhermore, I would skip the "machine starting up" and "loading game posts" as a plus, saving time).

Regards :)

wn2000 commented 3 months ago

I'm making some progress on this.

Current status is that I could reliably save/load states without crashing the core.

But apparently I'm still missing some data in my save.

Example:

  1. Run Akumajou Dracula, save a state outside of the castle at slot 0, save another state once inside the castle at slot 1.
  2. Quit game, then reneter the game.
  3. Load slot 1. I get this:

dracula

Aside from the obviously corrupted background, it seems the "transparency data" is also missing, as the eye-like creature floating outside of the window can be seen through the wall.

@gingerbeardman or anyone else, do you know where that data is kept?

Currently I'm already saving/restoring a lot of variables, including:

If in step 2, I do not quit the game, saving/loading seems to work fine. That again shows that I'm missing something in the save.

negativeExponent commented 3 months ago

save and set c68k's PC manually using the C68K_set/get_reg_xx in c68k.c if you are not yet doing so already.

wn2000 commented 3 months ago

save and set c68k's PC manually using the C68K_set/get_reg_xx in c68k.c if you are not yet doing so already.

Yeah doing that already. Will do more trial and error.

negativeExponent commented 3 months ago

save and set c68k's PC manually using the C68K_set/get_reg_xx in c68k.c if you are not yet doing so already.

Yeah doing that already. Will do more trial and error.

is your background loading fine in the Music mode?

wn2000 commented 3 months ago

is your background loading fine in the Music mode?

Good idea. I just tried. I waited until the title screen appears, then loaded a save state that was saved in Music Mode.

The screen did not refresh to show the Music Mode, but the correct music starts to play.

negativeExponent commented 3 months ago

is your background loading fine in the Music mode?

Good idea. I just tried. I waited until the title screen appears, then loaded a save state that was saved in Music Mode.

The screen did not refresh to show the Music Mode, but the correct music starts to play.

is your background loading fine in the Music mode?

Good idea. I just tried. I waited until the title screen appears, then loaded a save state that was saved in Music Mode.

The screen did not refresh to show the Music Mode, but the correct music starts to play.

is your background loading fine in the Music mode?

Good idea. I just tried. I waited until the title screen appears, then loaded a save state that was saved in Music Mode.

The screen did not refresh to show the Music Mode, but the correct music starts to play.

run TVRAM_SetAllDirty(); after loading states, this should fix the black bg on music mode, not sure if this helps your other issue.

wn2000 commented 3 months ago

Thanks I actually tried TVRAM_SetAllDirty() in game mode but it did not solve the corrupted background issue, so I removed it later. I'll try it again in the Music mode.

negativeExponent commented 3 months ago

are you able to load a state while the px68k is still booting (still on Human DOS screen) without crashing and its playable despite the garbled graphics? if you are able to, then its just probably something overlooked like write instead of read on a state, wrong variable size, incorrect mem index etc. do you have your changes uploaded?

wn2000 commented 3 months ago

I sorted it out. Missed some variables at an early phase of poking and thought I had everything saved.

The savestate is quite large atm, so may incur some performance hit when rewind is enabled. But should be good for saving progress.

negativeExponent commented 3 months ago

thats good to hear. when can we expect your PR for it?

wn2000 commented 3 months ago

Soon. Needs to clean it up.

negativeExponent commented 2 months ago

we should be getting this soon?.... hopefully?....

negativeExponent commented 1 month ago

Is now soon enough?

negativeExponent commented 3 weeks ago

Save state support has been added....

negativeExponent commented 3 weeks ago

done