]> git.sur5r.net Git - cc65/blob - libsrc/telestrat/tgi/telestrat-228-200-3.s
Removed IRQ support from TGI drivers.
[cc65] / libsrc / telestrat / tgi / telestrat-228-200-3.s
1 ;
2 ; Graphics driver for the 228x200x3 palette mode on the Telestrat
3 ;
4 ; Jede (jede@oric.org), 2017-10-15
5
6         .include        "zeropage.inc"
7
8         .include        "tgi-kernel.inc"
9         .include        "tgi-error.inc"
10         .include        "telestrat.inc"
11
12         .macpack        generic
13         .macpack        module
14
15 XSIZE   =       6               ; System font width
16 YSIZE   =       8               ; System font height
17
18 ; ------------------------------------------------------------------------
19 ; Header. Includes jump table and constants.
20
21         module_header   _telestrat_228_200_3_tgi
22
23 ; The first part of the header is a structure that has a signature,
24 ; and defines the capabilities of the driver.
25
26         .byte   "tgi"
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
37
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).
40
41         .addr   INSTALL
42         .addr   UNINSTALL
43         .addr   INIT
44         .addr   DONE
45         .addr   GETERROR
46         .addr   CONTROL
47         .addr   CLEAR
48         .addr   SETVIEWPAGE
49         .addr   SETDRAWPAGE
50         .addr   SETCOLOR
51         .addr   SETPALETTE
52         .addr   GETPALETTE
53         .addr   GETDEFPALETTE
54         .addr   SETPIXEL
55         .addr   GETPIXEL
56         .addr   LINE
57         .addr   BAR
58         .addr   CIRCLE
59         .addr   TEXTSTYLE
60         .addr   OUTTEXT
61
62 ; ------------------------------------------------------------------------
63 ; Data.
64
65 ; Variables mapped to the zero-page segment variables. These are
66 ; used for passing parameters to the driver.
67
68 X1      :=      ptr1
69 Y1      :=      ptr2
70 X2      :=      ptr3
71 Y2      :=      ptr4
72
73 ; Absolute variables used in the code
74
75 .bss
76
77 ERROR:          .res    1       ; Error code
78 MODE:           .res    1       ; Graphics mode
79 PALETTE:        .res    2
80
81 ; Constant table
82
83 .rodata
84
85 ; Default colors: black background, white foreground
86 ; (The third "color" actually flips a pixel
87 ; between the foreground and background colors.)
88 ;
89 DEFPALETTE:     .byte   0, 1
90
91 .code
92
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
99 ; kernel later.
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.
102 ;
103 ; Must set an error code: YES
104 ;
105
106 INIT:
107
108 ; Switch into graphics mode.
109         BRK_TELEMON(XHIRES)
110        
111 ; Done, reset the error code.
112
113         lda     #TGI_ERR_OK
114         sta     ERROR
115         rts
116
117 ; ------------------------------------------------------------------------
118 ; GETERROR: Return the error code in A, and clear it.
119
120 GETERROR:
121         ldx     #TGI_ERR_OK
122         lda     ERROR
123         stx     ERROR
124         rts
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
128 ; most of the time.
129 ;
130 ; Must set an error code: NO
131 ;
132
133 INSTALL:
134
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.
138 ;
139 ; Must set an error code: NO
140 ;
141
142 UNINSTALL:
143         rts
144
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.
149 ;
150 ; Must set an error code: NO
151 ;
152
153 DONE:
154         BRK_TELEMON(XTEXT)
155         rts
156 ; ------------------------------------------------------------------------
157 ; CONTROL: Platform-/driver-specific entry point.
158 ;
159 ; Must set an error code: YES
160 ;
161
162 CONTROL:
163         ; not done yet
164         rts
165
166 ; ------------------------------------------------------------------------
167 ; CLEAR: Clears the screen.
168 ;
169 ; Must set an error code: NO
170 ;
171
172 CLEAR:
173         ; not done yet
174         rts
175
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.
179 ;
180 ; Must set an error code: NO (will be called only if page OK)
181 ;
182
183 SETVIEWPAGE:
184
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.
188 ;
189 ; Must set an error code: NO (will be called only if page OK)
190 ;
191
192 SETDRAWPAGE:
193         rts
194
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).
198 ;
199 ; Must set an error code: NO (will be called only if color OK)
200 ;
201
202 SETCOLOR:
203         ; not done yet
204         rts
205
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
209 ; are not supported.
210 ;
211 ; Must set an error code: YES
212 ;
213
214 SETPALETTE:
215         ; not done yet
216         rts
217
218 flipcolor:
219         ; not done yet
220         rts
221
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.
226 ;
227 ; Must set an error code: NO
228 ;
229
230 GETPALETTE:
231         ; not done yet
232         rts
233
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.
239 ;
240 ; Must set an error code: NO (all drivers must have a default palette)
241 ;
242
243 GETDEFPALETTE:
244         lda     #<DEFPALETTE
245         ldx     #>DEFPALETTE
246         rts
247
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.
252 ;
253 ; Must set an error code: NO
254 ;
255
256 SETPIXEL:
257         lda #$80
258         
259 SETPIXELSETMODE:
260         sta HRSFB
261         lda X1
262         sta HRS1
263         lda Y1
264         sta HRS2
265         
266
267         
268         BRK_TELEMON(XCURSE)
269         
270         rts
271
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.
276
277 GETPIXEL:
278         ; not done yet
279         rts
280
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.
284 ;
285 ; Must set an error code: NO
286 ;
287
288 LINE:
289         ; not done yet
290         lda   X1
291         sta   HRS1
292         lda   Y1
293         sta   HRS2
294         
295         lda   X2
296         sta   HRS3
297         lda   Y2
298         sta   HRS4
299         
300         lda   #$ff
301         sta   HRSPAT
302
303         BRK_TELEMON(XDRAWA)
304         rts
305
306      
307         
308 CIRCLE:
309         ; not done yet
310         rts
311         
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:
318 ;       X1 <= X2
319 ;       Y1 <= Y2
320 ;       (X1 >= 0) && (X1 < XRES)
321 ;       (X2 >= 0) && (X2 < XRES)
322 ;       (Y1 >= 0) && (Y1 < YRES)
323 ;       (Y2 >= 0) && (Y2 < YRES)
324 ;
325 ; Must set an error code: NO
326 ;
327
328 BAR:
329         ; not done yet
330         rts
331
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.
335 ;
336 ; Must set an error code: NO
337 ;
338
339 TEXTSTYLE:
340         rts
341
342
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.
347 ;
348 ; Must set an error code: NO
349 ;
350
351 OUTTEXT:
352         ; put hires cursor in X & Y
353         lda   #$00
354         jsr   SETPIXELSETMODE
355         
356         
357         ; count the length of the string
358         ldy   #$00
359 loop:        
360         lda   (ptr3),y
361         beq   out
362         iny
363         bne   loop
364 out:
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
367         tya 
368         tax
369     
370         lda   ptr3     ; XSCHAR needs in A and Y the adress of the string        
371         ldy   ptr3+1    
372         BRK_TELEMON(XSCHAR)
373         rts