1 /* Graphics Library headerfile */
2 
3 #ifndef VGAGL_H
4 #define VGAGL_H
5 
6 #ifdef __cplusplus
7 extern "C"
8 {
9 #endif
10 
11 
12 /* Graphics context */
13 
14 #define CONTEXT_VIRTUAL		0x0
15 #define CONTEXT_PAGED		0x1
16 #define CONTEXT_LINEAR		0x2
17 #define CONTEXT_MODEX		0x3
18 #define CONTEXT_PLANAR16	0x4
19 
20 #define MODEFLAG_PAGEFLIPPING_CAPABLE		0x01
21 #define MODEFLAG_TRIPLEBUFFERING_CAPABLE	0x02
22 #define MODEFLAG_PAGEFLIPPING_ENABLED		0x04
23 #define MODEFLAG_TRIPLEBUFFERING_ENABLED	0x08
24 #define MODEFLAG_FLIPPAGE_BANKALIGNED		0x10
25 /*
26  * The next two can never occur together, thus we use the same flag
27  * (as svgalib does).
28  */
29 #define MODEFLAG_32BPP_SHIFT8			0x20
30 #define MODEFLAG_24BPP_REVERSED			0x20
31 
32     typedef struct {
33 	unsigned char modetype;	/* virtual, paged, linear, mode X */
34 	unsigned char modeflags;	/* or planar16 */
35 	unsigned char dummy;
36 	unsigned char flippage;
37 	int width;		/* width in pixels */
38 	int height;		/* height in pixels */
39 	int bytesperpixel;	/* bytes per pixel (1, 2, 3, or 4) */
40 	int colors;		/* number of colors */
41 	int bitsperpixel;	/* bits per pixel (8, 15, 16 or 24) */
42 	int bytewidth;		/* length of a scanline in bytes */
43 	char *vbuf;		/* address of framebuffer */
44 	int clip;		/* clipping enabled? */
45 	int clipx1;		/* top-left coordinate of clip window */
46 	int clipy1;
47 	int clipx2;		/* bottom-right coordinate of clip window */
48 	int clipy2;
49     } GraphicsContext;
50 
51     extern GraphicsContext currentcontext;
52 
53 #define BYTESPERPIXEL (currentcontext.bytesperpixel)
54 #define BYTEWIDTH (currentcontext.bytewidth)
55 #define WIDTH (currentcontext.width)
56 #define HEIGHT (currentcontext.height)
57 #define VBUF (currentcontext.vbuf)
58 #define MODETYPE (currentcontext.modetype)
59 #define MODEFLAGS (currentcontext.modeflags)
60 #define BITSPERPIXEL (currentcontext.bitsperpixel)
61 #define COLORS (currentcontext.colors)
62 
63 #define __clip (currentcontext.clip)
64 #define __clipx1 (currentcontext.clipx1)
65 #define __clipy1 (currentcontext.clipy1)
66 #define __clipx2 (currentcontext.clipx2)
67 #define __clipy2 (currentcontext.clipy2)
68 
69 
70 /* Configuration */
71 
72     int gl_setcontextvga(int m);
73     int gl_setcontextvgavirtual(int m);
74     void gl_setcontextvirtual(int w, int h, int bpp, int bitspp, void *vbuf);
75     void gl_setcontextwidth(int w);
76     void gl_setcontextheight(int h);
77     GraphicsContext *gl_allocatecontext(void);
78     void gl_setcontext(GraphicsContext * gc);
79     void gl_getcontext(GraphicsContext * gc);
80     void gl_freecontext(GraphicsContext * gc);
81 
82 /* Line drawing */
83 
84     void gl_setpixel(int x, int y, int c);
85     void gl_setpixelrgb(int x, int y, int r, int g, int b);
86     int gl_getpixel(int x, int y);
87     void gl_getpixelrgb(int x, int y, int *r, int *g, int *b);
88     int gl_rgbcolor(int r, int g, int b);
89     void gl_hline(int x1, int y, int x2, int c);
90     void gl_line(int x1, int y1, int x2, int y2, int c);
91     void gl_circle(int x, int y, int r, int c);
92 
93 /* Box (bitmap) functions */
94 
95     void gl_fillbox(int x, int y, int w, int h, int c);
96     void gl_getbox(int x, int y, int w, int h, void *dp);
97     void gl_putbox(int x, int y, int w, int h, void *dp);
98     void gl_putboxpart(int x, int y, int w, int h, int bw, int bh, void *b,
99 		       int xo, int yo);
100     void gl_putboxmask(int x, int y, int w, int h, void *dp);
101     void gl_copybox(int x1, int y1, int w, int h, int x2, int y2);
102     void gl_copyboxtocontext(int x1, int y1, int w, int h, GraphicsContext * gc,
103 			     int x2, int y2);
104     void gl_copyboxfromcontext(GraphicsContext * gc, int x1, int y1, int w, int h,
105 			       int x2, int y2);
106 /* The following functions only work in 256-color modes: */
107     void gl_compileboxmask(int w, int h, void *sdp, void *ddp);
108     int gl_compiledboxmasksize(int w, int h, void *sdp);
109     void gl_putboxmaskcompiled(int x, int y, int w, int h, void *dp);
110 
111 /* Miscellaneous */
112 
113     void gl_clearscreen(int c);
114     void gl_scalebox(int w1, int h1, void *sb, int w2, int h2, void *db);
115     void gl_setdisplaystart(int x, int y);
116     void gl_enableclipping(void);
117     void gl_setclippingwindow(int x1, int y1, int x2, int y2);
118     void gl_disableclipping(void);
119 
120 /* Screen buffering */
121 
122     void gl_copyscreen(GraphicsContext * gc);
123     void gl_setscreenoffset(int o);
124     int gl_enablepageflipping(GraphicsContext * gc);
125 
126 /* Text */
127 
128 /* Writemode flags. */
129 #define WRITEMODE_OVERWRITE 0
130 #define WRITEMODE_MASKED 1
131 #define FONT_EXPANDED 0
132 #define FONT_COMPRESSED 2
133 
134     void gl_expandfont(int fw, int fh, int c, void *sfdp, void *dfdp);
135     void gl_setfont(int fw, int fh, void *fdp);
136     void gl_colorfont(int fw, int fh, int c, void *fdp);
137     void gl_setwritemode(int wm);
138     void gl_write(int x, int y, char *s);
139     void gl_writen(int x, int y, int n, char *s);
140     void gl_setfontcolors(int bg, int fg);
141 
142     extern unsigned char *gl_font8x8;	/* compressed 8x8 font */
143 
144 /* 256-color Palette */
145 
146     typedef struct {
147 	struct {
148 	    unsigned char red;	/* 6-bit values */
149 	    unsigned char green;
150 	    unsigned char blue;
151 	} color[256];
152     } Palette;
153 
154     void gl_setpalettecolor(int c, int r, int b, int g);
155     void gl_getpalettecolor(int c, int *r, int *b, int *g);
156     void gl_setpalettecolors(int s, int n, void *dp);
157     void gl_getpalettecolors(int s, int n, void *dp);
158     void gl_setpalette(void *p);
159     void gl_getpalette(void *p);
160     void gl_setrgbpalette(void);
161 
162 
163 #ifdef __cplusplus
164 }
165 
166 #endif
167 #endif
168