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:Sega Master System ROM image

From ReverseEngineering.wiki
Format
Magic "TMR SEGA" at 0x7FF0 (optional)
Extensions .sms, .gg, .sg
Endianness little
On this wiki Facts · Code · Notes · Topics

Raw cartridge dump of the Sega Master System and Game Gear (.sms, .gg, .sg): no file header, the ROM bytes as they appear on the cartridge; the optional 16-byte "TMR SEGA" header sits at 0x7FF0 (0x3FF0 or 0x1FF0 in small ROMs) and the mapper registers are Z80 addresses 0xFFFC-0xFFFF.

Overview

A Master System or Game Gear ROM dump is the cartridge ROM byte for byte; there is no container. Emulators accept an optional 512-byte copier header in front: Mesen2 drops 0x200 bytes when the file size modulo 0x400 equals 0x200 (Core/SMS/SmsConsole.cpp, LoadRom). The platform is told apart by extension (.gg Game Gear, .sms Master System, .sg SG-1000, .col ColecoVision in Mesen2), not by content; see Platform:Sega Master System and Platform:Sega Game Gear.

TMR SEGA header

The export BIOSes of the SMS and GG check a 16-byte header at ROM offset 0x7FF0 (the documentation also lists 0x3FF0 and 0x1FF0; ares looks at all three, in the order 0x7FF0, 0x3FF0, 0x1FF0, depending on ROM size). Layout:

Offset Size Field
0x7FF0 8 ASCII TMR SEGA
0x7FF8 2 reserved (often 00 00, FF FF or 20 20)
0x7FFA 2 checksum, little endian
0x7FFC 2 product code, 4 BCD digits (26 70 = 7026)
0x7FFE 1 high nibble: version; low nibble: fifth product digit
0x7FFF 1 high nibble: region/system code; low nibble: ROM size code

Region codes (high nibble of 0x7FFF): 3 SMS Japan, 4 SMS Export, 5 GG Japan, 6 GG Export, 7 GG International. ROM size codes (low nibble): 0xA 8 KB, 0xB 16 KB, 0xC 32 KB, 0xD 48 KB, 0xE 64 KB, 0xF 128 KB, 0x0 256 KB, 0x1 512 KB, 0x2 1 MB. Documentation calls 0xA, 0xB, 0xD and 0x2 unused or buggy. Only the export SMS BIOS refuses a cartridge by this header; Japanese consoles and the Game Gear do not, and many Game Gear and Japanese releases carry a wrong checksum. ares uses the header only to guess a region: a ROM without TMR SEGA and region code 4 is treated as Japanese-only (mia/medium/master-system.cpp, validateHeader).

Checksum, as computed by MAME (mamedev/mame src/devices/bus/sega8/sega8_slot.cpp @ f242d941cf, log_info): a 16-bit sum of bytes from 0 up to min(end, 0x7FF0), plus bytes 0x8000 up to end, where end comes from the size code: 0xA 0x1FF0, 0xB 0x3FF0, 0xC 0x7FF0, 0xD 0xCFF0, 0xE 0x10000, 0xF 0x20000, 0x0 0x40000, 0x1 0x80000, 0x2 0x100000 (codes 3-9 give 0, meaning the whole ROM). The header bytes 0x7FF0-0x7FFF are skipped, and MAME reads the version from the high nibble of 0x7FFE and the product digit from the low nibble of 0x7FFE.

Codemasters header

Codemasters cartridges have no TMR SEGA header; they store a checksum at 0x7FE6 and its complement at 0x7FE8 (both 16-bit little endian), and Mesen2 detects their mapper by checking that the two sum to 0x10000. See Platform:Sega Master System#Mappers.

Size and mirroring

Images whose size is not a power of two are padded with zeros at the end to the next power of two by Mesen2; ROMs up to 0xC000 bytes (48 KB) are treated as having no mapper, larger ones as the standard Sega mapper.

Related

Platform:Sega Master System, Platform:Sega Game Gear, Format:Mega Drive ROM image (another Sega cartridge format, with a 256-byte header at 0x100).

Code & repositories

  • https://github.com/ares-emulator/ares @ 9408cb43d4948fc3ea6e152a307a34348df3fe04 · license: ISC (declared by the contributor; GitHub's detector did not recognize LICENSE)
    Multi-system emulator; its cartridge loaders and databases show header layouts, mapper detection and save types.
    Tested on: source read, not run: source read, not run · checked 2026-10-18