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 > Setting the SRAM size

#21231 - ravenq - Wed May 26, 2004 8:08 am

Just curious, is there any way to set the size of the sram for a game? When I write my game to a flash cart, it has 0k as the sram size, meaning whenever I try to read it, I get all the other crap that is stored there from the last game that used it.
_________________
The Game is Nothing.
The Playing of it Everything

#21267 - tepples - Wed May 26, 2004 4:04 pm

Some flash writing programs look for the string that identifies a common Nintendo savegame library. But is there a list of such strings (such as "SRAM_V112") on a site that the mods don't consider "piracy related"?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#21311 - torne - Thu May 27, 2004 1:07 pm

Probably not, but you don't really need a list. I've never tried it, but just putting SRAM_V112 in your code should be sufficient to make it detect that you are using SRAM saves. It is unlikely to detect the size correctly, though; I don't know how they do this (there is nothing in the N backup library that specifies the maximum size used, and the parameters to the sram read function are sufficiently flexible that it would be nontrivial to examine them). All SRAM library versions are equivalent as far as a flash link program is concerned, so it shouldn't matter which string you use.

#21315 - dagamer34 - Thu May 27, 2004 5:15 pm

SRAM is always 256 kb, not matter what. And most flash carts don't support 4kb EEPROM, they default it to 64kb EEPROM anyway. The only thing I would say the flash linker may not be sure of is Flash ROM.
_________________
Little kids and Playstation 2's don't mix. :(

#21341 - ravenq - Fri May 28, 2004 2:02 am

The flash cart will still work, as I said, but if for example I load my game, and then another game after it (that _does_ have the size set) then that second game will overwrite my game's data because my game didn't have space but aside for it.
_________________
The Game is Nothing.
The Playing of it Everything

#21385 - torne - Fri May 28, 2004 3:38 pm

Ah, I didn't notice the size was always detected as 256k; I thought they were doing something more clever to deduce the actual used size. I use LW so I don't see the savegame sizes. Detecting the flash size is easy; all the flashlibs up to v1.26 are 512Kbit, and the versions after that have the size (512k or 1M) as part of the version string. EEPROM would be harder to tell as the size is not part of the version string and the same library can be used to access both sizes (as the chip type is detected at runtime) - deducing whether a game uses a 4kbit EEPROM would be pretty hard.