forked from waskord/UnleashedRecomp_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpp
More file actions
100 lines (81 loc) · 2.61 KB
/
Copy pathapp.cpp
File metadata and controls
100 lines (81 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "app.h"
#ifdef _WIN32
#include <Windows.h>
#include <timeapi.h>
#endif
#include <cstdlib>
#include <api/SWA.h>
#include <gpu/video.h>
#include <install/installer.h>
#include <kernel/function.h>
#include <os/process.h>
#include <patches/audio_patches.h>
#include <patches/inspire_patches.h>
#include <ui/game_window.h>
#include <user/config.h>
#include <user/paths.h>
#include <user/registry.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);
}
// SWA::CApplication::CApplication
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;
SWA::SGlobals::Init();
Registry::Save();
__imp__sub_824EB490(ctx, base);
}
static std::thread::id g_mainThreadId = std::this_thread::get_id();
// SWA::CApplication::Update
PPC_FUNC_IMPL(__imp__sub_822C1130);
PPC_FUNC(sub_822C1130)
{
Video::WaitOnSwapChain();
// 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;
App::s_time += App::s_deltaTime;
// This function can also be called by the loading thread,
// which SDL does not like. To prevent the OS from thinking
// the process is unresponsive, we will flush while waiting
// for the pipelines to finish compiling in video.cpp.
if (std::this_thread::get_id() == g_mainThreadId)
{
SDL_PumpEvents();
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
GameWindow::Update();
}
AudioPatches::Update(App::s_deltaTime);
InspirePatches::Update();
// Apply subtitles option.
if (auto pApplicationDocument = SWA::CApplicationDocument::GetInstance())
pApplicationDocument->m_InspireSubtitles = Config::Subtitles;
if (Config::EnableEventCollisionDebugView)
*SWA::SGlobals::ms_IsTriggerRender = true;
if (Config::EnableGIMipLevelDebugView)
*SWA::SGlobals::ms_VisualizeLoadedLevel = true;
if (Config::EnableObjectCollisionDebugView)
*SWA::SGlobals::ms_IsObjectCollisionRender = true;
if (Config::EnableStageCollisionDebugView)
*SWA::SGlobals::ms_IsCollisionRender = true;
__imp__sub_822C1130(ctx, base);
}