An .mdx file is a Mega Drive ROM in an encoded form. No specification was found, and no real .mdx file was available for this site
(none was found on the machine or in the public sources searched), so everything here comes from two emulators’ source code and is
what they do, not a documented format. The viewer’s reading of the format is tested only on files built to the rule below.
Layout
0header: 4 bytes, not read by the emulator that supports the format4 bytes4ROM: the plain ROM image with every byte exclusive-or0x40the ROM size…possibly one byte after the ROM, which that emulator leaves out0 or 1 byte
Decoding
Genesis Plus GX (core/loadrom.c, load_rom) decides by the file extension alone: when it is MDX it runs
for i = 4 to size − 2:
rom[i − 4] = file[i] XOR 0x40
size = size − 5
and then carries on as for any ROM: it looks for the byte-swapped header and for a 512-byte copier header (SMD copier files). The loop skips 4 bytes, exclusive-ors the
rest with 0x40 and leaves the last byte of the file out, so size − 5 is the ROM size it uses.
The text SEGA at 0x100 of the ROM is therefore 13 05 07 01 at file offset 0x104 (S xor 0x40 is 0x13, E is 0x05, G is 0x07,
A is 0x01).
What is not known
- What the 4 header bytes hold. Genesis Plus GX ignores them. (The viewer shows them as bytes.)
- Whether the file has a trailing byte. Genesis Plus GX’s size − 5 removes one; if a file has none, that emulator loses the last ROM byte and its ROM size is odd. The viewer decodes bytes from offset 4 to the end when the remainder is a whole number of words, and leaves out a last byte only when it would leave an odd length. For a file with a trailing byte this gives the same ROM as Genesis Plus GX; for one without, it keeps the last byte, which Genesis Plus GX drops. This is a decision, not a fact from a source.
- How the format arose. MAME’s Mega Drive slot (
md_slot.cpp) has a cartridge “Romance of the Three Kingdoms – Battle of Red Cliffs” with an encoded version whose first 2 MiB it decodes by skipping 4 bytes (two 16-bit words) and exclusive-oring every word with0x4040, and the comment on the already decoded version says it came “from .mdx format”. That matches Genesis Plus GX’s rule and suggests the format is that cartridge’s encoding; this page infers it and does not know whether other games use it.
In the explorer
A file whose bytes at offset 0x104 are 13 05 07 01 (xor-hidden SEGA) opens as a Mega Drive ROM in its MDX form, whatever its name: the tree shows the 4-byte header, the encoded ROM and any
trailing byte, and the sections show the decoded ROM like any other. Genesis Plus GX goes by the name alone; this site does not, because .mdx is far more often the name of a Markdown file with JSX in it, which
stays what it was. The Container option can force or turn off the reading (forcing it on a file that is not MDX gives garbage).
Sources
- loadrom.c – Genesis Plus GX: the
MDXextension test and the decoding loop (read the source text) - md_slot.h and md_slot.cpp – MAME: the Battle of Red Cliffs entries (
REDCLIFF“already decoded from .mdx format”,REDCL_EN“the encoded version”) and the decoding of the second