Skip to content
Open
Changes from 1 commit
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
33 changes: 25 additions & 8 deletions src/MBC3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MBC3

(max 2MByte ROM and/or 32KByte RAM and Timer)
(max 2MByte ROM and/or 64KByte RAM and Timer)

Beside for the ability to access up to 2MB ROM (128 banks), and 32KB RAM
(4 banks), the MBC3 also includes a built-in Real Time Clock (RTC). The
Expand All @@ -24,6 +24,8 @@ Depending on the current Bank Number/RTC Register selection (see below),
this memory space is used to access an 8 KiB external RAM Bank, or a
single RTC Register.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved under the initial description paragraph.


## Registers

### A000-BFFF - RTC Register 08-0C (Read/Write)
Expand Down Expand Up @@ -58,11 +60,23 @@ Controls what is mapped into memory at A000-BFFF.

### 6000-7FFF - Latch Clock Data (Write Only)

When writing $00, and then $01 to this register, the current time
becomes latched into the RTC registers. The latched data will not change
until it becomes latched again, by repeating the write $00-\>$01
procedure. This provides a way to read the RTC registers while the
clock keeps ticking.
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.)

The exact behavior of this register varies depending on hardware:

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the two versions of this chip are mentioned before this point? I'd suggest adding a paragraph explaining this in the intro section.

Copy link
Contributor

@CasualPokePlayer CasualPokePlayer Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are at least 4 versions of the chip to be clear: MBC3, MBC3A, MBC3B, and MBC30. Only MBC3A and MBC3B have been tested for latching quirks (so far).


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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear what "indeterminate by default" means here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly do you not understand?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact thing that I don't understand is the intended meaning of the phrase "indeterminate by default".

The text could be improved by plainly describing the behaviour that this phrase presumably refers to.

e.g. questions that could be answered:

  • What is the default state? RTC selected / Clock battery inserted / System power cycle?
  • What happens when you read from the registers?
  • What about writes?

Copy link
Author

@nummacway nummacway Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"What is the default state? RTC selected / Clock battery inserted / System power cycle?" - Power-cycle, but I didn't want to repeat the same word again.
"What happens when you read from the registers?" The clock counter registers are indeterminate.
"What about writes?" As clearly explained a few paragraphs further down, latching is optional for writes. Since this register is only used for latching on MBC3A, this means that you can write.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.
Specifically for this instance, I'd prefer to have the repetition. Using a different term to refer to the same thing suggests a difference in meaning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we use expressions such as "These registers are left entirely uninitialized" instead of 'indeterminate'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth explaining the behaviour more specifically rather than relying on the phrase "latches the clock" which seems to use "latch" in an unusual way.
It sounds like a write to the register triggers an automatic sequence in which the latch is disabled and then enabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your first remark: That behaviour was just described two paragraphs above.
For the second one: What exactly are you referring to? You selected two full paragraphs.


Most games write $00 and then $01 to this register. This procedure will latch the clock on both chips, even if it is already latched.

:::tip

**Help wanted**

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is help wanted for?

Copy link
Contributor

@CasualPokePlayer CasualPokePlayer Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all chip variants have been tested extensively for latching quirks. MBC3 (without A/B/0) and MBC30 have not been tested. It'd also be good to verify that there is indeed MBC3A vs MBC3B behavior (since the testing for that so far has been a total of 2 carts, one MBC3A and one MBC3B, not a very good sample size).


:::

### Clock Counter Registers
| Register | Name | Description | Range |
Expand All @@ -73,8 +87,11 @@ clock keeps ticking.
| $0B | RTC DL | Lower 8 bits of Day Counter | ($00-$FF) |
| $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) | |

The Halt Flag is supposed to be set before **writing** to the RTC
Registers.
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.

Bits that are not required to store the above information will be ignored and always read 0.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is behavior tested in rtc3test (and my own MBC3A flashcart passes all tests here perfectly, as expected).

If we're mentioning more quirky behavior, we could mention the "subsecond counter", which is cleared upon writing to the seconds counter (although, it is also halted when the halt flag is set, so for practical usage this detail doesn't matter so much since you'd end up with a reset subsecond counter after writing to all the registers and unhalting)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this behavior is thought to be universal and the last sentence should be removed?


### The Day Counter

Expand Down