Rev 818 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
808 | serge | 1 | |
2 | |||
3 | |||
4 | #include "ati2d.h" |
||
5 | #include "accel_2d.h" |
||
6 | |||
7 | |||
8 | |||
9 | |||
815 | serge | 10 | |
11 | |||
808 | serge | 12 | |
13 | |||
815 | serge | 14 | |
808 | serge | 15 | void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor"); |
16 | void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore"); |
||
17 | cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx |
||
18 | |||
19 | |||
20 | void (__stdcall *old_set)(cursor_t*,int x,int y); |
||
21 | void (__stdcall *old_restore)(int x, int y); |
||
22 | cursor_t* (*old_create)(void); |
||
23 | cursor_t* __create_cursor(void); |
||
24 | |||
25 | |||
811 | serge | 26 | |
808 | serge | 27 | |
28 | { |
||
29 | RHDPtr rhdPtr; |
||
30 | u32 retval; |
||
31 | |||
32 | |||
33 | |||
34 | |||
35 | return 0; |
||
36 | |||
37 | |||
38 | { |
||
39 | printf("Can't open /rd/1/drivers/ati2d.log\nExit\n"); |
||
40 | return 0; |
||
41 | } |
||
42 | |||
43 | |||
44 | { |
||
45 | dbgprintf("Device not found\n"); |
||
46 | return 0; |
||
47 | }; |
||
48 | |||
49 | |||
50 | { |
||
51 | if(rhd.memBase[i]) |
||
52 | dbgprintf("Memory base_%d 0x%x size 0x%x\n", |
||
53 | i,rhd.memBase[i],(1< |
||
54 | }; |
||
55 | for(i=0;i<6;i++) |
||
56 | { |
||
57 | if(rhd.ioBase[i]) |
||
58 | dbgprintf("Io base_%d 0x%x size 0x%x\n", |
||
59 | i,rhd.ioBase[i],(1< |
||
60 | }; |
||
61 | if(!RHDPreInit()) |
||
62 | return 0; |
||
63 | |||
64 | |||
65 | // old_set = SetHwCursor; |
||
66 | // old_restore = HwCursorRestore ; |
||
67 | // old_create = HwCursorCreate; |
||
68 | |||
69 | |||
70 | rhd.has_tcl = 1; |
||
813 | serge | 71 | Init3DEngine(&rhd); |
72 | |||
808 | serge | 73 | |
74 | |||
75 | |||
76 | // SetHwCursor = r500_SetCursor; |
||
77 | // HwCursorCreate = __create_cursor; |
||
78 | // HwCursorRestore = r500_CursorRestore; |
||
79 | |||
80 | |||
81 | dbgprintf("reg service %s as: %x\n", "HDRAW", retval); |
||
82 | |||
83 | |||
84 | return retval; |
||
85 | }; |
||
86 | |||
87 | |||
88 | |||
89 | |||
90 | |||
91 | |||
92 | |||
93 | |||
94 | |||
95 | |||
96 | |||
97 | { |
||
98 | u32 *inp; |
||
99 | u32 *outp; |
||
100 | |||
101 | |||
102 | outp = io->output; |
||
103 | |||
104 | |||
105 | { |
||
106 | case SRV_GETVERSION: |
||
107 | if(io->out_size==4) |
||
108 | { |
||
109 | *(u32*)io->output = API_VERSION; |
||
110 | return 0; |
||
111 | } |
||
112 | break; |
||
113 | |||
114 | |||
115 | return ERR_PARAM; |
||
116 | }; |
||
117 | return ERR_PARAM; |
||
118 | } |
||
119 | |||
120 | |||
121 | |||
122 | { |
||
123 | u32 *inp; |
||
124 | u32 *outp; |
||
125 | |||
126 | |||
127 | outp = io->output; |
||
128 | |||
129 | |||
130 | { |
||
131 | case SRV_GETVERSION: |
||
132 | if(io->out_size==4) |
||
133 | { |
||
134 | *outp = API_VERSION; |
||
135 | return 0; |
||
136 | } |
||
137 | break; |
||
138 | |||
139 | |||
140 | if(io->inp_size==6) |
||
817 | serge | 141 | return DrawRect((draw_t*)inp); |
808 | serge | 142 | break; |
143 | |||
144 | |||
810 | serge | 145 | if(io->inp_size==9) |
817 | serge | 146 | return FillRect((fill_t*)inp); |
810 | serge | 147 | break; |
148 | |||
149 | |||
808 | serge | 150 | if(io->inp_size==5) |
151 | return Line2P((line2p_t*)inp); |
||
152 | break; |
||
153 | |||
154 | |||
810 | serge | 155 | if(io->inp_size==6) |
156 | return Blit((blit_t*)inp); |
||
157 | break; |
||
808 | serge | 158 | |
159 | |||
813 | serge | 160 | if(io->inp_size==6) |
161 | return RadeonComposite((blit_t*)inp); |
||
162 | break; |
||
163 | |||
164 | |||
815 | serge | 165 | if(io->inp_size==6) |
817 | serge | 166 | return CreatePixmap((userpixmap_t*)inp); |
167 | break; |
||
815 | serge | 168 | |
813 | serge | 169 | |
815 | serge | 170 | if(io->inp_size==8) |
171 | return PixBlit((pixblit_t*)inp); |
||
172 | break; |
||
173 | |||
174 | |||
817 | serge | 175 | if(io->inp_size==6) |
176 | return LockPixmap((userpixmap_t*)inp); |
||
177 | break; |
||
178 | |||
179 | |||
818 | serge | 180 | if(io->inp_size==6) |
181 | return UnlockPixmap((userpixmap_t*)inp); |
||
182 | break; |
||
183 | |||
184 | |||
829 | serge | 185 | if(io->inp_size==6) |
186 | return DestroyPixmap((userpixmap_t*)inp); |
||
187 | break; |
||
188 | |||
189 | |||
190 | if(io->inp_size==8) |
||
191 | return TransBlit((pixblit_t*)inp); |
||
192 | break; |
||
193 | |||
194 | |||
195 | |||
808 | serge | 196 | return ERR_PARAM; |
197 | }; |
||
198 | return ERR_PARAM; |
||
199 | } |
||
200 | |||
201 | |||
202 | |||
203 | #include "pci.c" |
||
204 | #include "ati_mem.c" |
||
205 | //#include "cursor.inc" |
||
817 | serge | 206 | |
808 | serge | 207 | |
208 | #include "accel_2d.inc" |
||
209 | #include "accel_3d.inc" |
||
811 | serge | 210 | |
808 | serge | 211 | |
212 | #define CLIP_BOTTOM 2 |
||
213 | #define CLIP_RIGHT 4 |
||
214 | #define CLIP_LEFT 8 |
||
215 | |||
216 | |||
217 | |||
218 | /*================================= |
||
219 | |||
220 | |||
221 | { |
||
222 | char flag; |
||
223 | |||
224 | |||
225 | if( x < clip.xmin ) { |
||
226 | flag |= CLIP_LEFT; |
||
227 | } else if( x > clip.xmax ) { |
||
228 | flag |= CLIP_RIGHT; |
||
229 | } |
||
230 | if( y < clip.ymin ) { |
||
231 | flag |= CLIP_TOP; |
||
232 | } else if( y > clip.ymax ) { |
||
233 | flag |= CLIP_BOTTOM; |
||
234 | } |
||
235 | return( flag ); |
||
236 | } |
||
237 | |||
238 | |||
239 | |||
240 | /*=========================================================================== |
||
241 | |||
242 | |||
243 | (x1, y1) is outside and ( x2, y2 ) is inside the viewport. |
||
244 | NOTE : the signs of denom and ( x - *x1 ) cancel out during division |
||
245 | so make both of them positive before rounding. */ |
||
246 | { |
||
247 | int numer; |
||
248 | int denom; |
||
249 | |||
250 | |||
251 | numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 ); |
||
252 | if( numer > 0 ) { |
||
253 | numer += denom; /* round to closest pixel */ |
||
254 | } else { |
||
255 | numer -= denom; |
||
256 | } |
||
257 | *y1 += numer / ( denom << 1 ); |
||
258 | *x1 = x; |
||
259 | } |
||
260 | |||
261 | |||
262 | |||
263 | /*============================================================= |
||
264 | |||
265 | |||
266 | viewport using the Cohen-Sutherland clipping algorithm. Return the |
||
267 | clipped coordinates and a decision drawing flag. */ |
||
268 | { |
||
269 | char flag1; |
||
270 | char flag2; |
||
271 | |||
272 | |||
273 | flag2 = _L1OutCode( *x2, *y2 ); |
||
274 | for( ;; ) { |
||
275 | if( flag1 & flag2 ) break; /* trivially outside */ |
||
276 | if( flag1 == flag2 ) break; /* completely inside */ |
||
277 | if( flag1 == 0 ) { /* first point inside */ |
||
278 | if( flag2 & CLIP_TOP ) { |
||
279 | line_inter( y2, x2, *y1, *x1, clip.ymin ); |
||
280 | } else if( flag2 & CLIP_BOTTOM ) { |
||
281 | line_inter( y2, x2, *y1, *x1, clip.ymax ); |
||
282 | } else if( flag2 & CLIP_RIGHT ) { |
||
283 | line_inter( x2, y2, *x1, *y1, clip.xmax ); |
||
284 | } else if( flag2 & CLIP_LEFT ) { |
||
285 | line_inter( x2, y2, *x1, *y1, clip.xmin ); |
||
286 | } |
||
287 | flag2 = _L1OutCode( *x2, *y2 ); |
||
288 | } else { /* second point inside */ |
||
289 | if( flag1 & CLIP_TOP ) { |
||
290 | line_inter( y1, x1, *y2, *x2, clip.ymin ); |
||
291 | } else if( flag1 & CLIP_BOTTOM ) { |
||
292 | line_inter( y1, x1, *y2, *x2, clip.ymax ); |
||
293 | } else if( flag1 & CLIP_RIGHT ) { |
||
294 | line_inter( x1, y1, *x2, *y2, clip.xmax ); |
||
295 | } else if( flag1 & CLIP_LEFT ) { |
||
296 | line_inter( x1, y1, *x2, *y2, clip.xmin ); |
||
297 | } |
||
298 | flag1 = _L1OutCode( *x1, *y1 ); |
||
299 | } |
||
300 | } |
||
301 | return( flag1 & flag2 ); |
||
302 | } |
||
303 | |||
304 | |||
305 | |||
306 | /*====================================================== |
||
307 | |||
308 | |||
309 | { |
||
310 | if( flag & CLIP_TOP ) { |
||
311 | *y = clip.ymin; |
||
312 | } else if( flag & CLIP_BOTTOM ) { |
||
313 | *y = clip.ymax; |
||
314 | } else if( flag & CLIP_RIGHT ) { |
||
315 | *x = clip.xmax; |
||
316 | } else if( flag & CLIP_LEFT ) { |
||
317 | *x = clip.xmin; |
||
318 | } |
||
319 | } |
||
320 | |||
321 | |||
322 | |||
323 | /*============================================================== |
||
324 | |||
325 | |||
326 | active viewport based on the Cohen-Sutherland algorithm for line |
||
327 | clipping. Return the clipped coordinates and a decision drawing |
||
328 | flag ( 0 draw : 1 don't draw ). */ |
||
329 | { |
||
330 | char flag1; |
||
331 | char flag2; |
||
332 | |||
333 | |||
334 | flag2 = _L1OutCode( *x2, *y2 ); |
||
335 | for( ;; ) { |
||
336 | if( flag1 & flag2 ) break; /* trivially outside */ |
||
337 | if( flag1 == flag2 ) break; /* completely inside */ |
||
338 | if( flag1 == 0 ) { |
||
339 | block_inter( x2, y2, flag2 ); |
||
340 | flag2 = _L1OutCode( *x2, *y2 ); |
||
341 | } else { |
||
342 | block_inter( x1, y1, flag1 ); |
||
343 | flag1 = _L1OutCode( *x1, *y1 ); |
||
344 | } |
||
345 | } |
||
346 | return( flag1 & flag2 ); |
||
347 | } |
||
348 | |||
349 | |||
350 | typedef struct |
||
351 | { |
||
352 | int left; |
||
353 | int top; |
||
354 | int right; |
||
355 | int bottom; |
||
356 | }rect_t; |
||
357 | |||
358 | |||
359 | { |
||
360 | struct _window *fd; |
||
361 | struct _window *bk; |
||
362 | |||
363 | |||
364 | int width; |
||
365 | int height; |
||
366 | |||
367 | |||
368 | }win_t, *WINPTR; |
||
369 | |||
370 | |||
371 | |||
372 | WINPTR bottom = NULL; |
||
373 | |||
374 | |||
375 | { |
||
376 | WINPTR pwin = malloc(sizeof(win_t)); |
||
377 | |||
378 | |||
379 | }; |
||
380 | |||
381 | |||
382 | |||
383 | { |
||
384 | WINPTR pwin = alloc_window(); |
||
385 | |||
386 | |||
387 | pwin->pos.top = t; |
||
388 | pwin->pos.right = l+w-1; |
||
389 | pwin->pos.bottom = t+h-1; |
||
390 | pwin->width = w; |
||
391 | pwin->height = h; |
||
392 | |||
393 | |||
394 | |||
395 | |||
396 | }; |
||
397 | |||
398 | |||
399 | { |
||
400 | WINPTR p = top; |
||
401 | |||
402 | |||
403 | { |
||
404 | if(pwin->level <= p->level) |
||
405 | { |
||
406 | pwin->fd = p; |
||
407 | pwin->bk = p->bk; |
||
408 | pwin->bk->fd = pwin; |
||
409 | p->bk = pwin; |
||
410 | } |
||
411 | else |
||
412 | p = p->fd; |
||
413 | } |
||
414 | else |
||
415 | top = pwin; |
||
416 | } |
||
417 | |||
418 | |||
419 | > |