How to add Save State support to unsupported ROMs

Save states in theory should work with all ROM's which make use of the VBlank interrupt. What this means isn't important unless you're into the inner workings of the system. Here's how to add support!

The theory is, we change the code in the keypad read routine, which every game should have, assuming it uses the keypad as an input device.

We overwrite a few of the instructions to 'Call' an address $0040. This is the Vblank address and instructs the ElcheapoSD to do its magic. We can't just call the address though, we need to re-insert the code we overwrote. Then we 'Return' back to the main code execution stream.

We start by opening the ROM in BGB.

Go to Debug, Access Breakpoints. Enter FF00 and hit Add. It is best to do this when the game is running.

You'll want to find a screen like this. Click on the game image until one appears.

We'll want to change the line "LD A,10" to "Call 0040"

We then scroll up to address 0040. We need to put those instructions we overwrote.

So we enter "LD A,10" and "LD (FF00),a"  and then "Ret"

To finish it off, we go to File, Fix checksums. Then save it, identifying you've patched it.

That's all there is too it. This can have some side effects, In Prince of Persia there is a sprite glitch on the continue/password screen. It otherwise works flawlessly with save states!

The same principal applies to Battletoads. I haven't come across another game which needs patching yet.