KN7000 Display Subsystem
KN7000 Display Subsystem
The KN7000 draws its UI to an LCD through the MILK toolkit’s graphics layer:
palette-indexed bitmaps and text, composited by a family of blit routines and
handed to the LCD controller. This page ties the hardware (the LCD controller
and the framebuffer it scans; see LCD hardware) to the
firmware (the drawing functions recovered by name in the
disassembly). Addresses are decoded from
kn7000_program.rom; work-RAM globals are in the 0x50000000 region.
Panel type: colour vs 2-bit grayscale
The MILK graphics layer supports more than one LCD panel type, and the firmware
keeps the type in a work-RAM halfword at 0x50007578 (accessed by GetColorMode /
SetColorMode). Two predicate functions read it — decoded straight from their
source:
GetColorMode: movhu (0x50007578), d0 ; ret # the panel-type value
CheckColorLcd: return (colormode == 0) # 0x48421D70
Check2BitLcd: return (colormode == 2) # 0x48421D82
So the panel-type enum is 0 = full-colour, 2 = 2-bit (4-level)
grayscale (value 1 is a further mono/other variant). A second halfword at
0x5000757A (GetLcdMode / SetLcdMode) holds a related mode flag. The
firmware branches on these throughout the graphics layer — e.g. it provides a
ConvPaletteMono4 routine to fold the colour palette down to 4 grey levels for
the 2-bit panel. The KN7000 itself has a 640×240 colour panel. Which instrument
reports the 2-bit model is not established (the model word is 2 when the ID byte at
0x9CC00000 is 0x04 and TgStrapProbe is not 3); in that mode the firmware still
works with 640 × 240 frames.
What selects mode 2 is a model word at 0x50005218: when it is 2, the start-up code
at 0x48414328 sets both the colour mode and the LCD mode to 2. In that mode
SetPaletteRGB also maps each palette entry to one of four grey levels
(ColorToMono4Level, 0x4842DB3C, by squared RGB distance kept in 16 bits, so not
always the nearest) and stores the level 0..3 in a 256-byte table at 0x50122CAC, which the
screen output and CaptureLcd read back through GetPaletteRGB4. The screen capture
follows the mode: a 640 × 240 4-bpp BMP (76,918 bytes) in mode 2, a 24-bpp one
(460,854 bytes) on the colour panel.
Palette-indexed bitmaps
UI artwork is stored as headerless palette-indexed bitmaps (the same design as the KN5000 — see Raw UI bitmaps). Pixels are raw palette indices, row-major, at 1, 2, 4 or 8 bpp. The blit API has one routine per source format, which is how the depths are known:
| Function | CPU addr | Source | Skips 0xF7 |
|---|---|---|---|
DrawBitmap |
0x48423B56 |
bitmap-table entry, 8 bpp | yes |
DrawBitmapFast |
0x48423C88 |
bitmap-table entry, 8 bpp, rows copied whole | no |
DrawIcons |
0x48423DCD |
icon-table entry, always 24 x 24 at 4 bpp (nibble n -> index n or 0xF0+n) | no |
DrawFrameSP |
0x48423EFB |
frame-table entry, 8 bpp; 0xF6 = the caller’s colour | yes |
DrawBitmapSP |
0x484240A4 |
caller’s pointer, 8 bpp | yes |
DrawBitmapSPFast |
0x4842429E |
caller’s pointer, 8 bpp, rows copied whole | no |
DrawBitmapSPFast4 |
0x484243CD |
caller’s pointer, 2 bpp; loads 4 colours at a caller-chosen palette index | no |
DrawBitmapSPFast16 |
0x484245BC |
caller’s pointer, 4 bpp, drawn as indices 0x20..0x2F; loads those 16 colours | no |
DrawBitmapSPFast256 |
0x48424784 |
caller’s pointer, 8 bpp; loads palette entries 0x20..0xCF first | no |
DrawBitmapSP2 |
0x484248DE |
caller’s pointer, 1 bpp, foreground and background colour | no |
DrawBitmapFile |
0x48424A9F |
Windows BMP in memory, 1/4/8 bpp, pixels + 0x20; loads palette 0x20..0xCF | no |
DrawBitmapFileEx |
0x48424CC8 |
the same BMP, but it only loads the palette and marks the rectangle dirty | - |
Draw2BpFile |
0x4842829F |
the same BMP; a second copy of DrawBitmapFile that cuts images at 240 rows |
no |
DrawJpegFile |
0x48424EBD |
JPEG, decoded straight to direct-colour picture pixels | no |
DrawJpegFileR |
0x48424F7D |
the same, with rounded corners (8 pixels per corner keep the background) | no |
Only DrawBitmap, DrawBitmapSP and DrawFrameSP skip pixels of index
0xF7 (CL_Transparent, the KN5000’s transparent colour, which the
extracted 8-bpp icons use heavily); the SP in the other names does not mean
transparency. None of the blitters clips horizontally: an image wider than
640 - x runs on into the next framebuffer row. The table and pointer
blitters stop at the first row at y >= 240; the JPEG path has no such stop.
Every routine has a fully labelled and commented listing in the disassembly
(annotations/gfx_draw.ann and annotations/gfx_bmpfile.ann, rendered into
src/program.s). Despite its name, Draw2BpFile has nothing 2-bit about it: it takes
1, 4 and 8 bpp and writes the 8-bit plane like DrawBitmapFile. Its only caller is the
hidden DEBUG TOOLS > BITMAP LOAD screen; the “2Bp” most likely names the 2-bit panel
mode above.
Windows BMP files
Pictures loaded from disk or SD card and the slide-show pictures are BMP or JPEG files,
and the homepage picture is a BMP; all are kept whole in memory. Every BMP user in the
firmware parses them
with one routine, GetBitmapInfo (0x48421DE1, 13 call sites). It accepts only
"BM" files with the 40-byte BITMAPINFOHEADER, one plane, 1, 4 or 8 bits per pixel,
at most 256 colours and no compression (BI_RGB); it copies up to 1 KB of colour table
and returns a pointer to the pixels. It never checks the width, the height, bfSize, or
that the colour table and pixels lie inside the file.
DrawBitmapFile loads the file’s colours 0..0xAF into palette entries
0x20..0xCF and adds 0x20 to every pixel. The rest of the palette belongs to the
UI, so a picture can use 176 colours, not 256. ConvertBitmapFile
(0x48421E88) prepares a file for that: it repacks the BMP in place inside a given size
(the colour table straight after the headers, the pixels straight after it) and, for an
8-bpp file whose repacked colour table has more than 176 entries (every 8-bpp homepage
picture), calls BmpReduceColors (0x4842215B). That
routine counts how often each colour index is used, sorts the palette most-used first
(a comb sort), keeps the first 176 and maps every other colour to the kept one at the
least squared RGB distance, rewriting palette and pixels in place. The slide show runs it
before drawing a picture, and the homepage loader before it programs the picture into
the custom flash.
Where the files themselves sit in RAM while this happens is on the Work RAM Map page.
Primitive drawing is provided too: DrawLine/DrawLineEx, DrawBox,
DrawFrame/DrawFrameEx/DrawFrameSP, DrawCircle.
The palette (CLUT)
Indices are resolved through a 256-entry colour look-up table, stored in the
program image at file 0x32573C. Each entry is a 32-bit 0x00BBGGRR
(BGR-order) word — proven by the named colour constants below (CL_Red = index
0xF9 = stored 0x000000FF, i.e. the low byte is red). It is the first data
structure the disassembly project lifted from raw bytes into
typed source. At runtime the palette is manipulated through SetPaletteRGB
(0x4842D9F1), GetPaletteRGB (0x4842DB23) and GetPaletteRGB4
(0x4842DB30); ConvPaletteMono4 (0x4842DC88) derives the 2-bit-panel
greyscale ramp from it.
Named colours
The firmware refers to palette entries by name through a CL_* constant table
(recovered by the KN7000 disassembly’s tools/gen_constants.py). The base is a
VGA-16 layout — the eight dark colours at indices 0x00–0x07 and the eight
bright ones at 0xF8–0xFF:
| Index | Name | Index | Name | |
|---|---|---|---|---|
0x00 |
CL_Black |
0xF8 |
CL_Gray |
|
0x01 |
CL_Maroon |
0xF9 |
CL_Red |
|
0x02 |
CL_Green |
0xFA |
CL_Lime |
|
0x03 |
CL_Olive |
0xFB |
CL_Yellow |
|
0x04 |
CL_Navy |
0xFC |
CL_Blue |
|
0x05 |
CL_Purple |
0xFD |
CL_Fuchsia |
|
0x06 |
CL_Teal |
0xFE |
CL_Aqua |
|
0x07 |
CL_Silver |
0xFF |
CL_White |
On top of that sit semantic UI colours — CL_TitleBar, CL_IconBack,
CL_Text, CL_Selected, CL_PageBack, CL_EditSw (0x17–0x1C), the
sound-expansion accents CL_SoundExp1–4, and crucially CL_Transparent =
0xF7, which names the transparent index the SP sprite blitters skip.
Fonts and text
Text metrics come from a font descriptor table whose base pointer lives at
0x50122DB8. Each descriptor is 0x14 (20) bytes, indexed by font id — read
directly from GetCharHeight / GetCharDescent:
GetCharHeight: font = *(0x50122DB8) + id*0x14 ; return *(font + 2) # 0x4842DF60
GetCharDescent: font = *(0x50122DB8) + id*0x14 ; return *(font + 4) # 0x4842DF73
so a descriptor holds the glyph height at +2, the descent at +4, and further metrics beyond.
GetFontCount / GetFontNameTable enumerate the installed fonts, and
ConvertStrings / ConvertStringsEx render/transform strings — the KN7000 draws
English/German/French/Spanish/Indonesian text plus a Japanese developer entry
(see firmware strings).
LCD hardware
The display hardware is one controller and the memory inside it:
- LCD controller — IC104 (
C0HBA0000117, the colour LCD controller; its video output is what Reading ROM out of the screen captures). It is an Epson S1D13806, the S1D13506 with its display memory inside (Boot ROM gives the evidence): registers at0x9CC00000, display memory at0x9CE00000. - Display memory — 1280 KB,
0x9CE00000-0x9CF3FFFF. The address space spans 2 MB; above the 1280 KB, reads return0xFFDF(probe PFT16 on the owner’s unit, 2026-10-26). - Framebuffer —
0x9CE00000. The firmware composites the whole display itself into a 640×240 RGB565 image at the start of display memory, which the controller scans (see the boot splash). Pictures reach it as 12-bit direct colour from two work-RAM planes (0x500D4080,0x500F9880), not as palette indices.
How the controller shows its memory
The probes of the Pinball Fantasies port (PFT14-PFT17, on the owner’s unit, program 893,
2026-10-26; kn7000/notes/session-2026-10-26/ in that repository) and the two Epson manuals
(S1D13506 Hardware Functional Specification X25B-A-001-12; S1D13806 Series Technical Manual, pages
14 and 122) give the following.
- 180-degree SwivelView. The firmware writes
REG[040h]=0x15: 16 bits a pixel, and bit 4, which withREG[1FCh]bit 6 clear selects 180-degree SwivelView (S1D13506 Table 8-19). The controller fetches display memory backwards, and the start address (REG[042h]-[044h], in words) is the image’s bottom-right word: (offset × height) − (offset − width) − 1 =0x0257FFfor a 640 × 240 frame at a line offset of0x280words. IC18’sLcdControllerInitwrites exactly that; the program firmware writes0x025A7F, one line further on, and so shows its frame’s rows 1-240. A start larger by one line offset moves the picture by a line: PFT14’s test picture scrolled smoothly on the unit, upright. - 8 bits a pixel through the look-up table.
REG[040h]bits 2-0 = 3 shows display memory a byte a pixel through a 256-entry look-up table, filled throughREG[1E2h](the index) andREG[1E4h](red, green, blue in turn, each in bits 7-4). That is 4 bits a primary, 16 levels. PFT15’s colour bars showed on the unit and moved as the table was rewritten. - The ink layer (
REG[070h]-[07Bh]): a full-screen overlay of 2 bits a dot (colour 0, colour 1, transparent, inverted) at its own address, independent of the start address.REG[071h]= n places it at0x140000− n × 8 KB (n from 1 to 160, S1D13806 manual). It is not turned by SwivelView: its dots are in the panel’s own order. On the unit, n = 133 put it at0x36000, inside the firmware’s frame, and the program menu showed as a pattern of ink dots; n = 5 put it at0x136000, which the boot clears, and the screen was colour 0. - One window. The registers have no split screen, no line-compare register and no
picture-in-picture window. The start address moves the whole picture; only the ink layer stays
in place. The Pinball Fantasies port keeps a table’s playfield at display memory
0x50000and scrolls it with one start-address write, and draws the dot display and the side panels in the ink layer at0x136000. - When the start address takes effect. The controller latches it as a frame begins. Written a
byte at a time with a frame starting in between, it shows the picture from a mixed address, a
few hundred dots off (seen on the unit as a ghost of the table).
REG[03Ah]bit 7 is meant to flag the non-display period between frames, but on the unit it read 1 before only 1 of 339 start-address writes, where 16 of 256 lines would give about 21. What it signals on this unit is open.
The kn7000_mame overlay models all of this: the start address, line offset and SwivelView, the 1280 KB, the ink layer, the non-display period and the 8-bit mode with its table (MAME Emulation Gaps).
The compositor
The routine that turns the planes into the frame is at 0x48414D40 in build 942. It
redraws one rectangle at a time: for each pixel it reads a byte from the first plane
(0x500D4090 in build 942, returned by GetVRAMAddr); if its top nibble is 0xD, the pixel
is direct colour (red in that byte’s low nibble, green and blue in the second plane,
0x500F9890, returned by GetWRAMAddr), otherwise the byte is a palette index looked up in
the RGB565 table at 0x50122ABC. The result goes to 0x9CE00000. Only rectangles the
firmware redraws are recomposited, so a pixel written straight into the frame stays until the
firmware repaints that spot — which is how the
uptime clock demo draws.
0x34000000 is not a display bank. It holds the MN103002A’s own on-chip
registers: the interrupt controller’s GxICR at 0x34000108–0x3400017F,
EXTMD at 0x34000280, the serial channels at 0x34000800 and the timers at
0x34001080. 0x90000000 and 0x8C000000 are not video windows either: they
are the uncached views of work RAM (0x50000000) and of the self-loaded library
(0x4C000000).
What the LCD costs the CPU
The frame at 0x9CE00000 is reached uncached, over a 16-bit bus, and it is slow. Pass 9 of the
ROM dumper timed it on the
owner’s instrument (program 893, the CPU at 64 MHz; CPU clock):
| access, clean runs | ns | CPU cycles |
|---|---|---|
| 16-bit store | 439.3 | 28.1 |
| 32-bit store | 888.5 | 56.9 |
| 16-bit load | 693.6 | 44.4 |
A load or store that hits the data cache in work RAM takes one cycle. The clean figures are a floor. Some of pass 9’s LCD tests had median runs 2 to 2.4 times their clean ones, and Another World’s own benchmark on the same unit measured 1.3-1.8 µs per 16-bit store while the display was running, three to four times the clean 439 ns. Nobody has yet shown why. One explanation that fits is that the LCD controller holds the CPU off while it fetches the display. So a program that draws should write only the pixels that change. Another World went from 1.5 to about 20 frames per second on the unit that way (Your Own Code on a Stock KN7000).
Relationship to the KN5000
The bitmap storage design, the transparent index 0xF7, the CLUT approach and
the Draw*/…Proc naming are all shared with the KN5000
(Shared Codebase Map); the KN5000
Display subsystem page is the conceptual companion. What
is KN7000-specific: the panel-type switch (colour and 2-bit), standard JPEG
artwork alongside the indexed bitmaps, direct-colour pictures, and the RGB565
framebuffer at 0x9CE00000.