2 ; Graphics driver for the 240x200x2 monochrome mode on the Atmos
4 ; Stefan Haubenthal <polluks@sdf.lonestar.org>
5 ; 2014-09-10, Greg King <gregdk@users.sf.net>
8 .include "zeropage.inc"
10 .include "tgi-kernel.inc"
11 .include "tgi-error.inc"
12 .include "telestrat.inc"
17 XSIZE = 6 ; System font width
18 YSIZE = 8 ; System font height
20 ; ------------------------------------------------------------------------
21 ; Header. Includes jump table and constants.
23 module_header _telestrat_240_200_2_tgi
25 ; First part of the header is a structure that has a magic and defines the
26 ; capabilities of the driver
28 .byte $74, $67, $69 ; "tgi"
29 .byte TGI_API_VERSION ; TGI API version number
30 .addr $0000 ; Library reference
31 .word 240 ; X resolution
32 .word 200 ; Y resolution
33 .byte 2 ; 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 and may point
41 ; 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. Some of 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
86 DEFPALETTE: .byte 0, 1
90 ; ------------------------------------------------------------------------
91 ; INSTALL routine. Is called after the driver is loaded into memory. May
92 ; initialize anything that has to be done just once. Is probably empty
95 ; Must set an error code: NO
100 ; ------------------------------------------------------------------------
101 ; UNINSTALL routine. Is called before the driver is removed from memory. May
102 ; clean up anything done by INSTALL but is probably empty most of the time.
104 ; Must set an error code: NO
110 ; ------------------------------------------------------------------------
111 ; INIT: Changes an already installed device from text mode to graphics
113 ; Note that INIT/DONE may be called multiple times while the driver
114 ; is loaded, while INSTALL is only called once, so any code that is needed
115 ; to initializes variables and so on must go here. Setting palette and
116 ; clearing the screen is not needed because this is called by the graphics
118 ; The graphics kernel will never call INIT when a graphics mode is already
119 ; active, so there is no need to protect against that.
121 ; Must set an error code: YES
126 ; Switch into graphics mode
130 ; Done, reset the error code
136 ; ------------------------------------------------------------------------
137 ; DONE: Will be called to switch the graphics device back into text mode.
138 ; The graphics kernel will never call DONE when no graphics mode is active,
139 ; so there is no need to protect against that.
141 ; Must set an error code: NO
148 ; ------------------------------------------------------------------------
149 ; GETERROR: Return the error code in A and clear it.
157 ; ------------------------------------------------------------------------
158 ; CONTROL: Platform/driver specific entry point.
160 ; Must set an error code: YES
167 ; ------------------------------------------------------------------------
168 ; CLEAR: Clears the screen.
170 ; Must set an error code: NO
177 ; ------------------------------------------------------------------------
178 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
179 ; The page number is already checked to be valid by the graphics kernel.
181 ; Must set an error code: NO (will only be called if page ok)
186 ; ------------------------------------------------------------------------
187 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
188 ; The page number is already checked to be valid by the graphics kernel.
190 ; Must set an error code: NO (will only be called if page ok)
196 ; ------------------------------------------------------------------------
197 ; SETCOLOR: Set the drawing color (in A). The new color is already checked
198 ; to be in a valid range (0..maxcolor-1).
200 ; Must set an error code: NO (will only be called if color ok)
207 ; ------------------------------------------------------------------------
208 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
209 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
212 ; Must set an error code: YES
216 lda #TGI_ERR_INV_FUNC ; This resolution has no palette
220 ; ------------------------------------------------------------------------
221 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
222 ; set the palette should return the default palette here, so there's no
223 ; way for this function to fail.
225 ; Must set an error code: NO
230 ; ------------------------------------------------------------------------
231 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
232 ; drivers should return something reasonable here, even drivers that don't
233 ; support palettes, otherwise the caller has no way to determine the colors
234 ; of the (not changeable) palette.
236 ; Must set an error code: NO (all drivers must have a default palette)
243 ; ------------------------------------------------------------------------
244 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
245 ; color. The coordinates passed to this function are never outside the
246 ; visible screen area, so there is no need for clipping inside this function.
248 ; Must set an error code: NO
255 ; ------------------------------------------------------------------------
256 ; GETPIXEL: Read the color value of a pixel and return it in A/X. The
257 ; coordinates passed to this function are never outside the visible screen
258 ; area, so there is no need for clipping inside this function.
264 ; ------------------------------------------------------------------------
265 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
266 ; X2/Y2 = ptr3/ptr4 using the current drawing color.
268 ; Must set an error code: NO
274 ; ------------------------------------------------------------------------
275 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
276 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color.
277 ; Contrary to most other functions, the graphics kernel will sort and clip
278 ; the coordinates before calling the driver, so on entry the following
279 ; conditions are valid:
282 ; (X1 >= 0) && (X1 < XRES)
283 ; (X2 >= 0) && (X2 < XRES)
284 ; (Y1 >= 0) && (Y1 < YRES)
285 ; (Y2 >= 0) && (Y2 < YRES)
287 ; Must set an error code: NO
294 ; ------------------------------------------------------------------------
295 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
296 ; direction is passend in X/Y, the text direction is passed in A.
298 ; Must set an error code: NO
305 ; ------------------------------------------------------------------------
306 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
307 ; current text style. The text to output is given as a zero terminated
308 ; string with address in ptr3.
310 ; Must set an error code: NO