Expand description
The CD unit: the expansion-port device that owns $1800-$18FF, CD RAM and the backup RAM
(unit.py).
It plugs into the base board’s socket 2 (PortDevice): claims() lists the pages, every
access carries its master-clock time, catch_up(mclk) runs the drive up to it (the board
calls it at every advance, base issue 0002; a register access also brings the drive’s clock
to its own time), present pulls the I/O port’s bit 7 low, and IRQ2 is the board’s wired-OR
line with this unit’s own bit, “cd”.
Registers [hw: pcetech 8 for the names; the bit-level behaviour is emulator-derived, tier 5, and each is marked]:
| addr | read | write |
|---|---|---|
$1800 | SCSI status: D3 I/O, D4 C/D, D5 MSG, D6 REQ, D7 BSY | select the drive (SEL pulse) |
$1801 | the SCSI data bus | the data bus (command bytes) |
$1802 | IRQ enable mask (D6-D0) and ACK (D7) | the same: D7 sets ACK, D6-D0 the mask |
$1803 | active IRQ bits, D1 = left/right flag; locks BRAM | – |
$1804 | the reset register | D1 = SCSI reset (the BIOS’s CD_RESET sets then clears it) |
$1805 | CD-DA sample, low byte | toggles left/right and latches that channel’s sample |
$1806 | CD-DA sample, high byte | – |
$1807 | subchannel byte (not modelled: 0) | D7 set unlocks BRAM |
$1808 | the SCSI data bus; a read of data in pulses ACK | ADPCM address low |
$1809 | – | ADPCM address high |
$1808/9, $180A-$180E | the ADPCM unit (adpcm.rs); $180B bit 1 = CD-to-ADPCM DMA | the same |
$180F | the fader register | fade control |
$1A00-$1AFF, banks $40-$43 | the Arcade Card, when fitted (arcade.rs) | the same |
$18C0-$18C7 | the Super System Card id registers (answered by the card) | – |
IRQ2 = (enable mask & active bits) != 0. Active bits: 0x04 ADPCM half, 0x08 ADPCM end, 0x10 subchannel, 0x20 status/message-in (REQ in those phases), 0x40 data-in (REQ in data in). The status/message and data-in bits are derived from the bus levels, the ADPCM bits are the unit’s half and end flags (adpcm.rs), the subchannel bit is U9.
Differences forced by Rust:
BoardPinsarrives with each call (the base board’s sockets.rs), so there is nobind;sync_irqis the reference’s_bus_irq,_adpcm_irqand_update_irq: after each call into the bus or the ADPCM unit it applies the level changes they listed, in order, and sets the unit’s bit on IRQ2. A unit driven with no board behind it takes aDetachedPins(the reference’s unbound unit).- The audio player is the bus’s (
unit.bus.cdda;unit.cdda()), the ADPCM unit is its own audio source, and the two are whataudio_sourceshands the mixer (the reference appends them to the board’s list). - The disc is shared by the bus and the player as an
Rc<Disc>. - The id registers
$18C0-$18C7are asked ofpins.cardwhen it is aSystemCard(the reference’s unit keeps the cardPcEngineCdbuilt it with). - Save states (
DeviceState): everything that changes as the console runs, in one bincode value; the switches, the wiring and the drive’s command log stay the unit’s own. The identity names the disc by its table of contents and says whether an Arcade Card is fitted, so a machine with another disc, or without the card, refuses the state. - A
bramimage longer than 2 KiB is an error (the reference’sValueError):withreturns aResult.
Structs§
- CdUnit
- CD RAM, backup RAM, the registers, the SCSI bus and the CD-DA player.
- Unit
Switches - The reference’s
CdUnitclass attributes, with its defaults.
Constants§
- BRAM_
BYTES - BRAM_
FORMATTED - [emu: Mesen2
PceCdRom.cpp] the BRAM the BIOS leaves after “initialise”: a header, rest zero. The real RAM is battery-backed and its content at an owner’s first power-up is unknown (U36); unformatted RAM makes some games (Far East of Eden) misbehave [emu: Mesen2 comment]. - BRAM_
PAGES - $1EE000-$1EE7FF, the first 2 KiB of bank $F7 [hw: pcetech 8]
- CD_
RAM_ BYTES - CD_
RAM_ PAGES - banks $80-$87, physical $100000-$10FFFF [hw: pcetech 8]
- IRQ_
ADPCM_ END - IRQ_
ADPCM_ HALF - IRQ_
DATA_ IN - IRQ_
STATUS_ MESSAGE - IRQ_
SUBCODE - REGISTER_
PAGE - $1800-$18FF