Move wall drawing to graphics.c

This commit is contained in:
Simon Robertshaw
2011-05-14 13:28:02 +01:00
parent d0f236d6b9
commit 16f014b06a
7 changed files with 219 additions and 502 deletions

View File

@@ -114,6 +114,8 @@ void xor_rect(pixel *vid, int x, int y, int w, int h);
void draw_parts(pixel *vid);
void draw_walls(pixel *vid);
void draw_decorations(pixel *vid_buf,pixel *decorations);
void draw_wavelengths(pixel *vid, int x, int y, int h, int wl);

View File

@@ -12,36 +12,6 @@ struct menu_section
};
typedef struct menu_section menu_section;
struct menu_wall
{
pixel colour;
const char *descs;
};
typedef struct menu_wall menu_wall;
static menu_wall mwalls[] =
{
{PIXPACK(0xC0C0C0), "Wall. Indestructible. Blocks everything. Conductive."},
{PIXPACK(0x808080), "E-Wall. Becomes transparent when electricity is connected."},
{PIXPACK(0xFF8080), "Detector. Generates electricity when a particle is inside."},
{PIXPACK(0x808080), "Streamline. Set start point of a streamline."},
{PIXPACK(0x808080), "Sign. Click on a sign to edit it or anywhere else to place a new one."},
{PIXPACK(0x8080FF), "Fan. Accelerates air. Use line tool to set direction and strength."},
{PIXPACK(0xC0C0C0), "Wall. Blocks most particles but lets liquids through. Conductive."},
{PIXPACK(0x808080), "Wall. Absorbs particles but lets air currents through."},
{PIXPACK(0x808080), "Erases walls."},
{PIXPACK(0x808080), "Wall. Indestructible. Blocks everything."},
{PIXPACK(0x3C3C3C), "Wall. Indestructible. Blocks particles, allows air"},
{PIXPACK(0x575757), "Wall. Indestructible. Blocks liquids and gasses, allows solids"},
{PIXPACK(0xFFFF22), "Conductor, allows particles, conducts electricity"},
{PIXPACK(0x242424), "E-Hole, absorbs particles, release them when powered"},
{PIXPACK(0xFFFFFF), "Air, creates airflow and pressure"},
{PIXPACK(0xFFBB00), "Heats the targetted element."},
{PIXPACK(0x00BBFF), "Cools the targetted element."},
{PIXPACK(0x303030), "Vacuum, reduces air pressure."},
{PIXPACK(0x579777), "Wall. Indestructible. Blocks liquids and solids, allows gasses"},
};
#define SC_WALL 0
#define SC_SPECIAL 8
#define SC_POWDERS 5

View File

@@ -782,6 +782,39 @@ static int lolzrule[9][9] =
{0,1,0,0,0,0,0,1,0},
{0,1,0,0,0,0,0,1,0},
};
struct wall_type
{
pixel colour;
pixel eglow; // if emap set, add this to fire glow
int drawstyle;
const char *descs;
};
typedef struct wall_type wall_type;
static wall_type wtypes[] =
{
{PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, "Wall. Indestructible. Blocks everything. Conductive."},
{PIXPACK(0x808080), PIXPACK(0x808080), 0, "E-Wall. Becomes transparent when electricity is connected."},
{PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, "Detector. Generates electricity when a particle is inside."},
{PIXPACK(0x808080), PIXPACK(0x000000), 0, "Streamline. Set start point of a streamline."},
{PIXPACK(0x808080), PIXPACK(0x000000), 0, "Sign. Click on a sign to edit it or anywhere else to place a new one."},
{PIXPACK(0x8080FF), PIXPACK(0x000000), 1, "Fan. Accelerates air. Use line tool to set direction and strength."},
{PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, "Wall. Blocks most particles but lets liquids through. Conductive."},
{PIXPACK(0x808080), PIXPACK(0x000000), 1, "Wall. Absorbs particles but lets air currents through."},
{PIXPACK(0x808080), PIXPACK(0x000000), 1, "Erases walls."},
{PIXPACK(0x808080), PIXPACK(0x000000), 3, "Wall. Indestructible. Blocks everything."},
{PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks particles, allows air"},
{PIXPACK(0x575757), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and gasses, allows solids"},
{PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, "Conductor, allows particles, conducts electricity"},
{PIXPACK(0x242424), PIXPACK(0x101010), 0, "E-Hole, absorbs particles, release them when powered"},
{PIXPACK(0xFFFFFF), PIXPACK(0x000000), -1, "Air, creates airflow and pressure"},
{PIXPACK(0xFFBB00), PIXPACK(0x000000), -1, "Heats the targetted element."},
{PIXPACK(0x00BBFF), PIXPACK(0x000000), -1, "Cools the targetted element."},
{PIXPACK(0x303030), PIXPACK(0x000000), -1, "Vacuum, reduces air pressure."},
{PIXPACK(0x579777), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and solids, allows gasses"},
};
#define CHANNELS ((int)(MAX_TEMP-73.15f)/100+2)
particle portalp[CHANNELS][8][80];
const particle emptyparticle;

View File

@@ -3063,6 +3063,174 @@ void draw_parts(pixel *vid)
#endif
}
void draw_walls(pixel *vid)
{
int x, y, i, j, cr, cg, cb;
unsigned char wt;
pixel pc;
for (y=0; y<YRES/CELL; y++)
for (x=0; x<XRES/CELL; x++)
if (bmap[y][x])
{
wt = bmap[y][x]-UI_ACTUALSTART;
pc = wtypes[wt].colour;
// standard wall patterns
if (wtypes[wt].drawstyle==1)
{
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
}
else if (wtypes[wt].drawstyle==2)
{
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
}
else if (wtypes[wt].drawstyle==3)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
}
// special rendering for some walls
if (bmap[y][x]==WL_EWALL)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (i&j&1)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
}
else
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!(i&j&1))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
}
}
else if (bmap[y][x]==WL_WALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
else
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
}
else if (bmap[y][x]==WL_EHOLE)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
}
else
{
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
}
}
if (cmode==CM_BLOB)
{
// when in blob view, draw some blobs...
if (wtypes[wt].drawstyle==1)
{
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc));
}
else if (wtypes[wt].drawstyle==2)
{
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc));
}
else if (wtypes[wt].drawstyle==3)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc));
}
if (bmap[y][x]==WL_EWALL)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (i&j&1)
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
else
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!(i&j&1))
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
}
else if (bmap[y][x]==WL_WALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc));
else
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
}
else if (bmap[y][x]==WL_EHOLE)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
}
else
{
for (j=0; j<CELL; j+=2)
for (i=0; i<CELL; i+=2)
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
}
}
}
if (wtypes[wt].eglow && emap[y][x])
{
// glow if electrified
pc = wtypes[wt].eglow;
cr = fire_r[y][x] + PIXR(pc);
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg = fire_g[y][x] + PIXG(pc);
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb = fire_b[y][x] + PIXB(pc);
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
}
void draw_decorations(pixel *vid_buf,pixel *decorations)
{
int i,r,g,b;

View File

@@ -1725,7 +1725,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
x = XRES-BARSIZE-18;
y += 19;
}*/
x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
x -= draw_tool_xy(vid_buf, x, y, n, wtypes[n-UI_WALLSTART].colour)+5;
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255);
@@ -1762,7 +1762,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
x = XRES-BARSIZE-18;
y += 19;
}*/
x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
x -= draw_tool_xy(vid_buf, x, y, n, wtypes[n-UI_WALLSTART].colour)+5;
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255);
@@ -1869,7 +1869,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
}
else if (i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART))
{
drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255);
drawtext(vid_buf, XRES-textwidth((char *)wtypes[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)wtypes[h-UI_WALLSTART].descs, 255, 255, 255, 255);
}
else
{

View File

@@ -1310,6 +1310,7 @@ int main(int argc, char *argv[])
for(i=0; i<30; i++){
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
draw_walls(vid_buf);
update_particles(vid_buf);
draw_parts(vid_buf);
render_fire(vid_buf);
@@ -1616,8 +1617,10 @@ int main(int argc, char *argv[])
if (!sys_pause||framerender) //Only update if not paused
memset(gravmap, 0, sizeof(gravmap)); //Clear the old gravmap
if(ngrav_enable)
draw_grav(vid_buf);
draw_walls(vid_buf);
update_particles(vid_buf); //update everything
draw_parts(vid_buf); //draw particles

View File

@@ -2118,481 +2118,22 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but
}
}
pfree=l;
if (cmode==CM_BLOB)//draw walls in BLOB mode differently, this should be moved elsewhere
for (y=0; y<YRES/CELL; y++)
{
for (y=0; y<YRES/CELL; y++)
for (x=0; x<XRES/CELL; x++)
{
for (x=0; x<XRES/CELL; x++)
{
if (bmap[y][x]==WL_WALL)
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
if (bmap[y][x]==WL_DESTROYALL)
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
if (bmap[y][x]==WL_ALLOWLIQUID)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_FAN)
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0xFF);
}
if (bmap[y][x]==WL_DETECT)
{
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0x80, 0x80);
}
if (emap[y][x])
{
cr = 255;
cg = 32;
cb = 8;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_EWALL)
{
if (emap[y][x])
{
cr = cg = cb = 128;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (i&j&1)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
}
else
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!(i&j&1))
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
}
}
if (bmap[y][x]==WL_WALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0xC0, 0xC0, 0xC0);
}
else
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80);
}
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_ALLOWALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
//pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0xFF, 0xFF, 0x22);
}
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_ALLOWGAS)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x97, 0x77);
}
}
}
if (bmap[y][x]==WL_ALLOWAIR)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x3C, 0x3C, 0x3C);
}
}
}
if (bmap[y][x]==WL_ALLOWSOLID)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x57, 0x57, 0x57);
}
}
}
if (bmap[y][x]==WL_EHOLE)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
{
for (i=(j)&1; i<CELL; i++)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
}
}
for (j=0; j<CELL; j+=2)
{
for (i=(j)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
}
}
}
else
{
for (j=0; j<CELL; j+=2)
{
for (i=(j)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24);
}
}
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (emap[y][x] && (!sys_pause||framerender))
emap[y][x] --;
}
}
}
else //draw walls in other modes, this should be elsewhere
{
for (y=0; y<YRES/CELL; y++)
{
for (x=0; x<XRES/CELL; x++)
{
if (bmap[y][x]==WL_WALL)
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
if (bmap[y][x]==WL_DESTROYALL)
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
if (bmap[y][x]==WL_ALLOWLIQUID)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_FAN)
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x8080FF);
if (bmap[y][x]==WL_DETECT)
{
for (j=0; j<CELL; j+=2)
for (i=(j>>1)&1; i<CELL; i+=2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFF8080);
if (emap[y][x])
{
cr = 255;
cg = 32;
cb = 8;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_EWALL)
{
if (emap[y][x])
{
cr = cg = cb = 128;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (i&j&1)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
else
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
if (!(i&j&1))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
}
if (bmap[y][x]==WL_WALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xC0C0C0);
else
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_ALLOWALLELEC)
{
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
{
//pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0xFFFF22);
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (bmap[y][x]==WL_ALLOWAIR)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x3C3C3C);
}
}
}
if (bmap[y][x]==WL_ALLOWGAS)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x579777);
}
}
}
if (bmap[y][x]==WL_ALLOWSOLID)
{
for (j=0; j<CELL; j+=2)
{
for (i=(j>>1)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x575757);
}
}
}
if (bmap[y][x]==WL_EHOLE)
{
if (emap[y][x])
{
for (j=0; j<CELL; j++)
{
for (i=(j)&1; i<CELL; i++)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
}
}
for (j=0; j<CELL; j+=2)
{
for (i=(j)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
}
}
}
else
{
for (j=0; j<CELL; j+=2)
{
for (i=(j)&1; i<CELL; i+=2)
{
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
}
}
}
if (emap[y][x])
{
cr = cg = cb = 16;
cr += fire_r[y][x];
if (cr > 255) cr = 255;
fire_r[y][x] = cr;
cg += fire_g[y][x];
if (cg > 255) cg = 255;
fire_g[y][x] = cg;
cb += fire_b[y][x];
if (cb > 255) cb = 255;
fire_b[y][x] = cb;
}
}
if (emap[y][x] && (!sys_pause||framerender))
emap[y][x] --;
}
if (bmap[y][x]==WL_WALL || bmap[y][x]==WL_WALLELEC || (bmap[y][x]==WL_EWALL&&!emap[y][x]))
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (emap[y][x] && (!sys_pause||framerender))
emap[y][x] --;
}
}
update_particles_i(vid, 0, 1);
// this should probably be elsewhere
for (y=0; y<YRES/CELL; y++)
for (x=0; x<XRES/CELL; x++)
if (bmap[y][x]==WL_STREAM)