Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the default of PALETTE?

Status
Not open for further replies.

Aron1

Programmer
Mar 19, 2003
11
0
0
HU
Please help me!

I have used in my program the PALETTE and all the colours have gone mad.

I want the colours back. so I need the default of the PALETTE.

If you can help me, please write to this forum.

Thank you very much!!!
 
i don't know how to change the pallete back to the original one but if you were gonna change the pallete back and forth you should save the original pallete and then after you change it save that pallete so you can load up the different pallets without having to go in and change them every time
 
You can find the approximate colors (may be a little difference) by using an html file to display the
various colors as background colors, then playing with
palette until you get a close match.

<html>
<body>
<table><tr><td bgcolor=cyan><font color=black>cyan background</font></td></tr>

</table>
</body>
</html>
 
actually, I'm pretty sure the original colors can be restored by using the PALETTE command with no parameters.

If you want to manipulate the palette, and you're in SCREEN 13, I suggest you use the much faster way doing this:
OUT &H3C8, palIndex
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b

I know it looks weird, but it writes directly to the VGA palette ports producing slick fast code :) -----------------------
Soon to come - a QBasic contest forum!
-----------------------
 
I found this in my old archived bas folder...use Palette without any parameters to restore it to it's original settings:


SCREEN 13 'using #13 cause it has 256 attributes
'and each attribute can be manipulated to a specific color
'see help on Palette (# to chg, intensity of RGBs)
CLS

PALETTE 250, 65536 * 63 + 256 * 0 + 63 'store Purple at #250 for use in
'a color statment below...

FOR I = 0 TO 63 'intensity = 0 (min) to 63 (max)
PALETTE 16 + I, 65536 * I + 256 * 0 'using #16+ to store colors,
LINE (0, 0 + I)-(300, 0 + I), 16 + I ' note I = 16 + I --to record
'LINE (0, 64 + I)-(319, 64 + I), 16 + I ' at palette #(16+I)
CIRCLE (100, 100), 0 + I, 16 + I
NEXT I

LOCATE 20, 1
COLOR 250 'use #250 (Purple) color from above
PRINT &quot; this is a text message in purple for 4 seconds&quot;
SLEEP 4

FOR I = 63 TO 0 STEP -1
LOCATE 20, 1
COLOR 16 + I 'use colr stord @ #16+I and up to
'fade the line
PRINT &quot; now blacking this line out...please wait &quot;
FOR slowdown = 1 TO 30000: NEXT slowdown
NEXT I

'the following code shows that I'm replacing the above manupliated color with
'red at palette #16+I(+) so any pix using that palette # will change with it
'instantly.
FOR I = 63 TO 0 STEP -1
PALETTE 16 + I, 65536 * 13 + 256 * 0 + I
FOR slowdown = 1 TO 30000: NEXT slowdown
NEXT I
SLEEP 4

COLOR 15
FOR x1 = 2 TO 100
FOR y1 = 2 TO 65
CrntX = POINT(x1, y1)
LOCATE 20, 1
PRINT &quot;color at &quot;; STR$(x1); &quot;,&quot;; STR$(y1); &quot; is &quot;; CrntX
PRINT &quot;Changing color now to white&quot;
'FOR slowdown = 1 TO 50000: NEXT slowdown
PSET (x1, y1), 15
NEXT
NEXT

[red]palette[/red]

print &quot;wasn't that fun?&quot;


HTH.
--MiggyD
 
Here is how I handled it in my static program:

SCREEN 13
DIM red(255), green(255), blue(255)
start.x = 0
end.x = 320
start.y = 0
end.y = 200
time = 1000
FOR changepalete = 1 TO 255

OUT &H3C7, changepalete
red(changepalete) = INP(&H3C9)
green(changepalete) = INP(&H3C9)
blue(changepalete) = INP(&H3C9)
'^These lines save the color settings.^

rndcolor = RND * 63
OUT &H3C8, changepalete
OUT &H3C9, rndcolor
OUT &H3C9, rndcolor
OUT &H3C9, rndcolor
'^These lines change the palete colors.^
NEXT changepalete
DEF SEG = &HA000
FOR Y = start.y TO end.y
FOR X = start.x TO end.x
POKE Y * 320& + X, INT(RND * 255) + 1
NEXT X
NEXT Y
DEF SEG
FOR timed = 1 TO time
FOR statics = 1 TO 255
coloring = RND * 63
OUT &H3C8, statics
OUT &H3C9, coloring
OUT &H3C9, coloring
OUT &H3C9, coloring
NEXT statics
NEXT timed
LINE (start.x, start.y)-(end.x, end.y), 0, BF

FOR fixpalette = 1 TO 255
OUT &H3C8, fixpalette
OUT &H3C9, red(fixpalette)
OUT &H3C9, green(fixpalette)
OUT &H3C9, blue(fixpalette)
NEXT fixpalette
'^These lines fix the palette.^
 
You really don't have to waste the memory like that. A simple PALETTE call will suffice. -----------------------
Soon to come - a QBasic contest forum!
-----------------------
 
Unless you're going to flip palettes around every 1/30th of a second, I don't see why you'd waste so much memory... -----------------------
Soon to come - a QBasic contest forum!
-----------------------
 
Ninkazu is right, you can set the palette back by using the command without any parameters.
 
Ok... Say you want to fade to the original colors...
You need to use a Routine similar to quebasic2's

PALETTE is SLOW

Here is a little program I made a second ago...


Code:
DECLARE SUB PALFADE (PSRC() AS ANY, PDST() AS ANY)
DECLARE SUB PALGET (C%, R%, G%, B%)
DECLARE SUB PALSET (C%, R%, G%, B%)
DEFINT A-Z
TYPE PALTYPE
  R AS INTEGER
  G AS INTEGER
  B AS INTEGER
END TYPE

DIM PAL1(255) AS PALTYPE
DIM PAL2(255) AS PALTYPE

SCREEN 13

FOR C = 0 TO 255
   PALGET C, PAL1(C).R, PAL1(C).G, PAL1(C).B
   SELECT CASE (C \ 63)
     CASE 0
       PAL2(C).R = C MOD 63
     CASE 1
       PAL2(C).G = C MOD 63
     CASE 2
       PAL2(C).B = C MOD 63
     CASE 3
       PAL2(C).R = C MOD 63
       PAL2(C).G = C MOD 63
       PAL2(C).B = C MOD 63
   END SELECT
NEXT

FOR Y = 0 TO 19
  FOR X = 0 TO 31
    LINE (X * 10, Y * 10)-(X * 10 + 9, Y * 10 + 9), C, BF
    C = (C + 1) MOD 256
  NEXT
NEXT

A$ = INPUT$(1)

PALFADE PAL1(), PAL2()

A$ = INPUT$(1)

PALFADE PAL2(), PAL1()

SUB PALFADE (PSRC() AS PALTYPE, PDST() AS PALTYPE)
'PALETTE FADE SUB BY JOSH STRIBLING  4-14-03

'SETUP
  DIM TEMP(255, 2) AS SINGLE
'FACTOR IS THE FADE STEPS (2 TO 255)
  FACTOR = 255

'PRECALCULATE THE DIVISION
  FOR C = 0 TO 255
    TEMP(C, 0) = (PDST(C).R - PSRC(C).R) / FACTOR
    TEMP(C, 1) = (PDST(C).G - PSRC(C).G) / FACTOR
    TEMP(C, 2) = (PDST(C).B - PSRC(C).B) / FACTOR
  NEXT

'FADE
  FOR F = 1 TO FACTOR - 1
    FOR C = 0 TO 255
      PALSET C, PSRC(C).R + INT(TEMP(C, 0) * F), PSRC(C).G + INT(TEMP(C, 1) * F), PSRC(C).B + INT(TEMP(C, 2) * F)
    NEXT
  'DELAY...  USE FOR ANYTHING WITH FACTOR UNDER 63
    'T! = TIMER: DO: LOOP UNTIL ABS(TIMER - T!) > .1 / FACTOR
  NEXT

'FINALIZE
  FOR C = 0 TO 255
    PALSET C, PDST(C).R, PDST(C).G, PDST(C).B
  NEXT
END SUB

SUB PALGET (C, R, G, B)
  OUT &H3C7, C
  R = INP(&H3C9)
  G = INP(&H3C9)
  B = INP(&H3C9)
END SUB

SUB PALSET (C, R, G, B)
  OUT &H3C8, C
  OUT &H3C9, R
  OUT &H3C9, G
  OUT &H3C9, B
END SUB

ENJOY ;-)
-Josh

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
Thank you very much! I tried it and it worked. I'll use it in my program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top