The register bits are on register bit layouts; this page gives the timing and the conflicts. The text is our own wording of the raw Pan Docs Markdown (CC0, read 2026-11-19, kept in the site’s sample sources with SHA-256 in the sample README); each section names its file. Pan Docs is the only source and nothing was checked on hardware.
OAM DMA
Source: OAM_DMA_Transfer.md.
Writing to DMA ($FF46) copies 160 bytes from $XX00–$XX9F (XX = $00 to $DF, the written value) to OAM ($FE00–$FE9F). It takes 160 M-cycles: 640 dots (1.4 lines) at normal speed, 320 dots (0.7 line) in Color double speed.
Bus conflicts
- DMG: during the transfer the CPU can reach only HRAM (
$FF80–$FFFE). A program must therefore copy a short routine into HRAM, start the transfer from inside it and wait there until it ends. - Color: the cartridge and work RAM are on separate buses, so the CPU can use ROM or cartridge RAM during a transfer from work RAM, and work RAM during a transfer from ROM or cartridge RAM. Because a
callwrites its return address to the stack, and the stack is usually in work RAM, Pan Docs still advises waiting in HRAM. - Interrupts push a return address and fetch the handler from ROM, so they must not happen during the transfer, especially timer, serial and joypad interrupts, which are not tied to the screen. Start the DMA in the VBlank handler or use
di.
The PPU while DMA runs
The PPU cannot read OAM properly either. Most programs therefore start DMA in mode 1, in or just after the VBlank handler. It can also be done during the drawing of the screen (modes 2 and 3), which allows more than 40 objects on screen (for example 40 in the top half and 40 in the bottom half) at the cost of a couple of lines without objects. Starting it in mode 3 can cause glitches. Pan Docs gives the detail: during the OAM scan (mode 2) most PPU revisions read each object as off-screen; during mode 3 the PPU reads whichever 16-bit word the DMA is writing when the object is fetched, giving wrong tile numbers and attributes for objects already found to be in range. Pan Docs has two to-do comments on this (a test ROM to find, and an experiment named “Red from OAM”); the statements are as given and not tested here.
Best practice
Pan Docs gives a 10-byte routine to copy into HRAM: load the high byte of the source address into A, write it to $FF46 (the transfer starts right after that instruction), then load 40 into A and loop dec a / jr nz (4 M-cycles per turn, so 160 M-cycles) and ret. A shorter form keeps only ldh [c],a and a counted loop in HRAM (5 bytes less HRAM) with the set-up in ROM, ending in a conditional ret z, which is 1 M-cycle slower so it does not read the stack on the last M-cycle of the DMA. For a transfer in the middle of a frame, wait for mode 0 first, so the transfer overlaps mode 2 of the next two lines and makes objects invisible only on those lines.
VRAM DMA on the Color (HDMA and GDMA)
Source: CGB_Registers.md. The registers are on registers/#ff51 to #ff55. Pan Docs notes that the HDMA names are not very descriptive, and mentions alternative names such as VDMA_LEN for HDMA5.
- Source (HDMA1 high, HDMA2 low): normally ROM, cartridge RAM or work RAM, that is
$0000–$7FF0or$A000–$DFF0. Pan Docs says it has not tested echo RAM, OAM,$FExx, I/O or HRAM. A source in VRAM copies garbage. The low four bits are ignored (treated as 0). - Destination (HDMA3 high, HDMA4 low): inside
$8000–$9FF0. Only bits 12 to 4 count; the top bits are ignored and the low four are treated as 0. - Length and start (HDMA5): writing starts the transfer. The low 7 bits give the length divided by
$10, minus 1, so$10to$800bytes are$00to$7F. Bit 7 picks the mode.
Bit 7 = 0: general-purpose DMA
All the data moves at once and the program is halted until it ends. It copies blindly, even while the screen is reading VRAM, so use it only with the display off, in VBlank, or for short blocks in HBlank. Afterwards HDMA5 reads $FF.
Bit 7 = 1: HBlank DMA
Moves $10 bytes in each HBlank, on lines 0 to 143. Nothing moves in VBlank (lines 144 to 153), and it goes on at line 0. The program stops during each block and runs in the gaps. The program must not change the destination VRAM bank (VBK) or the source ROM or RAM bank until the transfer ends. Pause the transfer to switch banks. When the CPU is halted with halt, the transfer is halted too and resumes when the CPU does (Pan Docs links a test ROM by alloncm showing this).
- Reading HDMA5 returns the remaining length (divided by
$10, minus 1).$FFmeans the transfer has finished. - Writing 0 to bit 7 stops an active HBlank transfer. HDMA5 then reads the number of blocks left, minus 1, in bits 6–0, with bit 7 set to 1. Stopping does not set HDMA1–4 to
$FF. - Bit 7 of HDMA5 shows whether a transfer is active: 1 = not active, 0 = active, under all circumstances, also after a general-purpose transfer and after stopping one.
- Warning: do not start an HBlank transfer (write HDMA5) during HBlank (STAT mode 0). If the destination address overflows, the transfer stops early; what the registers hold afterwards still has to be investigated (Pan Docs links an open issue).
Timing
A block of $10 bytes takes about 8 µs in both speeds: 8 M-cycles at normal speed and 16 “fast” M-cycles in double speed (Pan Docs links two timing pictures). Two bytes are always moved per microsecond, even if the program runs in normal speed. Older mappers (MBC1 to MBC3) and slow ROMs are not guaranteed to support general-purpose or HBlank DMA for that reason. That allows 2280 bytes in VBlank, which is up to 142.5 tiles. In double speed, the VRAM DMA keeps its normal timing, as does the picture unit, while the CPU, timer, serial port and OAM DMA run twice as fast.
VRAM banks
The Color has two 8 KiB VRAM banks, chosen by VBK bit 0 (reading gives the bank in bit 0 and 1 in all other bits). Bank 1 is laid out like bank 0: tiles in $8000–$97FF, and in $9800–$9FFF the attributes of the matching tile map entries.
Joypad
Source: Joypad_Input.md and Interrupt_Sources.md.
The eight buttons form a 2 × 4 matrix. Bits 5 and 4 of P1 ($FF00) pick a row, with 0 meaning selected, and bits 3 to 0 read the four lines of that row:
| Bit | Selecting bit 5 = 0 (buttons) | Selecting bit 4 = 0 (directions) |
|---|---|---|
| 3 | Start | Down |
| 2 | Select | Up |
| 1 | B | Left |
| 0 | A | Right |
- A pressed button reads as 0, not 1.
- With neither row selected (
$30written) the low nibble reads$F, all released. - Most programs read the port several times in a row. The early reads act as a short delay that lets the inputs settle, and only the last one is used.
- Joypad interrupt. It is requested when any of bits 0 to 3 goes from high to low, which is a press on a selected row. A button press usually gives several such changes from switch bounce. If both rows are selected and a line is already held low, pressing the button on the other row for that line changes nothing. If only one row is selected, the interrupt is useful for spotting presses on it. Pan Docs says the one really meaningful use is to end STOP standby.
- Super Game Boy. SGB games misuse bits 5 and 4 to send command packets to the SNES, and can read up to four joypads (see Super Game Boy).
Pan Docs describes no joypad glitch beyond the bounce above and the one in STOP (timer, HALT and power), so none is described here.
Serial transfer
Source: Serial_Data_Transfer_(Link_Cable).md and Interrupt_Sources.md.
Two consoles swap one byte at a time. The console that makes the clock is the master and the other is the slave (in SPI terms). If the slave has not loaded its next byte when the transfer starts, the last one goes out again. If it is ready but the last byte has not gone out yet, it must wait.
SB while a transfer runs
Before a transfer SB holds the next byte to send. During it, SB is a mix of the outgoing and the incoming byte: on each clock the leftmost bit is shifted out over the wire and the incoming bit is shifted in at bit 0. After 8 shifts SB holds the byte received. So after n shifts, bits 7 to n of the old byte have moved up and the low n bits hold the first n incoming bits, most significant first.
Starting and ending
- The master loads SB and sets SC to
$81(transfer requested, internal clock). It is told the transfer is done by SC bit 7 clearing and by a serial interrupt. When polling SC, read only bit 7. - The slave loads its byte and sets SC bit 7 (SC =
$80). It also gets a serial interrupt and SC bit 7 clears at the end. - The interrupt comes eight serial clock cycles after the start.
The clock
Without the Color’s mode, the internal clock is 8192 Hz only, about 1 KB per second before delays. In Color mode SC bit 1 and the speed give four rates:
| Clock | Transfer speed | When |
|---|---|---|
| 8192 Hz | 1 KB/s | bit 1 clear, normal speed |
| 16384 Hz | 2 KB/s | bit 1 clear, double speed |
| 262144 Hz | 32 KB/s | bit 1 set, normal speed |
| 524288 Hz | 64 KB/s | bit 1 set, double speed |
An external clock normally comes from another Game Boy but could come from another computer, for example a PC parallel port. It may have any speed, and the monochrome Game Boy is reported to accept up to 500 kHz. There is no lower limit: even with “one bit a month” the Game Boy waits for the next bit, and the clock pulses need not be regular.
Timeouts
With an external clock, a transfer ends only when the last bit arrives. If the other console gives no clock, is switched off or is not connected, it never ends. A program should therefore use a timeout counter and give up.
Disconnects
On a disconnected cable the input of a master reads 1, so it receives $FF bytes. If the cable is pulled during a transfer, the input rises to 1 over about 20 µs. If the slave was sending a 0 bit, the master reads 0 bits for up to that time, which at the highest Color speed can be more than one byte. Pan Docs marks the 20 µs as measured only on a CGB revision E.
Delays and synchronisation
The master should wait a little after each transfer so the other console can get ready: the console with the external clock must have set its start bit before the master starts. Alternatively the two consoles can swap internal and external clock for each byte. The transfer starts when the master sets its start flag, and the flag clears on both consoles at the end.
Infrared (Game Boy Color)
Source: IR.md and CGB_Registers.md. The register bits are on registers/#ff56. Pan Docs marks this chapter as written by the community and says parts are theory.
The Game Boy Color has an infrared port at the top: one diode to send and one to receive. Before it, infrared needed special cartridges (the HuC-1 variants). Few games used it. Turning the light on drains the battery. The port can talk to any device that sends infrared, such as TV remotes. The Advance has no port.
Kinds of exchange
There is no standard protocol: the game’s own code decides everything. Pan Docs groups the exchanges in four kinds:
- 1-player init: one console starts; both normally wait for a signal and one sends pulses when its player presses a button, like master and slave on the link cable. Most infrared games are of this kind (for example the Super Mario Bros. DX score exchange and the Mystery Gift of Pokémon Gold, Silver and Crystal).
- 2-player init: both consoles must start at about the same time (Pokémon Pinball score exchange, the Pokémon Trading Card Game “Card Pop”, Charabom trading in the Bomberman games).
- Active object init: the other side is a non-Color device that also sends and receives, built for the Color (Mystery Gift with the Pokémon Pikachu 2, the Pocket Sakura).
- Inactive object init: the other side only sends, and need not be made for the Color (Zok Zok Heroes, Chee Chai Alien, the Bomberman Max special stages, the Mission Impossible TV remote feature, and the Full Changer as the main exception). Communication goes one way.
The simplest scheme is like binary Morse code: a long on-off pulse for 0 and a short one for 1, or the reverse (Sakura Taisen GB seems to do this with the Pocket Sakura). Others send tables of pulse lengths, or custom patterns that cannot be understood without disassembling the code. The second-generation Pokémon games use the hardware timers; others count cycles. Four games share a similar start-up handshake: Pokémon TCG 1 and 2 and Bomberman Max Red and Blue. It needs both players to press at nearly the same time, but not exactly: each side sends a few pulses and then reads the sensor, so one side must be sending while the other is checking. Pan Docs’ theory is that this came from the HuC-1 and the Hudson “GB KISS” games, and says more research is needed to confirm it.
The RP register
RP ($FF56): bit 0 turns the light on (1) or off (0), read and write. Bit 1 is the received signal, read-only, 1 meaning no signal. Bits 2 to 5 are unused. Bits 6 and 7 are the read enable: 0 disables, 3 enables (read and write). Bits 6 and 7 must both be set ($C0) to read bit 1, otherwise bit 1 reads 1 as if no signal were seen (apart from the quirk below). Unused bits read as 1. Pan Docs also says to set RP back to $00 after use to save power, and that bit 0 should be clear if the console should not see its own signal.
Signal fade
The sensor adapts to the current level of infrared light. If a signal lasts beyond a certain time, the sensor treats it as the new normal level, and bit 1 goes back to 1. This is the “fade”. The fade time is longer the nearer the source is. At about 3.0 to 3.5 inches (7.62 to 8.89 cm) it is about 3 ms. The best distance for fade times near 3 ms is 2.5 to 4.0 inches (6.35 to 10.16 cm). Two Color consoles touching each other gave much shorter fade times, possibly because of interference. Pan Docs reads this as the sensor being good at sending but poor at receiving (the TV remote cheat; the plastic add-on of Chee Chai Alien).
Obscure behaviour
If bits 6 and 7 are cleared and then set again, bit 1 can go to 0 as if a signal were seen. It seems to happen in the presence of any light, and covering the sensor stops it. Pan Docs suggests the sensor resets to its lowest detection level. Writing $00 and then $C0 therefore gives a rough measure of the lighting:
Bit 1 after writing $00 | Bit 1 after writing $C0 | Lighting |
|---|---|---|
| 1 | 1 | dark |
| 0 | 1 | ambient |
| 0 (sometimes 1) | 0 | bright |
After writing $C0 the sensor needs a little time, so loop until bit 1 changes (a few hundred cycles in double speed is enough). If it stays 1 afterwards the light is ambient or dark. The delay does not seem to occur if bits 6 and 7 are never disabled, which is what most official software does (games write $C0 or $C1; a few write $00 first while setting up other registers, Pokémon Gold, Silver and Crystal among them). A bright source is soon adapted to, so the next $00 then $C0 reads dark or ambient. A suggested scheme, still theory: once bright is seen, write only $C0 so the sensor works normally, and go back to alternating writes when the signal stops.
The 4-player adapter (DMG-07)
Source: Four_Player_Adapter.md.
The DMG-07 connects four Game Boys through the serial port. It was made for the DMG; later models need link cable adapters. It does not power on until its player 1 cable is plugged into a Game Boy’s link port, because only that cable has the power pin connected. The adapter makes the serial clock for all transfers, so the Game Boys must use the external clock. An internal clock gives garbage.
Ping phase
At power-up the adapter sends 4-byte ping packets on every port. A Game Boy listens with SC bit 0 = 0 (external clock) and bit 7 = 1 (transfer requested). The power-up timing: clock period 15.95 µs (62.66 kHz), 128 µs per byte, 1.42 ms between bytes, 4.71 ms for the four bytes, 12.29 ms to the next packet, 17 ms in all (a little more than one video frame). The bytes are bunched at the start of the period.
| Byte | Adapter sends | The Game Boy’s reply to it |
|---|---|---|
| 1 | $FE (ping header) | ACK1 = $88 |
| 2 | STAT1 | ACK2 = $88 |
| 3 | STAT2 | RATE (packet timing) |
| 4 | STAT3 | SIZE (packet size) |
The reply to a byte is loaded into SB to be sent during the next transfer.
- RATE (a value of 0 does not change the speed and should not be used). In ping phase it changes only the delay between packets, from the next packet: delay = 12.2 ms + (RATE AND
$0F) × 1 ms, so 12.2 to 27.21 ms, with the 4.71 ms transfer unchanged. In transmission phase the rate is the last RATE sent before leaving ping phase: the delay between bytes is (RATE >> 4) × 0.106 ms + 0.887 ms. The packet plus delay time is the larger of (RATE AND$0F) × 1 ms + 17 ms, and (byte time + delay between bytes) × byte count + 0.36 to 2.15 ms, giving 17.0 to 41.6 ms. Pan Docs says the byte time is “~0.128 microseconds” (probably meaning 128 µs, as above; we do not decide) and that the formula for the 0.36 to 2.15 ms add-on is not yet understood. The byte count is 4, 8, 12 or 16. - SIZE: the number of usable data bytes each Game Boy sends per packet in transmission phase. The adapter broadcasts SIZE × 4 bytes (SIZE 3 gives 12). Values 1 to 4 work without issue.
- STAT bytes tell each Game Boy who is connected. Bit 7 player 4 connected, bit 6 player 3, bit 5 player 2, bit 4 player 1; bits 2–0 the player ID, 1 to 4, fixed by the port. The three STAT bytes are usually equal but can change in the middle of a ping. The upper bits are set as consoles reply correctly to pings; unanswered pings clear them. Examples:
FE 01 01 01player 1 alone, not yet connected;FE 11 11 11player 1 connected;FE 31 31 31players 1 and 2;FE 71 71 71players 1, 2 and 3;FE 62 62 62as seen by player 2 when players 2 and 3 are connected. Gaps do not matter (player 4 does not become player 2 if 2 and 3 are missing). Most games need only player 1, which acts as the master of the session in software.
Entering transmission phase
When all are ready, one console (usually player 1) sends AA AA AA AA, aligned so the first $AA is the reply to the ping header. While the adapter receives the fourth $AA it sends the first of four $CC. That CC CC CC CC is the sign to switch. Then the data packets start and the new RATE and SIZE take effect. In Pan Docs’ example with SIZE 1 and only player 1 connected, the exchange is: FE/88, 11/88, 11/10 (RATE $10), 11/01 (SIZE 1); then FE/AA, 11/AA, 11/AA, 11/AA; then CC/00 four times; then the first data packet AA 00 00 D6 (random data) against a reply that starts with $12.
Transmission protocol
While the adapter sends the data it collected in the previous packet, the Game Boys send their new data. So there is a one-packet delay. With SIZE 2 a packet is 8 bytes. The first 2 bytes are replies that go into the buffer, one slot per console (the others are ignored). The next 8 transfers return player 1’s, 2’s, 3’s and 4’s previous data in that order (a missing player’s slot is filled with zeros). On entering the phase the buffer holds garbage derived from what the master sent in ping phase. Pan Docs recommends ignoring the first packet received, but it is safe to start sending real data at once.
Restarting ping phase
Any console can send three or more $FF bytes in a row (aligned so the first is the reply to the first transfer of a packet) to return to ping phase. After the third $FF and the end of the current packet, the adapter sends a whole packet of $FF. That is the sign to switch back. To avoid false alarms, switch only after a whole packet of consecutive $FF (12 bytes if SIZE is 3). Then the adapter starts ping packets at once. In Pan Docs’ example with SIZE 1 and the other three sending $A5: 81/81, A5/00 three times; then 81/FF and A5/FF three times; then FF/00 four times; then the ping FE/00, 01/88, 01/88, F1/00.
External connectors
Source: External_Connectors.md.
Cartridge slot
| Pin | Name | Meaning |
|---|---|---|
| 1 | VDD | +5 V DC power |
| 2 | PHI | System clock, about 1.05 MHz (about 2.10 MHz in Color double speed) |
| 3 | /WR | Write |
| 4 | /RD | Read |
| 5 | /CS | Chip select |
| 6–21 | A0–A15 | Address lines |
| 22–29 | D0–D7 | Data lines |
| 30 | /RES | Reset |
| 31 | VIN | External sound input |
| 32 | GND | Ground |
Link port
Pins are numbered 2, 4, 6 in the upper row and 1, 3, 5 in the lower row, seen from outside the Game Boy’s socket with the flat side up. The wire colours are those of most standard cables; SIN and SOUT are crossed, so red and orange are swapped at one end of the cable.
| Pin | Name | Colour | Meaning |
|---|---|---|---|
| 1 | VCC | – | +5 V DC |
| 2 | SOUT | red | Data out |
| 3 | SIN | orange | Data in |
| 4 | P14 | – | Not used |
| 5 | SCK | green | Shift clock |
| 6 | GND | blue | Ground |
The original Game Boy has larger plugs than the Pocket and later models. Linking old and new is possible with a cable that has one large and one small plug.
Stereo sound connector
3.5 mm, female: tip = sound left, middle = sound right, base = ground.
External power supply
A barrel connector; the right one depends on the model.
| Model | Outer diameter | Inner diameter | Voltage | Load | Centre polarity |
|---|---|---|---|---|---|
| DMG | 3.5 mm | 1.35 mm | 6 V DC | 0.7 W | negative (−) |
| MGB | 2.35 mm | 0.7 mm | 3 V DC | 0.7 W | positive (+) |
| CGB | 2.35 mm | 0.7 mm | 3 V DC | 0.6 W | positive (+) |
The polarity is the sign of the inner (centre) contact; the outer one is always the opposite. The Color and the DMG print the voltage and polarity on the case near the connector. The Pocket lists the voltage but not the polarity. The Pocket and Color connector matches a Japanese standard (JEITA RC-5320A JSAP1, formerly EIAJ-01). The loads are from each model’s back label.
Sources
- Raw Pan Docs Markdown (CC0), read 2026-11-19, in
samples/gb/sources/pandocswith SHA-256 in the sample README:OAM_DMA_Transfer.md,CGB_Registers.md,Joypad_Input.md,Serial_Data_Transfer_(Link_Cable).md,Interrupt_Sources.md,IR.md,Four_Player_Adapter.md,External_Connectors.md. - OAM DMA Transfer, CGB Registers, Joypad Input, Serial Data Transfer – Pan Docs
Not described
Known, not yet covered
- The Game Genie and Shark cheat devices (Pan Docs’ Shark_Cheats.md) and the GBC approval process (GBC_Approval_Process.md) are not registers or protocols of the console; they are written on video, sound and I/O.
- Pan Docs’ timing and example drawings for the 4-player adapter are given here as text only; the 4-player timing formula for the 0.36 to 2.15 ms add-on is not understood by Pan Docs either.
Unknown
- What Pan Docs leaves open: the registers after an HBlank DMA whose destination overflows, whether echo RAM, OAM,
$FExx, I/O or HRAM work as a VRAM DMA source, and the 20 µs disconnect time on models other than the CGB revision E.