Reading gba SRAM

Post Reply
Dren
Posts: 11
Joined: Wed Mar 16, 2011 10:12 pm

Reading gba SRAM

Post by Dren » Wed Mar 16, 2011 10:24 pm

I want to load a gba save file into a gba cartridge's sram - I don't have a flash cartridge for gba. I can't seem to access the sram correctly. With this code I get no output, which means I'm getting a bunch of zeros:

Code: Select all

	vramSetBankE(VRAM_E_MAIN_BG);
	vramSetBankF(VRAM_F_MAIN_SPRITE);

	consoleDemoInit();
	consoleDebugInit(DebugDevice_CONSOLE);

	sysSetCardOwner(true);
	for (int i=0; i<0x10000; i++)
	{
		if (SRAM[i] != 0)
			printf("%d ", i);
	}
Writing to it had no effect either, didn't even corrupt the save file, but I'm probably missing something obvious. I also don't know what I'm doing with sysSetCardOwner(), but I read that I need it. The only examples I could find were very outdated and they don't compile anymore.

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Reading gba SRAM

Post by zeromus » Mon Mar 21, 2011 4:01 am

use sysSetCartOwner. Car_t_ is GBA slot-2; Car_d_ is NDS slot-1. of course, the comments say that.

Dren
Posts: 11
Joined: Wed Mar 16, 2011 10:12 pm

Re: Reading gba SRAM

Post by Dren » Mon Mar 21, 2011 9:10 pm

Oops. Well now it works, almost.
I've uploaded a save file into Final Fantasy V, but I can't yet write data to Pokemon Sapphire. As far as I can tell it uses a 1Mb flash chip. According to the nocash technical info on the gba I'm supposed to use commands instead of writing directly but none have any effect - I'm probably using them wrong. It says:
Erase Entire Chip (all device types)

[E005555h]=AAh, [E002AAAh]=55h, [E005555h]=80h (erase command)
[E005555h]=AAh, [E002AAAh]=55h, [E005555h]=10h (erase entire chip)
wait until [E000000h]=FFh (or timeout)

Erases all memory in chip, erased memory is FFh-filled.
I tried writing the values like this:

Code: Select all

	SRAM[0x005555] = 0xAA;
	SRAM[0x002AAA] = 0x55;
	SRAM[0x005555] = 0x80;

	SRAM[0x005555] = 0xAA;
	SRAM[0x002AAA] = 0x55;
	SRAM[0x005555] = 0x10;
Is that the way to go about it? It had no effect.

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Reading gba SRAM

Post by zeromus » Tue Mar 22, 2011 6:39 am

that's probably beyond the scope of this forum. you can't really expect to find experts on accessing flash memory on a gba cart.

Dren
Posts: 11
Joined: Wed Mar 16, 2011 10:12 pm

Re: Reading gba SRAM

Post by Dren » Tue Mar 22, 2011 8:35 pm

I was afraid of that. Well thanks for the help.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests