FUEGO
-----
Author: Diego Fraga
Coded sometime in 2003, released in july 2004.

Description:
-----------
A simple demo of fire effect coded with the great RosAsm assembler.  The source code is included in Fuego's exe. The fire effect (and its algorithm) are nothing new, it has been there for years. The are lots of them, just search the web. The difference, modesty aside, is that mine's looks better!


How it works:
------------
First we need an array that represents a rectangle that later will be used for mapping to screen, one byte per pixel.

The fire starts with the fuel: 2 lines of random pixels at the bottom of the rectangle buffer.
Every pixel above is an average of some of the pixels that it has below. Graphically:

 P
abc
def

The pixel P is the average of pixel 123456. P=(a+b+c+d+e+f)/6
With this we make the illusion that the fire rises and diffuses. Basically that's the core of the effect. To make it look better I experimented a lot of things: more and less pixels, multiply the pixels with different values, tweaking the average function (for example P=(a*3+b*5+c*3+d+e*2+f)/14 ), and some other cosmetics effects.

Now we have to render it. I was looking for an alternative for setting pixels on screen fast. The SetPixelV is slow, you have to make a call to the function for each pixel, so looking win32.hlp I found a function called SetDIBitsToDevice.  This function gets input from an array of bytes in memory and outputs to the screen very fast.

I created a nice palette, I don't remember exactly how I do it, perhaps I painted it first in photoshop or I did it trhough a little vb program. The things Is that the palette is and array of double words (4 bytes) containing each an RGB value from black (no fire) to white (hottest spot). What I remember is that I tweaked the palette a lot to make the fire look really good.

We just have to fill a new buffer with the correspondig value in the palette for each byte in the fire buffer. Then we just call the SetDIBitsToDevice function. That's it.


History:
-------
I don't remember when I saw a fire demo for the first time, but it was for sure on a Commodore 64 or an Amiga.  I've been amazed with computer demos from the old days when I owned a Commodore 64 (with datasette, no floppy drive!), later I saw some Amiga's demos too but I never could afford one Amiga. On those days I programed the C64 in basic and some assembler. Years later I jumped to the PC platform, I learned some quickbasic, a little assembler and later in windows visual ba$ic. I programmed some interesting (for me at least) demos programs in VB and later with vb+directx, including a little fire demo and a animated kaleidoscope.
Then I discover RosAsm: a great win32 assembler (It was named SpAsm in that days). First I wrote a simple program for a friend of mine (and for me too!) that lets you choose the color of the titles of icons in the desktop. With it I gained some experience and tried to make a fire demo...


Credits:
-------
First I want to thank a lot Betov for his superb RosAsm and for the attention he has on the forum with everybody.
Credits goes for Guga too for pointed a bug, that I hopelly fixed by now, and for he's interest in Fuego.
And finally to all the demo coders for inspired me!


-=Diego=-