home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / PCCGA.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-11  |  4.0 KB  |  156 lines

  1. /*
  2.     pccga.c
  3.  
  4.     % PC CGA support
  5.  
  6.     5/16/88  by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      4/26/89 ted    Moved attrmap out of info struct into pcdata.
  15.      5/06/89 ted    Added colormap initialization.
  16.      6/28/89 ted    removed dispid and changed mmwidth/height to x/ypixperm
  17.      7/10/89 ted    Installed new text-plotting approach.
  18.      7/12/89 ted    Added OSTATIC's and '_func' macros.
  19.      8/22/89 ted    Added fontdesc_struct elements to def_font initialization.
  20. */
  21.  
  22. #include "pcpriv.h"
  23.  
  24. OSTATIC pc_setinfo_func (cga_setinfo);
  25. /* -------------------------------------------------------------------------- */
  26.  
  27. boolean pc_Mode4(digp)
  28.     dig_struct *digp;
  29. {
  30.     return(pc_OpenCGA(digp, 0x04));
  31. }
  32.  
  33. boolean pc_Mode5(digp)
  34.     dig_struct *digp;
  35. {
  36.     return(pc_OpenCGA(digp, 0x05));
  37. }
  38.  
  39. boolean pc_Mode6(digp)
  40.     dig_struct *digp;
  41. {
  42.     return(pc_OpenCGA(digp, 0x06));
  43. }
  44.  
  45. boolean pc_ModeCpq40(digp)
  46.     dig_struct *digp;
  47. {
  48.     return(pc_OpenCGA(digp, PCMODE_CPQ40));
  49. }
  50. /* -------------------------------------------------------------------------- */
  51.  
  52. boolean DIGPRIV pc_OpenCGA(digp, mode)
  53.     dig_struct *digp;
  54.     int mode;
  55. {
  56.     if (!pc_OpenDIG(digp, mode, cga_setinfo)) {
  57.         return(FALSE);
  58.     }
  59.     pc_setgfuncs(digp);        /* Set the standard ptrs & vars for pc graphics */
  60.  
  61.     return(TRUE);
  62. }
  63. /* -------------------------------------------------------------------------- */
  64.  
  65. static dispinfo_struct cgainfo = {
  66.     {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0},    /* devname */
  67.     0x05,            /* mode */
  68.     0, 0,            /* xpixperm, ypixperm */
  69.     &pcdatastruc.dmspace, /* dispmap */
  70.     VID_CGAADDR,    /* dispaddr */
  71.     80,                /* bytewidth */
  72.     1,                /* ileave */
  73.     VID_CGABLOCK,    /* ilsize */
  74.     1,                /* nplanes */
  75.     2,                /* pixbits */
  76.  
  77.     4L,                /* ncolors */
  78.     DTYPE_MAPCOLOR,    /* color type */
  79.     (ocolmap_type)&pcdefcmap,     /* defcolmap */
  80.  
  81.     FALSE,            /* hardcursor */
  82.     BO_LSBYTFIRST,    /* byteorder */
  83.     {                /* def_font */
  84.         0,                /* fontid */
  85.         { 8, 8, 0, 0,0,0, 0 },        /* real: width, height, style, etc. */
  86.         { 8, 8, 0, 0,0,0, 0 }        /* req:  width, height, style, etc. */
  87.     }
  88. };
  89. /* -------------------------------------------------------------------------- */
  90.  
  91. static boolean DIGPRIV cga_setinfo(mode)
  92.     int mode;
  93. {
  94.     unsigned short fontvec[2];
  95.  
  96. /* Set up the device info structure */
  97.     memmove(&pcdata->info, &cgainfo, sizeof(dispinfo_struct));
  98.     pc_initdispmap(320, 200);
  99.  
  100.     pcdata->info.mode = mode;
  101.  
  102.     pchdata->xmouscale = 1;
  103.     pchdata->ymouscale = 1;
  104.  
  105.     pcdata->attrcols = pc_attrcols;
  106.  
  107.     /* Get the font address from absolute bios address */
  108.     pcdata->fontseg0  = BIOS_CGAFONTSEG;
  109.     pcdata->fontoffs0 = BIOS_CGAFONTOFFS;
  110.  
  111.     /* Extended ASCII font pointer points to second half of font table */
  112.     /* Get the font address from int 1F */
  113.     ram_segtomem(0x00, 4 * BIOS_CGAXFONTVEC, (byte *) fontvec, 4);
  114.     pcdata->fontseg1  = fontvec[1];
  115.     pcdata->fontoffs1 = fontvec[0];
  116.  
  117.     switch(mode) {
  118.     case 0x06:
  119.         pcdata->info.dispmap->width = 640;
  120.         pcdata->info.pixbits = 1;
  121.         pcdata->info.ncolors = 2L;
  122.         pcdata->info.defcolmap = (ocolmap_type)&pcdefmcmap;
  123.         strncpy(pcdata->info.devname, "IBM PC CGA HIRES", DEVNAMELEN-1);
  124.         pcdata->plotchar = pc_1bitplotchar;
  125.         break;
  126.     case 0x40:
  127.     case PCMODE_CPQ40:
  128.         pcdata->info.dispmap->width = 640;
  129.         pcdata->info.dispmap->height = 400;
  130.         pcdata->info.pixbits = 1;
  131.         pcdata->info.ncolors = 2L;
  132.         pcdata->info.ileave = 2;
  133.  
  134.         strncpy(pcdata->info.devname, "COMPAQ PLASMA MODE 40", DEVNAMELEN-1);
  135.         pcdata->info.def_font.real.height = 16;
  136.         pcdata->plotchar = pc_1bitplotchar;
  137.  
  138.         /* Find 16 bit font on Compaq by looking before the int 1F vector. */
  139.         pcdata->fontseg0  = pcdata->fontseg1;
  140.         pcdata->fontoffs0 = pcdata->fontoffs1 - 256 * 16;
  141.         pcdata->fontseg1  = 0;
  142.         pcdata->fontoffs1 = 0;
  143.         break;
  144.     default:
  145.         strncpy(pcdata->info.devname, "IBM PC CGA COLOR", DEVNAMELEN-1);
  146.         pchdata->xmouscale = 2;
  147.         pcdata->plotchar = pc_2bitplotchar;
  148.         break;
  149.     }
  150.     pcdata->info.devname[DEVNAMELEN-1] = '\0';
  151.  
  152.     return(TRUE);
  153. }
  154. /* -------------------------------------------------------------------------- */
  155.  
  156.