# Display WSDEV pages "Display", "Display/Screens", "Display/Sprites", "Display/Windows", "Display/Tile Data", "Display/Palette", "Display/LCD Icons", "Display/IO Ports", "Frame timing" and "Timing", at the pinned revisions. ## Layers, front to back High-priority sprites; Screen 2 (scroll and window); low-priority sprites; Screen 1 (scroll); the background colour (port 01h). Port 00h enables each layer and the two windows ("Display/IO Ports"). ## Screens Two 32 x 32 maps of 8 x 8 cells (256 x 256 pixels), each cell a word: tile index (9 bits), palette (4), tile bank (colour only, tiles 512-1023), H and V flip. Map bases from port 07h on 2 KiB boundaries; scroll X/Y per screen (ports 10h-13h). ## Sprites 128 entries of 4 bytes (tile 0-511 from bank 0 only, palette 0-7 meaning 8-15, window inside/outside, priority against Screen 2, flips, Y, X). Ports 04h-06h choose the table and the slice drawn. At most 32 sprites per line, chosen by Y alone (hidden and windowed ones count); earlier entries draw over later ones. The table is copied to an internal buffer on line 144, one word per clock, 256 words, and that copy is what the next frame draws ("Display/Sprites"). ## Windows A rectangle for Screen 2 (ports 08h-0Bh, inside or outside per port 00h bit 5) and one for sprites (0Ch-0Fh, each sprite choosing inside or outside). ## Tiles and colour modes | Mode (port 60h bits 7-5) | Tiles | Format | Palette | | --- | --- | --- | --- | | mono | 512 at 2000h | 2bpp planar, Game Boy layout | I/O 20h-3Fh: 16 palettes of four 3-bit entries into an 8-entry shade LUT (1Ch-1Fh) of 16 shades | | colour 2bpp | 1024 at 2000h | 2bpp planar | RAM FE00h-FFFFh, 12-bit RGB words; entries 4-15 unused | | colour 4bpp | 1024 at 4000h | 4bpp planar | same RAM | | colour 4bpp packed ("chunky") | 1024 at 4000h | 4bpp packed | same RAM | Transparency: in 2bpp, palettes 0-3 and 8-11 have an opaque colour 0, palettes 4-7 and 12-15 a transparent one; in 4bpp every colour 0 is transparent ("Display/Palette"). ## The LCD and its icons Port 14h: LCD enable (sleep leaves the segment area working) and, on WSC, a high-contrast mode that drives two LCD lines per SoC line. Port 15h: the icons (sleep, vertical, horizontal, three "etc." circles). Two hardware latches keep the cartridge icon and the sound icons lit for 128 more VBlanks after their condition ends ("Display/LCD Icons"). Ports 16h-18h and 1Ah are LCD-internal (final line, back porch, line counter, latched icons); their power-on values differ between ASWAN and SPHINX (boot-rom.md). ## Colour reproduction (host side) There is no canonical palette: the mono FSTN is near-linear, the WSC's CSTN in mono mode maps shade 0 to #FFF, 1 to #EEE and 15 to #000, the SwanCrystal's TFT is near gamma 2.2 ("Display/Palette"). The board outputs palette indices or raw 12-bit colours and shade numbers; the host chooses a curve per machine row (open decision 6). ## Timing Per line, the display quadrant fetches Screen 1's cell and tile data for each of the 28 visible tile columns in alternating cycles (cycles 0-55 shown on "Frame timing"), then more; on colour, the palette quadrant fetches the palette entry for the previous line's pixel N on cycle N (0-223). Many cells of that table are TODO, and WSDEV warns that "fetches may be off by one cycle". The line match and VBlank interrupts fire at the start of their line ("Display"). Mid-line register writes and their visible effect are U1. ## What decides pictures WSTS (asie's tests, MIT) has display tests in `mono/` and `color/`; Robert Peip's test ROMs for sprite priority and windows live in the MiSTer core's repository (GPL-2.0 by GitHub's report): run, not read, and not fetched here. No picture captures from real units are in hand (U2).