Rev 868 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 868 | Rev 876 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | //ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib |
1 | //ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib |
Line 2... | Line 2... | ||
2 | 2 | ||
- | 3 | #include "common.h" |
|
3 | #include "common.h" |
4 | |
4 | #include "ati2d.h" |
5 | #include "ati2d.h" |
Line 5... | Line 6... | ||
5 | #include "accel_2d.h" |
6 | #include "accel_2d.h" |
Line 6... | Line -... | ||
6 | - | ||
7 | RHD_t rhd; |
- | |
8 | 7 | ||
Line -... | Line 8... | ||
- | 8 | RHD_t rhd; |
|
- | 9 | ||
Line -... | Line 10... | ||
- | 10 | static clip_t clip; |
|
9 | pixmap_t scr_pixmap; |
11 | |
10 | 12 | static local_pixmap_t scr_pixmap; |
|
11 | static clip_t clip; |
13 | |
12 | 14 | ||
Line 13... | Line 15... | ||
13 | 15 | /* |
|
14 | void STDCALL (*SelectHwCursor)(cursor_t*)__asm__("SelectHwCursor"); |
16 | void STDCALL (*SelectHwCursor)(cursor_t*)__asm__("SelectHwCursor"); |
15 | void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor"); |
17 | void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor"); |
16 | void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore"); |
18 | void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore"); |
17 | cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx |
19 | cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx |
- | 20 | ||
Line 18... | Line 21... | ||
18 | 21 | void (__stdcall *old_select)(cursor_t*); |
|
Line 19... | Line 22... | ||
19 | void (__stdcall *old_select)(cursor_t*); |
22 | void (__stdcall *old_set)(cursor_t*,int x,int y); |
20 | void (__stdcall *old_set)(cursor_t*,int x,int y); |
23 | void (__stdcall *old_restore)(int x, int y); |
Line 84... | Line 87... | ||
84 | return retval; |
87 | return retval; |
85 | }; |
88 | }; |
86 | 89 | ||
Line 87... | Line -... | ||
87 | - | ||
88 | #pragma pack (push,1) |
- | |
89 | - | ||
90 | #pragma pack (pop) |
- | |
91 | 90 | ||
Line 92... | Line 91... | ||
92 | #define API_VERSION 0x01000100 |
91 | #define API_VERSION 0x01000100 |
Line -... | Line 92... | ||
- | 92 | ||
93 | 93 | #define SRV_GETVERSION 0 |
|
94 | #define SRV_GETVERSION 0 |
94 | |
95 | 95 | /* |
|
96 | int _stdcall srv_cursor(ioctl_t *io) |
96 | int _stdcall srv_cursor(ioctl_t *io) |
Line 115... | Line 115... | ||
115 | return ERR_PARAM; |
115 | return ERR_PARAM; |
116 | }; |
116 | }; |
117 | return ERR_PARAM; |
117 | return ERR_PARAM; |
118 | } |
118 | } |
119 | 119 | */ |
|
120 | 120 | ||
Line 121... | Line 121... | ||
121 | int _stdcall srv_2d(ioctl_t *io) |
121 | int _stdcall srv_2d(ioctl_t *io) |
122 | { |
122 | { |
123 | u32 *inp; |
123 | u32 *inp; |
124 | u32 *outp; |
124 | u32 *outp; |
Line 144... | Line 144... | ||
144 | case FILL_RECT: |
144 | case FILL_RECT: |
145 | if(io->inp_size==9) |
145 | if(io->inp_size==9) |
146 | return FillRect((fill_t*)inp); |
146 | return FillRect((fill_t*)inp); |
147 | break; |
147 | break; |
148 | 148 | /* |
|
149 | case LINE_2P: |
149 | case LINE_2P: |
150 | if(io->inp_size==5) |
150 | if(io->inp_size==6) |
151 | return Line2P((line2p_t*)inp); |
151 | return Line2P((draw_t*)inp); |
152 | break; |
152 | break; |
Line 153... | Line 153... | ||
153 | 153 | ||
154 | case BLIT: |
154 | case BLIT: |
155 | if(io->inp_size==6) |
155 | if(io->inp_size==6) |
Line 159... | Line 159... | ||
159 | case COMPIZ: |
159 | case COMPIZ: |
160 | if(io->inp_size==6) |
160 | if(io->inp_size==6) |
161 | return RadeonComposite((blit_t*)inp); |
161 | return RadeonComposite((blit_t*)inp); |
162 | break; |
162 | break; |
163 | 163 | */ |
|
164 | case PIXMAP: |
164 | case PX_CREATE: |
165 | if(io->inp_size==6) |
165 | if(io->inp_size==7) |
166 | return CreatePixmap((userpixmap_t*)inp); |
166 | return CreatePixmap((pixmap_t*)inp); |
167 | break; |
167 | break; |
Line 168... | Line 168... | ||
168 | 168 | ||
169 | case PIXBLIT: |
169 | case PIXBLIT: |
170 | if(io->inp_size==8) |
170 | if(io->inp_size==8) |
171 | return PixBlit((pixblit_t*)inp); |
171 | return PixBlit((pixblit_t*)inp); |
Line 172... | Line 172... | ||
172 | break; |
172 | break; |
173 | 173 | ||
174 | case PIXLOCK: |
174 | // case PIXLOCK: |
175 | if(io->inp_size==6) |
175 | // if(io->inp_size==6) |
176 | return LockPixmap((userpixmap_t*)inp); |
176 | // return LockPixmap((userpixmap_t*)inp); |
177 | break; |
177 | // break; |
178 | 178 | ||
179 | case PIXUNLOCK: |
179 | // case PIXUNLOCK: |
180 | if(io->inp_size==6) |
180 | // if(io->inp_size==6) |
Line 181... | Line 181... | ||
181 | return UnlockPixmap((userpixmap_t*)inp); |
181 | // return UnlockPixmap((userpixmap_t*)inp); |
182 | break; |
182 | // break; |
183 | 183 | ||
184 | case PIXDESTROY: |
184 | case PIXDESTROY: |
Line 185... | Line 185... | ||
185 | if(io->inp_size==6) |
185 | if(io->inp_size==6) |
186 | return DestroyPixmap((userpixmap_t*)inp); |
186 | return DestroyPixmap((pixmap_t*)inp); |
187 | break; |
187 | break; |
Line 204... | Line 204... | ||
204 | #include "ati_mem.c" |
204 | #include "ati_mem.c" |
205 | //#include "cursor.inc" |
205 | //#include "cursor.inc" |
206 | 206 | ||
Line 207... | Line 207... | ||
207 | #include "r500.inc" |
207 | #include "r500.inc" |
- | 208 | ||
- | 209 | #include "clip.inc" |
|
208 | #include "accel_2d.inc" |
210 | #include "accel_2d.inc" |
209 | #include "accel_3d.inc" |
211 | #include "accel_3d.inc" |
Line 210... | Line -... | ||
210 | - | ||
211 | #define CLIP_TOP 1 |
- | |
212 | #define CLIP_BOTTOM 2 |
- | |
213 | #define CLIP_RIGHT 4 |
- | |
214 | #define CLIP_LEFT 8 |
- | |
215 | - | ||
216 | - | ||
217 | char _L1OutCode( int x, int y ) |
- | |
218 | /*================================= |
- | |
219 | - | ||
220 | Verify that a point is inside or outside the active viewport. */ |
- | |
221 | { |
- | |
222 | char flag; |
- | |
223 | - | ||
224 | flag = 0; |
- | |
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 | static void line_inter( int * x1, int* y1, int x2, int y2, int x ) |
- | |
240 | /*=========================================================================== |
- | |
241 | - | ||
242 | Find the intersection of a line with a boundary of the viewport. |
- | |
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 | denom = abs( x2 - *x1 ); |
- | |
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 | int LineClip( int *x1, int *y1, int *x2, int *y2 ) |
- | |
263 | /*============================================================= |
- | |
264 | - | ||
265 | Clips the line with end points (x1,y1) and (x2,y2) to the active |
- | |
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 | flag1 = _L1OutCode( *x1, *y1 ); |
- | |
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 | static void block_inter( int *x, int *y, int flag ) |
- | |
306 | /*====================================================== |
- | |
307 | - | ||
308 | Find the intersection of a block with a boundary of the viewport. */ |
- | |
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 | int BlockClip( int *x1, int *y1, int *x2, int* y2 ) |
- | |
323 | /*============================================================== |
- | |
324 | - | ||
325 | Clip a block with opposite corners (x1,y1) and (x2,y2) to the |
- | |
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 | flag1 = _L1OutCode( *x1, *y1 ); |
- | |
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 | #if 0 |
- | |
350 | typedef struct |
- | |
351 | { |
- | |
352 | int left; |
- | |
353 | int top; |
- | |
354 | int right; |
- | |
355 | int bottom; |
- | |
356 | }rect_t; |
- | |
357 | - | ||
358 | typedef struct _window |
- | |
359 | { |
- | |
360 | struct _window *fd; |
- | |
361 | struct _window *bk; |
- | |
362 | - | ||
363 | rect_t pos; |
- | |
364 | int width; |
- | |
365 | int height; |
- | |
366 | - | ||
367 | int level; |
- | |
368 | }win_t, *WINPTR; |
- | |
369 | - | ||
370 | - | ||
371 | WINPTR top = NULL; |
- | |
372 | WINPTR bottom = NULL; |
- | |
373 | - | ||
374 | WINPTR alloc_window() |
- | |
375 | { |
- | |
376 | WINPTR pwin = malloc(sizeof(win_t)); |
- | |
377 | - | ||
378 | return pwin; |
- | |
379 | }; |
- | |
380 | - | ||
381 | - | ||
382 | WINPTR create_win(int l, int t, int w, int h, int level) |
- | |
383 | { |
- | |
384 | WINPTR pwin = alloc_window(); |
- | |
385 | - | ||
386 | pwin->pos.left = l; |
- | |
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 | pwin->level = level; |
- | |
394 | - | ||
395 | return pwin; |
- | |
396 | }; |
- | |
397 | - | ||
398 | void insert_window(WINPTR pwin) |
- | |
399 | { |
- | |
400 | WINPTR p = top; |
- | |
401 | - | ||
402 | if(p) |
- | |
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; |
- | |
Line 416... | Line -... | ||
416 | } |
- |