bbsan2k/Flash1M_Repro_SRAM_Patcher

Can you provide the source code of patchset?

Closed this issue · 2 comments

Hello, I'm looking at this project's code and see if I can modify it to save Sram to nor flash(as bootlegs are writeable)

but the patchsets are provided in hex, which I can't modify.

So can you kindly provide the source code of patchsets?

Hey,

Unfortunately there is no source of the patch sets. I loaded the according Roms in No$GBA and edited the assembler code - so this might be an approach for you.

The NOR Save stuff I know about works the following way:

Startup:

  1. Patch ROM entry adress to somewhere outside the normal "ROM".
  2. Load Code that moves data from NOR to SRAM into WRAM (X)
  3. Execute Code from (X) in WRAM
  4. Load ROM entry point

Saving:

  1. Patch Save functions to store the saves to SRAM
  2. After SRAM save jump to another address outside ROM space
  3. Load Code that stores SRAM content in NOR to WRAM (Y)
  4. Execute WRAM
  5. Continue from SP

This will lead to a ROM that should look like the following:

|------------------|--------------------|----------------------|-------------------------------------|
| (patched) ROM    | Bootup Code (X)    | Save Code (Y)        | Game Save Data                                  |
|------------------|--------------------|----------------------|-------------------------------------|

Essentially all my patches do is:

  • Remove Save specific Code (EEPROM/FLASH)
  • Add Bank Switching if required (for 1M --> SRAM)

Hope this helps

Thanks for your reply.
So, what you are saying is that you modify the patch base on the existing SRAM patch sets, right?
Where did you get those patches? GBATA or other tools?

I don't know much about patches, so this is what I really want to know:

What will happen when we do a 1M Sram save.

will it be like this:

  • save the first half of 512K bits
  • switch bank
  • save the second half of 512K bits

or it saves interleaf?

Basically what I want to do is to emulate 1M save in a cart that does not support SRAM banking.

Which requires :

  1. redirect the save loading part to nor flash, or, load the correct bank to SRAM when needed.
  2. when saving: save the correct data to nor flash.
    • if the saving is continuous, we can simply change the "SRAM bank switching" code in your patch to "SRAM to flash"
    • if the saving is not continuous, but only writes every data once, we can then erase the flash first, then we directly write it to flash when needed
    • if the saving is not continuous, and will do some read-modify-write, then it's quite difficult to save it to flash, we might need to use SRAM as a swap area to do so.

So, can you tell me what's happening when a game call the save function?