]> git.sur5r.net Git - cc65/blob - include/tgi.h
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / include / tgi.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                     tgi.h                                 */
4 /*                                                                           */
5 /*                            Tiny graphics interface                        */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002-2013, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _TGI_H
37 #define _TGI_H
38
39
40
41 #ifndef _TGI_ERROR_H
42 #include <tgi/tgi-error.h>
43 #endif
44
45
46
47 /*****************************************************************************/
48 /*                                  Definitions                              */
49 /*****************************************************************************/
50
51
52
53 /* Font constants for use with tgi_settextstyle */
54 #define TGI_FONT_BITMAP         0
55 #define TGI_FONT_VECTOR         1
56
57 /* Direction constants for use with tgi_settextstyle */
58 #define TGI_TEXT_HORIZONTAL     0
59 #define TGI_TEXT_VERTICAL       1
60
61 /* The name of the standard tgi driver for a platform */
62 extern const char tgi_stddrv[];
63
64 /* The address of the static standard tgi driver for a platform */
65 extern const void tgi_static_stddrv[];
66
67 /* A vector font definition */
68 typedef struct tgi_vectorfont tgi_vectorfont;
69
70
71
72 /*****************************************************************************/
73 /*                                 Functions                                 */
74 /*****************************************************************************/
75
76
77
78 void __fastcall__ tgi_load_driver (const char* name);
79 /* Load and install the given driver. */
80
81 void tgi_unload (void);
82 /* Uninstall, then unload the currently loaded driver. Will call tgi_done if
83  * necessary.
84  */
85
86 void __fastcall__ tgi_install (void* driver);
87 /* Install an already loaded driver. */
88
89 void tgi_uninstall (void);
90 /* Uninstall the currently loaded driver but do not unload it. Will call
91  * tgi_done if necessary.
92  */
93
94 void tgi_init (void);
95 /* Initialize the already loaded graphics driver. */
96
97 void tgi_done (void);
98 /* End graphics mode, switch back to text mode. Will NOT uninstall or unload
99  * the driver!
100  */
101
102 const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);
103 /* Load a vector font into memory and return it. In case of errors, NULL is
104  * returned and an error is set, which can be retrieved using tgi_geterror.
105  * To use the font, it has to be installed using tgi_install_vectorfont.
106  */
107
108 void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);
109 /* Install a vector font for use. More than one vector font can be loaded,
110  * but only one can be active. This function is used to tell which one. Call
111  * with a NULL pointer to uninstall the currently installed font.
112  */
113
114 void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);
115 /* Free a vector font that was previously loaded into memory. */
116
117 unsigned char tgi_geterror (void);
118 /* Return the error code for the last operation. This will also clear the
119  * error.
120  */
121
122 const char* __fastcall__ tgi_geterrormsg (unsigned char code);
123 /* Get an error message describing the error in code. */
124
125 void tgi_clear (void);
126 /* Clear the drawpage. */
127
128 unsigned tgi_getpagecount (void);
129 /* Returns the number of screen pages available. */
130
131 void __fastcall__ tgi_setviewpage (unsigned char page);
132 /* Set the visible page. Will set an error if the page is not available. */
133
134 void __fastcall__ tgi_setdrawpage (unsigned char page);
135 /* Set the drawable page. Will set an error if the page is not available. */
136
137 unsigned char tgi_getcolorcount (void);
138 /* Get the number of available colors. */
139
140 unsigned char tgi_getmaxcolor (void);
141 /* Return the maximum supported color number (the number of colors would
142  * then be getmaxcolor()+1).
143  */
144
145 void __fastcall__ tgi_setcolor (unsigned char color);
146 /* Set the current drawing color. */
147
148 unsigned char tgi_getcolor (void);
149 /* Return the current drawing color. */
150
151 void __fastcall__ tgi_setpalette (const unsigned char* palette);
152 /* Set the palette (not available with all drivers/hardware). palette is
153  * a pointer to as many entries as there are colors.
154  */
155
156 const unsigned char* tgi_getpalette (void);
157 /* Return the current palette. */
158
159 const unsigned char* tgi_getdefpalette (void);
160 /* Return the default palette. */
161
162 unsigned tgi_getxres (void);
163 /* Return the resolution in X direction. */
164
165 unsigned tgi_getmaxx (void);
166 /* Return the maximum x coordinate. The resolution in x direction is
167  * getmaxx() + 1
168  */
169
170 unsigned tgi_getyres (void);
171 /* Return the resolution in Y direction. */
172
173 unsigned tgi_getmaxy (void);
174 /* Return the maximum y coordinate. The resolution in y direction is
175  * getmaxy() + 1
176  */
177
178 unsigned tgi_getaspectratio (void);
179 /* Returns the aspect ratio for the loaded driver. The aspect ratio is an
180  * 8.8 fixed point value.
181  */
182
183 void __fastcall__ tgi_setaspectratio (unsigned aspectratio);
184 /* Set a new aspect ratio for the loaded driver. The aspect ratio is an
185  * 8.8 fixed point value.
186  */
187
188 unsigned char __fastcall__ tgi_getpixel (int x, int y);
189 /* Get the color value of a pixel. */
190
191 void __fastcall__ tgi_setpixel (int x, int y);
192 /* Plot a pixel in the current drawing color. */
193
194 void __fastcall__ tgi_gotoxy (int x, int y);
195 /* Set the graphics cursor to the given position. */
196
197 void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
198 /* Draw a line in the current drawing color. The graphics cursor will
199  * be set to x2/y2 by this call.
200  */
201
202 void __fastcall__ tgi_lineto (int x2, int y2);
203 /* Draw a line in the current drawing color from the graphics cursor to the
204  * new end point. The graphics cursor will be updated to x2/y2.
205  */
206
207 void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
208 /* Draw a circle in the current drawing color. */
209
210 void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);
211 /* Draw a full ellipse with center at x/y and radii rx/ry using the current
212  * drawing color.
213  */
214
215 void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
216                            unsigned sa, unsigned ea);
217 /* Draw an ellipse arc with center at x/y and radii rx/ry using the current
218  * drawing color. The arc covers the angle between sa and ea (startangle and
219  * endangle), which must be in the range 0..360 (otherwise the function may
220  * bevave unextectedly).
221  */
222
223 void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry,
224                                 unsigned sa, unsigned ea);
225 /* Draw an ellipse pie slice with center at x/y and radii rx/ry using the
226  * current drawing color. The pie slice covers the angle between sa and ea
227  * (startangle and endangle), which must be in the range 0..360 (otherwise the
228  * function may behave unextectedly).
229  */
230
231 void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
232 /* Draw a bar (a filled rectangle) using the current color. */
233
234 void __fastcall__ tgi_settextdir (unsigned char dir);
235 /* Set the direction for text output. dir is one of the TGI_TEXT_XXX
236  * constants.
237  */
238
239 void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
240 /* Set the scaling for text output. The scaling factors for width and height
241  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
242  */
243
244 void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
245                                     unsigned char dir, unsigned char font);
246 /* Set the style for text output. The scaling factors for width and height
247  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
248  * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
249  * constants.
250  */
251
252 unsigned __fastcall__ tgi_gettextwidth (const char* s);
253 /* Calculate the width of the text in pixels according to the current text
254  * style.
255  */
256
257 unsigned __fastcall__ tgi_gettextheight (const char* s);
258 /* Calculate the height of the text in pixels according to the current text
259  * style.
260  */
261
262 void __fastcall__ tgi_outtext (const char* s);
263 /* Output text at the current graphics cursor position. The graphics cursor
264  * is moved to the end of the text.
265  */
266
267 void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
268 /* Output text at the given cursor position. The graphics cursor is moved to
269  * the end of the text.
270  */
271
272 unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);
273 /* Call the driver specific control function. What this function does for
274  * a specific code depends on the driver. The driver will set an error
275  * for unknown codes or values.
276  */
277
278
279
280 /* End of tgi.h */
281 #endif
282
283
284