home *** CD-ROM | disk | FTP | other *** search
- /*
- pccga.c
-
- % PC CGA support
-
- 5/16/88 by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 4/26/89 ted Moved attrmap out of info struct into pcdata.
- 5/06/89 ted Added colormap initialization.
- 6/28/89 ted removed dispid and changed mmwidth/height to x/ypixperm
- 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.
- */
-
- #include "pcpriv.h"
-
- OSTATIC pc_setinfo_func (cga_setinfo);
- /* -------------------------------------------------------------------------- */
-
- boolean pc_Mode4(digp)
- dig_struct *digp;
- {
- return(pc_OpenCGA(digp, 0x04));
- }
-
- boolean pc_Mode5(digp)
- dig_struct *digp;
- {
- return(pc_OpenCGA(digp, 0x05));
- }
-
- boolean pc_Mode6(digp)
- dig_struct *digp;
- {
- return(pc_OpenCGA(digp, 0x06));
- }
-
- boolean pc_ModeCpq40(digp)
- dig_struct *digp;
- {
- return(pc_OpenCGA(digp, PCMODE_CPQ40));
- }
- /* -------------------------------------------------------------------------- */
-
- boolean DIGPRIV pc_OpenCGA(digp, mode)
- dig_struct *digp;
- int mode;
- {
- if (!pc_OpenDIG(digp, mode, cga_setinfo)) {
- return(FALSE);
- }
- pc_setgfuncs(digp); /* Set the standard ptrs & vars for pc graphics */
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- static dispinfo_struct cgainfo = {
- {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0}, /* devname */
- 0x05, /* mode */
- 0, 0, /* xpixperm, ypixperm */
- &pcdatastruc.dmspace, /* dispmap */
- VID_CGAADDR, /* dispaddr */
- 80, /* bytewidth */
- 1, /* ileave */
- VID_CGABLOCK, /* ilsize */
- 1, /* nplanes */
- 2, /* pixbits */
-
- 4L, /* ncolors */
- DTYPE_MAPCOLOR, /* color type */
- (ocolmap_type)&pcdefcmap, /* 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 cga_setinfo(mode)
- int mode;
- {
- unsigned short fontvec[2];
-
- /* Set up the device info structure */
- memmove(&pcdata->info, &cgainfo, sizeof(dispinfo_struct));
- pc_initdispmap(320, 200);
-
- pcdata->info.mode = mode;
-
- pchdata->xmouscale = 1;
- pchdata->ymouscale = 1;
-
- pcdata->attrcols = pc_attrcols;
-
- /* Get the font address from absolute bios address */
- pcdata->fontseg0 = BIOS_CGAFONTSEG;
- pcdata->fontoffs0 = BIOS_CGAFONTOFFS;
-
- /* Extended ASCII font pointer points to second half of font table */
- /* Get the font address from int 1F */
- ram_segtomem(0x00, 4 * BIOS_CGAXFONTVEC, (byte *) fontvec, 4);
- pcdata->fontseg1 = fontvec[1];
- pcdata->fontoffs1 = fontvec[0];
-
- switch(mode) {
- case 0x06:
- pcdata->info.dispmap->width = 640;
- pcdata->info.pixbits = 1;
- pcdata->info.ncolors = 2L;
- pcdata->info.defcolmap = (ocolmap_type)&pcdefmcmap;
- strncpy(pcdata->info.devname, "IBM PC CGA HIRES", DEVNAMELEN-1);
- pcdata->plotchar = pc_1bitplotchar;
- break;
- case 0x40:
- case PCMODE_CPQ40:
- pcdata->info.dispmap->width = 640;
- pcdata->info.dispmap->height = 400;
- pcdata->info.pixbits = 1;
- pcdata->info.ncolors = 2L;
- pcdata->info.ileave = 2;
-
- strncpy(pcdata->info.devname, "COMPAQ PLASMA MODE 40", DEVNAMELEN-1);
- pcdata->info.def_font.real.height = 16;
- pcdata->plotchar = pc_1bitplotchar;
-
- /* Find 16 bit font on Compaq by looking before the int 1F vector. */
- pcdata->fontseg0 = pcdata->fontseg1;
- pcdata->fontoffs0 = pcdata->fontoffs1 - 256 * 16;
- pcdata->fontseg1 = 0;
- pcdata->fontoffs1 = 0;
- break;
- default:
- strncpy(pcdata->info.devname, "IBM PC CGA COLOR", DEVNAMELEN-1);
- pchdata->xmouscale = 2;
- pcdata->plotchar = pc_2bitplotchar;
- break;
- }
- pcdata->info.devname[DEVNAMELEN-1] = '\0';
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-