Hi, This is Part 1 of a three part series on using the DAC registers to create and use thousands of colors. Trying to figure out what is going on with COLOR, PALETTE and the DAC can be a bit confusing. Hopefully I'll be able to shed a bit of light on the subject here. As this document is aimed at FirstBASIC and PowerBASIC I will be using SCREEN 12 (color VGA) as a reference. So, as you already know, there are 16 colors available to this screen but by using PALETTE you can select between 64 colors as to which 16 will be used. But, by changing the RGB values in the DAC registers you can actually have thousands of colors to choose from. You can still only access 16 of them at a time, but you may be amazed at what can be done with these few colors if you apply a bit of "magic". Let's back up here a minute and explore the commands/functions in PowerBASIC. COLOR uses numbers from 0 to 15. We'll call these numbers "colors" and they point to the palette. PALETTE can use numbers from 0 to 63 and we'll call these numbers "registers" as they point to the 64 DAC registers. As you can see, getting colors onto the screen is a three step process. COLOR points to PALETTE and PALETTE points to the DAC but as you can change the values in the DAC, well, you see what I mean. The DAC is a series of 64 registers with each register containing a triplet of bytes; Red, Green, and Blue. Each of these numbers can have a value from 0 to 63 with 0 being the complete absence of that particular element and 63 being the maximum presence. When these three elements are mixed they create all the thousands of available colors. If all three elements are set to 0 you have an absence of all color, hence BLACK. Conversely, if all three are set to 63 you have the presence of all colors, namely WHITE. If all three have the same value you have varying degrees of GRAY. ( 21,21,21 is DkGray like you get when you use COLOR 8, x) Theoretically, if you assign an element a value of 1 then you have that color (let's take Red). You set the DAC register to 1,0,0 then print a string. What you will see on your monitor is ! (or, at least, precious little). The reason for this is that "1", even though it is "red" is so close to BLACK that most monitors can't display it visibly. What we need to do is pump-up the power a bit. Change that one to 21 and and you'll get a very dark red. So, not only do you have control over the combinations of RGB but you can also declare in what proportions each is used. Art students learn that there are only 3 basic colors: Red, Blue, and Yellow. Mixing any two of these in equal amounts produce three more colors Purple (Red & Blue), Green (Yellow & Blue), and Orange (Red & Blue). Black is the absence of all color, White is the presence of all color and the 150 Greys are created using different proportions of the three basic colors. This works well when mixing paint but falls a bit short on RGB monitors. In the RGB world there are a new set of rules: BLACK = 00, 00, 00 WHITE = 63, 63, 63 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ RED = 63, 00, 00 CYAN = 00, 63, 63 GREEN = 00, 63, 00 MAGENTA = 63, 00, 63 BLUE = 00, 00, 63 YELLOW = 63, 63, 00 L.GREY = 42, 42, 42 D.GREY = 21, 21, 21 Get the idea? If, when creating new colors, you start with one of these and modify the element(s) that are zeroed out, you'll be able to create any number of colors. Then, if you want it darker, decrease the value of all three elements by an equal number. If this all sounds too difficult, you may be right! Creating does NOT come easily and requires a lot of time and patience. If you mix your RGB values wrong you end up with a muddy looking blob on your screen! Many times you need only adjust one of the three elements to bring out the beauty in a hue. It's basically an educated game of trial and error so, brew another pot of coffee and get settled 'cause you'll be spending some time in front of the monitor if you're going to create new colors. On the other hand, the final effects of your efforts may well be worth that all the extra work involved. In Part 2 you'll find all the basic tools you'll need to create your new palette of colors. ____ _ ____ ____ _____ | _ \ / \ / ___) __ | ___)(_ _) | Don Schullian | |_) / _ \ \____\/ \| _) | | | Gramou 33 |____//_/ \_\(____/\__/|_| |_| | Papagou, 15669 ___________________________________ | Greece =================================== | ++30-1-654-6200 Vertical Software Solutions |d83@ath.forthnet.gr