# Video: two HuC6270s, the KING, the Rainbow and the HuC6261 Keys as in [start-here.md](start-here.md). The KING has its own page, [king.md](king.md). ## The stack Five pixel sources meet in the HuC6261 mixer (T15 "HuC6261"): **VDC A** (HuC6270 background and sprites), **VDC B** (the same), **KING BG0-BG3** (four backgrounds), and the **Rainbow** (decoded motion picture). Each source's pixels are palette indices or direct colours; the HuC6261 applies per-layer palette offsets, priorities, chroma key and "cellophane" blending, and outputs YUV to the video encoder. **The PC Engine's VCE (HuC6260) is not in the PC-FX**: the HuC6261 takes its place (palettes in YUV, not RGB). ## HuC6270 x2 ("7up") - The same VDC as the PC Engine's (T15: "The PC-Engine used one 7up for its video"): registers 00-13h (MAWR, MARR, VRR/VWR, CR, RCR, BXR, BYR, MWR, HSR, HDR, VSR, VDR, VCR, DCR, SOUR, DESR, LENR, DVSSR) as HUD and pcengine-python's `vdc/` know them. - **Ports:** register select at 400h/500h, status read at 400h/500h, data at 404h/504h as 16-bit accesses (T15). The chip has a 16-bit CPU data bus and an `8/16` pin choosing 8- or 16-bit access (PFI's HuC6270 pinout: D0-D15, A0-A1, `8/16`, `/BUSY`); the PC Engine uses 8-bit access through the HuC6280's ST0/ST1/ST2 bytes. The PC-FX's 16-bit wiring is inferred from T15's halfword ports (HYPOTHESIS until a board photo or a test shows the `8/16` pin's level; U21). - **Pixel output** VD0-VD7 plus SP8G (the sprite/background flag) go to the HuC6261, which takes the 8 bits as a palette index with a per-VDC offset (HuC6261 register 04h). T15's register 00h bits 6-7 select 16 or 256 colours for VDC backgrounds and sprites: with two VDCs at 16 colours each, or (HYPOTHESIS, U21) the two VDCs combined as extra bits for 256 colours. - **Timing:** the VDC's dot clock and sync come from the HuC6261 (T15: dot clock 5 or 7 MHz, 256 or 320 wide; 262/263 lines or interlaced). pcengine-python's VDC takes its horizontal timing from the PC Engine's machine module (`HSYNC_CLOCKS`): the shared core needs that as a parameter (chip-rule.md). - **VRAM** per VDC: 64 KB (32K words) as on the PC Engine (HYPOTHESIS; T15 does not say; the main board's SRAM data sheets in PFI would tell: U21). - Interrupts: VDC A on PC-FX level 12, VDC B on 14 (T15 "Interrupt"). ## HuC6261 (DOC: T15 "HuC6261"; LIB `tetsu.h`) - Ports: register select 300h, status 300h (current raster in bits 5-13, interlace field bit 14, "displaying" bit 15), data 304h. - Register 00h, screen mode: line count (263, 262, interlaced, unknown), internal or external sync, **dot clock ~5 MHz (256 px) or ~7 MHz (320 px)**, VDC BG/sprite colour depth, and display enables for VDC BG, VDC sprites, KING BG0-3 and the Rainbow. - Palette: 512 entries? (the select register 01h's width is not given: U8) of 16 bits: Y in bits 15-8, U in 7-4, V in 3-0; written through 02h with auto-increment (T15 swaps the read/write labels between the register table and the text: 02h is "Palette data (R)" in the table but "Write only" in the text, C9). - Per-layer palette offsets (04h-07h, upper 7 bits), priorities (08h-09h, 3 bits per layer), chroma key ranges for Y, U, V (0Ah-0Ch: max in the high byte, min in the low; min > max disables), the constant colour (0Dh), cellophane control (0Eh: a coefficient set per layer, enable, front or back), sprite-bank cellophane select (0Fh), three coefficient pairs (10h-15h). - **Cellophane** (T15's formula): Y = (AY/8) x frontY + (BY/8) x backY, and for U and V the same around 80h, clipped at FFh; changes to 0Dh-0Fh take effect at the next line. The exact integer arithmetic (when the /8 truncates) is U9. - **Lines:** 262 or 263 (LIB: "263 lines, a little flickery, but less cross-talk"), interlace with a field bit. Exact dot clocks (21.47727 / 4 = 5.37 MHz and / 3 = 7.16 MHz by analogy with the PC Engine's VCE: HYPOTHESIS, U8), line length and visible area are not documented. ## HuC6271 Rainbow (DOC: T15 "HuC6271 (RAINBOW)": very thin) - "MotionJPEG processing chip". Data is placed into KRAM and fed to the Rainbow by the KING's Rainbow transfer (KING registers 40h-44h: enable, raster interrupt, KRAM address, start raster 0-261, block count 0-31, "1 block == 16 dots?"). - Ports 200h-214h: horizontal scroll (200h, word), control (204h) and four unknown halfword registers: **"More information needed!" for every one** (U7). - The stream: JPEG-like markers (FFFFh first block with two 64-byte quantisation tables, FFF8h following blocks, FFF0h/FFF3h unknown, "run length?"); "Huffman table has not been found yet ... a sign of its own compression" (U6). - Its palette offset is HuC6261 register 07h and its layer priority 08h bits 8-10: so its output can be palette-indexed (and, T15's BG modes suggest, direct YUV: U6). **There is no public description of the Rainbow's decode.** The only working decoders known are in emulators: Mednafen (GPL-2.0, closed) and MAME's `video/huc6271.cpp` (BSD-3-Clause line, Angelo Salese; whether it decodes anything is unknown: MAME's PC-FX is "preliminary" and the file was not opened). Options in the brief's open decisions: reverse-engineer the format from disc data ourselves (the streams are on the Redump discs; known JPEG and JPEG-like codecs give the shape), or read MAME's BSD file as a permitted source. HYPOTHESIS until then: an 8x8 DCT codec with fixed Huffman tables and per-stream quantisation, outputting YUV 4:2:x blocks 16 dots wide.