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:SNES ROM image

From ReverseEngineering.wiki
Format
Platforms Platform:Super Nintendo Entertainment System
Magic none; header found by scoring candidate locations
Extensions .sfc, .smc, .swc, .fig
Endianness little
On this wiki Facts · Code · Notes · Topics

Cartridge dump of the Super Nintendo / Super Famicom (.sfc, .smc): raw ROM, sometimes with a 512-byte copier header, containing a 48-byte internal header at 0x7FC0 (LoROM), 0xFFC0 (HiROM) or 0x40FFC0 (ExHiROM) with title, map mode, chip type, ROM and RAM size, region and a checksum pair.

Locating the header

There is no magic. Emulators try the candidate offsets and score them. Mesen2 tries file offsets 0x0000, 0x0200, 0x8000, 0x8200, 0x408000 and 0x408200 as a base B and reads the header block at B + 0x7FB0: so LoROM headers sit at 0x7FC0, HiROM at 0xFFC0, ExHiROM at 0x40FFC0, plus 0x200 when a 512-byte copier header (SMC) precedes the ROM.

Score: +1 if map mode (bit 4 cleared) is 0x20/0x22 at a LoROM base or 0x21/0x25 at a HiROM base; +1 each for ROM type < 8, ROM size < 0x10, SRAM size < 8; +8 if checksum + complement == 0xFFFF (both non-zero); +8 if the reset vector points at a plausible first opcode (CLI, SEI, JMP, JML, JSR, JSL, STZ), +4 for REP, SEP, LDA, LDX, LDY, -8 for BRK, SBC, CPY. A reset vector below 0x8000 disqualifies the candidate.

ares (ISC) scores differently (mia/medium/super-famicom.cpp, commit 9408cb43d4948fc3ea6e152a307a34348df3fe04). Copier header: if (size & 0x7FFF) == 512 the first 512 bytes are removed (lines 222-225), i.e. size modulo 32768 equals 512 (so also modulo 1024 equals 512 for any ROM that is a multiple of 1 KiB). The ROM must be at least 0x8000 bytes. It then scores four header blocks at 0x7FB0 (LoROM), 0xFFB0 (HiROM), 0x407FB0 (ExLoROM) and 0x40FFB0 (ExHiROM) and takes the highest, preferring LoROM, then HiROM, then ExLoROM on ties; the extended candidates get +4 when non-zero (lines 234-244). Score per candidate (lines 820-878): zero if the reset vector (block+0x4C) is below 0x8000; the first opcode at the reset vector adds 8 for SEI, CLC, SEC, STZ abs, JMP, JML; adds 4 for REP, SEP, LDA, LDX, LDY (absolute, long, immediate), JSR, JSL; subtracts 4 for RTI, RTS, RTL, CMP/CPX/CPY abs; subtracts 8 for BRK, COP, STP, WDM, SBC long,X; +4 if checksum + complement == 0xFFFF; +2 if the block is at 0x7FB0 with map mode 0x20 or at 0xFFB0 with map mode 0x21 (FastROM bit ignored). The result is never negative.

Internal header (block starts at B + 0x7FB0, CPU address 0xFFB0)

Offset in block CPU address Size Field
0x00 FFB0 2 maker code (extended header)
0x02 FFB2 4 game code
0x0D FFBD 1 expansion RAM size
0x0E FFBE 1 special version
0x0F FFBF 1 cartridge sub-type (selects among 0xF_ chips)
0x10 FFC0 21 title (ASCII or Shift-JIS, space padded)
0x25 FFD5 1 map mode: bit 4 FastRom; low bits 0 LoROM, 1 HiROM, 2 ExLoROM (0x22, S-DD1), 5 ExHiROM
0x26 FFD6 1 ROM type (coprocessor and battery)
0x27 FFD7 1 ROM size, 1 KiB << n
0x28 FFD8 1 SRAM size, 1 KiB << n
0x29 FFD9 1 destination (region) code
0x2A FFDA 1 developer id (0x33 = use the extended maker code)
0x2B FFDB 1 version
0x2C FFDC 2 checksum complement
0x2E FFDE 2 checksum (complement + checksum = 0xFFFF)
0x30 FFE0 32 CPU vectors (native then emulation: COP, BRK, ABORT, NMI, RESET, IRQ)

ROM type and coprocessors

Low nibble 0x02, 0x05, 0x06, 0x09, 0x0A mean a battery. If the low nibble is 3 or more, the high nibble names the chip: 0 DSP family (DSP-1, 1B, 2, 3, 4 told apart by ROM size and title), 1 Super FX (GSU), 2 OBC-1, 3 SA-1, 4 S-DD1, 5 RTC; 0xE3 Super Game Boy, 0xE5 Satellaview; high nibble 0xF with the sub-type byte: 0x00 SPC7110, 0x01 ST010/ST011, 0x02 ST018, 0x10 Cx4.

Code & repositories

  • https://github.com/SourMesen/Mesen2 @ b9fa69ddc6d0a331fb103fdb5eef6904305703c2 · license: GPL-3.0-only (declared by the contributor for the files used; GitHub reports GPL-3.0 for the repository)
    SNES header scoring and coprocessor detection (Core/SNES/BaseCartridge.cpp, CartTypes.h)
    Tested on: source read, not run: source read, not run · checked 2026-10-18; archived; last activity 2026-06-04; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/ares-emulator/ares @ 9408cb43d4948fc3ea6e152a307a34348df3fe04 · license: ISC (declared by the contributor; GitHub's detector did not recognize LICENSE)
    Multi-system emulator; mia/medium/super-famicom.cpp strips the copier header and scores LoROM/HiROM/ExLoROM/ExHiROM header candidates
    Tested on: source read, not run · checked 2026-10-19; last activity 2026-10-06; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • Checksums are not verified by hardware; hacks and fan translations often leave them stale, so use the score, not the checksum alone.
  • Map mode alone is unreliable; mislabelled headers exist, hence the multi-factor scoring.
  • Copier-header detection by size: ares removes 512 bytes when (size & 0x7FFF) == 512 (mia/medium/super-famicom.cpp lines 222-225); Mesen2 does not test the size but scores bases at +0x200 and removes 512 bytes from the winner (BaseCartridge.cpp lines 195-218). Unverified: a copier header on a ROM whose size is not a multiple of 32 KiB plus 512 is missed by the ares rule.

Evidence and references

Mesen2 (GPL-3.0), Core/SNES/BaseCartridge.cpp and CartTypes.h; see Platform:Super Nintendo Entertainment System.