Home | History | Annotate | Line # | Download | only in dev
grf_ccreg.h revision 1.3
      1  1.1       mw /*
      2  1.1       mw  * Driver for custom chips display.
      3  1.2  mycroft  *
      4  1.3       mw  *	$Id: grf_ccreg.h,v 1.3 1993/09/02 18:07:59 mw Exp $
      5  1.1       mw  */
      6  1.1       mw 
      7  1.1       mw /* this is a mere collection of data, the registers itself are in the
      8  1.1       mw    custom chip area */
      9  1.1       mw 
     10  1.1       mw struct ccfb {
     11  1.3       mw   int disp_width;
     12  1.3       mw   int disp_height;
     13  1.3       mw   int disp_x, disp_y;		/* this defines the dimension and
     14  1.3       mw 				   relative position of the display. */
     15  1.3       mw   int disp_z;			/* display depth */
     16  1.3       mw 
     17  1.3       mw   u_char *fb;			/* frame buffer, ie. block in chipmem
     18  1.3       mw 				   containing bitplane(s) */
     19  1.3       mw   int fb_width;
     20  1.3       mw   int fb_height;		/* dimension of the framebuffer. Can
     21  1.3       mw 				   be larger than the display! */
     22  1.3       mw   int fb_planesize;		/* size of each plane, in bytes */
     23  1.3       mw   int fb_x, fb_y;		/* offset of the framebuffer relative
     24  1.3       mw 				   to the display (disp_*) values */
     25  1.3       mw   int fb_z;			/* frame buffer depth */
     26  1.3       mw 
     27  1.3       mw /* these are added by mykes */
     28  1.3       mw #if 0
     29  1.3       mw   /* DON'T PUT THOSE HERE! They're fully calculatable from the above
     30  1.3       mw      values, and would introduce data redundancy */
     31  1.3       mw 
     32  1.3       mw   /*
     33  1.3       mw    * diwstrt, etc. are for direct poke into copper list
     34  1.3       mw    * there should be an ioctl to modify these values
     35  1.3       mw    */
     36  1.3       mw   u_short diwstrt, diwstop;
     37  1.3       mw   u_short ddfstrt, ddfstop;	/* initializers for hardware regs */
     38  1.3       mw #endif
     39  1.3       mw   /*
     40  1.3       mw    * 32 word color palette... also poked into copper list
     41  1.3       mw    * color 0 is background color
     42  1.3       mw    * color 1 is text color
     43  1.3       mw    * color 2 is intended for cursor color (not working yet)
     44  1.3       mw    * color 3 is intended for selection color (not working yet)
     45  1.3       mw    * color 10 (hex) is sprite pointer color 0 (transparent)
     46  1.3       mw    * color 11 is sprite pointer color 1
     47  1.3       mw    * color 12 is sprite pointer color 2
     48  1.3       mw    * color 13 is sprite pointer color 3
     49  1.3       mw    */
     50  1.3       mw   u_short col[32];		/* color palette */
     51  1.3       mw   /*
     52  1.3       mw    * beepSample is chipram of 20 bytes/10 words.  It is a sine wave
     53  1.3       mw    * sample for creating the beep sound.
     54  1.3       mw    */
     55  1.3       mw   char *beepSample;		/* pointer to beep audio sample */
     56  1.3       mw   /*
     57  1.3       mw    * the beep can have a variable (set by ioctl()) pitch/period.
     58  1.3       mw    * the ioctl() handler routine must stuff any new period into
     59  1.3       mw    * the hardware, too!
     60  1.3       mw    */
     61  1.3       mw   u_short beepPeriod;		/* audio hardware period for sample */
     62  1.3       mw   /*
     63  1.3       mw    * the beep can have a variable volume (set by ioctl()).  the
     64  1.3       mw    * ioctl() handler routine must stuff any new volume into the
     65  1.3       mw    * hardware, too!
     66  1.3       mw    */
     67  1.3       mw   u_short beepVolume;		/* audio hardware volume for sample */
     68  1.3       mw   /*
     69  1.3       mw    * At console init time, the copper list is created, and so is the
     70  1.3       mw    * sample buffer (in chip).  The init routine starts the audio hardware
     71  1.3       mw    * playing the sample in aud0 and aud1 (stereo L+R), but turns the
     72  1.3       mw    * volume OFF for both channels.  When a beep is started, beepTimer
     73  1.3       mw    * is set to beepTime (set beepTime with ioctl() to override default).
     74  1.3       mw    * the vbl handler cc_vbl() counts down beepTimer and when it hits
     75  1.3       mw    * zero, it turns off the volume again.  Cheap, but it works and no
     76  1.3       mw    * interrupts are needed :-)
     77  1.3       mw    */
     78  1.3       mw   u_short beepTimer, beepTime;	/* timer and timer value for audio beep */
     79  1.3       mw   /*
     80  1.3       mw    * there is a builtin facility for displaybeep, which is just a screen
     81  1.3       mw    * flash.  It is unimplemented, but the fields are defined here.  THe
     82  1.3       mw    * idea is for an ioctl() to be used to enable beep and/or display
     83  1.3       mw    * beep (or neither).  As with beepTime/beepTimer above, just set
     84  1.3       mw    * dbeepTime with the ioctl() handler.
     85  1.3       mw    */
     86  1.3       mw   u_short dbeepTimer, dbeepTime; /* timer and timer value for visual beep */
     87  1.3       mw   /*
     88  1.3       mw    * two copper lists are needed, one for even, one for odd frame of
     89  1.3       mw    * the display.  There is a nice copper list structure defined
     90  1.3       mw    * in grf_cc.c so the ioctl() function can poke values into the
     91  1.3       mw    * copper lists with ease.  Things to poke are colors, horizontal
     92  1.3       mw    * offset (i.e horizontal offset to plane pointers), and screen
     93  1.3       mw    * positioning (diwstrt, etc.).
     94  1.3       mw    */
     95  1.3       mw   u_short *cop1, *cop2;		/* both copperlists */
     96  1.3       mw   /*
     97  1.3       mw    * this is the mouse pointer.  It is 4+16*4+4 bytes in CHIP ram.
     98  1.3       mw    * the first 4 bytes are control bytes for the sprite DMA hardware,
     99  1.3       mw    * and are used by the cc_vbl() interrupt handler to move the
    100  1.3       mw    * mouse.  The next 16*4 words define the sprite, as in the
    101  1.3       mw    * hardware rkm: plane0 word/plane1 word format for 16 tall.
    102  1.3       mw    * the last 4 bytes are 2 null words, as required for sprite DMA.
    103  1.3       mw    * there is a cheap trick played with these null words!  The other
    104  1.3       mw    * 7 sprites point to these NULL words (any ZERO word in chip
    105  1.3       mw    * works, and these are dependable to be NULL).  THe intent for
    106  1.3       mw    * the 16*4 words is for an ioctl() call to be usable to alter
    107  1.3       mw    * the sprite pointer image - just copy 16*4 words into the pointer
    108  1.3       mw    * structure in chip ram!  There is a handy POINTER struct defined
    109  1.3       mw    * in grf_cc.c.
    110  1.3       mw    */
    111  1.3       mw   u_short *pointer;		/* sprite pointer memory */
    112  1.3       mw   /*
    113  1.3       mw    * mouseH and mouseV are the actual mouse counter register values.
    114  1.3       mw    * you need to keep track of them so you can do deltas from this frame's
    115  1.3       mw    * values to last frame's.  lastMouseH and lastMouseV are used for
    116  1.3       mw    * the mouse blanker.  ANY movement of the mouse unblanks the mouse
    117  1.3       mw    * (and if the screen is blanked, it is unblanked too).  You need
    118  1.3       mw    * to detect counter change and not position change - the mouse could
    119  1.3       mw    * be stuck in a corner and not moving :-)
    120  1.3       mw    */
    121  1.3       mw   u_char mouseH, mouseV;	/* mouse horiz, vert for delta */
    122  1.3       mw   u_char lastMouseH, lastMouseV; /* last values (for blanker) */
    123  1.3       mw   /*
    124  1.3       mw    * mouseX and mouseY are the actual mouse coordinates on the screen
    125  1.3       mw    * (in pixels).  There is some incomplete calculations in the source
    126  1.3       mw    * (grf_cc.c) for positioning the mouse - they don't factor in a
    127  1.3       mw    * variable diwstrt, etc.  This should be fixed :-)  mouseb1 and mouseb2
    128  1.3       mw    * are the mouse button values.  !0 means mouse button is down!
    129  1.3       mw    * An ioctl() can either move the mouse position (change mouseX,mouseY)
    130  1.3       mw    * or it can read the mouse position and buttons.
    131  1.3       mw    */
    132  1.3       mw   short mouseX, mouseY;			/* mouse coords */
    133  1.3       mw   u_char mouseb1, mouseb2, mouseb3;	/* mouse buttons */
    134  1.3       mw   /*
    135  1.3       mw    * There's two joystick ports on the Amiga.  joy0 is the joy port
    136  1.3       mw    * that the mouse is NOT normally plugged into.  joy1 is the joy
    137  1.3       mw    * port the mouse IS normally plugged into.  There are #defines
    138  1.3       mw    * for the bits for the joysticks below.  Note that if a mouse
    139  1.3       mw    * is plugged in, joy1 bits are not joystick bits (garbage :-)
    140  1.3       mw    * There is no facility for the grf_cc.c routine to use a mouse
    141  1.3       mw    * in either port - just the normal mouseport that amigaos uses.
    142  1.3       mw    * this should be enhanced (why not? :-)
    143  1.3       mw    */
    144  1.3       mw   u_char joy0, joy1;		/* joysticks */
    145  1.3       mw   /*
    146  1.3       mw    * The console (grf_cc.c) features a mouseblanker and a screenblanker.
    147  1.3       mw    * If you don't move the mouse for mouseTime 60ths of a second, the
    148  1.3       mw    * mouse will be blanked (sprite DMA turned off).  If you move the
    149  1.3       mw    * mouse, the DMA is turned on again (if the screen is blanked, it
    150  1.3       mw    * is turned on also).  If you don't hit a key or move the mouse for
    151  1.3       mw    * screenTime 60ths of a second, the screen will blank (raster DMA
    152  1.3       mw    * is turned off and color 0 set to BLACK.  If you hit a key or move
    153  1.3       mw    * the mouse, it will be unblanked.  The screenBlank/mouseBlank
    154  1.3       mw    * variables are the timers.  They are inited with screenTime/mouseTime.
    155  1.3       mw    * the cc_vbl() routine counts these timers down, and when they hit
    156  1.3       mw    * zero, the DMA is turned off.  The timers are restarted (full time
    157  1.3       mw    * to count down again) when the mouse is moved or key is hit (key
    158  1.3       mw    * hit for screen blanker only).  screenTime and mouseTime are intended
    159  1.3       mw    * for use with ioctl() handler.  Thus the timer times can be set by
    160  1.3       mw    * the ioctl handler ;-)
    161  1.3       mw    */
    162  1.3       mw   u_short screenTime, mouseTime; /* timer counts for screen/mouse blankers */
    163  1.3       mw   u_short screenBlank, mouseBlank; /* timers: screen, mouse blankers */
    164  1.3       mw   /*
    165  1.3       mw    * this below is unfinished, really.  instead of two bytes, one of pad,
    166  1.3       mw    * it should be 16 bits of flags (u_short).  One of the flags should
    167  1.3       mw    * be the enable flag.  I'm too lazy to fix it right now :-)  The
    168  1.3       mw    * enable flag is checked for blanking purposes.  If the flag is off,
    169  1.3       mw    * the blankers are disabled.  Typical use is for an addon graphics
    170  1.3       mw    * card (i.e. custom chipset graphics not in use).  The other flags
    171  1.3       mw    * should be used to enable beep, blankers, and so forth.
    172  1.3       mw    */
    173  1.3       mw   u_char enableFlag, pad;	/* flag: true if display enabled */
    174  1.1       mw };
    175  1.1       mw 
    176  1.3       mw /* bits for joy0, joy1 of ccfb */
    177  1.3       mw #define JOYLEFT (1<<0)
    178  1.3       mw #define JOYRIGHT (1<<1)
    179  1.3       mw #define JOYUP (1<<2)
    180  1.3       mw #define JOYDOWN (1<<3)
    181  1.3       mw #define JOYBUTTON (1<<4)
    182  1.3       mw 
    183  1.3       mw /* mouse/screen  blanker default timer times */
    184  1.3       mw #define DEF_MOUSE (60*5)	/* 5 seconds */
    185  1.3       mw #define DEF_SCREEN (60*5*60)	/* 5 minutes */
    186  1.1       mw 
    187  1.1       mw /* these are the initial values for changeable parameters: */
    188  1.1       mw #define	DEF_DISP_WIDTH		640
    189  1.1       mw #define DEF_DISP_HEIGHT		400
    190  1.1       mw #define DEF_DISP_X		258	/* "" */
    191  1.1       mw #define DEF_DISP_Y		88	/* hardware preferred values.. */
    192  1.1       mw #define DEF_FB_X		0
    193  1.1       mw #define DEF_FB_Y		0
    194  1.3       mw /* mtk: if it were up to me, I'd delete all of the above */
    195  1.3       mw /* mykes: NOPE! These are enough to regenerate the very hardware
    196  1.3       mw           specific diw* values, so drop those! */
    197  1.3       mw 
    198  1.3       mw /* 4 colors for text/cursor, etc., 4 colors for sprite/pointer */
    199  1.3       mw #define DEF_COL0		0xaaa
    200  1.3       mw #define DEF_COL1		0x000
    201  1.3       mw #define DEF_COL2		0x68b
    202  1.3       mw #define DEF_COL3		0xfff
    203  1.3       mw #define DEF_COL10		0xf00
    204  1.3       mw #define DEF_COL11		0x0f0
    205  1.3       mw #define DEF_COL12		0x00f
    206  1.3       mw #define DEF_COL13		0x0ff
    207  1.3       mw 
    208  1.3       mw /*
    209  1.3       mw  * display mode is a constant for now.  You always get hires interlace
    210  1.3       mw  * and two planes.  ECS modes may make sense at a later date, as do
    211  1.3       mw  * AGA and beyond.  First we need AGA machines with 030's so BSD will
    212  1.3       mw  * run on them.  Then we need docs on the hardware regs :-)
    213  1.3       mw  */
    214  1.3       mw #if 0
    215  1.3       mw /* don't do these hardwired. Besides, VIEWMODE changes if number of planes
    216  1.3       mw    changes, no hardwire either */
    217  1.3       mw 
    218  1.3       mw #define VIEWMODE 0xa204		/* 2 planes, hires, interlace */
    219  1.3       mw #define DEF_DIWSTRT 0x2c81
    220  1.3       mw #define DEF_DIWSTOP 0xf4c1
    221  1.3       mw #define DEF_DDFSTRT 0x003c
    222  1.3       mw #define DEF_DDFSTOP 0x00d4
    223  1.3       mw #endif
    224  1.3       mw 
    225  1.3       mw /* default audio values */
    226  1.3       mw #define DEF_PERIOD 200		/* default period value for audio (beep) */
    227  1.3       mw #define DEF_VOLUME 64		/* default volume value for audio (beep) */
    228  1.3       mw #define DEF_ABEEP 10		/* default timer for audio beep */
    229  1.3       mw /* default display beep values (not implemented yet) */
    230  1.3       mw #define DEF_DBEEP 10		/* default timer for display beep */
    231  1.3       mw 
    232  1.1       mw /* these are currently not changeable easily (would require reallocation
    233  1.1       mw    of display memory and rebuild of copperlists. Do this later perhaps) */
    234  1.3       mw 
    235  1.3       mw /* note: mtk, it was easier than you think :-) */
    236  1.3       mw /* note: mykes, yeah because you left them at 640x400... */
    237  1.1       mw #define DEF_FB_WIDTH		1024
    238  1.1       mw #define DEF_FB_HEIGHT		1024
    239  1.3       mw #define DEF_FB_Z		2
    240  1.3       mw #define DEF_DISP_Z		1	/* only 1, the curses plane is
    241  1.3       mw 					   treated as overlay plane */
    242  1.3       mw 
    243  1.3       mw /*
    244  1.3       mw  * these macros are used for separating hi and lo word of addresses.
    245  1.3       mw  * the copper list needs them separated - the hardware regs are
    246  1.3       mw  * words :-)
    247  1.3       mw  */
    248  1.3       mw #define HIADDR(x) (u_short)((((unsigned long)(x))>>16)&0xffff)
    249  1.3       mw #define LOADDR(x) (u_short)(((unsigned long)(x))&0xffff)
    250  1.3       mw 
    251  1.3       mw /* copper instructions */
    252  1.3       mw #define COP_MOVE(cl, reg, val)  \
    253  1.3       mw 	do { (cl)[0] = CUSTOM_OFS(reg); (cl)[1] = val; } while (0)
    254  1.3       mw #define COP_WAIT(cl, ypos)	\
    255  1.3       mw 	do { (cl)[0] = ((ypos) << 8) + 1; (cl)[1] = 0xff00; } while (0)
    256  1.3       mw #define COP_END(cl)		\
    257  1.3       mw 	do { (cl)[0] = 0xffff; (cl)[1] = 0xfffe; } while (0)
    258  1.3       mw 
    259