BIN 00010000
BIN 00100010
BIN 01111110
BIN 00000000
(If you know about binary numbers, then it should help you to know that BIN is used to write a number in binary instead of the usual decimal.)
These eight numbers are stored in memory, in eight places, each of which has an address. The address of the first byte, or group of eight digits, is USR "S" (S because that is what we chose in (ii)), that of the second is USR "S"+1, and so on up to the eighth, which has address USR "S"+7.
USR here is a function to convert a string argument into the address of the first byte in memory for the corresponding user-defined graphic. The string argument must be a single character which can be either the user-defined graphic itself or the corresponding letter (in upper or lower case). There is another use for USR, when its argument is a number, which will be dealt with in subsequent chapters.
Even if you don't understand this, the following program will do it for you:
5 FOR n=0 TO 7
10 READ row: POKE USR
"S"+n,row
15 NEXT n
20 DATA BIN 00000000
25 DATA BIN 01111100
30 DATA BIN 00100010
35 DATA BIN 00010000
40 DATA BIN 00010000
45 DATA BIN 00100010
50 DATA BIN 01111110
60 DATA BIN 00000000
The above example can also be rewritten using integer variables without the use of BIN while still expressing the graphic matrix in binary form. Can you restate it per what you've learned?
The POKE statement stores a number directly in a memory location, bypassing the assignment (LET) mechanism normally used by NextBASIC which also tracks its place in memory. The opposite of POKE is PEEK, and this allows us to look at the contents of a memory location although it does not actually alter the contents of that location. They will be dealt with properly in Chapter 23.There are a few more efficient ways to type all the above but for now, we're using the simplest forms of PEEK and POKE.
The tokens (which we referred to a little earlier) are stored right after character code 128. As you saw, in the character set printing example, codes 0 to 31 were absent. These are control characters or as commonly referred to: control codes. They either don't produce characters on screen – although they do have an effect on what's printed there – or, alternatively, they are used to control something other than the display itself, and the screen displays ? to show that it doesn't understand them. They are described more fully in Appendix A.
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.