ZX80 Character position

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Posts: 6
Joined: Wed Apr 06, 2016 9:36 pm

ZX80 Character position

Post by ZX79 »


I have been reading a book called The Turing Criterion: Machine Intelligent Programs for the 16K ZX81. It includes a line on how to poke a character into a specific position on the screen. It says it works for both the ZX80 and ZX81, and is similar to PRINT AT for the ZX81 . The line is:

POKE Y*33+X+1+PEEK(16396)+PEEK(16397)*256, n

Unfortunately, it is not clear to me how to format the line. For instance, if I want a character at location (5,5), should I start:

POKE 171.....

i.e. 165+5+1.

Does anyone know the correct format? Is it only for the 8K ZX80?

Thank you.
Posts: 188
Joined: Wed Sep 01, 2010 10:53 pm

Re: ZX80 Character position

Post by Fruitcake »

You can format the line exactly as shown, e.g. say you wanted to print a "A" at row 8 column 5 you would use:

Code: Select all

POKE 8*33+5+1+PEEK(16396)+PEEK(16397)*256,38
or if you could evaluate the maths yourself and use:

Code: Select all

POKE 270+PEEK(16396)+PEEK(16397)*256,38
or to make it clearer which character you are printing you could use:

Code: Select all

POKE 270+PEEK(16396)+PEEK(16397)*256,CODE "A"
If you plan to print a lot this way then you could create a subroutine that you call for each character, e.g.

Code: Select all

10 LET Y=8
20 LET X=5
40 GOSUB 9000

10 LET Y=15
20 LET X=26
40 GOSUB 9000


8990 STOP

9000 LET DFILE=1+PEEK(16396)+PEEK(16397)*256
9010 POKE Y*33+X+DFILE,C
In the subroutine, the start address of the display file (DFILE) is calculated separately to make it clearer to follow what is happening.

Typically you would put the line calculating DFILE at the start of the program since it only needs to be determined once rather than have the overhead of determining the same value every time you print a character. I just put it in the subroutine for the purposes of clarity for this explanation.

If you do print using the POKE approach then do not use SCROLL since this messes up the size of the display file since the new blank row will have a width of 1 and not 33. This is a shortcoming of the SCROLL command.

Hope that helps.
User avatar
Posts: 3135
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX80 Character position

Post by 1024MAK »

One other thing, the display file has to be fully expanded.

Posts: 180
Joined: Wed Oct 02, 2019 5:32 am

Re: ZX80 Character position

Post by bola_dor »

nice code.
I understand its utility on a ZX80 that lacks PRINT AT command.
is it faster than PRINT; or PRINT AT on a ZX81 in a one by one character printing? (I dont thinl it would be faster when printing a string)
ZX80, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ Spectrum, Sinclair QL.
Post Reply