=========================================================================== BBS: The Abacus * HST/DS * Potterville MI Date: 05-09-93 (14:14) Number: 6 From: EARL MONTGOMERY Refer#: 129 To: NELSON REMMLER Recvd: NO Subj: Palette Conf: (35) Quick Basi --------------------------------------------------------------------------- REM I hope this demo helps explain the VGA palette registers REM and graphic ports. This is the way I understand it and REM it works for me. REM Press the R key to increase RED. G key to increase GREEN REM and the B key to increase BLUE. Press the P key to read REM the RGB values directly from the VGA graphic ports. DEFINT A-Z: SCREEN 13: COLOR 142 LINE (0, 10)-(319, 50), , BF LOCATE 9, 15: COLOR 22: PRINT "Red Grn Blu"; print1: LOCATE 10, 15: PRINT r; : LOCATE 10, 19: PRINT g; LOCATE 10, 23: PRINT b; WAIT1: i$ = INKEY$ IF i$ = "" THEN GOTO WAIT1 i$ = UCASE$(i$) IF i$ = "R" THEN r = r + 1 IF i$ = "G" THEN g = g + 1 IF i$ = "B" THEN b = b + 1 IF i$ = "P" THEN GOTO CURRENTPALETTE IF r > 63 THEN r = 0 IF g > 63 THEN g = 0 IF b > 63 THEN b = 0 OUT &H3C8, 142 REM Sending color value 142 (color of box) to VGA graphic port REM &H3C8. This port now contains the color value we want to REM work with. OUT &H3C9, r: OUT &H3C9, g: OUT &H3C9, b REM VGA graphic port &H3C9 contains the palette info for REM RED GREEN and BLUE for the current color which was set REM with the out to &H3C8. The first out sets the RED value REM the second out the GREEN value and the 3rd out the REM BLUE value. GOTO print1 CURRENTPALETTE: OUT &H3C7, 142 FOR x = 1 TO 3 p(x) = INP(&H3C9) NEXT REM OUT &H3C7,142 says in effect "I want to read the value REM for color 142. REM The FOR-NEXT loop reads the INP from graphic port &H3C9 REM and the first read gives us the RED value, the second REM the Green value and the third the Blue value. LOCATE 16, 1 PRINT "Palette info from CURRENTPALETTE:" LOCATE 18, 1 PRINT "Red ", p(1) LOCATE 20, 1 PRINT "Green ", p(2) LOCATE 22, 1 PRINT "Blue ", p(3) LOCATE 13, 7 PRINT "Press any key to continue." WAIT2: i$ = INKEY$ IF i$ = "" THEN GOTO WAIT2 END IF LOCATE 13, 1 PRINT " " LOCATE 16, 1 PRINT " " LOCATE 18, 1 PRINT " " LOCATE 20, 1 PRINT " " LOCATE 22, 1 PRINT " " GOTO WAIT1 'Earl --- Maximus 2.01wb * Origin: Rabbit and Snake's BBS - Richardson, Texas (1:124/6108) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 575 950 203/23 209/209 SEEN-BY: 261/1023 280/1 390/1 396/1 15 397/2 2230/100 2440/5 3603/20