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