grfabs_ccreg.h revision 1.2 1 /*
2 * Copyright (c) 1994 Christian E. Hopps
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Christian E. Hopps.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Id: grfabs_ccreg.h,v 1.2 1994/03/27 06:23:35 chopps Exp $
31 */
32
33 #if ! defined (_GRFABS_CCREG_H)
34 #define _GRFABS_CCREG_H
35
36 typedef colormap_t *alloc_colormap_func (int);
37
38 typedef struct monitor_data {
39 LIST_HEAD(modelist, display_mode) modes; /* a list of supported modes. */
40 dmode_t *current_mode;
41 u_long flags; /* monitor flags. */
42 } mdata_t;
43
44 typedef struct display_mode_data {
45 monitor_t * monitor; /* the monitor that owns this mode. */
46 view_t * current_view; /* current view to be displayed. */
47 cop_t **frames;
48 u_short hedley_current; /* current hedley quadrent. */
49 u_short bplcon0; /* bplcon0 data. */
50 u_short std_start_x;
51 u_short std_start_y;
52 #if defined (GRF_ECS)
53 /* ECS registers. */
54 u_short beamcon0;
55 u_short hbstart; /* no modes use the rest of these */
56 u_short hbstop; /* ECS registers. */
57 u_short hsstart;
58 u_short hsstop;
59 u_short vbstart;
60 u_short vbstop;
61 u_short vsstart;
62 u_short vsstop;
63 #endif
64 /* some limit stuff. */
65 dimen_t max_size; /* largest fit. */
66 dimen_t min_size; /* smallest fit. */
67 u_short min_depth;
68 u_short max_depth;
69 u_long flags; /* mode specific flags. */
70 use_colormap_func *use_colormap;
71 get_colormap_func *get_colormap;
72 alloc_colormap_func *alloc_colormap;
73 display_view_func *display_view;
74 vbl_handler_func *vbl_handler; /* gets called every vertical blank. */
75 /* when this is the current mode.*/
76 } dmdata_t;
77
78 enum dmode_flag_bits {
79 DMB_INTERLACE,
80 DMB_HEDLEY_EXP
81 };
82
83 enum dmode_flags {
84 DMF_INTERLACE = 1 << DMB_INTERLACE,
85 DMF_HEDLEY_EXP = 1 << DMB_HEDLEY_EXP
86 };
87
88 typedef struct view_data {
89 dmode_t *mode; /* the mode for this view */
90 colormap_t *colormap;
91 u_long flags; /* view specific flags. */
92 } vdata_t;
93
94 enum view_flag_bits {
95 VB_DISPLAY,
96 };
97
98 enum view_flags {
99 VF_DISPLAY = 1 << VB_DISPLAY, /* set if view is being displayed */
100 };
101
102 /*
103 * This that are in grfabs_ccglb.c
104 */
105 #if defined (GRF_A2024)
106 # if defined (GRF_PAL)
107 extern cop_t std_pal_a2024_copper_list[];
108 extern int std_pal_a2024_copper_list_len;
109 extern int std_pal_a2024_copper_list_size;
110 # endif
111 # if defined (GRF_NTSC)
112 extern cop_t std_a2024_copper_list[];
113 extern int std_a2024_copper_list_len;
114 extern int std_a2024_copper_list_size;
115 # endif
116 extern cop_t std_dlace_copper_list[];
117 extern int std_dlace_copper_list_len;
118 extern int std_dlace_copper_list_size;
119
120 extern u_short a2024_color_value_line0[4];
121 extern u_short a2024_color_value_line1[4];
122 #endif /* GRF_A2024 */
123
124 extern cop_t std_copper_list[];
125 extern int std_copper_list_len;
126 extern int std_copper_list_size;
127 extern monitor_t *cc_monitor;
128 extern u_short cc_default_colors[32];
129 extern u_short cc_a2024_default_colors[4];
130
131 /*
132 * Misc macros, defines and enums.
133 */
134
135 #define MDATA(m) ((mdata_t *)(m->data))
136 #define DMDATA(d) ((dmdata_t *)(d->data))
137 #define VDATA(v) ((vdata_t *)(v->data))
138 #define RWDATA(r) ((rwdata_t *)(r->data))
139
140 #if defined (GRF_ECS)
141 #define CALC_DIWHIGH(hs, vs, he, ve) \
142 ((u_short)((he&0x100)<<5)|(ve&0x700)|((hs&0x100)>>3)|((vs&0x700)>>8))
143 #define USE_CON3 0x0001
144 #else
145 #define USE_CON3 0x0
146 #endif
147
148 enum lace_frame_numbers {
149 F_LACE_LONG,
150 F_LACE_SHORT,
151 F_LACE_STORE_LONG,
152 F_LACE_STORE_SHORT,
153 F_LACE_TOTAL
154 };
155
156 enum frame_numbers {
157 F_LONG,
158 F_STORE_LONG,
159 F_TOTAL
160 };
161
162 #if defined (GRF_A2024)
163
164 /*
165 * Defines macros and enums for A2024 hedley expansion
166 */
167
168 enum quad_frame_numbers {
169 F_QD_QUAD0, F_QD_QUAD1, F_QD_QUAD2, F_QD_QUAD3,
170 F_QD_STORE_QUAD0, F_QD_STORE_QUAD1, F_QD_STORE_QUAD2, F_QD_STORE_QUAD3,
171 F_QD_TOTAL
172 };
173
174 /* -------
175 * |0 |1 |
176 * |------
177 * |2 |3 |
178 * -------
179 */
180
181 #define QUAD0_ID 0x0001
182 #define QUAD1_ID 0x00f1
183 #define QUAD2_ID 0x0f01
184 #define QUAD3_ID 0x0ff1
185
186 #define HALF_2024_LINE (512>>3)
187 #define DIGITAL_RED 0x0800
188 #define DIGITAL_GREEN 0x0080
189 #define DIGITAL_BLUE 0x0008
190 #define DIGITAL_INTENSE 0x0001
191
192 #define A2024_L0_BLACK (0)
193 #define A2024_L0_DGREY (DIGITAL_BLUE)
194 #define A2024_L0_LGREY (DIGITAL_RED)
195 #define A2024_L0_WHITE (DIGITAL_RED|DIGITAL_BLUE)
196
197 #define A2024_L1_BLACK (0)
198 #define A2024_L1_DGREY (DIGITAL_INTENSE)
199 #define A2024_L1_LGREY (DIGITAL_GREEN)
200 #define A2024_L1_WHITE (DIGITAL_GREEN|DIGITAL_INTENSE)
201
202 #define A2024_L0_INDEX(color_reg) (((0x4&color_reg)>>1)|(0x1&color_reg))
203 #define A2024_L1_INDEX(color_reg) (((0x8&color_reg)>>2)|((0x2&color_reg)>>1))
204 #define A2024_CM_TO_CR(cm,rn) \
205 (a2024_color_value_line0[0x3 & (cm)->entry[A2024_L0_INDEX(rn)]] |\
206 a2024_color_value_line1[0x3 & (cm)->entry[A2024_L1_INDEX(rn)]])
207 #endif /* GRF_A2024 */
208
209 /*
210 * Misc defined values for custom chips.
211 */
212
213 /* ECS stuff */
214 #define VARVBLANK 0x1000 /* Variable vertical blank enable */
215 #define LOLDIS 0x0800 /* long line disable */
216 #define CSCBLANKEN 0x0400 /* redirect composite sync */
217 #define VARVSYNC 0x0200 /* Variable vertical sync enable */
218 #define VARHSYNC 0x0100 /* Variable horizontal sync enable */
219 #define VARBEAM 0x0080 /* variable beam counter enable */
220 #define DISPLAYDUAL 0x0040 /* use UHRES pointer and standard pointers */
221 #define DISPLAYPAL 0x0020 /* set decodes to generate PAL display */
222 #define VARCSYNC 0x0010 /* Variable composite sync enable */
223 #define CSBLANK 0x0008 /* Composite blank out to CSY* pin */
224 #define CSYNCTRUE 0x0004 /* composite sync true signal */
225 #define VSYNCTRUE 0x0002 /* vertical sync true */
226 #define HSYNCTRUE 0x0001 /* horizontal sync true */
227
228 /* new defines for bplcon0 */
229 #define USE_BPLCON3 1
230
231 /* new defines for bplcon2 */
232 #define BPLCON2_ZDCTEN (1<<10) /* colormapped genlock bit */
233 #define BPLCON2_ZDBPEN (1<<11) /* use bitplane as genlock bits */
234 #define BPLCON2_ZDBPSEL0 (1<<12) /* three bits to select one */
235 #define BPLCON2_ZDBPSEL1 (1<<13) /* of 8 bitplanes in */
236 #define BPLCON2_ZDBPSEL2 (1<<14) /* ZDBPEN genlock mode */
237
238 /* defines for bplcon3 register */
239 #define BPLCON3_EXTBLNKEN (1<<0) /* external blank enable */
240 #define BPLCON3_EXTBLKZD (1<<1) /* external blank ored into trnsprncy */
241 #define BPLCON3_ZDCLKEN (1<<2) /* zd pin outputs a 14mhz clock*/
242 #define BPLCON3_BRDNTRAN (1<<4) /* border is opaque */
243 #define BPLCON3_BRDNBLNK (1<<5) /* border is opaque */
244
245 /* mixture of stuff. */
246 #define STANDARD_NTSC_ROWS 262
247 #define STANDARD_PAL_ROWS 312
248 #define STANDARD_COLORCLOCKS 226
249 #define STANDARD_DENISE_MAX 455
250 #define STANDARD_DENISE_MIN 93
251 #define STANDARD_NTSC_BEAMCON ( 0x0000 )
252 #define STANDARD_PAL_BEAMCON ( DISPLAYPAL )
253 #define SPECIAL_BEAMCON ( VARVBLANK | LOLDIS | VARVSYNC | VARHSYNC | VARBEAM | CSBLANK | VSYNCTRUE)
254
255 #define MIN_NTSC_ROW 21
256 #define MIN_PAL_ROW 29
257 #define STANDARD_VIEW_X 0x81
258 #define STANDARD_VIEW_Y 0x2C
259 #define STANDARD_HBSTRT 0x06
260 #define STANDARD_HSSTRT 0x0B
261 #define STANDARD_HSSTOP 0x1C
262 #define STANDARD_HBSTOP 0x2C
263 #define STANDARD_VBSTRT 0x0122
264 #define STANDARD_VSSTRT 0x02A6
265 #define STANDARD_VSSTOP 0x03AA
266 #define STANDARD_VBSTOP 0x1066
267
268 /*
269 * Prototypes
270 */
271
272 #if defined (__STDC__)
273 /* monitor functions */
274 monitor_t *cc_init_monitor(void);
275 void monitor_vbl_handler(monitor_t * m);
276 dmode_t *get_current_mode(void);
277 dmode_t *get_next_mode(dmode_t * d);
278 dmode_t *get_best_mode(dimen_t * size, u_char depth);
279 bmap_t *alloc_bitmap(u_short width, u_short height, u_short depth, u_short flags);
280 void free_bitmap(bmap_t * bm);
281 void cc_load_mode(dmode_t * d);
282 int cc_init_modes(void);
283 /* mode functions */
284 monitor_t *cc_get_monitor(dmode_t * d);
285 view_t *cc_get_current_view(dmode_t * d);
286 view_t *cc_alloc_view(dmode_t * mode, dimen_t * dim, u_char depth);
287 colormap_t *cc_alloc_colormap(int depth);
288 int cc_colormap_checkvals(colormap_t * vcm, colormap_t * cm, int use);
289 int cc_get_colormap(view_t * v, colormap_t * cm);
290 int cc_use_colormap(view_t * v, colormap_t * cm);
291
292 # if defined (GRF_A2024)
293 colormap_t *cc_a2024_alloc_colormap(int depth);
294 int cc_a2024_get_colormap(view_t * v, colormap_t * cm);
295 int cc_a2024_use_colormap(view_t * v, colormap_t * cm);
296 # endif /* GRF_2024 */
297
298 void cc_mode_vbl_handler(dmode_t * d);
299 void cc_lace_mode_vbl_handler(dmode_t * d);
300 /* view functions */
301 void cc_init_view(view_t * v, bmap_t * bm, dmode_t * mode, box_t * dbox);
302 void cc_free_view(view_t * v);
303 void cc_remove_view(view_t * v);
304 dmode_t * cc_get_display_mode(view_t * v);
305
306 # if defined (GRF_NTSC)
307 dmode_t *cc_init_ntsc_hires(void);
308 void display_hires_view(view_t * v);
309 dmode_t *cc_init_ntsc_hires_lace(void);
310 void display_hires_lace_view(view_t * v);
311
312 # if defined (GRF_A2024)
313 dmode_t *cc_init_ntsc_hires_dlace(void);
314 void display_hires_dlace_view(view_t * v);
315 dmode_t *cc_init_ntsc_a2024(void);
316 void display_a2024_view(view_t * v);
317 void a2024_mode_vbl_handler(dmode_t * d);
318 # endif /* GRF_A2024 */
319 # endif /* GRF_NTSC */
320
321 # if defined (GRF_PAL)
322 dmode_t *cc_init_pal_hires(void);
323 void display_pal_hires_view(view_t * v);
324 dmode_t *cc_init_pal_hires_lace(void);
325 void display_pal_hires_lace_view(view_t * v);
326
327 # if defined (GRF_A2024)
328 dmode_t *cc_init_pal_hires_dlace(void);
329 void display_pal_hires_dlace_view(view_t * v);
330
331 dmode_t *cc_init_pal_a2024(void);
332 void display_pal_a2024_view(view_t * v);
333 void pal_a2024_mode_vbl_handler(dmode_t * d);
334 # endif /* GRF_A2024 */
335 # endif /* GRF_PAL */
336 #endif /* __STDC__ */
337
338
339 #endif /* _GRFABS_CCABS_H */
340