DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


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

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation
Author Message
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Sat Apr 08, 2006 4:01 am     Post subject: Qbasic4.5 Codes 02: Set color palette for Screen 13 Reply with quote

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

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

Arrays used:

Code:
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:
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(PAL.NUMBER, PAL.2, 1) <= 0 THEN PAL.COLT(PAL.NUMBER, PAL.2, 1) = 0
IF PAL.COLT(PAL.NUMBER, PAL.2, 2) <= 0 THEN PAL.COLT(PAL.NUMBER, PAL.2, 2) = 0
IF PAL.COLT(PAL.NUMBER, PAL.2, 3) <= 0 THEN PAL.COLT(PAL.NUMBER, PAL.2, 3) = 0
IF PAL.COLT(PAL.NUMBER, PAL.2, 1) >= 63 THEN PAL.COLT(PAL.NUMBER, PAL.2, 1) = 63
IF PAL.COLT(PAL.NUMBER, PAL.2, 2) >= 63 THEN PAL.COLT(PAL.NUMBER, PAL.2, 2) = 63
IF PAL.COLT(PAL.NUMBER, PAL.2, 3) >= 63 THEN PAL.COLT(PAL.NUMBER, PAL.2, 3) = 63
PALETTE PAL.POS, 65536 * PAL.COLT(PAL.NUMBER, PAL.2, 1) + 256 * PAL.COLT(PAL.NUMBER, PAL.2, 2) + PAL.COLT(PAL.NUMBER, PAL.2, 3)
PAL.COLOR(PAL.NUMBER, PAL.2) = ((PAL.NUMBER * 7) + PAL.2) - 7 + 1
NEXT PAL.2
END SUB


Reset sub routine:

Code:
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.. Happy

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.. Happy

My apology again to the forum for what I had done . . . . . Sad
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 
Free Windows games


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)