Home | History | Annotate | Line # | Download | only in dev
      1  1.9    lukem /*	$NetBSD: grfabs_ccreg.h,v 1.9 2006/03/08 23:46:22 lukem Exp $	*/
      2  1.4      cgd 
      3  1.1   chopps /*
      4  1.1   chopps  * Copyright (c) 1994 Christian E. Hopps
      5  1.1   chopps  * All rights reserved.
      6  1.1   chopps  *
      7  1.1   chopps  * Redistribution and use in source and binary forms, with or without
      8  1.1   chopps  * modification, are permitted provided that the following conditions
      9  1.1   chopps  * are met:
     10  1.1   chopps  * 1. Redistributions of source code must retain the above copyright
     11  1.1   chopps  *    notice, this list of conditions and the following disclaimer.
     12  1.1   chopps  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1   chopps  *    notice, this list of conditions and the following disclaimer in the
     14  1.1   chopps  *    documentation and/or other materials provided with the distribution.
     15  1.1   chopps  * 3. All advertising materials mentioning features or use of this software
     16  1.1   chopps  *    must display the following acknowledgement:
     17  1.1   chopps  *      This product includes software developed by Christian E. Hopps.
     18  1.1   chopps  * 4. The name of the author may not be used to endorse or promote products
     19  1.1   chopps  *    derived from this software without specific prior written permission
     20  1.1   chopps  *
     21  1.1   chopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1   chopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1   chopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1   chopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1   chopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1   chopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1   chopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1   chopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1   chopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1   chopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     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.6   chopps #if defined (GRF_ECS) || defined (GRF_AGA)
     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.3   chopps #if defined(GRF_AGA)
    125  1.3   chopps extern cop_t aga_copper_list[];
    126  1.3   chopps extern int aga_copper_list_len;
    127  1.3   chopps extern int aga_copper_list_size;
    128  1.3   chopps #endif
    129  1.3   chopps 
    130  1.1   chopps extern cop_t std_copper_list[];
    131  1.1   chopps extern int std_copper_list_len;
    132  1.1   chopps extern int std_copper_list_size;
    133  1.1   chopps extern monitor_t *cc_monitor;
    134  1.1   chopps extern u_short cc_default_colors[32];
    135  1.1   chopps extern u_short cc_a2024_default_colors[4];
    136  1.1   chopps 
    137  1.1   chopps /*
    138  1.1   chopps  * Misc macros, defines and enums.
    139  1.1   chopps  */
    140  1.1   chopps 
    141  1.1   chopps #define MDATA(m) ((mdata_t *)(m->data))
    142  1.1   chopps #define DMDATA(d) ((dmdata_t *)(d->data))
    143  1.1   chopps #define VDATA(v) ((vdata_t *)(v->data))
    144  1.1   chopps #define RWDATA(r) ((rwdata_t *)(r->data))
    145  1.1   chopps 
    146  1.6   chopps #if defined (GRF_ECS) || defined (GRF_AGA)
    147  1.1   chopps #define CALC_DIWHIGH(hs, vs, he, ve) \
    148  1.1   chopps         ((u_short)((he&0x100)<<5)|(ve&0x700)|((hs&0x100)>>3)|((vs&0x700)>>8))
    149  1.1   chopps #define USE_CON3 0x0001
    150  1.1   chopps #else
    151  1.1   chopps #define USE_CON3 0x0
    152  1.1   chopps #endif
    153  1.1   chopps 
    154  1.1   chopps enum lace_frame_numbers {
    155  1.1   chopps     F_LACE_LONG,
    156  1.1   chopps     F_LACE_SHORT,
    157  1.1   chopps     F_LACE_STORE_LONG,
    158  1.1   chopps     F_LACE_STORE_SHORT,
    159  1.1   chopps     F_LACE_TOTAL
    160  1.1   chopps };
    161  1.1   chopps 
    162  1.1   chopps enum frame_numbers {
    163  1.1   chopps     F_LONG,
    164  1.1   chopps     F_STORE_LONG,
    165  1.1   chopps     F_TOTAL
    166  1.1   chopps };
    167  1.1   chopps 
    168  1.1   chopps #if defined (GRF_A2024)
    169  1.1   chopps 
    170  1.1   chopps /*
    171  1.1   chopps  * Defines macros and enums for A2024 hedley expansion
    172  1.1   chopps  */
    173  1.1   chopps 
    174  1.1   chopps enum quad_frame_numbers {
    175  1.1   chopps     F_QD_QUAD0, F_QD_QUAD1, F_QD_QUAD2, F_QD_QUAD3,
    176  1.1   chopps     F_QD_STORE_QUAD0, F_QD_STORE_QUAD1, F_QD_STORE_QUAD2, F_QD_STORE_QUAD3,
    177  1.1   chopps     F_QD_TOTAL
    178  1.1   chopps };
    179  1.1   chopps 
    180  1.1   chopps /* -------
    181  1.1   chopps  * |0 |1 |
    182  1.1   chopps  * |------
    183  1.1   chopps  * |2 |3 |
    184  1.1   chopps  * -------
    185  1.1   chopps  */
    186  1.1   chopps 
    187  1.1   chopps #define QUAD0_ID 0x0001
    188  1.1   chopps #define QUAD1_ID 0x00f1
    189  1.1   chopps #define QUAD2_ID 0x0f01
    190  1.1   chopps #define QUAD3_ID 0x0ff1
    191  1.8  aymeric 
    192  1.1   chopps #define HALF_2024_LINE (512>>3)
    193  1.1   chopps #define DIGITAL_RED 0x0800
    194  1.1   chopps #define DIGITAL_GREEN 0x0080
    195  1.1   chopps #define DIGITAL_BLUE 0x0008
    196  1.1   chopps #define DIGITAL_INTENSE 0x0001
    197  1.1   chopps 
    198  1.1   chopps #define A2024_L0_BLACK  (0)
    199  1.1   chopps #define A2024_L0_DGREY  (DIGITAL_BLUE)
    200  1.1   chopps #define A2024_L0_LGREY  (DIGITAL_RED)
    201  1.1   chopps #define A2024_L0_WHITE  (DIGITAL_RED|DIGITAL_BLUE)
    202  1.1   chopps 
    203  1.1   chopps #define A2024_L1_BLACK  (0)
    204  1.1   chopps #define A2024_L1_DGREY  (DIGITAL_INTENSE)
    205  1.1   chopps #define A2024_L1_LGREY  (DIGITAL_GREEN)
    206  1.1   chopps #define A2024_L1_WHITE  (DIGITAL_GREEN|DIGITAL_INTENSE)
    207  1.1   chopps 
    208  1.1   chopps #define A2024_L0_INDEX(color_reg) (((0x4&color_reg)>>1)|(0x1&color_reg))
    209  1.1   chopps #define A2024_L1_INDEX(color_reg) (((0x8&color_reg)>>2)|((0x2&color_reg)>>1))
    210  1.1   chopps #define A2024_CM_TO_CR(cm,rn) \
    211  1.1   chopps 	(a2024_color_value_line0[0x3 & (cm)->entry[A2024_L0_INDEX(rn)]] |\
    212  1.1   chopps 	 a2024_color_value_line1[0x3 & (cm)->entry[A2024_L1_INDEX(rn)]])
    213  1.1   chopps #endif /* GRF_A2024 */
    214  1.1   chopps 
    215  1.1   chopps /*
    216  1.1   chopps  *  Misc defined values for custom chips.
    217  1.1   chopps  */
    218  1.1   chopps 
    219  1.1   chopps /* ECS stuff */
    220  1.1   chopps #define VARVBLANK	0x1000	/* Variable vertical blank enable */
    221  1.1   chopps #define LOLDIS		0x0800	/* long line disable */
    222  1.1   chopps #define CSCBLANKEN	0x0400	/* redirect composite sync */
    223  1.1   chopps #define VARVSYNC	0x0200	/* Variable vertical sync enable */
    224  1.1   chopps #define VARHSYNC	0x0100	/* Variable horizontal sync enable */
    225  1.1   chopps #define VARBEAM	0x0080	/* variable beam counter enable */
    226  1.1   chopps #define DISPLAYDUAL	0x0040	/* use UHRES pointer and standard pointers */
    227  1.1   chopps #define DISPLAYPAL	0x0020	/* set decodes to generate PAL display */
    228  1.1   chopps #define VARCSYNC	0x0010	/* Variable composite sync enable */
    229  1.1   chopps #define CSBLANK	0x0008	/* Composite blank out to CSY* pin */
    230  1.1   chopps #define CSYNCTRUE	0x0004	/* composite sync true signal */
    231  1.1   chopps #define VSYNCTRUE	0x0002	/* vertical sync true */
    232  1.1   chopps #define HSYNCTRUE	0x0001	/* horizontal sync true */
    233  1.1   chopps 
    234  1.1   chopps /* new defines for bplcon0 */
    235  1.1   chopps #define USE_BPLCON3	1
    236  1.1   chopps 
    237  1.1   chopps /* new defines for bplcon2 */
    238  1.1   chopps #define BPLCON2_ZDCTEN		(1<<10) /* colormapped genlock bit */
    239  1.1   chopps #define BPLCON2_ZDBPEN		(1<<11) /* use bitplane as genlock bits */
    240  1.1   chopps #define BPLCON2_ZDBPSEL0	(1<<12) /* three bits to select one */
    241  1.1   chopps #define BPLCON2_ZDBPSEL1	(1<<13) /* of 8 bitplanes in */
    242  1.1   chopps #define BPLCON2_ZDBPSEL2	(1<<14) /* ZDBPEN genlock mode */
    243  1.1   chopps 
    244  1.1   chopps /* defines for bplcon3 register */
    245  1.1   chopps #define BPLCON3_EXTBLNKEN	(1<<0)	/* external blank enable */
    246  1.1   chopps #define BPLCON3_EXTBLKZD	(1<<1)	/* external blank ored into trnsprncy */
    247  1.9    lukem #define BPLCON3_ZDCLKEN	(1<<2)	/* zd pin outputs a 14 MHz clock*/
    248  1.1   chopps #define BPLCON3_BRDNTRAN	(1<<4)	/* border is opaque */
    249  1.1   chopps #define BPLCON3_BRDNBLNK	(1<<5)	/* border is opaque */
    250  1.1   chopps 
    251  1.1   chopps /* mixture of stuff. */
    252  1.1   chopps #define	STANDARD_NTSC_ROWS	262
    253  1.1   chopps #define	STANDARD_PAL_ROWS	312
    254  1.1   chopps #define	STANDARD_COLORCLOCKS	226
    255  1.1   chopps #define	STANDARD_DENISE_MAX	455
    256  1.1   chopps #define	STANDARD_DENISE_MIN	93
    257  1.1   chopps #define	STANDARD_NTSC_BEAMCON	( 0x0000 )
    258  1.1   chopps #define	STANDARD_PAL_BEAMCON	( DISPLAYPAL )
    259  1.1   chopps #define	SPECIAL_BEAMCON	( VARVBLANK | LOLDIS | VARVSYNC | VARHSYNC | VARBEAM | CSBLANK | VSYNCTRUE)
    260  1.1   chopps 
    261  1.1   chopps #define	MIN_NTSC_ROW	21
    262  1.1   chopps #define	MIN_PAL_ROW	29
    263  1.1   chopps #define	STANDARD_VIEW_X	0x81
    264  1.1   chopps #define	STANDARD_VIEW_Y	0x2C
    265  1.1   chopps #define	STANDARD_HBSTRT	0x06
    266  1.1   chopps #define	STANDARD_HSSTRT	0x0B
    267  1.1   chopps #define	STANDARD_HSSTOP	0x1C
    268  1.1   chopps #define	STANDARD_HBSTOP	0x2C
    269  1.1   chopps #define	STANDARD_VBSTRT	0x0122
    270  1.1   chopps #define	STANDARD_VSSTRT	0x02A6
    271  1.1   chopps #define	STANDARD_VSSTOP	0x03AA
    272  1.1   chopps #define	STANDARD_VBSTOP	0x1066
    273  1.1   chopps 
    274  1.1   chopps /*
    275  1.1   chopps  * Prototypes
    276  1.1   chopps  */
    277  1.1   chopps 
    278  1.1   chopps #if defined (__STDC__)
    279  1.1   chopps /* monitor functions */
    280  1.1   chopps monitor_t *cc_init_monitor(void);
    281  1.1   chopps void monitor_vbl_handler(monitor_t * m);
    282  1.1   chopps dmode_t *get_current_mode(void);
    283  1.1   chopps dmode_t *get_next_mode(dmode_t * d);
    284  1.1   chopps dmode_t *get_best_mode(dimen_t * size, u_char depth);
    285  1.1   chopps bmap_t *alloc_bitmap(u_short width, u_short height, u_short depth, u_short flags);
    286  1.1   chopps void free_bitmap(bmap_t * bm);
    287  1.1   chopps void cc_load_mode(dmode_t * d);
    288  1.1   chopps int cc_init_modes(void);
    289  1.1   chopps /* mode functions */
    290  1.1   chopps monitor_t *cc_get_monitor(dmode_t * d);
    291  1.1   chopps view_t *cc_get_current_view(dmode_t * d);
    292  1.1   chopps view_t *cc_alloc_view(dmode_t * mode, dimen_t * dim, u_char depth);
    293  1.1   chopps colormap_t *cc_alloc_colormap(int depth);
    294  1.1   chopps int cc_colormap_checkvals(colormap_t * vcm, colormap_t * cm, int use);
    295  1.1   chopps int cc_get_colormap(view_t * v, colormap_t * cm);
    296  1.1   chopps int cc_use_colormap(view_t * v, colormap_t * cm);
    297  1.1   chopps 
    298  1.1   chopps #  if defined (GRF_A2024)
    299  1.1   chopps colormap_t *cc_a2024_alloc_colormap(int depth);
    300  1.1   chopps int cc_a2024_get_colormap(view_t * v, colormap_t * cm);
    301  1.1   chopps int cc_a2024_use_colormap(view_t * v, colormap_t * cm);
    302  1.1   chopps #  endif /* GRF_2024 */
    303  1.1   chopps 
    304  1.1   chopps void cc_mode_vbl_handler(dmode_t * d);
    305  1.1   chopps void cc_lace_mode_vbl_handler(dmode_t * d);
    306  1.1   chopps /* view functions */
    307  1.1   chopps void cc_init_view(view_t * v, bmap_t * bm, dmode_t * mode, box_t * dbox);
    308  1.1   chopps void cc_free_view(view_t * v);
    309  1.1   chopps void cc_remove_view(view_t * v);
    310  1.1   chopps dmode_t * cc_get_display_mode(view_t * v);
    311  1.7   mhitch 
    312  1.7   mhitch #if defined (GRF_SUPER72)
    313  1.7   mhitch dmode_t *cc_init_super72(void);
    314  1.7   mhitch void display_super72_view(view_t * v);
    315  1.7   mhitch #endif /* SUPER72 */
    316  1.1   chopps 
    317  1.1   chopps #  if defined (GRF_NTSC)
    318  1.1   chopps dmode_t *cc_init_ntsc_hires(void);
    319  1.1   chopps void display_hires_view(view_t * v);
    320  1.1   chopps dmode_t *cc_init_ntsc_hires_lace(void);
    321  1.1   chopps void display_hires_lace_view(view_t * v);
    322  1.1   chopps 
    323  1.1   chopps #    if defined (GRF_A2024)
    324  1.1   chopps dmode_t *cc_init_ntsc_hires_dlace(void);
    325  1.1   chopps void display_hires_dlace_view(view_t * v);
    326  1.1   chopps dmode_t *cc_init_ntsc_a2024(void);
    327  1.1   chopps void display_a2024_view(view_t * v);
    328  1.1   chopps void a2024_mode_vbl_handler(dmode_t * d);
    329  1.1   chopps #    endif /* GRF_A2024 */
    330  1.3   chopps 
    331  1.3   chopps #    if defined (GRF_AGA)
    332  1.3   chopps dmode_t *cc_init_ntsc_aga(void);
    333  1.3   chopps void display_aga_view(view_t * v);
    334  1.3   chopps #    endif /* GRF_AGA */
    335  1.1   chopps #  endif /* GRF_NTSC */
    336  1.1   chopps 
    337  1.1   chopps #  if defined (GRF_PAL)
    338  1.1   chopps dmode_t *cc_init_pal_hires(void);
    339  1.1   chopps void display_pal_hires_view(view_t * v);
    340  1.1   chopps dmode_t *cc_init_pal_hires_lace(void);
    341  1.1   chopps void display_pal_hires_lace_view(view_t * v);
    342  1.1   chopps 
    343  1.1   chopps #    if defined (GRF_A2024)
    344  1.1   chopps dmode_t *cc_init_pal_hires_dlace(void);
    345  1.1   chopps void display_pal_hires_dlace_view(view_t * v);
    346  1.1   chopps 
    347  1.1   chopps dmode_t *cc_init_pal_a2024(void);
    348  1.1   chopps void display_pal_a2024_view(view_t * v);
    349  1.1   chopps void pal_a2024_mode_vbl_handler(dmode_t * d);
    350  1.1   chopps #    endif /* GRF_A2024 */
    351  1.5   chopps 
    352  1.5   chopps #    if defined (GRF_AGA)
    353  1.5   chopps dmode_t *cc_init_pal_aga(void);
    354  1.5   chopps void display_pal_aga_view(view_t * v);
    355  1.5   chopps #    endif /* GRF_AGA */
    356  1.1   chopps #  endif /* GRF_PAL */
    357  1.1   chopps #endif /* __STDC__ */
    358  1.1   chopps 
    359  1.1   chopps 
    360  1.1   chopps #endif /* _GRFABS_CCABS_H */
    361