## Graphics Mode Display

This mode is used to display high-resolution 2- or 4-color graphics, and it includes commands to: set color; plot and erase individual points; draw and erase lines; position the graphics cursor; and draw circles.

The DISPLAY GRAPHICS command must be executed before any other graphics mode command is used. It causes the graphics screen to be displayed and sets a current display format and color. The first time the DISPLAY GRAPHICS command is given, a 6144 byte display memory is allocated by OS-9, so there must be at least this much continuous free memory available (the OS-9 mfree command can be used to check free memory). This memory is retained until the END GRAPHICS command is given, even if the program that initiated Graphics mode finishes, so it important that the END GRAPHICS command be used to give up the display memory when Graphics mode is no longer needed.

Graphics mode supports two basic formats: Two-Color which has 256 horizontal by 192 vertical points (G6R mode); and Four Color which has 128 horizontal by 192 vertical points (G6C mode). Two color sets are available in either mode. Regardless of the resolution of the format selected, all Graphics mode commands use a 256 by 192 point coordinate system. The X and Y coordinates are always positive numbers which assume that point 0,0 is the lower lefthand corner of the screen.

An invisible Graphics Cursor is used by many command to reduce the amount of output required to generate graphics. This cursor can be explicitly set to any point using the SET GRAPHICS CURSOR command. Also, all other commands that include X,Y coordinates (such as SET POINT) move the graphics cursor to the specified position.

Table B.2. Graphics Mode Selection Codes

Code | Format
--- | ---
00 | 256 x 192 two-color graphics
01 | 128 x 192 four-color graphics

Table B.3. Color Set and Current Foreground Color Selection Codes

|  | Two Color Format | Four Color Format
| Char | Background | Foreground | Background | Foreground
Color Set 1 | 00 | Black | Black | Green | Green
01 | Black | Green | Green | Yellow
02 |  |  | Green | Blue
03 |  |  | Green | Red
Color Set 2 | 04 | Black | Black | Buff | Buff
05 | Black | Buff | Buff | Cyan
06 |  |  | Buff | Magenta
07 |  |  | Buff | Orange
Color Set 3* | 08 |  |  | Black | Black
09 |  |  | Black | Dark Green
10 |  |  | Black | Med. Green
11 |  |  | Black | Light Green
Color Set 4* | 12 |  |  | Black | Black
13 |  |  | Black | Green
14 |  |  | Black | Red
15 |  |  | Black | Buff

* Color sets 3 and 4 not available on PAL video system (European) models. These color sets work only with NTSC (U.S., Canada, Japan) models.

Table B.4. Graphics Mode Control Commands

Control Code | Name/Function
--- | ---
15 | DISPLAY GRAPHICS - switches screen to graphics mode. This command must be given before any other graphics commands are used. The first time this command is given, a 6K byte display buffer is assigned. If 6K of contiguous memory is not available an error is returned. This command is followed by two characters which specify the graphics mode and current color/color set, respectively.
16 | PRESET SCREEN - presets entire screen to color code passed in next character.
17 | SET COLOR - selects foreground color (and color set) passed in next character, but does not change graphics mode.
18 | QUIT GRAPHICS - disables graphics mode and returns the 6K byte graphics memory area to OS-9 for other use. If the screen is not in alpha mode, then behavior is undetermined.
19 | ERASE GRAPHICS - erases all points to background color and homes graphics cursor to the desired position.
20 | HOME GRAPHICS CURSOR - moves graphics cursor to coordinates 0,0 (lower left hand corner).
21 | SET GRAPHICS CURSOR - moves graphics cursor to given coordinates X,Y. The binary value of the two characters that immediately follow are used as the X and Y values, respectively.
22 | DRAW LINE - draws a line of the current foreground color from the current graphics cursor position to the given X,Y coordinates. The binary value of the two characters that immediately follow are used as the X and Y values, respectively. The graphics cursor is moved to the end point of the line.
23 | ERASE LINE - same as DRAW LINE except the line is “drawn” in the current background color, thus erasing the line.
24 | SET POINT - sets the pixel-at point X,Y to the current foreground color. The binary value of the two characters that immediately follow are used as the x and Y values, respectively. The graphics cursor is moved to the point set.
25 | ERASE POINT - same as DRAW POINT except the point is “drawn” in the current background color, thus erasing the point.
26 | DRAW CIRCLE - draws a circle of the current foreground color with its center at the current graphics cursor position using a radius R which is obtained using the binary value of the next character. The graphics cursor position is not affected by this command.