# unit CRT

### Mad Pascal screen and keyboard handling units

author: Tomasz Biela (Tebe)

http://www.freepascal.org/docs-html/rtl/crt/index-5.html

## Constants:

name: | value: | description:
--- | --- | ---
CN_START_SELECT_OPTION | 0 | Consol values
CN_SELECT_OPTION | 1 |
CN_START_OPTION | 2 |
CN_OPTION | 3 |
CN_START_SELECT | 4 |
CN_SELECT | 5 |
CN_START | 6 |
CN_NONE | 7 |
BW40 | 0 | 40x25 B/W on Color Adapter
CO40 | 1 | 40x25 Color on Color Adapter
BW80 | 2 | 80x25 B/W on Color Adapter
CO80 | 3 | 80x25 Color on Color Adapter
Mono | 7 | 80x25 on Monochrome Adapter
C40 | CO40 |
C80 | CO80 |
Black | 0 |
Blue | 1 |
Green | 2 |
Cyan | 3 |
Red | 4 |
Magenta | 5 |
Brown | 6 |
LightGray | 7 |
DarkGray | 8 |
LightBlue | 9 |
LightGreen | 10 |
LightCyan | 11 |
LightRed | 12 |
LightMagenta | 13 |
Yellow | 14 |
White | 15 |
Blink | 128 |

## Register Variables:

name: | address: | type: | description:
--- | --- | --- | ---
Consol | $d01f | byte | CONSOL register

## Global Variables:

name: | type: | description:
--- | --- | ---
TextAttr | byte = 0 | Text Attribute

## Interface:

name: | description:
--- | ---
CursorOff | #### procedure CursorOff; Hide cursor
CursorOn | #### procedure CursorOn; Display cursor
ClrScr | #### procedure ClrScr; Clear screen
DelLine | #### procedure DelLine; Delete line at cursor position
InsLine | #### procedure InsLine; Insert an empty line at cursor position
ReadKey | #### function ReadKey: char; assembler; Read key from keybuffer ##### returns: char
TextBackground | #### procedure TextBackground(a: byte); assembler; Set text background ##### parameters: a - color value 0..255
TextColor | #### procedure TextColor(a: byte); assembler; Set text color ##### parameters: a - color value 0..255
Delay | #### procedure Delay(count: word); assembler; Waits a specified number of milliseconds ##### parameters: count - number of milliseconds
Keypressed | #### function Keypressed: Boolean; assembler; Check if there is a keypress in the keybuffer ##### returns: TRUE key has been pressed FALSE otherwise
GotoXY | #### procedure GotoXY(x: byte; y: byte); assembler; Set cursor position on screen. GotoXY positions the cursor at (X,Y), X in horizontal, Y in vertical direction relative to the origin of the current window. The origin is located at (1,1), the upper-left corner of the window. ##### parameters: x - horizontal positions (1..40) y - vertical positions (1..24)
WhereX | #### function WhereX: byte; assembler; Return X (horizontal) cursor position ##### returns: byte (1..40)
WhereY | #### function WhereY: byte; assembler; Return Y (vertical) cursor position ##### returns: byte (1..24)
ClrEol | #### procedure ClrEol; ClrEol clears the current line, starting from the cursor position, to the end of the window. The cursor doesn't move.
NoSound | #### procedure NoSound; assembler; Reset POKEY
Sound | #### procedure Sound(Chan,Freq,Dist,Vol: byte); assembler; Plays sound ##### parameters: Chan - channel (0..3) primary POKEY, (4..7) secondary POKEY Freq - frequency (0..255) Dist - distortion (0,2,4,6,8,10,12,14) Vol - volume (0..15)
TextMode | #### procedure TextMode(Mode: byte); assembler; Reset E: device ##### parameters: Mode - unused value