'PROG : PALETTE.BAS 'SENDER : MOHAMMAD SUSLI(abionnnn) 'SIZE : 4K 'SUBJECT : HOW TO DO GOOD VGA PALETTE ! 'In this program/tutorial I will show you how to program with 'Palette in VGA . If you have used it before and all you get is red, 'then this tutorial would help . VGA is deiffrent to EGA (Mode 9&7) 'EGA only contains 63 preset colours(In Australia we spell it with 'a u) while VGA can handel 16-bit colours but only 256 colours at 'a time! 'The QuickBasic Tutorial says: 'The VGA uses a different way of calculating color values from the 'EGA. To calculate a color value, select the intensities of red, green, 'and blue. The intensity of a color is a number from 0 (low intensity) 'to 63 (high intensity). Then use the following formula to calculate 'the actual color number: ' color number = 65536 * blue + 256 * green + red 'Because there are gaps in the range of color numbers, you should use 'the formula rather than just select a number. 'When used with the IBM Analog Monochrome Monitor, the VGA color values 'are converted to a gray-scale value by taking a weighted sum of the 'red, blue, and green intensities: ' gray value = 11% blue + 59% green + 30% red 'For example if the blue, green, and red intensities are 45, 20, and '20, the gray value would be .11*45+.59*20+.30*20 or 22 (the fraction 'in the result is dropped). 'OK then we will use the formula and yes it does work! SCREEN 13 'For the first example we will use mode 13 Blue = 24 Green = 32 FOR i% = 1 TO 60 'We will only go through 60 Red = i% 'Colours (note blue and green PALETTE i%, 65536 * Blue + 256 * Green + Red 'Are fixed!) NEXT i% PRINT "PRESS ANY KEY TO SHOW COLOURS ...." DO WHILE INKEY\$ = "": LOOP FOR i% = 1 TO 60 'Here I simple drew big squares LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF 'To show each colours NEXT i% PRINT "PRESS ANY KEY TO RESET COLOURS ...." DO WHILE INKEY\$ = "": LOOP PALETTE 'So we tried Mode 13 what about Mode 12 ? Well Mode 12 has 1 dis-advantage, 'only 16 colours! But that is enough to deminstrate ! Agian we will use the 'same formula . CLS SCREEN 12 Blue = 30 Green = 10 FOR i% = 1 TO 15 'Here we used diffrent Red = i% 'setting , but for only PALETTE i%, 65536 * Blue + 256 * Green + Red '15 colours! NEXT i% PRINT "PRESS ANY KEY TO SHOW COLOURS ...." DO WHILE INKEY\$ = "": LOOP FOR i% = 1 TO 15 'screen 12 is very clear LINE (i% * 10, 100)-(i% * 10 + 10, 110), i%, BF 'and used more and more NEXT i% 'in programs. PRINT "PRESS ANY KEY TO RESET COLOURS ...." DO WHILE INKEY\$ = "": LOOP PALETTE 'Now we will use a formula that is better , one which would make plane colours 'not a mixture of them ! The formula we use is very simple : 'Colour = Colour_Integer * Intensities 'Colour Integer is what Colour you want it can be one of these : '1 : Red '256 : Green '257 : Yellow '65536 : Blue '65537 : Purple CLS SCREEN 13 Red = 1 Green = 256 Yellow = 257 Blue = 65536 Purple = 65537 FOR Intensin% = 1 TO 60 PALETTE Intensin%, Red * Intensin% NEXT Intensin% PRINT "PRESS ANY KEY TO SHOW RED COLOURS" DO WHILE INKEY\$ = "": LOOP FOR i% = 1 TO 60 LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF NEXT i% PRINT "PRESS ANY KEY TO SHOW GREEN COLOURS" DO WHILE INKEY\$ = "": LOOP FOR Intensin% = 1 TO 60 PALETTE Intensin%, Green * Intensin% NEXT Intensin% FOR i% = 1 TO 60 LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF NEXT i% PRINT "PRESS ANY KEY TO SHOW YELLOW COLOURS" DO WHILE INKEY\$ = "": LOOP FOR Intensin% = 1 TO 60 PALETTE Intensin%, Yellow * Intensin% NEXT Intensin% FOR i% = 1 TO 60 LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF NEXT i% PRINT "PRESS ANY KEY TO SHOW BLUE COLOURS" DO WHILE INKEY\$ = "": LOOP FOR Intensin% = 1 TO 60 PALETTE Intensin%, Blue * Intensin% NEXT Intensin% FOR i% = 1 TO 60 LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF NEXT i% PRINT "PRESS ANY KEY TO SHOW PURPLE COLOURS" DO WHILE INKEY\$ = "": LOOP FOR Intensin% = 1 TO 60 PALETTE Intensin%, Purple * Intensin% NEXT Intensin% FOR i% = 1 TO 60 LINE (i% * 2, 100)-(i% * 2 + 1, 102), i%, BF NEXT i% 'Now you now what to do , you are probebly thinking , what the hell can I do 'with this ? Well many things you can make games with striking colour by using 'this! Or other things that I can't think of! Well I'll leave you to it! 'I can be reached at : 'abionnnn@geocities.com , abionnnn@hotmail.com , 'hhrxmx@echidna.stu.cowan.edu.au 'My Homepage is at : 'http://www.geocities.com/ResearchTriangle/3561/ 'If you need any help just drop me an e-mail !