2 ; Graphics driver for the 228x200x3 palette mode on the Atmos
4 ; Stefan Haubenthal <polluks@sdf.lonestar.org>
5 ; 2013-07-15, Greg King <gregdk@users.sf.net>
8 .include "zeropage.inc"
10 .include "tgi-kernel.inc"
11 .include "tgi-error.inc"
17 XSIZE = 6 ; System font width
18 YSIZE = 8 ; System font height
20 ; ------------------------------------------------------------------------
21 ; Header. Includes jump table and constants.
23 module_header _atmos_228_200_3_tgi
25 ; The first part of the header is a structure that has a signature,
26 ; and defines the capabilities of the driver.
29 .byte TGI_API_VERSION ; TGI API version number
30 .addr $0000 ; Library reference
31 .word 228 ; x resolution
32 .word 200 ; y resolution
33 .byte 3 ; Number of drawing colors
34 .byte 1 ; Number of screens available
35 .byte XSIZE ; System font x size
36 .byte YSIZE ; System font y size
37 .word $011C ; Aspect ratio (based on 4/3 display)
38 .byte 0 ; TGI driver flags
40 ; Next comes the jump table. Currently, all entries must be valid;
41 ; and, may point to an RTS, for test versions (function not implemented).
62 .addr 0 ; IRQ entry is unused
64 ; ------------------------------------------------------------------------
67 ; Variables mapped to the zero-page segment variables. These are
68 ; used for passing parameters to the driver.
75 ; Absolute variables used in the code
79 ERROR: .res 1 ; Error code
80 MODE: .res 1 ; Graphics mode
87 ; Default colors: black background, white foreground
88 ; (The third "color" actually flips a pixel
89 ; between the foreground and background colors.)
91 DEFPALETTE: .byte 0, 1
95 ; ------------------------------------------------------------------------
96 ; INIT: Changes an already installed device from text mode to graphics mode.
97 ; Note that INIT/DONE may be called multiple times while the driver
98 ; is loaded, while INSTALL is called only once. So, any code that is needed
99 ; to initialize variables and so on must go here. Setting palette and
100 ; clearing the screen are not needed because they are called by the graphics
102 ; The graphics kernel never will call INIT when a graphics mode is already
103 ; active, so there is no need to protect against that.
105 ; Must set an error code: YES
110 ; Switch into graphics mode.
114 ; Done, reset the error code.
116 ; ------------------------------------------------------------------------
117 ; GETERROR: Return the error code in A, and clear it.
124 ; ------------------------------------------------------------------------
125 ; INSTALL routine. Is called after the driver is loaded into memory. May
126 ; initialize anything that has to be done just once. Is probably empty
129 ; Must set an error code: NO
134 ; ------------------------------------------------------------------------
135 ; UNINSTALL routine. Is called before the driver is removed from memory. May
136 ; clean up anything done by INSTALL, but probably is empty most of the time.
138 ; Must set an error code: NO
144 ; ------------------------------------------------------------------------
145 ; DONE: Will be called to switch the graphics device back into text mode.
146 ; The graphics kernel never will call DONE when no graphics mode is active,
147 ; so there is no need to protect against that.
149 ; Must set an error code: NO
154 ; ------------------------------------------------------------------------
155 ; CONTROL: Platform-/driver-specific entry point.
157 ; Must set an error code: YES
166 ; ------------------------------------------------------------------------
167 ; CLEAR: Clears the screen.
169 ; Must set an error code: NO
174 ; ------------------------------------------------------------------------
175 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
176 ; The page number already is checked to be valid, by the graphics kernel.
178 ; Must set an error code: NO (will be called only if page OK)
183 ; ------------------------------------------------------------------------
184 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
185 ; The page number already is checked to be valid, by the graphics kernel.
187 ; Must set an error code: NO (will be called only if page OK)
193 ; ------------------------------------------------------------------------
194 ; SETCOLOR: Set the drawing color (in A). The new color already is checked
195 ; to be in a valid range (0..maxcolor-1).
197 ; Must set an error code: NO (will be called only if color OK)
204 ; ------------------------------------------------------------------------
205 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
206 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
209 ; Must set an error code: YES
235 ; ------------------------------------------------------------------------
236 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
237 ; set the palette should return the default palette here, so there's no
238 ; way for this function to fail.
240 ; Must set an error code: NO
248 ; ------------------------------------------------------------------------
249 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
250 ; drivers should return something reasonable here, even drivers that don't
251 ; support palettes; otherwise, the caller has no way to determine the colors
252 ; of the (not changeable) palette.
254 ; Must set an error code: NO (all drivers must have a default palette)
262 ; ------------------------------------------------------------------------
263 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
264 ; color. The co-ordinates passed to this function are never outside the
265 ; visible screen area, so there is no need for clipping inside this function.
267 ; Must set an error code: NO
276 add #2 * XSIZE ; Skip screen attribute columns
284 ; ------------------------------------------------------------------------
285 ; GETPIXEL: Read the color value of a pixel, and return it in A/X. The
286 ; co-ordinates passed to this function are never outside the visible screen
287 ; area, so there is no need for clipping inside this function.
303 ; ------------------------------------------------------------------------
304 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
305 ; X2/Y2 = ptr3/ptr4, using the current drawing color.
307 ; Must set an error code: NO
330 ; ------------------------------------------------------------------------
331 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
332 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4, using the current drawing color.
333 ; Contrary to most other functions, the graphics kernel will sort and clip
334 ; the co-ordinates before calling the driver; so, on entry, the following
335 ; conditions are valid:
338 ; (X1 >= 0) && (X1 < XRES)
339 ; (X2 >= 0) && (X2 < XRES)
340 ; (Y1 >= 0) && (Y1 < YRES)
341 ; (Y2 >= 0) && (Y2 < YRES)
343 ; Must set an error code: NO
360 ; ------------------------------------------------------------------------
361 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in the x
362 ; and y directions is passend in X/Y, the text direction is passed in A.
364 ; Must set an error code: NO
371 ; ------------------------------------------------------------------------
372 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
373 ; current text style. The text to output is given as a zero-terminated
374 ; string with its address in ptr3.
376 ; Must set an error code: NO
383 lda #3 ; (Move graphics cursor; don't draw)