Expand description
The drive’s SCSI-class controller: bus signals, phases, the REQ/ACK handshake, the commands
(scsi.py).
The CD unit’s controller is not emulated as a microcontroller (there is no second CPU on this
machine); it is a bus state machine that the System Card drives through $1800-$1802 and
$1808 [hw: pcetech 8; emu: Mesen2 PceScsiBus.cpp, Geargrafx scsi_controller.cpp,
Mednafen scsicd.cpp, ares pcd/scsi.cpp, MAME pce_cd.cpp all do the same]. Everything
here is time in master clocks (21.477272 MHz); the unit calls run_to(mclk) before
register accesses and the bus then runs its own timers up to that instant.
Signals ($1800 read): D3 I/O, D4 C/D, D5 MSG, D6 REQ, D7 BSY. Phases and the signals they
hold:
| phase | BSY | C/D | I/O | MSG | REQ | what the CPU does |
|---|---|---|---|---|---|---|
| bus free | writes $1800 (selects the drive) | |||||
| command | 1 | 1 | 1 | writes command bytes to $1801 | ||
| data in | 1 | 1 | (1) | reads bytes from $1801/$1808 | ||
| status | 1 | 1 | 1 | (1) | reads the status byte | |
| message in | 1 | 1 | 1 | 1 | (1) | reads the message byte |
| busy | 1 | waits (an audio command in progress) |
Every byte is a REQ/ACK handshake: the drive raises REQ, the CPU sets ACK ($1802 bit 7),
the drive drops REQ, the CPU drops ACK. IRQ2 sources ($1803 bits): data-in 0x40 and
status/message 0x20 are REQ held in those phases (CdUnit turns the levels into IRQ2).
The timings are ScsiSwitches (the reference’s class attributes), all provisional (U8): the
only measurements of this hardware are Shadoff’s seek table (tier 3) and the test ROMs
Mesen2’s author ran on a real console (tier 5, claimed in his source comments).
Differences forced by Rust:
- The bus owns the audio player (
bus.cdda), where the reference’s bus and unit hold the same object; the player’son_good_statuscallback iscdda.good_status_due, answered here right after the player ran (run_cdda). - The
irqcallback into the unit is a list,irq_changes, of(mask, level)in the order the reference would have called; the unit applies it after each call into the bus (nothing the callback reads can change in between). - The command list
cmd, the bufferoutand the ports are bytes; a sector with no disc in the drive (the reference asserts) reads as zeros.
Structs§
- ScsiBus
- Signals, phase, timers and the command set.
irq_changescollects (mask, level) when the REQ-held-in-a-phase conditions change (mask 0x40 data in, 0x20 status/message). - Scsi
Switches - Timing (master clocks), provisional; tier in the comment. The reference’s
ScsiBusclass attributes, with its defaults.
Enums§
Constants§
- ASC_
INVALID_ COMMAND - ASC_
LBA_ OUT_ OF_ RANGE - ASC_
MEDIUM_ NOT_ PRESENT - CHECK_
CONDITION - CMD_
AUDIO_ END - CMD_
AUDIO_ START - CMD_
PAUSE - CMD_
READ - CMD_
READ_ SUBQ - CMD_
READ_ TOC - CMD_
REQUEST_ SENSE - CMD_
TEST_ UNIT_ READY - GOOD
- SENSE_
ILLEGAL_ REQUEST - SENSE_
NOT_ READY