- fixed recursion issues caused by the plasma generator function performing a busy wait.

This commit is contained in:
Christoph Oelckers 2019-12-25 18:57:08 +01:00
parent 28cbecea67
commit 23bc599468
2 changed files with 184 additions and 182 deletions

View file

@ -887,6 +887,7 @@ void M_Drawer (void)
} }
if (!going) if (!going)
{ {
assert(DMenu::CurrentMenu);
DMenu::CurrentMenu->origin = { 0,0 }; DMenu::CurrentMenu->origin = { 0,0 };
// else if (DrawBackground) Menu_DrawBackground(origin); // else if (DrawBackground) Menu_DrawBackground(origin);
DMenu::CurrentMenu->Drawer(); DMenu::CurrentMenu->Drawer();

View file

@ -309,15 +309,22 @@ int nLogoTile;
#define kPlasmaWidth 320 #define kPlasmaWidth 320
#define kPlasmaHeight 80 #define kPlasmaHeight 80
int nextPlasmaTic;
void menu_DoPlasma() void menu_DoPlasma()
{ {
int ptile = nPlasmaTile;
if (totalclock >= nextPlasmaTic || !PlasmaBuffer)
{
nextPlasmaTic = (int)totalclock + 4;
if (!nLogoTile) if (!nLogoTile)
nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo; nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
if (!PlasmaBuffer) if (!PlasmaBuffer)
{ {
auto pixels = TileFiles.tileCreate(kTile4092, kPlasmaWidth, kPlasmaHeight); auto pixels = TileFiles.tileCreate(kTile4092, kPlasmaWidth, kPlasmaHeight);
memset(pixels, 96, kPlasmaWidth*kPlasmaHeight); memset(pixels, 96, kPlasmaWidth * kPlasmaHeight);
PlasmaBuffer = TileFiles.tileCreate(kTile4093, kPlasmaWidth, kPlasmaHeight); PlasmaBuffer = TileFiles.tileCreate(kTile4093, kPlasmaWidth, kPlasmaHeight);
memset(PlasmaBuffer, 96, kPlasmaWidth * kPlasmaHeight); memset(PlasmaBuffer, 96, kPlasmaWidth * kPlasmaHeight);
@ -350,13 +357,13 @@ void menu_DoPlasma()
uint8_t* plasmapix = const_cast<uint8_t*>(tilePtr(nPlasmaTile)); uint8_t* plasmapix = const_cast<uint8_t*>(tilePtr(nPlasmaTile));
uint8_t *r_ebx = plasmapix + 81; uint8_t* r_ebx = plasmapix + 81;
const uint8_t *r_edx = tilePtr(nPlasmaTile ^ 1) + 81; // flip between value of 4092 and 4093 with xor const uint8_t* r_edx = tilePtr(nPlasmaTile ^ 1) + 81; // flip between value of 4092 and 4093 with xor
for (int x = 0; x < kPlasmaWidth - 2; x++) for (int x = 0; x < kPlasmaWidth - 2; x++)
// for (int x = 1; x < 318; x++) // for (int x = 1; x < 318; x++)
{ {
// for (int y = 1; y < 79; y++) // for (int y = 1; y < 79; y++)
for (int y = 0; y < kPlasmaHeight - 2; y++) for (int y = 0; y < kPlasmaHeight - 2; y++)
{ {
uint8_t al = *r_edx; uint8_t al = *r_edx;
@ -447,9 +454,9 @@ void menu_DoPlasma()
{ {
int pB = plasma_B[j]; int pB = plasma_B[j];
int pC = plasma_C[j]; int pC = plasma_C[j];
int badOffset = (pC>>16) < nSmokeLeft || (pC>>16) >= nSmokeRight; int badOffset = (pC >> 16) < nSmokeLeft || (pC >> 16) >= nSmokeRight;
const uint8_t *ptr3 = (logopix + ((pC >> 16) - nSmokeLeft) * tilesiz[nLogoTile].y); const uint8_t* ptr3 = (logopix + ((pC >> 16) - nSmokeLeft)* tilesiz[nLogoTile].y);
plasma_C[j] += plasma_B[j]; plasma_C[j] += plasma_B[j];
@ -498,14 +505,11 @@ void menu_DoPlasma()
} }
} }
uint8_t *v28 = plasmapix + (80 * (plasma_C[j] >> 16)); uint8_t* v28 = plasmapix + (80 * (plasma_C[j] >> 16));
v28[nSmokeOffset] = 175; v28[nSmokeOffset] = 175;
} }
tileInvalidate(nPlasmaTile,-1,-1); tileInvalidate(nPlasmaTile, -1, -1);
overwritesprite(0, 0, nPlasmaTile, 0, 2, kPalNormal);
overwritesprite(160, 40, nLogoTile, 0, 3, kPalNormal);
// flip between tile 4092 and 4093 // flip between tile 4092 and 4093
if (nPlasmaTile == kTile4092) { if (nPlasmaTile == kTile4092) {
@ -514,18 +518,15 @@ void menu_DoPlasma()
else if (nPlasmaTile == kTile4093) { else if (nPlasmaTile == kTile4093) {
nPlasmaTile = kTile4092; nPlasmaTile = kTile4092;
} }
}
overwritesprite(0, 0, ptile, 0, 2, kPalNormal);
overwritesprite(160, 40, nLogoTile, 0, 3, kPalNormal);
// draw the fire urn/lamp thingies // draw the fire urn/lamp thingies
int dword_9AB5F = ((int)totalclock/16) & 3; int dword_9AB5F = ((int)totalclock/16) & 3;
overwritesprite(50, 150, kTile3512 + dword_9AB5F, 0, 3, kPalNormal); overwritesprite(50, 150, kTile3512 + dword_9AB5F, 0, 3, kPalNormal);
overwritesprite(270, 150, kTile3512 + ((dword_9AB5F + 2) & 3), 0, 3, kPalNormal); overwritesprite(270, 150, kTile3512 + ((dword_9AB5F + 2) & 3), 0, 3, kPalNormal);
// TEMP
int time = (int)totalclock + 4;
while ((int)totalclock < time) {
HandleAsync();
}
} }