]> git.sur5r.net Git - cc65/blob - include/tgi.h
Start of TGI changes. Untested, may not work.
[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 /* Constants used for tgi_textstyle */
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 default tgi mode for a platform */
64 extern const unsigned char tgi_stdmode;
65
66
67
68 /*****************************************************************************/
69 /*                                 Functions                                 */
70 /*****************************************************************************/
71
72
73
74 void __fastcall__ tgi_load (unsigned char mode);
75 /* Load and install the matching driver for the given mode. Will just load
76  * the driver and check if loading was successul. Will not switch to gaphics
77  * mode.
78  */
79
80 void __fastcall__ tgi_load_driver (const char* name);
81 /* Load and install the given driver. This function is identical to tgi_load
82  * with the only difference that the name of the driver is specified
83  * explicitly.
84  */
85
86 void __fastcall__ tgi_unload (void);
87 /* Uninstall, then unload the currently loaded driver. Will call tgi_done if
88  * necessary.
89  */
90
91 void __fastcall__ tgi_install (void* driver);
92 /* Install an already loaded driver. */
93
94 void __fastcall__ tgi_uninstall (void);
95 /* Uninstall the currently loaded driver but do not unload it. Will call
96  * tgi_done if necessary.
97  */
98
99 void __fastcall__ tgi_init (void);
100 /* Initialize the already loaded graphics driver. */
101
102 void __fastcall__ tgi_done (void);
103 /* End graphics mode, switch back to text mode. Will NOT uninstall or unload
104  * the driver!
105  */
106
107 unsigned char __fastcall__ tgi_geterror (void);
108 /* Return the error code for the last operation. This will also clear the
109  * error.
110  */
111
112 const char* __fastcall__ tgi_geterrormsg (unsigned char code);
113 /* Get an error message describing the error in code. */
114
115 void __fastcall__ tgi_clear (void);
116 /* Clear the drawpage. */
117
118 unsigned __fastcall__ tgi_getpagecount (void);
119 /* Returns the number of screen pages available. */
120
121 void __fastcall__ tgi_setviewpage (unsigned char page);
122 /* Set the visible page. Will set an error if the page is not available. */
123
124 void __fastcall__ tgi_setdrawpage (unsigned char page);
125 /* Set the drawable page. Will set an error if the page is not available. */
126
127 unsigned char __fastcall__ tgi_getcolorcount (void);
128 /* Get the number of available colors. */
129
130 unsigned char __fastcall__ tgi_getmaxcolor (void);
131 /* Return the maximum supported color number (the number of colors would
132  * then be getmaxcolor()+1).
133  */
134
135 void __fastcall__ tgi_setcolor (unsigned char color);
136 /* Set the current drawing color. */
137
138 unsigned char __fastcall__ tgi_getcolor (void);
139 /* Return the current drawing color. */
140
141 void __fastcall__ tgi_setpalette (const unsigned char* palette);
142 /* Set the palette (not available with all drivers/hardware). palette is
143  * a pointer to as many entries as there are colors.
144  */
145
146 const unsigned char* __fastcall__ tgi_getpalette (void);
147 /* Return the current palette. */
148
149 const unsigned char* __fastcall__ tgi_getdefpalette (void);
150 /* Return the default palette. */
151
152 unsigned __fastcall__ tgi_getxres (void);
153 /* Return the resolution in X direction. */
154
155 unsigned __fastcall__ tgi_getmaxx (void);
156 /* Return the maximum x coordinate. The resolution in x direction is
157  * getmaxx() + 1
158  */
159
160 unsigned __fastcall__ tgi_getyres (void);
161 /* Return the resolution in Y direction. */
162
163 unsigned __fastcall__ tgi_getmaxy (void);
164 /* Return the maximum y coordinate. The resolution in y direction is
165  * getmaxy() + 1
166  */
167
168 unsigned char __fastcall__ tgi_getpixel (int x, int y);
169 /* Get the color value of a pixel. */
170
171 void __fastcall__ tgi_setpixel (int x, int y);
172 /* Plot a pixel in the current drawing color. */
173
174 void __fastcall__ tgi_gotoxy (int x, int y);
175 /* Set the graphics cursor to the given position. */
176
177 void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
178 /* Draw a line in the current drawing color. The graphics cursor will
179  * be set to x2/y2 by this call.
180  */
181
182 void __fastcall__ tgi_lineto (int x2, int y2);
183 /* Draw a line in the current drawing color from the graphics cursor to the
184  * new end point. The graphics cursor will be updated to x2/y2.
185  */
186
187 void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
188 /* Draw a circle in the current drawing color. */
189
190 void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
191 /* Draw a bar (a filled rectangle) using the current color. */
192
193 void __fastcall__ tgi_textstyle (unsigned magwidth, unsigned magheight,
194                                  unsigned char dir);
195 /* Set the style for text output. The scaling factors for width and height
196  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
197  */
198
199 unsigned __fastcall__ tgi_textwidth (const char* s);
200 /* Calculate the width of the text in pixels according to the current text
201  * style.
202  */
203
204 unsigned __fastcall__ tgi_textheight (const char* s);
205 /* Calculate the height of the text in pixels according to the current text
206  * style.
207  */
208
209 void __fastcall__ tgi_outtext (const char* s);
210 /* Output text at the current graphics cursor position. The graphics cursor
211  * is moved to the end of the text.
212  */
213
214 void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
215 /* Output text at the given cursor position. The graphics cursor is moved to
216  * the end of the text.
217  */
218
219 unsigned __fastcall__ tgi_ioctl (unsigned char code, unsigned val);
220 /* Call the driver specific control function. What this function does for
221  * a specific code depends on the driver. The driver will set an error
222  * for unknown codes or values.
223  */
224
225
226
227 /* End of tgi.h */
228 #endif
229
230
231