-
Notifications
You must be signed in to change notification settings - Fork 1
MBCs
The Gameboy has a limited spaced with his 16-bit address bus.
To overcome this limitation many Games are using Memory Bank Controllers (MBC).
A MBC allow to expand the available address space by bank switching.
Cartridge with no MBC
or ROM only
(i.e.: with a rom size <32Kib
or <0x8000
)
are directly load into the Rom Address Space
.
Optionally up to 8KiB of RAM could be connected at
MCB1
cartridge are limited to 2MByte ROM and/or 32 KiB RAM
Name | Upper Bound | Lower Bound | Description |
---|---|---|---|
ROM Bank 0 | 0x0000 |
0x3FFF |
contain the first 16 KiB of Cartridge ROM (READONLY) |
ROM Bank n | 0x4000 |
0x7FFF |
Contain the 16 KiB of the Cartridge ROM Bank n (READONLY) |
RAM Bank n | 0xA000 |
0xBFFF |
Contain the Cartridge RAM Bank n |
Before reading or writting to the external RAM, the game must enable it before (to prevent loose of data on expected shutdown).
To enable the RAM the game MUST write 0x0A
in the range of 0x0000-0x1FFF
, to disable he MUST write 0x00
in the same range
To change the selected ROM Bank the game must write a byte in the range of 0x2000-0x3FFF
.
The bank number can be in the range 0x01-0x1F
so only the first 5-bits are taken in account.
The game write
0xE1
into0x2000
,0xE1 = 0b1110_0001
.
We kept the first 5 bits :n = (0xE1 & 0x1F) = 0x1
, so the bank 1 is selected
when the game need to use a bank number > 0x1f
see banking mode
When writing in the range of 0x4000-0x5FFF
set a 2-bit register that will be used for the banking mode
MBC1
have 2 banking modes: ROM
and RAM
.
These modes determine how the secondary 2-bit register is used.
You can change the mode by writing in the range of 0x6000-0x7FFF
the following value:
-
0x00
to enableROM
mode -
0x01
to enableRAM
mode
When ROM
mode is enable, the ROM bank n is the concatenation of the special 2-bit register and the 5-bit rom number register
When RAM
mode is enable, the RAM bank number is the value of the special 2-bit register