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