INTRODUCTION
GRAPHICS
CURSOR POSITIONING
GRAPHIC CHARACTERS
ATTRIBUTE COMMANDS
COMMENTS
COMMANDS SUMMARY
BASIC LANGUAGE USES
MACHINE LANGUAGE CALLS
:INTRODUCTION

     The KAYPRO 10 has a graphics and attributes set that currently
includes drawing and erasing lines, drawing and erasing pixels,
inverse video, reduced intensity, blinking fields, graphics char-
acters, cursor positioning, and cursor on/off.

:GRAPHICS

     To draw graphics on the KAYPRO 10, the screen is treated as an
array 100 pixels high, and 160 pixels wide. Any spot on the screen 
can be addressed by a vertical coordinate (ranging from 32 to 131)
and a horizontal coordinate (ranging from 32 to 191). The pixel in 
the upper left corner of the screen has coordinates of 32,32.
     Line and pixel graphics are drawn on the screen by writing an
escape sequence to the console output. For the purpose of drawing
lines and pixels, an escape sequence is a 4 or 6 byte sequence
defined as follows:

Escape sequence = ESC <sequence-type> <V1> <H1> [<V2> <H2>] 

where:
1)  ESC is an ascii 27 (1B hex).
2)  <sequence-type> is a character of the set { *, (space), L, D }.
3)  V1, H1, V2, H2 are 1-byte values indicating locations on the screen.

     To write a pixel, the sequence-type must be a "*". H2 and V2 
                are not used. V1 is the vertical coordinate of the
                pixel. H1 is the horizontal coordinate.

     To erase a pixel, the sequence-type must be a space. H1, V1, H2,
                and V2 are the same as above.
     
     To draw a line, the sequence-type must be a "L". H1 is the 
                horizontal coordinate of the first point of the
                line. V1 is the vertical coordinate of the first
                point. H2 is the horizontal coordinate of the 
                last point. V2 is the vertical coordinate of the
                last point.

     To delete a line, the sequence-type must be a "D". H1, V1, H2,
                and V2 are the same as above.

:CURSOR POSITIONING

     When positioning the cursor on the KAYPRO 10, the screen is 
treated as an array 25 characters high, and 80 characters wide. 
Any spot on the screen can be addressed by a vertical coordinate
(ranging from 32 to 66) and a horizontal coordinate (ranging from 
32 to 111). The character in the upper left corner of the screen 
has coordinates of 32,32.
     The cursor can be moved to a desired position on the screen
by writing an escape sequence to the console output. For the
purpose of cursor positioning, an escape sequence is a 4 byte
sequence defined as follows:

Escape sequence = ESC EQUALSIGN <V1> <H1>

where:
1)  ESC is an ascii 27 (1B hex).
2)  EQUALSIGN is the character '=' (3D hex).
3)  V1, H1 are 1-byte values indicating the location on the screen.

:GRAPHICS CHARACTERS

     Each of the character positions on the screen occupies the same
area as eight pixels (4 high, 2 wide). Thus, pixels can be addressed
in groups of eight at a time. To set pixels in a character position,
the cursor is moved to that position, and then a byte is sent to
the console output. This byte must have the high order bit set to 1
to distinguish it from normal characters. The remaining seven bits
are use to set 7 of the 8 pixels.

              I.E: to write these pixels....
                                -------   
           Pixel # 1 ------>   |   |   |   <------ Pixel # 0
                               |---+---|  
           Pixel # 3 ------>   |   |   |   <------ Pixel # 2
                               |---+---|  
           Pixel # 5 ------>   |   |   |   <------ Pixel # 4
                               |---+---|  
      Pixel # 7 (off)------>   |   |   |   <------ Pixel # 6
                                -------
              output this byte:
                     -------------------------------
   must be '1' -->  |   |   |   |   |   |   |   |   |  <-- bit for # 0
                     -------------------------------
                          ^   ^   ^   ^   ^   ^
                          |   |   |   |   |   |
                bit for # 6   |   |   |   |   bit for # 1
                    bit for # 5   |   |   bit for # 2
                        bit for # 4   bit for # 3

     As shown above, pixel # 7 is off. To write a pixel with it on,
send the inverse video command (ESC,B,0), then output the inverse
for bits 0 through 6.  I.e: 10000000b would print a blank graphics 
character; (ESC,B,0),10000000b would print a solid character.

:ATTRIBUTE COMMANDS

     A character can be set to inverse video, blinking, reduced
intensity, or underlined. Also, the cursor can be turned off. These
attributes are activated by sending a 3 byte escape sequence to the
console output:

Escape sequence = ESC <on-off-code> <attribute-code>

where:
1)  ESC is an ascii 27 (1B hex)
2)  <on-off-code> is a 'B' to set an attribute on, or a 'C' to set it off.
3)  <attribute-code> has a value of 0 through 7, as follows:
                0 = inverse video,
                1 = reduced intensity,
                2 = blinking,
                3 = underline,
                4 = cursor.
                5 = video mode (overwrite)
                B6 = save current cursor address
                C6 = recall cursor position
                7 = 25th line (status line)

Default for these attributes is: 0 = off, 1 = off, 2 = off, 3 = off, 4 = on.
                                 5 = on, 7 = off

:COMMENTS

1) Examples of line and pixel drawing can be found in GRAPHICS.BAS.

2) All of the coordinates used are 32 or greater. At first glance,
it would seem natural to start them at 1 or 0.  However BDOS interprets
some byte values of 32 or less as control keys. For example, an attempt
to use a coordinate of 9 will result in eight spaces being printed
on the screen (BDOS thinks that the 9 is a tab).

3) A line drawn from point a to point b will not always look the same
as a line from b to a; it will be a mirror image.

4) Graphics characters, pixels, and lines cannot write over normal 
characters.

:SUMMARY

Graphics commands:

        Set Pixel                       ESC, * , V1, H1
        Clear Pixel                     ESC,   , V1, H1
        Set line                        ESC, L , V1, H1, V2, H2
        Delete line                     ESC, D , V1, H1, V2, H2

Attribute commands:

Inverse video on     ESC, B, 0 | Inverse video off      ESC, C, 0
Reduced intensity on ESC, B, 1 | Reduced intensity off  ESC, C, 1
Blinking on          ESC, B, 2 | Blinking off           ESC, C, 2
Underlining on       ESC, B, 3 | Underlining off        ESC, C, 3
Cursor on            ESC, B, 4 | Cursor off             ESC, C, 4
Video Mode           ESC, B, 5 | Video mode off         ESC, C, 5
Save cursor position ESC, B, 6 | Recall cursor position ESC, C, 6
Enable 25th line     ESC, B, 7 | Disable 25th line      ESC, C, 7
          ---------------------------------------------
ASCII     ESC   A   B   C   0   1   2   3   4   5   6   7   8   9
HEX       1B   41  42  43  30  31  32  33  34  35  36  37  38  39
DEC       27   65  66  67  48  49  50  51  52  53  54  55  56  57

:Sample BASIC program using attribute calls:

This will print "This is the status line" in inverse video on the
25th line of the CRT not normally used.

10 PRINT CHR$(27);"B7"                REM enable 25th line
20 PRINT CHR$(27);"B6"                REM save cursor position
30 PRINT CHR$(27);"=8 "               REM load cursor to col 1 of line 25
40 PRINT CHR$(27);"B0"                REM inverse video on
50 PRINT " This is the 'status' line "
60 PRINT CHR$(27);"C0"                REM inverse video off
70 PRINT CHR$(27);"C7"                REM disable 25th line
80 PRINT CHR$(27);"C6"                REM recall cursor
90 END

:Sample routine from a machine language assembly program

PRINTIT:
        CALL        ILPRT                        ;BDOS print routine
        DB        1bh,'B0',1bh,'B1'        ;inverse on, half intensity
        DB        'This will print in half-intensity inverse video',13,10
        DB        1bh,'C1',1bh,'C0'        ;half off, inverse off
        DB        13,10,0
-intens