The original XFlame, courtesy of The Rasterman is now ported to SDL
(Another fun demo… heheh)
Anybody want to contribute code they’ve been working?
I’d love to see work in progress, if you’re comfortable with that.
This demo is in the latest CVS snapshot:
//
/* XFlame v1.0 */
//
/* By: /
/ The Rasterman (Carsten Haitzler) /
/ Copyright © 1996 /
/*****************************************************************************/
/ Ported to SDL by: /
/ Sam Lantinga /
/ /
/ This is a dirty port, just to get it working on SDL. /
/ Improvements left to the reader: /
/ Use depth-specific code to optimize HiColor/TrueColor display /
/ Fix the delta code – it’s broken – shame on Rasterman /
/ /
/*****************************************************************************/
/ This code is Freeware. You may copy it, modify it or do with it as you /
/ please, but you may not claim copyright on any code wholly or partly /
/ based on this code. I accept no responisbility for any consequences of /
/ using this code, be they proper or otherwise. /
/*****************************************************************************/
/ Okay, now all the legal mumbo-jumbo is out of the way, I will just say /
/ this: enjoy this program, do with it as you please and watch out for more /
/ code releases from The Rasterman running under X… the only way to code. */
/*****************************************************************************/
/* INCLUDES! */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include “SDL.h”
/* DEFINES */
#define GEN 500
#define MAX 300
#define WID 80
#define HIH 60
#define HSPREAD 26
#define VSPREAD 78
#define VFALLOFF 14
#define VARIANCE 5
#define VARTREND 2
#define RESIDUAL 68
#define NONE 0x00
#define CMAP 0x02
#define DELT 0x08 /* Delta code is broken – Rasterman? */
#define BLOK 0x20
#define LACE 0x40
/*This structure contains all of the “Global” variables for my program so */
/*that I just pass a pointer to my functions, not a million parameters */
struct globaldata
{
Uint32 flags;
SDL_Surface *screen;
int nrects;
SDL_Rect *rects;
};
void printhelp()
{
printf(“XFlame v1.0\n”);
printf(" By: The Rasterman (Carsten Haitzler)\n");
printf(" e-mail: s2154962 at cse.unsw.edu.au\n");
printf(" web: http://www.cse.unsw.edu.au/~s2154962/\n");
printf(" Ported to SDL by: Sam Lantinga\n");
printf(" e-mail: slouken at devolution.com\n");
printf(" web: http://www.devolution.com/~slouken/\n");
printf(" Copyright © 1996\n");
printf(" Please read the DOCS!\n");
printf(“Options:\n”);
printf(" -h : Prints this help\n");
printf(" -fullscreen : XFlame runs fullscreen if possible\n");
printf(" -cmap : XFlame uses its own colormap in its window\n");
printf(" -nicecmap : XFlame allocates fewer colors\n");
printf(" -block : XFlame updates the screen in one large block\n");
#ifdef FIXED_DELTA_CODE
printf(" -delta : XFlame updates the screen in deltas\n");
#endif
printf(" -lace : XFlame updates the screen using extended interlacing\n");
printf(" -width : XFlame uses a window of width pixels\n");
printf(" -height : XFlame uses a window of height pixels\n");
}
void fewargs()
{
/* If someone gives too few arguments, then tell them so! /
printf(“Toow few Arguments!\n”);
return;
}
int powerof(unsigned int n)
{
/ This returns the power of a number (eg powerof(8)==3, powerof(256)==8, /
/ powerof(1367)==11, powerof(2568)==12) */
int p=32;
if (n<=0x80000000) p=31;
if (n<=0x40000000) p=30;
if (n<=0x20000000) p=29;
if (n<=0x10000000) p=28;
if (n<=0x08000000) p=27;
if (n<=0x04000000) p=26;
if (n<=0x02000000) p=25;
if (n<=0x01000000) p=24;
if (n<=0x00800000) p=23;
if (n<=0x00400000) p=22;
if (n<=0x00200000) p=21;
if (n<=0x00100000) p=20;
if (n<=0x00080000) p=19;
if (n<=0x00040000) p=18;
if (n<=0x00020000) p=17;
if (n<=0x00010000) p=16;
if (n<=0x00008000) p=15;
if (n<=0x00004000) p=14;
if (n<=0x00002000) p=13;
if (n<=0x00001000) p=12;
if (n<=0x00000800) p=11;
if (n<=0x00000400) p=10;
if (n<=0x00000200) p=9;
if (n<=0x00000100) p=8;
if (n<=0x00000080) p=7;
if (n<=0x00000040) p=6;
if (n<=0x00000020) p=5;
if (n<=0x00000010) p=4;
if (n<=0x00000008) p=3;
if (n<=0x00000004) p=2;
if (n<=0x00000002) p=1;
if (n<=0x00000001) p=0;
return p;
}
int OpenDisp(void)
{
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
return(0);
atexit(SDL_Quit);
return(1);
}
int OpenWindow(struct globaldata *g,int w,int h)
{
Uint16 rw, rh;
Uint8 rb;
/This function opens sets a video mode closest to width w and height h/
rw = w;
rh = h;
rb = 8;
if (!SDL_GetVideoMode(&rw, &rh, &rb, g->flags))
{
return 0;
}
g->screen = SDL_SetVideoMode(rw, rh, 8, g->flags);
if (g->screen == NULL)
{
return 0;
}
return 1;
}
void
SetFlamePalette(struct globaldata *gb, int f,int *ctab)
{
/*This function sets the flame palette */
int r,g,b,i;
SDL_Color cmap[MAX];
/* This step is only needed on palettized screens /
r = g = b = 0;
for (i=0; (r != 255) || (g != 255) || (b != 255); i++)
{
r=i3;
g=(i-80)*3;
b=(i-160)*3;
if (r<0) r=0;
if (r>255) r=255;
if (g<0) g=0;
if (g>255) g=255;
if (b<0) b=0;
if (b>255) b=255;
cmap[i].r = r;
cmap[i].g = g;
cmap[i].b = b;
}
SDL_SetColors(gb->screen, cmap, 0, i);
/* This step is for all depths /
for (i=0;i<MAX;i++)
{
r=i3;
g=(i-80)*3;
b=(i-160)*3;
if (r<0) r=0;
if (r>255) r=255;
if (g<0) g=0;
if (g>255) g=255;
if (b<0) b=0;
if (b>255) b=255;
ctab[i]=SDL_MapRGB(gb->screen->format, r, g, b);
}
}
void
XFSetFlameZero(int *f, int w, int ws, int h)
{
/This function sets the entire flame array to zero/
int x,y,*ptr;
for (y=0;y<h;y++)
{
for (x=0;x<w;x++)
{
ptr=f+(y<<ws)+x;
*ptr=0;
}
}
}
#ifdef FIXED_DELTA_CODE
void
XFSetDeltaZero(int *d, int *dd, int w, int ds, int h)
{
/*This function sets the entire delta array to zero and copies the d */
/*array into the dd array fro double buffering */
int x,y,*ptr,*p;
for (y=0;y<h;y++)
{
for (x=0;x<w;x++)
{
ptr=d+(y<<ds)+x;
p=dd+(y<<ds)+x;
*p=ptr; / FIXME: Crashes on some width/height combinations */
ptr=0;
}
}
}
#endif / FIXED_DELTA_CODE */
void
XFSetRandomFlameBase(int *f, int w, int ws, int h)
{
/*This function sets the base of the flame to random values */
int x,y,*ptr;
/* initialize a random number seed from the time, so we get random /
/ numbers each time */
srand(time(NULL));
y=h-1;
for (x=0;x<w;x++)
{
ptr=f+(y<<ws)+x;
*ptr=rand()%MAX;
}
}
void
XFModifyFlameBase(int *f, int w, int ws, int h)
{
/*This function modifies the base of the flame with random values */
int x,y,*ptr,val;
y=h-1;
for (x=0;x<w;x++)
{
ptr=f+(y<<ws)+x;
*ptr+=((rand()%VARIANCE)-VARTREND);
val=*ptr;
if (val>MAX) *ptr=0;
if (val<0) *ptr=0;
}
}
void
XFProcessFlame(int *f, int w, int ws, int h, int *ff)
{
/*This function processes entire flame array */
int x,y,*ptr,*p,tmp,val;
for (y=(h-1);y>=2;y–)
{
for (x=1;x<(w-1);x++)
{
ptr=f+(y<<ws)+x;
val=(int)*ptr;
if (val>MAX) *ptr=(int)MAX;
val=(int)ptr;
if (val>0)
{
tmp=(valVSPREAD)>>8;
p=ptr-(2<<ws);
*p=*p+(tmp>>1);
p=ptr-(1<<ws);
*p=p+tmp;
tmp=(valHSPREAD)>>8;
p=ptr-(1<<ws)-1;
*p=*p+tmp;
p=ptr-(1<<ws)+1;
*p=*p+tmp;
p=ptr-1;
*p=*p+(tmp>>1);
p=ptr+1;
*p=*p+(tmp>>1);
p=ff+(y<<ws)+x;
*p=val;
if (y<(h-1)) ptr=(valRESIDUAL)>>8;
}
}
}
}
void
XFDrawFlameBLOK(struct globaldata *g,int *f, int w, int ws, int h, int *ctab)
{
/*This function copies & displays the flame image in one large block */
int x,y,*ptr,xx,yy,cl,cl1,cl2,cl3,cl4;
unsigned char *cptr,*im,*p;
/* get pointer to the image data */
if ( SDL_LockSurface(g->screen) < 0 )
return;
/* copy the calculated flame array to the image buffer */
im=(unsigned char *)g->screen->pixels;
for (y=0;y<(h-1);y++)
{
for (x=0;x<(w-1);x++)
{
xx=x<<1;
yy=y<<1;
ptr=f+(y<<ws)+x;
cl1=cl=(int)*ptr;
ptr=f+(y<<ws)+x+1;
cl2=(int)*ptr;
ptr=f+((y+1)<<ws)+x+1;
cl3=(int)*ptr;
ptr=f+((y+1)<<ws)+x;
cl4=(int)ptr;
cptr=im+yyg->screen->pitch+xx;
*cptr=(unsigned char)ctab[cl%MAX];
p=cptr+1;
*p=(unsigned char)ctab[((cl1+cl2)>>1)%MAX];
p=cptr+1+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl3)>>1)%MAX];
p=cptr+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl4)>>1)%MAX];
}
}
SDL_UnlockSurface(g->screen);
/* copy the image to the screen in one large chunk */
SDL_UpdateRect(g->screen, 0, 0, w<<1, h<<1);
}
#ifdef FIXED_DELTA_CODE
XFDrawFlameDELT(struct globaldata *g,int *f, int w, int ws, int h, int *d, int *dd, int dw, int ds, int dh, int *ctab)
{
/*This function copies & displays the flame image in DELTA fashion. */
/*this method is far more complex than plain BLOCK transfer or even */
/*interlaced method, as it only copies what it absolutely has to to */
/*the screen. the image is divided up into 32x32 pixel DELTAs, and if */
/*the contents of this DELTA isn’t completely black, it is copied to */
/*the screen, so if the flame image only takes approximately 1/3 of */
/*the entire image, only 1/3 of the pixles are copied, in 32x32 pixel */
/*blocks, so on LARGE flame windows (such as in root), we save a LOT */
/of image copying, by only copying what is necessary/
int x,y,*ptr,xx,yy,cl,cl1,cl2,cl3,cl4,ims,*pp;
unsigned char *cptr,*im,*p;
/* get pointer to the image data */
if ( SDL_LockSurface(g->screen) < 0 )
return;
/* set the delta array to ZERO /
XFSetDeltaZero(d,dd,dw,ds,dh);
/ copy the calculated flame array to the image buffer */
im=(unsigned char *)g->screen->pixels;
for (y=0;y<(h-1);y++)
{
for (x=0;x<(w-1);x++)
{
xx=x<<1;
yy=y<<1;
ptr=f+(y<<ws)+x;
cl1=cl=(int)*ptr;
ptr=f+(y<<ws)+x+1;
cl2=(int)*ptr;
ptr=f+((y+1)<<ws)+x+1;
cl3=(int)*ptr;
ptr=f+((y+1)<<ws)+x;
cl4=(int)ptr;
cptr=im+yyg->screen->pitch+xx;
*cptr=(unsigned char)ctab[cl%MAX];
p=cptr+1;
*p=(unsigned char)ctab[((cl1+cl2)>>1)%MAX];
p=cptr+1+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl3)>>1)%MAX];
p=cptr+g->screen->pitch;
p=(unsigned char)ctab[((cl1+cl4)>>1)%MAX];
/ now add the pixel value to the total value of this pixels DELTA */
xx=xx>>5;
yy=yy>>5;
ptr=d+(yy<<ds)+xx;
*ptr+=(int)cl;
}
}
SDL_UnlockSurface(g->screen);
/* copy the image to the screen in one delta at a time */
g->nrects = 0;
for (y=0;y<(dh-1);y++)
{
for (x=0;x<dw;x++)
{
ptr=d+(y<<ds)+x;
pp=dd+(y<<ds)+x;
if ((*ptr)||(pp))
{
g->rects[g->nrects].x = x<<5;
g->rects[g->nrects].y = y<<5;
g->rects[g->nrects].w = 32;
g->rects[g->nrects].h = 32;
++g->nrects;
}
}
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
}
#endif / FIXED_DELTA_CODE */
void
XFDrawFlameLACE(struct globaldata *g,int *f, int w, int ws, int h, int *ctab)
{
/*This function copies & displays the flame image in interlaced fashion */
/*that it, it first processes and copies the even lines to the screen, /
/ then is processes and copies the odd lines of the image to the screen */
int x,y,*ptr,xx,yy,cl,cl1,cl2,cl3,cl4;
unsigned char *cptr,*im,*p;
/* get pointer to the image data */
if ( SDL_LockSurface(g->screen) < 0 )
return;
/* copy the calculated flame array to the image buffer */
im=(unsigned char *)g->screen->pixels;
for (y=0;y<(h-1);y++)
{
for (x=0;x<(w-1);x++)
{
xx=x<<1;
yy=y<<1;
ptr=f+(y<<ws)+x;
cl1=cl=(int)*ptr;
ptr=f+(y<<ws)+x+1;
cl2=(int)*ptr;
ptr=f+((y+1)<<ws)+x+1;
cl3=(int)*ptr;
ptr=f+((y+1)<<ws)+x;
cl4=(int)ptr;
cptr=im+yyg->screen->pitch+xx;
*cptr=(unsigned char)ctab[cl%MAX];
p=cptr+1;
*p=(unsigned char)ctab[((cl1+cl2)>>1)%MAX];
p=cptr+1+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl3)>>1)%MAX];
p=cptr+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl4)>>1)%MAX];
}
}
SDL_UnlockSurface(g->screen);
/* copy the even lines to the screen /
w <<= 1;
h <<= 1;
g->nrects = 0;
for (y=0;y<(h-1);y+=4)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
/ copy the odd lines to the screen /
g->nrects = 0;
for (y=2;y<(h-1);y+=4)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
/ copy the even lines to the screen /
g->nrects = 0;
for (y=1;y<(h-1);y+=4)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
/ copy the odd lines to the screen */
g->nrects = 0;
for (y=3;y<(h-1);y+=4)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
}
void
XFDrawFlame(struct globaldata *g,int *f, int w, int ws, int h, int *ctab)
{
/*This function copies & displays the flame image in interlaced fashion */
/*that it, it first processes and copies the even lines to the screen, /
/ then is processes and copies the odd lines of the image to the screen */
int x,y,*ptr,xx,yy,cl,cl1,cl2,cl3,cl4;
unsigned char *cptr,*im,*p;
/* get pointer to the image data */
if ( SDL_LockSurface(g->screen) < 0 )
return;
/* copy the calculated flame array to the image buffer */
im=(unsigned char *)g->screen->pixels;
for (y=0;y<(h-1);y++)
{
for (x=0;x<(w-1);x++)
{
xx=x<<1;
yy=y<<1;
ptr=f+(y<<ws)+x;
cl1=cl=(int)*ptr;
ptr=f+(y<<ws)+x+1;
cl2=(int)*ptr;
ptr=f+((y+1)<<ws)+x+1;
cl3=(int)*ptr;
ptr=f+((y+1)<<ws)+x;
cl4=(int)ptr;
cptr=im+yyg->screen->pitch+xx;
*cptr=(unsigned char)ctab[cl%MAX];
p=cptr+1;
*p=(unsigned char)ctab[((cl1+cl2)>>1)%MAX];
p=cptr+1+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl3)>>1)%MAX];
p=cptr+g->screen->pitch;
*p=(unsigned char)ctab[((cl1+cl4)>>1)%MAX];
}
}
SDL_UnlockSurface(g->screen);
/* copy the even lines to the screen /
w <<= 1;
h <<= 1;
g->nrects = 0;
for (y=0;y<(h-1);y+=2)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
/ copy the odd lines to the screen */
g->nrects = 0;
for (y=1;y<(h-1);y+=2)
{
g->rects[g->nrects].x = 0;
g->rects[g->nrects].y = y;
g->rects[g->nrects].w = w;
g->rects[g->nrects].h = 1;
++g->nrects;
}
SDL_UpdateRects(g->screen, g->nrects, g->rects);
}
int Xflame(struct globaldata *g,int w, int h, int f, int *ctab)
{
int done;
SDL_Event event;
/*This function is the hub of XFlame… it initialises the flame array, */
/*processes the array, genereates the flames and displays them */
int *flame,flamesize,ws,flamewidth,flameheight,*flame2;
#ifdef FIXED_DELTA_CODE
int dwidth,deltawidth,ds,deltaheight,deltasize,*delta,*delta2;
#endif
/* workout the size needed for the flame array /
flamewidth=w>>1;
flameheight=h>>1;
ws=powerof(flamewidth);
flamesize=(1<<ws)flameheightsizeof(int);
/ allocate the memory for the flame array /
flame=(int )malloc(flamesize);
/ if we didn’t get the memory, return 0 /
if (!flame) return 0;
/ allocate the memory for the second flame array /
flame2=(int )malloc(flamesize);
/ if we didn’t get the memory, return 0 /
if (!flame2) return 0;
#ifdef FIXED_DELTA_CODE
/ if the user specified DELTA updating, allocate a delta array /
if (f&DELT)
{
dwidth=w>>5;
if (dwidth==0) dwidth=0;
deltawidth=(ws-5);
ds=powerof(deltawidth);
if (deltawidth==0) deltawidth=1;
deltaheight=(h>>5)+1;
if (deltaheight==0) deltaheight=1;
/ calculate the delta size /
deltasize=deltawidthdeltaheightsizeof(int);
/ allocate the memory for the delta array */
delta=(int )malloc(deltasize);
/ if we couldn’t get the memory, return 0 /
if (!delta) return 0;
/ allocate the memory for the second delta array */
delta2=(int )malloc(deltasize);
/ if we couldn’t get the memory, return 0 /
if (!delta2) return 0;
/ allocate the memory for update rectangles */
g->rects=(SDL_Rect )malloc((h>>5)(w>>5)sizeof(SDL_Rect));
/ if we couldn’t get the memory, return 0 /
if (!g->rects) return 0;
}
else
#endif / FIXED_DELTA_CODE /
if (f&BLOK)
{
g->rects = NULL;
}
else if (f&LACE)
{
/ allocate the memory for update rectangles */
g->rects=(SDL_Rect *)malloc((h>>2)sizeof(SDL_Rect));
/ if we couldn’t get the memory, return 0 /
if (!g->rects) return 0;
}
else
{
/ allocate the memory for update rectangles */
g->rects=(SDL_Rect *)malloc((h>>1)sizeof(SDL_Rect));
/ if we couldn’t get the memory, return 0 /
if (!g->rects) return 0;
}
/ set the flame array to ZERO /
XFSetFlameZero(flame,w>>1,ws,h>>1);
/ set the base of the flame to something random /
XFSetRandomFlameBase(flame,w>>1,ws,h>>1);
/ now loop, generating and displaying flames /
for (done=0; !done; )
{
/ modify the bas of the flame /
XFModifyFlameBase(flame,w>>1,ws,h>>1);
/ process the flame array, propagating the flames up the array /
XFProcessFlame(flame,w>>1,ws,h>>1,flame2);
#ifdef FIXED_DELTA_CODE
/ if the user selected DELTA display method, then draw the flames /
/ using DELTAs instead of interlaced /
if (f&DELT)
{
XFDrawFlameDELT(g,flame2,w>>1,ws,h>>1,delta,delta2,dwidth,ds,
deltaheight,ctab);
}
else
#endif / FIXED_DELTA_CODE /
/ if the user selected BLOCK display method, then display the flame /
/ all in one go, no fancy upating techniques involved /
if (f&BLOK)
{
XFDrawFlameBLOK(g,flame2,w>>1,ws,h>>1,ctab);
}
else if (f&LACE)
{
XFDrawFlameLACE(g,flame2,w>>1,ws,h>>1,ctab);
}
else
/ the default of displaying the flames INTERLACED /
{
XFDrawFlame(g,flame2,w>>1,ws,h>>1,ctab);
}
/ Look for a key or quit event */
while ( SDL_PollEvent(&event) )
{
if ( (event.type == SDL_KEYEVENT) || (event.type == SDL_QUITEVENT) )
done = 1;
}
}
return(done);
}
/* Here’s the MAIN part of the program */
int main(int argc, char **argv)
{
struct globaldata glob;
char disp[256];
int flags;
int width,height,i,colortab[MAX];
/* Set all the variable to default values */
strcpy(disp,":0.0");
flags=NONE;
width=128;
height=128;
/* Check command line for arguments /
glob.flags = SDL_SWSURFACE;
if (argc>1)
{
for (i=1;i<=argc;i++)
{
/ if the user requests help /
if (!strcmp("-h",argv[i-1]))
{
printhelp();
exit(0);
}
/ if the user requests to run on full display*/
if (!strcmp("-fullscreen",argv[i-1]))
{
glob.flags |= SDL_FULLSCREEN;
}
/* if the user requests to run with own colormap*/
if (!strcmp("-cmap",argv[i-1]))
{
glob.flags |= SDL_HWPALETTE;
flags|=CMAP;
}
#ifdef FIXED_DELTA_CODE
/* if the user requests to use Delta updating of the image /
if (!strcmp("-delta",argv[i-1]))
{
flags|=DELT;
}
#endif / FIXED_DELTA_CODE /
/ if the user requests to use Lace updating of the image /
if (!strcmp("-lace",argv[i-1]))
{
flags|=LACE;
}
/ if the user requests to use Block updating of the image /
if (!strcmp("-block",argv[i-1]))
{
flags|=BLOK;
}
/ if the user requests a particular width /
if (!strcmp("-width",argv[i-1]))
{
if ((i+1)>argc)
{
fewargs();
exit(1);
}
width=atoi(argv[i]);
if (width<16)
{
width=16;
}
i++;
}
/ if the user requests a particular height /
if (!strcmp("-height",argv[i-1]))
{
if ((i+1)>argc)
{
fewargs();
exit(1);
}
height=atoi(argv[i]);
if (height<16)
{
height=16;
}
i++;
}
}
}
if (!OpenDisp())
{
printf(“Could not initialize SDL: %s\n”,SDL_GetError());
exit(1);
}
if (!OpenWindow(&glob,width,height))
{
exit(1);
}
/ if the user requested a CLEAN display method, set the window up /
/ accordingly with backign store, saveunders etc.) */
/* Set up the palette for the flame according to user flags */
SetFlamePalette(&glob,flags,colortab);
/* Start displaying the flame!/
if (!Xflame(&glob,glob.screen->w,glob.screen->h,flags,colortab))
{
/ if Xflame returned 0, it encountered an error in allocating memory */
printf(“Not enough memory to allocate to the flame arrays\n”);
exit(1);
}
exit(0);
}