From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:INES and NES 2.0 ROM image" |
|---|
| claim | "The 16-byte iNES/NES 2.0 header: magic, PRG count (16 KiB units), CHR count (8 KiB units), then flag bytes 6-15 whose meaning depends on the dialect given by byte 7 bits 2-3." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:INES and NES 2.0 ROM image" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "NesHeader" |
|---|
| size | 16 |
|---|
| fields | | name | "magic" |
|---|
| offset | 0 |
|---|
| type | "char[4]" |
|---|
| note | "NES\x1A" |
|---|
|
| name | "PrgCount" |
|---|
| offset | 4 |
|---|
| type | "u8" |
|---|
| note | "16 KiB units; iNES: 0 means 256; NES 2.0: low 8 bits of the size, high nibble in Byte9 low nibble; if that nibble is 0xF the byte is an exponent-multiplier: size = (2*(b & 3)+1) << (b >> 2) bytes" |
|---|
|
| name | "ChrCount" |
|---|
| offset | 5 |
|---|
| type | "u8" |
|---|
| note | "8 KiB units; 0 = CHR RAM; NES 2.0 high nibble in Byte9 high nibble, 0xF selects the exponent-multiplier form as for PRG" |
|---|
|
| name | "Byte6" |
|---|
| offset | 6 |
|---|
| type | "u8" |
|---|
| note | "bit0 vertical mirror, bit1 battery, bit2 trainer, bit3 four-screen (overrides bit0), bits4-7 mapper low nibble" |
|---|
|
| name | "Byte7" |
|---|
| offset | 7 |
|---|
| type | "u8" |
|---|
| note | "dialect = bits2-3: 0b10 (8) NES 2.0, 0b00 iNES, anything else = old iNES (garbage in bytes 7-15, only the Byte6 mapper nibble is used). iNES/NES 2.0: bit0 VS System, bit1 PlayChoice, bits4-7 mapper mid; NES 2.0: bits0-1 console type (3 = extended, see Byte13)" |
|---|
|
| name | "Byte8" |
|---|
| offset | 8 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: mapper bits 8-11 (low nibble), submapper (high nibble)" |
|---|
|
| name | "Byte9" |
|---|
| offset | 9 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0: PRG size bits 8-11 (low nibble), CHR size bits 8-11 (high nibble); iNES: bit0 PAL" |
|---|
|
| name | "Byte10" |
|---|
| offset | 10 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: PRG RAM (low nibble), PRG NVRAM (high nibble); 0 = none, else 128 << (n-1) bytes (64 << n)" |
|---|
|
| name | "Byte11" |
|---|
| offset | 11 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: CHR RAM (low), CHR NVRAM (high), same coding" |
|---|
|
| name | "Byte12" |
|---|
| offset | 12 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: timing in bits 0-1 (0 NTSC, 1 PAL, 2 both -> NTSC, 3 Dendy)" |
|---|
|
| name | "Byte13" |
|---|
| offset | 13 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: console type 1 (VS): low nibble PPU model, high nibble VS hardware type; console type 3: low nibble extended console (0 NES, 1 VS, 2 PlayChoice, 4 EPSM, 0xC Famicom Network System)" |
|---|
|
| name | "Byte14" |
|---|
| offset | 14 |
|---|
| type | "u8" |
|---|
| note | "not read by Mesen2" |
|---|
|
| name | "Byte15" |
|---|
| offset | 15 |
|---|
| type | "u8" |
|---|
| note | "NES 2.0 only: default input device" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "header struct comment table and accessors (GetMapperID, GetPrgSize, GetSubMapper, GetNesGameSystem, GetMirroringType)" |
|---|
| repo | "https://github.com/SourMesen/Mesen2" |
|---|
| commit | "b9fa69ddc6d0a331fb103fdb5eef6904305703c2" |
|---|
| path | "Core/NES/NesHeader.cpp" |
|---|
| lines | "6-60, 83-139, 181-197" |
|---|
|
| type | "source" |
|---|
| detail | "GetRomHeaderVersion ((Byte7 & 0x0C) == 8 NES 2.0, == 0 iNes, else OldiNes), GetPrgSize/GetChrSize with the 0xF exponent-multiplier branch (GetSizeValue), GetMapperID per dialect, GetWorkRamSize.. (128 * 2^(v-1)), GetGameSystem/GetVsSystemType/GetVsSystemPpuModel using Byte13." |
|---|
| repo | "https://github.com/SourMesen/Mesen2" |
|---|
| commit | "b9fa69ddc6d0a331fb103fdb5eef6904305703c2" |
|---|
| path | "Core/NES/NesHeader.cpp" |
|---|
| lines | "6-251" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "NesHeader" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T09:14:12.590Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T17:24:24.147Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read NesHeader.cpp at the cited commit: dialect from Byte7&0x0C, mapper, PRG/CHR size incl. 0xF exponent-multiplier ((2*(b&3)+1)<<(b>>2)), RAM sizes 128<<(n-1), timing Byte12&3, console type Byte7&3 and Byte13 nibbles, Byte15 input all match; all fields are single bytes so no byte order applies." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T07:51:35.228Z" |
|---|
| summary | "Mesen2 distinguishes three dialects (NES 2.0, iNES, old iNES with garbage in bytes 7+) and has an exponent-multiplier size form when a size nibble is 0xF; add both and the iNES-only meanings." |
|---|
| changed | |
|---|
|
|
|---|