QBasic Tip Of the Week



Offensive Screename's Tip #1 (Week September 5-11)

63 Colors in screen 1!

This one's real simple.

All you have to do is use the command PALETTE instead of COLOR. So it'll look like this:

PALETTE 7, colornumber
PRINT "hi"

Put something higher than 15, and see which other colors you can access in screen 1!



New tip next week! Over 16 million colors in screen 13...

Offensive Screename's Tip #2 (Week September 12-18)

63 Over 16 million colors in screen 13

You've learned to make 63 colors in screen 13...Not enough? How about a bijillion colors on screen 13? ;)

This one is kinda tricky to understand if you're a begginer, but it will sink in eventually. Have you ever made a custom color in a program like Paint with RGB values? they same thing can be done in QBasic. Basically, you get control over the graphic card ports with OUT statements, and mix them with certain values...red, green, and blue. So the syntax will look like this:

SCREEN 13
FOR i = 1 to 63
OUT &H3C8, i 'I usually leave this as i.
OUT &H3C9, red 'you'll input a red value, 1-63
OUT &H3C9, green 'green value, one through sixty-three...
OUT &H3C9, blue 'blue value, one through 63..
NEXT

Input random values into red green and blue. Try 13 as a red value, 32 as green, and 27 as blue.

SCREEN 13
FOR i = 1 TO 63
OUT &H3C8, i
OUT &H3C9, 13
OUT &H3C9, 32
OUT &H3C9, 27
LINE (1, 1)-(50, 50), i, BF
NEXT

That'll give you a nice "forest" green color that you couldnt get before...

Now you may be wondering "one through sixty three? But I thought RGB values where 1-255!?" That's true. But since DOS/QB's palette is different, you'll have to divde 255 / 4 for each color. So a good, accurate palette would look like this

SCREEN 12
CLS
'remember, you are now inputting values 1-255!
INPUT "red value: ", r: red = r / 4
INPUT "green value: ", g: green = g / 4
INPUT "blue value: ", b: blue = b / 4
FOR i = 1 TO 63
OUT &H3C8, i
OUT &H3C9, red
OUT &H3C9, green
OUT &H3C9, blue
LINE (1, 1)-(50, 50), i, BF
NEXT

Alright, one last thing. Since you are using OUT statements, you're may want to reset the values to what they originally were. And you may need to do this, because this has actually inverted colors in programs...

FOR i = 1 to 255
OUT &H3C7, i
R = INP (&H3C9)
G = INP (&H3C9)
B = INP (&H3C9)
NEXT i

and that's all...thank you



New tip next week! Now to save palette colors!...Don't worry, it will be the last color tip for a while ;)

Back to mpsoftware...
Hosted by www.Geocities.ws

1