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

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [scr_djgr.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) 1999 Victor Rogachev <rogach@sut.ru>
5
 *
6
 * Screen Driver using DJGPP & GRX  Library
7
 *
8
 *  For only GRX lib
9
 *
10
 * This driver requires the following GRX entry points:
11
 *      GrSetMode, GrSetColor, GrPlot, GrPixel,
12
 *      GrHLine, GrVLine, GrFilledBox
13
 *
14
 * All graphics drawing primitives are based on top of these functions.
15
 */
16
 
17
#include <stdio.h>
18
#include "device.h"
19
#include "genfont.h"
20
 
21
#include <grx20.h>
22
 
23
/* specific grxlib driver entry points*/
24
static PSD  DJGR_open(PSD psd);
25
static void DJGR_close(PSD psd);
26
static void DJGR_getscreeninfo(PSD psd,PMWSCREENINFO psi);
27
static void DJGR_setpalette(PSD psd,int first,int count,MWPALENTRY *pal);
28
static void DJGR_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c);
29
static MWPIXELVAL DJGR_readpixel(PSD psd,MWCOORD x, MWCOORD y);
30
static void DJGR_drawhline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c);
31
static void DJGR_drawvline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c);
32
static void DJGR_fillrect(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,MWPIXELVAL c);
33
static void DJGR_blit(PSD dstpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,
34
                MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
35
static PSD  DJGR_allocatememgc(PSD psd);
36
 
37
SCREENDEVICE    scrdev = {
38
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
39
        DJGR_open,
40
        DJGR_close,
41
        DJGR_getscreeninfo,
42
        DJGR_setpalette,
43
        DJGR_drawpixel,
44
        DJGR_readpixel,
45
        DJGR_drawhline,
46
        DJGR_drawvline,
47
        DJGR_fillrect,
48
        gen_fonts,
49
        DJGR_blit,
50
        NULL,                   /* PreSelect*/
51
        NULL,                   /* DrawArea subdriver*/
52
        NULL,                   /* SetIOPermissions*/
53
        DJGR_allocatememgc,
54
        NULL,                   /* MapMemGC*/
55
        NULL                    /* FreeMemGC*/
56
};
57
 
58
extern int gr_mode;     /* temp kluge*/
59
 
60
 
61
/*
62
**      Open graphics
63
*/
64
static PSD
65
DJGR_open(PSD psd)
66
{
67
        int             x;
68
        int             y;
69
        int             c;
70
        GrVideoMode     *md_info;
71
 
72
        x = 640;
73
        y = 480;
74
        c = 256;
75
 
76
        GrSetMode(GR_width_height_color_graphics,x,y,c);
77
 
78
        md_info = (GrVideoMode *) GrCurrentVideoMode();
79
 
80
        psd->xres = psd->xvirtres = GrScreenX();
81
        psd->yres = psd->yvirtres = GrScreenY();
82
        psd->linelen = md_info->lineoffset;
83
        psd->planes = 1;
84
        psd->bpp = md_info->bpp;
85
        psd->ncolors = GrNumColors();
86
        psd->flags = PSF_SCREEN;
87
        psd->addr = 0;           /* FIXME */
88
 
89
        /* note: must change psd->pixtype here for truecolor systems*/
90
        psd->pixtype = MWPF_PALETTE;
91
 
92
        return psd;
93
}
94
 
95
/*
96
**      Close graphics
97
*/
98
static void
99
DJGR_close(PSD psd)
100
{
101
        GrSetMode(GR_default_text);
102
}
103
 
104
/*
105
**      Get Screen Info
106
*/
107
static void
108
DJGR_getscreeninfo(PSD psd,PMWSCREENINFO psi)
109
{
110
        psi->rows = psd->yvirtres;
111
        psi->cols = psd->xvirtres;
112
        psi->planes = psd->planes;
113
        psi->bpp = psd->bpp;
114
        psi->ncolors = psd->ncolors;
115
        psi->pixtype = psd->pixtype;
116
        psi->fonts = NUMBER_FONTS;
117
 
118
        if(scrdev.yvirtres > 480) {
119
                /* SVGA 800x600*/
120
                psi->xdpcm = 33;        /* assumes screen width of 24 cm*/
121
                psi->ydpcm = 33;        /* assumes screen height of 18 cm*/
122
        } else if(scrdev.yvirtres > 350) {
123
                /* VGA 640x480*/
124
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
125
                psi->ydpcm = 27;        /* assumes screen height of 18 cm*/
126
        } else {
127
                /* EGA 640x350*/
128
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
129
                psi->ydpcm = 19;        /* assumes screen height of 18 cm*/
130
        }
131
}
132
 
133
/*
134
**      Set Palette
135
*/
136
static void
137
DJGR_setpalette(PSD psd,int first,int count,MWPALENTRY *pal)
138
{
139
        while(first < 256 && count-- > 0) {
140
                GrSetColor(first++, pal->r, pal->g, pal->b);
141
                ++pal;
142
        }
143
}
144
 
145
/*
146
**      Draw Pixel
147
*/
148
static void
149
DJGR_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c)
150
{
151
        GrPlot(x, y, c);
152
}
153
 
154
/*
155
**      Read Pixel
156
*/
157
static MWPIXELVAL
158
DJGR_readpixel(PSD psd,MWCOORD x, MWCOORD y)
159
{
160
        return GrPixel(x, y);
161
}
162
 
163
/*
164
**      Draw Horizontal Line
165
*/
166
static void
167
DJGR_drawhline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
168
{
169
        GrHLine(x1, x2, y, c);
170
}
171
 
172
/*
173
**      Draw Vertical Line
174
*/
175
static void
176
DJGR_drawvline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
177
{
178
        GrVLine(x, y1, y2, c);
179
}
180
 
181
/*
182
**      Filled Box
183
*/
184
static void
185
DJGR_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c)
186
{
187
        GrFilledBox(x1, y1, x2, y2, c);
188
}
189
 
190
/*
191
**      Blit
192
*/
193
static void
194
DJGR_blit(PSD dstpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,MWCOORD h,
195
                PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op)
196
{
197
        /* FIXME*/
198
}
199
 
200
/* allocate a memory screen device*/
201
static PSD
202
DJGR_allocatememgc(PSD psd)
203
{
204
        /* if driver doesn't have blit, fail*/
205
        return NULL;
206
}

powered by: WebSVN 2.1.0

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