Gameboy MBC-2 RAM Question

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Gameboy MBC-2 RAM Question

Post by MottZilla »

Documents say the MBC-2 has built in 512 x 4bits of RAM. I'm not really sure what this means other than there is a total of 256 bytes... So is it 256 bytes at $A000, or is it 512 nibbles (4bits) at $A000 with the upper 4 bits ignored? Anyone know?
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

I guess it should by nybbles, with the upper 4 bits ignoerd. Altough I don't know much about the gameboy :cry:

I guess the MBC2 is to the Gameboy what the MMC6 is to the NES (altough it is much more widely used).
Useless, lumbering half-wits don't scare us.
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

But on NES, it was full bytes, which is part of the confusion. Currently I just emulate them with 2kbytes of RAM and the two games I know are MBC2 (Kid Icarus and Final Fantasy Adventure) both seem to be ok. FFA doesn't get in game due to incomplete emulation, but Kid Icarus doesn't seem to care and seems to run fine. Though I haven't actually tested its saving ability.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Well, if you emulate full bytes when it's nybbles, I guess there is no reason it won't work. But if you emulate nybbles when it's bytes, definitely it won't work. So I'd say emulate nybbles and see what happens.

Oh, and the .sav file my emulators give me for Final Fantasy adventure is 256 bytes long, but the bytes seems to takes all kind of values. So I guess they just re-arranged the nybbles in some way so that it makes full bytes and it doesn't waste space in the .save files. It seems to work on most of my GB emulators with the same file so there is some kind of standard.
Useless, lumbering half-wits don't scare us.
AWJ
Posts: 433
Joined: Mon Nov 10, 2008 3:09 pm

Post by AWJ »

It's 512 nybbles at $A000-A1FF--only the low 4 bits of each byte are valid. I think the high bits read as open bus. Here's the "load saved game" routine from Makaitoushi SaGa:

Code: Select all

ROM0:04DC CD 19 05         call 0519	; enable MBC2 battery RAM, hl = a000, de = cc00, b = 0
ROM0:04DF 2A               ldi a,(hl)
ROM0:04E0 E6 0F            and a,0f
ROM0:04E2 4F               ld c,a
ROM0:04E3 2A               ldi a,(hl)
ROM0:04E4 E6 0F            and a,0f
ROM0:04E6 CB 37            swap a
ROM0:04E8 B1               or c
ROM0:04E9 12               ld (de),a
ROM0:04EA 13               inc de
ROM0:04EB 05               dec b
ROM0:04EC 20 F1            jr nz,04df
ROM0:04EE AF               xor a
ROM0:04EF EA 00 00         ld (0000),a	; disable MBC2 battery RAM
ROM0:04F2 D9               reti
Why is the battery RAM laid out in this silly way? Because the RAM is inside the MBC2 chip itself, and the chip only has 4 data lines! MBC2 cartridges are limited to 16 ROM banks (2 megabits/256 kilobytes) for the same reason.
Post Reply