]> git.sur5r.net Git - cc65/blob - doc/tgi.sgml
Splitting of funcref
[cc65] / doc / tgi.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4 <title>Tiny Graphics Interface
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
6 <date>2017-11-23
7
8 <abstract>
9 The cc65 library provides functions for platform independent graphics.
10 Include the tgi.h header file to get the necessary definitions.
11 </abstract>
12
13 <!-- Table of contents -->
14 <itemize>
15 <item><ref id="tgi_arc" name="tgi_arc">
16 <item><ref id="tgi_bar" name="tgi_bar">
17 <item><ref id="tgi_circle" name="tgi_circle">
18 <item><ref id="tgi_clear" name="tgi_clear">
19 <item><ref id="tgi_done" name="tgi_done">
20 <item><ref id="tgi_ellipse" name="tgi_ellipse">
21 <item><ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
22 <item><ref id="tgi_getaspectratio" name="tgi_getaspectratio">
23 <item><ref id="tgi_getcolor" name="tgi_getcolor">
24 <item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
25 <item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
26 <item><ref id="tgi_geterror" name="tgi_geterror">
27 <item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
28 <item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
29 <item><ref id="tgi_getmaxx" name="tgi_getmaxx">
30 <item><ref id="tgi_getmaxy" name="tgi_getmaxy">
31 <item><ref id="tgi_getpagecount" name="tgi_getpagecount">
32 <item><ref id="tgi_getpalette" name="tgi_getpalette">
33 <item><ref id="tgi_getpixel" name="tgi_getpixel">
34 <item><ref id="tgi_gettextheight" name="tgi_gettextheight">
35 <item><ref id="tgi_gettextwidth" name="tgi_gettextwidth">
36 <item><ref id="tgi_getxres" name="tgi_getxres">
37 <item><ref id="tgi_getyres" name="tgi_getyres">
38 <item><ref id="tgi_gotoxy" name="tgi_gotoxy">
39 <item><ref id="tgi_init" name="tgi_init">
40 <item><ref id="tgi_install" name="tgi_install">
41 <item><ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
42 <item><ref id="tgi_ioctl" name="tgi_ioctl">
43 <item><ref id="tgi_line" name="tgi_line">
44 <item><ref id="tgi_lineto" name="tgi_lineto">
45 <item><ref id="tgi_load_driver" name="tgi_load_driver">
46 <item><ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">
47 <item><ref id="tgi_outtext" name="tgi_outtext">
48 <item><ref id="tgi_outtextxy" name="tgi_outtextxy">
49 <item><ref id="tgi_setaspectratio" name="tgi_setaspectratio">
50 <item><ref id="tgi_setcolor" name="tgi_setcolor">
51 <item><ref id="tgi_setdrawpage" name="tgi_setdrawpage">
52 <item><ref id="tgi_setpalette" name="tgi_setpalette">
53 <item><ref id="tgi_setpixel" name="tgi_setpixel">
54 <item><ref id="tgi_setviewpage" name="tgi_setviewpage">
55 <item><ref id="tgi_settextscale" name="tgi_settextscale">
56 <item><ref id="tgi_settextstyle" name="tgi_settextstyle">
57 <item><ref id="tgi_uninstall" name="tgi_uninstall">
58 <item><ref id="tgi_unload" name="tgi_unload">
59 </itemize>
60
61 <!-- Begin the document -->
62
63 <sect1>tgi_arc<label id="tgi_arc"><p>
64
65 <quote>
66 <descrip>
67 <tag/Function/Draw an elliptic arc in the current color.
68 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
69 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
70 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
71 <tag/Description/The function draws an elliptic arc with center at x/y and
72 radii rx/ry using the current drawing color. The arc covers the angle
73 between sa and ea (startangle and endangle), which must be in the range
74 0..360.
75 <tag/Notes/<itemize>
76 <item>The function is only available as fastcall function, so it may only
77 be used in presence of a prototype.
78 <item>The function behaves unexpectedly or may crash if the angles are out
79 of range.
80 </itemize>
81 <tag/Availability/cc65
82 <tag/See also/
83 <ref id="tgi_bar" name="tgi_bar">,
84 <ref id="tgi_circle" name="tgi_circle">,
85 <ref id="tgi_ellipse" name="tgi_ellipse">,
86 <ref id="tgi_pieslice" name="tgi_pieslice">,
87 <ref id="tgi_setcolor" name="tgi_setcolor">
88 <tag/Example/<verb>
89 /* Draw the upper half of an ellipse */
90 tgi_setcolor(TGI_COLOR_BLUE);
91 tgi_arc (50, 50, 40, 20, 0, 180);
92 </verb>
93 </descrip>
94 </quote>
95
96
97 <sect1>tgi_bar<label id="tgi_bar"><p>
98
99 <quote>
100 <descrip>
101 <tag/Function/The function fills a rectangle on the drawpage with the current
102 color.
103 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
104 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
105 <tag/Description/The function fills a rectangle on the drawpage with the current
106 color.
107 <tag/Notes/<itemize>
108 <item>The function is only available as fastcall function, so it may only
109 be used in presence of a prototype.
110 </itemize>
111 <tag/Availability/cc65
112 <tag/See also/Other tgi function
113 <tag/Example/<verb>
114 tgi_setcolor(TGI_COLOR_GREEN);
115 tgi_bar(10, 10, 100, 60);
116 </verb>
117 </descrip>
118 </quote>
119
120
121 <sect1>tgi_circle<label id="tgi_circle"><p>
122
123 <quote>
124 <descrip>
125 <tag/Function/The function draws a circle in the current color.
126 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
127 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
128 <tag/Description/The function draws a circle in the current color.
129 <tag/Notes/<itemize>
130 <item>The function is only available as fastcall function, so it may only
131 be used in presence of a prototype.
132 </itemize>
133 <tag/Availability/cc65
134 <tag/See also/
135 <ref id="tgi_arc" name="tgi_arc">,
136 <ref id="tgi_bar" name="tgi_bar">,
137 <ref id="tgi_ellipse" name="tgi_ellipse">,
138 <ref id="tgi_pieslice" name="tgi_pieslice">,
139 <ref id="tgi_setcolor" name="tgi_setcolor">
140 <tag/Example/<verb>
141 tgi_setcolor(TGI_COLOR_BLACK);
142 tgi_circle(50, 40, 40);
143 </verb>
144 </descrip>
145 </quote>
146
147
148 <sect1>tgi_clear<label id="tgi_clear"><p>
149
150 <quote>
151 <descrip>
152 <tag/Function/Clear the drawpage
153 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
154 <tag/Declaration/<tt/void tgi_clear (void);/
155 <tag/Description/Clear the drawpage
156 <tag/Availability/cc65
157 <tag/See also/Other tgi functions
158 <tag/Example/None.
159 </descrip>
160 </quote>
161
162
163 <sect1>tgi_done<label id="tgi_done"><p>
164
165 <quote>
166 <descrip>
167 <tag/Function/End graphics mode, switch back to text mode.
168 Will NOT uninstall or unload the driver!
169 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
170 <tag/Declaration/<tt/void tgi_done (void);/
171 <tag/Description/End graphics mode, switch back to text mode.
172 Will NOT uninstall or unload the driver!
173 <tag/Availability/cc65
174 <tag/See also/Other tgi functions
175 <tag/Example/None.
176 </descrip>
177 </quote>
178
179
180 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
181
182 <quote>
183 <descrip>
184 <tag/Function/The function draws an ellipse in the current color.
185 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
186 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
187 <tag/Description/The function draws an ellipse at position x/y with radii
188 rx and ry, using the current drawing color.
189 <tag/Notes/<itemize>
190 <item>The function is only available as fastcall function, so it may only
191 be used in presence of a prototype.
192 </itemize>
193 <tag/Availability/cc65
194 <tag/See also/
195 <ref id="tgi_arc" name="tgi_arc">,
196 <ref id="tgi_bar" name="tgi_bar">,
197 <ref id="tgi_circle" name="tgi_circle">,
198 <ref id="tgi_pieslice" name="tgi_pieslice">,
199 <ref id="tgi_setcolor" name="tgi_setcolor">
200 <tag/Example/<verb>
201 tgi_setcolor(TGI_COLOR_RED);
202 tgi_ellipse (50, 40, 40, 20);
203 </verb>
204 </descrip>
205 </quote>
206
207
208 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
209
210 <quote>
211 <descrip>
212 <tag/Function/Free a vector font that was previously loaded into memory.
213 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
214 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
215 <tag/Description/Free a vector font that was previously loaded into memory.
216 <tag/Notes/<itemize>
217 <item>The function is only available as fastcall function, so it may only
218 be used in presence of a prototype.
219 </itemize>
220 <tag/Availability/cc65
221 <tag/See also/
222 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
223 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
224 <tag/Example/None.
225 </descrip>
226 </quote>
227
228
229 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
230
231 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
232 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
233 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
234 <tag/Description/The function returns the pixel aspect ratio for the current
235 driver and display as an 8.8 fixed point value. It may be used to correct
236 geometric shapes so they look correct on the display. As an example, a circle
237 with a radius of 100 pixels may look elliptic on some driver/display
238 combinations if the aspect ratio is not 1.00.
239 <tag/Notes/<itemize>
240 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
241 monitor for the given platform. The aspect ratio may be wrong if another
242 monitor is used.
243 <item>No TGI function will use the aspect ratio. It is up to the programmer to
244 make use of it.
245 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
246 be used to change the aspect ratio for a loaded driver. The value is not reset
247 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
248 an application, switching into and out of graphics mode will not restore the
249 original aspect ratio.
250 </itemize>
251 <tag/Availability/cc65
252 <tag/See also/
253 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
254 <tag/Example/None.
255 </descrip>
256 </quote>
257
258
259 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
260
261 <quote>
262 <descrip>
263 <tag/Function/Return the current drawing color.
264 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
265 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
266 <tag/Description/The actual color is an index to a palette. During tgi_init
267 you will get a default palette. The number of colors depend on the platform.
268 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
269 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
270 and then you change the green of the palette to blue using tgi_setpalette then
271 after this painting in TGI_COLOR_GREEN will actually be blue.
272 <tag/Availability/cc65
273 <tag/See also/Other tgi functions
274 <tag/Example/<verb>
275 color = tgi_getcolor();
276 </verb>
277 </descrip>
278 </quote>
279
280
281 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
282
283 <quote>
284 <descrip>
285 <tag/Function/Get the number of available colors.
286 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
287 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
288 <tag/Description/Tgi platforms use indexed color palettes. This function
289 returns the number of entries we can use in the palette.
290 <tag/Availability/cc65
291 <tag/See also/Other tgi functions
292 <tag/Example/<verb>
293 if (tgi_getcolorcount() == 2) {
294   printf("Only monochrome graphics is supported\n");
295 }
296 </verb>
297 </descrip>
298 </quote>
299
300
301 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
302
303 <quote>
304 <descrip>
305 <tag/Function/Get the palette installed by default.
306 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
307 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
308 <tag/Description/The tgi driver has a default palette that is active at startup.
309 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
310 palette to work correctly.
311 <tag/Availability/cc65
312 <tag/See also/Other tgi functions
313 <tag/Example/None.
314 </descrip>
315 </quote>
316
317
318 <sect1>tgi_geterror<label id="tgi_geterror"><p>
319
320 <quote>
321 <descrip>
322 <tag/Function/Return the error code for the last operation.
323 This will also clear the error.
324 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
325 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
326 <tag/Description/Return the error code for the last operation.
327 This will also clear the error.
328 <tag/Availability/cc65
329 <tag/See also/Other tgi functions
330 <tag/Example/None.
331 </descrip>
332 </quote>
333
334
335 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
336
337 <quote>
338 <descrip>
339 <tag/Function/Get an error message describing the error.
340 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
341 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
342 <tag/Description/Get an error message describing the error.
343 <tag/Notes/<itemize>
344 <item>The function is only available as fastcall function, so it may only
345 be used in presence of a prototype.
346 </itemize>
347 <tag/Availability/cc65
348 <tag/See also/Other tgi functions
349 <tag/Example/None.
350 </descrip>
351 </quote>
352
353
354 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
355
356 <quote>
357 <descrip>
358 <tag/Function/Get the highest index of the palette.
359 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
360 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
361 <tag/Description/Get the highest index of the palette.
362 <tag/Availability/cc65
363 <tag/See also/Other tgi functions
364 <tag/Example/None.
365 </descrip>
366 </quote>
367
368
369 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
370
371 <quote>
372 <descrip>
373 <tag/Function/Get the maximum x coordinate that can be used on this screen.
374 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
375 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
376 <tag/Description/Get the maximum x coordinate that can be used on this screen.
377 <tag/Availability/cc65
378 <tag/See also/Other tgi functions
379 <tag/Example/None.
380 </descrip>
381 </quote>
382
383
384 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
385
386 <quote>
387 <descrip>
388 <tag/Function/Get the maximum y coordinate that can be used on this screen.
389 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
390 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
391 <tag/Description/Get the maximum y coordinate that can be used on this screen.
392 <tag/Availability/cc65
393 <tag/See also/Other tgi functions
394 <tag/Example/None.
395 </descrip>
396 </quote>
397
398
399 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
400
401 <quote>
402 <descrip>
403 <tag/Function/Return the number of screen pages available.
404 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
405 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
406 <tag/Description/Return the number of screen pages available.
407 <tag/Availability/cc65
408 <tag/See also/
409 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
410 <ref id="tgi_setviewpage" name="tgi_setviewpage">
411 <tag/Example/None.
412 </descrip>
413 </quote>
414
415
416 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
417
418 <quote>
419 <descrip>
420 <tag/Function/Get the palette installed.
421 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
422 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
423 <tag/Description/Get the palette installed.
424 <tag/Availability/cc65
425 <tag/See also/Other tgi functions
426 <tag/Example/None.
427 </descrip>
428 </quote>
429
430
431 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
432
433 <quote>
434 <descrip>
435 <tag/Function/Get the color of a pixel from the viewpage.
436 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
437 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
438 <tag/Description/Get the color of a pixel from the viewpage.
439 <tag/Notes/<itemize>
440 <item>The function is only available as fastcall function, so it may only
441 be used in presence of a prototype.
442 </itemize>
443 <tag/Availability/cc65
444 <tag/See also/Other tgi functions.
445 <tag/Example/None.
446 </descrip>
447 </quote>
448
449
450 <sect1>tgi_getxres<label id="tgi_getxres"><p>
451
452 <quote>
453 <descrip>
454 <tag/Function/Get number of horisontal pixels on the screen.
455 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
456 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
457 <tag/Description/Get number of horisontal pixels on the screen.
458 This is same as tgi_maxx()+1.
459 <tag/Availability/cc65
460 <tag/See also/Other tgi functions.
461 <tag/Example/None.
462 </descrip>
463 </quote>
464
465
466 <sect1>tgi_getyres<label id="tgi_getyres"><p>
467
468 <quote>
469 <descrip>
470 <tag/Function/Get number of vertical pixels on the screen.
471 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
472 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
473 <tag/Description/Get number of vertical pixels on the screen.
474 This is same as tgi_maxy()+1.
475 <tag/Availability/cc65
476 <tag/See also/Other tgi functions.
477 <tag/Example/None.
478 </descrip>
479 </quote>
480
481
482 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
483
484 <quote>
485 <descrip>
486 <tag/Function/Set graphics cursor at x, y.
487 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
488 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
489 <tag/Description/Set graphics cursor at x, y.
490 <tag/Notes/<itemize>
491 <item>The function is only available as fastcall function, so it may only
492 be used in presence of a prototype.
493 </itemize>
494 <tag/Availability/cc65
495 <tag/See also/Other tgi functions.
496 <tag/Example/None.
497 </descrip>
498 </quote>
499
500
501 <sect1>tgi_init<label id="tgi_init"><p>
502
503 <quote>
504 <descrip>
505 <tag/Function/Initialize the already loaded graphics driver.
506 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
507 <tag/Declaration/<tt/void tgi_init (void);/
508 <tag/Description/The tgi_init function will set the default palette to the
509 hardware.
510 <tag/Notes/<itemize>
511 <item><tt/tgi_init/ will not clear the screen. This allows switching between
512 text and graphics mode on platforms that have separate memory areas for the
513 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
514 name="tgi_clear">/ after <tt/tgi_init/.
515 </itemize>
516 <tag/Availability/cc65
517 <tag/See also/Other tgi functions.
518 <tag/Example/<verb>
519 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
520 tgi_init(); //Set up the default palette and clear the screen.
521 </verb>
522 </descrip>
523 </quote>
524
525
526 <sect1>tgi_install<label id="tgi_install"><p>
527
528 <quote>
529 <descrip>
530 <tag/Function/Install an already loaded driver and return an error code.
531 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
532 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
533 <tag/Description/The function installs a driver that was already loaded into
534 memory (or linked statically to the program). It returns an error code
535 (<tt/TGI_ERR_OK/ in case of success).
536 <tag/Notes/<itemize>
537 <item>The function is only available as fastcall function, so it may only be
538 used in presence of a prototype.
539 </itemize>
540 <tag/Availability/cc65
541 <tag/See also/
542 <ref id="tgi_load_driver" name="tgi_load_driver">,
543 <ref id="tgi_uninstall" name="tgi_uninstall">,
544 <ref id="tgi_unload" name="tgi_unload">
545 <tag/Example/<verb>
546 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
547 tgi_init(); //Set up the default palette and clear the screen.
548 </verb>
549 </descrip>
550 </quote>
551
552
553 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
554
555 <quote>
556 <descrip>
557 <tag/Function/Install an already loaded driver and return an error code.
558 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
559 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
560 <tag/Description/
561 Install a vector font for use. More than one vector font can be loaded,
562 but only one can be active. This function is used to tell which one. Call
563 with a NULL pointer to uninstall the currently installed font.
564 <tag/Notes/<itemize>
565 <item>The function is only available as fastcall function, so it may only be
566 used in presence of a prototype.
567 </itemize>
568 <tag/Availability/cc65
569 <tag/See also/
570 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
571 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
572 <tag/Example/None.
573 </descrip>
574 </quote>
575
576
577 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
578
579 <quote>
580 <descrip>
581 <tag/Function/Platform dependent code extensions.
582 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
583 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
584 <tag/Description/Some platforms have extra display hardware that is not
585 supported by standard tgi functions. You can extend the driver to support
586 this extra hardware using tgi_ioctl functions.
587 <tag/Notes/<itemize>
588 <item>The function is only available as fastcall function, so it may only
589 be used in presence of a prototype.
590 <item>These functions are not easily portable to other cc65 platforms.
591 </itemize>
592 <tag/Availability/cc65
593 <tag/See also/Other tgi functions.
594 <tag/Example/<verb>
595 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
596 #define tgi_flip() tgi_ioctl(1, (void*)0)
597 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
598 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
599 #define tgi_busy() tgi_ioctl(4, (void*)0)
600 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
601 if (!tgi_busy()) {
602   tgi_sprite(&amp;background);
603   tgi_setcolor(TGI_COLOR_BLUE);
604   tgi_outttextxy(20,40,"Hello World");
605   tgi_updatedisplay();
606 }
607 </verb>
608 </descrip>
609 </quote>
610
611
612 <sect1>tgi_line<label id="tgi_line"><p>
613
614 <quote>
615 <descrip>
616 <tag/Function/Draw a line in the current drawing color.
617 The graphics cursor will be set to x2/y2 by this call.
618 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
619 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
620 <tag/Description/Draw a line in the current drawing color.
621 The graphics cursor will be set to x2/y2 by this call.
622 <tag/Notes/<itemize>
623 <item>The function is only available as fastcall function, so it may only
624 be used in presence of a prototype.
625 </itemize>
626 <tag/Availability/cc65
627 <tag/See also/Other tgi functions.
628 <tag/Example/None.
629 </descrip>
630 </quote>
631
632
633 <sect1>tgi_lineto<label id="tgi_lineto"><p>
634
635 <quote>
636 <descrip>
637 <tag/Function/Draw a line in the current drawing color from the graphics
638 cursor to the new end point. The graphics cursor will be updated to x2/y2.
639 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
640 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
641 <tag/Description/Draw a line in the current drawing color from the graphics
642 cursor to the new end point. The graphics cursor will be updated to x2/y2.
643 <tag/Notes/<itemize>
644 <item>The function is only available as fastcall function, so it may only
645 be used in presence of a prototype.
646 </itemize>
647 <tag/Availability/cc65
648 <tag/See also/Other tgi functions.
649 <tag/Example/None.
650 </descrip>
651 </quote>
652
653
654 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
655
656 <quote>
657 <descrip>
658 <tag/Function/Load and install the given driver.
659 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
660 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
661 <tag/Description/Load and install the driver by name.
662 Will just load the driver and check if loading was successful.
663 Will not switch to graphics mode.
664 <tag/Notes/<itemize>
665 <item>The function is only available as fastcall function, so it may only
666 be used in presence of a prototype.
667 </itemize>
668 <tag/Availability/cc65
669 <tag/See also/Other tgi functions.
670 <tag/Example/None.
671 </descrip>
672 </quote>
673
674
675 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
676
677 <quote>
678 <descrip>
679 <tag/Function/Load the given vector font.
680 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
681 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
682 <tag/Description/
683 Load a vector font into memory and return it. In case of errors, NULL is
684 returned and an error is set, which can be retrieved using tgi_geterror.
685 To use the font, it has to be installed using tgi_install_vectorfont.
686 <tag/Notes/<itemize>
687 <item>The function is only available as fastcall function, so it may only
688 be used in presence of a prototype.
689 </itemize>
690 <tag/Availability/cc65
691 <tag/See also/
692 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
693 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
694 <tag/Example/None.
695 </descrip>
696 </quote>
697
698
699 <sect1>tgi_outtext<label id="tgi_outtext"><p>
700
701 <quote>
702 <descrip>
703 <tag/Function/Output text at the current graphics cursor position.
704 The graphics cursor is moved to the end of the text.
705 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
706 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
707 <tag/Description/Output text at the current graphics cursor position.
708 The graphics cursor is moved to the end of the text.
709 <tag/Notes/<itemize>
710 <item>The function is only available as fastcall function, so it may only
711 be used in presence of a prototype.
712 </itemize>
713 <tag/Availability/cc65
714 <tag/See also/Other tgi functions.
715 <tag/Example/None.
716 </descrip>
717 </quote>
718
719
720 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
721
722 <quote>
723 <descrip>
724 <tag/Function/Output text at the given cursor position.
725 The graphics cursor is moved to the end of the text.
726 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
727 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
728 <tag/Description/Output text at the given cursor position.
729 The graphics cursor is moved to the end of the text.
730 <tag/Notes/<itemize>
731 <item>The function is only available as fastcall function, so it may only
732 be used in presence of a prototype.
733 </itemize>
734 <tag/Availability/cc65
735 <tag/See also/Other tgi functions.
736 <tag/Example/None.
737 </descrip>
738 </quote>
739
740
741 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
742
743 <quote>
744 <descrip>
745 <tag/Function/Draw an elliptic pie slice in the current color.
746 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
747 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
748 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
749 <tag/Description/The function draws an elliptic pie slice with center at x/y
750 and radii rx/ry using the current drawing color. The pie slice covers the angle
751 between sa and ea (startangle and endangle), which must be in the range
752 0..360.
753 <tag/Notes/<itemize>
754 <item>The function is only available as fastcall function, so it may only
755 be used in presence of a prototype.
756 <item>The function behaves unexpectedly or may crash if the angles are out
757 of range.
758 </itemize>
759 <tag/Availability/cc65
760 <tag/See also/
761 <ref id="tgi_bar" name="tgi_arc">,
762 <ref id="tgi_bar" name="tgi_bar">,
763 <ref id="tgi_circle" name="tgi_circle">,
764 <ref id="tgi_ellipse" name="tgi_ellipse">,
765 <ref id="tgi_setcolor" name="tgi_setcolor">
766 <tag/Example/<verb>
767 /* Draw the closed upper half of an ellipse */
768 tgi_setcolor(TGI_COLOR_BLUE);
769 tgi_pieslice (50, 50, 40, 20, 0, 180);
770 </verb>
771 </descrip>
772 </quote>
773
774
775 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
776
777 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
778 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
779 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
780 <tag/Description/The function sets the pixel aspect ratio for the current
781 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
782 may be used to correct geometric shapes so they look correct on a given
783 display. As an example, a circle with a radius of 100 pixels may look elliptic
784 on some driver/display combinations if the aspect ratio is not 1.00.
785 <tag/Notes/<itemize>
786 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
787 monitor for the given platform. The aspect ratio may be wrong if another
788 monitor is used.
789 <item>No TGI function will use the aspect ratio. It is up to the programmer to
790 make use of it.
791 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
792 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
793 name="tgi_init">, so if a driver is linked statically to an application,
794 switching into and out of graphics mode will not restore the original aspect
795 ratio.
796 <item>The function is available only as a fastcall function; so, it may be used
797 only in the presence of a prototype.
798 </itemize>
799 <tag/Availability/cc65
800 <tag/See also/
801 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
802 <tag/Example/None.
803 </descrip>
804 </quote>
805
806
807 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
808
809 <quote>
810 <descrip>
811 <tag/Function/Set color to be used in future draw operations.
812 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
813 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
814 <tag/Description/Set color to be used in future draw operations.
815 <tag/Notes/<itemize>
816 <item>The function is only available as fastcall function, so it may only
817 be used in presence of a prototype.
818 </itemize>
819 <tag/Availability/cc65
820 <tag/See also/Other tgi functions.
821 <tag/Example/<verb>
822 tgi_setcolor(TGI_COLOR_BLACK);
823 tgi_bar(0,0,30,30);
824 tgi_setcolor(TGI_COLOR_WHITE);
825 tgi_bar(10,10,20,20);
826 </verb>
827 </descrip>
828 </quote>
829
830 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
831
832 <quote>
833 <descrip>
834 <tag/Function/Set the page for drawing.
835 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
836 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
837 <tag/Description/If the drawpage and the viewpage are the same then all drawing
838 is seen immediately as it is drawn. For double buffered games you can set the
839 drawpage to a different page than the viewpage. This lets you draw the next
840 screen in the background and when the screen is ready you display it.
841 <tag/Notes/<itemize>
842 <item>The function is only available as fastcall function, so it may only
843 be used in presence of a prototype.
844 </itemize>
845 <tag/Availability/cc65
846 <tag/See also/Other tgi functions.
847 <tag/Example/<verb>
848 tgi_setdrawpage(1);
849 tgi_outtextxy(10, 10, "Hello World");
850 tgi_setviewpage(1); // Show page 1
851 tgi_setdrawpage(0);
852 tgi_outtextxy(10, 10, "Creating next frame");
853 ...
854 tgi_setviewpage(0); // Show page 0
855 </verb>
856 </descrip>
857 </quote>
858
859 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
860
861 <quote>
862 <descrip>
863 <tag/Function/Set the palette (not available with all drivers/hardware).
864 Palette is a pointer to as many entries as there are colors.
865 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
866 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
867 <tag/Description/Set the palette (not available with all drivers/hardware).
868 Palette is a pointer to as many entries as there are colors.
869 <tag/Notes/<itemize>
870 <item>The function is only available as fastcall function, so it may only
871 be used in presence of a prototype.
872 </itemize>
873 <tag/Availability/cc65
874 <tag/See also/Other tgi functions.
875 <tag/Example/None.
876 </descrip>
877 </quote>
878
879 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
880
881 <quote>
882 <descrip>
883 <tag/Function/Plot a pixel on the drawpage with the current color.
884 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
885 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
886 <tag/Description/Plot a pixel on the drawpage with the current color.
887 <tag/Notes/<itemize>
888 <item>The function is only available as fastcall function, so it may only
889 be used in presence of a prototype.
890 </itemize>
891 <tag/Availability/cc65
892 <tag/See also/Other tgi functions.
893 <tag/Example/None.
894 </descrip>
895 </quote>
896
897 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
898
899 <quote>
900 <descrip>
901 <tag/Function/Set page to be visible on screen.
902 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
903 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
904 <tag/Description/If the drawpage and the viewpage are the same then all drawing
905 is seen immediately as it is drawn. For double buffered games you can set the
906 drawpage to a different page than the viewpage. This lets you draw the next
907 screen in the background and when the screen is ready you display it.
908 <tag/Notes/<itemize>
909 <item>The function is only available as fastcall function, so it may only
910 be used in presence of a prototype.
911 </itemize>
912 <tag/Availability/cc65
913 <tag/See also/Other tgi functions.
914 <tag/Example/<verb>
915 tgi_setdrawpage(1);
916 tgi_outtextxy(10, 10, "Hello World");
917 tgi_setviewpage(1); // Show page 1
918 tgi_setdrawpage(0);
919 tgi_outtextxy(10, 10, "Creating next frame");
920 ...
921 tgi_setviewpage(0); // Show page 0
922 </verb>
923 </descrip>
924 </quote>
925
926 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
927
928 <quote>
929 <descrip>
930 <tag/Function/Calculate the height of the text in pixels according to
931 the current text style.
932 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
933 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
934 <tag/Description/Calculate the height of the text in pixels according to
935 the current text style.
936 <tag/Notes/<itemize>
937 <item>The function is only available as fastcall function, so it may only
938 be used in presence of a prototype.
939 </itemize>
940 <tag/Availability/cc65
941 <tag/See also/Other tgi functions.
942 <tag/Example/None.
943 </descrip>
944 </quote>
945
946 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
947
948 <quote>
949 <descrip>
950 <tag/Function/Set the scaling for text output.
951 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
952 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
953 <tag/Description/
954 Set the scaling for text output. The scaling factors for width and height
955 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
956 <tag/Notes/<itemize>
957 <item>The function is only available as fastcall function, so it may only
958 be used in presence of a prototype.
959 </itemize>
960 <tag/Availability/cc65
961 <tag/See also/
962 <ref id="tgi_settextstyle" name="tgi_settextstyle">
963 <tag/Example/None.
964 </descrip>
965 </quote>
966
967 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
968
969 <quote>
970 <descrip>
971 <tag/Function/Set the style for text output.
972 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
973 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
974 <tag/Description/Set the style for text output.
975 <tag/Notes/<itemize>
976 <item>The function is only available as fastcall function, so it may only
977 be used in presence of a prototype.
978 </itemize>
979 <tag/Availability/cc65
980 <tag/See also/
981 <ref id="tgi_settextscale" name="tgi_settextscale">
982 <tag/Example/None.
983 </descrip>
984 </quote>
985
986 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
987
988 <quote>
989 <descrip>
990 <tag/Function/Calculate the width of the text in pixels according to the current text style.
991 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
992 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
993 <tag/Description/Calculate the width of the text in pixels according to the current text style.
994 <tag/Notes/<itemize>
995 <item>The function is only available as fastcall function, so it may only
996 be used in presence of a prototype.
997 </itemize>
998 <tag/Availability/cc65
999 <tag/See also/Other tgi functions.
1000 <tag/Example/None.
1001 </descrip>
1002 </quote>
1003
1004 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
1005
1006 <quote>
1007 <descrip>
1008 <tag/Function/Uninstall the currently loaded driver but do not unload it.
1009 Will call tgi_done if necessary.
1010 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
1011 <tag/Declaration/<tt/void tgi_uninstall (void);/
1012 <tag/Description/Uninstall the currently loaded driver but do not unload it.
1013 Will call tgi_done if necessary.
1014 <tag/Availability/cc65
1015 <tag/See also/Other tgi functions.
1016 <tag/Example/None.
1017 </descrip>
1018 </quote>
1019
1020 <sect1>tgi_unload<label id="tgi_unload"><p>
1021
1022 <quote>
1023 <descrip>
1024 <tag/Function/Uninstall, then unload the currently loaded driver.
1025 Will call tgi_done if necessary.
1026 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
1027 <tag/Declaration/<tt/void tgi_unload (void);/
1028 <tag/Description/Uninstall, then unload the currently loaded driver.
1029 Will call tgi_done if necessary.
1030 <tag/Availability/cc65
1031 <tag/See also/Other tgi functions.
1032 <tag/Example/None.
1033 </descrip>
1034 </quote>
1035
1036
1037 </article>