I was able to back up saves to most of my cartridges using the Kazoo and Anago, however I'm having trouble dumping and writing the saves of Startropics and Zoda's Revenge. I read these use the MMC6, which is similar to the MMC3 except for how the save RAM works. I read up on MMC3 and MMC6 on the wiki and still couldn't figure out how to code this.
Here's what I tried so far.
1. I copied the MMC3.ag script in the anago folder and renamed it MMC6.ag
2. In the header I changed the cpu_ram lines to this because the MMC6 RAM is only 1KB (mirrored four times) instead of 8KB
cpu_ram = {
size_base = 0x0400, size_max = 0x0400,
banksize = 0x0400,
}
I think I only need to write the first 1KB, maybe that's wrong.
3. Next, I edited the function cpu_ram_access to disable the MMC6's different PRG RAM protection and write the save to the appropriate location
function cpu_ram_access(d, pagesize, banksize)
{
cpu_write(d, 0x8000, 0x20);
cpu_write(d, 0xa001, 0xf0);
cpu_ramrw(d, 0x7000, banksize);
}
The first line changes the bit at 0x8000 to enable the PRG RAM. Without this, reading and writing to the PRG RAM has no effect. This is the main difference between MMC6 and MMC3.
The second line should enable reading and writing to the PRG RAM. However, the closet I've got to reading a save file is 0x200 lines of zeroes then 0x200 lines of the same repeating junk line. Reading or writing like this seems to delete the save. I tried setting a001 to 10, 20, 30, ... e0, f0 and couldn't get it to work on any so I know I'm missing something else here (possibly need to update NES mapper 4; I have no idea how to do that).
The third line writes the save file (it's size 0x400 and starts at 0x7000). I'm not sure, but I think this is supposed to mirror three more times to 0x7FFF after it's written.
I'm not sure how to make it work. Here's some other things I tried:
1. dump save with mmc3.ag -> get a .sav full of Fs. This is correct.
2. tweak 0xa001 -> still all Fs. This is also correct, since the PRG RAM is still locked in MMC6.
3. set 0x8000 to 0x20 -> now, tweaking 0xa001 has an effect, but I still can't get it to read/write the save properly.
Setting 0xa001 to the following values has the following effects:
0x00: .sav is still all Fs.
0x10: .sav is all Fs.
0x20: .sav is all 0s. Interesting.
0x40: .sav is all Fs.
0x80: .sav is 200 lines of 0s, followed by 200 of the same junk line, repeated four times. The save file on the cartridge is erased when reading or writing.
0xf0: same as setting 0xa001 to 0x80
I think this should be simple. What am I missing? Can someone figure out how to read and write a save to a Startropics or Zoda's Revenge cart and share how to do it?
Here's what I tried so far.
1. I copied the MMC3.ag script in the anago folder and renamed it MMC6.ag
2. In the header I changed the cpu_ram lines to this because the MMC6 RAM is only 1KB (mirrored four times) instead of 8KB
cpu_ram = {
size_base = 0x0400, size_max = 0x0400,
banksize = 0x0400,
}
I think I only need to write the first 1KB, maybe that's wrong.
3. Next, I edited the function cpu_ram_access to disable the MMC6's different PRG RAM protection and write the save to the appropriate location
function cpu_ram_access(d, pagesize, banksize)
{
cpu_write(d, 0x8000, 0x20);
cpu_write(d, 0xa001, 0xf0);
cpu_ramrw(d, 0x7000, banksize);
}
The first line changes the bit at 0x8000 to enable the PRG RAM. Without this, reading and writing to the PRG RAM has no effect. This is the main difference between MMC6 and MMC3.
The second line should enable reading and writing to the PRG RAM. However, the closet I've got to reading a save file is 0x200 lines of zeroes then 0x200 lines of the same repeating junk line. Reading or writing like this seems to delete the save. I tried setting a001 to 10, 20, 30, ... e0, f0 and couldn't get it to work on any so I know I'm missing something else here (possibly need to update NES mapper 4; I have no idea how to do that).
The third line writes the save file (it's size 0x400 and starts at 0x7000). I'm not sure, but I think this is supposed to mirror three more times to 0x7FFF after it's written.
I'm not sure how to make it work. Here's some other things I tried:
1. dump save with mmc3.ag -> get a .sav full of Fs. This is correct.
2. tweak 0xa001 -> still all Fs. This is also correct, since the PRG RAM is still locked in MMC6.
3. set 0x8000 to 0x20 -> now, tweaking 0xa001 has an effect, but I still can't get it to read/write the save properly.
Setting 0xa001 to the following values has the following effects:
0x00: .sav is still all Fs.
0x10: .sav is all Fs.
0x20: .sav is all 0s. Interesting.
0x40: .sav is all Fs.
0x80: .sav is 200 lines of 0s, followed by 200 of the same junk line, repeated four times. The save file on the cartridge is erased when reading or writing.
0xf0: same as setting 0xa001 to 0x80
I think this should be simple. What am I missing? Can someone figure out how to read and write a save to a Startropics or Zoda's Revenge cart and share how to do it?