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