Subversion Repositories Kolibri OS

Rev

Rev 813 | 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
 
99
{
100
  u32 *inp;
101
  u32 *outp;
102
103
 
104
  outp = io->output;
105
106
 
107
  {
108
    case SRV_GETVERSION:
109
      if(io->out_size==4)
110
      {
111
        *(u32*)io->output = API_VERSION;
112
        return 0;
113
      }
114
      break;
115
116
 
117
      return ERR_PARAM;
118
  };
119
  return ERR_PARAM;
120
}
121
122
 
123
 
124
{
125
  u32 *inp;
126
  u32 *outp;
127
128
 
129
  outp = io->output;
130
131
 
132
  {
133
    case SRV_GETVERSION:
134
      if(io->out_size==4)
135
      {
136
        *outp = API_VERSION;
137
        return 0;
138
      }
139
      break;
140
141
 
142
        if(io->inp_size==5)
143
          return DrawRect((draw_t*)inp);
144
        break;
145
146
 
810 serge 147
        if(io->inp_size==8)
148
          return FillRect((fill_t*)inp);
149
        break;
150
151
 
808 serge 152
        if(io->inp_size==5)
153
          return Line2P((line2p_t*)inp);
154
        break;
155
156
 
810 serge 157
        if(io->inp_size==6)
158
          return Blit((blit_t*)inp);
159
        break;
808 serge 160
161
 
813 serge 162
        if(io->inp_size==6)
163
          return RadeonComposite((blit_t*)inp);
164
        break;
165
166
 
815 serge 167
        if(io->inp_size==5)
168
          return CreatePixmap((new_pixmap_t*)inp);
169
        break;
170
813 serge 171
 
815 serge 172
        if(io->inp_size==8)
173
          return PixBlit((pixblit_t*)inp);
174
        break;
175
176
 
808 serge 177
      return ERR_PARAM;
178
  };
179
  return ERR_PARAM;
180
}
181
182
 
183
 
184
#include "pci.c"
185
#include "ati_mem.c"
186
#include "cursor.inc"
187
188
 
189
#include "accel_2d.inc"
190
#include "accel_3d.inc"
811 serge 191
808 serge 192
 
193
#define CLIP_BOTTOM     2
194
#define CLIP_RIGHT      4
195
#define CLIP_LEFT       8
196
197
 
198
 
199
/*=================================
200
201
 
202
{
203
    char            flag;
204
205
 
206
    if( x < clip.xmin ) {
207
        flag |= CLIP_LEFT;
208
    } else if( x > clip.xmax ) {
209
        flag |= CLIP_RIGHT;
210
    }
211
    if( y < clip.ymin ) {
212
        flag |= CLIP_TOP;
213
    } else if( y > clip.ymax ) {
214
        flag |= CLIP_BOTTOM;
215
    }
216
    return( flag );
217
}
218
219
 
220
 
221
/*===========================================================================
222
223
 
224
    (x1, y1) is outside and ( x2, y2 ) is inside the viewport.
225
    NOTE : the signs of denom and ( x - *x1 ) cancel out during division
226
           so make both of them positive before rounding.   */
227
{
228
    int            numer;
229
    int            denom;
230
231
 
232
    numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 );
233
    if( numer > 0 ) {
234
        numer += denom;                     /* round to closest pixel   */
235
    } else {
236
        numer -= denom;
237
    }
238
    *y1 += numer / ( denom << 1 );
239
    *x1 = x;
240
}
241
242
 
243
 
244
/*=============================================================
245
246
 
247
    viewport using the Cohen-Sutherland clipping algorithm. Return the
248
    clipped coordinates and a decision drawing flag.    */
249
{
250
    char            flag1;
251
    char            flag2;
252
253
 
254
    flag2 = _L1OutCode( *x2, *y2 );
255
    for( ;; ) {
256
        if( flag1 & flag2 ) break;                  /* trivially outside    */
257
        if( flag1 == flag2 ) break;                 /* completely inside    */
258
        if( flag1 == 0 ) {                          /* first point inside   */
259
            if( flag2 & CLIP_TOP ) {
260
                line_inter( y2, x2, *y1, *x1, clip.ymin );
261
            } else if( flag2 & CLIP_BOTTOM ) {
262
                line_inter( y2, x2, *y1, *x1, clip.ymax );
263
            } else if( flag2 & CLIP_RIGHT ) {
264
                line_inter( x2, y2, *x1, *y1, clip.xmax );
265
            } else if( flag2 & CLIP_LEFT ) {
266
                line_inter( x2, y2, *x1, *y1, clip.xmin );
267
            }
268
            flag2 = _L1OutCode( *x2, *y2 );
269
        } else {                                    /* second point inside  */
270
            if( flag1 & CLIP_TOP ) {
271
                line_inter( y1, x1, *y2, *x2, clip.ymin );
272
            } else if( flag1 & CLIP_BOTTOM ) {
273
                line_inter( y1, x1, *y2, *x2, clip.ymax );
274
            } else if( flag1 & CLIP_RIGHT ) {
275
                line_inter( x1, y1, *x2, *y2, clip.xmax );
276
            } else if( flag1 & CLIP_LEFT ) {
277
                line_inter( x1, y1, *x2, *y2, clip.xmin );
278
            }
279
            flag1 = _L1OutCode( *x1, *y1 );
280
        }
281
    }
282
    return( flag1 & flag2 );
283
}
284
285
 
286
 
287
/*======================================================
288
289
 
290
{
291
    if( flag & CLIP_TOP ) {
292
        *y = clip.ymin;
293
    } else if( flag & CLIP_BOTTOM ) {
294
        *y = clip.ymax;
295
    } else if( flag & CLIP_RIGHT ) {
296
        *x = clip.xmax;
297
    } else if( flag & CLIP_LEFT ) {
298
        *x = clip.xmin;
299
    }
300
}
301
302
 
303
 
304
/*==============================================================
305
306
 
307
    active viewport based on the Cohen-Sutherland algorithm for line
308
    clipping. Return the clipped coordinates and a decision drawing
309
    flag ( 0 draw : 1 don't draw ). */
310
{
311
    char            flag1;
312
    char            flag2;
313
314
 
315
    flag2 = _L1OutCode( *x2, *y2 );
316
    for( ;; ) {
317
        if( flag1 & flag2 ) break;                  /* trivially outside    */
318
        if( flag1 == flag2 ) break;                 /* completely inside    */
319
        if( flag1 == 0 ) {
320
            block_inter( x2, y2, flag2 );
321
            flag2 = _L1OutCode( *x2, *y2 );
322
        } else {
323
            block_inter( x1, y1, flag1 );
324
            flag1 = _L1OutCode( *x1, *y1 );
325
        }
326
    }
327
    return( flag1 & flag2 );
328
}
329
330
 
331
typedef struct
332
{
333
   int left;
334
   int top;
335
   int right;
336
   int bottom;
337
}rect_t;
338
339
 
340
{
341
   struct _window *fd;
342
   struct _window *bk;
343
344
 
345
   int width;
346
   int height;
347
348
 
349
}win_t, *WINPTR;
350
351
 
352
 
353
WINPTR bottom = NULL;
354
355
 
356
{
357
    WINPTR pwin = malloc(sizeof(win_t));
358
359
 
360
};
361
362
 
363
 
364
{
365
   WINPTR pwin = alloc_window();
366
367
 
368
   pwin->pos.top    = t;
369
   pwin->pos.right  = l+w-1;
370
   pwin->pos.bottom = t+h-1;
371
   pwin->width      = w;
372
   pwin->height     = h;
373
374
 
375
376
 
377
};
378
379
 
380
{
381
   WINPTR p = top;
382
383
 
384
   {
385
     if(pwin->level <= p->level)
386
     {
387
        pwin->fd = p;
388
        pwin->bk = p->bk;
389
        pwin->bk->fd = pwin;
390
        p->bk = pwin;
391
     }
392
     else
393
       p = p->fd;
394
   }
395
   else
396
     top = pwin;
397
}
398
399
 
400
>