diff --git a/.vs/launch.vs.json b/.vs/launch.vs.json index 7201456d92..af32f0bed6 100644 --- a/.vs/launch.vs.json +++ b/.vs/launch.vs.json @@ -1,5 +1,4 @@ { - // https://docs.microsoft.com/en-us/cpp/build/launch-vs-schema-reference-cpp?view=vs-2019 "version": "0.2.1", "defaults": {}, "configurations": [ @@ -8,9 +7,12 @@ "project": "CMakeLists.txt", "projectTarget": "goalc-test.exe (bin\\goalc-test.exe)", "name": "Run Tests - Summary", - "args": ["--gtest_brief=1"], + "args": [ + "--gtest_brief=1" + ], "env": { - "NEXT_DIR": "${projectDir}" + "NEXT_DIR": "${projectDir}", + "FAKE_ISO_PATH": "/game/fake_iso.txt" } }, { @@ -18,9 +20,12 @@ "project": "CMakeLists.txt", "projectTarget": "goalc-test.exe (bin\\goalc-test.exe)", "name": "Run Tests - Verbose", - "args": ["--gtest_brief=0"], + "args": [ + "--gtest_brief=0" + ], "env": { - "NEXT_DIR": "${projectDir}" + "NEXT_DIR": "${projectDir}", + "FAKE_ISO_PATH": "/game/fake_iso.txt" } }, { @@ -42,4 +47,4 @@ "name": "Build Decompiler" } ] -} +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7229990ef2..b40377dc4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Top Level CMakeLists.txt -cmake_minimum_required(VERSION 3.0) # todo - this was picked randomly +cmake_minimum_required(VERSION 3.16) project(jak) set(CMAKE_CXX_STANDARD 14) diff --git a/game/overlord/fake_iso.cpp b/game/overlord/fake_iso.cpp index f06c22ba83..22ea2c6bb8 100644 --- a/game/overlord/fake_iso.cpp +++ b/game/overlord/fake_iso.cpp @@ -348,6 +348,7 @@ uint32_t FS_LoadMusic(char* name, void* buffer) { (void)name; (void)buffer; assert(false); + return 0; } // TODO FS_LoadSoundBank @@ -355,4 +356,5 @@ uint32_t FS_LoadSoundBank(char* name, void* buffer) { (void)name; (void)buffer; assert(false); + return 0; } diff --git a/game/system/SystemThread.cpp b/game/system/SystemThread.cpp index 64121c6e11..2650245bcb 100644 --- a/game/system/SystemThread.cpp +++ b/game/system/SystemThread.cpp @@ -71,8 +71,8 @@ void SystemThreadManager::join() { */ void* bootstrap_thread_func(void* x) { SystemThread* thd = (SystemThread*)x; - SystemThreadInterface interface(thd); - thd->function(interface); + SystemThreadInterface iface(thd); + thd->function(iface); printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str()); return nullptr; } diff --git a/game/system/Timer.h b/game/system/Timer.h index ccdfbb742a..8bf0e0a096 100644 --- a/game/system/Timer.h +++ b/game/system/Timer.h @@ -1,6 +1,10 @@ #ifndef RUNTIME_TIMER_H #define RUNTIME_TIMER_H +#ifdef _WIN32 +#include +#endif + #include #include #include @@ -9,13 +13,56 @@ class Timer { public: explicit Timer() { start(); } - void start() { clock_gettime(CLOCK_MONOTONIC, &_startTime); } +#ifdef _WIN32 +#define MS_PER_SEC 1000ULL // MS = milliseconds +#define US_PER_MS 1000ULL // US = microseconds +#define HNS_PER_US 10ULL // HNS = hundred-nanoseconds (e.g., 1 hns = 100 ns) +#define NS_PER_US 1000ULL + +#define HNS_PER_SEC (MS_PER_SEC * US_PER_MS * HNS_PER_US) +#define NS_PER_HNS (100ULL) // NS = nanoseconds +#define NS_PER_SEC (MS_PER_SEC * US_PER_MS * NS_PER_US) + int Timer::clock_gettime_monotonic(struct timespec* tv) { + static LARGE_INTEGER ticksPerSec; + LARGE_INTEGER ticks; + double seconds; + + if (!ticksPerSec.QuadPart) { + QueryPerformanceFrequency(&ticksPerSec); + if (!ticksPerSec.QuadPart) { + errno = ENOTSUP; + return -1; + } + } + + QueryPerformanceCounter(&ticks); + + seconds = (double)ticks.QuadPart / (double)ticksPerSec.QuadPart; + tv->tv_sec = (time_t)seconds; + tv->tv_nsec = (long)((ULONGLONG)(seconds * NS_PER_SEC) % NS_PER_SEC); + + return 0; + } +#endif + + void start() { +#ifdef _WIN32 + clock_gettime_monotonic(&_startTime); +#elif __linux__ + clock_gettime(CLOCK_MONOTONIC, &_startTime); +#endif + } double getMs() { return (double)getNs() / 1.e6; } int64_t getNs() { struct timespec now; +#ifdef _WIN32 + clock_gettime_monotonic(&now); +#elif __linux__ clock_gettime(CLOCK_MONOTONIC, &now); +#endif + return (int64_t)(now.tv_nsec - _startTime.tv_nsec) + 1000000000 * (now.tv_sec - _startTime.tv_sec); } diff --git a/goalc/emitter/Register.h b/goalc/emitter/Register.h index 1e46393bb3..83c1924c8b 100644 --- a/goalc/emitter/Register.h +++ b/goalc/emitter/Register.h @@ -9,6 +9,8 @@ #include #include #include +#include + #include "common/common_types.h" namespace emitter {