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