Module sockets

Module sockets 

Source
Expand description

The sockets: narrow traits an add-on crate implements to plug into this board (sockets.py; the reference’s docs/sockets.md).

pcenginecd-rust and supergrafx-rust depend on this crate and never copy from it, as the reference’s add-ons pin the Python board. Test-only fakes for each socket live in src/fake_devices.rs; the base board implements only what it uses.

Numbering follows docs/sockets.md.

  1. CardSlot / Card the HuCard slot
  2. PortDevice the expansion port (EXT BUS)
  3. PageHandler one decode for every bus master (the page table is in pagetable.rs)
  4. BoardPins::hold bus timing: wait states go through the board
  5. PortDevice::catch_up clock domains: run up to mclk, callable inside an access
  6. IrqLine interrupt levels, one bit per source, wired-OR
  7. PixelPath per-line 9-bit pixels between the VDC(s) and the VCE
  8. VideoTiming one record per line
  9. AudioSource a source with a changeable rate and gain
  10. ResetKind reset events
  11. ControllerPort the pad port
  12. Instances Vdc, Vce, Psg hold no module state

Differences forced by Rust:

  • BoardPins is handed to a device at every call, not once by bind. The reference’s devices keep the board’s IRQ2 line and its hold callable; a Rust device cannot hold a reference into the board that owns it, so each access, catch_up and reset gets &mut BoardPins: the IRQ2 line, hold, the VDC instances (the SuperGrafx’s VPC decodes their page and steers to either), the opcode of the instruction being run (the VPC steers only ST0-ST2) and, for the port device and the pixel path, the card in the slot (a CD unit answers a Super System Card’s id registers from the card). The reference’s add-ons reach the same things through references they were built with.
  • A device that is two things in the reference is one trait object here. The reference’s VideoPage and Vpc share state by reference (one claims the VDC pages, the other is the pixel path); here PixelPath may also claim pages. The CD unit’s CD-DA and ADPCM players, appended to board.audio_sources in the reference, are answered by PortDevice::audio_sources, mixed after the PSG and before the board’s own list, which is the reference’s order (PSG, CD-DA, ADPCM).
  • Save states cannot walk an object graph: every socket trait carries DeviceState (bytes out, bytes in, an identity for media), which the reference gets from register_package.
  • Pad input: the reference’s host keeps the pad object and sets pad.pressed; here the board owns the device, so ControllerPort has set_pressed(port, mask).

Structs§

BoardPins
What the board hands a card, a port device or the pixel path with every call.
CardSlot
The slot. Empty is a real state: it answers $FF, does not ground /CD, and the I/O port’s CD-sense bit follows the expansion port, not the slot (docs/sockets.md).
DetachedPins
A BoardPins with no board behind it: for a device’s own tests (this crate’s and an add-on’s), which call its read, write and catch_up directly.
DirectPath
VDC 1 straight into the VCE.
IrqLine
A wired-OR level with one bit per source (never a max).
VdcAccess
The VDC accesses of one decode, for the board’s wait (issue 0004).
VideoTiming
One record per line, handed to anything that mixes or captures video.

Enums§

ResetKind
The PC Engine has no reset button or reset instruction on the console itself; a CD unit is reset by a register write inside the add-on (docs/sockets.md). Button exists for the Duo/Shuttle-class consoles (unverified).

Traits§

AudioSource
A mixer input with a changeable rate and gain. The PSG is board-owned and first in the list; the CD adds CD-DA (44.1 kHz) and ADPCM (variable).
Card
A HuCard: standard ROM, SF2, Populous, Tennokoe, a System Card, …
ControllerPort
What plugs into the pad port: a 2-button pad, a multitap, a 6-button pad, a mouse.
DeviceState
What a save state needs of a socket’s device (the reference walks the object graph).
PageHandler
Anything a range of 256-byte pages can be claimed by.
PixelPath
Where the VDC(s) meet the VCE. The default is VDC 1 straight into the VCE; the SuperGrafx’s VPC replaces it, mixing two VDC lines. Line granularity, not dot.
PortDevice
The EXT BUS device: A0-A20, D0-D7, /RD, /WR, IRQ2, audio in, K7 (I/O port bit 7).