2 ; Graphics driver for the 228x200x3 palette mode on the Atmos
4 ; Stefan Haubenthal <polluks@sdf.lonestar.org>
5 ; 2012-08-11, Greg King <greg.king5@verizon.net>
8 .include "zeropage.inc"
10 .include "tgi-kernel.inc"
11 .include "tgi-error.inc"
16 XSIZE = 6 ; System font width
17 YSIZE = 8 ; System font height
19 ; ------------------------------------------------------------------------
20 ; Header. Includes jump table and constants.
24 ; The first part of the header is a structure that has a signature,
25 ; and defines the capabilities of the driver.
28 .byte TGI_API_VERSION ; TGI API version number
29 .word 228 ; x resolution
30 .word 200 ; y resolution
31 .byte 3 ; Number of drawing colors
32 .byte 1 ; Number of screens available
33 .byte XSIZE ; System font x size
34 .byte YSIZE ; System font y size
35 .word $011C ; Aspect ratio (based on 4/3 display)
36 .byte 0 ; TGI driver flags
38 ; Next comes the jump table. Currently, all entries must be valid;
39 ; and, may point to an RTS, for test versions (function not implemented).
60 .addr 0 ; IRQ entry is unused
62 ; ------------------------------------------------------------------------
65 ; Variables mapped to the zero-page segment variables. These are
66 ; used for passing parameters to the driver.
73 ; Absolute variables used in the code
77 ERROR: .res 1 ; Error code
78 MODE: .res 1 ; Graphics mode
84 PARAM1 := $2E1 ; & $2E2
85 PARAM2 := $2E3 ; & $2E4
86 PARAM3 := $2E5 ; & $2E6
99 ; Default colors: black background, white foreground
100 ; (The third "color" actually flips a pixel
101 ; between the foreground and background colors.)
103 DEFPALETTE: .byte 0, 1
107 ; ------------------------------------------------------------------------
108 ; INIT: Changes an already installed device from text mode to graphics mode.
109 ; Note that INIT/DONE may be called multiple times while the driver
110 ; is loaded, while INSTALL is called only once. So, any code that is needed
111 ; to initialize variables and so on must go here. Setting palette and
112 ; clearing the screen are not needed because they are called by the graphics
114 ; The graphics kernel never will call INIT when a graphics mode is already
115 ; active, so there is no need to protect against that.
117 ; Must set an error code: YES
122 ; Switch into graphics mode.
126 ; Done, reset the error code.
128 ; ------------------------------------------------------------------------
129 ; GETERROR: Return the error code in A, and clear it.
136 ; ------------------------------------------------------------------------
137 ; INSTALL routine. Is called after the driver is loaded into memory. May
138 ; initialize anything that has to be done just once. Is probably empty
141 ; Must set an error code: NO
146 ; ------------------------------------------------------------------------
147 ; UNINSTALL routine. Is called before the driver is removed from memory. May
148 ; clean up anything done by INSTALL, but probably is empty most of the time.
150 ; Must set an error code: NO
156 ; ------------------------------------------------------------------------
157 ; DONE: Will be called to switch the graphics device back into text mode.
158 ; The graphics kernel never will call DONE when no graphics mode is active,
159 ; so there is no need to protect against that.
161 ; Must set an error code: NO
166 ; ------------------------------------------------------------------------
167 ; CONTROL: Platform-/driver-specific entry point.
169 ; Must set an error code: YES
178 ; ------------------------------------------------------------------------
179 ; CLEAR: Clears the screen.
181 ; Must set an error code: NO
186 ; ------------------------------------------------------------------------
187 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
188 ; The page number already is checked to be valid, by the graphics kernel.
190 ; Must set an error code: NO (will be called only if page OK)
195 ; ------------------------------------------------------------------------
196 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
197 ; The page number already is checked to be valid, by the graphics kernel.
199 ; Must set an error code: NO (will be called only if page OK)
205 ; ------------------------------------------------------------------------
206 ; SETCOLOR: Set the drawing color (in A). The new color already is checked
207 ; to be in a valid range (0..maxcolor-1).
209 ; Must set an error code: NO (will be called only if color OK)
216 ; ------------------------------------------------------------------------
217 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
218 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
221 ; Must set an error code: YES
247 ; ------------------------------------------------------------------------
248 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
249 ; set the palette should return the default palette here, so there's no
250 ; way for this function to fail.
252 ; Must set an error code: NO
260 ; ------------------------------------------------------------------------
261 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
262 ; drivers should return something reasonable here, even drivers that don't
263 ; support palettes; otherwise, the caller has no way to determine the colors
264 ; of the (not changeable) palette.
266 ; Must set an error code: NO (all drivers must have a default palette)
274 ; ------------------------------------------------------------------------
275 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
276 ; color. The co-ordinates passed to this function are never outside the
277 ; visible screen area, so there is no need for clipping inside this function.
279 ; Must set an error code: NO
288 add #2 * XSIZE ; Skip screen attribute columns
296 ; ------------------------------------------------------------------------
297 ; GETPIXEL: Read the color value of a pixel, and return it in A/X. The
298 ; co-ordinates passed to this function are never outside the visible screen
299 ; area, so there is no need for clipping inside this function.
315 ; ------------------------------------------------------------------------
316 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
317 ; X2/Y2 = ptr3/ptr4, using the current drawing color.
319 ; Must set an error code: NO
342 ; ------------------------------------------------------------------------
343 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
344 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4, using the current drawing color.
345 ; Contrary to most other functions, the graphics kernel will sort and clip
346 ; the co-ordinates before calling the driver; so, on entry, the following
347 ; conditions are valid:
350 ; (X1 >= 0) && (X1 < XRES)
351 ; (X2 >= 0) && (X2 < XRES)
352 ; (Y1 >= 0) && (Y1 < YRES)
353 ; (Y2 >= 0) && (Y2 < YRES)
355 ; Must set an error code: NO
372 ; ------------------------------------------------------------------------
373 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in the x
374 ; and y directions is passend in X/Y, the text direction is passed in A.
376 ; Must set an error code: NO
383 ; ------------------------------------------------------------------------
384 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
385 ; current text style. The text to output is given as a zero-terminated
386 ; string with its address in ptr3.
388 ; Must set an error code: NO
395 lda #3 ; (Move graphics cursor; don't draw)