.NES
iNES ROM image
Introduction
A .nes file is a copy of a Nintendo Entertainment System game cartridge,
for playing in an emulator. The format is called iNES, after the emulator that
introduced it in the 1990s. It stores the 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.
NES 2.0 is a backwards-compatible extension of the same header that describes cartridges more exactly, with larger mapper numbers and RAM sizes.
Software
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. When bits 2 and 3 of byte 7 are 10 in binary, the header
is NES 2.0.
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 bytes8further flags, padded with zeros in plain iNES8 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