2021-05-24 05:06:51 +00:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
2021-05-25 02:02:57 +00:00
|
|
|
#include <numeric>
|
2022-02-01 00:06:54 +00:00
|
|
|
#include <iostream>
|
2022-03-04 09:46:33 +00:00
|
|
|
#include "Runtime/CInfiniteLoopDetector.hpp"
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-05-04 00:27:19 +00:00
|
|
|
#include "ImGuiEngine.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
#include "Runtime/MP1/MP1.hpp"
|
|
|
|
#include "Runtime/ConsoleVariables/FileStoreManager.hpp"
|
|
|
|
#include "Runtime/ConsoleVariables/CVarManager.hpp"
|
|
|
|
#include "amuse/BooBackend.hpp"
|
|
|
|
|
|
|
|
#include "logvisor/logvisor.hpp"
|
|
|
|
|
2022-03-12 19:13:01 +00:00
|
|
|
#ifdef _WIN32
|
2022-02-22 05:53:57 +00:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif
|
|
|
|
#include <Windows.h>
|
|
|
|
#endif
|
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
#include "../version.h"
|
|
|
|
|
2022-02-21 02:28:07 +00:00
|
|
|
//#include <fenv.h>
|
|
|
|
//#pragma STDC FENV_ACCESS ON
|
|
|
|
|
2022-02-16 05:21:24 +00:00
|
|
|
#include <aurora/aurora.hpp>
|
2022-02-01 00:06:54 +00:00
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
using namespace std::literals;
|
|
|
|
|
|
|
|
class Limiter {
|
2021-05-30 19:03:35 +00:00
|
|
|
using delta_clock = std::chrono::high_resolution_clock;
|
|
|
|
using duration_t = std::chrono::nanoseconds;
|
2021-05-24 05:06:51 +00:00
|
|
|
|
|
|
|
public:
|
2021-05-30 19:03:35 +00:00
|
|
|
void Reset() { m_oldTime = delta_clock::now(); }
|
|
|
|
|
|
|
|
void Sleep(duration_t targetFrameTime) {
|
|
|
|
if (targetFrameTime.count() == 0) {
|
2021-05-24 05:06:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto start = delta_clock::now();
|
2021-05-30 19:03:35 +00:00
|
|
|
duration_t adjustedSleepTime = SleepTime(targetFrameTime);
|
|
|
|
if (adjustedSleepTime.count() > 0) {
|
2021-06-29 04:12:41 +00:00
|
|
|
NanoSleep(adjustedSleepTime);
|
2021-05-30 19:03:35 +00:00
|
|
|
duration_t overslept = TimeSince(start) - adjustedSleepTime;
|
|
|
|
if (overslept < duration_t{targetFrameTime}) {
|
2021-05-24 05:06:51 +00:00
|
|
|
m_overheadTimes[m_overheadTimeIdx] = overslept;
|
|
|
|
m_overheadTimeIdx = (m_overheadTimeIdx + 1) % m_overheadTimes.size();
|
|
|
|
}
|
|
|
|
}
|
2021-05-30 19:03:35 +00:00
|
|
|
Reset();
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 19:03:35 +00:00
|
|
|
duration_t SleepTime(duration_t targetFrameTime) {
|
|
|
|
const auto sleepTime = duration_t{targetFrameTime} - TimeSince(m_oldTime);
|
|
|
|
m_overhead = std::accumulate(m_overheadTimes.begin(), m_overheadTimes.end(), duration_t{}) / m_overheadTimes.size();
|
2021-05-24 05:06:51 +00:00
|
|
|
if (sleepTime > m_overhead) {
|
|
|
|
return sleepTime - m_overhead;
|
|
|
|
}
|
2021-05-30 19:03:35 +00:00
|
|
|
return duration_t{0};
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
delta_clock::time_point m_oldTime;
|
2021-05-30 19:03:35 +00:00
|
|
|
std::array<duration_t, 4> m_overheadTimes{};
|
2021-05-24 05:06:51 +00:00
|
|
|
size_t m_overheadTimeIdx = 0;
|
2021-05-30 19:03:35 +00:00
|
|
|
duration_t m_overhead = duration_t{0};
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2021-05-30 19:03:35 +00:00
|
|
|
duration_t TimeSince(delta_clock::time_point start) {
|
|
|
|
return std::chrono::duration_cast<duration_t>(delta_clock::now() - start);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
2021-06-29 04:12:41 +00:00
|
|
|
|
|
|
|
#if _WIN32
|
|
|
|
bool m_initialized;
|
|
|
|
double m_countPerNs;
|
|
|
|
|
|
|
|
void NanoSleep(const duration_t duration) {
|
|
|
|
if (!m_initialized) {
|
|
|
|
LARGE_INTEGER freq;
|
|
|
|
QueryPerformanceFrequency(&freq);
|
|
|
|
m_countPerNs = static_cast<double>(freq.QuadPart) / 1000000000.0;
|
|
|
|
m_initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
|
|
|
auto tickCount = static_cast<LONGLONG>(static_cast<double>(duration.count()) * m_countPerNs);
|
|
|
|
LARGE_INTEGER count;
|
|
|
|
QueryPerformanceCounter(&count);
|
|
|
|
if (ms > 10) {
|
|
|
|
// Adjust for Sleep overhead
|
|
|
|
::Sleep(ms - 10);
|
|
|
|
}
|
|
|
|
auto end = count.QuadPart + tickCount;
|
|
|
|
do {
|
|
|
|
QueryPerformanceCounter(&count);
|
|
|
|
} while (count.QuadPart < end);
|
|
|
|
}
|
|
|
|
#else
|
2022-02-07 10:45:56 +00:00
|
|
|
void NanoSleep(const duration_t duration) { std::this_thread::sleep_for(duration); }
|
2021-06-29 04:12:41 +00:00
|
|
|
#endif
|
2021-05-24 05:06:51 +00:00
|
|
|
};
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
extern std::string ExeDir;
|
2021-05-24 05:06:51 +00:00
|
|
|
|
|
|
|
namespace metaforce {
|
|
|
|
static logvisor::Module Log{"Metaforce"};
|
|
|
|
|
|
|
|
std::optional<MP1::CMain> g_mainMP1;
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
static std::string CPUFeatureString(const zeus::CPUInfo& cpuInf) {
|
|
|
|
std::string features;
|
2021-05-24 05:06:51 +00:00
|
|
|
#if defined(__x86_64__) || defined(_M_X64)
|
2021-06-30 18:20:45 +00:00
|
|
|
auto AddFeature = [&features](const char* str) {
|
2021-05-24 05:06:51 +00:00
|
|
|
if (!features.empty())
|
2021-06-30 18:20:45 +00:00
|
|
|
features += ", ";
|
2021-05-24 05:06:51 +00:00
|
|
|
features += str;
|
|
|
|
};
|
|
|
|
if (cpuInf.AESNI)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("AES-NI");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE1)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE2)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE2");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE3)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE3");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSSE3)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSSE3");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE4a)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE4a");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE41)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE4.1");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.SSE42)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("SSE4.2");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.AVX)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("AVX");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (cpuInf.AVX2)
|
2021-06-30 18:20:45 +00:00
|
|
|
AddFeature("AVX2");
|
2021-05-24 05:06:51 +00:00
|
|
|
#endif
|
|
|
|
return features;
|
|
|
|
}
|
2022-02-13 21:32:52 +00:00
|
|
|
#if 0
|
2021-05-24 05:06:51 +00:00
|
|
|
struct WindowCallback : boo::IWindowCallback {
|
2021-05-24 21:25:31 +00:00
|
|
|
friend struct Application;
|
|
|
|
|
|
|
|
private:
|
2021-05-24 05:06:51 +00:00
|
|
|
bool m_fullscreenToggleRequested = false;
|
|
|
|
boo::SWindowRect m_lastRect;
|
|
|
|
bool m_rectDirty = false;
|
|
|
|
bool m_windowInvalid = false;
|
2022-02-07 10:45:56 +00:00
|
|
|
// ImGuiWindowCallback m_imguiCallback;
|
2021-05-24 05:06:51 +00:00
|
|
|
|
|
|
|
void resized(const boo::SWindowRect& rect, bool sync) override {
|
|
|
|
m_lastRect = rect;
|
|
|
|
m_rectDirty = true;
|
2022-02-07 10:45:56 +00:00
|
|
|
// m_imguiCallback.resized(rect, sync);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void mouseDown(const boo::SWindowCoord& coord, EMouseButton button, boo::EModifierKey mods) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->mouseDown(coord, button, mods);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.mouseDown(coord, button, mods);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void mouseUp(const boo::SWindowCoord& coord, EMouseButton button, boo::EModifierKey mods) override {
|
2021-05-24 05:06:51 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
as->mouseUp(coord, button, mods);
|
|
|
|
}
|
|
|
|
}
|
2022-02-07 10:45:56 +00:00
|
|
|
// m_imguiCallback.mouseUp(coord, button, mods);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mouseMove(const boo::SWindowCoord& coord) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->mouseMove(coord);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.mouseMove(coord);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 10:45:56 +00:00
|
|
|
// void mouseEnter(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseEnter(coord); }
|
2021-05-24 21:25:31 +00:00
|
|
|
|
2022-02-07 10:45:56 +00:00
|
|
|
// void mouseLeave(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseLeave(coord); }
|
2021-05-24 21:25:31 +00:00
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
void scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->scroll(coord, scroll);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.scroll(coord, scroll);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->charKeyDown(charCode, mods, isRepeat);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.charKeyDown(charCode, mods, isRepeat);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void charKeyUp(unsigned long charCode, boo::EModifierKey mods) override {
|
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
as->charKeyUp(charCode, mods);
|
|
|
|
}
|
|
|
|
}
|
2022-02-07 10:45:56 +00:00
|
|
|
// m_imguiCallback.charKeyUp(charCode, mods);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void specialKeyDown(aurora::SpecialKey key, boo::EModifierKey mods, bool isRepeat) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->specialKeyDown(key, mods, isRepeat);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (True(mods & boo::EModifierKey::Alt)) {
|
2022-02-22 05:53:57 +00:00
|
|
|
// if (key == aurora::SpecialKey::Enter) {
|
2022-02-07 10:45:56 +00:00
|
|
|
// m_fullscreenToggleRequested = true;
|
2022-02-22 05:53:57 +00:00
|
|
|
// } else if (key == aurora::SpecialKey::F4) {
|
2022-02-07 10:45:56 +00:00
|
|
|
// m_windowInvalid = true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.specialKeyDown(key, mods, isRepeat);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void specialKeyUp(aurora::SpecialKey key, boo::EModifierKey mods) override {
|
2022-02-07 10:45:56 +00:00
|
|
|
// if (g_mainMP1) {
|
|
|
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
// as->specialKeyUp(key, mods);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// m_imguiCallback.specialKeyUp(key, mods);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void destroyed() override { m_windowInvalid = true; }
|
|
|
|
};
|
2022-02-13 21:32:52 +00:00
|
|
|
#endif
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
struct Application : aurora::AppDelegate {
|
2021-05-24 21:25:31 +00:00
|
|
|
private:
|
2022-02-21 02:28:07 +00:00
|
|
|
FileStoreManager& m_fileMgr;
|
|
|
|
CVarManager& m_cvarManager;
|
|
|
|
CVarCommons& m_cvarCommons;
|
2021-05-30 19:03:35 +00:00
|
|
|
ImGuiConsole m_imGuiConsole;
|
|
|
|
std::string m_errorString;
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string m_deferredProject;
|
2022-02-01 00:06:54 +00:00
|
|
|
bool m_projectInitialized = false;
|
2021-05-24 05:06:51 +00:00
|
|
|
std::optional<amuse::BooBackendVoiceAllocator> m_amuseAllocWrapper;
|
|
|
|
std::unique_ptr<boo::IAudioVoiceEngine> m_voiceEngine;
|
|
|
|
|
|
|
|
Limiter m_limiter{};
|
|
|
|
|
2021-05-24 21:25:31 +00:00
|
|
|
bool m_firstFrame = true;
|
2022-02-13 21:32:52 +00:00
|
|
|
bool m_fullscreenToggleRequested = false;
|
|
|
|
bool m_quitRequested = false;
|
2021-05-24 21:25:31 +00:00
|
|
|
using delta_clock = std::chrono::high_resolution_clock;
|
|
|
|
std::chrono::time_point<delta_clock> m_prevFrameTime;
|
|
|
|
|
2022-02-23 05:28:21 +00:00
|
|
|
std::vector<u32> m_deferredControllers; // used to capture controllers added before CInputGenerator
|
|
|
|
// is built, i.e during initialization
|
2022-02-09 08:54:53 +00:00
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
public:
|
2022-02-21 02:28:07 +00:00
|
|
|
Application(FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& cvarCmns)
|
2021-05-30 19:03:35 +00:00
|
|
|
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {}
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void onAppLaunched() noexcept override {
|
2022-02-01 00:06:54 +00:00
|
|
|
initialize();
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
auto backend = static_cast<std::string>(aurora::get_backend_string());
|
|
|
|
aurora::set_window_title(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend));
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
|
2021-05-24 05:06:51 +00:00
|
|
|
m_voiceEngine->setVolume(0.7f);
|
|
|
|
m_amuseAllocWrapper.emplace(*m_voiceEngine);
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
for (const auto& str : aurora::get_args()) {
|
|
|
|
auto arg = static_cast<std::string>(str);
|
|
|
|
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+'))
|
2021-05-24 05:06:51 +00:00
|
|
|
m_deferredProject = arg;
|
2021-06-30 18:20:45 +00:00
|
|
|
else if (arg == "--no-sound")
|
2021-05-24 05:06:51 +00:00
|
|
|
m_voiceEngine->setVolume(0.f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
void initialize() {
|
2021-05-24 05:06:51 +00:00
|
|
|
zeus::detectCPU();
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
for (const auto& str : aurora::get_args()) {
|
|
|
|
auto arg = static_cast<std::string>(str);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
|
|
|
|
Log.report(logvisor::Info, FMT_STRING("CPU Name: {}"), cpuInf.cpuBrand);
|
|
|
|
Log.report(logvisor::Info, FMT_STRING("CPU Vendor: {}"), cpuInf.cpuVendor);
|
2021-06-30 18:20:45 +00:00
|
|
|
Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf));
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
bool onAppIdle(float realDt) noexcept override {
|
2022-03-04 09:46:33 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
/* Ping the watchdog to let it know we're still alive */
|
|
|
|
CInfiniteLoopDetector::UpdateWatchDog(std::chrono::system_clock::now());
|
|
|
|
#endif
|
2022-02-09 08:54:53 +00:00
|
|
|
if (auto* input = g_InputGenerator) {
|
2022-02-23 05:28:21 +00:00
|
|
|
if (!m_deferredControllers.empty()) {
|
|
|
|
for (const auto which : m_deferredControllers) {
|
2022-03-22 19:04:57 +00:00
|
|
|
//input->controllerAdded(which);
|
2022-02-09 08:54:53 +00:00
|
|
|
}
|
2022-02-23 05:28:21 +00:00
|
|
|
m_deferredControllers.clear();
|
2022-02-09 08:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
if (!m_projectInitialized && !m_deferredProject.empty()) {
|
|
|
|
if (CDvdFile::Initialize(m_deferredProject)) {
|
|
|
|
m_projectInitialized = true;
|
2021-05-30 19:03:35 +00:00
|
|
|
} else {
|
2022-02-23 05:28:21 +00:00
|
|
|
Log.report(logvisor::Error, FMT_STRING("Failed to open disc image '{}'"), m_deferredProject);
|
|
|
|
m_errorString = fmt::format(FMT_STRING("Failed to open disc image '{}'"), m_deferredProject);
|
2021-05-30 19:03:35 +00:00
|
|
|
m_deferredProject.clear();
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 21:54:31 +00:00
|
|
|
const auto targetFrameTime = getTargetFrameTime();
|
|
|
|
bool skipRetrace = false;
|
|
|
|
if (g_ResFactory != nullptr) {
|
|
|
|
OPTICK_EVENT("Async Load Resources");
|
|
|
|
const auto idleTime = m_limiter.SleepTime(targetFrameTime);
|
|
|
|
skipRetrace = g_ResFactory->AsyncIdle(idleTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skipRetrace) {
|
|
|
|
// We stopped loading resources to catch the next frame
|
|
|
|
m_limiter.Reset();
|
|
|
|
} else {
|
|
|
|
// No more to load, and we're under frame time
|
|
|
|
{
|
|
|
|
OPTICK_EVENT("Sleep");
|
|
|
|
m_limiter.Sleep(targetFrameTime);
|
|
|
|
}
|
2021-06-28 22:10:54 +00:00
|
|
|
}
|
2021-06-30 21:54:31 +00:00
|
|
|
|
2021-06-28 22:10:54 +00:00
|
|
|
OPTICK_FRAME("MainThread");
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2021-06-06 20:59:53 +00:00
|
|
|
// Check if fullscreen has been toggled, if so set the fullscreen cvar accordingly
|
2022-02-13 21:32:52 +00:00
|
|
|
if (m_fullscreenToggleRequested) {
|
2021-06-06 20:59:53 +00:00
|
|
|
m_cvarCommons.m_fullscreen->fromBoolean(!m_cvarCommons.getFullscreen());
|
2022-02-13 21:32:52 +00:00
|
|
|
m_fullscreenToggleRequested = false;
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 20:59:53 +00:00
|
|
|
// Check if the user has modified the fullscreen CVar, if so set fullscreen state accordingly
|
|
|
|
if (m_cvarCommons.m_fullscreen->isModified()) {
|
2022-02-01 00:06:54 +00:00
|
|
|
aurora::set_fullscreen(m_cvarCommons.getFullscreen());
|
2021-06-06 20:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Let CVarManager inform all CVar listeners of the CVar's state and clear all mdoified flags if necessary
|
|
|
|
m_cvarManager.proc();
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
if (!g_mainMP1 && m_projectInitialized) {
|
|
|
|
g_mainMP1.emplace(nullptr, nullptr);
|
|
|
|
g_mainMP1->Init(m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper);
|
2021-05-30 19:03:35 +00:00
|
|
|
}
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2021-05-24 21:25:31 +00:00
|
|
|
float dt = 1 / 60.f;
|
2022-02-01 00:06:54 +00:00
|
|
|
if (m_cvarCommons.m_variableDt->toBoolean()) {
|
|
|
|
dt = std::min(realDt, 1 / 30.f);
|
2021-05-24 21:25:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 19:03:35 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
m_imGuiConsole.PreUpdate();
|
|
|
|
if (g_mainMP1->Proc(dt)) {
|
2022-02-01 00:06:54 +00:00
|
|
|
return false;
|
2021-05-30 19:03:35 +00:00
|
|
|
}
|
|
|
|
m_imGuiConsole.PostUpdate();
|
|
|
|
} else {
|
2022-02-23 05:28:21 +00:00
|
|
|
auto result = m_imGuiConsole.ShowAboutWindow(false, m_errorString, true);
|
|
|
|
if (result) {
|
|
|
|
m_deferredProject = std::move(*result);
|
|
|
|
}
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
if (m_quitRequested) {
|
|
|
|
if (g_mainMP1) {
|
|
|
|
g_mainMP1->Quit();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-02-01 00:06:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void onAppDraw() noexcept override {
|
|
|
|
OPTICK_EVENT("Draw");
|
|
|
|
if (g_Renderer != nullptr) {
|
|
|
|
g_Renderer->BeginScene();
|
2021-05-30 19:03:35 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
g_mainMP1->Draw();
|
|
|
|
}
|
2022-02-01 00:06:54 +00:00
|
|
|
g_Renderer->EndScene();
|
2021-05-24 21:25:31 +00:00
|
|
|
}
|
2022-02-01 00:06:54 +00:00
|
|
|
}
|
2021-05-24 21:25:31 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
void onAppPostDraw() noexcept override {
|
|
|
|
OPTICK_EVENT("PostDraw");
|
2021-05-24 05:06:51 +00:00
|
|
|
if (m_voiceEngine) {
|
|
|
|
m_voiceEngine->pumpAndMixVoices();
|
|
|
|
}
|
|
|
|
CGraphics::TickRenderTimings();
|
|
|
|
++logvisor::FrameIndex;
|
|
|
|
}
|
|
|
|
|
2022-02-06 22:53:42 +00:00
|
|
|
void onAppWindowResized(const aurora::WindowSize& size) noexcept override {
|
2022-02-26 20:38:08 +00:00
|
|
|
CGraphics::SetViewportResolution({static_cast<s32>(size.fb_width), static_cast<s32>(size.fb_height)});
|
2022-02-06 22:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onAppWindowMoved(std::int32_t x, std::int32_t y) noexcept override {
|
|
|
|
// TODO: implement this
|
|
|
|
}
|
2022-02-08 01:48:08 +00:00
|
|
|
|
2022-02-20 21:06:04 +00:00
|
|
|
void onAppDisplayScaleChanged(float scale) noexcept override { ImGuiEngine_Initialize(scale); }
|
|
|
|
|
2022-02-08 01:48:08 +00:00
|
|
|
void onControllerButton(uint32_t idx, aurora::ControllerButton button, bool pressed) noexcept override {
|
|
|
|
if (auto* input = g_InputGenerator) {
|
2022-03-22 19:04:57 +00:00
|
|
|
//input->controllerButton(idx, button, pressed);
|
2022-02-08 01:48:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onControllerAxis(uint32_t idx, aurora::ControllerAxis axis, int16_t value) noexcept override {
|
|
|
|
if (auto* input = g_InputGenerator) {
|
2022-03-22 19:04:57 +00:00
|
|
|
//input->controllerAxis(idx, axis, value);
|
2022-02-08 01:48:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 08:54:53 +00:00
|
|
|
void onControllerAdded(uint32_t which) noexcept override {
|
|
|
|
if (auto* input = g_InputGenerator) {
|
2022-03-22 19:04:57 +00:00
|
|
|
//input->controllerAdded(which);
|
2022-02-09 08:54:53 +00:00
|
|
|
} else {
|
2022-02-23 05:28:21 +00:00
|
|
|
m_deferredControllers.emplace_back(which);
|
2022-02-09 08:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onControllerRemoved(uint32_t which) noexcept override {
|
|
|
|
if (auto* input = g_InputGenerator) {
|
2022-03-22 19:04:57 +00:00
|
|
|
//input->controllerRemoved(which);
|
2022-02-09 08:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
void onAppExiting() noexcept override {
|
|
|
|
m_imGuiConsole.Shutdown();
|
|
|
|
if (g_mainMP1) {
|
|
|
|
g_mainMP1->Shutdown();
|
|
|
|
}
|
|
|
|
g_mainMP1.reset();
|
|
|
|
m_cvarManager.serialize();
|
|
|
|
m_voiceEngine.reset();
|
|
|
|
m_amuseAllocWrapper.reset();
|
|
|
|
CDvdFile::Shutdown();
|
|
|
|
}
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void onCharKeyDown(uint8_t code, aurora::ModifierKey mods, bool isRepeat) noexcept override {
|
2022-02-07 10:45:56 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
2022-02-13 21:32:52 +00:00
|
|
|
as->charKeyDown(code, mods, isRepeat);
|
2022-02-07 10:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void onCharKeyUp(uint8_t code, aurora::ModifierKey mods) noexcept override {
|
2022-02-07 10:45:56 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
2022-02-13 21:32:52 +00:00
|
|
|
as->charKeyUp(code, mods);
|
2022-02-07 10:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void onSpecialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat) noexcept override {
|
2022-02-07 10:45:56 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
2022-02-13 21:32:52 +00:00
|
|
|
as->specialKeyDown(key, mods, isRepeat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (True(mods & (aurora::ModifierKey::LeftAlt | aurora::ModifierKey::RightAlt))) {
|
|
|
|
if (key == aurora::SpecialKey::Enter) {
|
|
|
|
m_fullscreenToggleRequested = true;
|
|
|
|
} else if (key == aurora::SpecialKey::F4) {
|
|
|
|
m_quitRequested = true;
|
2022-02-07 10:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void onSpecialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods) noexcept override {
|
2022-02-07 10:45:56 +00:00
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
2022-02-13 21:32:52 +00:00
|
|
|
as->specialKeyUp(key, mods);
|
2022-02-07 10:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-20 03:22:03 +00:00
|
|
|
void onTextInput(const std::string& text) noexcept override {}
|
2022-02-16 05:21:24 +00:00
|
|
|
|
2022-02-20 03:22:03 +00:00
|
|
|
void onModifierKeyDown(aurora::ModifierKey mods, bool isRepeat) noexcept override {}
|
|
|
|
void onModifierKeyUp(aurora::ModifierKey mods) noexcept override {}
|
|
|
|
|
2022-03-16 02:38:55 +00:00
|
|
|
void onMouseMove(int32_t x, int32_t y, int32_t xrel, int32_t yrel, aurora::MouseButton state) noexcept override {
|
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
as->mouseMove(SWindowCoord{.pixel = {x, y}});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onMouseButtonDown(int32_t x, int32_t y, aurora::MouseButton button, int32_t clicks) noexcept override {
|
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
EMouseButton asBtn;
|
|
|
|
switch (button) {
|
|
|
|
case aurora::MouseButton::None:
|
|
|
|
asBtn = EMouseButton::None;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Primary:
|
|
|
|
asBtn = EMouseButton::Primary;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Middle:
|
|
|
|
asBtn = EMouseButton::Middle;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Secondary:
|
|
|
|
asBtn = EMouseButton::Secondary;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Aux1:
|
|
|
|
asBtn = EMouseButton::Aux1;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Aux2:
|
|
|
|
asBtn = EMouseButton::Aux2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
as->mouseDown(SWindowCoord{.pixel = {x, y}}, asBtn, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onMouseButtonUp(int32_t x, int32_t y, aurora::MouseButton button) noexcept override {
|
|
|
|
if (g_mainMP1) {
|
|
|
|
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
|
|
|
EMouseButton asBtn;
|
|
|
|
switch (button) {
|
|
|
|
case aurora::MouseButton::None:
|
|
|
|
asBtn = EMouseButton::None;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Primary:
|
|
|
|
asBtn = EMouseButton::Primary;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Middle:
|
|
|
|
asBtn = EMouseButton::Middle;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Secondary:
|
|
|
|
asBtn = EMouseButton::Secondary;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Aux1:
|
|
|
|
asBtn = EMouseButton::Aux1;
|
|
|
|
break;
|
|
|
|
case aurora::MouseButton::Aux2:
|
|
|
|
asBtn = EMouseButton::Aux2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
as->mouseUp(SWindowCoord{.pixel = {x, y}}, asBtn, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-20 03:22:03 +00:00
|
|
|
void onImGuiInit(float scale) noexcept override { ImGuiEngine_Initialize(scale); }
|
|
|
|
|
|
|
|
void onImGuiAddTextures() noexcept override { ImGuiEngine_AddTextures(); }
|
2022-02-16 05:21:24 +00:00
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
[[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
|
|
|
|
|
|
|
|
[[nodiscard]] uint32_t getSamples() const { return m_cvarCommons.getSamples(); }
|
|
|
|
|
|
|
|
[[nodiscard]] uint32_t getAnisotropy() const { return m_cvarCommons.getAnisotropy(); }
|
|
|
|
|
|
|
|
[[nodiscard]] bool getDeepColor() const { return m_cvarCommons.getDeepColor(); }
|
|
|
|
|
2021-05-30 19:03:35 +00:00
|
|
|
[[nodiscard]] std::chrono::nanoseconds getTargetFrameTime() const {
|
|
|
|
if (m_cvarCommons.getVariableFrameTime()) {
|
|
|
|
return std::chrono::nanoseconds{0};
|
|
|
|
}
|
|
|
|
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds{1}) / 60;
|
2021-05-24 21:25:31 +00:00
|
|
|
}
|
2021-05-24 05:06:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace metaforce
|
|
|
|
|
|
|
|
static void SetupBasics(bool logging) {
|
|
|
|
auto result = zeus::validateCPU();
|
|
|
|
if (!result.first) {
|
|
|
|
#if _WIN32 && !WINDOWS_STORE
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string msg =
|
|
|
|
fmt::format(FMT_STRING("ERROR: This build of Metaforce requires the following CPU features:\n{}\n"),
|
2021-05-24 05:06:51 +00:00
|
|
|
metaforce::CPUFeatureString(result.second));
|
2021-06-30 18:20:45 +00:00
|
|
|
MessageBoxW(nullptr, nowide::widen(msg).c_str(), L"CPU error", MB_OK | MB_ICONERROR);
|
2021-05-24 05:06:51 +00:00
|
|
|
#else
|
|
|
|
fmt::print(stderr, FMT_STRING("ERROR: This build of Metaforce requires the following CPU features:\n{}\n"),
|
|
|
|
metaforce::CPUFeatureString(result.second));
|
|
|
|
#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
logvisor::RegisterStandardExceptions();
|
|
|
|
if (logging)
|
|
|
|
logvisor::RegisterConsoleLogger();
|
|
|
|
|
|
|
|
#if SENTRY_ENABLED
|
2022-02-21 02:28:07 +00:00
|
|
|
FileStoreManager fileMgr{"sentry-native-metaforce"};
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string cacheDir{fileMgr.getStoreRoot()};
|
2021-05-24 05:06:51 +00:00
|
|
|
logvisor::RegisterSentry("metaforce", METAFORCE_WC_DESCRIBE, cacheDir.c_str());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
static bool IsClientLoggingEnabled(int argc, char** argv) {
|
2022-02-21 02:28:07 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (!strncmp(argv[i], "-l", 2)) {
|
2021-05-24 05:06:51 +00:00
|
|
|
return true;
|
2022-02-21 02:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-24 05:06:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !WINDOWS_STORE
|
2021-06-30 18:20:45 +00:00
|
|
|
int main(int argc, char** argv) {
|
2022-02-20 03:22:03 +00:00
|
|
|
// TODO: This seems to fix a lot of weird issues with rounding
|
|
|
|
// but breaks animations, need to research why this is the case
|
|
|
|
// for now it's disabled
|
|
|
|
// fesetround(FE_TOWARDZERO);
|
2022-02-21 02:28:07 +00:00
|
|
|
if (argc > 1 && !strcmp(argv[1], "--dlpackage")) {
|
2021-05-24 05:06:51 +00:00
|
|
|
fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE);
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetupBasics(IsClientLoggingEnabled(argc, argv));
|
2022-02-28 01:35:13 +00:00
|
|
|
metaforce::FileStoreManager fileMgr{"AxioDL", "metaforce"};
|
2022-02-21 02:28:07 +00:00
|
|
|
metaforce::CVarManager cvarMgr{fileMgr};
|
|
|
|
metaforce::CVarCommons cvarCmns{cvarMgr};
|
2021-05-24 05:06:51 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::vector<std::string> args;
|
2021-05-24 05:06:51 +00:00
|
|
|
for (int i = 1; i < argc; ++i)
|
2021-06-30 18:20:45 +00:00
|
|
|
args.emplace_back(argv[i]);
|
2021-05-24 05:06:51 +00:00
|
|
|
cvarMgr.parseCommandLine(args);
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
std::string logFile = cvarCmns.getLogFile();
|
|
|
|
std::string logFilePath;
|
2021-05-24 05:06:51 +00:00
|
|
|
if (!logFile.empty()) {
|
|
|
|
std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
|
|
|
char buf[100];
|
|
|
|
std::strftime(buf, 100, "%Y-%m-%d_%H-%M-%S", std::localtime(&time));
|
2021-06-30 18:20:45 +00:00
|
|
|
logFilePath = fmt::format(FMT_STRING("{}/{}-{}"), fileMgr.getStoreRoot(), buf, logFile);
|
2021-05-24 05:06:51 +00:00
|
|
|
logvisor::RegisterFileLogger(logFilePath.c_str());
|
|
|
|
}
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns);
|
2022-02-16 05:21:24 +00:00
|
|
|
auto icon = metaforce::GetIcon();
|
|
|
|
auto data = aurora::Icon{
|
|
|
|
.data = std::move(icon.data),
|
|
|
|
.width = icon.width,
|
|
|
|
.height = icon.height,
|
|
|
|
};
|
2022-02-16 09:23:39 +00:00
|
|
|
aurora::app_run(std::move(app), std::move(data), argc, argv);
|
2022-02-01 00:06:54 +00:00
|
|
|
return 0;
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if WINDOWS_STORE
|
|
|
|
#include "boo/UWPViewProvider.hpp"
|
|
|
|
using namespace Windows::ApplicationModel::Core;
|
|
|
|
|
|
|
|
[Platform::MTAThread] int WINAPIV main(Platform::Array<Platform::String ^> ^ params) {
|
|
|
|
SetupBasics(false);
|
|
|
|
metaforce::Application appCb;
|
2021-06-30 18:20:45 +00:00
|
|
|
auto viewProvider = ref new boo::ViewProvider(appCb, "metaforce", "Metaforce", "metaforce", params, false);
|
2021-05-24 05:06:51 +00:00
|
|
|
CoreApplication::Run(viewProvider);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif _WIN32
|
2021-05-25 02:02:57 +00:00
|
|
|
#include <shellapi.h>
|
2021-06-30 18:20:45 +00:00
|
|
|
#include <nowide/args.hpp>
|
2021-05-25 02:02:57 +00:00
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int) {
|
2021-05-24 05:06:51 +00:00
|
|
|
int argc = 0;
|
2021-06-30 18:20:45 +00:00
|
|
|
char** argv = nullptr;
|
|
|
|
nowide::args _(argc, argv);
|
2021-05-25 02:02:57 +00:00
|
|
|
const DWORD outType = GetFileType(GetStdHandle(STD_ERROR_HANDLE));
|
2021-06-30 18:20:45 +00:00
|
|
|
if (IsClientLoggingEnabled(argc, argv) && outType == FILE_TYPE_UNKNOWN)
|
2021-05-24 05:06:51 +00:00
|
|
|
logvisor::CreateWin32Console();
|
2021-06-30 18:20:45 +00:00
|
|
|
return main(argc, argv);
|
2021-05-24 05:06:51 +00:00
|
|
|
}
|
|
|
|
#endif
|