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