home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l200 / 6.ddi / LIB / COLOR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-21  |  2.0 KB  |  102 lines

  1. /*    COLOR(fg, bg, bd) -- set foreground, background, and border colors
  2.  
  3.     Copyright (c) 1984, 1985 by JMI Software Consultants, Inc.
  4.  */
  5. #include "bio.h"
  6.  
  7. /*    Color definitions
  8.  
  9.     foreground and border colors
  10.     fg        color display    monochrome display
  11.     0        black            black
  12.     1        blue            white with underline
  13.     2        green            white
  14.     3        cyan            white
  15.     4        red                white
  16.     5        magenta            white
  17.     6        brown            white
  18.     7        white            white
  19.     8        gray            black
  20.     9        light blue        intense white with underline
  21.     10        light green        intense white
  22.     11        light cyan        intense white
  23.     12        light red        intense white
  24.     13        light magenta    intense white
  25.     14        yellow            intense white
  26.     15        intense white    intense white
  27.  
  28.     The foreground can be made to blink by adding 16 to the fg
  29.     values above.
  30.  
  31.     background colors
  32.     bg        color display    monochrome display
  33.     0        black            black
  34.     1        blue            black
  35.     2        green            black
  36.     3        cyan            black
  37.     4        red                black
  38.     5        magenta            black
  39.     6        brown            black
  40.     7        white            white
  41.  
  42.     With the monochrome display, fg values of 0, 8, 16, 24 only
  43.     show up as black when used with bg values 0 or 7.
  44.     Also, a bg value of 7 only shows up black when used with
  45.     fg values of 0, 8, 16, or 24.
  46.     All other combinations of fg and bg produce a normal
  47.     white on black display.
  48.  
  49. */
  50.  
  51. LOCAL TEXT *clr[] =
  52.     {
  53.     "30", "34", "32", "36",         /* 0 - 3 */
  54.     "31", "35", "33", "37",            /* 4 - 7 */
  55.     };
  56.  
  57.  
  58. VOID COLOR(fg, bg, bd)
  59.     INT fg, bg, bd;
  60.     {
  61.     INTERN TEXT s[25];
  62.     COUNT i;
  63.  
  64.     i = 0;
  65.     s[i++] = '\033';
  66.     s[i++] = '[';
  67.     s[i++] = '0';
  68.     s[i++] = ';';
  69.     if (fg >= 0)
  70.         {
  71.         if (fg > 15 && fg < 32)
  72.             {
  73.             fg = fg - 16;
  74.             s[i++] = '5';
  75.             s[i++] = ';';
  76.             }
  77.         if (fg > 7 && fg < 16)
  78.             {
  79.             fg = fg - 8;
  80.             s[i++] = '1';
  81.             s[i++] = ';';
  82.             }
  83.         s[i++] = clr[fg][0];
  84.         s[i++] = clr[fg][1];
  85.         }
  86.     if (bg >= 0)
  87.         {
  88.         s[i++] = ';';
  89.         bg &= 7;
  90.         s[i++] = clr[bg][0] + 1;
  91.         s[i++] = clr[bg][1];
  92.         }
  93.     s[i++] = 'm';
  94.     s[i] = '$';
  95.     bdos(9, s);
  96.     if (bd != -1)
  97.         {
  98.         bd &= 0x1f;
  99.         outp(0x3D9, bd);
  100.         }
  101.     }
  102.