|Appendix II||Index||Appendix IV|
The CP/M Plus implementation on the Spectrum +3 includes a Terminal Emulator which provides facilities very similar to those of a Zenith Z19/Z29 monitor. This makes the Spectrum +3 screen one of the many to broadly emulate a VT52 terminal.
The terminal emulator is provided as part of the CRT physical device. This is normally attached to the CONOUT: logical device. (See Part 2, Chapter 4 for further details of CP/M devices.)
Use of the screen is limited to a viewport which may be all or part of the screen. The size and shape of the viewport is changed either through the ESC X sequence described below, or by selecting 24 x 80 mode or by enabling/disabling the status line.
Row and column numbers should be given relative to the top left hand corner of the viewport, with the exception of the row and column numbers needed to set a new viewport. These should be given relative to the top left hand corner of the screen.
Operations that erase text, only affect characters within the current viewport. However, scrolling the viewport will affect text to the left or right of the present viewport.
The full details of the way text is handled on the screen are as follows:
Characters with internal codes in the range 32...255 (#20...#FF in the hexadecimal notation) are displayed on the screen at the current cursor position.
Generally the cursor is then moved right by one column. However, if the cursor is at the column furthest to the right and wrapping is enabled, it will move to the column furthest to the left on the next line, the screen scrolling up if necessary. If wrapping is not enabled, the cursor will not move to the start of the next line and the final character on the line will be overwritten.
Characters with internal codes in the range 0...31 (#00...#1F) are interpreted as control codes as follows:
|7||#07||BEL||(Bell) Sounds a bleep.|
|8||#08||BS||(Backspace) Moves the cursor one column to the left. If the cursor is at the column furthest to the left and wrapping is enabled, it is moved to the column furthest to the right on the row above - unless it is already on the top row.|
|10||#0A||LF||(Line feed) Moves the cursor down one line, scrolling the screen up if necessary.|
|13||#0D||CR||(Carriage return) Moves the cursor to the column furthest to the left on the present row.|
|27||#1B||ESC||(Escape) Introduces an Escape sequence or a literal character.|
All other control codes are ignored.
The following Escape sequences are interpreted as follows:
|ESC 0||Disables the status line. The CRT may then use the bottom line of the screen. Disc system messages will appear with the CRT output.|
|ESC 1||Enables the status line. Disc system messages will appear on the bottom line of the screen.|
|ESC 2 n||Changes the character set to one of the national variants (see Part I, Section 4.5).|
|ESC 3 n||Changes screen size. (See Part I, Section 1.3). Set
n as follows:|
|ESC 4 n||Enable / Disable Page Mode. (See Part I, Section 4.3).
Set n as follows:|
|ESC 5 n||Enable / Disable auto-flip in 24 x 80 screen mode.
Set n as follows:|
|ESC A||Moves the cursor up. If the cursor is already on the top row, it has no effect.|
|ESC B||Moves the cursor down. If the cursor is already on the bottom row, it has no effect.|
|ESC C||Moves the cursor right one column. If the cursor is already at the column furthest to the right, it has no effect.|
|ESC D||Moves the cursor left one column. If the cursor is already at the column furthest to the left, it has no effect.|
|ESC E||Clears the viewport. The position of the cursor is unaffected.|
|ESC H||Moves the cursor to its Home position, ie. row 0, column 0 - the top left hand corner.|
|ESC I||(Reverse index) Moves the cursor up one row. The screen is scrolled down if necessary.|
|ESC J||Erases to the bottom of the viewport, including the character at the cursor position. The cursor position is unaffected.|
|ESC K||Erases to the end of the line, including the character at the cursor position. The cursor position is unaffected.|
|ESC L||Inserts a line. The row with the cursor on it and all rows below are scrolled down one line. The cursor row is cleared. The position of the cursor is unaffected.|
|ESC M||Deletes the line with the cursor on it. All rows below are scrolled up one line. The bottom row is cleared. The cursor position is unaffected.|
|ESC N||Deletes the character under the cursor. All the characters to the right of the cursor are shuffled one column to the left. The character at the end of the row is cleared. The cursor position is unaffected.|
|ESC X tr lc h w||Sets the text viewport. tr is the row number of the top of the view port plus 32 (#20); lc is the column number of the left hand edge of the viewport plus 32 (#20); h is the number of rows in the viewport (ie. its height) minus 1 plus 32 (#20); w is the number of column in the viewport (ie. its width) minus 1 plus 32 (#20). The cursor is moved if necessary to a position within the viewport.|
|ESC Y r c||Moves the cursor to a given position. r is the row number of the plus 32 (#20); c is the column number plus 32 (#20). If the position is beyond the end of the viewport, the cursor is moved to the edge of the viewport.|
|ESC b c||Sets the foreground colour. The values of c representing the different colours are listed in the table opposite.|
|ESC c c||Sets the background colour. The values of c representing the different colours are listed in the table opposite.|
|ESC d||Clears the viewport up to and including the character at the cursor position. The cursor position is unaffected.|
|ESC e||Enables the cursor blob.|
|ESC f||Disables the cursor blob.|
|ESC j||Saves the cursor position.|
|ESC k||Restores the cursor position as saved by ESC j.|
|ESC l||Erases all the characters on the line. The cursor position is unaffected.|
|ESC o||Erases the line up to and including the character at the cursor position. The cursor position is unaffected.|
|ESC p||Enters reverse video mode. Printable characters are displayed with the foreground and background colours reversed.|
|ESC q||Leaves reverse video mode.|
|ESC r||Enters underline mode.|
|ESC u||Leaves underline mode.|
|ESC v||Selects wrapping at the end of the line.|
|ESC w||Cancels wrapping at the end of the line.|
|ESC x||Enters 24 x 80 mode.|
|ESC y||Leaves 24 x 80 mode.|
Any other character after an ESC is displayed and the cursor advanced as above. This means that it is possible to display a number of the characters that have the same internal code as a control code by sending ESC followed by the control code. For example, ESC #0D will display ±.
Important: What you are doing when you send Escape Sequences to the screen (or to the printer) can affect their interpretation. For example, an application that automatically converts tabs into spaces can affect any Escape Sequence that includes the value 9. (Such an application program is BASIC: however, in BASIC this problem is readily solved by using the OPTION NOT TAB command.)
In addition it is not generally advisable to send escape sequences direct from an A> system prompt because of the way CP/M's command processor automatically converts lower case characters to upper case. In particular, you can't use ESC x and ESC y to go in and out of the 24 x 80 screen mode and you can't use ESC b and ESC c to set the foreground and background colours used on the screen, nice though this would be, because these Escape sequences involve lower case characters.
|Normal colour||Value (decimal)||Bright colour||Value (decimal)|
|Appendix II||Index||Appendix IV|