$if 0
    ķ                        PowerBASIC v3.20
 Ĵ          DASoft          ķ
   Ķ    Copyright 1995     DATE: 1995-10-01 ķ
    FILE NAME   DAC     .TXT           by            
                               Don Schullian, Jr.                      
   ͼ                                          
  A license is hereby granted to the holder to use this source code in   
  any program, commercial or otherwise,  without receiving the express   
  permission of the copyright holder and without paying any royalties,   
  as long as this code is not distributed in any compilable format.      
   IE: source code files, PowerBASIC Unit files, and printed listings    
 ͼ 
                   ....................................                   
   ͼ
$endif

So, you say you don't really like the 16 beautiful, hand-picked colors
you find on your VGA screen! Well, let's fix that. You have 262,144 to
choose from. Of course you can only access 16 at a time,  but at least
you now have a choice.

Each color you see on your screen is a presence of or absence of one or
more of the 3 colors, Red, Green, or Blue.  Each RGB color value can be
from 0 ( none ) to 63 ( full ).  If you have a color that is made up of
63 Red, 0 Green, and 0 Blue then what you see is a very bright pure red
If you have 21R, 21G, 21B then you get what you normally know as DkGrey
or color 8 and, of course 0, 0, 0 is Black! So, the lower the RGB value
the darker the color and  the higher the RGB number the brighter it is.

There are 256 colors or positions in the DAC, and each holds a RGB value.
SCREEN 0 and SCREEN 12 can only access the first 64 of these and they are
what need to be changed in order for PowerBASIC to display all the colors
available.

Now, we are going to run into some trouble with names here, so:
  PALETTE is PowerBASIC's palette number which holds a DAC number
  DAC     is DOS's palette number which holds the RGB values

Think of it like this:
  PowerBASIC has an array with 16 elements      ( 0 -> 15 )
  Each element holds a DAC number               ( 0 -> 63 )
  PALETTE sets the element(s) to the DAC number

Ok, one more time.......
   When you use the COLOR statement it points to
      one of the 16 PALETTE numbers which points to
      one of the 64 available DAC numbers which hold the
      R, G, and B values.

   So..............
      You change the DAC's RGB values in position 62 to 23,00,26
      then tell PALETTE 62, 15 so when you do a COLOR 14,15
      what you get are yellow letters on a purple background

EXAMPLE: CALL DACset( 62, 23, 00, 26 )
         PALETTE 62, 15
         COLOR 14, 15
         CLS
         PRINT "YELLOW LETTERS ON A PURPLE BACKGROUND"

As the DAC is laid out in one long string of BYTE values we use STRINGs
and BYTE arrays to interface with it.

POSs  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015
     
VALs RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBR
     

To address the first 16 DAC positions you could dim an array in either of
these 2 ways.  I prefer the 1st example as it allows me to quickly access
the individual RGB values "by the numbers".

DIM DACvals?( 0:2, 0:15 )   is a handy way or
DIM DACvals?( 1:48 )        will work just as well
DIM DACvals?( 0:2, 0:255 )  will get them all!!!

Everything you need to do all of this is either part of PowerBASIC or
can be found in this library; there's a raft of ready-to-go colors to
get you started.

If you want to do 3D images then you've got to put up with a few more
restrictions because you only have 16 colors to work with and to do 3D
you need 3 variations of each color (except the background) so you are
reduced to 5 normal colors, 5 light colors, and 5 dark colors. But you
will be surprized at just how effective it is when used in graphics!

As you browse through the list of ready-to-go colors in DACdata you'll
notice that I have prepared color sets to get  you started on your own
3D VGA screens.  To draw a box who's light source is in the upper left
corner of the screen you would draw the  top and left borders with the
light color,  the bottom and right borders with the dark color  and the
box itself would be in the normal color. This would make the box appear
to pop-out of the screen! The trick is arranging your colors as we have
in the test program.

Ok, just a quick art lesson here:
   There are 3 true colors:  RED, BLUE, YELLOW
   There are 6 primaries  :  RED, PURPLE, BLUE, GREEN, YELLOW, ORANGE
   PURPLE = RED    & BLUE
   GREEN  = BLUE   & YELLOW
   ORANGE = YELLOW & RED
   BLACK  = ABSENCE OF ALL COLOR    ( Night time, no sun )
   WHITE  = IS THE EQUAL PRESENCE OF ALL OF ALL 3
   GREY   = PRESENCE OF ALL 3 IN VARIING DEGREES

   Each color has a "feel":  BLUE   = Cool, calming
                             YELLOW = Warm, full of life
                             RED    = Hot!, danger, etc.

   On the computer each of the 3 colors RED, GREEN, BLUE can have a value
   of 0 -> 63. The higher the number the "brighter" the color. Each is
   effected by the other. Yellow is true color and only exists on the box
   as a part of GREEN so to get yellow you have to pump in the green then
   use RED to cancel the blue. ??? say what!? Yea, really neat, huh?

   Try to remember these simple rules when designing your programs as
   the colors you use/mix are much more important than you think! To exude
   calm and peace stick to blues and yellows. Go light on the reds. Colors
   effect each other also, don't mix purple and yellow unless you want to
   make someone jump out of his/her skin. Ditto with green and orange.
   Pastels are soft and sleepy. Premieres are REAL good for young children.
   Go forth, now and make Picasso jealous!

That's about as far as we can carry this discussion here.  Other .PBLs
deal with graphic screen and we go into more detail at that time. This
library is just a NUTZnBOLTS unit and not able to deal with it all!

Ahhhhhhhh... just a thought.... there are 64 DAC locations and PB uses
16DAC locations at a shot and 64\16 = 4 and DIM DAC?( 3, 2, 15 ) gives
a total of 64 * 3 holes.....   Good luck & have some fun with these as
they really perk up your programs and make them stand-out from all the
rest, even in TEXT MODE!!

