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