- added emscripten_sleep to some critical loops

This commit is contained in:
Ilya Shurumov 2021-04-11 01:24:05 +06:00
parent 4241a8a2c4
commit 612b03f261
6 changed files with 25 additions and 24 deletions

View File

@ -54,8 +54,7 @@ void ShowHiresScreens(char **names, int delay, int wait)
ReadControllers();
timedelay--;
} while ((wait != 0) || (Pads[0].dirnew & 0x40) == 0);
} while (wait || (Pads[0].dirnew & 0x40) == 0);
FadeOutHiresScreen();

View File

@ -67,7 +67,6 @@
#include "RAND.H"
#include "STRINGS.H"
#include "INLINE_C.H"
int levelstartpos[8][4] = {
@ -1330,13 +1329,11 @@ void GameLoop(void)
InitControllers();
VSync(0);
i = 4;
do {
for (i = 0; i < 5; i++)
{
ReadControllers();
VSync(0);
i--;
} while (i >= 0);
}
while (game_over == 0)
{
@ -1659,10 +1656,7 @@ void DrawGame(void)
RenderGame2(0);
ObjectDrawnCounter++;
while ((VSync(-1) - frame) < 2);
frame = VSync(-1);
SwapDrawBuffers();
}
else
@ -1678,12 +1672,17 @@ void DrawGame(void)
RenderGame2(1);
ObjectDrawnCounter++;
while ((VSync(-1) - frame) < 2);
frame = VSync(-1);
SwapDrawBuffers2(1);
}
#ifdef __EMSCRIPTEN__
while ((VSync(-1) - frame) < 2)
emscripten_sleep(1);
#else
while ((VSync(-1) - frame) < 2);
#endif
frame = VSync(-1);
#ifndef PSX
if (!FadingScreen)
PsyX_EndScene();
@ -1884,6 +1883,8 @@ int redriver2_main(int argc, char** argv)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "ERROR!", "Unable to load language files!\n\nSee console for details", NULL);
return -1;
}
// TODO: divide game by the states, place main loop here.
if (argc <= 1)
#endif

View File

@ -1,6 +1,5 @@
#include "driver2.h"
#include "sound.h"
#include "camera.h"
#include "xmplay.h"
#include "mission.h"
@ -841,6 +840,9 @@ void StopChannel(int channel)
do {
if (SpuGetKeyStatus(channels[channel].attr.voice) == 0)
break;
#ifdef __EMSCRIPTEN__
emscripten_sleep(1);
#endif
} while (VSync(-1) - vsync < 8);
ClearChannelFields(channel);
@ -853,14 +855,13 @@ void StopAllChannels(void)
{
int ct;
ct = 0;
do {
for (ct = 0; ct < MAX_SFX_CHANNELS; ct++)
{
StopChannel(ct);
VSync(0);
ct++;
} while (ct < MAX_SFX_CHANNELS);
}
}
// [D] [T]
void LockChannel(int channel)
{

View File

@ -4,9 +4,8 @@
#include <stdint.h>
#include <SDL.h>
#endif // !PSX
#include "system.h"
#include "platform.h"
#include "xaplay.h"
#include "loadview.h"

View File

@ -8,7 +8,7 @@
#include "LIBGPU.H"
#include "LIBSPU.H"
#include "psyx_compat.h"
#include "platform.h"
#define USE_PC_FILESYSTEM !defined(PSX) // PC filesystem is prioritized over CD
#define USE_CD_FILESYSTEM 1 // use always

View File

@ -7,6 +7,7 @@
#endif
#include "STRINGS.H"
#include "psyx_compat.h"
#ifndef PSX
#include "../utils/fs.h"