Introduction
A .pce file is a copy of the ROM in a HuCard, the credit-card-sized cartridge of the PC Engine (NEC and Hudson Soft, Japan 1987) and of the
TurboGrafx-16, its North American version. It is what an emulator or a flash card loads. There is no header and no signature: the file is
the ROM, in 8 KB banks, and the program it holds runs on a Hudson HuC6280, a
65C02 with a memory-mapping unit.
Because nothing says what the file is, the explorer takes it by its extension and, for what the bytes cannot say, offers choices: the copier header, the bit order, the mapper and the bank to disassemble. Nothing is guessed silently.
Structure
The processor sees 64 KB, in eight segments of 8 KB, each shown from any bank of a 2 MB physical space by a
mapping register. A HuCard’s ROM is physical banks $00 and up, so
file bank n is physical bank n. When the processor starts, the register for the top segment ($E000-$FFFF) holds
$00, so the first bank is at $E000, and the five interrupt vectors, which sit at
$FFF6-$FFFF, are the last ten bytes of the first bank, at file offset $1FF6:
0x0000bank 0: the program and data, mapped at$E000at reset8 KB0x1FF6IRQ2 / BRK vector2 bytes0x1FF8IRQ1 (the VDC) vector2 bytes0x1FFATIQ (the timer) vector2 bytes0x1FFCNMI vector2 bytes0x1FFEreset vector: where the processor starts2 bytes0x2000banks 1, 2, 3 … the rest of the game, 8 KB eachvaries
$E000 or more.The viewer shows the vectors, the banks, the memory map (the physical banks, the hardware page with the video chip, the colour encoder, the sound generator, the timer, the joypad port and the interrupt controller) and the code of bank 0 and of the bank you choose, disassembled for the HuC6280 with the hardware registers named. See the memory map.
The copier header
Some copiers put 512 bytes in front of the ROM. A reader recognises it by the size: the ROM is a whole number of 8 KB banks, so a file that is a whole number of banks plus 512 bytes has a header (the convention the jspce emulator uses is the file size modulo 8192; MAME’s is stricter, 16 KB plus 512). The explorer chooses by that rule and the option “Copier header” overrides it. The header is skipped for banks and addresses; nothing in it is read.
The bit order
The Japanese PC Engine and the American TurboGrafx-16 connect the eight data lines of a HuCard in opposite order, so the bytes of a dump taken from one
kind of card can be the bit-reversed copy of the other kind’s: a reset vector of $E012 reads as $48 $07 instead of $12 $E0.
MAME reverses the bytes when the byte at $1FFF is below $E0, because the high byte of a reset vector cannot be (the code is at
$E000-$FFFF at reset). The explorer does not reverse anything by itself: it shows that byte as a fact and says when it is below
$E0; the option “Bit order of the data” chooses (default: as the file is). The test cannot tell a dump whose high byte is $FF
(reversed it is $FF again), so a normal file with such a vector looks right either way.
Mappers
Most HuCards have no mapper. The 2.5 MB card of Street Fighter II Champion Edition does: see the mapper. The explorer takes a file of exactly 2.5 MB as that card (MAME does the same) and the option “Mapper” overrides it. Other cards and sizes (the 384 KB and 192 KB layouts, whose banks the hardware mirrors in a way these pages do not describe) are shown as plain banks.
Not described
Known, not yet covered
- Viewer: the explorer opens
.pcefiles: the vectors, the banks, the memory map and the code of bank 0 (at$E000) and of a bank you choose, disassembled for the HuC6280. It decodes every byte as an instruction (no separation of code and data), does not follow the vectors’ code, and learns the mapping registers only from alda #ndirectly before atam. It does not model the CD-ROM and Super System Card systems, the Arcade Card, the 384 KB and 192 KB layouts or the Populous RAM, and reads.sgx(SuperGrafx) files only if you name them.pce. It was tested on built ROMs and on four homebrew ROMs, not on a commercial game, and has not been run in a browser by its author. - Reference: the CD-ROM system’s memory map and registers, the Super System Card and Arcade Card, the SuperGrafx’s two video chips, the layouts of 384 KB cards, and the HuCard’s pins; the registers of the video, sound, timer and interrupt chips are named but not described.
Unknown
- Reference: the 512-byte copier header’s contents (nothing in it is read), and whether any copier used a rule other than the file size.
- Reference: what the mapping registers hold at reset except the top one (the sources read do not say).
Links
Software
Reference
- CPU memory map – the PCEdev wiki
- Memory Mapping – the mapping registers and the physical map
- pce_slot.cpp – MAME’s cartridge slot: the copier header rule, the size of the Street Fighter II card, the bit reversal
- pce_rom.cpp – MAME’s cartridge types: the Street Fighter II bank registers
- TG16: Region Information – the data-line order of Japanese and American HuCards