[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result My spiffy screen 13 palette fader... - Pete's QBASIC Site
Hi, just got back into doing some programming in QB. It's been almost 2 yrs. since I last coded. Anyways, what I was wanting to do first was to improve the quality of my palette fade in/out routines.
What I did was instead of decreasing a colors rgb intensity every cycle,
like most other fading routines, I decreased the colors rgb intensity more
gradually. (This fading effect looks much cleaner!)
'
DEFINT A-Z
'
TYPE PALdata
Red AS INTEGER
Grn AS INTEGER
Blu AS INTEGER
END TYPE
'
DIM SHARED PAL(255) AS PALdata
'
SCREEN 13
'
OUT &H3C7, 0
'
FOR x = 0 TO 255
PAL(x).Red = INP(&H3C9)
PAL(x).Grn = INP(&H3C9)
PAL(x).Blu = INP(&H3C9)
NEXT
'
FOR y = 0 TO 199
FOR x = 0 TO 319
PSET (x, y), INT(RND(1) * 254 + 1)
NEXT
NEXT
'
COLOR 15: LOCATE 13, 12: PRINT "...Press a key..."
'
DO: LOOP UNTIL INKEY$ <> INKEY$
'
OUT &H3C8, 0
'
FOR y = 1 TO 64
FOR x = 0 TO 255
r = PAL(x).Red - (y * (PAL(x).Red / 64))
g = PAL(x).Grn - (y * (PAL(x).Grn / 64))
b = PAL(x).Blu - (y * (PAL(x).Blu / 64))
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
WAIT &H3DA, 8
NEXT
'
FOR y = 1 TO 64
FOR x = 0 TO 255
r = y * (PAL(x).Red / 64)
g = y * (PAL(x).Grn / 64)
b = y * (PAL(x).Blu / 64)
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
WAIT &H3DA, 8
NEXT
'
SYSTEM
'
Cya, Nemesis.
p.s..I was thinking maybe writing a tutorial or something to explain the code in detail, step by step. What do you guys think?
That's funny. I have one that I wrote that's very similar to that. I was disatisfied with the ones I found in tutorials that looked very fakey.
Mine also pregenerates each inner loop (x in your case) to a temporary array, then puts that out to the video card in a separate inner loop. The result: a flickerless fade. (Your code would probably cause some flicker in the top quarter of the screen on my PIII 500mhz.)
Umm, added another feature which fades to and from any color.
So pretty much, with just a couple more lines of code, this routine
could be used for palette to palette fades also.
Anyways, here's the final fading routine that I'll be using in my gfx lib...
'
DEFINT A-Z
'
TYPE PALdata
Red AS INTEGER
Grn AS INTEGER
Blu AS INTEGER
END TYPE
'
DIM SHARED PAL(255) AS PALdata
'
SCREEN 13
'
OUT &H3C7, 0
'
FOR x = 0 TO 255
PAL(x).Red = INP(&H3C9)
PAL(x).Grn = INP(&H3C9)
PAL(x).Blu = INP(&H3C9)
NEXT
'
FOR y = 0 TO 199
FOR x = 0 TO 319
PSET (x, y), INT(RND(1) * 254 + 1)
NEXT
NEXT
'
COLOR 15: LOCATE 13, 12: PRINT "...Press a key..."
'
DO: LOOP UNTIL INKEY$ <> INKEY$
'
c = 1 'Color of fade.
'
OUT &H3C8, 0
'
FOR y = 1 TO 64
FOR x = 0 TO 255
r = PAL(x).Red - (y * ((PAL(x).Red - PAL(c).Red) / 64))
g = PAL(x).Grn - (y * ((PAL(x).Grn - PAL(c).Grn) / 64))
b = PAL(x).Blu - (y * ((PAL(x).Blu - PAL(c).Blu) / 64))
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
t! = TIMER: DO: LOOP UNTIL TIMER <> t!
NEXT
'
DO: LOOP UNTIL INKEY$ <> INKEY$
'
FOR y = 1 TO 64
FOR x = 0 TO 255
r = PAL(c).Red + (y * ((PAL(x).Red - PAL(c).Red) / 64))
g = PAL(c).Grn + (y * ((PAL(x).Grn - PAL(c).Grn) / 64))
b = PAL(c).Blu + (y * ((PAL(x).Blu - PAL(c).Blu) / 64))
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
t! = TIMER: DO: LOOP UNTIL TIMER <> t!
NEXT
'
SYSTEM
'
(Change the variable c for different colors of fade.)