2 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
4 * Copyright (c) 1999 Victor Rogachev <rogach@sut.ru>
6 * Screen Driver using DJGPP & GRX Library
10 * This driver requires the following GRX entry points:
11 * GrSetMode, GrSetColor, GrPlot, GrPixel,
12 * GrHLine, GrVLine, GrFilledBox
14 * All graphics drawing primitives are based on top of these functions.
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);
37 SCREENDEVICE scrdev = {
38 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
51 NULL, /* DrawArea subdriver*/
52 NULL, /* SetIOPermissions*/
58 extern int gr_mode; /* temp kluge*/
76 GrSetMode(GR_width_height_color_graphics,x,y,c);
78 md_info = (GrVideoMode *) GrCurrentVideoMode();
80 psd->xres = psd->xvirtres = GrScreenX();
81 psd->yres = psd->yvirtres = GrScreenY();
82 psd->linelen = md_info->lineoffset;
84 psd->bpp = md_info->bpp;
85 psd->ncolors = GrNumColors();
86 psd->flags = PSF_SCREEN;
87 psd->addr = 0; /* FIXME */
89 /* note: must change psd->pixtype here for truecolor systems*/
90 psd->pixtype = MWPF_PALETTE;
101 GrSetMode(GR_default_text);
108 DJGR_getscreeninfo(PSD psd,PMWSCREENINFO psi)
110 psi->rows = psd->yvirtres;
111 psi->cols = psd->xvirtres;
112 psi->planes = psd->planes;
114 psi->ncolors = psd->ncolors;
115 psi->pixtype = psd->pixtype;
116 psi->fonts = NUMBER_FONTS;
118 if(scrdev.yvirtres > 480) {
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) {
124 psi->xdpcm = 27; /* assumes screen width of 24 cm*/
125 psi->ydpcm = 27; /* assumes screen height of 18 cm*/
128 psi->xdpcm = 27; /* assumes screen width of 24 cm*/
129 psi->ydpcm = 19; /* assumes screen height of 18 cm*/
137 DJGR_setpalette(PSD psd,int first,int count,MWPALENTRY *pal)
139 while(first < 256 && count-- > 0) {
140 GrSetColor(first++, pal->r, pal->g, pal->b);
149 DJGR_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c)
158 DJGR_readpixel(PSD psd,MWCOORD x, MWCOORD y)
160 return GrPixel(x, y);
164 ** Draw Horizontal Line
167 DJGR_drawhline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
169 GrHLine(x1, x2, y, c);
173 ** Draw Vertical Line
176 DJGR_drawvline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
178 GrVLine(x, y1, y2, c);
185 DJGR_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c)
187 GrFilledBox(x1, y1, x2, y2, c);
194 DJGR_blit(PSD dstpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,MWCOORD h,
195 PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op)
200 /* allocate a memory screen device*/
202 DJGR_allocatememgc(PSD psd)
204 /* if driver doesn't have blit, fail*/