From: Chris Holmes Newsgroups: comp.os.msdos.djgpp Subject: Re: color pallete for 256 bits Date: Tue, 10 Aug 1999 07:32:11 -0400 Organization: Georgia Institute of Technology, Atlanta GA, USA Lines: 50 Message-ID: <37B00DBB.375B@surfsouth.com> References: <7op0n6$3lp$1 AT nnrp1 DOT deja DOT com> NNTP-Posting-Host: r69h109.res.gatech.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news-int.gatech.edu 934285153 16831 128.61.69.109 (10 Aug 1999 11:39:13 GMT) X-Complaints-To: usenet AT news DOT gatech DOT edu NNTP-Posting-Date: 10 Aug 1999 11:39:13 GMT X-Mailer: Mozilla 3.04Gold (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com zidharta AT yahoo DOT com wrote: > > when we use color pallete technique in 13h graphics mode ... > (where we set RGB using outport or inport ) > are we really get more colors?... it still 256 bits anyway isnt it? > so why are we using it? ... 256 bits? 256 color modes compose colors by using 3 6 bit (not 8 bit) values (red, green, and blue). Here's the port breakdown for changing the palette: 0x3c6 --> send this 0xff to tell it "hey, I'm using all 256 colors" 0x3c7 --> send this the palette entry (0 to 255) that you want to WRITE 0x3c8 --> send this the palette entry (0 to 255) that you want to READ 0x3c9 --> this is the ONLY color port. You HAVE to either write to it 3 times or read from it 3 times. i.e. to set color 44 to bright white, outportb(0x3c6, 255); outportb(0x3c7, 44); outportb(0x3c9, 63); // set red to highest outportb(0x3c9, 63); // set green to highest outportb(0x3c9, 63); // set blue to highest to read the red, green, and blue values from color 57: outportb(0x3c6, 255); outportb(0x3c8, 57); red = inportb(0x3c9); green = inportb(0x3c9); blue = inportb(0x3c9); BTW, the outportb(0x3c6, 255) isn't totally necessary, but if something swaps out your program from control of the screen, this could get screwed and it's not that many cycles, so unless you're doing something really palette intensive, it shouldn't cost much time and you won't have to worry about your palette just not working right on some machines. Hope this helps, Chris -- I know that I will never be politically correct, and I don't give a damn about my lack of etiquette! -- Meatloaf