The ZX Spectrum BASIC doesn't (ordinarily) let you print on lines 23 and 24 to allow for user input.

Is there a way around this? I found a fairly recent post that suggested I could POKE 16418,0 but testing this on both hardware and emulators it doesn't change anything.

This is my test code:

10 FOR a= 0 to 23
20 PRINT AT a,0;a
30 NEXT a

Which will end in 5 Out of screen (since it can't write to line index 22).

Or were these last two lines a pipedream for the 80s BASIC programmer?


POKE 16418,0 is for the ZX81, not the Spectrum - the equivalent system variable on the Spectrum is at 23659.

You need to take care when poking this address, as it's liable to cause a crash if the program exits (or displays a scroll? prompt) while the lower screen is disabled, but the following program demonstrates the principle:

10 POKE 23659,0
20 PRINT AT 22,0;"X"'"Y"
30 PAUSE 0
40 POKE 23659,2

For completeness, it's worth mentioning that the 'official' (and safe) way of accessing the lower screen is PRINT #0 (or equivalently PRINT #1), although that way you won't get direct control over PRINT AT coordinates.

10 PRINT #0;"hello world"
20 PAUSE 0
  • I like that there's an official way to print on those last lines, frustratingly they push the screen up by 1 line so I'm left with a blank line between (what I'd aim to be) line 21 and 22: imgur.com/E2PwrKV. – Remy Sharp Mar 17 '20 at 9:40
  • The first solution using poke seemed to work closer to what I was after, but I also needed to POKE 23692, 0 to hide the scroll message that I was getting (and restore it to 1 before my program ended). – Remy Sharp Mar 17 '20 at 9:41
  • Also mean to add that I love your work @gasman đź‘Ť you bandersnatch work features at the end of a talk I give on JavaScript and ZX Spectrum screens – Remy Sharp Mar 17 '20 at 9:42
  • Even without POKE you could certainly PRINT #0;AT which would allow you to print on the entire screen, as long as you had a convenient point where you could split the printing, anywhere between 1-22 lines in the top half and 2-23 in the bottom half. – Neil Dec 8 '20 at 23:08

I don't know about the normal printing routines in ZX Spectrum BASIC, but you can directly access the screen memory using POKE from BASIC. You'll need to work out where to get the 8 bytes of bitmap data comprising the character, then POKE them into the 8 bytes (on a 256-byte stride) corresponding to the desired character cell.

According to this, the first row of line 23 (line index 22), column 1 would be at $50C0, or 20672 in decimal. So the following should fill that character cell with ink colour:

10 FOR a= 0 TO 7
20 POKE 20672 + 256 * a, 255
30 NEXT a

The corresponding attribute byte is at $5AC0, or 23232.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.