2 ; Graphics driver for the 240x200x2 mode on the Atmos
4 ; Stefan Haubenthal <polluks@sdf.lonestar.org>
7 .include "zeropage.inc"
9 .include "tgi-kernel.inc"
10 .include "tgi-error.inc"
15 ; ------------------------------------------------------------------------
16 ; Header. Includes jump table and constants.
20 ; First part of the header is a structure that has a magic and defines the
21 ; capabilities of the driver
23 .byte $74, $67, $69 ; "tgi"
24 .byte TGI_API_VERSION ; TGI API version number
25 .word 240 ; X resolution
26 .word 200 ; Y resolution
27 .byte 2 ; Number of drawing colors
28 .byte 1 ; Number of screens available
29 xsize: .byte 6 ; System font X size
30 .byte 8 ; System font Y size
31 .word $011C ; Aspect ratio (based on 4/3 display)
33 ; Next comes the jump table. Currently all entries must be valid and may point
34 ; to an RTS for test versions (function not implemented).
55 .addr 0 ; IRQ entry is unused
57 ; ------------------------------------------------------------------------
60 ; Variables mapped to the zero page segment variables. Some of these are
61 ; used for passing parameters to the driver.
69 ; Absolute variables used in the code
73 ERROR: .res 1 ; Error code
74 MODE: .res 1 ; Graphics mode
76 ; Constants and tables
92 DEFPALETTE: .byte $00, $07
96 ; ------------------------------------------------------------------------
97 ; INSTALL routine. Is called after the driver is loaded into memory. May
98 ; initialize anything that has to be done just once. Is probably empty
101 ; Must set an error code: NO
106 ; ------------------------------------------------------------------------
107 ; UNINSTALL routine. Is called before the driver is removed from memory. May
108 ; clean up anything done by INSTALL but is probably empty most of the time.
110 ; Must set an error code: NO
116 ; ------------------------------------------------------------------------
117 ; INIT: Changes an already installed device from text mode to graphics
119 ; Note that INIT/DONE may be called multiple times while the driver
120 ; is loaded, while INSTALL is only called once, so any code that is needed
121 ; to initializes variables and so on must go here. Setting palette and
122 ; clearing the screen is not needed because this is called by the graphics
124 ; The graphics kernel will never call INIT when a graphics mode is already
125 ; active, so there is no need to protect against that.
127 ; Must set an error code: YES
132 ; Switch into graphics mode
136 ; Done, reset the error code
142 ; ------------------------------------------------------------------------
143 ; DONE: Will be called to switch the graphics device back into text mode.
144 ; The graphics kernel will never call DONE when no graphics mode is active,
145 ; so there is no need to protect against that.
147 ; Must set an error code: NO
152 ; ------------------------------------------------------------------------
153 ; GETERROR: Return the error code in A and clear it.
161 ; ------------------------------------------------------------------------
162 ; CONTROL: Platform/driver specific entry point.
164 ; Must set an error code: YES
173 ; ------------------------------------------------------------------------
174 ; CLEAR: Clears the screen.
176 ; Must set an error code: NO
181 ; ------------------------------------------------------------------------
182 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
183 ; The page number is already checked to be valid by the graphics kernel.
185 ; Must set an error code: NO (will only be called if page ok)
190 ; ------------------------------------------------------------------------
191 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
192 ; The page number is already checked to be valid by the graphics kernel.
194 ; Must set an error code: NO (will only be called if page ok)
200 ; ------------------------------------------------------------------------
201 ; SETCOLOR: Set the drawing color (in A). The new color is already checked
202 ; to be in a valid range (0..maxcolor-1).
204 ; Must set an error code: NO (will only be called if color ok)
211 ; ------------------------------------------------------------------------
212 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
213 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
216 ; Must set an error code: YES
232 ; ------------------------------------------------------------------------
233 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
234 ; set the palette should return the default palette here, so there's no
235 ; way for this function to fail.
237 ; Must set an error code: NO
242 ; ------------------------------------------------------------------------
243 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
244 ; drivers should return something reasonable here, even drivers that don't
245 ; support palettes, otherwise the caller has no way to determine the colors
246 ; of the (not changeable) palette.
248 ; Must set an error code: NO (all drivers must have a default palette)
256 ; ------------------------------------------------------------------------
257 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
258 ; color. The coordinates passed to this function are never outside the
259 ; visible screen area, so there is no need for clipping inside this function.
261 ; Must set an error code: NO
276 ; ------------------------------------------------------------------------
277 ; GETPIXEL: Read the color value of a pixel and return it in A/X. The
278 ; coordinates passed to this function are never outside the visible screen
279 ; area, so there is no need for clipping inside this function.
295 ; ------------------------------------------------------------------------
296 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
297 ; X2/Y2 = ptr3/ptr4 using the current drawing color.
299 ; Must set an error code: NO
320 ; ------------------------------------------------------------------------
321 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
322 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color.
323 ; Contrary to most other functions, the graphics kernel will sort and clip
324 ; the coordinates before calling the driver, so on entry the following
325 ; conditions are valid:
328 ; (X1 >= 0) && (X1 < XRES)
329 ; (X2 >= 0) && (X2 < XRES)
330 ; (Y1 >= 0) && (Y1 < YRES)
331 ; (Y2 >= 0) && (Y2 < YRES)
333 ; Must set an error code: NO
350 ; ------------------------------------------------------------------------
351 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
352 ; direction is passend in X/Y, the text direction is passed in A.
354 ; Must set an error code: NO
361 ; ------------------------------------------------------------------------
362 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
363 ; current text style. The text to output is given as a zero terminated
364 ; string with address in ptr3.
366 ; Must set an error code: NO