Layer 2: True-Colour Bitmap
π§
This chapter is a placeholder. The full text is being written.
Synopsis
Layer 2 is what the original Spectrum should have been. A linear bitmap, one byte per pixel, every pixel independently coloured from a 256-entry palette. Photographic-quality images. Hardware scrolling. And it sits next to the ULA screen, not on top of it β they cohabit, with priority decided by the compositor.
Topics:
- Three resolutions.
- 256Γ192, 256 colours per pixel (the default β 48 KB).
- 320Γ256, 256 colours per pixel (80 KB).
- 640Γ256, 16 colours per pixel (80 KB, packed nibbles).
- The Layer 2 memory window. How the page lives in the 2 MB pool but only becomes visible to the Z80 when you map it via NextRegs
$12(active page) and$13(shadow page). The βdraw on shadow, swap to activeβ pattern. - Enabling Layer 2. NextReg
$15(priority bits) and$69(display enable plus paging shortcut for the 16 KB write window at$0000β$3FFF). - Scrolling. NextRegs
$16(X-scroll low),$17(Y-scroll), and$71(X-scroll high bit for 320/640 modes). - The clipping window. NextRegs
$18β$1Bβ Layer 2 only renders inside this rectangle, which is also what makes split-screen and HUD overlays cheap. - Priority over ULA. The seven priority modes from NextReg
$15, the per-pixel priority bit (from Palettes), and the transparency colour (NextReg$14).
What you should know first
- Memory Architecture β Layer 2 lives in pageable RAM.
- Interrupts β needed for the line-interrupt split-screen exercise.
- Palettes.
Planned exercises
- Image viewer. Load a 256Γ192 Layer 2 image from the example pack and display it.
- DMA back-buffer update. Copy a rectangular or page-sized block from regular RAM into a Layer 2 memory page using zxnDMA. Start with a coarse transfer, such as copying an 8 KB chunk, before later evolving into rectangle-oriented updates. The visible result should be an immediate change in the Layer 2 image after enabling DMA, and the explanation should make clear which memory page is mapped for the destination.
- Smooth scroller. A pre-drawn 512-pixel-wide Layer 2 image that scrolls horizontally using NextReg
$16. - Top/bottom split. Use the line interrupt to swap palettes mid-screen β sky on top, ground below β without changing pixel data.