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