Subversion Repositories Kolibri OS

Rev

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