diff --git a/CMakeLists.txt b/CMakeLists.txt index 85153af04..1c52b280d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,14 +86,8 @@ if(APPLE AND NOT CMAKE_OSX_SYSROOT) OUTPUT_STRIP_TRAILING_WHITESPACE) endif() -# MSVC has a "latest" flag, which always uses the newest standard -# when available. GCC and Clang posess no such flag, and must be -# manually enforced. CMake, curiously, also doesn't have a "latest" -# standard flag either. -if (NOT MSVC) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE) set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE) @@ -131,7 +125,8 @@ if(MSVC) add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1 _CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1 _SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1 - _ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1) + _ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1 + _HAS_EXCEPTIONS=0) add_compile_options(/IGNORE:4221 $<$,$>:/wd4018> $<$,$>:/wd4800> @@ -165,14 +160,14 @@ if(MSVC) # Reports the proper value for the __cplusplus preprocessor macro. $<$:/Zc:__cplusplus> - - # Use latest C++ standard. - $<$:/std:c++latest> ) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # Flags for MSVC (not clang-cl) add_compile_options( + # Enable standards conforming preprocessor. + $<$:/Zc:preprocessor> + # Allow constexpr variables to have explicit external linkage. $<$:/Zc:externConstexpr> diff --git a/NESEmulator/CNESEmulator.cpp b/NESEmulator/CNESEmulator.cpp index 67f644515..df3524ae3 100644 --- a/NESEmulator/CNESEmulator.cpp +++ b/NESEmulator/CNESEmulator.cpp @@ -344,8 +344,8 @@ CNESEmulator::~CNESEmulator() { } int CNESEmulator::audioUpdate() { -// int origProcBufs = m_procBufs; -// + int origProcBufs = m_procBufs; + // uint8_t* data = apuGetBuf(); // if (data != NULL && m_procBufs) { // uint32_t apuBufSz = apuGetMaxBufSize(); @@ -370,7 +370,7 @@ int CNESEmulator::audioUpdate() { // // if (!origProcBufs) // // printf("OVERRUN\n"); // -// return origProcBufs; + return origProcBufs; } static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t); diff --git a/Runtime/CBasicsPC.cpp b/Runtime/CBasicsPC.cpp index 9afabf186..8efcf3ce0 100644 --- a/Runtime/CBasicsPC.cpp +++ b/Runtime/CBasicsPC.cpp @@ -24,6 +24,9 @@ #define _WIN32_IE 0x0400 #endif #include +#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#endif #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #endif @@ -349,7 +352,7 @@ void CBasics::MakeDir(const char* dir) { const nowide::wstackstring wdir(dir); if (!CreateDirectoryW(wdir.get(), NULL)) if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) - LogModule.report(logvisor::Fatal, "MakeDir({})", dir); + spdlog::fatal("MakeDir({})", dir); #else if (mkdir(dir, 0755)) if (errno != EEXIST) diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index 469a868d8..2a6dc9f2b 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -21,6 +21,7 @@ #endif #include #include +#include #endif #include "../version.h" @@ -537,8 +538,8 @@ int main(int argc, char** argv) { .allowJoystickBackgroundEvents = cvarCmns.getAllowJoystickInBackground(), .windowPosX = cvarCmns.getWindowPos().x, .windowPosY = cvarCmns.getWindowPos().y, - .windowWidth = static_cast(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x), - .windowHeight = static_cast(cvarCmns.getWindowSize().y < 0 ? 0 : cvarCmns.getWindowSize().y), + .windowWidth = static_cast(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x), + .windowHeight = static_cast(cvarCmns.getWindowSize().y < 0 ? 0 : cvarCmns.getWindowSize().y), .iconRGBA8 = icon.data.get(), .iconWidth = icon.width, .iconHeight = icon.height, diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 2e13e083c..48a6ce7b2 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -150,7 +150,7 @@ endfunction() set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) set(RUNTIME_LIBRARIES zeus nod NESEmulator libjpeg-turbo jbus kabufuda OptickCore - imgui_support aurora::aurora spdlog::spdlog + imgui_support aurora::aurora spdlog::spdlog $<$:nowide::nowide> ${ZLIB_LIBRARIES} ) @@ -218,7 +218,7 @@ elseif (UNIX) set(PLAT_LIBS rt) endif () -add_executable(metaforce CMain.cpp ${PLAT_SRCS} +add_executable(metaforce WIN32 CMain.cpp ${PLAT_SRCS} ImGuiConsole.hpp ImGuiConsole.cpp ImGuiControllerConfig.hpp ImGuiControllerConfig.cpp ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp) @@ -228,6 +228,9 @@ if (TARGET nfd) target_link_libraries(metaforce PRIVATE nfd) endif() target_compile_definitions(metaforce PUBLIC "-DMETAFORCE_TARGET_BYTE_ORDER=__BYTE_ORDER__") +if (WIN32) + target_link_options(metaforce PRIVATE /ENTRY:wWinMainCRTStartup) +endif () if (APPLE) if (TVOS) diff --git a/Runtime/CMemoryCardSysWin.cpp b/Runtime/CMemoryCardSysWin.cpp index 9615ce537..6d5a45e38 100644 --- a/Runtime/CMemoryCardSysWin.cpp +++ b/Runtime/CMemoryCardSysWin.cpp @@ -3,9 +3,12 @@ #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/IMain.hpp" #include "Runtime/CBasics.hpp" +#include "Runtime/Formatting.hpp" #include -#include +#include +#include +#include namespace metaforce { @@ -117,8 +120,8 @@ std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool do return {}; path += fmt::format("/MemoryCard{}.USA.raw", slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); - const nowide::wstackstring wpath(path); - FILE* fp = _wfopen(wpath.get(), L"wb"); + const auto wpath = nowide::widen(path); + FILE* fp = _wfopen(wpath.c_str(), L"wb"); if (fp == nullptr) { return {}; } @@ -136,8 +139,8 @@ std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool do } std::string tmpPath = path.substr(0, path.find_last_of('/')); CBasics::RecursiveMakeDir(tmpPath.c_str()); - const nowide::wstackstring wpath(path); - FILE* fp = _wfopen(wpath.get(), L"wb"); + const auto wpath = nowide::widen(path); + FILE* fp = _wfopen(wpath.c_str(), L"wb"); if (fp) { fclose(fp); return path; diff --git a/Runtime/ConsoleVariables/CVarManager.cpp b/Runtime/ConsoleVariables/CVarManager.cpp index 7a82579a2..750e9b505 100644 --- a/Runtime/ConsoleVariables/CVarManager.cpp +++ b/Runtime/ConsoleVariables/CVarManager.cpp @@ -225,7 +225,14 @@ std::vector CVarManager::loadCVars(const std::string& filename) if (parts.size() < 2) { continue; } - ret.emplace_back(StoreCVar::CVar{CStringExtras::Trim(parts[0]), CStringExtras::Trim(parts[1])}); + const auto key = CStringExtras::Trim(parts[0]); + auto value = parts[1]; + for (size_t i = 2; i < parts.size(); ++i) { + value += ":"; + value += parts[i]; + } + value = CStringExtras::Trim(value); + ret.emplace_back(StoreCVar::CVar{key, value}); } } } diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index 7c7926cc8..93ae4ea16 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -1955,6 +1955,9 @@ AuroraBackend backend_from_string(const std::string& str) { if (eq(str, "d3d12"sv) || eq(str, "d3d"sv)) { return BACKEND_D3D12; } + if (eq(str, "d3d11")) { + return BACKEND_D3D11; + } if (eq(str, "metal"sv)) { return BACKEND_METAL; } @@ -1982,6 +1985,8 @@ std::string_view backend_to_string(AuroraBackend backend) { return "auto"sv; case BACKEND_D3D12: return "d3d12"sv; + case BACKEND_D3D11: + return "d3d11"sv; case BACKEND_METAL: return "metal"sv; case BACKEND_VULKAN: @@ -2003,6 +2008,8 @@ std::string_view backend_name(AuroraBackend backend) { return "Auto"sv; case BACKEND_D3D12: return "D3D12"sv; + case BACKEND_D3D11: + return "D3D11"sv; case BACKEND_METAL: return "Metal"sv; case BACKEND_VULKAN: diff --git a/bintoc/CMakeLists.txt b/bintoc/CMakeLists.txt index 35f812015..f0ca663d8 100644 --- a/bintoc/CMakeLists.txt +++ b/bintoc/CMakeLists.txt @@ -3,7 +3,9 @@ cmake_policy(VERSION 3.15...3.20) project(bintoc LANGUAGES C) add_executable(bintoc bintoc.c) -add_subdirectory(../extern/athena/extern/zlib zlib EXCLUDE_FROM_ALL) + +find_package(ZLIB REQUIRED) +set(ZLIB_LIBRARIES ZLIB::ZLIB CACHE STRING "zlib libraries" FORCE) target_link_libraries(bintoc PRIVATE ${ZLIB_LIBRARIES}) install(TARGETS bintoc DESTINATION bin) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 4e6657c50..2db76a0c2 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -14,6 +14,18 @@ if (NOT TARGET spdlog) add_subdirectory(spdlog EXCLUDE_FROM_ALL) endif () +if (WIN32 AND NOT TARGET nowide) + include(FetchContent) + FetchContent_Declare( + nowide + URL https://github.com/boostorg/nowide/releases/download/v11.3.0/nowide_standalone_v11.3.0.tar.gz + URL_HASH SHA256=153ac93173c8de9c08e7701e471fa750f84c27e51fe329570c5aa06016591f8c + DOWNLOAD_EXTRACT_TIMESTAMP TRUE + EXCLUDE_FROM_ALL + ) + FetchContent_MakeAvailable(nowide) +endif () + add_subdirectory(nod EXCLUDE_FROM_ALL) add_subdirectory(jbus EXCLUDE_FROM_ALL) add_subdirectory(kabufuda EXCLUDE_FROM_ALL) diff --git a/extern/aurora b/extern/aurora index 1016fbb36..5c7ee8b04 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 1016fbb36d5479cbad909323d083ed232063a7a5 +Subproject commit 5c7ee8b04ab9febc11a6b79cfb54af6803e03c26 diff --git a/extern/nod b/extern/nod index 958430308..6febcc2c7 160000 --- a/extern/nod +++ b/extern/nod @@ -1 +1 @@ -Subproject commit 9584303083c8406a37a7834a443d8dfe34eb0d69 +Subproject commit 6febcc2c79c54a964a43ed462312091197d75bb2