BBS: Inland Empire Archive
Date: 07-10-92 (05:51)             Number: 148
From: RICH GELDREICH               Refer#: NONE
  To: PHIL HODGES                   Recvd: NO  
Subj: Re:svga!                       Conf: (2) Quik_Bas
>    Hey, I have a question! I can't figure out how to cycle the bloody
> palette in VGA. I try PALETTE 200, 150 and I get an error. I tried
> figuring out the crypic formulae in the on-line help, and it just
> confused me more! Why can't you just go PALETTE 200, 175 ? How do you
> translate color 175 into ColorNum& ?? What is the meaning of Life, the
> Universe and Everything?! What color would a space chameleon turn?
> Where's my thing? Did Rube Goldberg really design the Macintosh?
>    Seriously, though...

    There's really nothing "bloody" about the VGA's palette. It's just
a little more complicated...

    On the VGA, you've got three primary colors, red, green, and blue.
For each color you can control the intensity, from 0-63. By mixing up
these primary colors in the correct amounts, you can get any color you
    QB's nifty little formula is something like:

    palette index, (red+green*256&+blue*65536&)

    The reason why you have to multiply the green value by 256 and the
blue value by 65536 is simple. QB needs each of the RGB values in one,
easy to handle number(a long integer). A long integer has got 4 bytes,
or 32 bits. The red value goes in the first 8 bits(that's why it isn't
multiplied by anything). The green value goes in the next byte, or 8
bits over(what's 2 to the 8 power? 256!). The blue value goes over
to the next byte, or 16 bits over(2 to the 16th power is 65536).
Actually, that formula can be rewritten to:

    palette index, (red or green*256& or blue*65536&)

    But forget that, I've probably confused you enough as it is!

    There's another way to change the palletes on the VGA(although it's
"naughty"!). It's much, much quicker than using the PALETTE statement.

    Try this:

    OUT &h3c7, index:OUT &h3c8, index 'where index is from 0-255
    OUT &h3c9, Red 'red value, from 0-63
    OUT &h3c9, Green 'gren value, from 0-63
    OUT &h3c9, Blue  'blue value, from 0-63

    That goes directly to the VGA. It runs circles around QB and the
BIOS. Of course, there are people that don't like this way of doing
things. Well, they can go stuff there faces in a toilet because I for
one don't give a damn!

    Hope that helps,

    Rich Geldreich

--- RBBSMAIL 17.2A
 * Origin: Computer Co-Op RBBS HST, 609-784-9404 Voorhees
NJ (RBBS-PC 1:266/29)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET