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’sPixelPathsocket 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-ST2to VDC 2 when$0Ebit 0 is set (Vpc::st_to_vdc2, used byVideoPage); - 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:
VideoPageis the board’sPixelPathand owns theVpc. The reference has two objects that share state by reference:Vpcis the pixel path,VideoPageclaims the pages and holds the VPC and both VDCs. Here one trait object is both (the base board’ssockets::PixelPathmay claim pages),VideoPage::vpcis the VPC, and the VDCs arepins.vdcs, handed in with every access. Each access steered to a VDC is made withpins.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_vramfrom inside the access, the base board serves the chip after the access stops and makes it again).store_immediateispins.opcode: the reference’s page calls back into theSuperGrafxobject, which reads the core’sopcode; here the board hands the opcode to the device with each access (and 0 with no CPU, where the reference answersFalse).- 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 enumPriorityLabels, andWINDOW_ORIGIN’s dict by dot divider isWindowOrigin. - 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 byBoard::reset) is what the reference’sSuperGrafx.resetdoes after the board’s: a power-on reset resets the VPC.
Structs§
- Video
Page - 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. - Window
Origin - U-SGX1: the window origin per dot clock (
Vpc::window_origin), by the dot divider.
Enums§
- Priority
Labels - 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
- WINDO
W1_ LSB - WINDO
W1_ MSB - WINDO
W2_ LSB - WINDO
W2_ MSB