Minor optimisations for startup and render_fire

This commit is contained in:
jacksonmj 2011-07-26 01:26:58 +08:00 committed by Simon Robertshaw
parent 94e316af85
commit db5cb5e2f9
2 changed files with 11 additions and 11 deletions

View File

@ -3798,17 +3798,20 @@ void render_fire(pixel *vid)
for (y=-CELL+1; y<2*CELL; y++)
for (x=-CELL+1; x<2*CELL; x++)
addpixel(vid, i*CELL+x, j*CELL+y, r, g, b, fire_alpha[y+CELL][x+CELL]);
r *= 8;
g *= 8;
b *= 8;
for (y=-1; y<2; y++)
for (x=-1; x<2; x++)
if (i+x>=0 && j+y>=0 && i+x<XRES/CELL && j+y<YRES/CELL && (x || y))
if ((x || y) && i+x>=0 && j+y>=0 && i+x<XRES/CELL && j+y<YRES/CELL)
{
r += fire_r[j+y][i+x] / 8;
g += fire_g[j+y][i+x] / 8;
b += fire_b[j+y][i+x] / 8;
r += fire_r[j+y][i+x];
g += fire_g[j+y][i+x];
b += fire_b[j+y][i+x];
}
r /= 2;
g /= 2;
b /= 2;
r /= 16;
g /= 16;
b /= 16;
fire_r[j][i] = r>4 ? r-4 : 0;
fire_g[j][i] = g>4 ? g-4 : 0;
fire_b[j][i] = b>4 ? b-4 : 0;

View File

@ -1126,6 +1126,7 @@ void clear_sim(void)
memset(emap, 0, sizeof(emap));
memset(signs, 0, sizeof(signs));
memset(parts, 0, sizeof(particle)*NPART);
pfree = -1;
memset(pmap, 0, sizeof(pmap));
memset(pv, 0, sizeof(pv));
memset(vx, 0, sizeof(vx));
@ -1736,10 +1737,6 @@ int main(int argc, char *argv[])
menu_count();
parts = calloc(sizeof(particle), NPART);
cb_parts = calloc(sizeof(particle), NPART);
for (i=0; i<NPART-1; i++)
parts[i].life = i+1;
parts[NPART-1].life = -1;
pfree = 0;
fire_bg=calloc(XRES*YRES, PIXELSIZE);
init_can_move();
clear_sim();