# The LCD and its controller ## What the TRG says (DOC) - 240 x 64 pixels, "Super-twist", 8 lines of 40 characters; each character a 6 x 8 cell; full IBM PC extended character set (its Appendix B); a virtual 80 x 25 MDA page; PC-BIOS pixel set/reset for graphics; software contrast; block or underline cursor; no text attributes, no cursor sizes (TRG 2.1.4, 2.8, 3.1.2). - "It is driven by a set of LCD screen drivers which are controlled by a graphics LCD controller ... The controller also uses a dedicated Video RAM chip and a character generator ROM" (2.1.4). The TRG never names the controller. - Software writes the MDA buffer at B0000; "any screen refreshing must be invoked by the application" (3.7): Int 61h Fn 12h copies the buffer to the controller; Fn 1Fh makes the BIOS refresh on key presses and/or ticks ("Refresh on NMIs state", "Refresh on keys state"); Fn 0Eh picks Static PC, 40 x 8 or Tracked windows (3.3.1, 3.7). Video modes 7 (text), 8, 9, 0Ah (graphics, all 240 x 64 on the Portfolio) (3.7). So the board does **not** scan the MDA buffer: the picture is whatever the firmware last wrote into the controller's own RAM through its ports. ## Which controller: HD61830, not T6A43 (C2) The brief for this Phase 0 named a T6A43. No source consulted ties a T6A43 to the Portfolio. The evidence for an HD61830-family part: 1. **The firmware's own command stream (OBSERVED in MAME, but the bytes are DIP's).** At boot the BIOS writes instruction codes to port 8011 and data to 8010: `00` <- `19`, `01` <- `75`, `02` <- `27`, `03` <- `3F`, `04` <- `07`, `08`/`09` <- `00`, `0A`/`0B`, then `0C` (write display data) repeatedly. Against the Hitachi HD61830 sheet (`reference/docs/hitachi-lcd-1992.pdf`, book pp. 431-434, DOC): `00` mode control, `01` character pitch = (Vp-1)<<4 | (Hp-1), so `75` = 8 x 6 (the TRG's 6 x 8 cell); `02` number of characters HN-1, so `27` = 40 (240 / 6); `03` number of time divisions Nx-1, so `3F` = 64 (the 64 rows); `04` cursor position Cp-1, so `07` = row 8 (the underline); `08`/`09` display start address; `0A`/`0B` cursor address; `0C` write display data. Every value matches the panel the TRG describes. 2. MAME's Portfolio uses its "Hitachi HD61830B LCD Controller" device with an external 32 KB character ROM `c101783-001a-01.u3` (`-listxml`, OBSERVED). The register interface is therefore HD61830's (RS selects instruction or data: port 8011 is RS = 1, 8010 is RS = 0). Whether the part is an HD61830 or an HD61830B is U7: the data book's "Differences Between Products" (book p.17, DOC) gives the HD61830 an internal oscillator, 1.1 MHz and a largest screen of **64 x 240 dots at 1/64 duty** (exactly the Portfolio's panel), and the HD61830B an external oscillator, 2.4 MHz and 128 x 480 dots, with different pins 6, 7 and 9. A board photograph (the package marking) decides it. ## What the HD61830 gives the board (DOC, Hitachi) - Character mode and graphic mode; up to 4096 characters or 512 K dots of external RAM; an internal 7,360-bit character generator (160 5 x 7 + 32 5 x 11 characters); "use of extended ROM allows 8 x 16 (256 characters max.)". The Portfolio's full 256-character IBM set with 6 x 8 cells needs the external ROM (TRG's "character generator ROM"). - Thirteen data registers behind a 4-bit instruction register; a busy flag on DB7 when reading with RS = 1; read display data, set/clear bit (the BIOS's pixel calls are the likely users: HYPOTHESIS). - Graphic mode for Int 10h modes 8-0Ah: 240 / 8 = 30 bytes a row x 64 rows (HYPOTHESIS for how the BIOS sets it up; read the BIOS's mode-set path). ## For the build - `lcd.py`: the HD61830 command set (registers, RAM, cursor, blink, busy flag), character and graphic rendering to a 240 x 64 1-bit frame, the external CG ROM as a player-supplied file. The HD61830 stays in the board (chip rule: no other family board uses it). - Unknowns: U7 the part; U8 the controller's clock and so its frame rate and busy time (MAME shows 72 Hz, OBSERVED; no document gives the Portfolio's figure); U9 the CG ROM's wiring (which address lines carry the line code; MAME's 32 KB image vs the 4 KB a 256 x 16-line map needs); U10 the contrast register's address and range; U11 whether the display RAM is 2 KB or more (the "dedicated Video RAM chip"). - The picture is checked against MAME's snapshot of the banner (mame-oracle.md) first; no hardware photograph is pinned (a pinned photo of a running unit would be tier 1 for layout, U12).