Overview
A rectangular frame drawn with PRINT AT and PAPER colour. Top and bottom bars (rows 0 and 21) serve as title and footer — use centre text to place labels. Side borders (column 0 and 31) complete the box. The interior (rows 1-20, cols 1-30) is the play area. Used in Lucky Number, Wire Panic, and most BASIC games as the standard screen layout.
Why rows 0-21?
The Spectrum has 24 rows (0-23) total, but the ROM reserves rows 22-23: row 22 is the system status line (where 0 OK, 0:1 appears after a program ends) and row 23 is the INPUT prompt area. BASIC programs that try to PRINT AT 22-23 either overwrite system messages or get pushed back by INPUT/PRINT. The 0-21 range is the safe play area for BASIC games.
PRINT AT with PAPER writes to both the display memory (the " " character) and the attribute memory (the PAPER colour). The ULA reads attribute memory every 8 scanlines to colour each character cell.
Code
10 REM Screen frame
20 REM Pattern: reusable across games
30 REM
40 REM Usage:
50 REM LET fc=1: GO SUB 3200
60 REM
70 REM Parameters:
80 REM fc = frame PAPER colour (e.g. 1=blue)
90 REM
100 REM Draws a 1-cell border around rows 0-21
110 REM Interior is rows 1-20, cols 1-30
120 REM Row 0 and 21 are solid bars (for title/footer)
130 REM Cols 0 and 31 are side borders
140 REM
150 REM After calling, use centre text (GO SUB 3000)
160 REM to place title in row 0 and footer in row 21:
170 REM LET r=0: LET t$="GAME TITLE": PAPER fc
180 REM INK 6: BRIGHT 1: GO SUB 3000
190 REM
3200 REM === Draw screen frame in PAPER fc ===
3210 FOR i=0 TO 31
3220 PRINT AT 0,i; PAPER fc;" "
3230 PRINT AT 21,i; PAPER fc;" "
3240 NEXT i
3250 FOR i=1 TO 20
3260 PRINT AT i,0; PAPER fc;" "
3270 PRINT AT i,31; PAPER fc;" "
3280 NEXT i
3290 RETURN
Trade-offs
| Aspect | Detail |
|---|---|
| Speed | ~72 PRINT AT calls — draw once at game start |
| Memory | ~10 lines of code |
| Limitation | Fixed at rows 0-21, cols 0-31. Adjust for different layouts |
| Customisation | Change fc for different frame colours. Use centre text for title/footer |
When to use: Any game that needs a bordered play area with title and footer.
When to avoid: Full-screen games with no UI borders.
Related
Patterns: Text Utilities — centre and clear
Vault: ULA — display + attribute memory | ZX Spectrum