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

  1. /*
  2.     dispmono.c
  3.  
  4.     % disp_MapMono        monochome on/off functionw
  5.  
  6.     OWL 1.2
  7.     Copyright (c) 1988, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      3/28/90 jmd    ansi-fied
  13. */
  14.  
  15. #include "oakhead.h"
  16. #include "disppriv.h"
  17.  
  18. #define WHITE    0x07
  19. #define BLACK    0x00
  20. #define BOLD    0x0F
  21. #define BLINK    0x08
  22.  
  23. void disp_MapMono(boolean mono)
  24. /*
  25.     if mono == TRUE maps colors for mono displays.
  26.     higher values are generalized as lighter than lower values, with the
  27.     range being from 0 - 7 (8 - f are moduloed, but bolding and blinking
  28.     are preserved), therefore:
  29.     fore < back (eg. 0x31) maps to 0x70
  30.     fore > back (eg. 0x25) maps to 0x07
  31. */
  32. {
  33.     int f, b, diff;
  34.  
  35.     if (!mono) {
  36.         for (f = 0; f < 0x10; f++) {
  37.             for (b = 0; b < 0x10; b++) {
  38.  
  39.                 disp_SetMapEntry((byte)(b * 0x10 + f), (opixval)b, (opixval)f);
  40.             }
  41.         }
  42.         return;
  43.     }            
  44.  
  45.     for (f = 0; f < 0x10; f++) {
  46.         for (b = 0; b < 0x10; b++) {
  47.  
  48.             if ((diff = b%0x08 - f%0x08) == 0) {    /* f == b */
  49.  
  50.                 disp_SetMapEntry((char)(b * 0x10 + f), BLACK, BLACK);
  51.             }
  52.             else if (diff > 0) {                    /* f < b */
  53.  
  54.                 disp_SetMapEntry((char)(b * 0x10 + f),
  55.                     (b > 0x07) ? BOLD:WHITE,        /* back, foreground */
  56.                     (f > 0x07) ? BOLD:BLACK);
  57.             }
  58.             else {                                    /* f > b */
  59.                 disp_SetMapEntry((char)(b * 0x10 + f),
  60.                     (b > 0x07) ? BLINK:BLACK,        /* back, foreground */
  61.                     (f > 0x07) ? BOLD:WHITE);
  62.             }
  63.         }
  64.     }
  65. }
  66.