home *** CD-ROM | disk | FTP | other *** search
- /*
- pcmcga.c
-
- % PC MCGA support
-
- 5/16/88 by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 4/14/89 ted Added palette poking function.
- 5/06/89 ted Added colormap initialization.
- 6/15/89 Ted Added PlotText func.
- 7/10/89 ted Installed new text-plotting approach.
- 7/12/89 ted Added OSTATIC's and '_func' macros.
- 8/22/89 ted Added fontdesc_struct elements to def_font initialization.
- */
-
- #define DEFDEFCMAPS /* Define default pc cmap declarations in this file */
-
- #include "pcpriv.h"
-
- /* Declare and initialize default 256 color color map */
- /* Note: initializers are broken up so as not to choke the M5.1 compiler */
-
- OGLOBAL ocolmap_struct(256) pcdefmcgamap = PC_DEF_MCGAMAPINIT0
- PC_DEF_MCGAMAPINIT2
- PC_DEF_MCGAMAPINIT4
- PC_DEF_MCGAMAPINIT6
- PC_DEF_MCGAMAPINIT8
- PC_DEF_MCGAMAPINITA
- PC_DEF_MCGAMAPINITC
- PC_DEF_MCGAMAPINITE;
-
- OSTATIC pc_setinfo_func (mcga_setinfo);
- OSTATIC attrcols_func (mcga_attrcols);
- OSTATIC void DIGPRIV mcga_setfuncs(_arg1(dig_struct *));
- OSTATIC void DIGPRIV mcga_setcolmap(_arg1(ocolmap_type));
- OSTATIC dig_dControl_func (mcga_dControl);
- /* -------------------------------------------------------------------------- */
-
- boolean pc_Mode13(digp)
- dig_struct *digp;
- {
- return(pc_OpenMCGA(digp, 0x13));
- }
- /* -------------------------------------------------------------------------- */
-
- boolean DIGPRIV pc_OpenMCGA(digp, mode)
- dig_struct *digp;
- int mode;
- {
- if (!pc_OpenDIG(digp, mode, mcga_setinfo)) {
- return(FALSE);
- }
- mcga_setfuncs(digp);
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- static void DIGPRIV mcga_setfuncs(digp)
- dig_struct *digp;
- {
- pc_setgfuncs(digp); /* Set the standard ptrs & vars for pc graphics */
-
- digp->dControl = mcga_dControl;
- }
- /* -------------------------------------------------------------------------- */
-
- static dispinfo_struct mcgainfo = {
- {'I','B','M',' ', 'P','C',' ','M', 'C','G','A',' ',
- 'G','R','A','P', 'H','I','C','S', 0,0}, /* devname */
- 0x13, /* mode */
- 0, 0, /* xpixperm, ypixperm */
- &pcdatastruc.dmspace, /* dispmap */
- VID_EVGAADDR, /* dispaddr */
- 320, /* bytewidth */
- 0, /* ileave */
- 0, /* ilsize */
- 1, /* nplanes */
- 8, /* pixbits */
-
- 256L, /* ncolors */
- DTYPE_MAPCOLOR, /* color type */
- (ocolmap_type) &pcdefmcgamap, /* defcolmap */
-
- FALSE, /* hardcursor */
- BO_LSBYTFIRST, /* byteorder */
- { /* def_font */
- 0, /* fontid */
- { 8, 8, 0, 0,0,0, 0 }, /* real: width, height, style, etc. */
- { 8, 8, 0, 0,0,0, 0 } /* req: width, height, style, etc. */
- }
- };
- /* -------------------------------------------------------------------------- */
-
- static boolean DIGPRIV mcga_setinfo(mode)
- int mode;
- {
- int i;
-
- /* Set up the device info structure */
- memmove(&pcdata->info, &mcgainfo, sizeof(dispinfo_struct));
- pc_initdispmap(320, 200);
-
- pcdata->info.mode = mode;
-
- /* Set up attrmap */
- pcdata->attrsize = 8; /* 8 bit attrmap elements */
- pcdata->xattrmap = (byte *) omalloc(OA_DIGATTRMAP, 256 * sizeof(byte));
- if (pcdata->xattrmap == NULL) {
- return(FALSE);
- }
- /* Set up stuff for font plotter */
- pcdata->attrcols = mcga_attrcols;
- pcdata->plotchar = pc_8bitplotchar;
-
- for (i = 0; i < 256; i++) {
- pcdata->attrmap[i] = (byte) (i & 0x0F);
- pcdata->xattrmap[i] = (byte) (i >> 4);
- }
- pchdata->xmouscale = 2;
- pchdata->ymouscale = 1;
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- int mcga_dControl(msg, indata, outdata)
- dig_dcmsg msg;
- VOID *indata;
- VOID *outdata;
- {
- setattr_struct *pvs;
-
- switch (msg) {
- case DC_SETATTRCOLS:
- pvs = (setattr_struct *)indata;
-
- pcdata->attrmap[pvs->attr] = ((byte) (pvs->fg));
- pcdata->xattrmap[pvs->attr] = ((byte) (pvs->bg));
- break;
- case DC_GETATTRFG:
- *((opixval *) outdata) = (opixval)
- pcdata->attrmap[*((byte *)indata)];
- break;
- case DC_GETATTRBG:
- *((opixval *) outdata) = (opixval)
- pcdata->xattrmap[*((byte *)indata)];
- break;
- case DC_SETCOLMAP:
- mcga_setcolmap((ocolmap_type) indata);
- break;
- case DC_GETCOLMAP:
- ocolmap_set((ocolmap_type) outdata, pcdata->colmap);
- break;
- default:
- return(pc_dControl(msg, indata, outdata));
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- static unsigned DIGPRIV mcga_attrcols(rattr)
- byte rattr;
- /*
- Return a word with foreground pixval in the low byte and background
- pixval in the high byte.
- */
- {
- union {
- struct { byte bot, top; } dblcol;
- unsigned short x;
- } splitcol;
-
- splitcol.dblcol.bot = pcdata->attrmap[rattr];
- splitcol.dblcol.top = pcdata->xattrmap[rattr];
-
- return((unsigned) splitcol.x);
- }
- /* -------------------------------------------------------------------------- */
-
- static void DIGPRIV mcga_setcolmap(cmap)
- ocolmap_type cmap;
- {
- OREGS regs;
- byte *rgbarray, *p, *endp;
-
- if (cmap == NULL) {
- return;
- }
- /* Write new vals */
- regs.x.ax = 0x1012; /* int 10h, funtion 10.12: set block of regs */
- regs.x.bx = (int) cmap->firstpix; /* start */
- regs.x.cx = (int) cmap->nentries; /* count */
-
- rgbarray = (byte *)ocolmap_entry(cmap, cmap->firstpix);
- endp = rgbarray + cmap->nentries * 3;
- for (p = rgbarray; p < endp; p++) *p = *p >> 2; /* Scale rgb values for bios */
-
- /* put table address in es:dx */
- regs.a.esdx = rgbarray; /* dest. table address */
- oakint86es(BIOS_VIDINT, ®s, cmap->nentries * 3);
- for (p = rgbarray; p < endp; p++) *p = (*p << 2)+3; /* Un-scale rgb values again */
-
- /* Copy the info into our colmap copy */
- ocolmap_set(pcdata->colmap, cmap);
- }
- /* -------------------------------------------------------------------------- */
-