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:Nintendo 64 ROM image

From ReverseEngineering.wiki
Format
Platforms Platform:Nintendo 64
Magic 80 37 12 40 (z64, big endian); 37 80 40 12 (v64); 40 12 37 80 (n64)
Extensions .z64, .v64, .n64
Endianness big (native .z64)
On this wiki Facts · Code · Notes · Topics

Dump of a Platform:Nintendo 64 cartridge ROM (.z64, .v64, .n64): a 64-byte header (PI bus configuration, clock rate, entry point, libultra version, two CRC words, 20-byte title, game code and version) followed by the 4 KiB IPL3 bootcode at 0x40-0xFFF and the game data from 0x1000. Dumps exist in three byte orders, told apart by the first four bytes.

Identification

The first word of every ROM is the PI domain-1 bus configuration, 0x80371240 on practically all cartridges, which doubles as a byte-order marker:

First bytes Byte order Usual extension To convert to .z64
80 37 12 40 big endian, as on the cartridge bus .z64 none
37 80 40 12 16-bit byte-swapped .v64 (Doctor V64) swap each pair of bytes
40 12 37 80 32-bit little endian .n64 reverse each 4-byte word

Convert to .z64 before hashing, reading the header or loading into a disassembler; all offsets below are .z64 offsets. Extensions are unreliable (some tools write big-endian files as .n64), so check the bytes.

mupen64plus-core (GPL-2.0-or-later, src/main/rom.c at commit 902bc60f561570bb3480d76910258b9afa10bafd) accepts a file when its first four bytes are 80 37 12 40 (any size), or 37 80 40 12 with an even size, or 40 12 37 80 with a size divisible by 4 (lines 75-88). It converts v64 by swapping each 16-bit unit and n64 by swapping each 32-bit word (lines 105-136), then hashes the converted image with MD5 and looks it up in its database; if no entry matches it falls back to the CRC1/CRC2 pair. Its header struct (api/m64p_types.h, m64p_rom_header) is: bytes 0-3 PI LAT/PGS/PWD/PGS2 registers, ClockRate at 0x04, PC at 0x08, Release at 0x0C, CRC1 0x10, CRC2 0x14, 8 unknown bytes at 0x18, 20-byte Name at 0x20, 4 unknown bytes at 0x34, Manufacturer_ID at 0x38 (it prints "Nintendo" when the value is N), 16-bit Cartridge_ID at 0x3C, Country_code at 0x3E, Version at 0x3F. For an unknown ROM whose Cartridge_ID is 0x4445 (ED, the advanced homebrew header) the save type comes from Version >> 4; any other unknown ROM defaults to 4 Kbit EEPROM (rom.c lines 220-230).

Structures

Offset Size Field
0x00 4 PI domain-1 configuration (0x80371240)
0x04 4 clock rate override (0 = default)
0x08 4 boot address / entry point (usually 0x80000400)
0x0C 4 libultra release the game was built with (0 on homebrew)
0x10 8 CRC1, CRC2: checksum of ROM 0x1000-0x100FFF checked by Nintendo's IPL3
0x18 8 reserved
0x20 20 title, ASCII padded with spaces
0x34 7 reserved (homebrew: controller types, see below)
0x3B 4 game code: category (N cartridge, D 64DD, ...), 2-character ID, region (E USA, J Japan, P Europe, ...)
0x3F 1 ROM version (homebrew: save type and flags)
0x40 0xFC0 IPL3 bootcode
0x1000 - game code and data

Advanced homebrew header

Flashcarts (EverDrive-64, SummerCart64) and emulators read save type and peripherals from the header of homebrew ROMs when the 2-character ID at 0x3C is ED. Then byte 0x3F is save_type << 4 | region_free << 1 | rtc, with save types 0 none, 1 EEPROM 4 Kbit, 2 EEPROM 16 Kbit, 3 SRAM 256 Kbit, 4 SRAM 768 Kbit, 5 FlashRAM 1 Mbit, 6 SRAM 1 Mbit; bytes 0x34-0x37 give the device on controller ports 1-4 (0x00 controller, 0x01 with Rumble Pak, 0x02 with Controller Pak, 0x03 with Transfer Pak, 0x80 mouse, 0x81 VRU, 0x82 GameCube controller, 0x83 Randnet keyboard, 0x84 GameCube keyboard, 0xFF none). Commercial ROMs never use the ID ED, so a ROM with ED there is homebrew.

Boot code (IPL3) and CIC

The PIF boot ROM copies ROM 0x000-0xFFF to RSP DMEM and asks the cartridge's CIC chip to confirm a 48-bit hash of the 1008 words at 0x040-0xFFF, computed from a per-CIC seed byte. If they disagree the console does not boot, so a ROM's IPL3 identifies the CIC its cartridge needs (6101, 6102/7101, 6103/7103, 6105/7105, 6106/7106 and the 64DD/iQue variants), and emulators pick the CIC by hashing this area. Because the IPL3 must match a CIC, homebrew either reuses a Nintendo IPL3 or uses an open-source one whose final words are brute-forced so that the hash collides with the CIC-6102 value (libdragon's IPL3 does this; Library:libdragon#Identification).

The CRC1/CRC2 words at 0x10 are a different checksum: Nintendo's IPL3 computes it over ROM 0x1000-0x100FFF with a CIC-dependent seed and locks up on a mismatch; libdragon's IPL3 ignores it, so libdragon ROMs leave both words 0.

How an emulator names the CIC: mupen64plus-core (src/device/pif/cic.c, commit 902bc60f56) adds up the 1008 32-bit words (0xFC0 bytes) of the IPL3 at ROM 0x40-0xFFF into a 64-bit sum and looks the sum up in a table of ten known values (lines 54-73). Variant names in cic.h: X101, X102, X103, X105, X106 (the 6101/7101, 6102/7102, 6103/7103, 6105/7105, 6106/7106 families; two different sums map to X101) and 5101, 5167, 8303, 8401, 8501 (the 64DD and iQue-related chips). Each variant carries a seed byte: 5101 0xAC, X101 and X102 0x3F, X103 0x78, X105 0x91, X106 0x85, 5167/8303/8401 0xDD, 8501 0xDE. An unknown sum logs a warning and falls back to CIC 6102 (line 59-62). The sum for CIC-X102 is 0xD057C85244 and for X105 0x11A49F60E96. Unverified: that the sum is taken over the big-endian image words as the table assumes; test by summing a known-good .z64 IPL3 area as native-endian 32-bit words on a little-endian host.

Code & repositories

  • https://github.com/DragonMinded/libdragon @ e356bf3f56f7afbf7e5246329562f145965cfdfc · license: Unlicense
    Open-source N64 SDK: hardware register definitions (include/, src/vi.h), an open-source IPL3 bootcode with documented boot hand-over (boot/), the ROM builder n64tool and the SYMT symbol-table generator n64sym (tools/). The preview branch (39d0d60) has newer TOC and SYMT formats.
    Tested on: Read at trunk e356bf3 and preview 39d0d60 (2026-09-15); header, TOC and ELF layouts checked with a Python parser on boot/bin/ipl3_*.z64 and the N64FlashcartMenu V0.3.4 ROM. · checked 2026-10-17; archived; last activity 2026-09-14; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/mupen64plus/mupen64plus-core @ 902bc60f561570bb3480d76910258b9afa10bafd · license: GPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize a license file)
    N64 emulator core: ROM byte-order detection and swapping (src/main/rom.c), header struct (src/api/m64p_types.h) and CIC identification by IPL3 sum (src/device/pif/cic.c)
    Tested on: source read, not run · checked 2026-10-19; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • Hash or patch the .z64 form; a hash of a .v64 or .n64 file does not match ROM databases that list big-endian hashes.
  • The entry point in the header is a RAM address, not a ROM offset: under Nintendo's IPL3 ROM 0x1000 is loaded to it.
  • Unverified: some games (for example those using CIC 6103 or 6106) are commonly said to add a fixed offset to the header entry point before jumping; test by comparing the header entry point with the first executed address in an emulator trace for such a game.

Evidence & references

  • Header layout: libdragon boot/ipl3.c rom_header_t (lines 92-103) and tools/n64tool.c (title at 0x20, category 0x3B, region 0x3E), commit e356bf3.
  • Advanced homebrew header: libdragon tools/ed64romconfig.c lines 28-58 and 308-321.
  • Byte orders and the CIC-6102 hash value were checked on libdragon's IPL3 binaries and on the N64FlashcartMenu V0.3.4 release ROM (AGPL-3.0, a libdragon build).