]> git.sur5r.net Git - cc65/blob - doc/tgi.sgml
Moved documentation to funcref.
[cc65] / doc / tgi.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4 <title>Tiny Graphics Interface
5 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<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
9 <abstract>
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>.
13 </abstract>
14
15 <!-- Begin the document -->
16
17 <sect>tgi.h<label id="tgi.h">
18
19 <sect1>tgi_arc<label id="tgi_arc"><p>
20
21 <quote>
22 <descrip>
23 <tag/Function/Draw an elliptic arc in the current color.
24 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
25 <tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y,
26 unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/
27 <tag/Description/The function draws an elliptic arc with center at x/y and
28 radii rx/ry using the current drawing color. The arc covers the angle
29 between sa and ea (startangle and endangle), which must be in the range
30 0..360.
31 <tag/Notes/<itemize>
32 <item>The function is only available as fastcall function, so it may only
33 be used in presence of a prototype.
34 <item>The function behaves unexpectedly or may crash if the angles are out
35 of range.
36 </itemize>
37 <tag/Availability/cc65
38 <tag/See also/
39 <ref id="tgi_bar" name="tgi_bar">,
40 <ref id="tgi_circle" name="tgi_circle">,
41 <ref id="tgi_ellipse" name="tgi_ellipse">,
42 <ref id="tgi_pieslice" name="tgi_pieslice">,
43 <ref id="tgi_setcolor" name="tgi_setcolor">
44 <tag/Example/<verb>
45 /* Draw the upper half of an ellipse */
46 tgi_setcolor(TGI_COLOR_BLUE);
47 tgi_arc (50, 50, 40, 20, 0, 180);
48 </verb>
49 </descrip>
50 </quote>
51
52
53 <sect1>tgi_bar<label id="tgi_bar"><p>
54
55 <quote>
56 <descrip>
57 <tag/Function/The function fills a rectangle on the drawpage with the current
58 color.
59 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
60 <tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/
61 <tag/Description/The function fills a rectangle on the drawpage with the current
62 color.
63 <tag/Notes/<itemize>
64 <item>The function is only available as fastcall function, so it may only
65 be used in presence of a prototype.
66 </itemize>
67 <tag/Availability/cc65
68 <tag/See also/Other tgi function
69 <tag/Example/<verb>
70 tgi_setcolor(TGI_COLOR_GREEN);
71 tgi_bar(10, 10, 100, 60);
72 </verb>
73 </descrip>
74 </quote>
75
76
77 <sect1>tgi_circle<label id="tgi_circle"><p>
78
79 <quote>
80 <descrip>
81 <tag/Function/The function draws a circle in the current color.
82 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
83 <tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/
84 <tag/Description/The function draws a circle in the current color.
85 <tag/Notes/<itemize>
86 <item>The function is only available as fastcall function, so it may only
87 be used in presence of a prototype.
88 </itemize>
89 <tag/Availability/cc65
90 <tag/See also/
91 <ref id="tgi_arc" name="tgi_arc">,
92 <ref id="tgi_bar" name="tgi_bar">,
93 <ref id="tgi_ellipse" name="tgi_ellipse">,
94 <ref id="tgi_pieslice" name="tgi_pieslice">,
95 <ref id="tgi_setcolor" name="tgi_setcolor">
96 <tag/Example/<verb>
97 tgi_setcolor(TGI_COLOR_BLACK);
98 tgi_circle(50, 40, 40);
99 </verb>
100 </descrip>
101 </quote>
102
103
104 <sect1>tgi_clear<label id="tgi_clear"><p>
105
106 <quote>
107 <descrip>
108 <tag/Function/Clear the drawpage
109 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
110 <tag/Declaration/<tt/void tgi_clear (void);/
111 <tag/Description/Clear the drawpage
112 <tag/Availability/cc65
113 <tag/See also/Other tgi functions
114 <tag/Example/None.
115 </descrip>
116 </quote>
117
118
119 <sect1>tgi_done<label id="tgi_done"><p>
120
121 <quote>
122 <descrip>
123 <tag/Function/End graphics mode, switch back to text mode.
124 Will NOT uninstall or unload the driver!
125 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
126 <tag/Declaration/<tt/void tgi_done (void);/
127 <tag/Description/End graphics mode, switch back to text mode.
128 Will NOT uninstall or unload the driver!
129 <tag/Availability/cc65
130 <tag/See also/Other tgi functions
131 <tag/Example/None.
132 </descrip>
133 </quote>
134
135
136 <sect1>tgi_ellipse<label id="tgi_ellipse"><p>
137
138 <quote>
139 <descrip>
140 <tag/Function/The function draws an ellipse in the current color.
141 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
142 <tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
143 <tag/Description/The function draws an ellipse at position x/y with radii
144 rx and ry, using the current drawing color.
145 <tag/Notes/<itemize>
146 <item>The function is only available as fastcall function, so it may only
147 be used in presence of a prototype.
148 </itemize>
149 <tag/Availability/cc65
150 <tag/See also/
151 <ref id="tgi_arc" name="tgi_arc">,
152 <ref id="tgi_bar" name="tgi_bar">,
153 <ref id="tgi_circle" name="tgi_circle">,
154 <ref id="tgi_pieslice" name="tgi_pieslice">,
155 <ref id="tgi_setcolor" name="tgi_setcolor">
156 <tag/Example/<verb>
157 tgi_setcolor(TGI_COLOR_RED);
158 tgi_ellipse (50, 40, 40, 20);
159 </verb>
160 </descrip>
161 </quote>
162
163
164 <sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p>
165
166 <quote>
167 <descrip>
168 <tag/Function/Free a vector font that was previously loaded into memory.
169 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
170 <tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/
171 <tag/Description/Free a vector font that was previously loaded into memory.
172 <tag/Notes/<itemize>
173 <item>The function is only available as fastcall function, so it may only
174 be used in presence of a prototype.
175 </itemize>
176 <tag/Availability/cc65
177 <tag/See also/
178 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
179 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">
180 <tag/Example/None.
181 </descrip>
182 </quote>
183
184
185 <sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p>
186
187 <quote> <descrip> <tag/Function/Return the pixel aspect ratio.
188 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
189 <tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/
190 <tag/Description/The function returns the pixel aspect ratio for the current
191 driver and display as an 8.8 fixed point value. It may be used to correct
192 geometric shapes so they look correct on the display. As an example, a circle
193 with a radius of 100 pixels may look elliptic on some driver/display
194 combinations if the aspect ratio is not 1.00.
195 <tag/Notes/<itemize>
196 <item>The aspect ratio is encoded in the TGI driver which assumes a "standard"
197 monitor for the given platform. The aspect ratio may be wrong if another
198 monitor is used.
199 <item>No TGI function will use the aspect ratio. It is up to the programmer to
200 make use of it.
201 <item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can
202 be used to change the aspect ratio for a loaded driver. The value is not reset
203 by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to
204 an application, switching into and out of graphics mode will not restore the
205 original aspect ratio.
206 </itemize>
207 <tag/Availability/cc65
208 <tag/See also/
209 <ref id="tgi_setaspectratio" name="tgi_setaspectratio">
210 <tag/Example/None.
211 </descrip>
212 </quote>
213
214
215 <sect1>tgi_getcolor<label id="tgi_getcolor"><p>
216
217 <quote>
218 <descrip>
219 <tag/Function/Return the current drawing color.
220 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
221 <tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
222 <tag/Description/The actual color is an index to a palette. During tgi_init
223 you will get a default palette. The number of colors depend on the platform.
224 All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
225 platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
226 and then you change the green of the palette to blue using tgi_setpalette then
227 after this painting in TGI_COLOR_GREEN will actually be blue.
228 <tag/Availability/cc65
229 <tag/See also/Other tgi functions
230 <tag/Example/<verb>
231 color = tgi_getcolor();
232 </verb>
233 </descrip>
234 </quote>
235
236
237 <sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p>
238
239 <quote>
240 <descrip>
241 <tag/Function/Get the number of available colors.
242 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
243 <tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
244 <tag/Description/Tgi platforms use indexed color palettes. This function
245 returns the number of entries we can use in the palette.
246 <tag/Availability/cc65
247 <tag/See also/Other tgi functions
248 <tag/Example/<verb>
249 if (tgi_getcolorcount() == 2) {
250   printf("Only monochrome graphics is supported\n");
251 }
252 </verb>
253 </descrip>
254 </quote>
255
256
257 <sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p>
258
259 <quote>
260 <descrip>
261 <tag/Function/Get the palette installed by default.
262 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
263 <tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
264 <tag/Description/The tgi driver has a default palette that is active at startup.
265 The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
266 palette to work correctly.
267 <tag/Availability/cc65
268 <tag/See also/Other tgi functions
269 <tag/Example/None.
270 </descrip>
271 </quote>
272
273
274 <sect1>tgi_geterror<label id="tgi_geterror"><p>
275
276 <quote>
277 <descrip>
278 <tag/Function/Return the error code for the last operation.
279 This will also clear the error.
280 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
281 <tag/Declaration/<tt/unsigned char tgi_geterror (void);/
282 <tag/Description/Return the error code for the last operation.
283 This will also clear the error.
284 <tag/Availability/cc65
285 <tag/See also/Other tgi functions
286 <tag/Example/None.
287 </descrip>
288 </quote>
289
290
291 <sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p>
292
293 <quote>
294 <descrip>
295 <tag/Function/Get an error message describing the error.
296 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
297 <tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/
298 <tag/Description/Get an error message describing the error.
299 <tag/Notes/<itemize>
300 <item>The function is only available as fastcall function, so it may only
301 be used in presence of a prototype.
302 </itemize>
303 <tag/Availability/cc65
304 <tag/See also/Other tgi functions
305 <tag/Example/None.
306 </descrip>
307 </quote>
308
309
310 <sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p>
311
312 <quote>
313 <descrip>
314 <tag/Function/Get the highest index of the palette.
315 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
316 <tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/
317 <tag/Description/Get the highest index of the palette.
318 <tag/Availability/cc65
319 <tag/See also/Other tgi functions
320 <tag/Example/None.
321 </descrip>
322 </quote>
323
324
325 <sect1>tgi_getmaxx<label id="tgi_getmaxx"><p>
326
327 <quote>
328 <descrip>
329 <tag/Function/Get the maximum x coordinate that can be used on this screen.
330 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
331 <tag/Declaration/<tt/unsigned tgi_getmaxx (void);/
332 <tag/Description/Get the maximum x coordinate that can be used on this screen.
333 <tag/Availability/cc65
334 <tag/See also/Other tgi functions
335 <tag/Example/None.
336 </descrip>
337 </quote>
338
339
340 <sect1>tgi_getmaxy<label id="tgi_getmaxy"><p>
341
342 <quote>
343 <descrip>
344 <tag/Function/Get the maximum y coordinate that can be used on this screen.
345 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
346 <tag/Declaration/<tt/unsigned tgi_getmaxy (void);/
347 <tag/Description/Get the maximum y coordinate that can be used on this screen.
348 <tag/Availability/cc65
349 <tag/See also/Other tgi functions
350 <tag/Example/None.
351 </descrip>
352 </quote>
353
354
355 <sect1>tgi_getpagecount<label id="tgi_getpagecount"><p>
356
357 <quote>
358 <descrip>
359 <tag/Function/Return the number of screen pages available.
360 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
361 <tag/Declaration/<tt/unsigned tgi_getpagecount (void);/
362 <tag/Description/Return the number of screen pages available.
363 <tag/Availability/cc65
364 <tag/See also/
365 <ref id="tgi_setdrawpage" name="tgi_setdrawpage">,
366 <ref id="tgi_setviewpage" name="tgi_setviewpage">
367 <tag/Example/None.
368 </descrip>
369 </quote>
370
371
372 <sect1>tgi_getpalette<label id="tgi_getpalette"><p>
373
374 <quote>
375 <descrip>
376 <tag/Function/Get the palette installed.
377 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
378 <tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/
379 <tag/Description/Get the palette installed.
380 <tag/Availability/cc65
381 <tag/See also/Other tgi functions
382 <tag/Example/None.
383 </descrip>
384 </quote>
385
386
387 <sect1>tgi_getpixel<label id="tgi_getpixel"><p>
388
389 <quote>
390 <descrip>
391 <tag/Function/Get the color of a pixel from the viewpage.
392 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
393 <tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
394 <tag/Description/Get the color of a pixel from the viewpage.
395 <tag/Notes/<itemize>
396 <item>The function is only available as fastcall function, so it may only
397 be used in presence of a prototype.
398 </itemize>
399 <tag/Availability/cc65
400 <tag/See also/Other tgi functions.
401 <tag/Example/None.
402 </descrip>
403 </quote>
404
405
406 <sect1>tgi_gettextheight<label id="tgi_gettextheight"><p>
407
408 <quote>
409 <descrip>
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.
416 <tag/Notes/<itemize>
417 <item>The function is only available as fastcall function, so it may only
418 be used in presence of a prototype.
419 </itemize>
420 <tag/Availability/cc65
421 <tag/See also/Other tgi functions.
422 <tag/Example/None.
423 </descrip>
424 </quote>
425
426
427 <sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p>
428
429 <quote>
430 <descrip>
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.
435 <tag/Notes/<itemize>
436 <item>The function is only available as fastcall function, so it may only
437 be used in presence of a prototype.
438 </itemize>
439 <tag/Availability/cc65
440 <tag/See also/Other tgi functions.
441 <tag/Example/None.
442 </descrip>
443 </quote>
444
445
446 <sect1>tgi_getxres<label id="tgi_getxres"><p>
447
448 <quote>
449 <descrip>
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.
457 <tag/Example/None.
458 </descrip>
459 </quote>
460
461
462 <sect1>tgi_getyres<label id="tgi_getyres"><p>
463
464 <quote>
465 <descrip>
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.
473 <tag/Example/None.
474 </descrip>
475 </quote>
476
477
478 <sect1>tgi_gotoxy<label id="tgi_gotoxy"><p>
479
480 <quote>
481 <descrip>
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.
486 <tag/Notes/<itemize>
487 <item>The function is only available as fastcall function, so it may only
488 be used in presence of a prototype.
489 </itemize>
490 <tag/Availability/cc65
491 <tag/See also/Other tgi functions.
492 <tag/Example/None.
493 </descrip>
494 </quote>
495
496
497 <sect1>tgi_init<label id="tgi_init"><p>
498
499 <quote>
500 <descrip>
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
505 hardware.
506 <tag/Notes/<itemize>
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/.
511 </itemize>
512 <tag/Availability/cc65
513 <tag/See also/Other tgi functions.
514 <tag/Example/<verb>
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.
517 </verb>
518 </descrip>
519 </quote>
520
521
522 <sect1>tgi_install<label id="tgi_install"><p>
523
524 <quote>
525 <descrip>
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).
532 <tag/Notes/<itemize>
533 <item>The function is only available as fastcall function, so it may only be
534 used in presence of a prototype.
535 </itemize>
536 <tag/Availability/cc65
537 <tag/See also/
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">
541 <tag/Example/<verb>
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.
544 </verb>
545 </descrip>
546 </quote>
547
548
549 <sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p>
550
551 <quote>
552 <descrip>
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);/
556 <tag/Description/
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.
560 <tag/Notes/<itemize>
561 <item>The function is only available as fastcall function, so it may only be
562 used in presence of a prototype.
563 </itemize>
564 <tag/Availability/cc65
565 <tag/See also/
566 <ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">,
567 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
568 <tag/Example/None.
569 </descrip>
570 </quote>
571
572
573 <sect1>tgi_ioctl<label id="tgi_ioctl"><p>
574
575 <quote>
576 <descrip>
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.
583 <tag/Notes/<itemize>
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.
587 </itemize>
588 <tag/Availability/cc65
589 <tag/See also/Other tgi functions.
590 <tag/Example/<verb>
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)
597 if (!tgi_busy()) {
598   tgi_sprite(&amp;background);
599   tgi_setcolor(TGI_COLOR_BLUE);
600   tgi_outttextxy(20,40,"Hello World");
601   tgi_updatedisplay();
602 }
603 </verb>
604 </descrip>
605 </quote>
606
607
608 <sect1>tgi_line<label id="tgi_line"><p>
609
610 <quote>
611 <descrip>
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.
618 <tag/Notes/<itemize>
619 <item>The function is only available as fastcall function, so it may only
620 be used in presence of a prototype.
621 </itemize>
622 <tag/Availability/cc65
623 <tag/See also/Other tgi functions.
624 <tag/Example/None.
625 </descrip>
626 </quote>
627
628
629 <sect1>tgi_lineto<label id="tgi_lineto"><p>
630
631 <quote>
632 <descrip>
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.
639 <tag/Notes/<itemize>
640 <item>The function is only available as fastcall function, so it may only
641 be used in presence of a prototype.
642 </itemize>
643 <tag/Availability/cc65
644 <tag/See also/Other tgi functions.
645 <tag/Example/None.
646 </descrip>
647 </quote>
648
649
650 <sect1>tgi_load_driver<label id="tgi_load_driver"><p>
651
652 <quote>
653 <descrip>
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.
660 <tag/Notes/<itemize>
661 <item>The function is only available as fastcall function, so it may only
662 be used in presence of a prototype.
663 </itemize>
664 <tag/Availability/cc65
665 <tag/See also/Other tgi functions.
666 <tag/Example/None.
667 </descrip>
668 </quote>
669
670
671 <sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p>
672
673 <quote>
674 <descrip>
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);/
678 <tag/Description/
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.
682 <tag/Notes/<itemize>
683 <item>The function is only available as fastcall function, so it may only
684 be used in presence of a prototype.
685 </itemize>
686 <tag/Availability/cc65
687 <tag/See also/
688 <ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">,
689 <ref id="tgi_free_vectorfont" name="tgi_free_vectorfont">
690 <tag/Example/None.
691 </descrip>
692 </quote>
693
694
695 <sect1>tgi_outtext<label id="tgi_outtext"><p>
696
697 <quote>
698 <descrip>
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.
705 <tag/Notes/<itemize>
706 <item>The function is only available as fastcall function, so it may only
707 be used in presence of a prototype.
708 </itemize>
709 <tag/Availability/cc65
710 <tag/See also/Other tgi functions.
711 <tag/Example/None.
712 </descrip>
713 </quote>
714
715
716 <sect1>tgi_outtextxy<label id="tgi_outtextxy"><p>
717
718 <quote>
719 <descrip>
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.
726 <tag/Notes/<itemize>
727 <item>The function is only available as fastcall function, so it may only
728 be used in presence of a prototype.
729 </itemize>
730 <tag/Availability/cc65
731 <tag/See also/Other tgi functions.
732 <tag/Example/None.
733 </descrip>
734 </quote>
735
736
737 <sect1>tgi_pieslice<label id="tgi_pieslice"><p>
738
739 <quote>
740 <descrip>
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
748 0..360.
749 <tag/Notes/<itemize>
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
753 of range.
754 </itemize>
755 <tag/Availability/cc65
756 <tag/See also/
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">
762 <tag/Example/<verb>
763 /* Draw the closed upper half of an ellipse */
764 tgi_setcolor(TGI_COLOR_BLUE);
765 tgi_pieslice (50, 50, 40, 20, 0, 180);
766 </verb>
767 </descrip>
768 </quote>
769
770
771 <sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p>
772
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.
781 <tag/Notes/<itemize>
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
784 monitor is used.
785 <item>No TGI function will use the aspect ratio. It is up to the programmer to
786 make use of it.
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
791 ratio.
792 <item>The function is available only as a fastcall function; so, it may be used
793 only in the presence of a prototype.
794 </itemize>
795 <tag/Availability/cc65
796 <tag/See also/
797 <ref id="tgi_getaspectratio" name="tgi_getaspectratio">
798 <tag/Example/None.
799 </descrip>
800 </quote>
801
802
803 <sect1>tgi_setcolor<label id="tgi_setcolor"><p>
804
805 <quote>
806 <descrip>
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.
811 <tag/Notes/<itemize>
812 <item>The function is only available as fastcall function, so it may only
813 be used in presence of a prototype.
814 </itemize>
815 <tag/Availability/cc65
816 <tag/See also/Other tgi functions.
817 <tag/Example/<verb>
818 tgi_setcolor(TGI_COLOR_BLACK);
819 tgi_bar(0,0,30,30);
820 tgi_setcolor(TGI_COLOR_WHITE);
821 tgi_bar(10,10,20,20);
822 </verb>
823 </descrip>
824 </quote>
825
826
827 <sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p>
828
829 <quote>
830 <descrip>
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.
838 <tag/Notes/<itemize>
839 <item>The function is only available as fastcall function, so it may only
840 be used in presence of a prototype.
841 </itemize>
842 <tag/Availability/cc65
843 <tag/See also/Other tgi functions.
844 <tag/Example/<verb>
845 tgi_setdrawpage(1);
846 tgi_outtextxy(10, 10, "Hello World");
847 tgi_setviewpage(1); // Show page 1
848 tgi_setdrawpage(0);
849 tgi_outtextxy(10, 10, "Creating next frame");
850 ...
851 tgi_setviewpage(0); // Show page 0
852 </verb>
853 </descrip>
854 </quote>
855
856
857 <sect1>tgi_setpalette<label id="tgi_setpalette"><p>
858
859 <quote>
860 <descrip>
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.
867 <tag/Notes/<itemize>
868 <item>The function is only available as fastcall function, so it may only
869 be used in presence of a prototype.
870 </itemize>
871 <tag/Availability/cc65
872 <tag/See also/Other tgi functions.
873 <tag/Example/None.
874 </descrip>
875 </quote>
876
877
878 <sect1>tgi_setpixel<label id="tgi_setpixel"><p>
879
880 <quote>
881 <descrip>
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.
886 <tag/Notes/<itemize>
887 <item>The function is only available as fastcall function, so it may only
888 be used in presence of a prototype.
889 </itemize>
890 <tag/Availability/cc65
891 <tag/See also/Other tgi functions.
892 <tag/Example/None.
893 </descrip>
894 </quote>
895
896
897 <sect1>tgi_settextscale<label id="tgi_settextscale"><p>
898
899 <quote>
900 <descrip>
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);/
904 <tag/Description/
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.
907 <tag/Notes/<itemize>
908 <item>The function is only available as fastcall function, so it may only
909 be used in presence of a prototype.
910 </itemize>
911 <tag/Availability/cc65
912 <tag/See also/
913 <ref id="tgi_settextstyle" name="tgi_settextstyle">
914 <tag/Example/None.
915 </descrip>
916 </quote>
917
918
919 <sect1>tgi_settextstyle<label id="tgi_settextstyle"><p>
920
921 <quote>
922 <descrip>
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.
927 <tag/Notes/<itemize>
928 <item>The function is only available as fastcall function, so it may only
929 be used in presence of a prototype.
930 </itemize>
931 <tag/Availability/cc65
932 <tag/See also/
933 <ref id="tgi_settextscale" name="tgi_settextscale">
934 <tag/Example/None.
935 </descrip>
936 </quote>
937
938
939 <sect1>tgi_setviewpage<label id="tgi_setviewpage"><p>
940
941 <quote>
942 <descrip>
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.
950 <tag/Notes/<itemize>
951 <item>The function is only available as fastcall function, so it may only
952 be used in presence of a prototype.
953 </itemize>
954 <tag/Availability/cc65
955 <tag/See also/Other tgi functions.
956 <tag/Example/<verb>
957 tgi_setdrawpage(1);
958 tgi_outtextxy(10, 10, "Hello World");
959 tgi_setviewpage(1); // Show page 1
960 tgi_setdrawpage(0);
961 tgi_outtextxy(10, 10, "Creating next frame");
962 ...
963 tgi_setviewpage(0); // Show page 0
964 </verb>
965 </descrip>
966 </quote>
967
968
969 <sect1>tgi_uninstall<label id="tgi_uninstall"><p>
970
971 <quote>
972 <descrip>
973 <tag/Function/Uninstall the currently loaded driver but do not unload it.
974 Will call tgi_done if necessary.
975 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
976 <tag/Declaration/<tt/void tgi_uninstall (void);/
977 <tag/Description/Uninstall the currently loaded driver but do not unload it.
978 Will call tgi_done if necessary.
979 <tag/Availability/cc65
980 <tag/See also/Other tgi functions.
981 <tag/Example/None.
982 </descrip>
983 </quote>
984
985
986 <sect1>tgi_unload<label id="tgi_unload"><p>
987
988 <quote>
989 <descrip>
990 <tag/Function/Uninstall, then unload the currently loaded driver.
991 Will call tgi_done if necessary.
992 <tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
993 <tag/Declaration/<tt/void tgi_unload (void);/
994 <tag/Description/Uninstall, then unload the currently loaded driver.
995 Will call tgi_done if necessary.
996 <tag/Availability/cc65
997 <tag/See also/Other tgi functions.
998 <tag/Example/None.
999 </descrip>
1000 </quote>
1001
1002
1003 </article>