Hi, I have been working through qbasic tutorials provided on petesqbsite (using freebasic though) and have been trying to work things out for myself rather than ask questions for every little thing, but I've finally hit a brick wall. One of the programs in the tutorials teaches about palettes and provides an example to fade the screen to black. I am trying to modify it so it fades to black, then back to the original color again. It works SOME of the time, but other times will not END or will suddenly switch to a random color after the fade-up (the fade to black works fine every time).
Can anybody see anything wrong with my code? I've also posted this on the freebasic forums, I think some of you guys use both, any help is much appreciated!
Cls
Screen 20
Print "Specify a color to fade"
Input Col
Cls
Paint (1, 1), Col
Sleep
Out &H3C7, Col
R = Inp(&H3C9)
G = Inp(&H3C9)
B = Inp(&H3C9)
SR = R
SG = G
SB = B
Do
If R >= 1 Then R = R - 1
If G >= 1 Then G = G - 1
If B >= 1 Then B = B - 1
Out &H3C8, Col
Out &H3C9, R
Out &H3C9, G
Out &H3C9, B
For PAUSE = 1 To 1000000: Next
Loop Until R = 0 And G = 0 And B = 0
Sleep
Do
If R <= SR Then R = R + 1
If G <= SG Then G = G + 1
If B <= SB Then B = B + 1
Out &H3C8, Col 'Go To Port To Write Palette Information
Out &H3C9, R 'Change Red Value to R (our variable)
Out &H3C9, G 'Do the same with Green
Out &H3C9, B 'And with Blue
For PAUSE = 1 To 1000000: Next
Loop Until R = SR And G = SG And B = SB
End