Still here? Great! This is Part 3 of the three part series on using the DAC. In here I'm going to give you a leg-up and drop a few hints and tips that we've come across over the years that make the VGA screen a bit more exciting. The pointers used by PALETTE are not in any sequence so when you use COLOR 8, x, PALETTE points to DAC register 56! This situation is difficult to handle when you want to "do your own thing" so we need to make it a bit more manageable. The easy way is to reset the pointers in PALETTE to be in sequence. This is easily done: FOR C% = 0 TO 15 PALETTE C%, C% NEXT This bit of code alines the 16 pointers to the first 16 DAC registers and, consequently, lines them up with the numbers used by COLOR. The whole thing becomes so simple that it's child's play. This same thing could have been done using PALETTE USING. This routine loads the values (C%) from an array: DIM Pal%(63) FOR V% = 0 TO 63 Pal%(V%) = V% NEXT PALETTE USING Pal%(0) This bit of code would load the first 16 elements of Pal%() into the PALETTE pointers. If you had use PALETTE USING Pal%(16) then elements 16 through 31 would have been used. So, in short, by using PALETTE USING and a few other goodies you could pre-define all 64 DAC registers in four sets of 16 and change the colors on your screen like this: FOR X% = 0 TO 63 STEP 16 PALETTE USING Pal%(X%) DELAY 2 NEXT Down at the bottom of this file is routine called DACcolorDATA that will return the RGB values for 92 colors. If you have a quick look you'll see that most of these colors are in combinations of 3, normal, light and dark. The reason for this is that it requires at least 3 shades of the same color to create a 3D effect. Think of a simple box on SCREEN 12. You draw and fill the box with normal, then draw a line across the top and down the left side with light and across the bottom and down the right side with dark and you have, what looks to be a button popping out of the screen. This is so common place in today's GUI's I know you've seen it but it is extremely difficult to do using the standard 16 colors that come with SCREEN 12. To get the job done easily you need to load you own colors into the DAC. This will could give you 5 color sets and white. If you arrange the color sets properly you can also save yourself another headache. Consider this: %White = 0 %Red = 1 : %LtRed = 6 : %DkRed = 11 %Green = 2 : %LtGreen = 7 : %DkGreen = 12 %Blue = 3 : %LtBlue = 8 : %DkBlue = 13 %Gold = 4 : %LtGold = 9 : %DkGold = 14 %Grey = 5 : %LtGrey = 10 : %DkGrey = 15 (black) If you set your palette pointers to 0 through 15 then load the color values as shown above from the list in DACcolorDATA you have 5 3D color sets and easy access, mathematically, to the light and dark shades of the colors. You could build and call box drawing routines with just one color attribute and it would be able to compute the light and dark attributes quite easily. The little function, below, is in almost every program I've written for several years. It loads my favorite 5 colors and returns the original DAC values so I can restore them before ending the program. FUNCTION fLoad3Dcolor$ () LOCAL PUBLIC LOCAL D$, H$, P% ' WHITE RED GREEN BLUE YELLOW GREY ' ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ D$ = CHR$(63,63,63,55,00,00,00,42,08,00,00,56,63,47,00,36,36,36) +_ CHR$(63,30,30,15,63,15,28,28,63,63,57,21,48,48,48) +_ CHR$(42,00,00,00,24,00,00,00,36,48,30,00,08,08,08) H$ = fDACread$(16) CALL DACwrite( D$ ) FOR P% = 0 TO 15 PALETTE P%, P% NEXT fLoad3Dcolors$ = H$ END FUNCTION This routine will get you started with 3D boxes. The border width is determined by the parameter Depth% and you only need send one color from the "normal" list ( 1 to 5 ). SUB BevelBox( BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, _ BYVAL Colour%, BYVAL Depth% ) LOCAL PUBLIC LOCAL D% LINE ( X1%, Y1% ) - ( X2%, Y2% ), Colour%, BF ' fill the inside FOR D% = 0 TO ( Depth% -1 ) LINE (X1%, Y1% ) - ( X2%, Y1% ), Colour% + 5 ' top row LINE (X1%, Y1% ) - ( X1%, Y2% ), Colour% + 5 ' left side LINE (X1%, Y2% ) - ( X2%, Y2% ), Colour% +10 ' bottom row LINE (X2%, Y1%+1 ) - ( X2%, Y2% ), Colour% +10 ' right side X1% = X1% + 1 : X2% = X2% - 1 ' decrease size Y1% = Y1% + 1 : Y2% = Y2% - 1 ' of the box NEXT END SUB Well, that's about it. You should now be able to take this info and start punching up your VGA screen. Throughout these three tutorials I've concentrated on graphics mode but remember the DAC controls the colors in text mode as well so, have at it! It is against my better judgement but I'm going to mention it anyhow; If you like what you've seen here then I would invite you do d/load my library "Nuts 'n Bolts". The 3D color system is supported by this library and there are some rather good (even if I say so myself;) box drawing routines and a host of ASM routines specifically built for the 386 and SCREEN 12 that will make life a bit easier. As long as you use the routines in the library for yourself it is a freebie. Have fun, Don ____ _ ____ ____ _____ | _ \ / \ / ___) __ | ___)(_ _) | Don Schullian | |_) / _ \ \____\/ \| _) | | | Gramou 33 |____//_/ \_\(____/\__/|_| |_| | Papagou, 15669 ___________________________________ | Greece =================================== | ++30-1-654-6200 Vertical Software Solutions |d83@ath.forthnet.gr ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SUB DACcolorDATA ( BYVAL Colour$, SEG Red%, SEG Green%, SEG Blue% ) LOCAL PUBLIC SELECT CASE UCASE$( Colour$ ) CASE "PURPLE" : Red% = 42 : Green% = 24 : Blue% = 47 CASE "PURPLEL" : Red% = 57 : Green% = 18 : Blue% = 63 CASE "PURPLED" : Red% = 23 : Green% = 00 : Blue% = 26 CASE "FUCHSIA" : Red% = 63 : Green% = 00 : Blue% = 49 CASE "FUCHSIAL" : Red% = 63 : Green% = 24 : Blue% = 49 CASE "FUCHSIAD" : Red% = 42 : Green% = 00 : Blue% = 36 CASE "PINK" : Red% = 63 : Green% = 33 : Blue% = 49 CASE "PINKL" : Red% = 63 : Green% = 38 : Blue% = 49 CASE "PINKD" : Red% = 60 : Green% = 22 : Blue% = 38 CASE "LAVENDER" : Red% = 63 : Green% = 21 : Blue% = 63 CASE "LAVENDERL" : Red% = 63 : Green% = 33 : Blue% = 63 CASE "LAVENDERD" : Red% = 31 : Green% = 00 : Blue% = 31 CASE "DASRED" : Red% = 55 : Green% = 00 : Blue% = 00 CASE "DASREDL" : Red% = 63 : Green% = 30 : Blue% = 30 CASE "DASREDD" : Red% = 42 : Green% = 00 : Blue% = 00 CASE "DASGREEN" : Red% = 00 : Green% = 42 : Blue% = 08 CASE "DASGREENL" : Red% = 15 : Green% = 63 : Blue% = 15 CASE "DASGREEND" : Red% = 00 : Green% = 24 : Blue% = 00 CASE "DASBLUE" : Red% = 00 : Green% = 00 : Blue% = 56 CASE "DASBLUEL" : Red% = 28 : Green% = 28 : Blue% = 63 CASE "DASBLUED" : Red% = 00 : Green% = 00 : Blue% = 36 CASE "DASGOLD" : Red% = 63 : Green% = 47 : Blue% = 00 CASE "DASGOLDL" : Red% = 63 : Green% = 57 : Blue% = 21 CASE "DASGOLDD" : Red% = 48 : Green% = 30 : Blue% = 00 CASE "DASGREY" : Red% = 36 : Green% = 36 : Blue% = 36 CASE "DASGREYL" : Red% = 48 : Green% = 48 : Blue% = 48 CASE "DASGREYD" : Red% = 08 : Green% = 08 : Blue% = 08 CASE "GREY" : Red% = 36 : Green% = 36 : Blue% = 36 CASE "GREYL" : Red% = 48 : Green% = 48 : Blue% = 48 CASE "GREYD" : Red% = 08 : Green% = 08 : Blue% = 08 CASE "BLUE" : Red% = 00 : Green% = 00 : Blue% = 42 CASE "BLUEL" : Red% = 15 : Green% = 63 : Blue% = 42 CASE "BLUED" : Red% = 00 : Green% = 00 : Blue% = 32 CASE "PSBLUE" : Red% = 21 : Green% = 42 : Blue% = 63 CASE "PSBLUEL" : Red% = 33 : Green% = 49 : Blue% = 63 CASE "PSBLUED" : Red% = 28 : Green% = 28 : Blue% = 63 CASE "POWDER" : Red% = 00 : Green% = 23 : Blue% = 63 CASE "POWDERL" : Red% = 00 : Green% = 35 : Blue% = 63 CASE "POWDERD" : Red% = 00 : Green% = 00 : Blue% = 56 CASE "GREEN" : Red% = 00 : Green% = 42 : Blue% = 00 CASE "GREENL" : Red% = 15 : Green% = 63 : Blue% = 15 CASE "GREEND" : Red% = 00 : Green% = 32 : Blue% = 00 CASE "BRGREEN" : Red% = 00 : Green% = 52 : Blue% = 00 CASE "BRGREENL" : Red% = 00 : Green% = 63 : Blue% = 00 CASE "BRGREEND" : Red% = 00 : Green% = 37 : Blue% = 00 CASE "PSGREEN" : Red% = 00 : Green% = 63 : Blue% = 42 CASE "PSGREENL" : Red% = 46 : Green% = 63 : Blue% = 23 CASE "PSGREEND" : Red% = 00 : Green% = 48 : Blue% = 26 CASE "CYAN" : Red% = 00 : Green% = 42 : Blue% = 42 CASE "CYANL" : Red% = 00 : Green% = 52 : Blue% = 52 CASE "CYAND" : Red% = 00 : Green% = 32 : Blue% = 32 CASE "BRCYAN" : Red% = 00 : Green% = 52 : Blue% = 52 CASE "BRCYANL" : Red% = 23 : Green% = 63 : Blue% = 63 CASE "BRCYAND" : Red% = 00 : Green% = 36 : Blue% = 36 CASE "RED" : Red% = 42 : Green% = 00 : Blue% = 00 CASE "REDL" : Red% = 63 : Green% = 30 : Blue% = 30 CASE "REDD" : Red% = 32 : Green% = 00 : Blue% = 00 CASE "BRRED" : Red% = 63 : Green% = 00 : Blue% = 00 CASE "BRREDL" : Red% = 63 : Green% = 30 : Blue% = 30 CASE "BRREDD" : Red% = 42 : Green% = 00 : Blue% = 00 CASE "DKRED" : Red% = 36 : Green% = 00 : Blue% = 00 CASE "DKREDL" : Red% = 46 : Green% = 00 : Blue% = 00 CASE "DKREDD" : Red% = 24 : Green% = 00 : Blue% = 00 CASE "MAGENTA" : Red% = 42 : Green% = 00 : Blue% = 42 CASE "MAGENTAL" : Red% = 54 : Green% = 00 : Blue% = 54 CASE "MAGENTAD" : Red% = 32 : Green% = 00 : Blue% = 32 CASE "BROWN" : Red% = 42 : Green% = 21 : Blue% = 11 CASE "BROWNL" : Red% = 53 : Green% = 32 : Blue% = 22 CASE "BROWND" : Red% = 32 : Green% = 11 : Blue% = 00 CASE "DKGREY" : Red% = 21 : Green% = 21 : Blue% = 21 CASE "LTBLUE" : Red% = 21 : Green% = 21 : Blue% = 63 CASE "LTGREEN" : Red% = 21 : Green% = 63 : Blue% = 21 CASE "LTCYAN" : Red% = 21 : Green% = 63 : Blue% = 63 CASE "LTRED" : Red% = 63 : Green% = 21 : Blue% = 21 CASE "LTMAGENTA" : Red% = 63 : Green% = 21 : Blue% = 63 CASE "WHITE" : Red% = 63 : Green% = 63 : Blue% = 63 CASE "YELLOW" : Red% = 63 : Green% = 63 : Blue% = 00 CASE "YELLOWL" : Red% = 63 : Green% = 63 : Blue% = 32 CASE "YELLOWD" : Red% = 48 : Green% = 46 : Blue% = 00 CASE "GOLD" : Red% = 57 : Green% = 44 : Blue% = 00 CASE "GOLDL" : Red% = 63 : Green% = 50 : Blue% = 23 CASE "GOLDD" : Red% = 47 : Green% = 34 : Blue% = 00 CASE "COPPER" : Red% = 63 : Green% = 44 : Blue% = 00 CASE "COPPERL" : Red% = 63 : Green% = 49 : Blue% = 12 CASE "COPPERD" : Red% = 50 : Green% = 30 : Blue% = 00 CASE "DKGOLD" : Red% = 56 : Green% = 42 : Blue% = 00 CASE "DKGOLDL" : Red% = 63 : Green% = 49 : Blue% = 12 CASE "DKGOLDD" : Red% = 44 : Green% = 30 : Blue% = 00 CASE "ORANGE" : Red% = 63 : Green% = 24 : Blue% = 00 CASE "ORANGEL" : Red% = 63 : Green% = 35 : Blue% = 10 CASE "ORANGED" : Red% = 45 : Green% = 16 : Blue% = 00 CASE ELSE : Red% = 00 : Green% = 00 : Blue% = 00 ' BLACK END SELECT END SUB