summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2025-03-07 17:39:58 -0600
committerLywx <kiritodev01@gmail.com>2025-03-07 18:00:41 -0600
commit5f8550790adb5ce374ac31965f533f91e8d36191 (patch)
treeb94f5fe2cfd0194728a109caae28cebe60894158
parent629125110d50c1b206b8cd9c5560e47e80377a05 (diff)
Fixed compilation
-rw-r--r--.gitignore8
-rw-r--r--CMakeLists.txt45
-rw-r--r--src/port/Engine.cpp35
-rw-r--r--src/port/GameExtractor.cpp7
-rw-r--r--src/port/ui/PortMenu.cpp25
-rw-r--r--src/stubs.c2
6 files changed, 97 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index d7a173155..c3c08ceb1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -119,4 +119,10 @@ imgui.ini
spaghettify.cfg.json
# modding
-*.wasm \ No newline at end of file
+*.wasm
+
+cmake-build-*/
+.idea/
+.vs
+build*/
+.DS_Store \ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb8f88ebf..c83e5558a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,12 +15,17 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment ve
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_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Spaghettify)
+set(PROJECT_TEAM "MegaMech")
+set(PROJECT_VERSION_MAJOR 1)
+set(PROJECT_VERSION_MINOR 0)
+set(PROJECT_VERSION_PATCH 0)
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
# Add a custom module path to locate additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
-include(FindFontconfig)
+set(YAML_CPP_STATIC_DEFINE ON)
+add_compile_definitions(YAML_CPP_STATIC_DEFINE)
include(cmake/lus-cvars.cmake)
if (WIN32)
@@ -70,6 +75,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 ON)
@@ -80,7 +99,7 @@ set(GFX_DEBUG_DISASSEMBLER ON)
add_compile_definitions(
VERSION_US=1
ENABLE_RUMBLE=1
- # F3DEX_GBI=1
+ F3DEX_GBI=1
_LANGUAGE_C
_USE_MATH_DEFINES
CIMGUI_DEFINE_ENUMS_AND_STRUCTS
@@ -243,7 +262,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(dr_libs)
#==============================================================================#
-# Libultraship Integration #
+# Libultraship Integration #
#==============================================================================#
include_directories(
@@ -347,8 +366,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"Vorbis::vorbisfile"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
+ find_package(SDL2)
set(ADDITIONAL_LIBRARY_DEPENDENCIES
-lglad
+ SDL2::SDL2
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
@@ -376,8 +397,12 @@ if(USE_NETWORKING)
endif()
find_package(SDL2_net REQUIRED)
include_directories(${SDL2_NET_INCLUDE_DIRS})
- # target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net)
- # target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING)
+ if(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
+ target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net)
+ else()
+ target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net)
+ endif()
endif()
option(USE_STANDALONE "Build as a standalone executable" OFF)
@@ -408,11 +433,6 @@ endif()
################################################################################
# Compile and link options
################################################################################
-
-set(GBI_UCODE F3DEX_GBI)
-
-target_compile_definitions(${PROJECT_NAME} PRIVATE F3DEX_GBI=1)
-
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
@@ -603,6 +623,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
endif()
endif()
+if(NOT CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
include(ExternalProject)
ExternalProject_Add(TorchExternal
PREFIX TorchExternal
@@ -616,7 +637,6 @@ if (MSVC)
else()
set(TORCH_EXECUTABLE ${install_dir}/src/TorchExternal-build/torch)
endif()
-message(STATUS "Torch executable path: ${TORCH_EXECUTABLE}")
add_custom_target(
ExtractAssets
@@ -661,6 +681,7 @@ endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES)
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/SpaghettiKart.desktop")
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_ICON_FILE "${CMAKE_SOURCE_DIR}/logo.png")
+endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_GENERATOR "External")
@@ -671,4 +692,4 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif()
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/configure-packaging.cmake)
-include(cmake/packaging.cmake)
+include(cmake/packaging.cmake) \ No newline at end of file
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index 4a03712e1..179315595 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -29,6 +29,10 @@
#include <utility>
+#ifdef __SWITCH__
+#include <port/switch/SwitchImpl.h>
+#endif
+
extern "C" {
bool prevAltAssets = false;
float gInterpolationStep = 0.0f;
@@ -46,6 +50,10 @@ float gInterpolationStep = 0.0f;
GameEngine* GameEngine::Instance;
GameEngine::GameEngine() {
+#ifdef __SWITCH__
+ Ship::Switch::Init(Ship::PreInitPhase);
+ Ship::Switch::Init(Ship::PostInitPhase);
+#endif
std::vector<std::string> archiveFiles;
const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("spaghetti.o2r");
@@ -102,10 +110,11 @@ GameEngine::GameEngine() {
this->context->Init(archiveFiles, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck);
-
- // this->context = Ship::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3,
- // { 26800, 512, 1100 });
-
+#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
wnd->SetRendererUCode(ucode_f3dex);
this->context->InitGfxDebugger();
@@ -193,18 +202,21 @@ bool GameEngine::GenAssetFile() {
}
void GameEngine::ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type) {
- #if defined(__SWITCH__)
- SPDLOG_ERROR(message);
- #else
- SDL_ShowSimpleMessageBox(type, title, message, nullptr);
- SPDLOG_ERROR(message);
- #endif
+#if defined(__SWITCH__)
+ SPDLOG_ERROR(message);
+#else
+ SDL_ShowSimpleMessageBox(type, title, message, nullptr);
+ SPDLOG_ERROR(message);
+#endif
}
int GameEngine::ShowYesNoBox(const char* title, const char* box) {
int ret;
#ifdef _WIN32
ret = MessageBoxA(nullptr, box, title, MB_YESNO | MB_ICONQUESTION);
+#elif defined(__SWITCH__)
+ SPDLOG_ERROR(box);
+ return IDYES;
#else
SDL_MessageBoxData boxData = { 0 };
SDL_MessageBoxButtonData buttons[2] = { { 0 } };
@@ -236,6 +248,9 @@ void GameEngine::Create() {
void GameEngine::Destroy() {
AudioExit();
+#ifdef __SWITCH__
+ Ship::Switch::Exit();
+#endif
}
bool ShouldClearTextureCacheAtEndOfFrame = false;
diff --git a/src/port/GameExtractor.cpp b/src/port/GameExtractor.cpp
index 4a222c681..0182241be 100644
--- a/src/port/GameExtractor.cpp
+++ b/src/port/GameExtractor.cpp
@@ -5,15 +5,18 @@
#include "Context.h"
#include "spdlog/spdlog.h"
-#include "portable-file-dialogs.h"
#include <port/Engine.h>
+#if !defined(__IOS__) && !defined(__ANDROID__) && !defined(__SWITCH__)
+#include "portable-file-dialogs.h"
+#endif
+
std::unordered_map<std::string, std::string> mGameList = {
{ "579c48e211ae952530ffc8738709f078d5dd215e", "Mario Kart 64 (US)" },
};
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/PortMenu.cpp b/src/port/ui/PortMenu.cpp
index 825ed8527..791e2ac73 100644
--- a/src/port/ui/PortMenu.cpp
+++ b/src/port/ui/PortMenu.cpp
@@ -10,6 +10,10 @@
#include <tuple>
#include "ResolutionEditor.h"
+#ifdef __SWITCH__
+#include <port/switch/SwitchImpl.h>
+#endif
+
extern "C" {
extern s32 gGamestateNext;
extern s32 gMenuSelection;
@@ -362,10 +366,31 @@ void PortMenu::AddEnhancements() {
.Tooltip("When Disable Wall Collision are enable what is the minimal height you can get."));
}
+#ifdef __SWITCH__
+static const std::unordered_map<int32_t, const char*> switchCPUProfiles = {
+ { Ship::SwitchProfiles::MAXIMUM, "Maximum Performance" },
+ { Ship::SwitchProfiles::HIGH, "High Performance" },
+ { Ship::SwitchProfiles::BOOST, "Boost Performance" },
+ { Ship::SwitchProfiles::STOCK, "Stock Performance" },
+ { Ship::SwitchProfiles::POWERSAVINGM1, "Powersaving Mode 1" },
+ { Ship::SwitchProfiles::POWERSAVINGM2, "Powersaving Mode 2" },
+ { Ship::SwitchProfiles::POWERSAVINGM3, "Powersaving Mode 3" }
+};
+#endif
+
void PortMenu::AddDevTools() {
AddMenuEntry("Developer", "gSettings.Menu.DevToolsSidebarSection");
AddSidebarEntry("Developer", "General", 3);
WidgetPath path = { "Developer", "General", SECTION_COLUMN_1 };
+#ifdef __SWITCH__
+ AddWidget(path, "Switch CPU Profile", WIDGET_CVAR_COMBOBOX)
+ .CVar("gSwitchPerfMode")
+ .Options(ComboboxOptions()
+ .Tooltip("Switches the CPU profile to a different one")
+ .ComboMap(switchCPUProfiles)
+ .DefaultIndex(Ship::SwitchProfiles::STOCK))
+ .Callback([](WidgetInfo& info) { Ship::Switch::ApplyOverclock(); });
+#endif
AddWidget(path, "Popout Menu", WIDGET_CVAR_CHECKBOX)
.CVar("gSettings.Menu.Popout")
.Options(CheckboxOptions().Tooltip("Changes the menu display from overlay to windowed."));
diff --git a/src/stubs.c b/src/stubs.c
index 7d4e39f1c..866215f9c 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -96,8 +96,10 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name
return PFS_NO_ERROR;
}
+#ifndef __SWITCH__
void osSetTime(OSTime time) {
}
+#endif
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern) {
}