Go to most recent revision | Details | 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 | |||
141 | if(io->inp_size==5) |
||
142 | return Line2P((line2p_t*)inp); |
||
143 | break; |
||
144 | |||
145 | |||
146 | if(io->inp_size==8) |
||
147 | return FillRect((fill_t*)inp); |
||
148 | break; |
||
149 | |||
150 | |||
151 | return ERR_PARAM; |
||
152 | }; |
||
153 | return ERR_PARAM; |
||
154 | } |
||
155 | |||
156 | |||
157 | |||
158 | #include "pci.c" |
||
159 | #include "ati_mem.c" |
||
160 | #include "cursor.inc" |
||
161 | |||
162 | |||
163 | #include "accel_2d.inc" |
||
164 | |||
165 | |||
166 | #define CLIP_BOTTOM 2 |
||
167 | #define CLIP_RIGHT 4 |
||
168 | #define CLIP_LEFT 8 |
||
169 | |||
170 | |||
171 | |||
172 | /*================================= |
||
173 | |||
174 | |||
175 | { |
||
176 | char flag; |
||
177 | |||
178 | |||
179 | if( x < clip.xmin ) { |
||
180 | flag |= CLIP_LEFT; |
||
181 | } else if( x > clip.xmax ) { |
||
182 | flag |= CLIP_RIGHT; |
||
183 | } |
||
184 | if( y < clip.ymin ) { |
||
185 | flag |= CLIP_TOP; |
||
186 | } else if( y > clip.ymax ) { |
||
187 | flag |= CLIP_BOTTOM; |
||
188 | } |
||
189 | return( flag ); |
||
190 | } |
||
191 | |||
192 | |||
193 | |||
194 | /*=========================================================================== |
||
195 | |||
196 | |||
197 | (x1, y1) is outside and ( x2, y2 ) is inside the viewport. |
||
198 | NOTE : the signs of denom and ( x - *x1 ) cancel out during division |
||
199 | so make both of them positive before rounding. */ |
||
200 | { |
||
201 | int numer; |
||
202 | int denom; |
||
203 | |||
204 | |||
205 | numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 ); |
||
206 | if( numer > 0 ) { |
||
207 | numer += denom; /* round to closest pixel */ |
||
208 | } else { |
||
209 | numer -= denom; |
||
210 | } |
||
211 | *y1 += numer / ( denom << 1 ); |
||
212 | *x1 = x; |
||
213 | } |
||
214 | |||
215 | |||
216 | |||
217 | /*============================================================= |
||
218 | |||
219 | |||
220 | viewport using the Cohen-Sutherland clipping algorithm. Return the |
||
221 | clipped coordinates and a decision drawing flag. */ |
||
222 | { |
||
223 | char flag1; |
||
224 | char flag2; |
||
225 | |||
226 | |||
227 | flag2 = _L1OutCode( *x2, *y2 ); |
||
228 | for( ;; ) { |
||
229 | if( flag1 & flag2 ) break; /* trivially outside */ |
||
230 | if( flag1 == flag2 ) break; /* completely inside */ |
||
231 | if( flag1 == 0 ) { /* first point inside */ |
||
232 | if( flag2 & CLIP_TOP ) { |
||
233 | line_inter( y2, x2, *y1, *x1, clip.ymin ); |
||
234 | } else if( flag2 & CLIP_BOTTOM ) { |
||
235 | line_inter( y2, x2, *y1, *x1, clip.ymax ); |
||
236 | } else if( flag2 & CLIP_RIGHT ) { |
||
237 | line_inter( x2, y2, *x1, *y1, clip.xmax ); |
||
238 | } else if( flag2 & CLIP_LEFT ) { |
||
239 | line_inter( x2, y2, *x1, *y1, clip.xmin ); |
||
240 | } |
||
241 | flag2 = _L1OutCode( *x2, *y2 ); |
||
242 | } else { /* second point inside */ |
||
243 | if( flag1 & CLIP_TOP ) { |
||
244 | line_inter( y1, x1, *y2, *x2, clip.ymin ); |
||
245 | } else if( flag1 & CLIP_BOTTOM ) { |
||
246 | line_inter( y1, x1, *y2, *x2, clip.ymax ); |
||
247 | } else if( flag1 & CLIP_RIGHT ) { |
||
248 | line_inter( x1, y1, *x2, *y2, clip.xmax ); |
||
249 | } else if( flag1 & CLIP_LEFT ) { |
||
250 | line_inter( x1, y1, *x2, *y2, clip.xmin ); |
||
251 | } |
||
252 | flag1 = _L1OutCode( *x1, *y1 ); |
||
253 | } |
||
254 | } |
||
255 | return( flag1 & flag2 ); |
||
256 | } |
||
257 | |||
258 | |||
259 | |||
260 | /*====================================================== |
||
261 | |||
262 | |||
263 | { |
||
264 | if( flag & CLIP_TOP ) { |
||
265 | *y = clip.ymin; |
||
266 | } else if( flag & CLIP_BOTTOM ) { |
||
267 | *y = clip.ymax; |
||
268 | } else if( flag & CLIP_RIGHT ) { |
||
269 | *x = clip.xmax; |
||
270 | } else if( flag & CLIP_LEFT ) { |
||
271 | *x = clip.xmin; |
||
272 | } |
||
273 | } |
||
274 | |||
275 | |||
276 | |||
277 | /*============================================================== |
||
278 | |||
279 | |||
280 | active viewport based on the Cohen-Sutherland algorithm for line |
||
281 | clipping. Return the clipped coordinates and a decision drawing |
||
282 | flag ( 0 draw : 1 don't draw ). */ |
||
283 | { |
||
284 | char flag1; |
||
285 | char flag2; |
||
286 | |||
287 | |||
288 | flag2 = _L1OutCode( *x2, *y2 ); |
||
289 | for( ;; ) { |
||
290 | if( flag1 & flag2 ) break; /* trivially outside */ |
||
291 | if( flag1 == flag2 ) break; /* completely inside */ |
||
292 | if( flag1 == 0 ) { |
||
293 | block_inter( x2, y2, flag2 ); |
||
294 | flag2 = _L1OutCode( *x2, *y2 ); |
||
295 | } else { |
||
296 | block_inter( x1, y1, flag1 ); |
||
297 | flag1 = _L1OutCode( *x1, *y1 ); |
||
298 | } |
||
299 | } |
||
300 | return( flag1 & flag2 ); |
||
301 | } |
||
302 | |||
303 | |||
304 | typedef struct |
||
305 | { |
||
306 | int left; |
||
307 | int top; |
||
308 | int right; |
||
309 | int bottom; |
||
310 | }rect_t; |
||
311 | |||
312 | |||
313 | { |
||
314 | struct _window *fd; |
||
315 | struct _window *bk; |
||
316 | |||
317 | |||
318 | int width; |
||
319 | int height; |
||
320 | |||
321 | |||
322 | }win_t, *WINPTR; |
||
323 | |||
324 | |||
325 | |||
326 | WINPTR bottom = NULL; |
||
327 | |||
328 | |||
329 | { |
||
330 | WINPTR pwin = malloc(sizeof(win_t)); |
||
331 | |||
332 | |||
333 | }; |
||
334 | |||
335 | |||
336 | |||
337 | { |
||
338 | WINPTR pwin = alloc_window(); |
||
339 | |||
340 | |||
341 | pwin->pos.top = t; |
||
342 | pwin->pos.right = l+w-1; |
||
343 | pwin->pos.bottom = t+h-1; |
||
344 | pwin->width = w; |
||
345 | pwin->height = h; |
||
346 | |||
347 | |||
348 | |||
349 | |||
350 | }; |
||
351 | |||
352 | |||
353 | { |
||
354 | WINPTR p = top; |
||
355 | |||
356 | |||
357 | { |
||
358 | if(pwin->level <= p->level) |
||
359 | { |
||
360 | pwin->fd = p; |
||
361 | pwin->bk = p->bk; |
||
362 | pwin->bk->fd = pwin; |
||
363 | p->bk = pwin; |
||
364 | } |
||
365 | else |
||
366 | p = p->fd; |
||
367 | } |
||
368 | else |
||
369 | top = pwin; |
||
370 | } |
||
371 | |||
372 | |||
373 | > |