grfabs_reg.h revision 1.1 1 /* $NetBSD: grfabs_reg.h,v 1.1 1995/03/26 07:12:15 leo Exp $ */
2
3 /*
4 * Copyright (c) 1995 Leo Weppelman
5 * Copyright (c) 1994 Christian E. Hopps
6 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christian E. Hopps.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef _GRFABS_REG_H
34 #define _GRFABS_REG_H
35
36 struct point {
37 long x;
38 long y;
39 };
40 typedef struct point point_t;
41
42 struct dimension {
43 u_long width;
44 u_long height;
45 };
46 typedef struct dimension dimen_t;
47
48 struct box {
49 long x;
50 long y;
51 u_long width;
52 u_long height;
53 };
54 typedef struct box box_t;
55
56 struct rectangle {
57 long left;
58 long top;
59 long right;
60 long bottom;
61 };
62 typedef struct rectangle rect_t;
63
64 typedef struct bitmap bmap_t;
65 typedef struct colormap colormap_t;
66 typedef struct display_mode dmode_t;
67
68 /*
69 * View stuff.
70 */
71
72 struct view {
73 bmap_t *bitmap; /* bitmap. */
74 box_t display; /* viewable area. */
75 dmode_t *mode; /* the mode for this view */
76 colormap_t *colormap; /* the colormap for this view */
77 int flags;
78 };
79 typedef struct view view_t;
80
81 /* View-flags: */
82 #define VF_DISPLAY 1 /* view is on the air now */
83
84 /*
85 * Bitmap stuff.
86 */
87 struct bitmap {
88 u_short bytes_per_row; /* number of bytes per display row. */
89 u_short rows; /* number of display rows. */
90 u_short depth; /* depth of bitmap. */
91 u_char *plane; /* plane data for bitmap. */
92 u_char *hw_address; /* mappable bitplane pointer. */
93 };
94
95 /*
96 * Colormap stuff.
97 */
98 struct colormap {
99 u_short nentries; /* number of entries in the map */
100 u_short *centry; /* actual colormap */
101 };
102
103 /*
104 * Create a colormap entry
105 */
106 #define MAKE_CENTRY(r,g,b) (((r & 0xf)<<8)|((g & 0xf)<<4)|(b & 0xf))
107 #define MAX_CENTRIES 256 /* that all there is */
108
109 /* display mode */
110 struct display_mode {
111 LIST_ENTRY(display_mode) link;
112 u_char *name; /* logical name for mode. */
113 dimen_t size; /* screen size */
114 u_char depth; /* screen depth */
115 u_short vm_reg; /* video mode register */
116 view_t *current_view; /* view displaying me */
117 };
118
119 /*
120 * Misc draw related macros.
121 */
122 #define INIT_BOX(b,xx,yy,ww,hh) \
123 do { \
124 (b)->x = xx; \
125 (b)->y = yy; \
126 (b)->width = ww; \
127 (b)->height = hh; \
128 } while(0)
129
130 /*
131 * Prototypes:
132 */
133 view_t *grf_alloc_view __P((dmode_t *d, dimen_t *dim, u_char depth));
134 void grf_display_view __P((view_t *v));
135 void grf_remove_view __P((view_t *v));
136 void grf_free_view __P((view_t *v));
137 int grf_get_colormap __P((view_t *, colormap_t *));
138 int grf_use_colormap __P((view_t *, colormap_t *));
139
140 #endif /* _GRFABS_REG_H */
141