home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / SCPAL1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  3.5 KB  |  115 lines

  1. /**
  2. *
  3. * Name        scpal1 -- Define one EGA palette color
  4. *
  5. * Synopsis    ercode = scpal1(reg,value);
  6. *
  7. *        int ercode      0 if successful;
  8. *                  1 if operation not valid for current
  9. *                       video adapter;
  10. *                  2 if reg is out of 0-16 range.
  11. *        unsigned reg      Palette register to define (0-15, or
  12. *                    16 for border).
  13. *        unsigned value      Color value to be displayed (see
  14. *                    format below).
  15. *
  16. * Description    This function defines the physical color to be displayed
  17. *        by a given attribute value and color dot value.
  18. *
  19. *        The current video device must be an Enhanced Graphics
  20. *        Adapter (EGA).
  21. *
  22. *        The color value has the following format:
  23. *
  24. *               ************* bits ************
  25. *
  26. *               5     4     3     2       1     0
  27. *
  28. *               R'    G'/I  B'    R     G     B
  29. *
  30. *        Bits 0-5 correspond to the individual color signals,
  31. *        except that bit 4 corresponds to the intensity bit when
  32. *        used with the IBM Color Display.  Bits 6 and 7 of the
  33. *        color value are ignored.
  34. *
  35. *        As an example, the EGA ROM BIOS defines the following
  36. *        color values when the adapter is reset:
  37. *
  38. *               ************* bits ************
  39. *
  40. *               5     4     3     2       1     0
  41. *
  42. *       Register Value  R'    G'/I  B'    R     G     B  Color
  43. *       -------- -----  -------------------------------  -------------
  44. *           0     0x00  0     0     0     0       0     0  black
  45. *           1     0x01  0     0     0     0       0     1  blue
  46. *           2     0x02  0     0     0     0       1     0  green
  47. *           3     0x03  0     0     0     0       1     1  cyan
  48. *           4     0x04  0     0     0     1       0     0  red
  49. *           5     0x05  0     0     0     1       0     1  magenta
  50. *           6     0x14  0     1     0     1       0     0  brown
  51. *           7     0x07  0     0     0     1       1     1  white
  52. *           8     0x38  1     1     1     0       0     0  dark gray
  53. *           9     0x39  1     1     1     0       0     1  light blue
  54. *          10     0x3a  1     1     1     0       1     0  light green
  55. *          11     0x3b  1     1     1     0       1     1  light cyan
  56. *          12     0x3c  1     1     1     1       0     0  light red
  57. *          13     0x3d  1     1     1     1       0     1  light magenta
  58. *          14     0x3e  1     1     1     1       0     1  yellow
  59. *          15     0x3f  1     1     1     1       1     1  intense white
  60. *    16 (border)  0x00  0     0     0     0       0     0  black
  61. *
  62. *        The border ("overscan") color is specified by a reg
  63. *        value of 16.  The Enhanced Color Display supports a
  64. *        border color only in 200-line modes.  The default border
  65. *        color is 0.
  66. *
  67. * Returns    ercode          0 if successful,
  68. *                  1 if operation not valid for current
  69. *                       video adapter;
  70. *                  2 if reg is out of 0-16 range.
  71. *
  72. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987,1989
  73. *
  74. **/
  75.  
  76. #include <dos.h>
  77.  
  78. #include <bscreens.h>
  79.  
  80. #define  OK            0          /* Error codes.          */
  81. #define  INVALID_REQUEST    1
  82. #define  REG_RANGE        2
  83.  
  84. int scpal1(reg,value)
  85. unsigned reg,value;
  86. {
  87.     int        result;
  88.     int        device;
  89.     int        mode,act_page,columns;
  90.     union REGS inregs,outregs;
  91.  
  92.     if (utrange(reg,0,16))
  93.     result = REG_RANGE;
  94.     else
  95.     {
  96.     scequip();              /* Detect equipment.          */
  97.  
  98.     device = scmode(&mode,&columns,&act_page);
  99.     if (device == b_ega || device == b_vga || b_pcmodel == IBM_JR)
  100.     {
  101.         inregs.h.ah = 0x10;
  102.         inregs.h.al = (unsigned char) ((reg == 16) ? 1 : 0);
  103.         inregs.h.bh = (unsigned char) utlobyte(value);
  104.                       /* (BL ignored if AL == 1.) */
  105.         inregs.h.bl = (unsigned char) reg;
  106.         int86(0x10,&inregs,&outregs);
  107.         result = OK;
  108.     }
  109.     else                  /* Not supported.          */
  110.         result = INVALID_REQUEST;
  111.     }
  112.  
  113.     return result;
  114. }
  115.