You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/MBC3.md
+18-12Lines changed: 18 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,15 @@
1
1
# MBC3
2
2
3
-
(max 4 MiB ROM, 64 KiB RAM, and Timer)
3
+
(max 4 MiB ROM, 64 KiB RAM, and timer)
4
4
5
-
Beside for the ability to access up to 2MB ROM (128 banks), and 32KB RAM
6
-
(4 banks), the MBC3 also includes a built-in Real Time Clock (RTC). The
7
-
RTC requires an external 32.768 kHz Quartz Oscillator, and an external
8
-
battery (if it should continue to tick when the Game Boy is turned off).
5
+
Beside for the ability to access up to 4 MiB ROM (256 banks) and 64 KiB RAM
6
+
(8 banks), the MBC3 also includes a built-in Real Time Clock (RTC), sometimes referred to as the timer. The
7
+
RTC requires an external 32.768 kHz quartz crystal oscillator, and an external
8
+
battery (if it should continue to tick when the Game Boy is turned off). All official MBC3 releases utilize cartridge RAM and a battery, but a few DMG games don't use the timer and therefore lack the crystal.
9
+
10
+
There are (at least) four different versions of this MBC that can be distinguished by the print on the chip itself: MBC3, MBC3A, MBC3B and MBC30. Only the latter supports the full 4 MiB of ROM and 64 KiB of RAM whereas the other three can only access half of that. The MBC30 is only found in the Japanese _Pocket Monsters: Crystal Version_, which is also the only release with the full 64 KiB of RAM (8 banks). No game uses the full 4 MiB.
11
+
12
+
The different versions of the chip are not distinguished in the cartridge header, not even the MBC30.
9
13
10
14
## Memory
11
15
@@ -24,8 +28,6 @@ Depending on the current Bank Number/RTC Register selection (see below),
24
28
this memory space is used to access an 8 KiB external RAM Bank, or a
25
29
single RTC Register.
26
30
27
-
The Japanese version of Pokémon Crystal Version is the only official game to have an MBC3 with 8 RAM banks (for a total of 64 KiB). It is sometimes referred to as MBC30, reflecting the print on the chip, although the cartridge type in the header is not different.
28
-
29
31
## Registers
30
32
31
33
### A000-BFFF - RTC Register 08-0C (Read/Write)
@@ -60,21 +62,23 @@ Controls what is mapped into memory at A000-BFFF.
60
62
61
63
### 6000-7FFF - Latch Clock Data (Write Only)
62
64
63
-
Latching makes a static copy of the current timestamp available in the clock counter registers while the clock keeps running in the background. This makes sure that your reads from the counter registers will be consistent, since any counter overflowing while you read the different parts can have you read an incorrect value (e.g. reading the hour at 11:59 and the minute at 12:00 will give 12:59.)
65
+
Latching makes a static copy of the current timestamp available in the clock counter registers while the clock keeps running in the background. This makes sure that your reads from the counter registers will be consistent, since any counter overflowing while you read the different parts can have you read an incorrect value (e.g. reading the minute at 11:59 and the hour at 12:00 will give 12:59.)
64
66
65
67
The exact behavior of this register varies depending on hardware:
66
68
67
69
MBC3B provides a running clock on power-on and after writing any even value to this register. It is still recommended to latch the clock by writing any odd value. MBC3B can only latch while it provides a running clock, so you must write an even value before you can write an odd value again.
68
70
69
71
MBC3A's clock counters are indeterminate by default. Writing any value to this register latches the clock. MBC3A cannot provide a running clock. Naturally, it can latch repeatedly.
70
72
71
-
**tl;dr**: The behaviour of this register depends on the MBC's version, so for maximum compatibility, write $00 then $01 to this register to safely trigger latching.
73
+
**tl;dr:** Write $00 then $01 to this register to safely trigger latching on all versions of the chip.
72
74
73
75
:::tip
74
76
75
77
**Help wanted**
76
78
77
-
If you have a flashcart and any MBC3 or MBC30 cart (see the print on the chip), please reach out to us on gbdev Discord so you can be given the test ROMs.
79
+
The exact latching behavior of MBC3 and MBC30 has not been tested and the sample size could be improved even for the MBC3A and MBC3B.
80
+
81
+
If you would like to help, have a flashcart and any official RTC cartridge, please reach out to us on gbdev Discord so you can be given the test ROMs.
78
82
79
83
:::
80
84
@@ -87,11 +91,13 @@ If you have a flashcart and any MBC3 or MBC30 cart (see the print on the chip),
87
91
| $0B | RTC DL | Lower 8 bits of Day Counter | ($00-$FF) |
88
92
| $0C | RTC DH | Upper 1 bit of Day Counter, Carry Bit, Halt Flag. <br>Bit 0: Most significant bit (Bit 8) of Day Counter<br>Bit 6: Halt (0=Active, 1=Stop Timer)<br>Bit 7: Day Counter Carry Bit (1=Counter Overflow) ||
89
93
90
-
The Halt Flag is supposed to be set before **writing** to the RTC Registers. This makes sure no register overflows while you write the different parts.
94
+
The Halt Flag is supposed to be set before **writing** to the RTC Registers. This makes sure no register overflows while you write the different parts. The MBC3 chip however does not require you to halt or latch the clock before you write to the counter registers. Note that latching also prevents you from seeing your writes reflected immediately.
91
95
92
96
Bits that are not required to store the above information will be ignored and always read 0.
93
97
94
-
You can write values larger than the ones mentioned above (up to 63 for seconds and minutes, and up to 31 for hours). Invalid values will then continue incrementing like a valid value and will only overflow once the available bits no longer suffice. This overflow however will not cause a carry, neither does writing 60 or 24 directly. For example, if you write 30:59:63 (and clear the Halt Flag), it will be 30:59:00 one second later, and 31:00:00 one minute after that. This behavior has been confirmed on MBC3B.
98
+
You can write values larger than the ones mentioned above (up to 63 for seconds and minutes, and up to 31 for hours). Invalid values will then continue incrementing like a valid value and will only overflow once the available bits no longer suffice. This overflow however will not cause a carry, neither does writing 60 or 24 directly. For example, if you write 30:59:63 (and clear the Halt Flag), it will be 30:59:00 one second later, and 31:00:00 one minute after that.
99
+
100
+
Writing to the seconds register also resets the inaccessible sub-second counter.
0 commit comments