ROM type signature
From MSX Game Library
This documentation is a proposal for ROM type signature to help Flash tools and emulators correctly detect ROM formats and, in particular, the type of mapper used.
This proposal is aimed above all at new MSX productions, for which there are still detection problems, particularly with mapped ROMs (Lilly's Saga, Phenix Corrupta, etc.).
Note: All the strings of this page are defined without zero-terminator.
Contents
ROM type signature
The ROM type signature is 8 bytes long and placed just after the 16 bytes ROM header starting with "AB".
Type | Signature |
---|---|
ASCII 8 KB | "ROM_ASC8" |
ASCII 16 KB | "ROM_AS16" |
Konami 8 KB (K4) | "ROM_KON4" |
Konami 8 KB with SCC (K5) | "ROM_KON5" |
NEO 8 KB | "ROM_NEO8" |
NEO 16 KB | "ROM_NE16" |
Plain 16 KB (page 0) | "ROM_16P0" |
Plain 16 KB (page 1) | "ROM_16P1" |
Plain 16 KB (page 2) | "ROM_16P2" |
Plain 16 KB (page 3) | "ROM_16P3" |
Plain 32 KB (page 0-1) | "ROM_32P0" |
Plain 32 KB (page 1-2) | "ROM_32P1" |
Plain 32 KB (page 2-3) | "ROM_32P2" |
Plain 48 KB (page 0-2) | "ROM_48P0" |
Plain 48 KB (page 1-3) | "ROM_48P1" |
Plain 64 KB (page 0-3) | "ROM_64P0" |
| |
Plain (no mapper) | "ROM_PL", x, 0 (see bellow) |
Note: These are just a few examples to show the intent, but if this signature format is of interest to developers and tool creators (flash and emulators) then we could draw up a more exhaustive list of existing ROM types.
Plain ROM (alternative)
For plain ROM, "ROM_PL" is followed by a byte describing the ROM format:
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|
1 | x | Mirror | Head | Last page | First page |
Where:
- First page: First page number of the ROM (0-3)
- Last page: Last page number of the ROM (0-3)
- Head: Page number of the ROM header (0: 0x4000, 1: 0x8000)
- Mirror: Is ROM mirrored in other pages (0: No, 1: Yes)
For example:
Type | Signature |
---|---|
Plain 16 KB (page #1) | "ROM_PL", 0b10000101, 0 |
Plain 16 KB (page #2) | "ROM_PL", 0b10011010, 0 |
Plain 32 KB | "ROM_PL", 0b10001001, 0 |
Plain 48 KB | "ROM_PL", 0b10001000, 0 |
Plain 64 KB | "ROM_PL", 0b10001100, 0 |
Note: This format don't support 8 KB plain ROM but this ROM size are no longer of any interest nowadays.
Detection
Most of the time, the ROM header is at the beginning of the .ROM file, so the signature is at offset 16 of this file. However, there are formats where this is not the case, such as a 32 KB ROM with its header visible at address 0x8000 of the memory space and therefore placed in the .ROM file at offset 0x4000.
For the ROM mappers, the header can be in the segment selected by default in the bank that cover addresses from 0x4000 or in segment selected by default in the bank that cover addresses from 0x8000. In ASCII mappers, segment 0 (the first segment) is selected in all banks, so the header is necessarily at the beginning of the .ROM file. However, with the Konami with SCC mapper, if bank 0 (which covers addresses from 0x4000) is initialized on segment 0 (the start of the ROM file), bank 2 (which covers addresses from 0x8000) is initialized on segment 2 at offset 0x4000 of the ROM file. Both locations should be checked for ROM header and signature.
Appendix
Signature as code
The 4 first bytes of the ROM type signature "ROM_", have been choose because the Z80 instructions it generates are incoherent enough so it's extremely unlikely that a program would start with these instructions and therefore unintentionally contain a valid signature. The next 4 bytes further increase the security of this signature.
Z80 instructions generated by the first 4 bytes of the signature:
ld d, d ; 'R' ld c, a ; 'O' ld c, l ; 'M' ld e, a ; '_'
Known ROM signature
Device | Signature | Size | Address |
---|---|---|---|
MSX-Audio | "AUDIO" | 5 bytes | 0x0080 |
Internal MSX-Music (and FM-PAC clone) | "APRLOPLL" | 8 bytes | 0x4018 |
FM-PAC | "OPLL" | 4 bytes | 0x401C |