# Video: GLUE's timing and the Shifter ## What Atari documents (DOC: HWSPEC 3, 5.2, 9; SVC "Video Shifter", "Glue", "Memory Controller") - **Display memory** is part of main RAM: n bit planes interleaved by 16-bit words into one 32,000-byte (0x7D00) block starting on any 256-byte boundary; the base is loaded into the MMU's video address counter, which increments as words are fetched (HWSPEC 3.1). - **Three modes** in the Shifter's mode register FF8260: 320x200 with 4 planes, 640x200 with 2, 640x400 with 1; the mode should be changed during vertical blank (HWSPEC 3.2, 5.2). - **Palette**: 16 registers of 3+3+3 bits (512 colours); in 640x200 only the first four are used; in 640x400 the palette is bypassed and bit 0 of colour 0 inverts the picture; colour 0 is the border in colour modes, black in mono (HWSPEC 3.2). The STE adds a fourth bit per gun, placed **above** the old most significant bit for compatibility (DOC: STEADD "Color Palette"). - **The pipeline**: the MMU strobes each display word into the Shifter (DCYC); one bit of each plane's word forms the palette index, plane 0 the least significant (HWSPEC 3.2; SVC). - **GLUE** makes BLANK, DE (display enable), HSYNC and VSYNC; VSYNC makes the MMU reload the video counter from the base during vertical blank; DE tells the MMU and Shifter that a display line is being scanned (SVC "Glue"). FF820A selects 50/60 Hz and internal/external sync (HWSPEC 9). Monochrome mode is 71 Hz on the SM124 (not in HWSPEC: HYPOTHESIS until the counters are read, U3). - **Interrupts**: HSYNC (IPL 2) and VSYNC (IPL 4) as autovectors from GLUE, and DE into the MFP's Timer B event input, so Timer B counts display lines; "the first of which occurs at the end of the first display line" (HWSPEC 5.2, 10). The STE addendum gives the budget after a Timer B interrupt: about 144 machine cycles to reload HSCROLL and the video address before the display processor uses them (DOC: STEADD "Split Screen"). - **Mono detect** reaches the MFP's GPIP 7; on the STE it is XORed with the DMA-sound-active signal (DOC: HWSPEC 5.2; STEADD "Interrupts without Timer A"). ## What Atari does not document The line and frame structure: cycles per line, lines per frame, where in the line DE, blank and sync start and stop, when GLUE samples the 50/60 Hz bit and the mode register, and what happens when a program changes them mid-line. This is the centre of ST demo practice ("opening" the top, bottom, left and right borders; "sync scrolling" by changing line lengths), and every such effect is a race between a CPU write and GLUE's per-cycle comparisons. What the detectors say (tier 5, OBSERVED, not judges): | Mode | Cycles a line | Lines | Source | | --- | --- | --- | --- | | 50 Hz | 512 | 313 | MAME 0.285 `-listxml st` (htotal 1024 at a 16 MHz pixel clock, vtotal 313, 50.05 Hz); Clock Signal `Video.cpp` | | 60 Hz | 508 | 263 | Clock Signal | | 71 Hz (mono) | 224 | 500 | Clock Signal, whose author marks the 72 Hz vertical numbers "guesswork" | Clock Signal's horizontal tables also place DE on, DE off, blank and the line-length latch at specific cycles per mode (cycle 54 for the latch, DE at 56 and 376 at 50 Hz), with its author's own notes that several are approximations. MAME's ST (preliminary) drew nothing by 30 s of TOS 1.04 boot in this phase's run ([mame-oracle.md](mame-oracle.md)), so it is no picture detector today. **Where the truth is**: Atari's own gate-level design of the STE's GSTMCU (GLUE+MMU combo), 49 sheets, recovered from Atari's backups by Christian Zietz (ASIC: `ST4081S.PDF`, the latest revision present, its sheets titled "GLUE COMBO", engineer Horton, with blocks named TIMING, VIDEO, COUNTER, REFRESH, SOUND). That is a manufacturer's design document (tier 2, read as DIE-grade for logic), for the **STE**. For the ST's separate GLUE and MMU no design files are known in this survey (U2): the STE design is the best evidence for the ST's counters, to be confirmed by test programs with real-unit verdicts where any exist. Also there, not used: gyurco's `gstmcu` (a Verilog model of the GSTMCU from Zietz's schematics, and of the Shifter from Jorge Cwik's reverse engineering) has **no licence**: closed box only (sources.md). Jorge Cwik's Shifter work is published on atari-forum.com, which refuses AI crawlers: set aside (site's wishes). ## The Shifter's own corners (U8) Pixel output relative to the fetch (the Shifter's internal 4-word latch and the delay from DCYC to the first pixel), what a mid-line mode change does to the shift register ("the Shifter trick": monochrome mode in a colour line to open the left border), the reload order in medium and high resolution, and the STE's HSCROLL prefetch (the extra fetch STEADD mentions: "an additional four-plane data fetch" when HSCROLL is non-zero). Evidence in hand: STEADD for the STE's documented behaviour; ASIC's `ST4118.PDF` is a different "68K Game Shifter" (Panther prototype, ASIC README), not the ST's. ## Modelling (proposed) - GLUE as a per-cycle state machine (8 MHz) with its counters and comparison points as named constants, each tagged with its evidence, first from the GSTMCU sheets. - The MMU's slot table per 4-cycle period (CPU, video, refresh, DMA), feeding the 68000's access alignment ([bus-and-memory.md](bus-and-memory.md)). - The Shifter per pixel clock (32 MHz in mono, 16 in medium, 8 in low), its output a list of palette indices per line with the palette as it was at each pixel (palette writes mid-line are visible: ST "raster" colour changes). - Output frame: the whole scanned area including borders (the overscan programs need it), with the 320x200 window as a view.