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

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