2 ; Graphics driver for the 228x200x3 palette mode on the Telestrat
4 ; Jede (jede@oric.org), 2017-10-15
6 .include "zeropage.inc"
8 .include "tgi-kernel.inc"
9 .include "tgi-error.inc"
10 .include "telestrat.inc"
15 XSIZE = 6 ; System font width
16 YSIZE = 8 ; System font height
18 ; ------------------------------------------------------------------------
19 ; Header. Includes jump table and constants.
21 module_header _telestrat_228_200_3_tgi
23 ; The first part of the header is a structure that has a signature,
24 ; and defines the capabilities of the driver.
27 .byte TGI_API_VERSION ; TGI API version number
28 .addr $0000 ; Library reference
29 .word 228 ; x resolution
30 .word 200 ; y resolution
31 .byte 3 ; Number of drawing colors
32 .byte 1 ; Number of screens available
33 .byte XSIZE ; System font x size
34 .byte YSIZE ; System font y size
35 .word $011C ; Aspect ratio (based on 4/3 display)
36 .byte 0 ; TGI driver flags
38 ; Next comes the jump table. Currently, all entries must be valid;
39 ; and, may point to an RTS, for test versions (function not implemented).
62 ; ------------------------------------------------------------------------
65 ; Variables mapped to the zero-page segment variables. These are
66 ; used for passing parameters to the driver.
73 ; Absolute variables used in the code
77 ERROR: .res 1 ; Error code
78 MODE: .res 1 ; Graphics mode
85 ; Default colors: black background, white foreground
86 ; (The third "color" actually flips a pixel
87 ; between the foreground and background colors.)
89 DEFPALETTE: .byte 0, 1
93 ; ------------------------------------------------------------------------
94 ; INIT: Changes an already installed device from text mode to graphics mode.
95 ; Note that INIT/DONE may be called multiple times while the driver
96 ; is loaded, while INSTALL is called only once. So, any code that is needed
97 ; to initialize variables and so on must go here. Setting palette and
98 ; clearing the screen are not needed because they are called by the graphics
100 ; The graphics kernel never will call INIT when a graphics mode is already
101 ; active, so there is no need to protect against that.
103 ; Must set an error code: YES
108 ; Switch into graphics mode.
111 ; Done, reset the error code.
117 ; ------------------------------------------------------------------------
118 ; GETERROR: Return the error code in A, and clear it.
125 ; ------------------------------------------------------------------------
126 ; INSTALL routine. Is called after the driver is loaded into memory. May
127 ; initialize anything that has to be done just once. Is probably empty
130 ; Must set an error code: NO
135 ; ------------------------------------------------------------------------
136 ; UNINSTALL routine. Is called before the driver is removed from memory. May
137 ; clean up anything done by INSTALL, but probably is empty most of the time.
139 ; Must set an error code: NO
145 ; ------------------------------------------------------------------------
146 ; DONE: Will be called to switch the graphics device back into text mode.
147 ; The graphics kernel never will call DONE when no graphics mode is active,
148 ; so there is no need to protect against that.
150 ; Must set an error code: NO
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 already is checked to be valid, by the graphics kernel.
180 ; Must set an error code: NO (will be called only if page OK)
185 ; ------------------------------------------------------------------------
186 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
187 ; The page number already is checked to be valid, by the graphics kernel.
189 ; Must set an error code: NO (will be called only if page OK)
195 ; ------------------------------------------------------------------------
196 ; SETCOLOR: Set the drawing color (in A). The new color already is checked
197 ; to be in a valid range (0..maxcolor-1).
199 ; Must set an error code: NO (will be called only 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
222 ; ------------------------------------------------------------------------
223 ; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
224 ; set the palette should return the default palette here, so there's no
225 ; way for this function to fail.
227 ; Must set an error code: NO
234 ; ------------------------------------------------------------------------
235 ; GETDEFPALETTE: Return the default palette for the driver in A/X. All
236 ; drivers should return something reasonable here, even drivers that don't
237 ; support palettes; otherwise, the caller has no way to determine the colors
238 ; of the (not changeable) palette.
240 ; Must set an error code: NO (all drivers must have a default palette)
248 ; ------------------------------------------------------------------------
249 ; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
250 ; color. The co-ordinates passed to this function are never outside the
251 ; visible screen area, so there is no need for clipping inside this function.
253 ; Must set an error code: NO
272 ; ------------------------------------------------------------------------
273 ; GETPIXEL: Read the color value of a pixel, and return it in A/X. The
274 ; co-ordinates passed to this function are never outside the visible screen
275 ; area, so there is no need for clipping inside this function.
281 ; ------------------------------------------------------------------------
282 ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
283 ; X2/Y2 = ptr3/ptr4, using the current drawing color.
285 ; Must set an error code: NO
312 ; ------------------------------------------------------------------------
313 ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
314 ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4, using the current drawing color.
315 ; Contrary to most other functions, the graphics kernel will sort and clip
316 ; the co-ordinates before calling the driver; so, on entry, the following
317 ; conditions are valid:
320 ; (X1 >= 0) && (X1 < XRES)
321 ; (X2 >= 0) && (X2 < XRES)
322 ; (Y1 >= 0) && (Y1 < YRES)
323 ; (Y2 >= 0) && (Y2 < YRES)
325 ; Must set an error code: NO
332 ; ------------------------------------------------------------------------
333 ; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in the x
334 ; and y directions is passed in X/Y, the text direction is passed in A.
336 ; Must set an error code: NO
343 ; ------------------------------------------------------------------------
344 ; OUTTEXT: Output text at x/y = ptr1/ptr2, using the current color and the
345 ; current text style. The text to output is given as a zero-terminated
346 ; string with its address in ptr3.
348 ; Must set an error code: NO
352 ; put hires cursor in X & Y
357 ; count the length of the string
365 ; XSCHAR routine from telemon needs to have the length of the string in X register
366 ; copy Y register to X register. It could be optimized in 65C02 with TYX
370 lda ptr3 ; XSCHAR needs in A and Y the adress of the string