The header is 16 bytes in the ROM, and a program is not required to have one. This page follows SMS Power’s pages on the ROM header and on the BIOSes, which document what the Master System and Game Gear BIOSes check. File offsets are addresses in the ROM, after any copier header.
Where the header is
The header ends 16 bytes before the end of the first 8, 16 or 32 KB of the ROM, at 0x1FF0,
0x3FF0 or 0x7FF0. The Master System BIOS (version 1.3 is the one SMS Power describes in
detail) looks for it for each of the card, cartridge and expansion slots, in that order of slot, and in each slot at
0x7FF0, then 0x3FF0, then 0x1FF0: it copies 16 bytes and looks for
TMR SEGA in the first eight. If it finds none the slot counts as empty. Only 0x7FF0 is used in
known software. The Game Gear BIOS (which SMS Power calls the TMSS BIOS) looks at the cartridge only, at the same three
places; if the text is not there the screen stays off and the console locks up.
Several BIOSes do not look for a header at all: the Japanese version 2.1 checks that the first 256 bytes of each slot
are not all alike, an uncommon version 2.0 that the first 513 bytes are not all the same, and the Korean Samsung BIOS that the
first 16 bytes are not all 0xFF. A ROM without a header can therefore run on a Japanese
console and not on an export one; many homebrew ROMs have none.
Fields
| Offset | Size | Field | Meaning |
|---|---|---|---|
+0x0 | 8 | Signature | The ASCII text TMR SEGA. |
+0x8 | 2 | Reserved | Not used. Often 00 00, FF FF or 20 20; the last comes from Sega documentation that ran these bytes into the signature. |
+0xA | 2 | Checksum | 16-bit, little-endian. |
+0xC | 2.5 | Product code | BCD digits; the half byte at the top of +0xE is a further digit. |
+0xE (low nibble) | 0.5 | Version | 0 for the first release, higher for later revisions. |
+0xF (high nibble) | 0.5 | Region | 3 to 7. |
+0xF (low nibble) | 0.5 | ROM size | A code, 0xA to 0xF and 0x0 to 0x2. |
Signature
The eight bytes 54 4D 52 20 53 45 47 41, the text TMR SEGA. The export Master System BIOS and the Game Gear BIOS require
it. The comparison is exact, so a lower-case or damaged signature is not a header.
Checksum
A 16-bit sum of bytes, stored little-endian at +0xA, which the export Master System BIOS compares with the
sum it computes and answers “SOFTWARE ERROR” if they differ. Japanese consoles and the Game Gear do not check it (SMS Power
lists the Game Gear check as absent), and Game Gear and Japanese releases often have no correct checksum. The ROM size code
chooses which bytes are summed. The 16 bytes of the header are left out when the header is at 0x7FF0, because
the first range stops at 0x7FEF:
| Size code | ROM size | Summed | SMS Power’s note |
|---|---|---|---|
0xA | 8 KB | 0x0000–0x1FEF | unused |
0xB | 16 KB | 0x0000–0x3FEF | unused |
0xC | 32 KB | 0x0000–0x7FEF | |
0xD | 48 KB | 0x0000–0xBFEF | unused, buggy: some BIOS routines compute it wrongly. The range also holds the header at 0x7FF0, checksum bytes included. |
0xE | 64 KB | 0x0000–0x7FEF and 0x8000–0xFFFF | rarely used |
0xF | 128 KB | 0x0000–0x7FEF and 0x8000–0x1FFFF | |
0x0 | 256 KB | 0x0000–0x7FEF and 0x8000–0x3FFFF | |
0x1 | 512 KB | 0x0000–0x7FEF and 0x8000–0x7FFFF | rarely used |
0x2 | 1 MB | 0x0000–0x7FEF and 0x8000–0xFFFFF | unused, buggy: the BIOS versions 1.3, 2.4, 3.4 and 4.4 do not sum this range correctly; the Alex Kidd BIOS fixed it, the Sonic BIOS did not include the fix |
0x3–0x9 | — | not supported | |
The sum is of unsigned bytes, modulo 65536. The range of the code, not the length of the file, decides, and the size code
often says less than the file holds. The explorer computes the sum for every size code except 0x3–0x9, and
reports a mismatch as an error only for region code 4, the one the export BIOS checks. It was checked on one real ROM,
the homebrew game Datastorm (32 KB, size code 0xC): the sum of 0x0000–0x7FEF is
0xE642, the stored value.
Product code and version
The last four digits of the product code are in BCD in +0xC (the two lower digits) and
+0xD (the two upper): 26 70 reads 7026. The high four bits of +0xE are a digit
written in hexadecimal that comes before them: 26 70 2 is 27026, and a gives 10, so
26 70 a is 107026 (a 0 adds no digit). The low four bits of +0xE are the version, 0
for the first release and higher for revisions, often with bug fixes.
Region code
The high four bits of the last header byte. Only the export Master System BIOS checks it, and it demands 4.
| Code | Console |
|---|---|
3 | Master System, Japan |
4 | Master System, export |
5 | Game Gear, Japan |
6 | Game Gear, export |
7 | Game Gear, international |
The explorer uses the region to choose between the Master System and the Game Gear. A file without a header is told by its extension, and the options bar can override both.
ROM size code
The low four bits of the last header byte give the size the checksum covers: 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. The code is often present when the checksum is not, and it often
names a size smaller than the file, as only the first part is summed.
Copier header
Some copiers put a 512-byte block in front of the ROM. Everything above then moves 512 bytes later in the file; the file
size is a whole number of 16 KB pages plus 512. The explorer skips the block when the size has this form, or when the
TMR SEGA text is found 512 bytes in and not at the ordinary place. This rule is the common convention and was not
found in a specification, so the options bar can switch it off. A ROM without a header and with an unusual size is not
detected.
Sources
- ROM Header – SMS Power: places, fields, region and size codes
- BIOSes – SMS Power: the order the BIOS searches, the checksum ranges, the other BIOSes’ checks
Not described
How the BIOSes treat a header found only at 0x3FF0 or 0x1FF0 with a size code that
reaches past it, and the unused size codes on real hardware, are not in the sources read, and no real ROM here has such a
header. The Game Gear BIOS’s own checks are given by SMS Power only as “none” for region and checksum.