grfabs_reg.h revision 1.6 1 1.6 leo /* $NetBSD: grfabs_reg.h,v 1.6 1996/03/10 11:42:38 leo Exp $ */
2 1.1 leo
3 1.1 leo /*
4 1.1 leo * Copyright (c) 1995 Leo Weppelman
5 1.1 leo * Copyright (c) 1994 Christian E. Hopps
6 1.1 leo * All rights reserved.
7 1.1 leo * Redistribution and use in source and binary forms, with or without
8 1.1 leo * modification, are permitted provided that the following conditions
9 1.1 leo * are met:
10 1.1 leo * 1. Redistributions of source code must retain the above copyright
11 1.1 leo * notice, this list of conditions and the following disclaimer.
12 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 leo * notice, this list of conditions and the following disclaimer in the
14 1.1 leo * documentation and/or other materials provided with the distribution.
15 1.1 leo * 3. All advertising materials mentioning features or use of this software
16 1.1 leo * must display the following acknowledgement:
17 1.1 leo * This product includes software developed by Christian E. Hopps.
18 1.1 leo * 4. The name of the author may not be used to endorse or promote products
19 1.1 leo * derived from this software without specific prior written permission
20 1.1 leo *
21 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 leo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 leo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 leo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 leo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 leo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 leo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 leo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 leo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 leo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 leo */
32 1.1 leo
33 1.1 leo #ifndef _GRFABS_REG_H
34 1.1 leo #define _GRFABS_REG_H
35 1.1 leo
36 1.6 leo #include <atari/dev/grfabs_fal.h>
37 1.6 leo
38 1.1 leo struct point {
39 1.1 leo long x;
40 1.1 leo long y;
41 1.1 leo };
42 1.1 leo typedef struct point point_t;
43 1.1 leo
44 1.1 leo struct dimension {
45 1.1 leo u_long width;
46 1.1 leo u_long height;
47 1.1 leo };
48 1.1 leo typedef struct dimension dimen_t;
49 1.1 leo
50 1.1 leo struct box {
51 1.1 leo long x;
52 1.1 leo long y;
53 1.1 leo u_long width;
54 1.1 leo u_long height;
55 1.1 leo };
56 1.1 leo typedef struct box box_t;
57 1.1 leo
58 1.1 leo struct rectangle {
59 1.1 leo long left;
60 1.1 leo long top;
61 1.1 leo long right;
62 1.1 leo long bottom;
63 1.1 leo };
64 1.1 leo typedef struct rectangle rect_t;
65 1.1 leo
66 1.1 leo typedef struct bitmap bmap_t;
67 1.1 leo typedef struct colormap colormap_t;
68 1.1 leo typedef struct display_mode dmode_t;
69 1.1 leo
70 1.1 leo /*
71 1.1 leo * View stuff.
72 1.1 leo */
73 1.1 leo
74 1.1 leo struct view {
75 1.1 leo bmap_t *bitmap; /* bitmap. */
76 1.1 leo box_t display; /* viewable area. */
77 1.1 leo dmode_t *mode; /* the mode for this view */
78 1.1 leo colormap_t *colormap; /* the colormap for this view */
79 1.1 leo int flags;
80 1.1 leo };
81 1.1 leo typedef struct view view_t;
82 1.1 leo
83 1.1 leo /* View-flags: */
84 1.1 leo #define VF_DISPLAY 1 /* view is on the air now */
85 1.1 leo
86 1.1 leo /*
87 1.1 leo * Bitmap stuff.
88 1.1 leo */
89 1.1 leo struct bitmap {
90 1.1 leo u_short bytes_per_row; /* number of bytes per display row. */
91 1.1 leo u_short rows; /* number of display rows. */
92 1.1 leo u_short depth; /* depth of bitmap. */
93 1.1 leo u_char *plane; /* plane data for bitmap. */
94 1.1 leo u_char *hw_address; /* mappable bitplane pointer. */
95 1.1 leo };
96 1.1 leo
97 1.1 leo /*
98 1.1 leo * Colormap stuff.
99 1.1 leo */
100 1.1 leo struct colormap {
101 1.2 leo u_char type; /* what type of entries these are. */
102 1.2 leo union {
103 1.2 leo u_char grey; /* CM_GREYSCALE */
104 1.2 leo struct { /* CM_COLOR */
105 1.2 leo u_char red;
106 1.2 leo u_char green;
107 1.2 leo u_char blue;
108 1.2 leo } rgb_mask;
109 1.2 leo } valid_mask;
110 1.2 leo u_short first; /* color register entry[0] refers to */
111 1.2 leo u_short size; /* number of entries */
112 1.2 leo u_long *entry; /* the table of actual color values */
113 1.1 leo };
114 1.1 leo
115 1.1 leo /*
116 1.2 leo * Mask short-hands
117 1.2 leo */
118 1.2 leo #define grey_mask valid_mask.grey
119 1.2 leo #define red_mask valid_mask.rgb_mask.red
120 1.2 leo #define green_mask valid_mask.rgb_mask.green
121 1.2 leo #define blue_mask valid_mask.rgb_mask.blue
122 1.2 leo
123 1.2 leo enum colormap_type {
124 1.2 leo CM_MONO, /* only on or off allowed */
125 1.2 leo CM_GREYSCALE, /* grey values */
126 1.2 leo CM_COLOR /* RGB values */
127 1.2 leo };
128 1.2 leo
129 1.2 leo #define MAX_CENTRIES 256 /* that all there is */
130 1.2 leo /*
131 1.1 leo * Create a colormap entry
132 1.1 leo */
133 1.4 leo #define MAKE_COLOR_ENTRY(r,g,b) (((r & 0xff)<<16)|((g & 0xff)<<8)|(b & 0xff))
134 1.2 leo #define MAKE_MONO_ENTRY(x) ((x) ? 1 : 0)
135 1.2 leo #define MAKE_GREY_ENTRY(l) (l & 0xff)
136 1.2 leo
137 1.4 leo #define CM_L2TT(v) \
138 1.5 leo (((0x000f0000 & (v)) >> 8) | ((0x00000f00 & (v)) >> 4) |\
139 1.5 leo (0x0000000f & (v)))
140 1.4 leo #define CM_TT2L(v) \
141 1.4 leo ((((0x00000f00 & (v)) * 0xff / 0xf) << 8) |\
142 1.4 leo (((0x000000f0 & (v)) * 0xff / 0xf) << 4) |\
143 1.4 leo (0x0000000f & (v)) * 0xff / 0xf)
144 1.4 leo #define CM_L2FAL(v) \
145 1.5 leo (((0x003f0000 & (v)) << 10) | ((0x00003f00 & (v)) << 10) |\
146 1.5 leo (0x0000003f & (v)) << 2)
147 1.4 leo #define CM_FAL2L(v) \
148 1.4 leo (((((0xfc000000 & (v)) >> 10) * 0xff / 0x3f) & 0x00ff0000) |\
149 1.4 leo ((((0x00fc0000 & (v)) >> 10) * 0xff / 0x3f) & 0x0000ff00) |\
150 1.4 leo ((0x000000fc & (v)) >> 2) * 0xff / 0x3f)
151 1.4 leo #define CM_L2ST(v) \
152 1.5 leo (((0x000e0000 & (v)) >> 9) | ((0x00000e00 & (v)) >> 5) |\
153 1.5 leo (0x0000000e & (v)) >> 1)
154 1.4 leo #define CM_ST2L(v) \
155 1.4 leo (((((0x00000700 & (v)) * 0xff / 0x7) << 8) & 0x00ff0000) |\
156 1.4 leo ((((0x00000070 & (v)) * 0xff / 0x7) << 4) & 0x0000ff00) |\
157 1.4 leo (0x00000007 & (v)) * 0xff / 0x7)
158 1.4 leo
159 1.4 leo struct grfabs_sw {
160 1.4 leo void (*display_view) __P((view_t*));
161 1.4 leo view_t * (*alloc_view) __P((dmode_t *, dimen_t *, u_char));
162 1.4 leo void (*free_view) __P((view_t *));
163 1.4 leo void (*remove_view) __P((view_t *));
164 1.4 leo int (*use_colormap) __P((view_t *, colormap_t *));
165 1.4 leo };
166 1.6 leo
167 1.1 leo /* display mode */
168 1.1 leo struct display_mode {
169 1.1 leo LIST_ENTRY(display_mode) link;
170 1.1 leo u_char *name; /* logical name for mode. */
171 1.1 leo dimen_t size; /* screen size */
172 1.1 leo u_char depth; /* screen depth */
173 1.6 leo union {
174 1.6 leo u_short tt_reg; /* video mode register tt */
175 1.6 leo struct {
176 1.6 leo u_short fal_mode; /* falcon mode */
177 1.6 leo struct videl *fal_regs; /* videl register values */
178 1.6 leo } fal_vid;
179 1.6 leo } video_mode;
180 1.4 leo struct grfabs_sw *grfabs_funcs; /* hardware switch table */
181 1.1 leo view_t *current_view; /* view displaying me */
182 1.1 leo };
183 1.6 leo
184 1.6 leo #define vm_reg video_mode.tt_reg
185 1.6 leo #define vm_mode video_mode.fal_vid.fal_mode
186 1.6 leo #define vm_regs video_mode.fal_vid.fal_regs
187 1.1 leo
188 1.1 leo /*
189 1.4 leo * Definition of available graphic mode list.
190 1.4 leo */
191 1.4 leo typedef LIST_HEAD(modelist, display_mode) MODES;
192 1.4 leo
193 1.4 leo /*
194 1.1 leo * Misc draw related macros.
195 1.1 leo */
196 1.1 leo #define INIT_BOX(b,xx,yy,ww,hh) \
197 1.1 leo do { \
198 1.1 leo (b)->x = xx; \
199 1.1 leo (b)->y = yy; \
200 1.1 leo (b)->width = ww; \
201 1.1 leo (b)->height = hh; \
202 1.1 leo } while(0)
203 1.1 leo
204 1.4 leo
205 1.4 leo /*
206 1.4 leo * Common variables
207 1.4 leo */
208 1.4 leo extern view_t gra_con_view;
209 1.4 leo extern colormap_t gra_con_cmap;
210 1.4 leo extern long gra_con_colors[MAX_CENTRIES];
211 1.4 leo extern u_long gra_def_color16[16];
212 1.4 leo
213 1.1 leo /*
214 1.1 leo * Prototypes:
215 1.1 leo */
216 1.4 leo #ifdef FALCON_VIDEO
217 1.4 leo void falcon_probe_video __P((MODES *));
218 1.4 leo #endif /* FALCON_VIDEO */
219 1.4 leo #ifdef TT_VIDEO
220 1.4 leo void tt_probe_video __P((MODES *));
221 1.4 leo #endif /* TT_VIDEO */
222 1.4 leo
223 1.1 leo view_t *grf_alloc_view __P((dmode_t *d, dimen_t *dim, u_char depth));
224 1.3 leo dmode_t *grf_get_best_mode __P((dimen_t *dim, u_char depth));
225 1.1 leo void grf_display_view __P((view_t *v));
226 1.1 leo void grf_remove_view __P((view_t *v));
227 1.1 leo void grf_free_view __P((view_t *v));
228 1.1 leo int grf_get_colormap __P((view_t *, colormap_t *));
229 1.1 leo int grf_use_colormap __P((view_t *, colormap_t *));
230 1.1 leo
231 1.1 leo #endif /* _GRFABS_REG_H */
232