gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > SRAM and WRAM

#21203 - johnny_north - Tue May 25, 2004 8:51 pm

According to the gbatek docs:

Code:
Reading and Writing
Reading from SRAM should be performed by code exectued in WRAM only (but not by code executed in ROM). There is no such restriction for writing.


Why?

#21206 - ampz - Tue May 25, 2004 9:08 pm

As far as I know, no one knows. I can see no technical reason why you cannot access savegame SRAM from within ROM code.

I know commercial games do access flash from within ROM code. (flash and SRAM are accessed exactly the same way, so...)

#21207 - johnny_north - Tue May 25, 2004 9:31 pm

I ran across this accidently after looking at the waitstate tepples pointed out in the "emulation" post. I had one of those "oh crap" / "but wait just a second..." moments.

the docs go on to say:

Quote:
Preventing Data Loss
The GBA SRAM carts do not include a write-protect function (unlike older 8bit gameboy carts). This seems to be a problem and may cause data loss when a cartridge is removed or inserted while the GBA is still turned on. As far as I understand, this is not so much a hardware problem, but rather a software problem, ie. theoretically you could remove/insert the cartridge as many times as you want, but you should take care that your program does not crash (and write blindly into memory).


This seems to mix rationalization for using the cart interrupt and an explanation for corrupted SRAM, but I'm not making the connection.

I'm wondering if I'll be protecting SRAM by employing a cart interrupt. Is it a commercial cart requirement to include a cart interrupt and are you able to recover gracefully from a cart yank?

#21246 - ampz - Wed May 26, 2004 11:41 am

johnny_north wrote:
I'm wondering if I'll be protecting SRAM by employing a cart interrupt.

Under some very unlikely circumstances, maybe...
johnny_north wrote:
Is it a commercial cart requirement to include a cart interrupt and are you able to recover gracefully from a cart yank?

It is no commercial requirement since most commercial games I know of crashes just fine if you remove the cart :)
If you use the cart interrupt properly, yes, is should be very possible to recover fine from a cart yank.

#21316 - johnny_north - Thu May 27, 2004 5:33 pm

Quote:
It is no commercial requirement since most commercial games I know of crashes just fine if you remove the cart :)


Good point ;P

#21350 - tepples - Fri May 28, 2004 3:22 am

The distinction here is between a crash and a dataloss. It appears that Nintendo wants games to preserve savegame data even if the cart is yanked during gameplay.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.