Module vpc

Module vpc 

Source
Expand description

The HuC6202 video priority controller (VPC): the SuperGrafx’s pixel path and its register block (vpc.py).

[hw: sgxtech, “Video Priority Controller”] The VPC

  • mixes the 9-bit pixel buses of VDC 1 and VDC 2 and hands the result to the VCE (Vpc::mix, the board’s PixelPath socket 7: one row per VDC, one row back);
  • keeps two window widths and four 4-bit (enable, enable, priority) groups, one per window area;
  • steers ST0-ST2 to VDC 2 when $0E bit 0 is set (Vpc::st_to_vdc2, used by VideoPage);
  • decodes the video chip area $FF:0000-03FF (VideoPage, with the compat switch).

A VDC row value is 9 bits: bit 8 sprite, bits 7-4 palette, bits 3-0 colour; a colour of 0 is transparent. “Priority between backgrounds and sprites is managed internally to the VDC”: the VPC sees only the bit-8 sprite flag and the transparency, so it cannot tell a high-priority sprite from a low one.

Everything the sources do not settle is a named switch with a provisional default and its tier, so a later judge changes one line (the reference’s docs/m6-record.md lists them as U/C entries).

Differences forced by Rust:

  • VideoPage is the board’s PixelPath and owns the Vpc. The reference has two objects that share state by reference: Vpc is the pixel path, VideoPage claims the pages and holds the VPC and both VDCs. Here one trait object is both (the base board’s sockets::PixelPath may claim pages), VideoPage::vpc is the VPC, and the VDCs are pins.vdcs, handed in with every access. Each access steered to a VDC is made with pins.vdc_read / vdc_write, so that the base board’s wait reaches it (pcengine-python issue 0004: where the reference’s VDC calls the board’s _serve_vram from inside the access, the base board serves the chip after the access stops and makes it again).
  • store_immediate is pins.opcode: the reference’s page calls back into the SuperGrafx object, which reads the core’s opcode; here the board hands the opcode to the device with each access (and 0 with no CPU, where the reference answers False).
  • The named switches are fields (priority_labels, window_origin, window_off_at_or_below, VideoPage::st_steers_in_compat) where the reference has class attributes; PRIORITY_LABELS’ two strings are the enum PriorityLabels, and WINDOW_ORIGIN’s dict by dot divider is WindowOrigin.
  • Save states: DeviceState (bytes out, bytes in), where the reference’s state walks the object graph. As there, the registers, the shadows, the write log and the position of the compatibility switch are in a state; the named switches are the system’s own.
  • Reset: PixelPath::reset (called by Board::reset) is what the reference’s SuperGrafx.reset does after the board’s: a power-on reset resets the VPC.

Structs§

VideoPage
The video chip area, $FF:0000-03FF (four 256-byte pages): what the VPC decodes.
Vpc
Registers, ST steering and the mix. mix(timing, rows) is the PixelPath’s.
WindowOrigin
U-SGX1: the window origin per dot clock (Vpc::window_origin), by the dot divider.

Enums§

PriorityLabels
C-SGX1: which reading of the 2-bit priority codes (Vpc::priority_labels).

Constants§

COLOUR
bits 3-0: 0 is transparent
PRIORITY_A
bits 7-4 window 2 only, bits 3-0 windows 1 and 2 overlapping
PRIORITY_B
bits 7-4 no window, bits 3-0 window 1 only
SPRITE
bit 8 of a VDC row value: the pixel came from a sprite
ST_OPCODES
[hw: HuC6280 hardware manual] ST0, ST1, ST2 are opcodes $03, $13, $23.
ST_STEER
bit 0: ST0-ST2 go to VDC 2
WINDOW1_LSB
WINDOW1_MSB
WINDOW2_LSB
WINDOW2_MSB