10

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?

13

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
| improve this answer | |
  • 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 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 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 at 9:42
5

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.

| improve this answer | |

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.