|
Atari GTIA+ by Paul Lay |
|
The 8-bit Atari micros have very sophisticated graphics capabilities thanks to a couple of custom chips, ANTIC and GTIA. Much of their power is derived from the fact that a 256-colour palette is provided. However, at best only 16 of these colours can be displayed at once. Display list interrupts can be used to alter colours, but these are restrictive. This program provides a custom display list which allows all 256 colours to be freely displayed with a resolution of 80 by 96. The principle behind this display is that every scan line alternates between 16 luminance and 16 hue modes (GTIA modes 9 and 11 ), so that the overall effect is of a single scan line with all 256 models. Graphics routines To support this custom graphics mode, a full set of graphics routines have been provided (something which the Atari ROM has always lacked). They interface to Basic via USR calls and are described below. In the program, lines 10 to 1360 set up the routines, and lines 1370 onwards provide a demonstration program, showing how the routines are used. Graphics var = USR (GRAPHICS, option) where option is one of FULLCLR, SPLITCLR, FULLNOCLR or SPLITNOCLR. This routine opens the custom graphics mode with all the standard screen configurations provided for. Note that in order to switch between GTIA modes 9 and 11 every scan line, a display list interrupt is used which alters PRIOR ($DO1B). Particularly interesting about this DLI is that the glitch problem associated with keyboard input has been resolved. This was performed by synchronising to the vertical line counter VCOUNT ($D40B). Colour COLOR c Note that colour is still specified by the Basic COLOR statement. The only difference is that the colour is specified by a value in the range 0 to 255, which represents 16*hue+luminance. Plot var = USR (PLOT, x, y) This routine plots the pixel at position x,y in the current colour. Drawto var = USR (DRAWTO, x, y) This routine draws a line from the current graphics cursor position to position x, y in the current colour. Note that the generalised integer Bresenham's algorithm is used, working with byte arithmetic. Mode var = USR (MODE, option) where option is one of NORMAL, ANDMODE, ORMODE or XOR. This routine allows special plotting modes to be used (normal, and, or, and exclusive or protting modes). These modes are commonly used for special effects such as animation, colour blending and masking. Move var = USR (MOVE, x, y) This routine moves the graphics cursor to position x, y Locate var = USR (LOCATE, x, y) This routine returns to the calling variable the colour of the pixel specified at position x, y Fill var = USR (FILL, x, y) This routine performs an area fill in the current colour at position x, y (an area fill fills the area identified by the colour under the specified position, and is capable of filling any shape). Note that a scan line seed fill algorithm is used which specifically minimises stack use. Circle var = USR (CIRCLE, x, y, r) This routine draws a circle in the current colour with centre x,y and radius r. Bresenham's incremental circle algorithm is used. Disc var = USR (DISC, x, y, r) This routine draws a disc (filled circle) in the current colour with centre x, y and radius r. Clipping off the screen is provided but suffers from the fact that the Basic USR command can only accept positive parameter values. Also, as byte arithmetic is extensively used (for efficiency), any value exceeding 255 will be truncated accordingly. When normally using any of the GTIA modes, SETCOLOR 4, hue, lum is used to alter colours. Obviously, this is now no longer needed as all 256 colours are readily available. However, by experimenting with SETCOLOR 4, hue, lum, filter effects can be generated (effectively giving an enormous colour palette). Finally, note that the routines reside in memory between locations $7828 and $7ECO. When the routines have been set up, users with a disk drive could always enter DOS and save a binary file between these addresses, removing the need for lines 90 to 1190 by loading the binary file instead. |
|