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