# Video: the HD46505, text, PCG and graphics ## The CRTC SX1 p. 76 names the part **HD46505-SP** (Hitachi), programmed through 1800h (register number 0-17) and 1801h (data); "of the 18 registers, 12 actually matter" on the X1. HIT87's cross-reference lists the HD46505R/HD46505S beside the HD6845R/HD6845S and Motorola's MC6845 (HIT87 contents, p. 139 and the cross-reference table); the "-SP" is the S variant in a plastic package (HYPOTHESIS by Hitachi's suffix convention; check HIT87's ordering table). The S variant is the one the CPC calls **type 0** (cpc-python crtc-6845.md: HD6845S), so the CPC's measured type-0 counter rules are the nearest open evidence for the X1's CRTC. MAME's `x1` boot (OBSERVED, docs/mame-oracle.md) writes R0-R13 in order at 2.28 ms: R0 = 37h (55), R1 = 28h (40), R2 = 2Dh, R3 = 34h, R4 = 1Fh (31), R5 = 02h, R6 = 19h (25), R7 = 1Ch, R8 = 00h, R9 = 07h, R10 = 60h, R11 = 07h, R12/R13 = 0000h: a 40-column, 25-row, 8-line character screen of 56 characters by 32 rows plus 2 lines (OBSERVED: what the IPL programs on MAME's model; the real IPL is the same ROM, so these are firmware facts, not CRTC behaviour). Uses beyond plain timing (SX1 ch. 1): - 40/80 columns: 1A02h bit 6 (0 = 80, 1 = 40) with matching CRTC values (p. 76). - Superimpose scroll: R5 rewritten plus 1A02h bit 4 = 0 (p. 76). - The turbo's 400-line mode and underline mode need 1FD0h as well (p. 76). - Displaying more than 80 x 25 by reprogramming R1/R6 (ch. 1 "2000 文字" discussion). ## Text, attributes, PCG - Text VRAM 3000h-37FFh (character codes) and attributes 2000h-27FFh, in I/O space (SX1 p. 27); 2048 bytes each, of which 2000 are shown at 80 x 25 (SX1 ch. 1). - Characters come from the CG ROM (8 x 8 ANK: `fnt0808.x1` in MAME's set; the 8 x 16 `ank.fnt` for the turbo) or the **PCG**, three planes of 256 user characters at 15**h/16**h/17**h (SX1 p. 15). Plain X1 PCG access is the notorious one: by common knowledge the row within the character comes from the CRTC's raster position at the moment of the access, so programs write PCG data in step with the display (HYPOTHESIS until SX1 ch. 2 is read for the rule); the turbo adds a fast mode addressing the row by the low nibble (1FD0h bit 5). This timing dependency is the X1's hardest video behaviour (U7). - Kanji on the turbo: the text VRAM byte is the kanji ROM's low address, with the attribute side carrying the rest (SX1 p. 27, ch. 3). ## Graphics Three 16 KB planes (BLUE, RED, GREEN) in I/O space from 4000h, 640 x 200 or 320 x 200 (the address formula `4000h + X/8 + (Y and 7) x 2048 + (Y / 8) x 80` for BLUE in 640 mode, x 40 in 320 mode: SX1 p. 28). The memory order follows the CRTC's MA/RA (raster address in the upper bits), so the layout is a consequence of wiring MA and RA to the VRAM address. Palette (10**h-12**h, 8 colours from 3-bit codes), priority (13**h), and on the turbo Z the 4096-colour modes (1FB9h-1FC5h). Simultaneous plane writes: 1A02h (SX1 p. 28). ## The chip rule (decision 4) A 6845 is now wanted by four family boards: cpc-python (HD6845S/UM6845R/MC6845 types, in-board by its decision 2), bbcmicro-python (proposes `crtc6845-python`, its decision 2), ibmpc-python (MDA/CGA, supports `crtc6845-python`, its decision 2) and this one. **Proposal: support the extraction of `crtc6845-python`** with the CRTC as a per-type rule table (the CPC's types 0-2 as rows, the HD46505S as a row equal to or close to type 0), the X1 adding no new type unless HIT87 shows a difference. The X1 needs: MA/RA outputs per character clock, DISPEN, HSYNC/VSYNC, and the cursor; the PCG timing needs the raster address readable by the board at any moment of a CPU access. ## Unknowns - U3 The character clock per mode (MAME's 894.88 kHz on `x1` is a 40-column figure? The 14.31818 MHz-derived dot clocks are not stated in the parts of SX1 read.) - U7 PCG write timing on the plain X1: exactly which raster line an access lands on. - U8 HD46505S vs the CPC's type-0 rules: no X1-specific measurement found.