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