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