Subversion Repositories shark

Rev

Rev 682 | Rev 743 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
485 giacomo 1
#include <ll/i386/hw-data.h>
2
#include <ll/i386/mem.h>
3
#include <linux/fb.h>
4
 
5
static unsigned char font_table[127][8] =
6
      {
7
        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
8
        {0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e},
9
        {0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e},
10
        {0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00},
11
        {0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00},
12
        {0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c},
13
        {0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c},
14
        {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00},
15
        {0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff},
16
        {0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00},
17
        {0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff},
18
        {0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78},
19
        {0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18},
20
        {0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0},
21
        {0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0},
22
        {0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99},
23
        {0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00},
24
        {0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00},
25
        {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18},
26
        {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00},
27
        {0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00},
28
        {0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78},
29
        {0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00},
30
        {0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff},
31
        {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00},
32
        {0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00},
33
        {0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00},
34
        {0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00},
35
        {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00},
36
        {0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00},
37
        {0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00},
38
        {0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00},
39
        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
40
        {0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00},
41
        {0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00},
42
        {0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00},
43
        {0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00},
44
        {0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00},
45
        {0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00},
46
        {0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00},
47
        {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00},
48
        {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00},
49
        {0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00},
50
        {0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00},
51
        {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60},
52
        {0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00},
53
        {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00},
54
        {0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00},
55
        {0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00},
56
        {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00},
57
        {0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00},
58
        {0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00},
59
        {0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00},
60
        {0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00},
61
        {0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00},
62
        {0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00},
63
        {0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00},
64
        {0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00},
65
        {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00},
66
        {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60},
67
        {0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00},
68
        {0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00},
69
        {0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00},
70
        {0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00},
71
        {0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00},
72
        {0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00},
73
        {0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00},
74
        {0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00},
75
        {0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00},
76
        {0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00},
77
        {0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00},
78
        {0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00},
79
        {0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00},
80
        {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
81
        {0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00},
82
        {0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00},
83
        {0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00},
84
        {0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00},
85
        {0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00},
86
        {0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00},
87
        {0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00},
88
        {0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00},
89
        {0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00},
90
        {0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00},
91
        {0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
92
        {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00},
93
        {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},
94
        {0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00},
95
        {0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00},
96
        {0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00},
97
        {0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00},
98
        {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00},
99
        {0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00},
100
        {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00},
101
        {0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00},
102
        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff},
103
        {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},
104
        {0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00},
105
        {0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00},
106
        {0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00},
107
        {0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00},
108
        {0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},
109
        {0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00},
110
        {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},
111
        {0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00},
112
        {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},
113
        {0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78},
114
        {0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00},
115
        {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
116
        {0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00},
117
        {0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00},
118
        {0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00},
119
        {0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0},
120
        {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e},
121
        {0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00},
122
        {0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00},
123
        {0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00},
124
        {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00},
125
        {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},
126
        {0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00},
127
        {0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00},
128
        {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},
129
        {0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00},
130
        {0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00},
131
        {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},
132
        {0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00},
133
        {0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
134
      };
135
 
670 giacomo 136
#define rgb16(r, g, b) ((((WORD)(r & 0xF8)>>3) << 11) | (((WORD)(g & 0xFC)>>2) << 5) | ((WORD)(b & 0xF8)>>3))
137
 
138
int vga16color[16] = {  rgb16(0,0,0),
139
                        rgb16(0,0,168),
140
                        rgb16(0,168,0),
141
                        rgb16(0,168,168),
142
                        rgb16(168,0,0),
143
                        rgb16(168,0,168),
144
                        rgb16(168,168,0),
145
                        rgb16(208,208,208),
146
                        rgb16(168,168,168),
147
                        rgb16(0,0,252),
148
                        rgb16(0,252,0),
149
                        rgb16(0,252,252),
150
                        rgb16(252,0,0),
151
                        rgb16(252,0,252),
152
                        rgb16(252,252,0),
153
                        rgb16(252,252,252)};
154
 
485 giacomo 155
#define memsetw(addr, val, n) {LIN_ADDR i; for(i = addr; i < addr + n; i += 2) *(WORD *)i = val;}
156
 
157
struct fb_info *grx_info = NULL;
486 giacomo 158
extern struct fb_info *registered_fb[FB_MAX];
578 giacomo 159
void *video_memory;
485 giacomo 160
 
529 giacomo 161
void FB26_use_grx(int num)
485 giacomo 162
{
163
 
486 giacomo 164
  grx_info = registered_fb[num];
578 giacomo 165
  video_memory = (void *)(grx_info->screen_base);
485 giacomo 166
 
167
}
168
 
740 mauro 169
void grx_putimage(WORD x1, WORD y1, WORD x2, WORD y2, void *buf)
485 giacomo 170
{
171
 
488 giacomo 172
  WORD bpr;
173
  LIN_ADDR addr, p;
174
  WORD dx, y;
485 giacomo 175
 
176
  if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
177
 
488 giacomo 178
  bpr = grx_info->var.xres * 2;
179
  p = buf;
180
  addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1);
682 giacomo 181
  dx = (x2 - x1) * 2;
488 giacomo 182
 
682 giacomo 183
  for (y = y1; y < y2; y++) {
488 giacomo 184
    memcpy(addr, p, dx);
185
    p += dx;
186
    addr += bpr;
187
  }
485 giacomo 188
 
189
}
190
 
740 mauro 191
void grx_getimage(WORD x1, WORD y1, WORD x2, WORD y2, void *buf)
485 giacomo 192
{
193
    WORD bpr;
194
    LIN_ADDR addr, p;
195
    WORD dx, y;
196
 
197
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
198
 
199
    bpr = grx_info->var.xres * 2;
200
    p = buf;
201
    addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1);
682 giacomo 202
    dx = (x2 - x1) * 2;
485 giacomo 203
 
682 giacomo 204
    for (y = y1; y < y2; y++) {
485 giacomo 205
        memcpy(p, addr, dx);
206
        p += dx;
207
        addr += bpr;
208
    }
209
 
210
}
211
 
212
void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
213
{
214
 
215
  if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
216
 
488 giacomo 217
  WORD bpr;
218
  DWORD addr;
219
  WORD dx, y;
485 giacomo 220
 
488 giacomo 221
  bpr = grx_info->var.xres * 2;;
222
  addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1);
223
  dx = (x2 - x1 + 1) * 2;
224
 
225
  for (y = y1; y <= y2; y++) {
226
    memsetw((LIN_ADDR)addr, color, dx);
227
    addr += bpr;
228
  }
485 giacomo 229
 
230
}
231
 
531 giacomo 232
void grx_clear(DWORD color)
233
{
234
  if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
235
 
236
  DWORD addr;
237
  WORD dx, y;
238
 
239
  addr = (DWORD)(grx_info->screen_base);
240
  dx = grx_info->var.xres * 2;
241
 
242
  for (y = 0; y < grx_info->var.yres; y++) {
243
    memsetw((LIN_ADDR)addr, color, dx);
244
    addr += dx;
245
  }                                                                                                              
246
}
247
 
485 giacomo 248
void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
249
{
250
    WORD bpr;
251
    DWORD addr;
252
    WORD dx, y;
253
 
254
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
255
 
256
    bpr = grx_info->var.xres * 2;
257
    addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1);
258
    dx = (x2 - x1) * 2;
259
 
260
    memsetw((LIN_ADDR)addr, color, dx+2);
261
    addr += bpr;
262
 
263
    for (y = y1 + 1; y <= y2 - 1; y++) {
264
        *(WORD *)addr = color;
265
        *(WORD *)(addr + dx) = color;
266
        addr += bpr;
267
    }
268
    memsetw((LIN_ADDR)addr, color, dx+2);
269
}
270
 
271
void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg)
272
{
273
    DWORD fp, addr;
274
    WORD bpr;
275
    int r, c, bits;
276
 
277
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
278
 
279
    bpr = grx_info->var.xres * 2;
280
    addr = (DWORD)(grx_info->screen_base);
281
    while (*text) {
282
        fp = (DWORD)&(font_table[*(BYTE *)text][0]);
283
        for (r=0; r<8; r++) {
284
            bits = *(BYTE *)(fp++);
285
            for (c=0; c<8; c++)
286
                if (bits & (0x80>>c))
287
                    *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) =  fg;
288
                else
289
                    *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) = bg;
290
        }
291
        text++;
292
        x += 8;
293
    }
294
}
295
 
487 giacomo 296
void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
485 giacomo 297
{
298
    register int t, distance;
299
    register DWORD addr;
300
    register WORD bpr;
301
    int xerr=0, yerr=0, deltax, deltay;
302
    int incx, incy;
303
 
531 giacomo 304
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
305
 
485 giacomo 306
    bpr = grx_info->var.xres * 2;
307
    addr = (DWORD)(grx_info->screen_base);
308
    deltax = x2 - x1;                   /* compute both distances */
309
    deltay = y2 - y1;
310
 
311
    if (deltax > 0)                     /* compute increments */
312
        incx = 1;
313
    else if (deltax == 0)
314
        incx = 0;
315
    else
316
        incx = -1;
317
 
318
    if (deltay > 0)
319
        incy = 1;
320
    else if (deltay == 0)
321
        incy = 0;
322
    else
323
        incy = -1;
324
 
325
    deltax = abs(deltax);               /* determine greater distance */
326
    deltay = abs(deltay);
327
    if (deltax > deltay)
328
        distance = deltax;
329
    else
330
        distance = deltay;
331
 
332
    for (t=0; t<=distance+1; t++) {     /* draw the line */
333
        *(WORD *)(addr + y1 * bpr + (x1 * 2)) = color;
334
        xerr += deltax;
335
        yerr += deltay;
336
        if (xerr > distance) {
337
            xerr -= distance;
338
            x1 += incx;
339
        }
340
        if (yerr > distance) {
341
            yerr -= distance;
342
            y1 += incy;
343
        }
344
    }
345
}
346
 
347
void grx_plot(WORD x, WORD y, DWORD color)
348
{
349
    WORD bpr;
350
 
351
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
352
 
353
    bpr = grx_info->var.xres * 2;
354
    *(WORD *)(grx_info->screen_base + y * bpr + (x * 2)) = color;
355
}
356
 
357
DWORD grx_getpixel(WORD x, WORD y)
358
{
359
    WORD bpr;
360
    DWORD rv;
361
 
362
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return -1;
363
 
364
    bpr = grx_info->var.xres * 2;
365
    rv = *(WORD *)(grx_info->screen_base + y * bpr + (x * 2));
366
    return rv;
367
 
368
}
369
 
370
static void circlepixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c)
371
{
531 giacomo 372
 
373
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
374
 
485 giacomo 375
    grx_plot(sx + x, sy + y, c);
376
    grx_plot(sx - x, sy + y, c);
377
    grx_plot(sx + x, sy - y, c);
378
    grx_plot(sx - x, sy - y, c);
379
    grx_plot(sx + y, sy + x, c);
380
    grx_plot(sx - y, sy + x, c);
381
    grx_plot(sx + y, sy - x, c);
382
    grx_plot(sx - y, sy - x, c);
383
}
384
 
385
void grx_circle(WORD sx, WORD sy, WORD r, DWORD c)
386
{
387
    int x, y, d;
388
 
389
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
390
 
391
    if (r < 1) {
392
        grx_plot(sx, sy, c);
393
        return;
394
    }
395
 
396
    x = 0;
397
    y = r;
398
    d = 1 - r;
399
    circlepixels(x, y, sx, sy, c);
400
    while (x < y) {
401
        if (d < 0)
402
            d += x * 2 + 3;
403
        else {
404
            d += x * 2 - y * 2 + 5;
405
            y--;
406
        }
407
        x++;
408
        circlepixels(x, y, sx, sy, c);
409
    }
410
}
411
 
412
static __inline__ void discpixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c)
413
{
531 giacomo 414
 
415
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
416
 
485 giacomo 417
    grx_line(sx + x, sy + y, sx + x, sy - y, c);
418
    grx_line(sx - x, sy + y, sx - x, sy - y, c);
419
    grx_line(sx + y, sy + x, sx + y, sy - x , c);
420
    grx_line(sx - y, sy + x, sx - y, sy - x , c);
421
}
422
 
423
void grx_disc(WORD sx, WORD sy, WORD r, DWORD c)
424
{
425
    int x, y, d;
426
 
427
    if (!grx_info || grx_info->var.bits_per_pixel != 16) return;
428
 
429
    if (r < 1) {
430
        grx_plot(sx, sy, c);
431
        return;
432
    }
433
    x = 0;
434
    y = r;
435
    d = 1 - r;
436
    discpixels(x, y, sx, sy, c);
437
    while (x < y) {
438
        if (d < 0)
439
            d += x * 2 + 3;
440
        else {
441
            d += x * 2 - y * 2 + 5;
442
            y--;
443
        }
444
        x++;   
445
        discpixels(x, y, sx, sy, c);
446
    }
447
}
448