1 <!doctype linuxdoc system>
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">
10 The cc65 library provides functions for platform independent graphics.
11 Include the tgi.h header file to get the necessary definitions, see also
12 <tt>samples/tgidemo.c</tt> and <tt>samples/mandelbrot.c</tt>.
15 <!-- Begin the document -->
17 <sect>tgi.h<label id="tgi.h">
19 <sect1>tgi_arc<label id="tgi_arc"><p>
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
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
37 <tag/Availability/cc65
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">
45 /* Draw the upper half of an ellipse */
46 tgi_setcolor(TGI_COLOR_BLUE);
47 tgi_arc (50, 50, 40, 20, 0, 180);
53 <sect1>tgi_bar<label id="tgi_bar"><p>
57 <tag/Function/The function fills a rectangle on the drawpage with the current
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
64 <item>The function is only available as fastcall function, so it may only
65 be used in presence of a prototype.
67 <tag/Availability/cc65
68 <tag/See also/Other tgi function
70 tgi_setcolor(TGI_COLOR_GREEN);
71 tgi_bar(10, 10, 100, 60);
77 <sect1>tgi_circle<label id="tgi_circle"><p>
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.
86 <item>The function is only available as fastcall function, so it may only
87 be used in presence of a prototype.
89 <tag/Availability/cc65
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">
97 tgi_setcolor(TGI_COLOR_BLACK);
98 tgi_circle(50, 40, 40);
104 <sect1>tgi_clear<label id="tgi_clear"><p>
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
119 <sect1>tgi_done<label id="tgi_done"><p>
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
136 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
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.
146 <item>The function is only available as fastcall function, so it may only
147 be used in presence of a prototype.
149 <tag/Availability/cc65
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">
157 tgi_setcolor(TGI_COLOR_RED);
158 tgi_ellipse (50, 40, 40, 20);
164 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
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.
173 <item>The function is only available as fastcall function, so it may only
174 be used in presence of a prototype.
176 <tag/Availability/cc65
178 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
179 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
185 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
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.
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
199 <item>No TGI function will use the aspect ratio. It is up to the programmer to
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.
207 <tag/Availability/cc65
209 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
215 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
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
231 color = tgi_getcolor();
237 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
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
249 if (tgi_getcolorcount() == 2) {
250 printf("Only monochrome graphics is supported\n");
257 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
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
274 <sect1>tgi_geterror<label id="tgi_geterror"><p>
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
291 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
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.
300 <item>The function is only available as fastcall function, so it may only
301 be used in presence of a prototype.
303 <tag/Availability/cc65
304 <tag/See also/Other tgi functions
310 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
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
325 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
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
340 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
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
355 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
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
365 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
366 <ref id="tgi_setviewpage" name="tgi_setviewpage">
372 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
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
387 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
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.
396 <item>The function is only available as fastcall function, so it may only
397 be used in presence of a prototype.
399 <tag/Availability/cc65
400 <tag/See also/Other tgi functions.
406 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
410 <tag/Function/Calculate the height of the text in pixels according to
411 the current text style.
412 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
413 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/
414 <tag/Description/Calculate the height of the text in pixels according to
415 the current text style.
417 <item>The function is only available as fastcall function, so it may only
418 be used in presence of a prototype.
420 <tag/Availability/cc65
421 <tag/See also/Other tgi functions.
427 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
431 <tag/Function/Calculate the width of the text in pixels according to the current text style.
432 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
433 <tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/
434 <tag/Description/Calculate the width of the text in pixels according to the current text style.
436 <item>The function is only available as fastcall function, so it may only
437 be used in presence of a prototype.
439 <tag/Availability/cc65
440 <tag/See also/Other tgi functions.
446 <sect1>tgi_getxres<label id="tgi_getxres"><p>
450 <tag/Function/Get number of horisontal pixels on the screen.
451 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
452 <tag/Declaration/<tt/unsigned tgi_getxres (void);/
453 <tag/Description/Get number of horisontal pixels on the screen.
454 This is same as tgi_maxx()+1.
455 <tag/Availability/cc65
456 <tag/See also/Other tgi functions.
462 <sect1>tgi_getyres<label id="tgi_getyres"><p>
466 <tag/Function/Get number of vertical pixels on the screen.
467 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
468 <tag/Declaration/<tt/unsigned tgi_getyres (void);/
469 <tag/Description/Get number of vertical pixels on the screen.
470 This is same as tgi_maxy()+1.
471 <tag/Availability/cc65
472 <tag/See also/Other tgi functions.
478 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
482 <tag/Function/Set graphics cursor at x, y.
483 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
484 <tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/
485 <tag/Description/Set graphics cursor at x, y.
487 <item>The function is only available as fastcall function, so it may only
488 be used in presence of a prototype.
490 <tag/Availability/cc65
491 <tag/See also/Other tgi functions.
497 <sect1>tgi_init<label id="tgi_init"><p>
501 <tag/Function/Initialize the already loaded graphics driver.
502 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
503 <tag/Declaration/<tt/void tgi_init (void);/
504 <tag/Description/The tgi_init function will set the default palette to the
507 <item><tt/tgi_init/ will not clear the screen. This allows switching between
508 text and graphics mode on platforms that have separate memory areas for the
509 screens. If you want the screen cleared, call <tt/<ref id="tgi_clear"
510 name="tgi_clear">/ after <tt/tgi_init/.
512 <tag/Availability/cc65
513 <tag/See also/Other tgi functions.
515 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
516 tgi_init(); //Set up the default palette and clear the screen.
522 <sect1>tgi_install<label id="tgi_install"><p>
526 <tag/Function/Install an already loaded driver and return an error code.
527 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
528 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/
529 <tag/Description/The function installs a driver that was already loaded into
530 memory (or linked statically to the program). It returns an error code
531 (<tt/TGI_ERR_OK/ in case of success).
533 <item>The function is only available as fastcall function, so it may only be
534 used in presence of a prototype.
536 <tag/Availability/cc65
538 <ref id="tgi_load_driver" name="tgi_load_driver">,
539 <ref id="tgi_uninstall" name="tgi_uninstall">,
540 <ref id="tgi_unload" name="tgi_unload">
542 tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it.
543 tgi_init(); //Set up the default palette and clear the screen.
549 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
553 <tag/Function/Install an already loaded driver and return an error code.
554 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
555 <tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/
557 Install a vector font for use. More than one vector font can be loaded,
558 but only one can be active. This function is used to tell which one. Call
559 with a NULL pointer to uninstall the currently installed font.
561 <item>The function is only available as fastcall function, so it may only be
562 used in presence of a prototype.
564 <tag/Availability/cc65
566 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
567 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
573 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
577 <tag/Function/Platform dependent code extensions.
578 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
579 <tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/
580 <tag/Description/Some platforms have extra display hardware that is not
581 supported by standard tgi functions. You can extend the driver to support
582 this extra hardware using tgi_ioctl functions.
584 <item>The function is only available as fastcall function, so it may only
585 be used in presence of a prototype.
586 <item>These functions are not easily portable to other cc65 platforms.
588 <tag/Availability/cc65
589 <tag/See also/Other tgi functions.
591 #define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr))
592 #define tgi_flip() tgi_ioctl(1, (void*)0)
593 #define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
594 #define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
595 #define tgi_busy() tgi_ioctl(4, (void*)0)
596 #define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
598 tgi_sprite(&background);
599 tgi_setcolor(TGI_COLOR_BLUE);
600 tgi_outttextxy(20,40,"Hello World");
608 <sect1>tgi_line<label id="tgi_line"><p>
612 <tag/Function/Draw a line in the current drawing color.
613 The graphics cursor will be set to x2/y2 by this call.
614 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
615 <tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/
616 <tag/Description/Draw a line in the current drawing color.
617 The graphics cursor will be set to x2/y2 by this call.
619 <item>The function is only available as fastcall function, so it may only
620 be used in presence of a prototype.
622 <tag/Availability/cc65
623 <tag/See also/Other tgi functions.
629 <sect1>tgi_lineto<label id="tgi_lineto"><p>
633 <tag/Function/Draw a line in the current drawing color from the graphics
634 cursor to the new end point. The graphics cursor will be updated to x2/y2.
635 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
636 <tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/
637 <tag/Description/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.
640 <item>The function is only available as fastcall function, so it may only
641 be used in presence of a prototype.
643 <tag/Availability/cc65
644 <tag/See also/Other tgi functions.
650 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
654 <tag/Function/Load and install the given driver.
655 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
656 <tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/
657 <tag/Description/Load and install the driver by name.
658 Will just load the driver and check if loading was successful.
659 Will not switch to graphics mode.
661 <item>The function is only available as fastcall function, so it may only
662 be used in presence of a prototype.
664 <tag/Availability/cc65
665 <tag/See also/Other tgi functions.
671 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
675 <tag/Function/Load the given vector font.
676 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
677 <tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/
679 Load a vector font into memory and return it. In case of errors, NULL is
680 returned and an error is set, which can be retrieved using tgi_geterror.
681 To use the font, it has to be installed using tgi_install_vectorfont.
683 <item>The function is only available as fastcall function, so it may only
684 be used in presence of a prototype.
686 <tag/Availability/cc65
688 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
689 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
695 <sect1>tgi_outtext<label id="tgi_outtext"><p>
699 <tag/Function/Output text at the current graphics cursor position.
700 The graphics cursor is moved to the end of the text.
701 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
702 <tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/
703 <tag/Description/Output text at the current graphics cursor position.
704 The graphics cursor is moved to the end of the text.
706 <item>The function is only available as fastcall function, so it may only
707 be used in presence of a prototype.
709 <tag/Availability/cc65
710 <tag/See also/Other tgi functions.
716 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
720 <tag/Function/Output text at the given cursor position.
721 The graphics cursor is moved to the end of the text.
722 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
723 <tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/
724 <tag/Description/Output text at the given cursor position.
725 The graphics cursor is moved to the end of the text.
727 <item>The function is only available as fastcall function, so it may only
728 be used in presence of a prototype.
730 <tag/Availability/cc65
731 <tag/See also/Other tgi functions.
737 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
741 <tag/Function/Draw an elliptic pie slice in the current color.
742 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
743 <tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y,
744 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
745 <tag/Description/The function draws an elliptic pie slice with center at x/y
746 and radii rx/ry using the current drawing color. The pie slice covers the angle
747 between sa and ea (startangle and endangle), which must be in the range
750 <item>The function is only available as fastcall function, so it may only
751 be used in presence of a prototype.
752 <item>The function behaves unexpectedly or may crash if the angles are out
755 <tag/Availability/cc65
757 <ref id="tgi_bar" name="tgi_arc">,
758 <ref id="tgi_bar" name="tgi_bar">,
759 <ref id="tgi_circle" name="tgi_circle">,
760 <ref id="tgi_ellipse" name="tgi_ellipse">,
761 <ref id="tgi_setcolor" name="tgi_setcolor">
763 /* Draw the closed upper half of an ellipse */
764 tgi_setcolor(TGI_COLOR_BLUE);
765 tgi_pieslice (50, 50, 40, 20, 0, 180);
771 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
773 <quote> <descrip> <tag/Function/Set the pixel aspect ratio.
774 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
775 <tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/
776 <tag/Description/The function sets the pixel aspect ratio for the current
777 driver and display. The argument is an 8.8 fixed point value. The aspect ratio
778 may be used to correct geometric shapes so they look correct on a given
779 display. As an example, a circle with a radius of 100 pixels may look elliptic
780 on some driver/display combinations if the aspect ratio is not 1.00.
782 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
783 monitor for the given platform. The aspect ratio may be wrong if another
785 <item>No TGI function will use the aspect ratio. It is up to the programmer to
787 <item>The <tt/tgi_setaspectratio/ function can be used to change the aspect
788 ratio for a loaded driver. The value is not reset by <ref id="tgi_init"
789 name="tgi_init">, so if a driver is linked statically to an application,
790 switching into and out of graphics mode will not restore the original aspect
792 <item>The function is available only as a fastcall function; so, it may be used
793 only in the presence of a prototype.
795 <tag/Availability/cc65
797 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
803 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
807 <tag/Function/Set color to be used in future draw operations.
808 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
809 <tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
810 <tag/Description/Set color to be used in future draw operations.
812 <item>The function is only available as fastcall function, so it may only
813 be used in presence of a prototype.
815 <tag/Availability/cc65
816 <tag/See also/Other tgi functions.
818 tgi_setcolor(TGI_COLOR_BLACK);
820 tgi_setcolor(TGI_COLOR_WHITE);
821 tgi_bar(10,10,20,20);
827 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
831 <tag/Function/Set the page for drawing.
832 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
833 <tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/
834 <tag/Description/If the drawpage and the viewpage are the same then all drawing
835 is seen immediately as it is drawn. For double buffered games you can set the
836 drawpage to a different page than the viewpage. This lets you draw the next
837 screen in the background and when the screen is ready you display it.
839 <item>The function is only available as fastcall function, so it may only
840 be used in presence of a prototype.
842 <tag/Availability/cc65
843 <tag/See also/Other tgi functions.
846 tgi_outtextxy(10, 10, "Hello World");
847 tgi_setviewpage(1); // Show page 1
849 tgi_outtextxy(10, 10, "Creating next frame");
851 tgi_setviewpage(0); // Show page 0
857 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
861 <tag/Function/Set the palette (not available with all drivers/hardware).
862 Palette is a pointer to as many entries as there are colors.
863 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
864 <tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
865 <tag/Description/Set the palette (not available with all drivers/hardware).
866 Palette is a pointer to as many entries as there are colors.
868 <item>The function is only available as fastcall function, so it may only
869 be used in presence of a prototype.
871 <tag/Availability/cc65
872 <tag/See also/Other tgi functions.
878 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
882 <tag/Function/Plot a pixel on the drawpage with the current color.
883 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
884 <tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/
885 <tag/Description/Plot a pixel on the drawpage with the current color.
887 <item>The function is only available as fastcall function, so it may only
888 be used in presence of a prototype.
890 <tag/Availability/cc65
891 <tag/See also/Other tgi functions.
897 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
901 <tag/Function/Set the scaling for text output.
902 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
903 <tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/
905 Set the scaling for text output. The scaling factors for width and height
906 are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
908 <item>The function is only available as fastcall function, so it may only
909 be used in presence of a prototype.
911 <tag/Availability/cc65
913 <ref id="tgi_settextstyle" name="tgi_settextstyle">
919 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
923 <tag/Function/Set the style for text output.
924 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
925 <tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/
926 <tag/Description/Set the style for text output.
928 <item>The function is only available as fastcall function, so it may only
929 be used in presence of a prototype.
931 <tag/Availability/cc65
933 <ref id="tgi_settextscale" name="tgi_settextscale">
939 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
943 <tag/Function/Set page to be visible on screen.
944 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
945 <tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/
946 <tag/Description/If the drawpage and the viewpage are the same then all drawing
947 is seen immediately as it is drawn. For double buffered games you can set the
948 drawpage to a different page than the viewpage. This lets you draw the next
949 screen in the background and when the screen is ready you display it.
951 <item>The function is only available as fastcall function, so it may only
952 be used in presence of a prototype.
954 <tag/Availability/cc65
955 <tag/See also/Other tgi functions.
958 tgi_outtextxy(10, 10, "Hello World");
959 tgi_setviewpage(1); // Show page 1
961 tgi_outtextxy(10, 10, "Creating next frame");
963 tgi_setviewpage(0); // Show page 0
969 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
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.
986 <sect1>tgi_unload<label id="tgi_unload"><p>
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.