Mail Archives: djgpp/2003/01/12/22:45:14
"Joel_S" <jbs30000 DOT news DOT invalid AT web2news DOT net> wrote:
>Well, since I'm writting routines for screen mode 0x12 being able to
>change the palettes of the 16 colors is necessary for properly diplaying
>a bitmap file. But I'm not to worried, the built in SCREEN commands in
The 16 colors are processed by both the 256-color palette (the DAC)
and the 16-color palette in the first 16 registers of the Attribute
Controller. You can set the palette with code like this:
int i, j;
for(i = 0; i < 16; i++) {
/* reset Attribute Controller (AC) flip-flop so 0x3C0 is AC address */
(void)inportb(0x3DA);
/* set AC address = i. You must clear bit b5 here to modify the palettes.
Clearing this bit will also blank the display. */
outportb(0x3C0, i);
/* read AC register #i
THIS is the index into the 256-color palette, not 'i' */
j = inportb(0x3C1);
/* set the 256-color palette (DAC) entry. Only the bottom 6 bits of each
R, G, and B entry are significant, so we divide by 4. Change RED, GREEN,
and BLUE to whatever is appropriate for your code. */
outportb(0x3C8, j);
outportb(0x3C9, RED [i] / 4);
outportb(0x3C9, GREEN[i] / 4);
outportb(0x3C9, BLUE [i] / 4);
}
/* set bit b5 in AC address register to lock palette and unblank display */
(void)inportb(0x3DA);
outportb(0x3C0, 0x20);
- Raw text -