Home | History | Annotate | Line # | Download | only in dev
grfabs_reg.h revision 1.6
      1 /*	$NetBSD: grfabs_reg.h,v 1.6 1996/03/10 11:42:38 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 #include <atari/dev/grfabs_fal.h>
     37 
     38 struct point {
     39     long	x;
     40     long	y;
     41 };
     42 typedef struct point point_t;
     43 
     44 struct dimension {
     45     u_long	width;
     46     u_long	height;
     47 };
     48 typedef struct dimension dimen_t;
     49 
     50 struct box {
     51     long	x;
     52     long	y;
     53     u_long	width;
     54     u_long	height;
     55 };
     56 typedef struct box box_t;
     57 
     58 struct rectangle {
     59     long	left;
     60     long	top;
     61     long	right;
     62     long	bottom;
     63 };
     64 typedef struct rectangle rect_t;
     65 
     66 typedef struct bitmap bmap_t;
     67 typedef struct colormap colormap_t;
     68 typedef struct display_mode dmode_t;
     69 
     70 /*
     71  * View stuff.
     72  */
     73 
     74 struct view {
     75     bmap_t	*bitmap;	/* bitmap.				*/
     76     box_t	display;	/* viewable area.			*/
     77     dmode_t	*mode;		/* the mode for this view		*/
     78     colormap_t	*colormap;	/* the colormap for this view		*/
     79     int		flags;
     80 };
     81 typedef struct view view_t;
     82 
     83 /* View-flags: */
     84 #define	VF_DISPLAY	1	/* view is on the air now		*/
     85 
     86 /*
     87  * Bitmap stuff.
     88  */
     89 struct bitmap {
     90     u_short	bytes_per_row;	/* number of bytes per display row.	*/
     91     u_short	rows;		/* number of display rows.		*/
     92     u_short	depth;		/* depth of bitmap.			*/
     93     u_char	*plane;		/* plane data for bitmap.		*/
     94     u_char	*hw_address;	/* mappable bitplane pointer.		*/
     95 };
     96 
     97 /*
     98  * Colormap stuff.
     99  */
    100 struct colormap {
    101     u_char	type;		/* what type of entries these are.	*/
    102     union {
    103         u_char	grey;		/* CM_GREYSCALE				*/
    104         struct {		/* CM_COLOR				*/
    105             u_char	red;
    106             u_char	green;
    107             u_char	blue;
    108         } rgb_mask;
    109     } valid_mask;
    110     u_short	first;		/* color register entry[0] refers to	*/
    111     u_short	size;		/* number of entries			*/
    112     u_long	*entry;		/* the table of actual color values	*/
    113 };
    114 
    115 /*
    116  * Mask short-hands
    117  */
    118 #define grey_mask  valid_mask.grey
    119 #define red_mask   valid_mask.rgb_mask.red
    120 #define green_mask valid_mask.rgb_mask.green
    121 #define blue_mask  valid_mask.rgb_mask.blue
    122 
    123 enum colormap_type {
    124 	CM_MONO,		/* only on or off allowed		*/
    125 	CM_GREYSCALE,		/* grey values				*/
    126 	CM_COLOR		/* RGB values				*/
    127 };
    128 
    129 #define	MAX_CENTRIES		256		/* that all there is	*/
    130 /*
    131  * Create a colormap entry
    132  */
    133 #define	MAKE_COLOR_ENTRY(r,g,b)	(((r & 0xff)<<16)|((g & 0xff)<<8)|(b & 0xff))
    134 #define MAKE_MONO_ENTRY(x)	((x) ? 1 : 0)
    135 #define MAKE_GREY_ENTRY(l)	(l & 0xff)
    136 
    137 #define CM_L2TT(v) \
    138     (((0x000f0000 & (v)) >> 8) | ((0x00000f00 & (v)) >> 4) |\
    139       (0x0000000f & (v)))
    140 #define CM_TT2L(v) \
    141     ((((0x00000f00 & (v)) * 0xff / 0xf) << 8) |\
    142      (((0x000000f0 & (v)) * 0xff / 0xf) << 4) |\
    143        (0x0000000f & (v)) * 0xff / 0xf)
    144 #define CM_L2FAL(v) \
    145     (((0x003f0000 & (v)) << 10) | ((0x00003f00 & (v)) << 10) |\
    146       (0x0000003f & (v)) << 2)
    147 #define CM_FAL2L(v) \
    148     (((((0xfc000000 & (v)) >> 10) * 0xff / 0x3f) & 0x00ff0000) |\
    149      ((((0x00fc0000 & (v)) >> 10) * 0xff / 0x3f) & 0x0000ff00) |\
    150        ((0x000000fc & (v)) >>  2) * 0xff / 0x3f)
    151 #define CM_L2ST(v) \
    152     (((0x000e0000 & (v)) >> 9) | ((0x00000e00 & (v)) >> 5) |\
    153       (0x0000000e & (v)) >> 1)
    154 #define CM_ST2L(v) \
    155     (((((0x00000700 & (v)) * 0xff / 0x7) << 8) & 0x00ff0000) |\
    156      ((((0x00000070 & (v)) * 0xff / 0x7) << 4) & 0x0000ff00) |\
    157         (0x00000007 & (v)) * 0xff / 0x7)
    158 
    159 struct grfabs_sw {
    160 	void	 (*display_view) __P((view_t*));
    161 	view_t	* (*alloc_view) __P((dmode_t *, dimen_t *, u_char));
    162 	void	 (*free_view) __P((view_t *));
    163 	void	 (*remove_view) __P((view_t *));
    164 	int 	 (*use_colormap) __P((view_t *, colormap_t *));
    165 };
    166 
    167 /* display mode */
    168 struct display_mode {
    169     LIST_ENTRY(display_mode)	link;
    170     u_char			*name;		/* logical name for mode. */
    171     dimen_t			size;		/* screen size		  */
    172     u_char			depth;		/* screen depth		  */
    173     union {
    174 	u_short			tt_reg;		/* video mode register tt */
    175 	struct {
    176 	    u_short		fal_mode;	/* falcon mode		  */
    177 	    struct videl	*fal_regs;	/* videl register values  */
    178 	} fal_vid;
    179     } video_mode;
    180     struct grfabs_sw		*grfabs_funcs;	/* hardware switch table  */
    181     view_t			*current_view;	/* view displaying me	  */
    182 };
    183 
    184 #define vm_reg		video_mode.tt_reg
    185 #define vm_mode		video_mode.fal_vid.fal_mode
    186 #define vm_regs		video_mode.fal_vid.fal_regs
    187 
    188 /*
    189  * Definition of available graphic mode list.
    190  */
    191 typedef LIST_HEAD(modelist, display_mode) MODES;
    192 
    193 /*
    194  * Misc draw related macros.
    195  */
    196 #define INIT_BOX(b,xx,yy,ww,hh)						\
    197 	do {								\
    198 		(b)->x = xx;						\
    199 		(b)->y = yy;						\
    200 		(b)->width = ww;					\
    201 		(b)->height = hh;					\
    202 	} while(0)
    203 
    204 
    205 /*
    206  * Common variables
    207  */
    208 extern view_t		gra_con_view;
    209 extern colormap_t	gra_con_cmap;
    210 extern long		gra_con_colors[MAX_CENTRIES];
    211 extern u_long		gra_def_color16[16];
    212 
    213 /*
    214  * Prototypes:
    215  */
    216 #ifdef FALCON_VIDEO
    217 void	falcon_probe_video __P((MODES *));
    218 #endif /* FALCON_VIDEO */
    219 #ifdef TT_VIDEO
    220 void	tt_probe_video __P((MODES *));
    221 #endif /* TT_VIDEO */
    222 
    223 view_t	*grf_alloc_view __P((dmode_t *d, dimen_t *dim, u_char depth));
    224 dmode_t	*grf_get_best_mode __P((dimen_t *dim, u_char depth));
    225 void	grf_display_view __P((view_t *v));
    226 void	grf_remove_view __P((view_t *v));
    227 void	grf_free_view __P((view_t *v));
    228 int	grf_get_colormap __P((view_t *, colormap_t *));
    229 int	grf_use_colormap __P((view_t *, colormap_t *));
    230 
    231 #endif /* _GRFABS_REG_H */
    232