From: NoEmailAds AT execpc DOT com (Chris Giese) Newsgroups: comp.os.msdos.djgpp Subject: Re: VGA DAC programming Date: Mon, 13 Jan 2003 03:39:42 GMT Organization: PROPULSION GROUP Message-ID: <3e2234ce.1638784@news.voyager.net> References: <10780N882 AT web2news DOT com> <3E20E6CD DOT 470D12B3 AT yahoo DOT com DOT au> <10943N098 AT web2news DOT com> X-Newsreader: Forte Free Agent 1.21/32.243 X-Complaints-To: abuse AT supernews DOT com Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Joel_S" 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);