In SCREEN 12, I tried to modify the RGB values of the displayed colors
using Interrupt &H10, as such modifications seem not to be possible
with the PALETTE statement. But I discovered that the color numbers
used by the Interrupt services were not identical with the color numbers
used by PowerBasic. To verify this, I wrote a small test program which
is reproduced below. I found that color numbers 0 to 5 and 7 were
identical, but in order to change the color no.6, I had to input 20
(decimal), and for changing colors 8 to 15, I had to input numbers
from 56 to 63.
This anomaly occurred only when setting the screen mode with the SCREEN
statement, but not in a similar program which sets the screen mode via
Interrupt &H10, (In that case, of course, the graphics statements like
LINE, PAINT, etc. are not available.) Neither did it occur in QuickBasic,
only in PowerBasic.
Now my question: Is this anomaly inherent to PowerBasic, so that it
will produce the same results on all VGA systems, or might it depend on
the BIOS type, the video card, or some other factor beyond my control?
I would like to implement palette changes in a program, but I need to
be sure it will not produce unexpected results on different systems.
Hans Ruegg
'=========== TEST PROGRAM "BLINK" ================
'Lets the user input a color index and lets the corresponding
'color blink for half a second.
'Input of a negative index will terminate the program.
SCREEN 12
GOSUB displayColors
DO
GOSUB changeColor
LOOP UNTIL indx%<0
SCREEN 0
END
displayColors: 'display squares in all 16 colors
FOR row%=0 TO 3: FOR colu%=0 TO 3
cl% = 4*row%+colu%
LINE (48*colu%, 48*row%)-(48*colu%+45, 48*row%+45), cl%, BF
LOCATE 3*row%+2, 6*colu%+3: PRINT TRIM$(STR$(cl%));
NEXT colu%: NEXT row%
RETURN
changeColor:
LOCATE 25,1: PRINT "No. to change: "
LOCATE 25,15: INPUT indx%
IF indx%<0 THEN RETURN
blink indx%
RETURN
'=============================================================
SUB blink (ind%)
'Lets the color no. ind% blink for half a second in its opposite color
getDAC ind%, red%, green%, blue%
putDAC ind%, red% XOR 63, green% XOR 63, blue% XOR 63
t!=TIMER
DO: LOOP UNTIL TIMER>t!+0.5
putDAC ind%, red%, green%, blue%
END SUB
SUB putDAC (ind%, red%, green%, blue%)
'Sets new RGB values in the VGA palette for color no. ind%
REG 1, &H1010
REG 2, ind%
REG 3, 256*green% + blue%
REG 4, 256*red%
CALL INTERRUPT &H10
END SUB
SUB getDAC (ind%, red%, green%, blue%)
'Retrieves the RGB values of the current VGA palette for color no. ind%
REG 1, &H1015
REG 2, ind%
CALL INTERRUPT &H10
gb% = REG(3)
green% = gb%\256: blue% = gb% AND 255
red% = REG(4)\256
END SUB
'============================================================
using Interrupt &H10, as such modifications seem not to be possible
with the PALETTE statement. But I discovered that the color numbers
used by the Interrupt services were not identical with the color numbers
used by PowerBasic. To verify this, I wrote a small test program which
is reproduced below. I found that color numbers 0 to 5 and 7 were
identical, but in order to change the color no.6, I had to input 20
(decimal), and for changing colors 8 to 15, I had to input numbers
from 56 to 63.
This anomaly occurred only when setting the screen mode with the SCREEN
statement, but not in a similar program which sets the screen mode via
Interrupt &H10, (In that case, of course, the graphics statements like
LINE, PAINT, etc. are not available.) Neither did it occur in QuickBasic,
only in PowerBasic.
Now my question: Is this anomaly inherent to PowerBasic, so that it
will produce the same results on all VGA systems, or might it depend on
the BIOS type, the video card, or some other factor beyond my control?
I would like to implement palette changes in a program, but I need to
be sure it will not produce unexpected results on different systems.
Hans Ruegg
'=========== TEST PROGRAM "BLINK" ================
'Lets the user input a color index and lets the corresponding
'color blink for half a second.
'Input of a negative index will terminate the program.
SCREEN 12
GOSUB displayColors
DO
GOSUB changeColor
LOOP UNTIL indx%<0
SCREEN 0
END
displayColors: 'display squares in all 16 colors
FOR row%=0 TO 3: FOR colu%=0 TO 3
cl% = 4*row%+colu%
LINE (48*colu%, 48*row%)-(48*colu%+45, 48*row%+45), cl%, BF
LOCATE 3*row%+2, 6*colu%+3: PRINT TRIM$(STR$(cl%));
NEXT colu%: NEXT row%
RETURN
changeColor:
LOCATE 25,1: PRINT "No. to change: "
LOCATE 25,15: INPUT indx%
IF indx%<0 THEN RETURN
blink indx%
RETURN
'=============================================================
SUB blink (ind%)
'Lets the color no. ind% blink for half a second in its opposite color
getDAC ind%, red%, green%, blue%
putDAC ind%, red% XOR 63, green% XOR 63, blue% XOR 63
t!=TIMER
DO: LOOP UNTIL TIMER>t!+0.5
putDAC ind%, red%, green%, blue%
END SUB
SUB putDAC (ind%, red%, green%, blue%)
'Sets new RGB values in the VGA palette for color no. ind%
REG 1, &H1010
REG 2, ind%
REG 3, 256*green% + blue%
REG 4, 256*red%
CALL INTERRUPT &H10
END SUB
SUB getDAC (ind%, red%, green%, blue%)
'Retrieves the RGB values of the current VGA palette for color no. ind%
REG 1, &H1015
REG 2, ind%
CALL INTERRUPT &H10
gb% = REG(3)
green% = gb%\256: blue% = gb% AND 255
red% = REG(4)\256
END SUB
'============================================================
Comment