'=========================================================================== ' Subject: V-FIRE ROUTINE V1.0 Date: 02-06-99 (09:04) ' Author: Sam Thursfield Code: QB, QBasic, PDS ' Origin: sam.thursfield@btinternet.com Packet: GRAPHICS.ABC '=========================================================================== '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ' лл лл мммллл лл мммммллл мммллл ' лл лл лллллппп лл ллппппп плл ллллппп ' лл лл лл мммллл лл лл лл лл ммм ' лл лл мм ллллппп лл лл ммлл ллммлллппп ' лл лл ллпп лл лл лллллпп ллпп ' лл лл лл лл ллллллм лл ' лл лл лл лл лл пплл лл мммллл ' ллл лл лл лл лл ллллппп ' By Sam Thursfield (AKA ElvisII) 23-24 January 1999 '=-=-=-=-=-=-=-=-=-=-=-=-=-= V F I R E V 1 . 0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=- 'Well, this is my new fire routine. It really needs to be compiled to run 'Well, so I've included the compiled version for all you QBasic users. 'It is fairly fast. Four FPS Environment on my Cyrix P150+, and 53 compiled. ' 'So why is is so damn fast? Well, this is why: ' ў Uses poke instead of PSet ' ў Doesn't run full screen ' ў Only averages 4 pixels, not 8. '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ' '-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Begin legal crap =-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 'I suppose I'd better do some legal crap: You may, and are in fact incouraged, 'To use this code in your own programs. Just give me credit for it. Also, if 'Any of this code damages you, your computer, or anything else of yours, I 'Cannot be held responsible. '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= End legal crap -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- DECLARE SUB Fire (StartX%, EndX%, StartY%, EndY%, FPS%) DECLARE SUB PalSet (I%, R%, G%, B%) DEFINT A-Z 'All unmarked variables are integers for speed '$DYNAMIC 'Dynamically organise memory for more DIM SHARED F(49 TO 269, 139 TO 199)'Array for fire SCREEN 13 'VGA 320*200*256 RANDOMIZE TIMER 'Seed the random number generator Fire 49, 269, 139, 199, FFPS'Run the fire! SCREEN 0: WIDTH 80, 25: CLS 'Back to text Mode PRINT "FPS for Fire: "; FFPS'Display the speed of the various functions SUB Fire (StartX, EndX, StartY, EndY, FPS) 'Sets fire to your computer! DEF SEG = &HA000 FOR I = 0 TO 63 'Sets the fire palette PalSet I, I, 0, 0 'First black faded to red... PalSet I + 64, 63, I, 0 'Then red to yellow... PalSet I + 128, 63, 63, I 'Then yellow to white... PalSet I + 192, 63, 63, 63 'Then set the rest to white NEXT I Start! = TIMER 'For the frame counter DO 'The main loop X = StartX + 15 'Set the seed line DO X = X + (RND * 12) IF X > EndX - 10 THEN X = EndX - 10 'Check we don't go off the edge F(X, EndY - 1) = (RND * 250) + 50 'Set pixel with a random colour LOOP UNTIL X = EndX - 10 FOR X = StartX TO EndX FOR Y = StartY TO EndY - 2 IF X > StartX AND X < EndX THEN Col = F(X - 1, Y + 1) 'Average out the pixels Col = Col + F(X, Y + 1) Col = Col + F(X + 1, Y + 1) Col = Col + F(X, Y + 2) Col = Col \ 4 - 3 END IF IF X = StartX THEN Col = F(X + 1, Y) IF X = EndX THEN Col = F(X - 1, Y) IF Col < 0 THEN Col = 0 F(X, Y) = Col 'Set the pixel... IF Y < EndY - 3 THEN Offset& = ((Y + 3) * 320&) + X POKE Offset&, F(X, Y) END IF NEXT Y NEXT X Frame = Frame + 1 'Frame counter IF TIMER > Start! + 2 THEN 'If two seconds has passed... Start! = TIMER 'Reset the timer FPS = Frame \ 2 'Find the number of frames per sec. Frame = 0 'And reset the frame counter END IF LOOP UNTIL INKEY$ <> "" 'Stop after a keypress DO: LOOP WHILE INKEY$ <> "" 'Clear the keyboard buffer END SUB SUB PalSet (I, R, G, B) 'Sets palette using VGA registers OUT &H3C8, I 'Set the colour to be set OUT &H3C9, R 'Set the Red value... OUT &H3C9, G 'The Green value... OUT &H3C9, B 'And the Blue value END SUB