home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / PCCGA.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-29  |  4.1 KB  |  152 lines

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