Skip to content
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

GBA: More details about How GBC Mode Works #396

Open
Dwedit opened this issue Feb 8, 2025 · 0 comments
Open

GBA: More details about How GBC Mode Works #396

Dwedit opened this issue Feb 8, 2025 · 0 comments

Comments

@Dwedit
Copy link

Dwedit commented Feb 8, 2025

The page here describes the GBA cartridge switch, and what happens when it is pressed: https://gbdev.gg8.se/wiki/articles/Gameboy_and_Gameboy_Color_special_modes_and_features#Entering_GBC_mode_manually_on_GBA_.28GBA.29 (Information contributed by Nitro2k01)

Read that section of the article before reading this post. It's really amazing.

GBA has a cartridge switch.

When the cartridge switch is pressed: GBA mode is unable to access Joypad, Cartridge Bus, and EWRAM.
When the cartridge switch is not pressed: GBC mode is unable to access Joypad, Cartridge Bus, and main Work RAM.

Things that are unavailable read as zeroes.

It turns out that EWRAM doubles as GBC's Work RAM, and IWRAM doubles as GBC's Video RAM. But as the page describes, it has an unusual memory layout. For the EWRAM, only the lowest byte of each halfword is used. For the IWRAM, the four bytes that make up each word correspond to different areas of VRAM.


This means that you can still partially use GBA mode even when the cartridge switch is pressed in. Joypad, cartridge bus, and EWRAM aren't available, but the BIOS, VRAM and IWRAM still are. The BIOS itself runs in GBA mode before it detects that the switch is pressed, and switches to GBC mode.


Then the coolest part of the article: the undocumented GBA IO register that causes GBC mode to skip running the GBC bootrom, and execute code from GBC VRAM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant