Module unit

Module unit 

Source
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 every cycle, base issue 0002), 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]:

addrreadwrite
$1800SCSI status: D3 I/O, D4 C/D, D5 MSG, D6 REQ, D7 BSYselect the drive (SEL pulse)
$1801the SCSI data busthe data bus (command bytes)
$1802IRQ enable mask (D6-D0) and ACK (D7)the same: D7 sets ACK, D6-D0 the mask
$1803active IRQ bits, D1 = left/right flag; locks BRAM–
$1804the reset registerD1 = SCSI reset (the BIOS’s CD_RESET sets then clears it)
$1805CD-DA sample, low bytetoggles left/right and latches that channel’s sample
$1806CD-DA sample, high byte–
$1807subchannel byte (not modelled: 0)D7 set unlocks BRAM
$1808the SCSI data bus; a read of data in pulses ACKADPCM address low
$1809–ADPCM address high
$1808/9, $180A-$180Ethe ADPCM unit (adpcm.rs); $180B bit 1 = CD-to-ADPCM DMAthe same
$180Fthe fader registerfade control
$1A00-$1AFF, banks $40-$43the Arcade Card, when fitted (arcade.rs)the same
$18C0-$18C7the 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:

  • BoardPins arrives with each call (the base board’s sockets.rs), so there is no bind; sync_irq is the reference’s _bus_irq, _adpcm_irq and _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 a DetachedPins (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 what audio_sources hands 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-$18C7 are asked of pins.card when it is a SystemCard (the reference’s unit keeps the card PcEngineCd built 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 bram image longer than 2 KiB is cut (the reference’s slice assignment would grow the RAM).

Structs§

CdUnit
CD RAM, backup RAM, the registers, the SCSI bus and the CD-DA player.
UnitSwitches
The reference’s CdUnit class 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