SYNC label appears everywhere if your computer is slow #511

This commit is contained in:
BADIM-PC\Vadim 2018-01-22 12:59:34 +03:00
parent cb7206db34
commit 607515947c
5 changed files with 31 additions and 28 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -66,12 +66,12 @@ static void readConfigNoSound(Config* config, lua_State* lua)
lua_pop(lua, 1);
}
static void readConfigShowMissedFrames(Config* config, lua_State* lua)
static void readConfigShowSync(Config* config, lua_State* lua)
{
lua_getglobal(lua, "MISSED_FRAMES");
lua_getglobal(lua, "SHOW_SYNC");
if(lua_isinteger(lua, -1))
config->data.missedFrames = lua_tointeger(lua, -1);
if(lua_isboolean(lua, -1))
config->data.showSync = lua_toboolean(lua, -1);
lua_pop(lua, 1);
}
@ -209,7 +209,7 @@ static void readConfig(Config* config)
readConfigVideoScale(config, lua);
readConfigCheckNewVersion(config, lua);
readConfigNoSound(config, lua);
readConfigShowMissedFrames(config, lua);
readConfigShowSync(config, lua);
readConfigUseVsync(config, lua);
readTheme(config, lua);
}

View File

@ -224,7 +224,7 @@ static struct
FileSystem* fs;
bool quitFlag;
s32 missedFrames;
bool missedFrame;
s32 argc;
char **argv;
@ -315,7 +315,7 @@ static struct
.fullscreen = false,
.quitFlag = false,
.missedFrames = 0,
.missedFrame = false,
.argc = 0,
.argv = NULL,
};
@ -2111,6 +2111,8 @@ static void drawRecordLabel(u32* frame, s32 sx, s32 sy, const u32* color)
static void drawDesyncLabel(u32* frame)
{
if(getConfig()->showSync && studio.missedFrame)
{
static const u16 DesyncLabel[] =
{
0b0110101010010011,
@ -2120,8 +2122,6 @@ static void drawDesyncLabel(u32* frame)
0b1100110010010011,
};
if(studio.missedFrames >= getConfig()->missedFrames)
{
enum{sx = TIC80_WIDTH-24, sy = 8, Cols = sizeof DesyncLabel[0]*BITS_IN_BYTE, Rows = COUNT_OF(DesyncLabel)};
const u32* pal = tic_palette_blit(&studio.tic->config.palette);
@ -2789,6 +2789,8 @@ static void emstick()
{
static double nextTick = -1.0;
studio.missedFrame = false;
if(nextTick < 0.0)
nextTick = emscripten_get_now();
@ -2797,9 +2799,15 @@ static void emstick()
double delay = nextTick - emscripten_get_now();
if(delay < 0.0)
{
nextTick -= delay;
studio.missedFrame = true;
}
else
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
if(studio.missedFrames > 0)
studio.missedFrames--;
}
#endif
@ -2842,6 +2850,8 @@ s32 main(s32 argc, char **argv)
while (!studio.quitFlag)
{
studio.missedFrame = false;
nextTick += Delta;
tick();
@ -2851,11 +2861,7 @@ s32 main(s32 argc, char **argv)
if(delay < 0)
{
nextTick -= delay;
if(studio.missedFrames < getConfig()->missedFrames)
studio.missedFrames++;
continue;
studio.missedFrame = true;
}
else
{
@ -2866,9 +2872,6 @@ s32 main(s32 argc, char **argv)
SDL_Delay(time);
}
}
if(studio.missedFrames > 0)
studio.missedFrames--;
}
}
}

View File

@ -102,7 +102,7 @@ typedef struct
bool checkNewVersion;
bool noSound;
bool useVsync;
s32 missedFrames;
bool showSync;
} StudioConfig;