2 ; Graphics driver for the 240x200x2 monochrome mode on the Atmos
4 ; Jede (jede@oric.org), 2017-10-15
7 .include "zeropage.inc"
9 .include "tgi-kernel.inc"
10 .include "tgi-error.inc"
11 .include "telestrat.inc"
16 XSIZE = 6 ; System font width
17 YSIZE = 8 ; System font height
19 ; ------------------------------------------------------------------------
20 ; Header. Includes jump table and constants.
22 module_header _telestrat_240_200_2_tgi
24 ; First part of the header is a structure that has a magic and defines the
25 ; capabilities of the driver
27 .byte $74, $67, $69 ; "tgi"
28 .byte TGI_API_VERSION ; TGI API version number
29 .addr $0000 ; Library reference
30 .word 240 ; X resolution
31 .word 200 ; Y resolution
32 .byte 2 ; Number of drawing colors
33 .byte 1 ; Number of screens available
34 .byte XSIZE ; System font X size
35 .byte YSIZE ; System font Y size
36 .word $011C ; Aspect ratio (based on 4/3 display)
37 .byte 0 ; TGI driver flags
39 ; Next comes the jump table. Currently all entries must be valid and may point
40 ; to an RTS for test versions (function not implemented).
61 .addr 0 ; IRQ entry is unused
63 ; ------------------------------------------------------------------------
66 ; Variables mapped to the zero page segment variables. Some of these are
67 ; used for passing parameters to the driver.
74 ; Absolute variables used in the code
78 ERROR: .res 1 ; Error code
79 MODE: .res 1 ; Graphics mode
85 DEFPALETTE: .byte 0, 1
89 ; ------------------------------------------------------------------------
90 ; INSTALL routine. Is called after the driver is loaded into memory. May
91 ; initialize anything that has to be done just once. Is probably empty
94 ; Must set an error code: NO
99 ; ------------------------------------------------------------------------
100 ; UNINSTALL routine. Is called before the driver is removed from memory. May
101 ; clean up anything done by INSTALL but is probably empty most of the time.
103 ; Must set an error code: NO
109 ; ------------------------------------------------------------------------
110 ; INIT: Changes an already installed device from text mode to graphics
112 ; Note that INIT/DONE may be called multiple times while the driver
113 ; is loaded, while INSTALL is only called once, so any code that is needed
114 ; to initializes variables and so on must go here. Setting palette and
115 ; clearing the screen is not needed because this is called by the graphics
117 ; The graphics kernel will never call INIT when a graphics mode is already
118 ; active, so there is no need to protect against that.
120 ; Must set an error code: YES
125 ; Switch into graphics mode
129 ; Done, reset the error code
135 ; ------------------------------------------------------------------------
136 ; DONE: Will be called to switch the graphics device back into text mode.
137 ; The graphics kernel will never call DONE when no graphics mode is active,
138 ; so there is no need to protect against that.
140 ; Must set an error code: NO
147 ; ------------------------------------------------------------------------
148 ; GETERROR: Return the error code in A and clear it.
156 ; ------------------------------------------------------------------------
157 ; CONTROL: Platform/driver specific entry point.
159 ; Must set an error code: YES
166 ; ------------------------------------------------------------------------
167 ; CLEAR: Clears the screen.
169 ; Must set an error code: NO
176 ; ------------------------------------------------------------------------
177 ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
178 ; The page number is already checked to be valid by the graphics kernel.
180 ; Must set an error code: NO (will only be called if page ok)
185 ; ------------------------------------------------------------------------
186 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
187 ; The page number is already checked to be valid by the graphics kernel.
189 ; Must set an error code: NO (will only be called if page ok)
195 ; ------------------------------------------------------------------------
196 ; SETCOLOR: Set the drawing color (in A). The new color is already checked
197 ; to be in a valid range (0..maxcolor-1).
199 ; Must set an error code: NO (will only be called if color ok)
206 ; ------------------------------------------------------------------------
207 ; SETPALETTE: Set the palette (not available with all drivers/hardware).
208 ; A pointer to the palette is passed in ptr1. Must set an error if palettes
211 ; Must set an error code: YES
215 lda #TGI_ERR_INV_FUNC ; This resolution has no palette
219 ; ------------------------------------------------------------------------
220 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
221 ; set the palette should return the default palette here, so there's no
222 ; way for this function to fail.
224 ; Must set an error code: NO
229 ; ------------------------------------------------------------------------
230 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
231 ; drivers should return something reasonable here, even drivers that don't
232 ; support palettes, otherwise the caller has no way to determine the colors
233 ; of the (not changeable) palette.
235 ; Must set an error code: NO (all drivers must have a default palette)
242 ; ------------------------------------------------------------------------
243 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
244 ; color. The coordinates passed to this function are never outside the
245 ; visible screen area, so there is no need for clipping inside this function.
247 ; Must set an error code: NO
266 ; ------------------------------------------------------------------------
267 ; GETPIXEL: Read the color value of a pixel and return it in A/X. The
268 ; coordinates passed to this function are never outside the visible screen
269 ; area, so there is no need for clipping inside this function.
275 ; ------------------------------------------------------------------------
276 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
277 ; X2/Y2 = ptr3/ptr4 using the current drawing color.
279 ; Must set an error code: NO
305 ; ------------------------------------------------------------------------
306 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
307 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color.
308 ; Contrary to most other functions, the graphics kernel will sort and clip
309 ; the coordinates before calling the driver, so on entry the following
310 ; conditions are valid:
313 ; (X1 >= 0) && (X1 < XRES)
314 ; (X2 >= 0) && (X2 < XRES)
315 ; (Y1 >= 0) && (Y1 < YRES)
316 ; (Y2 >= 0) && (Y2 < YRES)
318 ; Must set an error code: NO
325 ; ------------------------------------------------------------------------
326 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
327 ; direction is passend in X/Y, the text direction is passed in A.
329 ; Must set an error code: NO
336 ; ------------------------------------------------------------------------
337 ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
338 ; current text style. The text to output is given as a zero terminated
339 ; string with address in ptr3.
341 ; Must set an error code: NO
345 ; put hires cursor in X & Y
350 ; count the length of the string
358 ; XSCHAR routine from telemon needs to have the length of the string in X register
359 ; copy Y register to X register. It could be optimized in 65C02 with TYX
363 lda ptr3 ; XSCHAR needs in A and Y the adress of the string