Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
hello ☀
working on a new and exciting project for a cool festival and i want to create a save file.
i'm not finding much materials about this subject
anyone knows how to do so, or can point my to a relevant link?
thanks ☘
Offline
Are you using gbdk or asm?
Offline
I believe you've already been answered on IRC, but written reference is always good, so here goes.
For ROMs to correctly produce save files on emulators, you need to do two things.
First, make sure the MBC type in the header is set to a type that includes RAM+BATTERY. RAM means the "cartridge" contains extra RAM, BATTERY means the RAM is battery-backed, ie that it can retain data between resets. [1][2]
Second, set the SRAM size to something non-zero. [3][4]
Footnotes:
[1] ROM+RAM+BATTERY is *in theory* a valid combination, however since no commercial ROM ever made use of it, compatibility is hit-or-miss.
[2] MBC2 has a built-in RAM of 512 half-bytes (256 bytes total), which works somewhat differently. Check the wiki for more info.
[3] 2kB is possible but not recommended, according to beware. Probably due to only partially filling the SRAM space.
[4] The situation for SRAM sizes over 32kB are more complex. 64kB is only used by Pokémon Crystal JP (with a special variant of MBC3 known as MBC30). 128kB is only possible with MBC5. Compatibility with both of those is hit-or-miss too, for example Gambatte versions older than this commit didn't do 64k or 128k, nor do the original EverDrive GB models; the X series does support 64k SRAM but not 128k, due to what may be a software bug.
Offline
Hi.
I saw the thread and I am wondering... how can you use the external RAM from the cartridge to store maps?
My goal is to store a level map in that ram, (just 8 kb is enough) so I can edit the tiles (to collect coins like in mario games).
I used the gbdk functions to test (ENABLE_RAM_MBC5; SWITCH_RAM_MBC5(0)) and also inline assembly, but it just worked for small arrays, the moment I try to store something big, it fails.
Also in BGB I can see A000, and it looks just as rom bank 1. So I'm doing something very wrong .
Do all flash carts have external ram?. if not, maybe using it is not a good idea...
I own an USB smart cart, and it looks like it has 128 Kb of ram. what is the bank it is using for for saves?.
EDIT: got it!.
Just assigned an address to the map array (0xA000). Once you enable the ram, and switch to relevant bank, you can always access that array.
Also The only settings that work in the linker are :
-Wl-yt27 (ROM+MBC5+RAM+BATT)
-Wl-ya4 (RAM = 128kb). You only need 8 Kb, but setting it to 128 was the only option that worked for me.
I tested it on the USB Smart Cart, and it worked ok.
Last edited by Mills (2019-04-23 07:22:17)
Offline
thanks ISSOtm!
tidy and beautiful as always ✴
Offline