Reduce PAPR+ARAY read/write duration and reformat mark color

This commit is contained in:
Rebmiami 2023-12-12 15:57:52 -05:00
parent 19461e315e
commit a50f4a10f3
4 changed files with 31 additions and 36 deletions

View File

@ -1097,7 +1097,7 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr) const
case PT_PAPR: case PT_PAPR:
// BCOL can always pass through PAPR in order to color it // BCOL can always pass through PAPR in order to color it
// Most elements are blocked by marked PAPR, except for certified "weird" elements where it's inverse // Most elements are blocked by marked PAPR, except for certified "weird" elements where it's inverse
if ((pt == PT_BCOL) || ((parts[ID(r)].life >> 24) & 0x01 ^ (pt != PT_ANAR && pt != PT_BIZR && pt != PT_BIZRG))) if ((pt == PT_BCOL) || (parts[ID(r)].life ^ (pt != PT_ANAR && pt != PT_BIZR && pt != PT_BIZRG)))
result = 2; result = 2;
else else
result = 0; result = 0;

View File

@ -175,7 +175,7 @@ static int update(UPDATE_FUNC_ARGS)
// Read // Read
// End reading state early // End reading state early
parts[r].tmp = 0; parts[r].tmp = 0;
if ((parts[r].life >> 24) & 0x1) if (parts[r].life)
{ {
break; break;
} }
@ -183,13 +183,14 @@ static int update(UPDATE_FUNC_ARGS)
else else
{ {
// Write // Write
parts[r].life = 0x11A2222; parts[r].life = 1;
parts[r].dcolour = 0xFF1A2222;
} }
} }
else else
{ {
// Enter writing state // Enter writing state
parts[r].tmp = 0x0A; parts[r].tmp = 0x03;
} }
// this if prevents BRAY from stopping on certain materials // this if prevents BRAY from stopping on certain materials
} }
@ -236,7 +237,7 @@ static int update(UPDATE_FUNC_ARGS)
// Read // Read
// End reading state early // End reading state early
parts[r].tmp = 0; parts[r].tmp = 0;
if ((parts[r].life >> 24) & 0x1) if (parts[r].life)
{ {
break; break;
} }
@ -244,13 +245,14 @@ static int update(UPDATE_FUNC_ARGS)
else else
{ {
// Write // Write
parts[r].life = 0x0; parts[r].life = 0;
parts[r].dcolour = 0;
} }
} }
else else
{ {
// Enter reading state // Enter reading state
parts[r].tmp = 0x1A; parts[r].tmp = 0x13;
} }
} }
docontinue = 1; docontinue = 1;

View File

@ -160,7 +160,7 @@ static int update(UPDATE_FUNC_ARGS)
int bit = 0x1; int bit = 0x1;
while (TYP(rr) == PT_PAPR && bit <= 0x3FFFFFFF) while (TYP(rr) == PT_PAPR && bit <= 0x3FFFFFFF)
{ {
if ((parts[ID(rr)].life >> 24) & 0x1) if (parts[ID(rr)].life)
{ {
photonWl |= bit; photonWl |= bit;
} }
@ -190,9 +190,15 @@ static int update(UPDATE_FUNC_ARGS)
while (TYP(r) == PT_PAPR && bit <= 0x3FFFFFFF) while (TYP(r) == PT_PAPR && bit <= 0x3FFFFFFF)
{ {
if (photonWl & bit) if (photonWl & bit)
parts[ID(r)].life = 0x1080820; {
parts[ID(r)].life = 1;
parts[ID(r)].dcolour = 0x1080820;
}
else else
parts[ID(r)].life = 0x0; {
parts[ID(r)].life = 0;
parts[ID(r)].dcolour = 0;
}
nx += rx; nx += rx;
ny += ry; ny += ry;
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES) if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)

View File

@ -50,7 +50,7 @@ void Element::Element_PAPR()
LowTemperature = ITL; LowTemperature = ITL;
LowTemperatureTransition = NT; LowTemperatureTransition = NT;
HighTemperature = 700.0f; HighTemperature = 700.0f;
HighTemperatureTransition = PT_NONE; // Add ash or broken paper element? HighTemperatureTransition = PT_NONE;
Update = &update; Update = &update;
Graphics = &graphics; Graphics = &graphics;
@ -81,25 +81,14 @@ static int update(UPDATE_FUNC_ARGS)
// Get marked by BCOL // Get marked by BCOL
if (TYP(pmap[y][x]) == PT_BCOL) if (TYP(pmap[y][x]) == PT_BCOL)
{ {
parts[i].life = 0x122222A; parts[i].life = 1;
parts[i].dcolour = 0xFF22222A;
} }
// Get unmarked by SOAP // Generally, these should correspond, but correct if they don't.
for (auto rx = -1; rx <= 1; rx++) if (!parts[i].life != !parts[i].dcolour)
{ {
for (auto ry = -1; ry <= 1; ry++) parts[i].life = parts[i].dcolour ? 1 : 0;
{
if (rx || ry)
{
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) == PT_SOAP)
{
parts[i].life = 0;
}
}
}
} }
// Decrement tmp counter for laser reading/writing // Decrement tmp counter for laser reading/writing
@ -116,15 +105,12 @@ static int update(UPDATE_FUNC_ARGS)
static int graphics(GRAPHICS_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS)
{ {
int ta = (cpart->life >> 24) & 0x01; if (cpart->life)
int tr = (cpart->life >> 16) & 0xFF;
int tg = (cpart->life >> 8) & 0xFF;
int tb = (cpart->life) & 0xFF;
if (ta)
{ {
*colr = tr; float alpha = ((cpart->dcolour >> 24) & 0xFF) / 255.f;
*colg = tg; *colr = int(*colr * (1 - alpha) + ((cpart->dcolour >> 16) & 0xFF) * alpha);
*colb = tb; *colg = int(*colg * (1 - alpha) + ((cpart->dcolour >> 8) & 0xFF) * alpha);
*colb = int(*colb * (1 - alpha) + ((cpart->dcolour) & 0xFF) * alpha);
} }
// Darken when burnt // Darken when burnt
float maxtemp = std::max((float)cpart->tmp2, cpart->temp); float maxtemp = std::max((float)cpart->tmp2, cpart->temp);
@ -137,7 +123,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
if (cpart->tmp) if (cpart->tmp)
{ {
*pixel_mode |= PMODE_GLOW; *pixel_mode |= PMODE_GLOW;
float flash = (cpart->tmp & 0xF) / 15.f; float flash = (cpart->tmp & 0xF) / 3.f;
*cola = flash * 200; *cola = flash * 200;
*colr = int(*colr * (1 - flash)); *colr = int(*colr * (1 - flash));
*colg = int(*colg * (1 - flash)); *colg = int(*colg * (1 - flash));
@ -152,5 +138,6 @@ static int graphics(GRAPHICS_FUNC_ARGS)
*colb += int(255 * flash); *colb += int(255 * flash);
} }
} }
*pixel_mode |= NO_DECO;
return 0; return 0;
} }