Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing to the save/load game data
(11-15-2018, 04:26 AM)KeiDash Wrote: OMG assembler...I don't know it.

Well, I'm going to try to understand it and if I got it, implement a save/load data. In other case, I try to find another way to do it.

Many thanks Loic!

I did take a quick look at the C sources mentioned by Ed...
So... it's inline assembly ^_^;

What you need is the SAVEOFFSET and the BLOCK_NB. You can find them in my previous post if you want to be able to test your code on flashmasta or bung.
Otherwise, you can use the data in my previous forum link to determine them, depending on the size of your game (from 4mbits to 32mbits).

void Flash(void *data) {
    __ASM("SAVEOFFSET    EQU    0x1e0000");                     // you need to set this offset depending on your game size
    __ASM("BLOCK_NB        EQU    30");                                // this offset should give you the bloc number (see link in previous post)

    __ASM("VECT_FLASHWRITE    EQU    6");
    __ASM("VECT_FLASHERS    EQU    8");
    __ASM("rWDCR        EQU    0x6f");
    __ASM("WD_CLR        EQU    0x4e");

    // Erase block first (mandatory) : 64kb for only 256 bytes
    __ASM("    ld    ra3,0");
    __ASM("    ld    rb3,BLOCK_NB");
    __ASM("    ld    rw3,VECT_FLASHERS");
    __ASM("    ld    (rWDCR),WD_CLR");
    __ASM("    swi    1");

    // Then write data
    __ASM("    ld    ra3,0");
    __ASM("    ld    rbc3,1");    // 256 bytes
    __ASM("    ld    xhl,(xsp+4)");
    __ASM("    ld    xhl3,xhl");
    __ASM("    ld    xde3,SAVEOFFSET");
    __ASM("    ld    rw3,VECT_FLASHWRITE");
    __ASM("    ld    (rWDCR),WD_CLR");
    __ASM("    swi    1");

    __ASM("    ld    (rWDCR),WD_CLR");

void GetSavedData(void *data) {                                  // should be rather easy, just a simple data copy from flash to ram
    u32 *ptr = (u32*)(0x200000+0x1e0000);
    u32 *ptrData = (u32*)data;
    u8 i;
    if (*ptr == MAGIC_NB) // Data saved
        for (i=0;i<64;i++)
            ptrData[i] = ptr[i];
    else // No data
        ptrData[0] = MAGIC_NB;
        for (i=1;i<64;i++)
            ptrData[i] = 0;
Edit : I think those C sources come from SOD/Thor's "Another day in hell" shooter (

Messages In This Thread
Accessing to the save/load game data - by KeiDash - 11-14-2018, 11:38 PM
RE: Accessing to the save/load game data - by Loïc - 11-15-2018, 08:59 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)