|APPENDIX C (Part 1)|
|A description of the ZX Spectrum for reference|
|The first section of this appendix is a repeat of that part of the Introduction concerning the keyboard and screen.
The keyboardZX Spectrum characters comprise not only the single symbols (letters, digits, etc), but also the compound tokens (keywords, function names, etc) and all these are entered trom the keyboard rather than being spelled out. To obtain all these functions and commands some keys have five or more distinct meanings, given partly by shifting the keys (i.e. pressing either the CAPS SHIFT key or the SYMBOL SHIFT key at the same time as the required one) and partly by having the machine in different modes.
The mode is indicated by the cursor, a flashing letter that shows where the next character from the keyboard will be inserted.
(for keywords) mode automatically replaces mode when the machine is expecting a command or program line (rather than INPUT data), and from its position on the line it knows it should expect a line number or a keyword. This is at the beginning of the line, or just after THEN, or just after: (except in a string). If unshifted, the next key will be interpreted as either a keyword (written on the keys), or a digit.
(for letters) mode normally occurs at all other times. If unshifted, the next key will be interpreted as the main symbol on that key, in lower case for letters.
In both and modes, SYMBOL SHIFT and a key will be interpreted as the subsidiary red character on the key and CAPS SHIFT with a digit key will be interpreted as the control function written in white above the key. CAPS SHIFT with other keys does not affect the keywords in mode, and in mode it converts lower case to capitals.
(for capitals) mode is a variant of mode in which all letters appear as capitals. CAPS LOCK causes a change from mode to mode or back again.
(for extended) mode is used for obtaining further characters, mostly tokens. It occurs after both shift keys are pressed together, and lasts for one key depression only. In this mode, a letter gives one character or token (shown in green above it) if unshifted, and another (shown in red below it) if pressed with either shift. A digit key gives a token if pressed with SYMBOL SHIFT; otherwise it gives a colour control sequence.
(for graphics) mode occurs after GRAPHICS (CAPS SHIFT and 9) is pressed, and lasts until it is pressed again. A digit key will give a mosaic graphic, quit GRAPHICS or DELETE, and each of the letter keys apart from V, W, X, Y and Z, will give a user-defined graphic.
If any key is held down for more than about 2 or 3 seconds, it will start repeating.
Keyboard input appears in the bottom half of the screen as it is typed, each character (single symbol or compound token) being inserted just before the cursor. The cursor can be moved left with CAPS SHIFT and 5, or right with CAPS SHIFT and 8. The character before the cursor can be deleted with DELETE (CAPS SHIFT and 0). (Note: the whole line can be deleted by typing EDIT (CAPS SHIFT and 1) followed by ENTER.)
When ENTER is pressed, the line is executed, entered into the program, or used as INPUT data as appropriate, unless it contains a syntax error. In this case a flashing appears next to the error.
As program lines are entered, a listing is displayed in the top half of the screen. The manner in which the listing is produced is rather complicated, and explained more fully in Chapter 2. The last line entered is called the current line and is indicated by the symbol >, but this can be changed by using the keys (CAPS SHIFT and 6) and (CAPS SHIFT and 7). If EDIT (CAPS SHIFT and 1) is pressed, the current line is brought down to the bottom part of the screen and can be edited.
When a command is executed or a program run, output is displayed in the top half of the screen and remains until a program line is entered, or ENTER is pressed with an empty line, or or is pressed. In the bottom part appears a report giving a code (digit or letter) referring you to Appendix B, a brief verbal summary of what Appendix B says, the number of the line containing the last statement executed (or 0 for a command) and the position of the statement within the line. The report remains on the screen until a key is pressed (and indicates mode).
In certain circumstances, CAPS SHIFT with the SPACE key acts as a BREAK, stopping the computer with report D or L. This is recognised
The television screenThis has 24 lines, each 32 characters long, and is divided into two parts. The top part is at most 22 lines and displays either a listing or program output. When printing in the top part has reached the bottom, it all scrolls up one line; if this would involve losing a line that you have not had a chance to see yet, then the computer stops with the message scroll?. Pressing the keys N, SPACE or STOP will make the program stop with report D BREAK- CONT repeats; any other key will let the scrolling continue. The bottom part is used for inputting commands, program lines, and INPUT data, and also for displaying reports. The bottom part starts of as two lines (the upper one blank), but it expands to accommodate whatever is typed in. When it reaches the current print position in the top half, further expansions will make the top half scroll up.
Each character position has attributes specifying its paper (background) and ink (foreground) colours, a two-level brightness, and whether it flashes or not. The available colours are black, blue, red, magenta, green, yellow and white.
The edge of the screen can be set to any of the colours using the border statement.
A character position is divided into 8x8 pixels and high resolution graphics are obtained by setting the pixels individually to show either the ink or paper colour for that character position.
The attributes at a character position are adjusted whenever a character is written there or a pixel is plotted The exact manner of the adjustment is determined by the pnnting parameters. of which there are two sets (called permanent and temporary) of six: the PAPER, INK, FLASH, BRIGHT, INVERSE and OVER parameters. Permanent parameters for the top part are set up by PAPER, INK, etc, statements, and last until further notice. (Initially they are black ink on white paper. With normal brightness, no flashing, normal video and no overprinting). Permanent parameters for the bottom part use the border colour as the paper colour, with a black or white contrasting ink colour, normal brightness, no flashing, normal video and no overprinting.
Temporary parameters are set up by PAPER, INK, etc, items, which are embedded in PRINT, LPRINT, INPUT, PLOT, DRAW and CIRCLE statements, and also by PAPER, INK, etc control characters when they are printed to the television - they are followed by a further byte to specify the parameter value. Temporary parameters last only to the end of the PRINT (or whatever) statement, or, in INPUT statements, until some INPUT data is needed from the keyboard, when they are replaced by the permanent parameters.
PAPER and INK parameters are in the range 0 to 9. Parameters 0 to 7 are the colours used when a character is printed:
Parameter 8 ('transparent') specifies that the colour on the screen is to be left unchanged when a character is printed.
Parameter 9 ('contrast') specifies that the colour in question (paper or ink) is to be made either white or black to show up against the other colour.
FLASH and BRIGHT parameters are 0,1 or 8: 1 means that flashing or brightness is turned on, 0 that it is turned off, and 8 ('transparent') that it is left unchanged at any character position.
OVER and INVERSE parameters are 0 or 1:
OVER 0 new characters obliterate old ones
OVER 1 the bit patterns of the old and new characters are combined using an 'exclusive or' operation (overprinting)
INVERSE 0 new characters are printed as ink colour on paper colour (normal video)
INVERSE 1 new characters are printed as paper colour on ink colour (inverse video)
When a TAB control character is received by the television, two more bytes are expected to specify a tab stop n (less significant byte first). This is reduced modulo 32 to n0 (say), and then sufficient spaces are printed to move the printing position into column n0. When a comma control character is received, then sufficient spaces (at least one) are printed to move the printing position into column 0 or column 16. When an ENTER control character is received, the printing position is moved on to the next line.
The printerOutput to the ZX printer is via a buffer one line (32 characters) long, and a line is sent to the printer
TAB controls and comma controls output spaces in the same way as on the television.
The AT control changes the printing position using the column number, and ignores the line number.
The printer is affected by INVERSE and OVER controls (and also statements) in the same way as the screen is, but not by PAPER, INK, FLASH or BRIGHT.
The printer will stop with error B if BREAK is pressed. If the printer is absent the output will simply be lost.