Appendix II Index Appendix IV

Appendix III

Terminal characteristics

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 #07BEL (Bell) Sounds a bleep.
8 #08BS (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#0ALF (Line feed) Moves the cursor down one line, scrolling the screen up if necessary.
13#0DCR (Carriage return) Moves the cursor to the column furthest to the left on the present row.
27#1BESC (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 1Enables the status line. Disc system messages will appear on the bottom line of the screen.
ESC 2 nChanges the character set to one of the national variants (see Part I, Section 4.5).
ESC 3 nChanges screen size. (See Part I, Section 1.3). Set n as follows:
0
24 x 32 screen (23 x 32 if status line enabled)
1
24 x 51 screen (23 x 51 if status line enabled)
2
24 x 80 screen (23 x 80 if status line enabled)
Sets the viewport to cover the whole screen, clears the viewport. Cancels page mode. Cancels 24 x 80 mode (set by ESC x)
ESC 4 nEnable / Disable Page Mode. (See Part I, Section 4.3). Set n as follows:
0
disable page mode
1
enable page mode
ESC 5 nEnable / Disable auto-flip in 24 x 80 screen mode. Set n as follows:
0
enable auto-flip
1
disable auto-flip
ESC AMoves the cursor up. If the cursor is already on the top row, it has no effect.
ESC BMoves the cursor down. If the cursor is already on the bottom row, it has no effect.
ESC CMoves the cursor right one column. If the cursor is already at the column furthest to the right, it has no effect.
ESC DMoves the cursor left one column. If the cursor is already at the column furthest to the left, it has no effect.
ESC EClears the viewport. The position of the cursor is unaffected.
ESC HMoves 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 JErases to the bottom of the viewport, including the character at the cursor position. The cursor position is unaffected.
ESC KErases to the end of the line, including the character at the cursor position. The cursor position is unaffected.
ESC LInserts 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 MDeletes 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 NDeletes 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 dClears the viewport up to and including the character at the cursor position. The cursor position is unaffected.
ESC eEnables the cursor blob.
ESC fDisables the cursor blob.
ESC jSaves the cursor position.
ESC kRestores the cursor position as saved by ESC j.
ESC lErases all the characters on the line. The cursor position is unaffected.
ESC oErases the line up to and including the character at the cursor position. The cursor position is unaffected.
ESC pEnters reverse video mode. Printable characters are displayed with the foreground and background colours reversed.
ESC qLeaves reverse video mode.
ESC rEnters underline mode.
ESC uLeaves underline mode.
ESC vSelects wrapping at the end of the line.
ESC wCancels wrapping at the end of the line.
ESC xEnters 24 x 80 mode.
ESC yLeaves 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.

Colour values

Normal colourValue (decimal) Bright colourValue (decimal)
Black 32
Blue 34Bright Blue 35
Red 40Bright Red 44
Magenta 42Bright Magenta47
Green 64Bright Green 80
Cyan 66Bright Cyan 83
Yellow 72Bright Yellow 92
White 74Bright White 95

Appendix II Index Appendix IV