Introduction
iNES is the original header for .nes files, named after the iNES
emulator that introduced it in the 1990s. It stores a Nintendo Entertainment System
cartridge’s program ROM and graphics ROM behind a 16-byte header that tells the emulator
how the cartridge was wired, above all which mapper chip it used to switch banks of ROM
in and out. Most of the NES ROM images in circulation use it.
Structure
The file starts with the 16-byte header. The first four bytes are
4E 45 53 1A (NES and an MS-DOS end-of-file character). Byte 4
gives the size of the program ROM in 16 KB units and byte 5 the size of the character
(graphics) ROM in 8 KB units, where 0 means the cartridge uses RAM for graphics. Bytes 6
and 7 hold flags: the screen mirroring, whether there is battery-backed save RAM,
whether a 512-byte trainer follows the header, and the mapper number split across the
two high nibbles. Byte 8 can give the size of work RAM and byte 9 the TV system, but
few files fill them in, and the rest of the header is zero.
0magicNES\x1A4 bytes4PRG ROM size in 16 KB units, CHR ROM size in 8 KB units2 bytes6flags 6 and flags 7: mirroring, battery, trainer, mapper number2 bytes8work RAM size, TV system, then zeros8 bytes16trainer, only when flag 6 bit 2 is set512 bytes…PRG ROM: the game’s program16 KB units…CHR ROM: the game’s tile graphics8 KB units
Telling it apart
The file starts with 4E 45 53 1A and bits 2 and 3 of byte 7 are
00. When they are 10 in binary, the file is
NES 2.0.
Links
Software
Reference
- iNES, NESdev Wiki