# K1GE and K2GE: the video The K1GE (NGP) and K2GE (NGPC) are SNK's graphics engines with the LCD controller. They stay in this board (the chip rule: no other family machine uses them). Sources, all weak: **T11** = Gollum's tech-11.txt (2000), **JT** = Judge's ngpctech.txt (c. 2000), **ares** = ares `6e67c8b` `ares/ngp/kge/` (ISC, readable, tier 5: OBSERVED), **MAME** = MAME 0.285 run as a closed box. **No SNK document and no hardware capture is in hand** (ares's comments cite "the dev manual", an SNK development manual this Phase 0 did not find: U1 in the handoff brief). ## Screen and timing - 160 x 152 visible, 515 clocks per line at 6.144 MHz, 199 lines (MAME's screen entry; ares steps 515 per line and wraps after `io.vlines`, register 8006, default 198, which ares refuses to set below 152: "it is unknown if this value can be set below the height of the LCD screen"). - Raster position readable at 8008 (horizontal, ares: hcounter bits 2-9) and 8009 (line; Metal Slug 1st Mission polls it against 7E and 80, JT). - Interrupts: vertical blank (and a horizontal one, ares `hblankEnableIRQ` with "todo: should be 0") through 8000's enable bits (MAME: the BIOS writes `8000 = C0`). ## Registers (8000-87FF) | Address | What | Source | | --- | --- | --- | | 8000 | interrupt enables (bit 7 vblank, bit 6 hblank) | ares; MAME log `K 8000 C0` | | 8002-8005 | window: left x, top y, width, height (outside it, one colour) | T11, JT, ares | | 8006 | lines per frame (vlines) | ares | | 8008, 8009 | raster h and v counters | ares, JT | | 8010 | status: bit 6 vblank active, bit 7 "character over" | ares | | 8012 | bits 0-2 colour outside the window, bit 7 negative display | ares; the BIOS writes it first (MAME log) | | 8020, 8021 | sprite plane scroll x, y | T11, ares | | 8030 | plane priority (bit 7: which scroll plane is in front) | T11, ares | | 8032-8035 | scroll plane 1 x, y; plane 2 x, y | T11, ares | | 8100-8117 | monochrome palettes: 3-bit shades, sprite 2x4, plane1 2x4, plane2 2x4 (entry 0 of each is transparent, writes ignored in ares) | T11, JT, ares | | 8118 | K2GE background: bits 0-2 colour, bits 6-7 mode (ares: only bit 0 of the mode is honoured; "the dev manual says only background.mode = 0b10 enables background.color", Ogre Battle sets 0b00) | ares dac.cpp, memory.cpp; JT | | 8200-83FF | K2GE colour palettes: 12-bit BGR (`0BGR`, 4 bits each), sprite 16x4, plane1 16x4, plane2 16x4, then background and window entries and the compatibility palettes at C0-FF | T11, ares color.cpp | | 8400, 8402 | the power LED: control and blink frequency | ares | | 87E2 | K2GE bit 7: colour mode (0 native, 1 monochrome-compatible) | ares | | 87FE | input port register (reserved; ares returns 3F) | ares | ## Memory | Range | What | Source | | --- | --- | --- | | 8800-88FF | 64 sprites x 4 bytes: tile low 8 bits; flags (ares: bit 7 H flip, 6 V flip, 5 mono palette, 4-3 priority, 2 H chain, 1 V chain, 0 tile bit 8); x; y | ares memory.cpp; T11 gives the second byte as `HVBPPPPT` (palette in bits 4-1), copied from its map entry: C5 | | 8C00-8C3F | K2GE sprite palette numbers, 1 byte per sprite | T11, JT | | 9000-97FF, 9800-9FFF | the two scroll maps, 32 x 32 entries of 2 bytes: tile 9 bits, H/V flip, palette (4 bits colour / 1 bit mono) | T11 (writes "32 x 20"; 0x800 bytes is 32 x 32: C4), ares | | A000-BFFF | 512 tiles, 8x8 at 2 bits per pixel, 16 bytes each | T11 | ## Rendering - Layers: background colour, sprites with priority 1, the back plane, sprites with priority 2, the front plane, sprites with priority 3, then the window mask (ares dac.cpp order; plane priority from 8030). - Sprite chaining: a sprite's position is relative to the previous sprite's when its chain bit is set (ares sprite.cpp), so multi-tile objects move by one entry. - Line buffering: "the Neo Geo Pocket attempts to buffer a line of sprites in advance ... all 64 sprites on the same line" unless VRAM is written during display ("character over", not emulated in ares, "this information is not currently known"): U2. - The NGPC runs monochrome cartridges in a compatibility mode: the BIOS fills the compatibility palettes (ares colorMode 1, entries C0-FF), and the game sees K1GE registers. The cartridge header's byte 0x23 (00 mono, 10 colour) is what the BIOS reads (JT; census.md: 126 colour headers, 1 mono in the NGPC set). ## What the board needs (milestones V1-V3 in the handoff brief) Dot-exact rendering of a line from the register and VRAM state at the dot each write lands (writes logged with their clock), so mid-line scroll and palette changes show; the character-over flag; the monochrome shade table (3-bit, ares: 7 - level over 16 steps, a guess at the LCD's response: tag HYPOTHESIS); the K2GE's 12-bit colour to the host as-is (no LCD colour correction in the specification; a host filter).