Skip to content

Document address wrapping behaviour of MBC2 RAM, and note questionable source of $52-$54 ROM size tags #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions content/MBC2.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ The MBC2 doesn't support external RAM, instead it includes 512x4 bits
of built-in RAM (in the MBC2 chip itself). It still requires an external
battery to save data during power-off though. As the data consists of
4bit values, only the lower 4 bits of the "bytes" in this memory area
are used.
are used. The upper 4 bits of each byte are undefined and should not be
relied upon.

### A200-BFFF - 15 "echoes" of A000-A1FF

Only the bottom 9 bits of the address are used to index into the internal
RAM, so RAM access repeats. As with the A000-A1FF region, only the lower
4 bits of the "bytes" are used, and the upper 4 bits of each byte are
undefined and should not be relied upon.

## Control Registers

### 0000-3FFF - RAM Enable and ROM Bank Number (Write Only)

This address range is responsible for both enabling/disabling the RAM
and for controlling the ROM bank number. Bit 8 of the address determines
whether to control the RAM-enable flag or the ROM bank number.
and for controlling the ROM bank number. Bit 8 of the address (the least
significant bit of the upper address byte) determines whether to control
the RAM enable flag or the ROM bank number.

#### When Bit 8 is Clear

Expand Down
18 changes: 14 additions & 4 deletions content/The_Cartridge_Header.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,34 @@ Specifies the ROM Size of the cartridge. Typically calculated as "N such that 32
| $53 | 1.2 MByte | 80 *
| $54 | 1.5 MByte | 96 *

\* Only listed in unofficial docs
\* Only listed in unofficial docs. No cartridges or ROM files using these sizes are known.
As the other ROM sizes are all powers of 2, these are likely inaccurate. The source for these
values is unknown.

### 0149 - RAM Size

Specifies the size of the external RAM in the cartridge (if any).

| Code | Size | Comment
|------|--------|---------
| $00 | 0 | No RAM
| $01 | - | Unused (but unofficial docs list it as 2 KB)
| $00 | 0 | No RAM *
| $01 | - | Unused **
| $02 | 8 KB | 1 bank
| $03 | 32 KB | 4 banks of 8 KB each
| $04 | 128 KB | 16 banks of 8 KB each
| $05 | 64 KB | 8 banks of 8 KB each

When using a MBC2 chip, $00 must be specified in this entry, even though
\* When using a MBC2 chip, $00 must be specified as the RAM Size, even though
the MBC2 includes a built-in RAM of 512 x 4 bits.

\** Listed in various unofficial docs as 2KB. However, a 2KB RAM chip was never used in a cartridge.
The source for this value is unknown.

Various "PD" ROMs ("Public Domain" homebrew ROMs generally tagged "(PD)"
in the filename) are known to use the $01 RAM Size tag, but this is believed
to have been a mistake with early homebrew tools and the PD ROMs often don't use
cartridge RAM at all.

### 014A - Destination Code

Specifies if this version of the game is supposed to be sold in Japan,
Expand Down