1 <!doctype linuxdoc system>
4 <title>Tiny Graphics Interface
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
9 The cc65 library provides functions for platform independent graphics.
10 Include the tgi.h header file to get the necessary definitions.
13 <!-- Table of contents -->
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">
61 <!-- Begin the document -->
63 <sect1>tgi_arc<label id="tgi_arc"><p>
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
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
81 <tag/Availability/cc65
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">
89 /* Draw the upper half of an ellipse */
90 tgi_setcolor(TGI_COLOR_BLUE);
91 tgi_arc (50, 50, 40, 20, 0, 180);
97 <sect1>tgi_bar<label id="tgi_bar"><p>
101 <tag/Function/The function fills a rectangle on the drawpage with the current
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
108 <item>The function is only available as fastcall function, so it may only
109 be used in presence of a prototype.
111 <tag/Availability/cc65
112 <tag/See also/Other tgi function
114 tgi_setcolor(TGI_COLOR_GREEN);
115 tgi_bar(10, 10, 100, 60);
121 <sect1>tgi_circle<label id="tgi_circle"><p>
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.
130 <item>The function is only available as fastcall function, so it may only
131 be used in presence of a prototype.
133 <tag/Availability/cc65
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">
141 tgi_setcolor(TGI_COLOR_BLACK);
142 tgi_circle(50, 40, 40);
148 <sect1>tgi_clear<label id="tgi_clear"><p>
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
163 <sect1>tgi_done<label id="tgi_done"><p>
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
180 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
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.
190 <item>The function is only available as fastcall function, so it may only
191 be used in presence of a prototype.
193 <tag/Availability/cc65
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">
201 tgi_setcolor(TGI_COLOR_RED);
202 tgi_ellipse (50, 40, 40, 20);
208 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
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.
217 <item>The function is only available as fastcall function, so it may only
218 be used in presence of a prototype.
220 <tag/Availability/cc65
222 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
223 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
229 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
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.
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
243 <item>No TGI function will use the aspect ratio. It is up to the programmer to
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.
251 <tag/Availability/cc65
253 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
259 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
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
275 color = tgi_getcolor();
281 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
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
293 if (tgi_getcolorcount() == 2) {
294 printf("Only monochrome graphics is supported\n");
301 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
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
318 <sect1>tgi_geterror<label id="tgi_geterror"><p>
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
335 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
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.
344 <item>The function is only available as fastcall function, so it may only
345 be used in presence of a prototype.
347 <tag/Availability/cc65
348 <tag/See also/Other tgi functions
354 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
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
369 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
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
384 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
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
399 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
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
409 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
410 <ref id="tgi_setviewpage" name="tgi_setviewpage">
416 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
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
431 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
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.
440 <item>The function is only available as fastcall function, so it may only
441 be used in presence of a prototype.
443 <tag/Availability/cc65
444 <tag/See also/Other tgi functions.
450 <sect1>tgi_getxres<label id="tgi_getxres"><p>
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.
466 <sect1>tgi_getyres<label id="tgi_getyres"><p>
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.
482 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
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.
491 <item>The function is only available as fastcall function, so it may only
492 be used in presence of a prototype.
494 <tag/Availability/cc65
495 <tag/See also/Other tgi functions.
501 <sect1>tgi_init<label id="tgi_init"><p>
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
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/.
516 <tag/Availability/cc65
517 <tag/See also/Other tgi functions.
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.
526 <sect1>tgi_install<label id="tgi_install"><p>
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).
537 <item>The function is only available as fastcall function, so it may only be
538 used in presence of a prototype.
540 <tag/Availability/cc65
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">
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.
553 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
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);/
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.
565 <item>The function is only available as fastcall function, so it may only be
566 used in presence of a prototype.
568 <tag/Availability/cc65
570 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
571 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
577 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
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.
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.
592 <tag/Availability/cc65
593 <tag/See also/Other tgi functions.
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)
602 tgi_sprite(&background);
603 tgi_setcolor(TGI_COLOR_BLUE);
604 tgi_outttextxy(20,40,"Hello World");
612 <sect1>tgi_line<label id="tgi_line"><p>
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.
623 <item>The function is only available as fastcall function, so it may only
624 be used in presence of a prototype.
626 <tag/Availability/cc65
627 <tag/See also/Other tgi functions.
633 <sect1>tgi_lineto<label id="tgi_lineto"><p>
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.
644 <item>The function is only available as fastcall function, so it may only
645 be used in presence of a prototype.
647 <tag/Availability/cc65
648 <tag/See also/Other tgi functions.
654 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
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.
665 <item>The function is only available as fastcall function, so it may only
666 be used in presence of a prototype.
668 <tag/Availability/cc65
669 <tag/See also/Other tgi functions.
675 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
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);/
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.
687 <item>The function is only available as fastcall function, so it may only
688 be used in presence of a prototype.
690 <tag/Availability/cc65
692 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
693 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
699 <sect1>tgi_outtext<label id="tgi_outtext"><p>
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.
710 <item>The function is only available as fastcall function, so it may only
711 be used in presence of a prototype.
713 <tag/Availability/cc65
714 <tag/See also/Other tgi functions.
720 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
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.
731 <item>The function is only available as fastcall function, so it may only
732 be used in presence of a prototype.
734 <tag/Availability/cc65
735 <tag/See also/Other tgi functions.
741 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
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
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
759 <tag/Availability/cc65
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">
767 /* Draw the closed upper half of an ellipse */
768 tgi_setcolor(TGI_COLOR_BLUE);
769 tgi_pieslice (50, 50, 40, 20, 0, 180);
775 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
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.
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
789 <item>No TGI function will use the aspect ratio. It is up to the programmer to
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
796 <item>The function is available only as a fastcall function; so, it may be used
797 only in the presence of a prototype.
799 <tag/Availability/cc65
801 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
807 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
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.
816 <item>The function is only available as fastcall function, so it may only
817 be used in presence of a prototype.
819 <tag/Availability/cc65
820 <tag/See also/Other tgi functions.
822 tgi_setcolor(TGI_COLOR_BLACK);
824 tgi_setcolor(TGI_COLOR_WHITE);
825 tgi_bar(10,10,20,20);
830 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
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.
842 <item>The function is only available as fastcall function, so it may only
843 be used in presence of a prototype.
845 <tag/Availability/cc65
846 <tag/See also/Other tgi functions.
849 tgi_outtextxy(10, 10, "Hello World");
850 tgi_setviewpage(1); // Show page 1
852 tgi_outtextxy(10, 10, "Creating next frame");
854 tgi_setviewpage(0); // Show page 0
859 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
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.
870 <item>The function is only available as fastcall function, so it may only
871 be used in presence of a prototype.
873 <tag/Availability/cc65
874 <tag/See also/Other tgi functions.
879 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
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.
888 <item>The function is only available as fastcall function, so it may only
889 be used in presence of a prototype.
891 <tag/Availability/cc65
892 <tag/See also/Other tgi functions.
897 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
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.
909 <item>The function is only available as fastcall function, so it may only
910 be used in presence of a prototype.
912 <tag/Availability/cc65
913 <tag/See also/Other tgi functions.
916 tgi_outtextxy(10, 10, "Hello World");
917 tgi_setviewpage(1); // Show page 1
919 tgi_outtextxy(10, 10, "Creating next frame");
921 tgi_setviewpage(0); // Show page 0
926 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
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.
937 <item>The function is only available as fastcall function, so it may only
938 be used in presence of a prototype.
940 <tag/Availability/cc65
941 <tag/See also/Other tgi functions.
946 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
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);/
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.
957 <item>The function is only available as fastcall function, so it may only
958 be used in presence of a prototype.
960 <tag/Availability/cc65
962 <ref id="tgi_settextstyle" name="tgi_settextstyle">
967 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
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.
976 <item>The function is only available as fastcall function, so it may only
977 be used in presence of a prototype.
979 <tag/Availability/cc65
981 <ref id="tgi_settextscale" name="tgi_settextscale">
986 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
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.
995 <item>The function is only available as fastcall function, so it may only
996 be used in presence of a prototype.
998 <tag/Availability/cc65
999 <tag/See also/Other tgi functions.
1004 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
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.
1020 <sect1>tgi_unload<label id="tgi_unload"><p>
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.