diff --git a/CMakeLists.txt b/CMakeLists.txt index f949fa0b..fb66a28c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment ve # Set the C++ standard and enable the MSVC parallel build option set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") +set(PROJECT_TEAM "Lywx & YoshiCrystal") +set(PROJECT_VERSION_MAJOR 2) +set(PROJECT_VERSION_MINOR 0) +set(PROJECT_VERSION_PATCH 0) #add_compile_options(-fsanitize=address) #add_link_options(-fsanitize=address) @@ -69,6 +73,20 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() endif() +################################################################################ +# Global configuration types +################################################################################ +if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") +set(CMAKE_C_FLAGS_DEBUG "-g -ffast-math -DDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -ffast-math -DDEBUG") +set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") +else() +set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") +set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG") +endif() + # Set game compilation version set(VERSION us) set(USE_NETWORKING OFF) @@ -309,8 +327,16 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "Vorbis::vorbisfile" ) elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") + find_package(SDL2) + find_package(Vorbis REQUIRED) + link_libraries(Vorbis::vorbisfile) + find_package(Ogg REQUIRED) + link_libraries(Ogg::ogg) set(ADDITIONAL_LIBRARY_DEPENDENCIES -lglad + SDL2::SDL2 + "Ogg::ogg" + "Vorbis::vorbisfile" ) elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS") set(ADDITIONAL_LIBRARY_DEPENDENCIES @@ -360,6 +386,7 @@ nx_generate_nacp(${PROJECT_NAME}.nacp nx_create_nro(${PROJECT_NAME} NACP ${PROJECT_NAME}.nacp + ICON ${CMAKE_CURRENT_SOURCE_DIR}/nx-logo.jpg ) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.nro DESTINATION . COMPONENT ${PROJECT_NAME}) diff --git a/nx-logo.jpg b/nx-logo.jpg new file mode 100644 index 00000000..9d6fea2c Binary files /dev/null and b/nx-logo.jpg differ diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index dcedb08d..e4d5b4bf 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef __SWITCH__ +#include +#endif + namespace fs = std::filesystem; extern "C" { @@ -59,6 +63,11 @@ std::vector MemoryPool; GameEngine* GameEngine::Instance; GameEngine::GameEngine() { +#ifdef __SWITCH__ + Ship::Switch::Init(Ship::PreInitPhase); + Ship::Switch::Init(Ship::PostInitPhase); +#endif + std::vector archiveFiles; const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("sf64.o2r"); const std::string assets_path = Ship::Context::GetPathRelativeToAppDirectory("starship.o2r"); @@ -159,9 +168,11 @@ GameEngine::GameEngine() { this->context->Init(archiveFiles, {}, 3, { 32000, 1024, 1680 }, window, controlDeck); +#ifndef __SWITCH__ Ship::Context::GetInstance()->GetLogger()->set_level( (spdlog::level::level_enum) CVarGetInteger("gDeveloperTools.LogLevel", 1)); Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); +#endif auto loader = context->GetResourceManager()->GetResourceLoader(); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, @@ -289,6 +300,9 @@ void GameEngine::Destroy() { free(ptr); } MemoryPool.clear(); +#ifdef __SWITCH__ + Ship::Switch::Exit(); +#endif } void GameEngine::StartFrame() const { diff --git a/src/port/extractor/GameExtractor.cpp b/src/port/extractor/GameExtractor.cpp index 4b325a33..f8392bc8 100644 --- a/src/port/extractor/GameExtractor.cpp +++ b/src/port/extractor/GameExtractor.cpp @@ -4,8 +4,10 @@ #include "Context.h" #include "spdlog/spdlog.h" -#include "portable-file-dialogs.h" #include +#if !defined(__IOS__) && !defined(__ANDROID__) && !defined(__SWITCH__) +#include "portable-file-dialogs.h" +#endif std::unordered_map mGameList = { { "d8b1088520f7c5f81433292a9258c1184afa1457", "Star Fox 64 (U) (V1.0)" }, @@ -21,7 +23,7 @@ std::unordered_map mGameList = { }; bool GameExtractor::SelectGameFromUI() { -#if !defined(__IOS__) || !defined(__ANDROID__) || !defined(__SWITCH__) +#if !defined(__IOS__) && !defined(__ANDROID__) && !defined(__SWITCH__) auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64" }).result(); if (selection.empty()) { diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index b870dded..22b5b167 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -14,6 +14,11 @@ #include "port/notification/notification.h" #include "utils/StringHelper.h" +#ifdef __SWITCH__ +#include +#include +#endif + extern "C" { #include "sys.h" #include @@ -192,20 +197,10 @@ void DrawSettingsMenu(){ UIWidgets::Spacer(0); -#ifndef __SWITCH__ UIWidgets::CVarCheckbox("Menubar Controller Navigation", "gControlNav", { .tooltip = "Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar" }); -#endif - // UIWidgets::CVarCheckbox("Show Inputs", "gInputEnabled", { - // .tooltip = "Shows currently pressed inputs on the bottom right of the screen" - // }); - if (CVarGetInteger("gInputEnabled", 0)) { - UIWidgets::CVarSliderFloat("Input Scale", "gInputScale", 1.0f, 3.0f, 1.0f, { - .tooltip = "Sets the on screen size of the displayed inputs from the Show Inputs setting", - .format = "%.1fx", - }); - } + UIWidgets::CVarCheckbox("Invert Y Axis", "gInvertYAxis",{ .tooltip = "Inverts the Y axis for controlling vehicles" }); @@ -648,6 +643,16 @@ void DrawDebugMenu() { Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); } +#ifdef __SWITCH__ + if (UIWidgets::CVarCombobox("Switch CPU Profile", "gSwitchPerfMode", SWITCH_CPU_PROFILES, { + .tooltip = "Switches the CPU profile to a different one", + .defaultIndex = (int)Ship::SwitchProfiles::STOCK + })) { + SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[CVarGetInteger("gSwitchPerfMode", (int)Ship::SwitchProfiles::STOCK)]); + Ship::Switch::ApplyOverclock(); + } +#endif + UIWidgets::WindowButton("Gfx Debugger", "gGfxDebuggerEnabled", GameUI::mGfxDebuggerWindow, { .tooltip = "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" });