Dolphin, the GameCube and Wii emulator - Forums
Uncompress Savestate - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Dolphin Emulator Discussion and Support (https://forums.dolphin-emu.org/Forum-dolphin-emulator-discussion-and-support)
+--- Forum: Development Discussion (https://forums.dolphin-emu.org/Forum-development-discussion)
+--- Thread: Uncompress Savestate (/Thread-uncompress-savestate)



Uncompress Savestate - Vash - 12-24-2009

Hi, I need to decompress the savestates of the dolphin due to some hack I'm doing in some wii games. It is possible to do it with some flag that I can't find?


RE: Uncompress Savestate - LuisR14 - 12-27-2009

dolphin doesn't compress savestates Tongue


RE: Uncompress Savestate - Vash - 12-27-2009

I saw the LZO functions in the code, but i guess it's chuncked so it would take a loooot to uncompress it manually..


RE: Uncompress Savestate - LuisR14 - 12-29-2009

dolphin doesn't compress the savestates >_>


RE: Uncompress Savestate - sl1nk3 - 12-29-2009

(12-29-2009, 01:44 PM)LuisR14 Wrote: dolphin doesn't compress the savestates >_>

The name of this function should be pretty much self explanatory :
http://code.google.com/p/dolphin-emu/source/browse/trunk/Source/Core/Core/Src/State.cpp#151


RE: Uncompress Savestate - LuisR14 - 12-29-2009

T_T (dam whoever told me that it doesn't >_>), and seeing from that i'd like to see an uncompressed save state Smile


RE: Uncompress Savestate - Phoenix - 12-30-2009

Hi All!
I recently developed a decompressor for dolphin's save states. It should work fine 'cose is based on the decompression code of dolphin.

Reading the "loading save state code", i noticed something strange.

Code:
fread(&header, sizeof(state_header), 1, f);
    
...
sz = header.sz;
bCompressedState = (sz != 0);
if (bCompressedState)
{
    Core::DisplayMessage("Decompressing State...", 500);

    lzo_uint i = 0;
    buffer = new u8[sz];
...
    while (true)
    {
        lzo_uint cur_len = 0;
        lzo_uint new_len = 0;
        if (fread(&cur_len, 1, sizeof(int), f) == 0)
            break;
        if (feof(f))
            break;  // don't know if this happens.
        fread(out, 1, cur_len, f);
        int res = lzo1x_decompress(out, cur_len, (buffer + i), &new_len, NULL);

        i += new_len;
    }
}
else
{
    fseek(f, 0, SEEK_END);
    sz = (int)(ftell(f) - sizeof(int));
    fseek(f, sizeof(int), SEEK_SET);
    buffer = new u8[sz];
             fread(buffer, 1, sz, f);
}

Checking if the save state is compressed or not. If the save is decompressed, the code reads in the buffer the wrong data i think:
Code:
fseek(f, 0, SEEK_END);
sz = (int)(ftell(f) - sizeof(int)); <-- should exclude the header size, not int size
fseek(f, sizeof(int), SEEK_SET); <-- should seek after header size, not int size
buffer = new u8[sz];
fread(buffer, 1, sz, f);