2001-08-13 19:29:07 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2002-06-21 12:01:16 +00:00
|
|
|
/* tgi.h */
|
2001-08-13 19:29:07 +00:00
|
|
|
/* */
|
2002-06-21 12:01:16 +00:00
|
|
|
/* Tiny graphics interface */
|
2001-08-13 19:29:07 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2009-09-11 18:59:37 +00:00
|
|
|
/* (C) 2002-2009, Ullrich von Bassewitz */
|
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2001-08-13 19:29:07 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
#ifndef _TGI_H
|
|
|
|
#define _TGI_H
|
2001-08-13 19:29:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
#ifndef _TGI_MODE_H
|
2002-12-20 23:25:04 +00:00
|
|
|
#include <tgi/tgi-mode.h>
|
2002-06-21 12:01:16 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _TGI_ERROR_H
|
2002-12-20 23:25:04 +00:00
|
|
|
#include <tgi/tgi-error.h>
|
2002-06-21 12:01:16 +00:00
|
|
|
#endif
|
2001-08-13 19:29:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-03 11:18:49 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Definitions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-01 21:49:09 +00:00
|
|
|
/* Color constants */
|
|
|
|
#define TGI_COLOR_BLACK 0
|
|
|
|
#define TGI_COLOR_WHITE 1
|
|
|
|
|
|
|
|
/* Font constants for use with tgi_textstyle */
|
|
|
|
#define TGI_FONT_BITMAP 0
|
|
|
|
#define TGI_FONT_VECTOR 1
|
|
|
|
|
|
|
|
/* Direction constants for use with tgi_textstyle */
|
2002-10-03 11:18:49 +00:00
|
|
|
#define TGI_TEXT_HORIZONTAL 0
|
|
|
|
#define TGI_TEXT_VERTICAL 1
|
|
|
|
|
2009-09-11 18:59:37 +00:00
|
|
|
/* The name of the standard tgi driver for a platform */
|
|
|
|
extern const char tgi_stddrv[];
|
|
|
|
|
|
|
|
/* The default tgi mode for a platform */
|
|
|
|
extern const unsigned char tgi_stdmode;
|
|
|
|
|
2009-11-01 21:49:09 +00:00
|
|
|
/* A vector font definition */
|
|
|
|
typedef struct tgi_vectorfont tgi_vectorfont;
|
|
|
|
|
2002-10-03 11:18:49 +00:00
|
|
|
|
|
|
|
|
2001-08-13 19:29:07 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Functions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_load (unsigned char mode);
|
2003-02-11 12:37:46 +00:00
|
|
|
/* Load and install the matching driver for the given mode. Will just load
|
|
|
|
* the driver and check if loading was successul. Will not switch to gaphics
|
|
|
|
* mode.
|
2001-08-13 19:29:07 +00:00
|
|
|
*/
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_load_driver (const char* name);
|
2003-02-11 12:37:46 +00:00
|
|
|
/* Load and install the given driver. This function is identical to tgi_load
|
|
|
|
* with the only difference that the name of the driver is specified
|
2009-09-11 18:59:37 +00:00
|
|
|
* explicitly.
|
2002-06-21 12:01:16 +00:00
|
|
|
*/
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_unload (void);
|
2003-02-11 12:37:46 +00:00
|
|
|
/* Uninstall, then unload the currently loaded driver. Will call tgi_done if
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void __fastcall__ tgi_install (void* driver);
|
|
|
|
/* Install an already loaded driver. */
|
|
|
|
|
|
|
|
void __fastcall__ tgi_uninstall (void);
|
|
|
|
/* Uninstall the currently loaded driver but do not unload it. Will call
|
|
|
|
* tgi_done if necessary.
|
|
|
|
*/
|
2002-06-21 12:01:16 +00:00
|
|
|
|
2002-12-29 20:58:36 +00:00
|
|
|
void __fastcall__ tgi_init (void);
|
2003-02-11 12:37:46 +00:00
|
|
|
/* Initialize the already loaded graphics driver. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_done (void);
|
2003-02-11 12:37:46 +00:00
|
|
|
/* End graphics mode, switch back to text mode. Will NOT uninstall or unload
|
|
|
|
* the driver!
|
|
|
|
*/
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2009-11-01 21:49:09 +00:00
|
|
|
const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);
|
|
|
|
/* Load a vector font into memory and return it. In case of errors, NULL is
|
|
|
|
* returned and an error is set, which can be retrieved using tgi_geterror.
|
2009-11-01 22:01:06 +00:00
|
|
|
* To use the font, it has to be installed using tgi_install_vectorfont.
|
2009-11-01 21:49:09 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-01 22:01:06 +00:00
|
|
|
void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);
|
|
|
|
/* Install a vector font for use. More than one vector font can be loaded,
|
2009-11-01 21:49:09 +00:00
|
|
|
* but only one can be active. This function is used to tell which one. Call
|
2009-11-01 22:01:06 +00:00
|
|
|
* with a NULL pointer to uninstall the currently installed font.
|
2009-11-01 21:49:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void tgi_free_vectorfont (const tgi_vectorfont* font);
|
2009-11-01 22:01:06 +00:00
|
|
|
/* Free a vector font that was previously loaded into memory. */
|
2009-11-01 21:49:09 +00:00
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
unsigned char __fastcall__ tgi_geterror (void);
|
2002-06-21 14:16:32 +00:00
|
|
|
/* Return the error code for the last operation. This will also clear the
|
|
|
|
* error.
|
|
|
|
*/
|
2002-06-21 12:01:16 +00:00
|
|
|
|
2004-06-15 09:08:39 +00:00
|
|
|
const char* __fastcall__ tgi_geterrormsg (unsigned char code);
|
|
|
|
/* Get an error message describing the error in code. */
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_clear (void);
|
2009-10-27 21:20:06 +00:00
|
|
|
/* Clear the drawpage. */
|
2002-07-07 10:30:31 +00:00
|
|
|
|
2003-10-29 19:00:42 +00:00
|
|
|
unsigned __fastcall__ tgi_getpagecount (void);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Returns the number of screen pages available. */
|
2002-06-21 12:01:16 +00:00
|
|
|
|
2002-06-22 21:40:24 +00:00
|
|
|
void __fastcall__ tgi_setviewpage (unsigned char page);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Set the visible page. Will set an error if the page is not available. */
|
2002-06-22 21:40:24 +00:00
|
|
|
|
|
|
|
void __fastcall__ tgi_setdrawpage (unsigned char page);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Set the drawable page. Will set an error if the page is not available. */
|
|
|
|
|
|
|
|
unsigned char __fastcall__ tgi_getcolorcount (void);
|
|
|
|
/* Get the number of available colors. */
|
2002-06-22 21:40:24 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
unsigned char __fastcall__ tgi_getmaxcolor (void);
|
2001-08-13 19:29:07 +00:00
|
|
|
/* Return the maximum supported color number (the number of colors would
|
|
|
|
* then be getmaxcolor()+1).
|
|
|
|
*/
|
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
void __fastcall__ tgi_setcolor (unsigned char color);
|
|
|
|
/* Set the current drawing color. */
|
|
|
|
|
|
|
|
unsigned char __fastcall__ tgi_getcolor (void);
|
|
|
|
/* Return the current drawing color. */
|
|
|
|
|
|
|
|
void __fastcall__ tgi_setpalette (const unsigned char* palette);
|
|
|
|
/* Set the palette (not available with all drivers/hardware). palette is
|
|
|
|
* a pointer to as many entries as there are colors.
|
2001-08-13 19:29:07 +00:00
|
|
|
*/
|
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
const unsigned char* __fastcall__ tgi_getpalette (void);
|
2003-10-23 09:30:37 +00:00
|
|
|
/* Return the current palette. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
const unsigned char* __fastcall__ tgi_getdefpalette (void);
|
2003-10-23 09:30:37 +00:00
|
|
|
/* Return the default palette. */
|
2002-06-22 21:40:24 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
unsigned __fastcall__ tgi_getxres (void);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Return the resolution in X direction. */
|
2002-06-21 12:01:16 +00:00
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
unsigned __fastcall__ tgi_getmaxx (void);
|
|
|
|
/* Return the maximum x coordinate. The resolution in x direction is
|
|
|
|
* getmaxx() + 1
|
|
|
|
*/
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
unsigned __fastcall__ tgi_getyres (void);
|
|
|
|
/* Return the resolution in Y direction. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
unsigned __fastcall__ tgi_getmaxy (void);
|
|
|
|
/* Return the maximum y coordinate. The resolution in y direction is
|
|
|
|
* getmaxy() + 1
|
|
|
|
*/
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
unsigned char __fastcall__ tgi_getpixel (int x, int y);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Get the color value of a pixel. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_setpixel (int x, int y);
|
2002-07-07 10:30:31 +00:00
|
|
|
/* Plot a pixel in the current drawing color. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-22 21:53:58 +00:00
|
|
|
void __fastcall__ tgi_gotoxy (int x, int y);
|
|
|
|
/* Set the graphics cursor to the given position. */
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
|
2002-06-22 21:53:58 +00:00
|
|
|
/* Draw a line in the current drawing color. The graphics cursor will
|
|
|
|
* be set to x2/y2 by this call.
|
|
|
|
*/
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_lineto (int x2, int y2);
|
|
|
|
/* Draw a line in the current drawing color from the graphics cursor to the
|
2002-06-22 21:53:58 +00:00
|
|
|
* new end point. The graphics cursor will be updated to x2/y2.
|
2002-06-21 12:01:16 +00:00
|
|
|
*/
|
|
|
|
|
2002-06-21 14:16:32 +00:00
|
|
|
void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
|
2002-06-22 21:53:58 +00:00
|
|
|
/* Draw a circle in the current drawing color. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2009-11-05 17:14:29 +00:00
|
|
|
void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);
|
|
|
|
/* Draw a full ellipse with center at x/y and radii rx/ry using the current
|
|
|
|
* drawing color.
|
|
|
|
*/
|
|
|
|
|
2009-11-05 20:16:43 +00:00
|
|
|
void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
|
|
|
|
unsigned sa, unsigned ea);
|
|
|
|
/* Draw an ellipse arc with center at x/y and radii rx/ry using the current
|
|
|
|
* drawing color. The arc covers the angle between sa and ea (startangle and
|
|
|
|
* endangle), which must be in the range 0..360 (otherwise the function may
|
|
|
|
* bevave unextectedly).
|
|
|
|
*/
|
|
|
|
|
2009-11-05 20:32:17 +00:00
|
|
|
void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry,
|
|
|
|
unsigned sa, unsigned ea);
|
|
|
|
/* Draw an ellipse pie slice with center at x/y and radii rx/ry using the
|
|
|
|
* current drawing color. The pie slice covers the angle between sa and ea
|
|
|
|
* (startangle and endangle), which must be in the range 0..360 (otherwise the
|
|
|
|
* function may behave unextectedly).
|
|
|
|
*/
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
|
2002-06-22 21:53:58 +00:00
|
|
|
/* Draw a bar (a filled rectangle) using the current color. */
|
2001-08-13 19:29:07 +00:00
|
|
|
|
2009-11-02 22:29:49 +00:00
|
|
|
void __fastcall__ tgi_textscale (unsigned width, unsigned height);
|
|
|
|
/* Set the scaling for text output. The scaling factors for width and height
|
2009-10-30 21:26:35 +00:00
|
|
|
* are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
|
|
|
|
*/
|
2002-10-03 11:18:49 +00:00
|
|
|
|
2009-11-02 22:29:49 +00:00
|
|
|
void __fastcall__ tgi_textstyle (unsigned width, unsigned height,
|
|
|
|
unsigned char dir, unsigned char font);
|
|
|
|
/* Set the style for text output. The scaling factors for width and height
|
|
|
|
* are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
|
|
|
|
* dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
|
|
|
|
* constants.
|
|
|
|
*/
|
2009-11-05 17:14:29 +00:00
|
|
|
|
2002-10-03 11:18:49 +00:00
|
|
|
unsigned __fastcall__ tgi_textwidth (const char* s);
|
|
|
|
/* Calculate the width of the text in pixels according to the current text
|
|
|
|
* style.
|
|
|
|
*/
|
|
|
|
|
|
|
|
unsigned __fastcall__ tgi_textheight (const char* s);
|
|
|
|
/* Calculate the height of the text in pixels according to the current text
|
|
|
|
* style.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void __fastcall__ tgi_outtext (const char* s);
|
|
|
|
/* Output text at the current graphics cursor position. The graphics cursor
|
|
|
|
* is moved to the end of the text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
|
|
|
|
/* Output text at the given cursor position. The graphics cursor is moved to
|
|
|
|
* the end of the text.
|
|
|
|
*/
|
|
|
|
|
2004-10-14 18:24:52 +00:00
|
|
|
unsigned __fastcall__ tgi_ioctl (unsigned char code, unsigned val);
|
|
|
|
/* Call the driver specific control function. What this function does for
|
|
|
|
* a specific code depends on the driver. The driver will set an error
|
|
|
|
* for unknown codes or values.
|
|
|
|
*/
|
|
|
|
|
2001-08-13 19:29:07 +00:00
|
|
|
|
|
|
|
|
2002-06-21 12:01:16 +00:00
|
|
|
/* End of tgi.h */
|
2001-08-13 19:29:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|