Desmemu Save State

Discussion in 'NDS - Emulation and Homebrew' started by Kaleid, Jan 30, 2011.

Jan 30, 2011

Desmemu Save State by Kaleid at 9:51 PM (930 Views / 0 Likes) 2 replies

  1. Kaleid
    OP

    Newcomer Kaleid Advanced Member

    Joined:
    Jan 22, 2011
    Messages:
    69
    Country:
    United States
    I posted in another forum, but it may have been the wrong one. Here to see if any emulator pros can help me out.

    I am trying to figure out the format of Desmemu save states. Here is what I know. (Please note I know almost nothing about the cpp language, as I code in vb.)

    1. The states are compressed with zlib.
    CODE#include
    2. The header is 32 bytes long. See this code found in the saves.cpp source file:
    Code:
    ÂÂÂÂÂÂÂÂos = outstream;
    ÂÂÂÂÂÂÂÂos->fseek(32,SEEK_SET); //skip the header
    ÂÂÂÂÂÂÂÂwritechunks(os);
    3. The header contains the following:
    Code:
    //dump the header
    ÂÂÂÂoutstream->fseek(0,SEEK_SET);
    ÂÂÂÂoutstream->fwrite(magic,16);
    ÂÂÂÂwrite32le(SAVESTATE_VERSION,outstream);
    ÂÂÂÂwrite32le(EMU_DESMUME_VERSION_NUMERIC(),outstream); //desmume version
    ÂÂÂÂwrite32le(len,outstream); //uncompressed length
    ÂÂÂÂwrite32le(comprlen,outstream); //compressed length (-1 if it is not compressed)
    The magic number and version is simply
    Code:
    #define SAVESTATE_VERSIONÂÂÂÂÂÂ 12
    static const char* magic = "DeSmuME SState";
    The Desmemu version is 0x000161E8 (90600 or 0.9.6).

    Anywho, since the header is 32 bytes long, the should mean the actual compressed state starts at 0x20. This seems correct since all the states have the same 32-bit value there (0xBDEC9C78). All attempts to delete the header and decompress the remains have yielded nothing but errors.

    Any help with this issue would be amazing! I would like to finish my save state editors soon. Thanks.
     
  2. avenir

    Member avenir GBAtemp Fan

    Joined:
    Dec 8, 2010
    Messages:
    375
    Country:
    United States
  3. Kaleid
    OP

    Newcomer Kaleid Advanced Member

    Joined:
    Jan 22, 2011
    Messages:
    69
    Country:
    United States
    As I said in my original post, I know almost nothing of the c++ language. Also, I have tried to read through the saves.cpp file. That is where the code from my original post came from.
    Also, how would changing the value at 0x1c to 0xffffffff allow the file to be decompressed by an external decompressor? Maybe you didn't understand my original post.

    I want to be able to decompress the save state using the zlib dll in my own program. When I try to do that, it returns errors every time saying the file format is incorrect, most likely because of the header Desmemu uses.
     

Share This Page