home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / PCTEXTIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-01  |  3.5 KB  |  127 lines

  1. /*
  2.     pctextin.c
  3.  
  4.     % PC text info routines
  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.      1/18/89 Ted    Made mode 3 detect # of rows & cols if current mode.
  15.      2/25/89 ted    Made mode 3 ignore the bios # of rows if it's not supported.
  16.      6/28/89 ted    removed dispid and changed mmwidth/height to x/ypixperm
  17.      8/22/89 ted    Added fontdesc_struct elements to def_font initialization.
  18.  
  19.      3/28/90 jmd    ansi-fied
  20.      6/22/90 ted    added "void"s to no-parameter functions per ansii.
  21. */
  22.  
  23. #include "pcpriv.h"
  24. /* -------------------------------------------------------------------------- */
  25.  
  26. static dispinfo_struct textinfo = {
  27.     {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0},    /* devname */
  28.     0x07,            /* mode */
  29.     0, 0,            /* xpixperm, ypixperm */
  30.     &pcdatastruc.dmspace, /* dispmap */
  31.     VID_MONOADDR,    /* dispaddr */
  32.     160,            /* bytewidth */
  33.     0,                /* ileave */
  34.     0,                /* ilsize */
  35.     1,                /* nplanes */
  36.     16,                /* pixbits */
  37.  
  38.     2L,                /* ncolors */
  39.     DTYPE_MONOCHROME, /* colortype */
  40.     NULL,            /* defcolmap */
  41.  
  42.     TRUE,            /* hardcursor */
  43.     BO_LSBYTFIRST,    /* byteorder */
  44.     {                /* def_font */
  45.         0,                /* fontid */
  46.         { 1, 1,    0, 0,0,0, 0 },        /* real: width, height, style, etc. */
  47.         { 1, 1,    0, 0,0,0, 0 }        /* req:  width, height, style, etc. */
  48.     }
  49. };
  50. /* -------------------------------------------------------------------------- */
  51.  
  52. boolean DIGPRIV text_setinfo(int mode)
  53. {
  54.     byte rows, cols;
  55.  
  56. /* Set up the device info structure */
  57.     memmove(&pcdata->info, &textinfo, sizeof(dispinfo_struct));
  58.     pc_initdispmap(80, 25);
  59.  
  60.     pcdata->info.mode = mode;
  61. /* Pre-set default values */
  62.     pchdata->xmouscale = 8;
  63.     pchdata->ymouscale = 8;
  64.     cols = 80;
  65.     rows = 25;
  66.  
  67.     if (mode == 0x07) {
  68.         pcdata->info.dispaddr = VID_MONOADDR;
  69.         pcdata->info.colortype = DTYPE_MONOCHROME;
  70.         pcdata->info.ncolors = 2L;
  71.  
  72.         strncpy(pcdata->info.devname, "IBM PC MDA TEXT", DEVNAMELEN-1);
  73.     }
  74.     else {
  75.         pcdata->info.dispaddr = VID_CGAADDR;
  76.         pcdata->info.colortype = DTYPE_MAPCOLOR;
  77.         pcdata->info.ncolors = 16L;
  78.  
  79.         switch (mode) {
  80.         case 0x00:
  81.         case 0x01:
  82.             pchdata->xmouscale = 16;
  83.             cols = 40;
  84.             strncpy(pcdata->info.devname, "IBM PC 40 COL TEXT", DEVNAMELEN-1);
  85.             break;
  86.         case PCMODE_EGA43:
  87.             rows = 43;
  88.             strncpy(pcdata->info.devname, "IBM PC EGA 43 LINE", DEVNAMELEN-1);
  89.             break;
  90.         case PCMODE_VGA50:
  91.             rows = 50;
  92.             strncpy(pcdata->info.devname, "IBM PC VGA 50 LINE", DEVNAMELEN-1);
  93.             break;
  94.         default:
  95.             strncpy(pcdata->info.devname, "IBM PC CGA TEXT", DEVNAMELEN-1);
  96.         }
  97.     }
  98.     pcdata->info.devname[DEVNAMELEN-1] = '\0';
  99.  
  100.     /* If staying in mode, override with width & height from BIOS data area */
  101.     if (mode == pcdata->oldmode) {
  102.         ram_segtomem(0x40, 0x84, &cols, 1);    /* Get Rows from BIOS data area */
  103.         cols++;
  104.         /* using cols as a temp. variable to preserve rows for now */
  105.         /* Old PC's and some clones don't support the rows var in the BIOS, */
  106.         /* so we only use it if it's a plausible number */
  107.         if (cols > 25) rows = cols;
  108.         
  109.         ram_segtomem(0x40, 0x4A, &cols, 1);    /* Get Cols from BIOS data area */
  110.     }
  111.     pcdata->info.bytewidth = 2 * cols;
  112.     pcdata->info.dispmap->width = cols;
  113.     pcdata->info.dispmap->height = rows;
  114.  
  115.     pcdata->fontlines = (mode == 0x07) ? 14 : 8;
  116.  
  117.     return(TRUE);
  118. }
  119. /* -------------------------------------------------------------------------- */
  120.  
  121. boolean pc_GetRetrace(void)
  122. {
  123.     return(pc_retrace());
  124. }
  125. /* -------------------------------------------------------------------------- */
  126.  
  127.