diff --git a/.github/workflows/build_mac32.yml b/.github/workflows/build_mac32.yml index fa2366c88..d7325850f 100644 --- a/.github/workflows/build_mac32.yml +++ b/.github/workflows/build_mac32.yml @@ -31,8 +31,8 @@ jobs: cd src PATH=$PATH:/usr/local/compiler/target/bin - i386-apple-darwin8-clang *.c Window_cocoa.m ${{ env.COMMON_FLAGS }} $LATEST_FLAG -o cc-mac32-gl1 -framework Cocoa -framework OpenGL -framework IOKit -lobjc -lgcc_s.1 - i386-apple-darwin8-clang *.c Window_cocoa.m ${{ env.COMMON_FLAGS }} $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -o cc-mac32-gl2 -framework Cocoa -framework OpenGL -framework IOKit -lobjc -lgcc_s.1 + i386-apple-darwin8-clang *.c Window_cocoa.m ${{ env.COMMON_FLAGS }} $LATEST_FLAG -o cc-mac32-gl1 -framework Cocoa -framework OpenGL -framework IOKit -lobjc -static-libgcc + i386-apple-darwin8-clang *.c Window_cocoa.m ${{ env.COMMON_FLAGS }} $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -o cc-mac32-gl2 -framework Cocoa -framework OpenGL -framework IOKit -lobjc -static-libgcc - uses: ./.github/actions/notify_failure diff --git a/src/Game.c b/src/Game.c index b61f56769..3af0ea1ff 100644 --- a/src/Game.c +++ b/src/Game.c @@ -636,13 +636,20 @@ static void LimitFPS(void) { #else static float gfx_targetTime, gfx_actualTime; +static CC_INLINE float ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end) { + cc_uint64 elapsed = Stopwatch_ElapsedMicroseconds(beg, end); + if (elapsed > 5000000) elapsed = 5000000; + + return (int)elapsed / 1000.0f; +} + /* Examines difference between expected and actual frame times, */ /* then sleeps if actual frame time is too fast */ static void LimitFPS(void) { cc_uint64 frameEnd, sleepEnd; frameEnd = Stopwatch_Measure(); - gfx_actualTime += Stopwatch_ElapsedMicroseconds(frameStart, frameEnd) / 1000.0f; + gfx_actualTime += ElapsedMilliseconds(frameStart, frameEnd); gfx_targetTime += gfx_minFrameMs; /* going faster than FPS limit - sleep to slow down */ @@ -654,7 +661,7 @@ static void LimitFPS(void) { /* duration can significantly deviate from requested time */ /* (e.g. requested 4ms, but actually slept for 8ms) */ sleepEnd = Stopwatch_Measure(); - gfx_actualTime += Stopwatch_ElapsedMicroseconds(frameEnd, sleepEnd) / 1000.0f; + gfx_actualTime += ElapsedMilliseconds(frameEnd, sleepEnd); } /* reset accumulated time to avoid excessive FPS drift */ @@ -728,7 +735,7 @@ static CC_INLINE void Game_RenderFrame(void) { /* avoid large delta with suspended process */ if (elapsed > 5000000) elapsed = 5000000; - double deltaD = elapsed / (1000.0 * 1000.0); + double deltaD = (int)elapsed / (1000.0 * 1000.0); float delta = (float)deltaD; Window_ProcessEvents(delta);