OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mw/] [src/] [drivers/] [scr_tc.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3
 *
4
 * Copyright (c) 2000 Victor Larionov, Victor Rogachev <rogach@sut.ru>
5
 * Modified by mlkao
6
 *
7
 * Screen Driver using BGI for DOS TURBOC
8
 *
9
 * This driver requires the following BGI entry points:
10
 *      initgraph, closegraph,
11
 *      putpixel, getpixel
12
 *      setcolor, line, setfillstyle, bar
13
 *
14
 * All graphics drawing primitives are based on top of these functions.
15
 *
16
 * This file also contains the generalized low-level font/text
17
 * drawing routines, which will be split out into another file.
18
 * Both fixed and proportional fonts are supported.
19
 */
20
 
21
#include <stdio.h>
22
#include <graphics.h>
23
#include "device.h"
24
#include "genfont.h"
25
 
26
/* specific bgi driver entry points*/
27
static PSD  BGI_open(PSD psd);
28
static void BGI_close(PSD psd);
29
static void BGI_getscreeninfo(PSD psd,PMWSCREENINFO psi);
30
static void BGI_setpalette(PSD psd,int first,int count,MWPALENTRY *pal);
31
static void BGI_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c);
32
static MWPIXELVAL BGI_readpixel(PSD psd,MWCOORD x, MWCOORD y);
33
static void BGI_drawhline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c);
34
static void BGI_drawvline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c);
35
static void BGI_fillrect(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,MWPIXELVAL c);
36
static void BGI_blit(PSD dstpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,MWCOORD h,
37
                PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
38
static PSD  BGI_allocatememgc(PSD psd);
39
 
40
SCREENDEVICE    scrdev = {
41
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
42
        BGI_open,
43
        BGI_close,
44
        BGI_getscreeninfo,
45
        BGI_setpalette,
46
        BGI_drawpixel,
47
        BGI_readpixel,
48
        BGI_drawhline,
49
        BGI_drawvline,
50
        BGI_fillrect,
51
        gen_fonts,
52
        BGI_blit,
53
        NULL,                   /* PreSelect*/
54
        NULL,                   /* DrawArea subdriver*/
55
        NULL,                   /* SetIOPermissions*/
56
        BGI_allocatememgc,
57
        NULL,                   /* MapMemGC*/
58
        NULL                    /* FreeMemGC*/
59
};
60
 
61
/* add by mlkao */
62
extern int gr_mode;     /* temp kluge*/
63
static struct linesettingstype lineinfo;
64
static struct palettetype bgi_pal;
65
 
66
static PSD
67
BGI_open(PSD psd)
68
{
69
        int             gd=VGA;
70
        int             gm=VGAHI;
71
 
72
        registerbgidriver(EGAVGA_driver);
73
        initgraph(&gd,&gm,"");
74
 
75
        getlinesettings(&lineinfo);
76
 
77
        psd->xres = psd->xvirtres = getmaxx()+1;
78
        psd->yres = psd->yvirtres = getmaxy()+1;
79
        psd->linelen = lineinfo.thickness;
80
        psd->planes = 1;
81
        psd->bpp = 4;           /* FIXME?? */
82
        psd->ncolors = getmaxcolor() + 1;
83
        psd->flags = PSF_SCREEN;
84
        psd->addr = 0;           /* FIXME */
85
 
86
        /* note: must change psd->pixtype here for truecolor systems*/
87
        psd->pixtype = MWPF_PALETTE;
88
        return psd;
89
}
90
 
91
static void
92
BGI_close(PSD psd)
93
{
94
        closegraph();
95
}
96
 
97
static void
98
BGI_getscreeninfo(PSD psd,PMWSCREENINFO psi)
99
{
100
        psi->rows = psd->yvirtres;
101
        psi->cols = psd->xvirtres;
102
        psi->planes = psd->planes;
103
        psi->bpp = psd->bpp;
104
        psi->ncolors = psd->ncolors;
105
        psi->pixtype = psd->pixtype;
106
        psi->fonts = NUMBER_FONTS;
107
 
108
        if(scrdev.yvirtres > 480) {
109
                /* SVGA 800x600*/
110
                psi->xdpcm = 33;        /* assumes screen width of 24 cm*/
111
                psi->ydpcm = 33;        /* assumes screen height of 18 cm*/
112
        } else if(scrdev.yvirtres > 350) {
113
                /* VGA 640x480*/
114
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
115
                psi->ydpcm = 27;        /* assumes screen height of 18 cm*/
116
        } else {
117
                /* EGA 640x350*/
118
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
119
                psi->ydpcm = 19;        /* assumes screen height of 18 cm*/
120
        }
121
}
122
 
123
static void
124
BGI_setpalette(PSD psd,int first,int count,MWPALENTRY *pal)
125
{
126
        /* std 16 color palette assumed*/
127
}
128
 
129
static void
130
BGI_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c)
131
{
132
        switch(gr_mode) {
133
                case MWMODE_COPY: break;
134
                case MWMODE_XOR: c ^= getpixel(x, y); break;
135
                case MWMODE_OR:  c |= getpixel(x, y); break;
136
                case MWMODE_AND: c &= getpixel(x, y); break;
137
        }
138
        putpixel(x, y, c);
139
}
140
 
141
static MWPIXELVAL
142
BGI_readpixel(PSD psd,MWCOORD x, MWCOORD y)
143
{
144
        return getpixel(x, y);
145
}
146
 
147
static void
148
BGI_drawhline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
149
{
150
        MWCOORD x;
151
 
152
        if (x1 > x2) {
153
                x  = x1;
154
                x1 = x2;
155
                x2 = x;
156
        }
157
 
158
        setcolor(c);
159
        switch(gr_mode) {
160
                case MWMODE_COPY:
161
                        setwritemode(COPY_PUT);
162
                        break;
163
                case MWMODE_XOR:
164
                        setwritemode(XOR_PUT);
165
                        break;
166
                case MWMODE_OR:
167
                        for(x = x1; x <= x2; x++)
168
                                putpixel(x, y, c | getpixel(x, y));
169
                        return;
170
                case MWMODE_AND:
171
                        for(x = x1; x <= x2; x++)
172
                                putpixel(x, y, c & getpixel(x, y));
173
                        return;
174
        }
175
        line(x1, y, x2, y);
176
}
177
 
178
static void
179
BGI_drawvline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
180
{
181
        MWCOORD y;
182
 
183
        if (y1 > y2) {
184
                y  = y1;
185
                y1 = y2;
186
                y2 = y;
187
        }
188
 
189
        setcolor(c);
190
        switch(gr_mode) {
191
                case MWMODE_COPY:
192
                        setwritemode(COPY_PUT);
193
                        break;
194
                case MWMODE_XOR:
195
                        setwritemode(XOR_PUT);
196
                        break;
197
                case MWMODE_OR:
198
                        for(y = y1; y <= y2; y++)
199
                                putpixel(x, y, c | getpixel(x, y));
200
                                return;
201
                case MWMODE_AND:
202
                        for(y = y1; y <= y2; y++)
203
                                putpixel(x, y, c & getpixel(x, y));
204
                                return;
205
        }
206
        line(x, y1, x, y2);
207
}
208
 
209
static void
210
BGI_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2,
211
        MWPIXELVAL c)
212
{
213
        MWCOORD x, y;
214
 
215
        if (x1 > x2) {
216
                x  = x1;
217
                x1 = x2;
218
                x2 = x;
219
        }
220
        if (y1 > y2) {
221
                y  = y1;
222
                y1 = y2;
223
                y2 = y;
224
        }
225
 
226
        switch(gr_mode) {
227
                case MWMODE_COPY:
228
                        setfillstyle(1,c);
229
                        bar(x1, y1, x2, y2);
230
                        break;
231
 
232
                case MWMODE_XOR:
233
                        for(x = x1; x <= x2; x++)
234
                                for(y = y1; y <= y2; y++)
235
                                        putpixel(x, y, c ^ getpixel(x, y));
236
                        break;
237
 
238
                case MWMODE_OR:
239
                        for(x = x1; x <= x2; x++)
240
                                for(y = y1; y <= y2; y++)
241
                                        putpixel(x, y, c | getpixel(x, y));
242
                        break;
243
 
244
                case MWMODE_AND:
245
                        for(x = x1; x <= x2; x++)
246
                                for(y = y1; y <= y2; y++)
247
                                        putpixel(x, y, c & getpixel(x, y));
248
                        break;
249
 
250
                default:
251
                        break;
252
        }
253
}
254
 
255
static void
256
BGI_blit(PSD dstpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,MWCOORD h,
257
                PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op)
258
{
259
        /* FIXME*/
260
}
261
 
262
/* allocate a memory screen device*/
263
static PSD
264
BGI_allocatememgc(PSD psd)
265
{
266
        /* if driver doesn't have blit, fail*/
267
        return NULL;
268
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.