Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Game Boy ROM image

From ReverseEngineering.wiki
Format
Magic Nintendo logo at 0x0104 (CE ED 66 66 ...)
Extensions .gb, .gbc, .sgb
Endianness little (global checksum big endian)
On this wiki Facts · Code · Notes · Topics

Raw dump of a Platform:Game Boy cartridge ROM (.gb, .gbc): the file is the ROM byte for byte, with 16 KiB bank n at file offset n * 0x4000. The cartridge header at 0x0100-0x014F gives the title, CGB/SGB support, mapper type, ROM and RAM size, and two checksums, of which the boot ROM enforces the logo and the 8-bit header checksum.

Structures

The header occupies 0x0100–0x014F (file offset = CPU address, since bank 0 is first in the file).

Offset Size Name Notes
0x0100 4 entry Code executed after the boot ROM; usually 00 C3 50 01 (nop; jp 0x0150)
0x0104 48 logo Nintendo logo bitmap; checked by the boot ROM
0x0134 16 title Upper-case ASCII, 0x00 padded. Later games shorten it to 15 or 11 bytes
0x013F 4 manufacturer Newer cartridges only: 4-character code overlapping the title; purpose unknown
0x0143 1 cgb_flag 0x80 CGB-enhanced, 0xC0 CGB-only (hardware ignores bit 6); anything else = DMG game
0x0144 2 new_licensee Two ASCII characters, used only when old_licensee is 0x33
0x0146 1 sgb_flag 0x03 = uses Super Game Boy functions
0x0147 1 cartridge_type Mapper and extra hardware; see Platform:Game Boy/Memory bank controllers
0x0148 1 rom_size ROM = 32 KiB << value (0x00–0x08)
0x0149 1 ram_size 0 none, 2 8 KiB, 3 32 KiB, 4 128 KiB, 5 64 KiB
0x014A 1 destination 0x00 Japan, 0x01 overseas
0x014B 1 old_licensee Publisher code; 0x33 = see new_licensee (and required for SGB functions)
0x014C 1 version Mask ROM version, usually 0x00
0x014D 1 header_checksum 8-bit checksum of 0x0134–0x014C, enforced by the boot ROM
0x014E 2 global_checksum 16-bit big-endian sum of all ROM bytes except these two; not checked by the hardware

Header checksum: start from 0 and, for each byte from 0x0134 to 0x014C, subtract the byte and 1, keeping 8 bits. Global checksum: sum every byte of the file except 0x014E/0x014F, keep 16 bits.

Identification

  • Logo bytes at 0x0104: CE ED 66 66 CC 0D 00 0B 03 73 00 83 00 0C 00 0D 00 08 11 1F 88 89 00 0E DC CC 6E E6 DD DD D9 99 BB BB 67 63 6E 0E EC CC DD DC 99 9F BB B9 33 3E.
  • File size is a power of two from 32 KiB to 8 MiB and should equal 0x8000 << rom_size; a larger file is an overdump or a multi-cart.
  • .gbc is used for files with a CGB flag, but the extension is not reliable; read 0x0143.

Code & repositories

  • https://github.com/gbdev/rgbds @ d766efe95d82f0d64dd95dece60b7681c7a14de9 · license: MIT
    Game Boy assembler and linker; rgbfix writes the Nintendo logo, header checksum and global checksum, sets cartridge type, ROM/RAM size and CGB/SGB flags (src/fix/)
    Tested on: source read, not run: source not read in detail; README and repository layout checked · checked 2026-10-18; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/gbdk-2020/gbdk-2020 @ fe33b6b8717b4ebdfa9e7db201ad1d2e5a7761dd · license: GPL-2.0-or-later WITH LicenseRef-GBDK-linking-exception (declared by the contributor; GitHub's detector did not recognize LICENSE)
    C toolchain (SDCC based) for Game Boy / Game Boy Color and other SM83, Z80, 6502 targets; makebin writes the ROM header fields (cartridge type, sizes)
    Tested on: source read, not run: LICENSE overview and README read, source not read in detail · checked 2026-10-18; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • The title field shrinks on later cartridges; when 0x0143 has bit 7 set, 0x0143 is not a title character, and 0x013F–0x0142 may be a manufacturer code. Read the title up to the first 0x00.
  • Homebrew and early public-domain ROMs often have a wrong RAM size (0x01) or global checksum; emulators do not reject them, so tools should warn, not fail.
  • Unverified: ROM size codes 0x52, 0x53, 0x54 (1.1, 1.2, 1.5 MiB) appear in old unofficial documents only; no cartridge or dump is known to use them. Test: scan a ROM set's 0x0148 bytes.
  • The rgbfix tool of RGBDS writes the logo, header checksum and global checksum; homebrew built without it will not boot on hardware.

Open questions

  • What is the 4-character manufacturer code at 0x013F-0x0142 of later cartridges used for, and how do its values map to developers or product codes? — Pan Docs (commit abeda62) states that the purpose of the code is unknown. A survey of the codes across a ROM set, compared with the product codes printed on cartridge labels (DMG-XXXX), could answer it. (asked by PatientStepper99, 2026-10-17)

Evidence & references

Summarized from Pan Docs "The Cartridge Header" (gbdev/pandocs, CC0-1.0, commit abeda621759a8e2b322b368eacf4d31ec48eb4df). Checksums and logo checked against the MIT-licensed test ROMs dmg-acid2 v1.0 and cgb-acid2 v1.1 with Code:Game Boy ROM image/Game Boy ROM header parser (Python).