]> git.sur5r.net Git - cc65/blob - include/tgi.h
Adjustments to recent adding of get/set prefix to tgi function names.
[cc65] / include / tgi.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                     tgi.h                                 */
4 /*                                                                           */
5 /*                            Tiny graphics interface                        */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002-2011, 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 /* A vector font definition */
65 typedef struct tgi_vectorfont tgi_vectorfont;
66
67
68
69 /*****************************************************************************/
70 /*                                 Functions                                 */
71 /*****************************************************************************/
72
73
74
75 void __fastcall__ tgi_load_driver (const char* name);
76 /* Load and install the given driver. */
77
78 void tgi_unload (void);
79 /* Uninstall, then unload the currently loaded driver. Will call tgi_done if
80  * necessary.
81  */
82
83 void __fastcall__ tgi_install (void* driver);
84 /* Install an already loaded driver. */
85
86 void tgi_uninstall (void);
87 /* Uninstall the currently loaded driver but do not unload it. Will call
88  * tgi_done if necessary.
89  */
90
91 void tgi_init (void);
92 /* Initialize the already loaded graphics driver. */
93
94 void tgi_done (void);
95 /* End graphics mode, switch back to text mode. Will NOT uninstall or unload
96  * the driver!
97  */
98
99 const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);
100 /* Load a vector font into memory and return it. In case of errors, NULL is
101  * returned and an error is set, which can be retrieved using tgi_geterror.
102  * To use the font, it has to be installed using tgi_install_vectorfont.
103  */
104
105 void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);
106 /* Install a vector font for use. More than one vector font can be loaded,
107  * but only one can be active. This function is used to tell which one. Call
108  * with a NULL pointer to uninstall the currently installed font.
109  */
110
111 void tgi_free_vectorfont (const tgi_vectorfont* font);
112 /* Free a vector font that was previously loaded into memory. */
113
114 unsigned char tgi_geterror (void);
115 /* Return the error code for the last operation. This will also clear the
116  * error.
117  */
118
119 const char* __fastcall__ tgi_geterrormsg (unsigned char code);
120 /* Get an error message describing the error in code. */
121
122 void tgi_clear (void);
123 /* Clear the drawpage. */
124
125 unsigned tgi_getpagecount (void);
126 /* Returns the number of screen pages available. */
127
128 void __fastcall__ tgi_setviewpage (unsigned char page);
129 /* Set the visible page. Will set an error if the page is not available. */
130
131 void __fastcall__ tgi_setdrawpage (unsigned char page);
132 /* Set the drawable page. Will set an error if the page is not available. */
133
134 unsigned char tgi_getcolorcount (void);
135 /* Get the number of available colors. */
136
137 unsigned char tgi_getmaxcolor (void);
138 /* Return the maximum supported color number (the number of colors would
139  * then be getmaxcolor()+1).
140  */
141
142 void __fastcall__ tgi_setcolor (unsigned char color);
143 /* Set the current drawing color. */
144
145 unsigned char tgi_getcolor (void);
146 /* Return the current drawing color. */
147
148 void __fastcall__ tgi_setpalette (const unsigned char* palette);
149 /* Set the palette (not available with all drivers/hardware). palette is
150  * a pointer to as many entries as there are colors.
151  */
152
153 const unsigned char* tgi_getpalette (void);
154 /* Return the current palette. */
155
156 const unsigned char* tgi_getdefpalette (void);
157 /* Return the default palette. */
158
159 unsigned tgi_getxres (void);
160 /* Return the resolution in X direction. */
161
162 unsigned tgi_getmaxx (void);
163 /* Return the maximum x coordinate. The resolution in x direction is
164  * getmaxx() + 1
165  */
166
167 unsigned tgi_getyres (void);
168 /* Return the resolution in Y direction. */
169
170 unsigned tgi_getmaxy (void);
171 /* Return the maximum y coordinate. The resolution in y direction is
172  * getmaxy() + 1
173  */
174
175 unsigned tgi_getaspectratio (void);
176 /* Returns the aspect ratio for the loaded driver. The aspect ratio is an
177  * 8.8 fixed point value.
178  */
179
180 void __fastcall__ tgi_setaspectratio (unsigned aspectratio);
181 /* Set a new aspect ratio for the loaded driver. The aspect ratio is an
182  * 8.8 fixed point value.
183  */
184
185 unsigned char __fastcall__ tgi_getpixel (int x, int y);
186 /* Get the color value of a pixel. */
187
188 void __fastcall__ tgi_setpixel (int x, int y);
189 /* Plot a pixel in the current drawing color. */
190
191 void __fastcall__ tgi_gotoxy (int x, int y);
192 /* Set the graphics cursor to the given position. */
193
194 void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
195 /* Draw a line in the current drawing color. The graphics cursor will
196  * be set to x2/y2 by this call.
197  */
198
199 void __fastcall__ tgi_lineto (int x2, int y2);
200 /* Draw a line in the current drawing color from the graphics cursor to the
201  * new end point. The graphics cursor will be updated to x2/y2.
202  */
203
204 void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
205 /* Draw a circle in the current drawing color. */
206
207 void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);
208 /* Draw a full ellipse with center at x/y and radii rx/ry using the current
209  * drawing color.
210  */
211
212 void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
213                            unsigned sa, unsigned ea);
214 /* Draw an ellipse arc with center at x/y and radii rx/ry using the current
215  * drawing color. The arc covers the angle between sa and ea (startangle and
216  * endangle), which must be in the range 0..360 (otherwise the function may
217  * bevave unextectedly).
218  */
219
220 void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry,
221                                 unsigned sa, unsigned ea);
222 /* Draw an ellipse pie slice with center at x/y and radii rx/ry using the
223  * current drawing color. The pie slice covers the angle between sa and ea
224  * (startangle and endangle), which must be in the range 0..360 (otherwise the
225  * function may behave unextectedly).
226  */
227
228 void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
229 /* Draw a bar (a filled rectangle) using the current color. */
230
231 void __fastcall__ tgi_settextdir (unsigned char dir);
232 /* Set the direction for text output. dir is one of the TGI_TEXT_XXX
233  * constants.
234  */
235
236 void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
237 /* Set the scaling for text output. The scaling factors for width and height
238  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
239  */
240
241 void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
242                                     unsigned char dir, unsigned char font);
243 /* Set the style for text output. The scaling factors for width and height
244  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
245  * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
246  * constants.
247  */
248
249 unsigned __fastcall__ tgi_gettextwidth (const char* s);
250 /* Calculate the width of the text in pixels according to the current text
251  * style.
252  */
253
254 unsigned __fastcall__ tgi_gettextheight (const char* s);
255 /* Calculate the height of the text in pixels according to the current text
256  * style.
257  */
258
259 void __fastcall__ tgi_outtext (const char* s);
260 /* Output text at the current graphics cursor position. The graphics cursor
261  * is moved to the end of the text.
262  */
263
264 void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
265 /* Output text at the given cursor position. The graphics cursor is moved to
266  * the end of the text.
267  */
268
269 unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);
270 /* Call the driver specific control function. What this function does for
271  * a specific code depends on the driver. The driver will set an error
272  * for unknown codes or values.
273  */
274
275
276
277 /* End of tgi.h */
278 #endif
279
280
281