]> git.sur5r.net Git - cc65/blob - include/graphics.h
Added mouse module from C64
[cc65] / include / graphics.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                graphics.h                                 */
4 /*                                                                           */
5 /*                             Graphics library                              */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2001      Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
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 _GRAPHICS_H
37 #define _GRAPHICS_H
38
39
40
41 /*****************************************************************************/
42 /*                                 Constants                                 */
43 /*****************************************************************************/
44
45
46
47 #define GM_TEXT                 0U      /* Text mode */
48 #define GM_320_200_2            1U      /* 320x200, 2 colors (b/w) */
49 #define GM_160_200_4            2U      /* 160x200, 4 colors */
50
51
52
53 /*****************************************************************************/
54 /*                                   Data                                    */
55 /*****************************************************************************/
56
57
58
59 struct palettetype {
60     unsigned char   r;          /* Red component */
61     unsigned char   g;          /* Green component */
62     unsigned char   b;          /* Blue component */
63 };
64
65
66
67 /*****************************************************************************/
68 /*                                 Functions                                 */
69 /*****************************************************************************/
70
71
72
73 unsigned char __fastcall__ initgraph (unsigned char mode);
74 /* Initialize the graphics screen to the given mode, return the new mode.
75  * Not all modes are available on all systems, check the returned mode
76  * to see if the initialization was successful.
77  */
78
79 void closegraph (void);
80 /* End graphics mode, switch back to text mode */
81
82 void cleargraphscreen (void);
83 /* Clear the screen */
84
85 unsigned char getgraphmode (void);
86 /* Return the current graphics mode */
87
88 unsigned char getmaxcolor (void);
89 /* Return the maximum supported color number (the number of colors would
90  * then be getmaxcolor()+1).
91  */
92
93 unsigned getmaxx (void);
94 /* Return the maximum x coordinate. The resolution in x direction is
95  * getmaxx() + 1
96  */
97
98 unsigned getmaxy (void);
99 /* Return the maximum y coordinate. The resolution in y direction is
100  * getmaxy() + 1
101  */
102
103 void __fastcall__ getaspectratio (unsigned* xasp, unsigned* yasp);
104 /* Get the aspect ratio for the current graphics mode. yasp will always be
105  * 10000, xasp depends on the maxx/mayy ratio of the current resolution.
106  */
107
108 void __fastcall__ setcolor (unsigned char color);
109 /* Set the current drawing color */
110
111 unsigned char getcolor (void);
112 /* Return the current drawing color */
113
114 unsigned char getbkcolor (void);
115 /* Return the current background color */
116
117 void __fastcall__ setbkcolor (unsigned char color);
118 /* Set the background color */
119
120 void __fastcall__ setpalette (unsigned num, const struct palettetype* palette);
121 /* Set one palette entry */
122
123 void __fastcall__ getpalette (unsigned num, struct palettetype* palette);
124 /* Get one palette entry */
125
126 void __fastcall__ setallpalette (const struct palettetype* allpalette);
127 /* Set all palette entries */
128
129 unsigned char __fastcall__ getpixel (int x, int y);
130 /* Get the color value of a pixel */
131
132 void __fastcall__ putpixel (int x, int y);
133 /* Plot a point in the current drawing color */
134
135 void __fastcall__ line (int x1, int y1, int x2, int y2);
136 /* Draw a line in the current drawing color */
137
138 void __fastcall__ circle (int x, int y, unsigned radius);
139 /* Draw a circle in the current drawing color */
140
141 void __fastcall__ outtext (int x, int y, const char* text);
142 /* Print a text in graphics mode */
143
144 void __fastcall__ bar (int x1, int y1, int x2, int y2);
145 /* Draw a bar (a filled rectangle) using the current color */
146
147
148
149 /* End of graphics.h */
150 #endif
151
152
153