mGBA Forums
Save State Information - re: compression, etc. - Printable Version

+- mGBA Forums (
+-- Forum: mGBA (
+--- Forum: General (
+--- Thread: Save State Information - re: compression, etc. (/showthread.php?tid=5624)

Save State Information - re: compression, etc. - wuvo - 09-14-2023


I'm a hobbyist who enjoys messing with save state data in hex editors, and occasionally writing tools (for Windows) like game editors, save state editors, etc... I downloaded mGBA with the hopes of being able to poke around in the save states of a particular game and write a guide or some software.

However, the save states are compressed, and vary in size - and apparently also contain image data and/or the *.sav file architecture, etc, all within the *.ss* file.

Does anyone know of any documentation regarding the compression methods or any other useful information about the save state architecture? (I've looked through some of the source code on GitHub but haven't found anything useful yet.)

I can't seem to find options to turn off SS compression in mGBA.


RE: Save State Information - re: compression, etc. - endrift - 09-14-2023

You can turn off save state compression by disabling saving screenshot extra data. When enabled, save states are embedded in custom chunks in PNGs, namely gbAs (main save state) and gbAx (extra data, usually things like metadata, .sav file, etc). These custom chunks are compressed using zlib's default compression. When screenshots are disabled, everything is uncompressed with the raw save state followed by the extra data, as the raw save state is a fixed size based on the platform.

The format of the raw save state is documented in the appropriate header file for the platform in question:


All data is stored in little endian byte order (even on the Wii).

The format of the extra data in an uncompressed file, is an array of extdata type, size, and offset into the file. In PNG save states, each datum has its own gbAx chunk, with a 4-byte tag, 4 byte (uncompressed) length, then compressed data.

The relevant code is in this file:, and the list of tag types is at the top of this file:

RE: Save State Information - re: compression, etc. - wuvo - 09-14-2023

I had disabled those options and noticed the size increase in the save state, but it seemed to only effect one of the saves - turns out it was just the file details in Explorer not refreshing appropriately... lead me to believe the options weren't having an effect.

Thanks for the fast reply, and appreciate pointing me to the appropriate code.

Nice emulator!