home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scpal1 -- Define one EGA palette color
- *
- * Synopsis ercode = scpal1(reg,value);
- *
- * int ercode 0 if successful;
- * 1 if operation not valid for current
- * video adapter;
- * 2 if reg is out of 0-16 range.
- * unsigned reg Palette register to define (0-15, or
- * 16 for border).
- * unsigned value Color value to be displayed (see
- * format below).
- *
- * Description This function defines the physical color to be displayed
- * by a given attribute value and color dot value.
- *
- * The current video device must be an Enhanced Graphics
- * Adapter (EGA).
- *
- * The color value has the following format:
- *
- * ************* bits ************
- *
- * 5 4 3 2 1 0
- *
- * R' G'/I B' R G B
- *
- * Bits 0-5 correspond to the individual color signals,
- * except that bit 4 corresponds to the intensity bit when
- * used with the IBM Color Display. Bits 6 and 7 of the
- * color value are ignored.
- *
- * As an example, the EGA ROM BIOS defines the following
- * color values when the adapter is reset:
- *
- * ************* bits ************
- *
- * 5 4 3 2 1 0
- *
- * Register Value R' G'/I B' R G B Color
- * -------- ----- ------------------------------- -------------
- * 0 0x00 0 0 0 0 0 0 black
- * 1 0x01 0 0 0 0 0 1 blue
- * 2 0x02 0 0 0 0 1 0 green
- * 3 0x03 0 0 0 0 1 1 cyan
- * 4 0x04 0 0 0 1 0 0 red
- * 5 0x05 0 0 0 1 0 1 magenta
- * 6 0x14 0 1 0 1 0 0 brown
- * 7 0x07 0 0 0 1 1 1 white
- * 8 0x38 1 1 1 0 0 0 dark gray
- * 9 0x39 1 1 1 0 0 1 light blue
- * 10 0x3a 1 1 1 0 1 0 light green
- * 11 0x3b 1 1 1 0 1 1 light cyan
- * 12 0x3c 1 1 1 1 0 0 light red
- * 13 0x3d 1 1 1 1 0 1 light magenta
- * 14 0x3e 1 1 1 1 0 1 yellow
- * 15 0x3f 1 1 1 1 1 1 intense white
- * 16 (border) 0x00 0 0 0 0 0 0 black
- *
- * The border ("overscan") color is specified by a reg
- * value of 16. The Enhanced Color Display supports a
- * border color only in 200-line modes. The default border
- * color is 0.
- *
- * Returns ercode 0 if successful,
- * 1 if operation not valid for current
- * video adapter;
- * 2 if reg is out of 0-16 range.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
- #include <dos.h>
-
- #include <bscreens.h>
-
- #define OK 0 /* Error codes. */
- #define INVALID_REQUEST 1
- #define REG_RANGE 2
-
- int scpal1(reg,value)
- unsigned reg,value;
- {
- int result;
- int device;
- int mode,act_page,columns;
- union REGS inregs,outregs;
-
- if (utrange(reg,0,16))
- result = REG_RANGE;
- else
- {
- scequip(); /* Detect equipment. */
-
- device = scmode(&mode,&columns,&act_page);
- if (device == b_ega || device == b_vga || b_pcmodel == IBM_JR)
- {
- inregs.h.ah = 0x10;
- inregs.h.al = (unsigned char) ((reg == 16) ? 1 : 0);
- inregs.h.bh = (unsigned char) utlobyte(value);
- /* (BL ignored if AL == 1.) */
- inregs.h.bl = (unsigned char) reg;
- int86(0x10,&inregs,&outregs);
- result = OK;
- }
- else /* Not supported. */
- result = INVALID_REQUEST;
- }
-
- return result;
- }