diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index e9ccf8199..546de8a59 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -730,6 +730,13 @@ void timerhandler() } } +void HandleAsync() +{ + handleevents(); + if (!bInMove) + OSD_DispatchQueued(); +} + int MyGetStringWidth(const char *str) { int nLen = strlen(str); @@ -2022,9 +2029,6 @@ LOOP2: LOOP3: while (levelnew != -1) { - // CHECKME - this should be here? - handleevents(); - // BLUE if (CDplaying()) { fadecdaudio(); @@ -2032,6 +2036,7 @@ LOOP3: CheckCD(); +#if 0 if (!bNoCDCheck) { while (!checkcdrom()) @@ -2044,6 +2049,7 @@ LOOP3: } } } +#endif if (levelnew == kMap20) { @@ -2100,12 +2106,18 @@ LOOP3: mysetbrightness((uint8_t)nGamma); //int edi = totalclock; tclocks2 = totalclock; + CONTROL_BindsEnabled = 1; // Game Loop while (1) { if (levelnew >= 0) + { + CONTROL_BindsEnabled = 0; goto LOOP1; - CONTROL_BindsEnabled = 1; + } + + HandleAsync(); + OSD_DispatchQueued(); // Section B if (!nCDTrackLength && !nFreeze && !nNetPlayerCount) { @@ -2150,9 +2162,6 @@ LOOP3: videoNextPage(); - // TEST - trying to fix player unable to restart when dead... - handleevents(); - // TODO CONTROL_GetButtonInput(); CheckKeys(); UpdateSounds(); @@ -2182,6 +2191,7 @@ LOOP3: fclose(vcrfp); } + CONTROL_BindsEnabled = 0; goto MENU; } } @@ -2307,7 +2317,7 @@ LOOP3: // loc_12149: if (bInDemo) { - while (tclocks > totalclock) { handleevents(); } + while (tclocks > totalclock) { HandleAsync(); } tclocks = totalclock; } @@ -2319,6 +2329,7 @@ LOOP3: { CONTROL_ClearButton(gamefunc_Escape); MENU2: + CONTROL_BindsEnabled = 0; nMenu = menu_Menu(1); switch (nMenu) @@ -2343,6 +2354,7 @@ MENU2: } break; } + CONTROL_BindsEnabled = 1; RefreshStatus(); } else if (KB_KeyDown[sc_PrintScreen]) @@ -2392,8 +2404,6 @@ MENU2: } } - handleevents(); - if (PlayerList[nLocalPlayer].nHealth > 0) { if (BUTTON(gamefunc_Inventory_Left)) @@ -2596,7 +2606,7 @@ void DoTitle() while (LocalSoundPlaying()) { - handleevents(); + HandleAsync(); menu_DoPlasma(); overwritesprite(160, 100, nTile, 0, 3, kPalNormal); @@ -2826,7 +2836,7 @@ int Query(short nLines, short nKeys, ...) while (1) { - handleevents(); + HandleAsync(); char key = toupper(KB_GetCh()); diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index aa2b0a491..a4570339a 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -85,6 +85,8 @@ int DoSpiritHead(); void UpdateScreenSize(); +void HandleAsync(); + extern buildvfs_kfd kopen4loadfrommod(const char* filename, char searchfirst); extern int32_t g_commandSetup; extern int32_t g_noSetup; diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 0c2fae779..75d8ccbf3 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -196,7 +196,7 @@ void WaitNoKey(int nSecs, void (*pFunc) (void)) while (nTotalTime > totalclock) { #ifdef _MSC_VER - handleevents(); + HandleAsync(); #endif if (pFunc) { pFunc(); @@ -211,7 +211,7 @@ int WaitAnyKey(int nSecs) while (1) { #ifdef _MSC_VER - handleevents(); + HandleAsync(); #endif if (nTotalTime <= totalclock || nSecs == -1) { return -1; diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index 7c071cde7..3610a56cc 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -8,25 +8,6 @@ #include #include -#ifdef __WATCOMC__ -#include -#include -#include - -void handleevents() -{ -} -#else - -#ifdef __cplusplus -extern "C" { -#endif -int handleevents(void); -#ifdef __cplusplus -} -#endif -#endif - #define kMaxGrads 12 const char *GradList[kMaxGrads] = { @@ -212,7 +193,7 @@ void WaitTicks(int nTicks) if (htimer) { nTicks += totalclock; - while (nTicks > totalclock) { handleevents(); } + while (nTicks > totalclock) { HandleAsync(); } } else { diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index d0c5b9b3b..9b34a2cd1 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -443,13 +443,8 @@ void menu_DoPlasma() for (int j = 0; j < 5; j++) { int pB = plasma_B[j]; - - if ((plasma_C[j]>>16) <= nSmokeLeft) - plasma_C[j] = nSmokeLeft<<16; - else if ((plasma_C[j]>>16) >= nSmokeRight) - plasma_C[j] = nSmokeRight<<16; - int pC = plasma_C[j]; + int badOffset = (pC>>16) < nSmokeLeft || (pC>>16) >= nSmokeRight; uint8_t *ptr3 = (uint8_t*)(waloff[kExhumedLogo] + ((pC >> 16) - nSmokeLeft) * tilesiz[kExhumedLogo].y); @@ -461,6 +456,9 @@ void menu_DoPlasma() plasma_B[j] = -plasma_B[j]; plasma_A[j] = esi == 0; } + + if (badOffset) + continue; unsigned int nSmokeOffset = 0; @@ -501,6 +499,8 @@ void menu_DoPlasma() v28[nSmokeOffset] = 175; } + tileInvalidate(nPlasmaTile,-1,-1); + overwritesprite(0, 0, nPlasmaTile, 0, 2, kPalNormal); overwritesprite(160, 40, kExhumedLogo, 0, 3, kPalNormal); @@ -521,7 +521,7 @@ void menu_DoPlasma() // TEMP int time = totalclock + 4; while (totalclock < time) { - handleevents(); + HandleAsync(); } } @@ -666,7 +666,7 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest) while (var_38 < 12) { - handleevents(); + HandleAsync(); if ((totalclock - startTime) / kTimerTicks) { @@ -688,8 +688,6 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest) // for each level - drawing the 'level completed' on-fire smoke markers for (i = 0; i < kMap20; i++) { - handleevents(); - int screenY = (i >> 1) * -200; if (nLevelBest >= i) // check if the player has finished this level @@ -837,7 +835,7 @@ void menu_AdjustVolume() while (1) { - handleevents(); + HandleAsync(); menu_DoPlasma(); @@ -1027,7 +1025,7 @@ int menu_NewGameMenu() while (1) { - handleevents(); + HandleAsync(); menu_DoPlasma(); int y = (tilesiz[kMenuBlankTitleTile].y - (tilesiz[kMenuBlankTitleTile].y / 2) / 2) + 65; @@ -1139,7 +1137,7 @@ int menu_NewGameMenu() while (1) { - handleevents(); + HandleAsync(); overwritesprite(x, y, kMenuCursorTile, 0, 2, kPalNormal); overwritesprite(233, y, kMenuCursorTile, 0, 10, kPalNormal); @@ -1149,7 +1147,7 @@ int menu_NewGameMenu() while (KB_KeyWaiting()) { - handleevents(); + HandleAsync(); ch = KB_GetCh(); if (!ch) { @@ -1290,7 +1288,7 @@ int menu_LoadGameMenu() { menu_DoPlasma(); - handleevents(); + HandleAsync(); overwritesprite(80, 65, kMenuLoadGameTile, 0, 2, kPalNormal); @@ -1486,7 +1484,7 @@ int menu_Menu(int nVal) while (1) { - handleevents(); + HandleAsync(); // skip any disabled menu items so we're selecting the first active one while (!ptr[nMenu]) @@ -1566,7 +1564,7 @@ int menu_Menu(int nVal) // loc_3A0A7 while (KB_KeyDown[sc_Escape]) { - handleevents(); + HandleAsync(); PlayLocalSound(StaticSound[kSound33], 0); KB_KeyDown[sc_Escape] = 0; @@ -1892,7 +1890,7 @@ uint8_t AdvanceCinemaText() while (1) { - handleevents(); + HandleAsync(); if (KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Return] || KB_KeyDown[sc_Space]) { break; @@ -2229,7 +2227,7 @@ void DoLastLevelCinema() while (nEndTime > totalclock) { - handleevents(); + HandleAsync(); if (var_24 >= 116) { @@ -2252,7 +2250,7 @@ void DoLastLevelCinema() do { - handleevents(); + HandleAsync(); LABEL_11: if (strlen(gString[nString]) == 0) break; @@ -2274,7 +2272,7 @@ LABEL_11: // loc_3ADD7 while (1) { - handleevents(); + HandleAsync(); if (strlen(gString[nString]) == 0) break; @@ -2287,7 +2285,7 @@ LABEL_11: while (*nChar) { - handleevents(); + HandleAsync(); if (*nChar != ' ') { PlayLocalSound(StaticSound[kSound71], 0); @@ -2316,7 +2314,7 @@ LABEL_11: do { - handleevents(); + HandleAsync(); if (v11 <= totalclock) goto LABEL_11; @@ -2329,7 +2327,7 @@ LABEL_28: while (1) { - handleevents(); + HandleAsync(); DoStatic(var_28, var_24);