1 /*****************************************************************************/
5 /* Tiny graphics interface */
9 /* (C) 2002-2003 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
42 #include <tgi/tgi-mode.h>
45 #include <tgi/tgi-error.h>
50 /*****************************************************************************/
52 /*****************************************************************************/
56 /* Constants used for tgi_textstyle */
57 #define TGI_TEXT_HORIZONTAL 0
58 #define TGI_TEXT_VERTICAL 1
62 /*****************************************************************************/
64 /*****************************************************************************/
68 void __fastcall__ tgi_load (unsigned char mode);
69 /* Load and install the matching driver for the given mode. Will just load
70 * the driver and check if loading was successul. Will not switch to gaphics
74 void __fastcall__ tgi_load_driver (const char* name);
75 /* Load and install the given driver. This function is identical to tgi_load
76 * with the only difference that the name of the driver is specified
77 * explicitly. You should NOT use this function in most cases, use tgi_load()
81 void __fastcall__ tgi_unload (void);
82 /* Uninstall, then unload the currently loaded driver. Will call tgi_done if
86 void __fastcall__ tgi_install (void* driver);
87 /* Install an already loaded driver. */
89 void __fastcall__ tgi_uninstall (void);
90 /* Uninstall the currently loaded driver but do not unload it. Will call
91 * tgi_done if necessary.
94 void __fastcall__ tgi_init (void);
95 /* Initialize the already loaded graphics driver. */
97 void __fastcall__ tgi_done (void);
98 /* End graphics mode, switch back to text mode. Will NOT uninstall or unload
102 unsigned char __fastcall__ tgi_geterror (void);
103 /* Return the error code for the last operation. This will also clear the
107 void __fastcall__ tgi_clear (void);
108 /* Clear the screen. */
110 void __fastcall__ tgi_getpagecount (void);
111 /* Returns the number of screen pages available. */
113 void __fastcall__ tgi_setviewpage (unsigned char page);
114 /* Set the visible page. Will set an error if the page is not available. */
116 void __fastcall__ tgi_setdrawpage (unsigned char page);
117 /* Set the drawable page. Will set an error if the page is not available. */
119 unsigned char __fastcall__ tgi_getcolorcount (void);
120 /* Get the number of available colors. */
122 unsigned char __fastcall__ tgi_getmaxcolor (void);
123 /* Return the maximum supported color number (the number of colors would
124 * then be getmaxcolor()+1).
127 void __fastcall__ tgi_setcolor (unsigned char color);
128 /* Set the current drawing color. */
130 unsigned char __fastcall__ tgi_getcolor (void);
131 /* Return the current drawing color. */
133 void __fastcall__ tgi_setpalette (const unsigned char* palette);
134 /* Set the palette (not available with all drivers/hardware). palette is
135 * a pointer to as many entries as there are colors.
138 const unsigned char* __fastcall__ tgi_getpalette (void);
139 /* Return the current palette. Will return NULL for drivers that do not
143 const unsigned char* __fastcall__ tgi_getdefpalette (void);
144 /* Return the default palette. Will return NULL for drivers that do not
148 unsigned __fastcall__ tgi_getxres (void);
149 /* Return the resolution in X direction. */
151 unsigned __fastcall__ tgi_getmaxx (void);
152 /* Return the maximum x coordinate. The resolution in x direction is
156 unsigned __fastcall__ tgi_getyres (void);
157 /* Return the resolution in Y direction. */
159 unsigned __fastcall__ tgi_getmaxy (void);
160 /* Return the maximum y coordinate. The resolution in y direction is
164 unsigned char __fastcall__ tgi_getpixel (int x, int y);
165 /* Get the color value of a pixel. */
167 void __fastcall__ tgi_setpixel (int x, int y);
168 /* Plot a pixel in the current drawing color. */
170 void __fastcall__ tgi_gotoxy (int x, int y);
171 /* Set the graphics cursor to the given position. */
173 void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
174 /* Draw a line in the current drawing color. The graphics cursor will
175 * be set to x2/y2 by this call.
178 void __fastcall__ tgi_lineto (int x2, int y2);
179 /* Draw a line in the current drawing color from the graphics cursor to the
180 * new end point. The graphics cursor will be updated to x2/y2.
183 void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
184 /* Draw a circle in the current drawing color. */
186 void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
187 /* Draw a bar (a filled rectangle) using the current color. */
189 void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy,
191 /* Set the style for text output. */
193 unsigned __fastcall__ tgi_textwidth (const char* s);
194 /* Calculate the width of the text in pixels according to the current text
198 unsigned __fastcall__ tgi_textheight (const char* s);
199 /* Calculate the height of the text in pixels according to the current text
203 void __fastcall__ tgi_outtext (const char* s);
204 /* Output text at the current graphics cursor position. The graphics cursor
205 * is moved to the end of the text.
208 void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
209 /* Output text at the given cursor position. The graphics cursor is moved to
210 * the end of the text.