Hi,
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.
ZX80 Character position
Re: ZX80 Character position
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:
or if you could evaluate the maths yourself and use:
or to make it clearer which character you are printing you could use:
If you plan to print a lot this way then you could create a subroutine that you call for each character, e.g.
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.
Code: Select all
POKE 8*33+5+1+PEEK(16396)+PEEK(16397)*256,38
Code: Select all
POKE 270+PEEK(16396)+PEEK(16397)*256,38
Code: Select all
POKE 270+PEEK(16396)+PEEK(16397)*256,CODE "A"
Code: Select all
10 LET Y=8
20 LET X=5
30 LET C=CODE "A"
40 GOSUB 9000
10 LET Y=15
20 LET X=26
30 LET C=CODE "G"
40 GOSUB 9000
...
8990 STOP
9000 LET DFILE=1+PEEK(16396)+PEEK(16397)*256
9010 POKE Y*33+X+DFILE,C
9020 RETURN
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.
- 1024MAK
- Posts: 5101
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX80 Character position
One other thing, the display file has to be fully expanded.
Mark
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: ZX80 Character position
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)
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)
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come