🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2684

Re: Help setting 16 palette VGA entries

#2684
From: Risto Lankinen
Date: Thu, 16 May 1991 10:01
41 lines
2460 bytes
mh2620@sarek.sbc.com (Mark Horstman) writes:

>        /* 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
>         */

Hi!

Amazingly, the above arrangement makes some sense:

If you viewed the system colors as 0..9,-10..-1 instead of 0..19, then colors
having their sum = -1 are 'opposite', thus a color is inverted by XOR-op.
The above arrangement preserves this property on the indexes of the same
colors, therefore speeding up many graphic operations by not having to invert
the color, but only its index.

When the same colors are assigned to a palette with 256 entries, the index
values used are 0..9 and 246..255, so the property above still holds.  Since
the designers of Windows have chosen to use 20 colors, the 'extra' four have
had to be inserted in the middle of the 'standard' 16 colors.

This doesn't explain the system colors 7 and 12 being exchanged, however.  It
may have something similar to do with palette tables *smaller* than 16 (EGA).

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              3   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 +1 is PRIME!  Now working on 2 -1 *
replies: risto@yj.data.nokia.fi     ***************************************
Technical Details
Message-ID: <1175@tuura.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!rpi!uupsi!sunic!news.funet.fi!fuug!tuura!risto
References: <108350001@hplred.HP.COM> <1991May15.133229.22794@swbatl.sbc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!rpi!uupsi!sunic!news.funet.fi!fuug!tuura!risto
From: risto@tuura.UUCP (Risto Lankinen)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Help setting 16 palette VGA entries
Message-ID: <1175@tuura.UUCP>
Date: 16 May 91 10:01:18 GMT
References: <108350001@hplred.HP.COM> <1991May15.133229.22794@swbatl.sbc.com>
Organization: Nokia Data Systems Oy
Lines: 41