Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!uwm.edu!wuarchive!swbatl!sarek.sbc.com!mh2620 From: mh2620@sarek.sbc.com (Mark Horstman) Newsgroups: comp.windows.ms.programmer Subject: Re: Help setting 16 palette VGA entries Message-ID: <1991May15.133229.22794@swbatl.sbc.com> Date: 15 May 91 13:32:29 GMT References: <108350001@hplred.HP.COM> Sender: mh2620@sarek (Mark Horstman) Reply-To: mh2620@sarek.sbc.com Organization: Southwestern Bell Lines: 55 In article <108350001@hplred.HP.COM>, blackwoo@hplred.HP.COM (Craig Blackwood) writes: > Specifically, I have a VGA card and a driver which supports 16 pure > colors; I want to write directly to the VGA card and have it change > one or more of the palette entries so that I have control over the > displayed color (it is even OK if windows resets the palette when > another application is run.) > > To do this I need to know how to talk directly with the VGA card > AND do this without windows knowing that I have done it. > If you are using the standard VGA driver that comes with Win 3.0 the only way to get all sixteen mode 12 colors is behind Windows back. If you ask Microsoft, the official answer is 'buy the device driver kit for Windows and write your own VGA driver'. I found that unacceptable. With a little help I got around the limitation. I was able to find out that the standard System Palette w/20 colors maps into the 16 VGA mode 12 palette registers (the middle four colors are combinations). Unfortunately they don't map directly (i.e. 1->1, ..., 16->16) but in the following fashion: /* This is really ugly. Each of the standard VGA System Palette * entries don't map intuitively into the VGA palette registers. * Here is how they map out: * * VGAPAL SYSPAL VGAPAL SYSPAL * 00 00 08 07 * 01 01 09 13 * 02 02 10 14 * 03 03 11 15 * 04 04 12 16 * 05 05 13 17 * 06 06 14 18 * 07 12 15 19 */ My application just waits to get a WM_SETFOCUS event, then saves the current state of the hardware colormap and installs the one I want. When I get a WM_KILLFOCUS event I put them back. I tried installing the colormap when the mouse enters my window/client area, and un-installing it when the mouse leaves but I could never tell when the mouse left (WM_NCMOUSEMOVE? only tells you when the mouse moves into YOUR non-client area, not that it just left your window :-( ). Windows never knows whats going on. Don't mess directly with the pallette registers tho', modify the color registers that they point to. Of course this will probably break under the Win 3.1?, but hey, I had a deadline to meet :-). -- Mark Horstman mh2620@sarek.sbc.com Southwestern Bell Telephone St. Louis, MO