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-mode.inc"
11 .include "tgi-error.inc"
16 ; ------------------------------------------------------------------------
17 ; Header. Includes jump table and constants.
21 ; First part of the header is a structure that has a magic and defines the
22 ; capabilities of the driver
24 .byte $74, $67, $69 ; "tgi"
25 .byte TGI_API_VERSION ; TGI API version number
26 .word 240 ; X resolution
27 .word 200 ; Y resolution
28 .byte 2 ; Number of drawing colors
29 .byte 1 ; Number of screens available
30 xsize: .byte 6 ; System font X size
31 .byte 8 ; System font Y size
32 .word $100 ; Aspect ratio
34 ; Next comes the jump table. Currently all entries must be valid and may point
35 ; to an RTS for test versions (function not implemented).
56 .addr 0 ; IRQ entry is unused
58 ; ------------------------------------------------------------------------
61 ; Variables mapped to the zero page segment variables. Some of these are
62 ; used for passing parameters to the driver.
70 ; Absolute variables used in the code
74 ERROR: .res 1 ; Error code
75 MODE: .res 1 ; Graphics mode
77 ; Constants and tables
93 DEFPALETTE: .byte $00, $07
97 ; ------------------------------------------------------------------------
98 ; INSTALL routine. Is called after the driver is loaded into memory. May
99 ; initialize anything that has to be done just once. Is probably empty
102 ; Must set an error code: NO
107 ; ------------------------------------------------------------------------
108 ; UNINSTALL routine. Is called before the driver is removed from memory. May
109 ; clean up anything done by INSTALL but is probably empty most of the time.
111 ; Must set an error code: NO
117 ; ------------------------------------------------------------------------
118 ; INIT: Changes an already installed device from text mode to graphics
120 ; Note that INIT/DONE may be called multiple times while the driver
121 ; is loaded, while INSTALL is only called once, so any code that is needed
122 ; to initializes variables and so on must go here. Setting palette and
123 ; clearing the screen is not needed because this is called by the graphics
125 ; The graphics kernel will never call INIT when a graphics mode is already
126 ; active, so there is no need to protect against that.
128 ; Must set an error code: YES
133 ; Switch into graphics mode
137 ; Done, reset the error code
143 ; ------------------------------------------------------------------------
144 ; DONE: Will be called to switch the graphics device back into text mode.
145 ; The graphics kernel will never call DONE when no graphics mode is active,
146 ; so there is no need to protect against that.
148 ; Must set an error code: NO
153 ; ------------------------------------------------------------------------
154 ; GETERROR: Return the error code in A and clear it.
162 ; ------------------------------------------------------------------------
163 ; CONTROL: Platform/driver specific entry point.
165 ; Must set an error code: YES
174 ; ------------------------------------------------------------------------
175 ; CLEAR: Clears the screen.
177 ; Must set an error code: NO
182 ; ------------------------------------------------------------------------
183 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
184 ; The page number is already checked to be valid by the graphics kernel.
186 ; Must set an error code: NO (will only be called if page ok)
191 ; ------------------------------------------------------------------------
192 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
193 ; The page number is already checked to be valid by the graphics kernel.
195 ; Must set an error code: NO (will only be called if page ok)
201 ; ------------------------------------------------------------------------
202 ; SETCOLOR: Set the drawing color (in A). The new color is already checked
203 ; to be in a valid range (0..maxcolor-1).
205 ; Must set an error code: NO (will only be called if color ok)
212 ; ------------------------------------------------------------------------
213 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
214 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
217 ; Must set an error code: YES
233 ; ------------------------------------------------------------------------
234 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
235 ; set the palette should return the default palette here, so there's no
236 ; way for this function to fail.
238 ; Must set an error code: NO
243 ; ------------------------------------------------------------------------
244 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
245 ; drivers should return something reasonable here, even drivers that don't
246 ; support palettes, otherwise the caller has no way to determine the colors
247 ; of the (not changeable) palette.
249 ; Must set an error code: NO (all drivers must have a default palette)
257 ; ------------------------------------------------------------------------
258 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
259 ; color. The coordinates passed to this function are never outside the
260 ; visible screen area, so there is no need for clipping inside this function.
262 ; Must set an error code: NO
277 ; ------------------------------------------------------------------------
278 ; GETPIXEL: Read the color value of a pixel and return it in A/X. The
279 ; coordinates passed to this function are never outside the visible screen
280 ; area, so there is no need for clipping inside this function.
296 ; ------------------------------------------------------------------------
297 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
298 ; X2/Y2 = ptr3/ptr4 using the current drawing color.
300 ; Must set an error code: NO
321 ; ------------------------------------------------------------------------
322 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
323 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color.
324 ; Contrary to most other functions, the graphics kernel will sort and clip
325 ; the coordinates before calling the driver, so on entry the following
326 ; conditions are valid:
329 ; (X1 >= 0) && (X1 < XRES)
330 ; (X2 >= 0) && (X2 < XRES)
331 ; (Y1 >= 0) && (Y1 < YRES)
332 ; (Y2 >= 0) && (Y2 < YRES)
334 ; Must set an error code: NO
351 ; ------------------------------------------------------------------------
352 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
353 ; direction is passend in X/Y, the text direction is passed in A.
355 ; Must set an error code: NO
362 ; ------------------------------------------------------------------------
363 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
364 ; current text style. The text to output is given as a zero terminated
365 ; string with address in ptr3.
367 ; Must set an error code: NO