Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <ll/i386/hw-data.h>
20
#include <ll/i386/hw-instr.h>
21
#include <ll/i386/mem.h>
22
#include <ll/stdlib.h>
23
 
24
#include <drivers/gd.h>
25
 
151 giacomo 26
#include "font.h"
2 pj 27
#include "fun8.h"
28
 
29
#define fontaddr       0xffa6eL     /* indirizzo set caratteri         */
30
extern DWORD flbaddr;
31
 
32
void RdWin_256(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf)
33
{
34
    WORD b_bank, b_offset, display_ptr;
35
    int dx, len1, len2, bank_num, row, sx[12];
36
/*    int bank, enmem;*/
37
    DWORD end_of_line, display_offset;
38
    WORD bytes_per_row;
39
    LIN_ADDR p;
40
 
41
    bytes_per_row = gd_getbpr();
42
    p = buf;
43
 
44
    if (bytes_per_row == 1024) {
45
/*      ClrWin_1024(x1,y1,x2,y2,color);*/
46
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
47
        dx = (x2 - x1) + 1;
48
        display_offset = b_offset;
49
        bank_num = b_bank;
50
        Load_Write_Bank_256(bank_num);
51
        row = y1;
52
        do {
53
            display_ptr = display_offset;
54
/*          Clr_Part(color, dx, display_ptr);*/
55
            memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), dx);
56
            p += dx;
57
            display_offset += bytes_per_row;
58
            if (display_offset >= 65536L) {
59
                bank_num++;
60
                Load_Write_Bank_256(bank_num);
61
                display_offset = x1;
62
            }
63
            row++;
64
        } while (row <= y2);
65
        Load_Write_Bank_256(0);
66
    } else {
67
        if (bytes_per_row == 640) {
68
            sx[0] = 0;
69
            sx[1] = 256;
70
            sx[2] = 512;
71
            sx[3] = 128;
72
            sx[4] = 384;
73
            sx[5] = 0;
74
        }
75
        if (bytes_per_row == 800) {
76
            sx[0] = 0;
77
            sx[1] = 736;
78
            sx[2] = 672;
79
            sx[3] = 608;
80
            sx[4] = 544;
81
            sx[5] = 480;
82
            sx[6] = 416;
83
            sx[7] = 352;
84
        }
85
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
86
        dx = (x2 - x1) + 1;
87
        row = y1;
88
        display_offset = b_offset;
89
        display_ptr = display_offset;
90
        bank_num = b_bank;
91
        Load_Write_Bank_256(bank_num);
92
        do {
93
            end_of_line = display_ptr + (x2 - x1);
94
            if (end_of_line > 65536L) {
95
                len2 = (1 + end_of_line - 65536L);
96
                len1 = dx - len2;
97
/*              Clr_Part(color, length_1, display_ptr);*/
98
                memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), len1);
99
                p += len1;
100
                bank_num++;
101
                Load_Write_Bank_256(bank_num);
102
                display_ptr = 0;
103
/*              Clr_Part(color, length_2, display_ptr);*/
104
                memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), len2);
105
                p += len2;
106
                display_ptr = bytes_per_row - len1;
107
            } else {
108
/*              Clr_Part(color, dx, display_ptr);*/
109
                memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), dx);
110
                p += dx;
111
                display_offset = display_ptr + bytes_per_row;
112
                if (display_offset > 65536L) {
113
                    bank_num++;
114
                    Load_Write_Bank_256(bank_num);
115
                    if (sx[bank_num] <= x1) {
116
                        display_ptr = x1 - sx[bank_num];
117
                    } else {
118
                        display_ptr = x1 + (bytes_per_row - sx[bank_num]);
119
                    }
120
                } else {
121
                    display_ptr += bytes_per_row;
122
                }
123
            }
124
            row++;
125
        } while (row <= y2);
126
        Load_Write_Bank_256(0);
127
    }
128
}
129
 
130
void WrWin_256(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf)
131
{
132
    WORD b_bank, b_offset, display_ptr;
133
    int dx, len1, len2, bank_num, row, sx[12];
134
/*    int bank, enmem;*/
135
    DWORD end_of_line, display_offset;
136
    WORD bytes_per_row;
137
    LIN_ADDR p;
138
 
139
    bytes_per_row = gd_getbpr();
140
    p = buf;
141
 
142
    if (bytes_per_row == 1024) {
143
/*      ClrWin_1024(x1,y1,x2,y2,color);*/
144
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
145
        //dx = (x2 - x1);
146
        dx = (x2 - x1 + 1);
147
        display_offset = b_offset;
148
        bank_num = b_bank;
149
        Load_Write_Bank_256(bank_num);
150
        row = y1;
151
        do {
152
            display_ptr = display_offset;
153
/*          Clr_Part(color, dx, display_ptr);*/
154
            memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, dx);
155
            p += dx;
156
            display_offset += bytes_per_row;
157
            if (display_offset >= 65536L) {
158
                bank_num++;
159
                Load_Write_Bank_256(bank_num);
160
                display_offset = x1;
161
            }
162
            row++;
163
        } while (row <= y2);
164
        Load_Write_Bank_256(0);
165
    } else {
166
        if (bytes_per_row == 640) {
167
            sx[0] = 0;
168
            sx[1] = 256;
169
            sx[2] = 512;
170
            sx[3] = 128;
171
            sx[4] = 384;
172
            sx[5] = 0;
173
        }
174
        if (bytes_per_row == 800) {
175
            sx[0] = 0;
176
            sx[1] = 736;
177
            sx[2] = 672;
178
            sx[3] = 608;
179
            sx[4] = 544;
180
            sx[5] = 480;
181
            sx[6] = 416;
182
            sx[7] = 352;
183
        }
184
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
185
        dx = (x2 - x1 + 1);
186
        row = y1;
187
        display_offset = b_offset;
188
        display_ptr = display_offset;
189
        bank_num = b_bank;
190
        Load_Write_Bank_256(bank_num);
191
        do {
192
            end_of_line = display_ptr + (x2 - x1);
193
//          if (end_of_line >= 65536L) {
194
            if (end_of_line > 65536L) {
195
                len2 = (1 + end_of_line - 65536L);
196
                len1 = dx - len2;
197
/*              Clr_Part(color, length_1, display_ptr);*/
198
                memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, len1);
199
                p += len1;
200
                bank_num++;
201
                Load_Write_Bank_256(bank_num);
202
                display_ptr = 0;
203
/*              Clr_Part(color, length_2, display_ptr);*/
204
                memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, len2);
205
                p += len2;
206
                display_ptr = bytes_per_row - len1;
207
            } else {
208
/*              Clr_Part(color, dx, display_ptr);*/
209
                memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, dx);
210
                p += dx;
211
                display_offset = display_ptr + bytes_per_row;
212
                if (display_offset > 65536L) {
213
                //if (display_offset >= 65536L) {
214
                    bank_num++;
215
                    Load_Write_Bank_256(bank_num);
216
                    if (sx[bank_num] <= x1) {
217
                        display_ptr = x1 - sx[bank_num];
218
                    } else {
219
                        display_ptr = x1 + (bytes_per_row - sx[bank_num]);
220
                    }
221
                } else {
222
                    display_ptr += bytes_per_row;
223
                }
224
            }
225
            row++;
226
        } while (row <= y2);
227
        Load_Write_Bank_256(0);
228
    }
229
}
230
 
231
void linGet8(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf)
232
{
233
    WORD bpr;
234
    LIN_ADDR addr, p;
235
    WORD dx, y;
236
 
237
    bpr = gd_getbpr();
238
    p = buf;
239
    addr = (void *)(flbaddr + x1 + bpr * y1);
240
    //dx = x2 - x1;
241
    dx = x2 - x1 +1;
242
 
243
    for (y = y1; y <= y2; y++) {
244
        memcpy(p, addr, dx);
245
        p += dx;
246
        addr += bpr;
247
    }
248
}
249
 
250
void linPut8(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf)
251
{
252
    WORD bpr;
253
    LIN_ADDR addr, p;
254
    WORD dx, y;
255
 
256
    bpr = gd_getbpr();
257
    p = buf;
258
    addr = (void *)(flbaddr + x1 + bpr * y1);
259
    dx = x2 - x1 +1;
260
 
261
    for (y = y1; y <= y2; y++) {
262
        memcpy(addr, p, dx);
263
        p += dx;
264
        addr += bpr;
265
    }
266
}
267
 
268
void ClrWin_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
269
{
270
    WORD b_bank, b_offset, display_ptr;
271
    int dx, len1, len2, bank_num, row, sx[12];
272
/*    int bank, enmem;*/
273
    DWORD end_of_line, display_offset;
274
    WORD bytes_per_row;
275
 
276
    bytes_per_row = gd_getbpr();
277
 
278
    if (bytes_per_row == 1024) {
279
/*      ClrWin_1024(x1,y1,x2,y2,color);*/
280
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
281
        dx = (x2 - x1) + 1;
282
        display_offset = b_offset;
283
        bank_num = b_bank;
284
        Load_Write_Bank_256(bank_num);
285
        row = y1;
286
        do {
287
            display_ptr = display_offset;
288
/*          Clr_Part(color, dx, display_ptr);*/
289
            memset((LIN_ADDR)(0xA0000 + display_ptr), color, dx);
290
            display_offset += bytes_per_row;
291
            if (display_offset >= 65536L) {
292
                bank_num++;
293
                Load_Write_Bank_256(bank_num);
294
                display_offset = x1;
295
            }
296
            row++;
297
        } while (row <= y2);
298
        Load_Write_Bank_256(0);
299
    } else {
300
        if (bytes_per_row == 640) {
301
            sx[0] = 0;
302
            sx[1] = 256;
303
            sx[2] = 512;
304
            sx[3] = 128;
305
            sx[4] = 384;
306
            sx[5] = 0;
307
        }
308
        if (bytes_per_row == 800) {
309
            sx[0] = 0;
310
            sx[1] = 736;
311
            sx[2] = 672;
312
            sx[3] = 608;
313
            sx[4] = 544;
314
            sx[5] = 480;
315
            sx[6] = 416;
316
            sx[7] = 352;
317
        }
318
        Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank);
319
        dx = (x2 - x1) + 1;
320
        row = y1;
321
        display_offset = b_offset;
322
        display_ptr = display_offset;
323
        bank_num = b_bank;
324
        Load_Write_Bank_256(bank_num);
325
        do {
326
            end_of_line = display_ptr + (x2 - x1);
327
            if (end_of_line >= 65536L) {
328
                len2 = (1 + end_of_line - 65536L);
329
                len1 = dx - len2;
330
/*              Clr_Part(color, length_1, display_ptr);*/
331
                memset((LIN_ADDR)(0xA0000 + display_ptr), color, len1);
332
                bank_num++;
333
                Load_Write_Bank_256(bank_num);
334
                display_ptr = 0;
335
/*              Clr_Part(color, length_2, display_ptr);*/
336
                memset((LIN_ADDR)(0xA0000 + display_ptr), color, len2);
337
                display_ptr = bytes_per_row - len1;
338
            } else {
339
/*              Clr_Part(color, dx, display_ptr);*/
340
                memset((LIN_ADDR)(0xA0000 + display_ptr), color, dx);
341
                display_offset = display_ptr + bytes_per_row;
342
                if (display_offset >= 65536L) {
343
                    bank_num++;
344
                    Load_Write_Bank_256(bank_num);
345
                    if (sx[bank_num] <= x1) {
346
                        display_ptr = x1 - sx[bank_num];
347
                    } else {
348
                        display_ptr = x1 + (bytes_per_row - sx[bank_num]);
349
                    }
350
                } else {
351
                    display_ptr += bytes_per_row;
352
                }
353
            }
354
            row++;
355
        } while (row <= y2);
356
        Load_Write_Bank_256(0);
357
    }
358
}
359
 
360
void linBox8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
361
{
362
    WORD bpr;
363
    DWORD addr;
364
    WORD dx, y;
365
 
366
    bpr = gd_getbpr();
367
    addr = flbaddr + x1 + bpr * y1;
368
    dx = x2 - x1 + 1;
369
 
370
    for (y = y1; y <= y2; y++) {
371
        memset((LIN_ADDR)addr, color, dx);
372
        addr += bpr;
373
    }
374
}
375
 
376
void WrRect_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
377
{
378
    WORD bank, offs, ebank, eoffs;
379
    WORD bpr;
380
    WORD line_segment, len;
381
    WORD y;
382
 
383
    bpr = gd_getbpr();
384
    len = 1 + x2 - x1;
385
    Seg_Off_256(x2, y1, bpr, &eoffs, &ebank);
386
    Seg_Off_256(x1, y1, bpr, &offs, &bank);
387
    Load_Write_Bank_256(bank);
388
    if (bank == ebank) {
389
        memset((LIN_ADDR)(0xA0000 + offs), color, len);
390
    } else {
391
        line_segment = 65536L - offs;
392
        memset((LIN_ADDR)(0xA0000 + offs), color, line_segment);
393
        Load_Write_Bank_256(ebank);
394
        memset((LIN_ADDR)0xA0000, color, eoffs);
395
    }
396
    for (y = y1 + 1; y < y2 + 1; y++) {
397
        Seg_Off_256(x1, y, bpr, &offs, &bank);
398
        Load_Write_Bank_256(bank);
399
        lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
400
        Seg_Off_256(x2, y, bpr, &offs, &bank);
401
        Load_Write_Bank_256(bank);
402
        lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
403
    }
404
    Seg_Off_256(x2, y2, bpr, &eoffs, &ebank);
405
    Seg_Off_256(x1, y2, bpr, &offs, &bank);
406
    Load_Write_Bank_256(bank);
407
    if (bank == ebank) {
408
        memset((LIN_ADDR)(0xA0000 + offs), color, len);
409
    } else {
410
        line_segment = 65536L - offs;
411
        memset((LIN_ADDR)(0xA0000 + offs), color, line_segment);
412
        Load_Write_Bank_256(ebank);
413
        memset((LIN_ADDR)0xA0000, color, eoffs);
414
    }
415
}
416
 
417
void linRect8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
418
{
419
    WORD bpr;
420
    DWORD addr;
421
    WORD dx, y;
422
 
423
    bpr = gd_getbpr();
424
    addr = flbaddr + x1 + bpr * y1;
425
    dx = x2 - x1;
426
 
427
    memset((LIN_ADDR)addr, color, dx+1);
428
    addr += bpr;
429
 
430
    for (y = y1 + 1; y <= y2 - 1; y++) {
431
        lmempokeb((LIN_ADDR)addr, color);
432
        lmempokeb((LIN_ADDR)(addr + dx), color);
433
        addr += bpr;
434
    }
435
    memset((LIN_ADDR)addr, color, dx+1);
436
}
437
 
438
void WrText_256(char *text, WORD x, WORD y, DWORD fg, DWORD bg)
439
{
440
    DWORD fp;
441
    WORD offs, bank;
442
    WORD bpr;
443
    int r, c, bits;
444
 
445
    bpr = gd_getbpr();
446
    while (*text) {
151 giacomo 447
        fp = (DWORD)&(font_table[*(BYTE *)text][0]);
2 pj 448
        for (r=0; r<8; r++) {
449
            bits = lmempeekb((LIN_ADDR)(fp++));
450
            for (c=0; c<8; c++)
451
                if (bits & (0x80>>c)) {
452
                    Seg_Off_256(x + c, y + r, bpr, &offs, &bank);
453
                    Load_Write_Bank_256(bank);
454
                    lmempokeb((LIN_ADDR)(0xA0000 + offs), fg);
455
                }
456
/*                  lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), fg);*/
457
/*                  vbe_putpixel((x+c),(y+r),fg);*/
458
                else {
459
                    Seg_Off_256(x + c, y + r, bpr, &offs, &bank);
460
                    Load_Write_Bank_256(bank);
461
                    lmempokeb((LIN_ADDR)(0xA0000 + offs), bg);
462
                }
463
/*                  lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), bg);*/
464
/*                  vbe_putpixel((x+c), (y+r), bg);*/
465
        }
466
        text++;
467
        x += 8;
468
    }
469
}
470
 
471
void linText8(char *text, WORD x, WORD y, DWORD fg, DWORD bg)
472
{
473
    DWORD fp, addr;
474
    WORD bpr;
475
    int r, c, bits;
476
 
477
    bpr = gd_getbpr();
478
    addr = gd_getflb();
479
    while (*text) {
480
        /*DOSSetAddr(fp, (fontaddr + (8 * *(BYTE *)text)));*/
481
        /*DOSSetAddr(fp, (fontaddr + (8 * *(BYTE *)text)));*/
151 giacomo 482
        fp = (DWORD)&(font_table[*(BYTE *)text][0]);
2 pj 483
        for (r=0; r<8; r++) {
484
            bits = lmempeekb((LIN_ADDR)fp++);
485
            for (c=0; c<8; c++)
486
                if (bits & (0x80>>c))
487
                    lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), fg);
488
/*                  vbe_putpixel((x+c),(y+r),fg);*/
489
                else
490
                    lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), bg);
491
/*                  vbe_putpixel((x+c), (y+r), bg);*/
492
        }
493
        text++;
494
        x += 8;
495
    }
496
}
497
 
498
void WrLine_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
499
{
500
    int dx, dy, incr1, incr2, d, x, y, xend, yend, yinc, xinc;
501
    WORD bpr;
502
    WORD bank, offs, ebank, eoffs;
503
    WORD line_segment, len;
504
 
505
    bpr = gd_getbpr();
506
    if (y2 == y1) {
507
        y = y1;
508
        if (x1 > x2) {
509
            xend = x1;
510
            x1 = x2;
511
            x2 = xend;
512
        }
513
/*      WrHline_256(x1, x2, y1, color, bpr);    */
514
        len = 1 + x2 - x1;
515
        Seg_Off_256(x2, y, bpr, &eoffs, &ebank);
516
        Seg_Off_256(x1, y, bpr, &offs, &bank);
517
        Load_Write_Bank_256(bank);
518
        if (bank == ebank) {
519
            memset((LIN_ADDR)(0xA0000 + offs), color, len);
520
        } else {
521
            line_segment = 65536L - offs;
522
            memset((LIN_ADDR)(0xA0000 + offs), color, line_segment);
523
            Load_Write_Bank_256(ebank);
524
            memset((LIN_ADDR)0xA0000, color, eoffs);
525
        }
526
    } else {
527
        dx = abs(x2 - x1);
528
        dy = abs(y2 - y1);
529
        if (dx >= dy) {
530
            if (x1 > x2) {
531
                x = x2;
532
                y = y2;
533
                xend = x1;
534
                if (dy == 0) {
535
                    yinc = 0;
536
                } else {
537
                    if (y2 > y1) {
538
                        yinc = -1;
539
                    } else {
540
                        yinc = 1;
541
                    }
542
                }
543
            } else {
544
                x = x1;
545
                y = y1;
546
                xend = x2;
547
                if (dy == 0) {
548
                    yinc = 0;
549
                } else {
550
                    if (y2 > y1) {
551
                        yinc =1;
552
                    } else {
553
                        yinc = -1;
554
                    }
555
                }
556
            }
557
            incr1 = 2 * dy;
558
            d = incr1 - dx;
559
            incr2 = 2 * (dy - dx);
560
            Seg_Off_256(x, y, bpr, &offs, &bank);
561
            Load_Write_Bank_256(bank);
562
            lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
563
            while (x < xend) {
564
                x++;
565
                if (d < 0) {
566
                    d += incr1;
567
                } else {
568
                    y += yinc;
569
                    d += incr2;
570
                }
571
                Seg_Off_256(x, y, bpr, &offs, &bank);
572
                Load_Write_Bank_256(bank);
573
                lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
574
            }
575
        } else {
576
            if (y1 > y2) {
577
                x = x2;
578
                y = y2;
579
                yend = y1;
580
                if (dx == 0) {
581
                    xinc = 0;
582
                } else {
583
                    if (x2 > x1) {
584
                        xinc = -1;
585
                    } else {
586
                        xinc = 1;
587
                    }
588
                }
589
            } else {
590
                x = x1;
591
                y = y1;
592
                yend = y2;
593
                if (dx == 0) {
594
                    xinc = 0;
595
                } else {
596
                    if (x2 > x1) {
597
                        xinc = 1;
598
                    } else {
599
                        xinc = -1;
600
                    }
601
                }
602
            }
603
            incr1 = 2 * dx;
604
            d = incr1 - dy;
605
            incr2 = 2 * (dx - dy);
606
            Seg_Off_256(x, y, bpr, &offs, &bank);
607
            Load_Write_Bank_256(bank);
608
            lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
609
            while (y < yend) {
610
                y++;
611
                if (d < 0) {
612
                    d += incr1;
613
                } else {
614
                    x += xinc;
615
                    d += incr2;
616
                }
617
                Seg_Off_256(x, y, bpr, &offs, &bank);
618
                Load_Write_Bank_256(bank);
619
                lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
620
            }
621
        }
622
    }
623
}
624
 
625
void linLine8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color)
626
{
627
    register int t, distance;
628
    register DWORD addr;
629
    register WORD bpr;
630
    int xerr=0, yerr=0, deltax, deltay;
631
    int incx, incy;
632
 
633
    bpr = gd_getbpr();
634
    addr = gd_getflb();
635
    deltax = x2 - x1;                   /* compute both distances */
636
    deltay = y2 - y1;
637
 
638
    if (deltax > 0)                     /* compute increments */
639
        incx = 1;
640
    else if (deltax == 0)
641
        incx = 0;
642
    else
643
        incx = -1;
644
 
645
    if (deltay > 0)
646
        incy = 1;
647
    else if (deltay == 0)
648
        incy = 0;
649
    else
650
        incy = -1;
651
 
652
    deltax = abs(deltax);               /* determine greater distance */
653
    deltay = abs(deltay);
654
    if (deltax > deltay)
655
        distance = deltax;
656
    else
657
        distance = deltay;
658
 
659
    for (t=0; t<=distance+1; t++) {     /* draw the line */
660
/*      vbe_putpixel(x1, y1, colour);*/
661
        lmempokeb((LIN_ADDR)(addr + y1 * bpr + x1), color);
662
        xerr += deltax;
663
        yerr += deltay;
664
        if (xerr > distance) {
665
            xerr -= distance;
666
            x1 += incx;
667
        }
668
        if (yerr > distance) {
669
            yerr -= distance;
670
            y1 += incy;
671
        }
672
    }
673
}
674
 
675
void WrPixel_256(WORD x, WORD y, DWORD color)
676
{
677
    WORD bpr;
678
    WORD bank, offs;
679
 
680
    bpr = gd_getbpr();
681
    Seg_Off_256(x, y, bpr, &offs, &bank);
682
    Load_Write_Bank_256(bank);
683
    lmempokeb((LIN_ADDR)(0xA0000 + offs), color);
684
/*    Load_Write_Bank_256(0);*/
685
}
686
 
687
void linWr8(WORD x, WORD y, DWORD color)
688
{
689
    WORD bpr;
690
 
691
    bpr = gd_getbpr();
692
    lmempokeb((LIN_ADDR)(flbaddr + y * bpr + x), color);
693
}
694
 
695
DWORD RdPixel_256(WORD x, WORD y)
696
{
697
    WORD bpr;
698
    WORD bank, offs;
699
    DWORD rv;
700
 
701
    bpr = gd_getbpr();
702
    Seg_Off_256(x, y, bpr, &offs, &bank);
703
    Load_Write_Bank_256(bank);
704
    rv = lmempeekb((LIN_ADDR)(0xA0000 + offs));
705
    return rv;
706
}
707
 
708
DWORD linRd8(WORD x, WORD y)
709
{
710
    WORD bpr;
711
    DWORD rv;
712
 
713
    bpr = gd_getbpr();
714
    rv = lmempeekb((LIN_ADDR)(flbaddr + y * bpr + x));
715
    return rv;
716
}
717