Files
UnleashedRecomp/UnleashedRecomp/app.cpp
Skyth (Asilkan) f1416c85ba Implement frame limiter. (#60)
* Implement audio timing with integer math.

* Add busy loop to audio thread.

* Implement a frame limiter.

* Implement implot.

* Add more stuff to the profiler window.

* Redo frame limiter logic to fix drifting.

* Move frame limiter, add limiters for SFD & loading screen.

* Update waiting logic for audio thread.

* Correct small delta time errors.

* Decrease delta time error threshold.

* Set busy wait threshold to 2ms.

* Change spin wait in D3D12 present to infinite wait.

* Replace FPS literals with constants.
2024-12-22 19:58:06 +03:00

60 lines
1.3 KiB
C++

#include <app.h>
#include <install/installer.h>
#include <kernel/function.h>
#include <ui/game_window.h>
#include <patches/audio_patches.h>
#include <user/config.h>
#include <os/process.h>
void App::Restart(std::vector<std::string> restartArgs)
{
os::process::StartProcess(os::process::GetExecutablePath(), restartArgs, os::process::GetWorkingDirectory());
Exit();
}
void App::Exit()
{
Config::Save();
#ifdef _WIN32
timeEndPeriod(1);
#endif
std::_Exit(0);
}
// CApplication::Ctor
PPC_FUNC_IMPL(__imp__sub_824EB490);
PPC_FUNC(sub_824EB490)
{
App::s_isInit = true;
App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath());
App::s_language = Config::Language;
__imp__sub_824EB490(ctx, base);
}
// CApplication::Update
PPC_FUNC_IMPL(__imp__sub_822C1130);
PPC_FUNC(sub_822C1130)
{
// Correct small delta time errors.
if (Config::FPS >= FPS_MIN && Config::FPS < FPS_MAX)
{
double targetDeltaTime = 1.0 / Config::FPS;
if (abs(ctx.f1.f64 - targetDeltaTime) < 0.00001)
ctx.f1.f64 = targetDeltaTime;
}
App::s_deltaTime = ctx.f1.f64;
SDL_PumpEvents();
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
GameWindow::Update();
AudioPatches::Update(App::s_deltaTime);
__imp__sub_822C1130(ctx, base);
}