Many early Mega Drive dumps are in the form written by the Super Magic Drive, a game
copier, usually with the extension .smd. No specification of the copier’s
format was found. What follows is what emulator loaders (DGen’s) and the
file command’s magic rules rely on, which is enough to convert such a file
to a plain ROM; the meaning of most header bytes is unknown.
Layout
0header512 bytes0x200block 0: ROM bytes0x0000–0x3FFF, interleaved16 KiB0x4200block 1: ROM bytes0x4000–0x7FFF16 KiB…one block per 16 KiB of ROM16 KiB each
Header
| Offset | Size | Meaning |
|---|---|---|
0 | 1 | Number of 16 KiB blocks in this file. (DGen does not rely on it and works the count out as (file size − 512) ÷ 16384.) |
2 | 1 | Split flag: 0 for a standalone file or the last of a series; non-zero for a part of a split ROM. (A note on the copier’s BIOS calls bit 6 of a header status byte the multi-file flag.) |
8 | 2 | AA BB, the marker that identifies the header. |
10 | 1 | Image type, shared with other copiers of the same family: 0x06 Sega Magic Drive image, 0x07 Sega Magic Drive save RAM (and 0x02–0x05 for Magic Griffon and Super Wild Card files). |
| others | — | Unknown. |
How the parts of a split ROM fit together is not described in the sources read for this page.
Interleaving
The copier stored each 16 KiB block as two halves: the first 8 KiB holds the bytes at odd addresses and the second 8 KiB the bytes at even addresses. For byte j (0 to 8191) of block n:
rom[n × 16384 + 2j + 1] = block[j] first half → odd addresses
rom[n × 16384 + 2j] = block[8192 + j] second half → even addresses
This is why the text SEGA GENESIS at ROM address 0x100
shows up in an SMD file as EAGN at offset 0x280 (512 for the
header plus 0x80, the odd bytes 0x101, 0x103,
0x105, 0x107), and SEGA MEGA DRIVE as
EAMG. Together with AA BB at offset 8, that is how the
file command recognises an SMD image.
Converting to a plain ROM
- Check for
AA BBat offset 8 (and, if wanted,EAGNorEAMGat0x280). - Drop the first 512 bytes.
- For each 16 KiB block, interleave its two halves as above.
- The result is an ordinary
.md/.binimage whose header is at0x100.
A plain ROM is told apart by finding SEGA at 0x100, where
an SMD file has header bytes.
Byte-swapped dumps and the emulator rule
Some dumps have every pair of bytes the wrong way round, so SEGA at
0x100 reads ESAG; swapping each pair back gives the plain ROM.
Genesis Plus GX (source read: core/loadrom.c) looks for the swapped text
ESAGM GE ARDVI E or ESAGG NESESI at 0x100
and again at 0x80100. It also treats any file without SEGA at
0x100 whose size is a multiple of 512 bytes with an odd number of 512-byte
units as having a 512-byte header, removes it and de-interleaves the 16 KiB blocks as above, whatever the
extension. That emulator does not check what it gets: it trusts that anything it was asked to load as a ROM is a Mega Drive ROM.
This site’s viewer, which must also decide whether a file is a Mega Drive ROM at all, differs in three ways:
- It applies the size rule only to files named
.smd. For any other name it asks for proof:AA BB 06at offsets 8 to 10 with a whole number of 16 KiB blocks after the header, or the interleavedSEGAdescribed above (EandAat0x280and0x281,SandGat0x2280and0x2281), the test that MAME’s Mega Drive loader (the GoodGEN rule) starts with. A random file of 512 + 16384 bytes named.binis therefore not taken, while Genesis Plus GX would load it. - It looks for the swapped text
ESAGat0x100, and at0x80100when0x100does not readSEGA, but only the first four letters, not the wholeESAGM GE ARDVI EorESAGG NESESIthat Genesis Plus GX asks for. Why that emulator also looks 512 KiB in is not stated in its source; no ROM that needs it was found. - It also reads the whole-file interleave below, which Genesis Plus GX does not.
Whole-file interleave
MAME’s Mega Drive cartridge loader (md_slot.cpp, the branch it calls “MD”) reads a second kind of interleaved dump, with no header and no blocks: the first half of the file holds the bytes at odd ROM
addresses and the second half those at even addresses.
rom[2k + 1] = file[k] first half → odd addresses
rom[2k] = file[length / 2 + k] second half → even addresses
MAME recognises it by E, A and then M or G at file offsets 0x80–0x82: the odd bytes of SEGA MEGA DRIVE and SEGA GENESIS at ROM 0x101, 0x103 and 0x105.
The viewer asks for the same and also for S and G at length / 2 + 0x80 and an even length. No specification, name or copier for this layout was found (it is a guess that it came from a copier
of the Multi Game Doctor family); this page describes MAME’s code only. No real file in this form was available, so the viewer’s reading is tested on files converted from real ROMs by the rule above.
Sources
- romload.c – DGen’s ROM loader: the
AA BBtest at offset 8, the block count and the de-interleaving loop - Magdir/console – the
filecommand’s magic rules: block count, split flag,EAGN/EAMGat0x280 - loadrom.c – Genesis Plus GX: the byte-swap test, the 512-byte header rule and the de-interleave loop
- md_slot.cpp – MAME:
genesis_is_SMD(the interleavedSEGAtest, copied from GoodGEN) and the loaders for the SMD and whole-file interleaved forms - Super Magic Drive BIOS notes – Spritesmind: the multi-file bit
- SWC header – Archaic Ruins’ notes on the Super Wild Card header, which list the image types of the Magic Drive and related copiers