Qbasic4.5 Codes 02: Set color palette for Screen 13

Discuss popular GCS tools like ZZT, Megazeux and Adventure Game Studio, as well as programming and other topics related to game design.
Post Reply
User avatar
NeonAmd64
Experienced Member
Experienced Member
Posts: 84
Joined: Mon Mar 20, 2006 7:15 pm
Location: Next to you, if not then who

Qbasic4.5 Codes 02: Set color palette for Screen 13

Post by NeonAmd64 »

Here is a code that I programmed as a start for my 3D games in QBasic: B)

Description: The code will generate 7 levels from black to white through the color specified.

Arrays used:

Code: Select all

Rem Here are arrays used to store the colors I thought it would be useful to put
DIM SHARED PAL.COLOR(36, 7) AS INTEGER
DIM SHARED PAL.COLT(36, 7, 3) AS INTEGER
Main Sub routine:

Code: Select all

Rem subroutine for creating the levels[brightness] for the color
SUB D3D.PAL (PAL.NUMBER, PAL.RED, PAL.GREEN, PAL.BLUE)
PAL.COLT(PAL.NUMBER, 4, 1) = (PAL.BLUE / 100) * 63
PAL.COLT(PAL.NUMBER, 4, 2) = (PAL.GREEN / 100) * 63
PAL.COLT(PAL.NUMBER, 4, 3) = (PAL.RED / 100) * 63
PAL.UP.RED = (PAL.RED / 100) * 63
PAL.UP.GREEN = (PAL.GREEN / 100) * 63
PAL.UP.BLUE = (PAL.BLUE / 100) * 63
PAL.DOWN.RED = (PAL.RED / 100) * 63
PAL.DOWN.GREEN = (PAL.GREEN / 100) * 63
PAL.DOWN.BLUE = (PAL.BLUE / 100) * 63
TEMP1 = PAL.DOWN.BLUE
TEMP2 = PAL.DOWN.GREEN
TEMP3 = PAL.DOWN.RED
FOR PAL.C = 3 TO 1 STEP -1
PAL.DOWN.RED = PAL.DOWN.RED - (TEMP3 / 3)
PAL.DOWN.GREEN = PAL.DOWN.GREEN - (TEMP2 / 3)
PAL.DOWN.BLUE = PAL.DOWN.BLUE - (TEMP1 / 3)
PAL.COLT(PAL.NUMBER, PAL.C, 1) = PAL.DOWN.BLUE
PAL.COLT(PAL.NUMBER, PAL.C, 2) = PAL.DOWN.GREEN
PAL.COLT(PAL.NUMBER, PAL.C, 3) = PAL.DOWN.RED
NEXT PAL.C
TEMP1 = PAL.UP.BLUE
TEMP2 = PAL.UP.GREEN
TEMP3 = PAL.UP.RED
FOR PAL.C = 5 TO 7
PAL.UP.RED = PAL.UP.RED + (TEMP3 / 3)
PAL.UP.GREEN = PAL.UP.GREEN + (TEMP2 / 3)
PAL.UP.BLUE = PAL.UP.BLUE + (TEMP1 / 3)
PAL.COLT(PAL.NUMBER, PAL.C, 1) = PAL.UP.BLUE
PAL.COLT(PAL.NUMBER, PAL.C, 2) = PAL.UP.GREEN
PAL.COLT(PAL.NUMBER, PAL.C, 3) = PAL.UP.RED
NEXT PAL.C
FOR PAL.2 = 1 TO 7
PAL.POS = ((PAL.NUMBER * 7) + PAL.2) - 7 + 1
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 1&#41; <= 0 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 1&#41; = 0
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 2&#41; <= 0 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 2&#41; = 0
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 3&#41; <= 0 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 3&#41; = 0
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 1&#41; >= 63 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 1&#41; = 63
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 2&#41; >= 63 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 2&#41; = 63
IF PAL.COLT&#40;PAL.NUMBER, PAL.2, 3&#41; >= 63 THEN PAL.COLT&#40;PAL.NUMBER, PAL.2, 3&#41; = 63
PALETTE PAL.POS, 65536 * PAL.COLT&#40;PAL.NUMBER, PAL.2, 1&#41; + 256 * PAL.COLT&#40;PAL.NUMBER, PAL.2, 2&#41; + PAL.COLT&#40;PAL.NUMBER, PAL.2, 3&#41;
PAL.COLOR&#40;PAL.NUMBER, PAL.2&#41; = &#40;&#40;PAL.NUMBER * 7&#41; + PAL.2&#41; - 7 + 1
NEXT PAL.2
END SUB
Reset sub routine:

Code: Select all

Rem Here is a reset subroutine 
SUB D3D.PAL.RESET
FOR PAL.X = 0 TO 255
PALETTE PAL.X, 0
NEXT PAL.X
END SUB
You can modify the code to suit your needs but I prefer you to program it your self.

If explanation is needed then ask me.. :)

I had created lots of codes during my life and I am happy to share it with you. If you are interested then take it ... and send me at least a small message.. :)

My apology again to the forum for what I had done . . . . . :(
I am living in a black metal and I hope I die for a principle. And of course you still don't know me….
Words are coded in the two sentences above, don't try to decode it.
Post Reply