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

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