mamedev / mame

MAME
https://www.mamedev.org/
Other
7.8k stars 1.96k forks source link

Can save states be copied between desktop and ECMAScript versions of MAME? #7132

Open danmons opened 3 years ago

danmons commented 3 years ago

I've followed the guide for building MAME to ECMAScript here using the 0.217 source release: https://docs.mamedev.org/initialsetup/compilingmame.html#emscripten-javascript-and-html

I've also built a local 0.217 binary for my Linux x86_64 desktop from the same source release. I've used the local version to take a save state, and then passed that file via Emularity to my web version.

The emulator in the browser loads the actual machine/bios/game fine, however I get the following message on load in the emulated GUI:

"Error: Unable to load state due to invalid header. Make sure the save state is correct for this machine."

Are these save states portable? I can successfully save and load new save states in the browser version, however I'm not sure how to save these permanently (they don't even land on browser disk cache, and I don't know how to extract them from running memory). I was hoping the local version could be copied from my desktop system to the web version easily.

I'm building a Sega SC-3000 specific build ("sc3000" driver, which is a clone of "sg1000"), and the desire to use save states is to avoid lengthy/complex tape loading for users of the web-hosted versions. (Virtual tape loading via .wav files works fine in the web/Emularity version, but I just want this to be as simple to use as possible for potential users who are non-technical or unfamiliar with this original system).

cuavas commented 3 years ago

Save states are supposed to be portable, but certain MAME devices aren’t endian-safe, so they sometimes aren’t portable between big- and little-endian machines. If they aren’t portable between C++ and ECMASCRIPT versions, I’d say something is going wrong.

danmons commented 3 years ago

I finally managed to craft some javascript to download the in-memory save state from the ECMAscript version. I could then take that file, upload it to the web server, and send it along with Emularity at load time to load the state again as expected.

I took that ECMAscript-build-generated state file, and passed it to the desktop version of MAME, and it gave me the same error: "Error: Unable to load state due to invalid header. Make sure the save state is correct for this machine."

From that it appears that these builds can't share save states.

I can provide samples of these from each version if required (if it's OK to attach binary blobs to issues, and/or useful?). They're under 3KB each.

cuavas commented 3 years ago

I don’t think we’ve disabled attachments.

danmons commented 3 years ago

Apologies for the delay. I've re-tested this with:

EMSDK 1.40.1 (2.X would not build) MAME 0.230 Ubuntu Linux 20.04.2, GCC 9.3.0, OpenJDK 11.0.10

ECMASCRIPT version was built with the following: emmake make SUBTARGET=sc3000 SOURCES=src/mame/drivers/sg1000.cpp,src/lib/formats/sc3000_bit.cpp

C++/Linux version built with: make SUBTARGET=sc3000 SOURCES=src/mame/drivers/sg1000.cpp,src/lib/formats/sc3000_bit.cpp

My command line for running the Linux version looks like: ./sc3000 sc3000 -ui_active -cart Sega_BASIC_Level_3_V1_SC-3000.sc -cass sc3000_vortex_blaster.wav

And I load the eCMASCRIPT version similarly via Emularity, documented here (this was back in August when I first experimented with this, so versions are slightly older than what I've re-tested today): https://stickfreaks.com/sega-sc-3000/faq-emulator-in-a-web-browser

I've then loaded my BIOS/tape image in both, loaded the tape game into RAM, and captured a save state (URL above shows how I do that for the ECMASCRIPT version).

Each save state is attached to this message, and attempting to load one state into the other version gives the error: "Error: Unable to load state due to invalid header. Make sure the save state is correct for this machine."

I can copy the save state for a given build to another physical machine or browser and execute everything there as expected. However any attempt to load the ECMASCRIPT generated save state in the C++ binary or vice versa fails.

savestates.zip

If there's any more information I can provide, please let me know.