diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-23 12:52:26 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-23 12:52:26 (GMT) |
| commit | 1c7b9d9949f4aca2ceba44b9d41420ad34c69f94 (patch) | |
| tree | f917e85e29ac8c95b4ed894ea4b8b764e2290c47 /src/elements | |
| parent | 014c1fbad669b0cf1abd881e696f0c7e432b3707 (diff) | |
| download | powder-1c7b9d9949f4aca2ceba44b9d41420ad34c69f94.zip powder-1c7b9d9949f4aca2ceba44b9d41420ad34c69f94.tar.gz | |
Pass particle pointer to graphics update function instead of index. Make PIPE use subcall to get graphics info. Cache for particle graphics properties. Stickman PSPEC_STICKMAN added and implemented
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/deut.c | 14 | ||||
| -rw-r--r-- | src/elements/fire.c | 2 | ||||
| -rw-r--r-- | src/elements/lava.c | 6 | ||||
| -rw-r--r-- | src/elements/newgraphics.c | 266 | ||||
| -rw-r--r-- | src/elements/phot.c | 6 | ||||
| -rw-r--r-- | src/elements/pipe.c | 82 | ||||
| -rw-r--r-- | src/elements/plsm.c | 2 | ||||
| -rw-r--r-- | src/elements/stkm.c | 16 | ||||
| -rw-r--r-- | src/elements/stkm2.c | 15 |
9 files changed, 236 insertions, 173 deletions
diff --git a/src/elements/deut.c b/src/elements/deut.c index bee3753..9276de1 100644 --- a/src/elements/deut.c +++ b/src/elements/deut.c @@ -71,18 +71,18 @@ int update_DEUT(UPDATE_FUNC_ARGS) { int graphics_DEUT(GRAPHICS_FUNC_ARGS) { - if(parts[i].life>=700) + if(cpart->life>=700) { - *colr += parts[i].life*1; - *colg += parts[i].life*2; - *colb += parts[i].life*3; + *colr += cpart->life*1; + *colg += cpart->life*2; + *colb += cpart->life*3; *pixel_mode |= PMODE_GLOW; } else { - *colr += parts[i].life*1; - *colg += parts[i].life*2; - *colb += parts[i].life*3; + *colr += cpart->life*1; + *colg += cpart->life*2; + *colb += cpart->life*3; *pixel_mode |= PMODE_BLUR; } return 0; diff --git a/src/elements/fire.c b/src/elements/fire.c index 391c743..b16b679 100644 --- a/src/elements/fire.c +++ b/src/elements/fire.c @@ -2,7 +2,7 @@ int graphics_FIRE(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)flm_data[caddress]; *colg = (unsigned char)flm_data[caddress+1]; *colb = (unsigned char)flm_data[caddress+2]; diff --git a/src/elements/lava.c b/src/elements/lava.c index a748cf7..0a9fb8a 100644 --- a/src/elements/lava.c +++ b/src/elements/lava.c @@ -2,9 +2,9 @@ int graphics_LAVA(GRAPHICS_FUNC_ARGS) { - *colr = parts[i].life * 2 + 0xE0; - *colg = parts[i].life * 1 + 0x50; - *colb = parts[i].life / 2 + 0x10; + *colr = cpart->life * 2 + 0xE0; + *colg = cpart->life * 1 + 0x50; + *colb = cpart->life / 2 + 0x10; if (*colr>255) *colr = 255; if (*colg>192) *colg = 192; if (*colb>128) *colb = 128; diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c index 6f941e0..2f7be03 100644 --- a/src/elements/newgraphics.c +++ b/src/elements/newgraphics.c @@ -1,11 +1,11 @@ #include <element.h> int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT { - int t = parts[i].type, z = parts[i].tmp - 5;//speckles! - if (parts[i].temp>(ptransitions[t].thv-800.0f))//hotglow for quartz + int t = cpart->type, z = cpart->tmp - 5;//speckles! + if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz { float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - int q = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); + int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); *colr += sin(frequency*q) * 226 + (z * 16); *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); @@ -20,7 +20,7 @@ int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT } int graphics_CLST(GRAPHICS_FUNC_ARGS) { - int z = parts[i].tmp - 5;//speckles! + int z = cpart->tmp - 5;//speckles! *colr += z * 16; *colg += z * 16; *colb += z * 16; @@ -28,7 +28,7 @@ int graphics_CLST(GRAPHICS_FUNC_ARGS) } int graphics_CBNW(GRAPHICS_FUNC_ARGS) { - int z = parts[i].tmp2 - 20;//speckles! + int z = cpart->tmp2 - 20;//speckles! *colr += z * 1; *colg += z * 2; *colb += z * 8; @@ -36,9 +36,9 @@ int graphics_CBNW(GRAPHICS_FUNC_ARGS) } int graphics_SPNG(GRAPHICS_FUNC_ARGS) { - *colr -= parts[i].life*15; - *colg -= parts[i].life*15; - *colb -= parts[i].life*15; + *colr -= cpart->life*15; + *colg -= cpart->life*15; + *colb -= cpart->life*15; if (*colr<=50) *colr = 50; if (*colg<=50) @@ -50,50 +50,50 @@ int graphics_SPNG(GRAPHICS_FUNC_ARGS) int graphics_LIFE(GRAPHICS_FUNC_ARGS) { pixel pc; - if (parts[i].ctype==NGT_LOTE)//colors for life states + if (cpart->ctype==NGT_LOTE)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(255, 128, 0); - else if (parts[i].tmp==1) + else if (cpart->tmp==1) pc = PIXRGB(255, 255, 0); else pc = PIXRGB(255, 0, 0); } - else if (parts[i].ctype==NGT_FRG2)//colors for life states + else if (cpart->ctype==NGT_FRG2)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(0, 100, 50); else pc = PIXRGB(0, 255, 90); } - else if (parts[i].ctype==NGT_STAR)//colors for life states + else if (cpart->ctype==NGT_STAR)//colors for life states { - if (parts[i].tmp==4) + if (cpart->tmp==4) pc = PIXRGB(0, 0, 128); - else if (parts[i].tmp==3) + else if (cpart->tmp==3) pc = PIXRGB(0, 0, 150); - else if (parts[i].tmp==2) + else if (cpart->tmp==2) pc = PIXRGB(0, 0, 190); - else if (parts[i].tmp==1) + else if (cpart->tmp==1) pc = PIXRGB(0, 0, 230); else pc = PIXRGB(0, 0, 70); } - else if (parts[i].ctype==NGT_FROG)//colors for life states + else if (cpart->ctype==NGT_FROG)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(0, 100, 0); else pc = PIXRGB(0, 255, 0); } - else if (parts[i].ctype==NGT_BRAN)//colors for life states + else if (cpart->ctype==NGT_BRAN)//colors for life states { - if (parts[i].tmp==1) + if (cpart->tmp==1) pc = PIXRGB(150, 150, 0); else pc = PIXRGB(255, 255, 0); } else { - pc = gmenu[parts[i].ctype].colour; + pc = gmenu[cpart->ctype].colour; } *colr = PIXR(pc); *colg = PIXG(pc); @@ -102,17 +102,17 @@ int graphics_LIFE(GRAPHICS_FUNC_ARGS) } int graphics_DUST(GRAPHICS_FUNC_ARGS) { - if(parts[i].life >= 1) + if(cpart->life >= 1) { - *colr = parts[i].flags; - *colg = parts[i].tmp; - *colb = parts[i].ctype; - if (decorations_enable && parts[i].dcolour) + *colr = cpart->flags; + *colg = cpart->tmp; + *colb = cpart->ctype; + if (decorations_enable && cpart->dcolour) { - int a = (parts[i].dcolour>>24)&0xFF; - *colr = (a*((parts[i].dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((parts[i].dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((parts[i].dcolour)&0xFF) + (255-a)**colb) >> 8; + int a = (cpart->dcolour>>24)&0xFF; + *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; } *firea = 255; *firer = *colr; @@ -126,38 +126,38 @@ int graphics_GRAV(GRAPHICS_FUNC_ARGS) *colr = 20; *colg = 20; *colb = 20; - if (parts[i].vx>0) + if (cpart->vx>0) { - *colr += (parts[i].vx)*GRAV_R; - *colg += (parts[i].vx)*GRAV_G; - *colb += (parts[i].vx)*GRAV_B; + *colr += (cpart->vx)*GRAV_R; + *colg += (cpart->vx)*GRAV_G; + *colb += (cpart->vx)*GRAV_B; } - if (parts[i].vy>0) + if (cpart->vy>0) { - *colr += (parts[i].vy)*GRAV_G; - *colg += (parts[i].vy)*GRAV_B; - *colb += (parts[i].vy)*GRAV_R; + *colr += (cpart->vy)*GRAV_G; + *colg += (cpart->vy)*GRAV_B; + *colb += (cpart->vy)*GRAV_R; } - if (parts[i].vx<0) + if (cpart->vx<0) { - *colr -= (parts[i].vx)*GRAV_B; - *colg -= (parts[i].vx)*GRAV_R; - *colb -= (parts[i].vx)*GRAV_G; + *colr -= (cpart->vx)*GRAV_B; + *colg -= (cpart->vx)*GRAV_R; + *colb -= (cpart->vx)*GRAV_G; } - if (parts[i].vy<0) + if (cpart->vy<0) { - *colr -= (parts[i].vy)*GRAV_R2; - *colg -= (parts[i].vy)*GRAV_G2; - *colb -= (parts[i].vy)*GRAV_B2; + *colr -= (cpart->vy)*GRAV_R2; + *colg -= (cpart->vy)*GRAV_G2; + *colb -= (cpart->vy)*GRAV_B2; } return 0; } int graphics_WIFI(GRAPHICS_FUNC_ARGS) { float frequency = 0.0628; - int q = parts[i].tmp; + int q = cpart->tmp; *colr = sin(frequency*q + 0) * 127 + 128; *colg = sin(frequency*q + 2) * 127 + 128; *colb = sin(frequency*q + 4) * 127 + 128; @@ -192,75 +192,25 @@ int graphics_BIZR(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; - if(fabs(parts[i].vx)+fabs(parts[i].vy)>0) + if(fabs(cpart->vx)+fabs(cpart->vy)>0) { *firea = 255; - *fireg = *colg/5 * fabs(parts[i].vx)+fabs(parts[i].vy); - *fireb = *colb/5 * fabs(parts[i].vx)+fabs(parts[i].vy); - *firer = *colr/5 * fabs(parts[i].vx)+fabs(parts[i].vy); + *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); + *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); + *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); *pixel_mode |= FIRE_ADD; } return 0; } -int graphics_PIPE(GRAPHICS_FUNC_ARGS) -{ - if (parts[i].ctype==2) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - else if (parts[i].ctype==3) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - else if (parts[i].ctype==4) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - else if (parts[i].temp<272.15&&parts[i].ctype!=1) - { - if (parts[i].temp>173.25&&parts[i].temp<273.15) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - if (parts[i].temp>73.25&&parts[i].temp<=173.15) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - if (parts[i].temp>=0&&parts[i].temp<=73.15) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - } - if ((parts[i].tmp&0xFF)>0 && (parts[i].tmp&0xFF)<PT_NUM) - { - //Maybe use a subcall to get the info of the embedded particle? - *colr = PIXR(ptypes[parts[i].tmp&0xFF].pcolors); - *colg = PIXG(ptypes[parts[i].tmp&0xFF].pcolors); - *colb = PIXB(ptypes[parts[i].tmp&0xFF].pcolors); - } - return 0; -} int graphics_INVS(GRAPHICS_FUNC_ARGS) { if(pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f) @@ -273,7 +223,7 @@ int graphics_INVS(GRAPHICS_FUNC_ARGS) } int graphics_ACID(GRAPHICS_FUNC_ARGS) { - int s = parts[i].life; + int s = cpart->life; if (s>75) s = 75; //These two should not be here. if (s<49) s = 49; s = (s-49)*3; @@ -286,19 +236,19 @@ int graphics_ACID(GRAPHICS_FUNC_ARGS) } int graphics_FILT(GRAPHICS_FUNC_ARGS) { - int x, temp_bin = (int)((parts[i].temp-273.0f)*0.025f); + int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); if (temp_bin < 0) temp_bin = 0; if (temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; + cpart->ctype = 0x1F << temp_bin; *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; @@ -308,49 +258,49 @@ int graphics_FILT(GRAPHICS_FUNC_ARGS) int graphics_BRAY(GRAPHICS_FUNC_ARGS) { int x, trans = 255; - if(parts[i].tmp==0) + if(cpart->tmp==0) { - trans = parts[i].life * 7; + trans = cpart->life * 7; if (trans>255) trans = 255; - if (parts[i].ctype) { + if (cpart->ctype) { *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; } } - else if(parts[i].tmp==1) + else if(cpart->tmp==1) { - trans = parts[i].life/4; + trans = cpart->life/4; if (trans>255) trans = 255; - if (parts[i].ctype) { + if (cpart->ctype) { *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; } } - else if(parts[i].tmp==2) + else if(cpart->tmp==2) { - trans = parts[i].life*100; + trans = cpart->life*100; if (trans>255) trans = 255; *colr = 255; *colr = 150; @@ -363,7 +313,7 @@ int graphics_BRAY(GRAPHICS_FUNC_ARGS) } int graphics_SWCH(GRAPHICS_FUNC_ARGS) { - if(parts[i].life >= 10) + if(cpart->life >= 10) { *colr = 17; *colg = 217; @@ -383,25 +333,25 @@ int graphics_THDR(GRAPHICS_FUNC_ARGS) } int graphics_GLOW(GRAPHICS_FUNC_ARGS) { - *firer = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f; - *fireg = restrict_flt(parts[i].ctype, 0, 128)/50.0f; - *fireb = restrict_flt(parts[i].tmp, 0, 128)/50.0f; + *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; + *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; + *fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f; - *colr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255); - *colg = restrict_flt(64.0f+parts[i].ctype, 0, 255); - *colb = restrict_flt(64.0f+parts[i].tmp, 0, 255); + *colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255); + *colg = restrict_flt(64.0f+cpart->ctype, 0, 255); + *colb = restrict_flt(64.0f+cpart->tmp, 0, 255); *pixel_mode |= FIRE_ADD; return 0; } int graphics_LCRY(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); - if(parts[i].dcolour && parts[i].dcolour&0xFF000000) + int lifemod = ((cpart->life>10?10:cpart->life)*10); + if(cpart->dcolour && cpart->dcolour&0xFF000000) { - *colr += (lifemod * (255-(parts[i].dcolour>>16)&0xFF))>>8; - *colg += (lifemod * (255-(parts[i].dcolour>>8)&0xFF))>>8; - *colb += (lifemod * (255-(parts[i].dcolour)&0xFF))>>8; + *colr += (lifemod * (255-(cpart->dcolour>>16)&0xFF))>>8; + *colg += (lifemod * (255-(cpart->dcolour>>8)&0xFF))>>8; + *colb += (lifemod * (255-(cpart->dcolour)&0xFF))>>8; } else { @@ -414,21 +364,21 @@ int graphics_LCRY(GRAPHICS_FUNC_ARGS) } int graphics_PCLN(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); + int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; *colg += lifemod; return 0; } int graphics_PBCN(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); + int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; *colg += lifemod/2; return 0; } int graphics_DLAY(GRAPHICS_FUNC_ARGS) { - int stage = (int)(((float)parts[i].life/(parts[i].temp-273.15))*100.0f); + int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); *colr += stage; *colg += stage; *colb += stage; @@ -436,19 +386,19 @@ int graphics_DLAY(GRAPHICS_FUNC_ARGS) } int graphics_HSWC(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colr += lifemod; return 0; } int graphics_PVOD(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*16); + int lifemod = ((cpart->life>10?10:cpart->life)*16); *colr += lifemod; return 0; } int graphics_STOR(GRAPHICS_FUNC_ARGS) { - if(parts[i].tmp){ + if(cpart->tmp){ *colr = 0x50; *colg = 0xDF; *colb = 0xDF; @@ -461,20 +411,20 @@ int graphics_STOR(GRAPHICS_FUNC_ARGS) } int graphics_PUMP(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colb += lifemod; return 0; } int graphics_GPMP(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colg += lifemod; *colb += lifemod; return 0; } int graphics_HFLM(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)hflm_data[caddress]; *colg = (unsigned char)hflm_data[caddress+1]; *colb = (unsigned char)hflm_data[caddress+2]; @@ -491,17 +441,17 @@ int graphics_HFLM(GRAPHICS_FUNC_ARGS) } int graphics_FIRW(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)firw_data[caddress]; *colg = (unsigned char)firw_data[caddress+1]; *colb = (unsigned char)firw_data[caddress+2]; - if (decorations_enable && parts[i].dcolour) + if (decorations_enable && cpart->dcolour) { - int a = (parts[i].dcolour>>24)&0xFF; - *colr = (a*((parts[i].dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((parts[i].dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((parts[i].dcolour)&0xFF) + (255-a)**colb) >> 8; + int a = (cpart->dcolour>>24)&0xFF; + *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; } *firea = 255; @@ -516,7 +466,7 @@ int graphics_FIRW(GRAPHICS_FUNC_ARGS) } int graphics_BOMB(GRAPHICS_FUNC_ARGS) { - if (parts[i].tmp==0) { + if (cpart->tmp==0) { *pixel_mode |= PMODE_FLARE; } else @@ -527,7 +477,7 @@ int graphics_BOMB(GRAPHICS_FUNC_ARGS) } int graphics_GBMB(GRAPHICS_FUNC_ARGS) { - if (parts[i].life <= 0) { + if (cpart->life <= 0) { *pixel_mode |= PMODE_FLARE; } else @@ -538,7 +488,7 @@ int graphics_GBMB(GRAPHICS_FUNC_ARGS) } int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal { - *colr += (parts[i].tmp2-295.15f)/3; + *colr += (cpart->tmp2-295.15f)/3; if (*colr > 170) *colr = 170; @@ -547,10 +497,10 @@ int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal *colg = *colb = *colr; - if((parts[i].temp-295.15f) > 300.0f-200.0f) + if((cpart->temp-295.15f) > 300.0f-200.0f) { float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); - int q = ((parts[i].temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(parts[i].temp-295.15f)-(300.0f-200.0f); + int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); *colr += sin(frequency*q) * 226; *colg += sin(frequency*q*4.55 +3.14) * 34; diff --git a/src/elements/phot.c b/src/elements/phot.c index f999753..7a9d4f2 100644 --- a/src/elements/phot.c +++ b/src/elements/phot.c @@ -64,11 +64,11 @@ int graphics_PHOT(GRAPHICS_FUNC_ARGS) int x = 0; *colr = *colg = *colb = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; diff --git a/src/elements/pipe.c b/src/elements/pipe.c index 7411932..7014536 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -235,3 +235,85 @@ int update_PIPE(UPDATE_FUNC_ARGS) { } return 0; } + +int graphics_PIPE(GRAPHICS_FUNC_ARGS) +{ + if (cpart->ctype==2) + { + *colr = 50; + *colg = 1; + *colb = 1; + } + else if (cpart->ctype==3) + { + *colr = 1; + *colg = 50; + *colb = 1; + } + else if (cpart->ctype==4) + { + *colr = 1; + *colg = 1; + *colb = 50; + } + else if (cpart->temp<272.15&&cpart->ctype!=1) + { + if (cpart->temp>173.25&&cpart->temp<273.15) + { + *colr = 50; + *colg = 1; + *colb = 1; + } + if (cpart->temp>73.25&&cpart->temp<=173.15) + { + *colr = 1; + *colg = 50; + *colb = 1; + } + if (cpart->temp>=0&&cpart->temp<=73.15) + { + *colr = 1; + *colg = 1; + *colb = 50; + } + } + if ((cpart->tmp&0xFF)>0 && (cpart->tmp&0xFF)<PT_NUM) + { + //Create a temp. particle and do a subcall. + particle tpart; + int t; + memset(&tpart, 0, sizeof(particle)); + tpart.type = cpart->tmp&0xFF; + tpart.temp = cpart->temp; + tpart.life = cpart->flags; + tpart.tmp = cpart->pavg[0]; + tpart.ctype = cpart->pavg[1]; + t = tpart.type; + if (graphicscache[t].isready) + { + *pixel_mode = graphicscache[t].pixel_mode; + *colr = graphicscache[t].colr; + *colg = graphicscache[t].colg; + *colb = graphicscache[t].colb; + *firea = graphicscache[t].firea; + *firer = graphicscache[t].firer; + *fireg = graphicscache[t].fireg; + *fireb = graphicscache[t].fireb; + } + else + { + if (ptypes[t].graphics_func) + { + (*(ptypes[t].graphics_func))(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb); + } + else + { + graphics_DEFAULT(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb); + } + } + //*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors); + //*colg = PIXG(ptypes[cpart->tmp&0xFF].pcolors); + //*colb = PIXB(ptypes[cpart->tmp&0xFF].pcolors); + } + return 0; +} diff --git a/src/elements/plsm.c b/src/elements/plsm.c index 3bab693..6cd0275 100644 --- a/src/elements/plsm.c +++ b/src/elements/plsm.c @@ -2,7 +2,7 @@ int graphics_PLSM(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)parts[i].life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)plasma_data[caddress]; *colg = (unsigned char)plasma_data[caddress+1]; *colb = (unsigned char)plasma_data[caddress+2]; diff --git a/src/elements/stkm.c b/src/elements/stkm.c index a96de2a..752f167 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -13,6 +13,22 @@ int update_STKM(UPDATE_FUNC_ARGS) return 0; } +int graphics_STKM(GRAPHICS_FUNC_ARGS) +{ + *pixel_mode = PSPEC_STICKMAN; + if ((int)player[2]<PT_NUM) + { + *colr = PIXR(ptypes[(int)player[2]].pcolors); + *colg = PIXG(ptypes[(int)player[2]].pcolors); + *colb = PIXB(ptypes[(int)player[2]].pcolors); + } + else + { + *colr = *colg = *colb = 255; + } + return 1; +} + int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { int r, rx, ry; float pp, d; diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c index b1aeb20..7ada3cb 100644 --- a/src/elements/stkm2.c +++ b/src/elements/stkm2.c @@ -12,3 +12,18 @@ int update_STKM2(UPDATE_FUNC_ARGS) { return 0; } +int graphics_STKM2(GRAPHICS_FUNC_ARGS) +{ + *pixel_mode = PSPEC_STICKMAN; + if ((int)player2[2]<PT_NUM) + { + *colr = PIXR(ptypes[(int)player2[2]].pcolors); + *colg = PIXG(ptypes[(int)player2[2]].pcolors); + *colb = PIXB(ptypes[(int)player2[2]].pcolors); + } + else + { + *colr = *colg = *colb = 255; + } + return 1; +} |
