diff --git a/.gitignore b/.gitignore index ce21454c..f5a9871b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ torch.hash.yml cmake-build-*/ .idea/ .vs +build* diff --git a/CMakeLists.txt b/CMakeLists.txt index e7c30cee..cb5ea849 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,74 @@ add_subdirectory(libultraship ${CMAKE_CURRENT_SOURCE_DIR}/libultraship) add_dependencies(${PROJECT_NAME} libultraship) target_link_libraries(${PROJECT_NAME} PRIVATE libultraship) +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_package(glfw3 REQUIRED) + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "libultraship;" + "ZAPDUtils;" + "ZAPDLib;" + "glu32;" + "SDL2::SDL2;" + "SDL2::SDL2main;" + "$<$:SDL2_net::SDL2_net-static>" + "glfw;" + "winmm;" + "imm32;" + "version;" + "setupapi" + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "libultraship;" + "ZAPDUtils;" + "ZAPDLib;" + "glu32;" + "SDL2::SDL2;" + "SDL2::SDL2main;" + "glfw;" + "winmm;" + "imm32;" + "version;" + "setupapi" + ) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") + find_package(SDL2) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "libultraship;" + "ZAPDUtils;" + SDL2::SDL2 + -lglad + Threads::Threads + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + find_package(SDL2 REQUIRED) + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "libultraship;" + SDL2::SDL2-static + + "$<$:-Wl,--wrap=abort>" + ) + target_include_directories(${PROJECT_NAME} PRIVATE + ${DEVKITPRO}/portlibs/wiiu/include/ + ) +else() + find_package(SDL2) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "libultraship;" + "ZAPDUtils;" + "ZAPDLib;" + SDL2::SDL2 + "$<$:SDL2_net::SDL2_net>" + ${CMAKE_DL_LIBS} + Threads::Threads + ) +endif() if(USE_NETWORKING) if(MSVC) @@ -261,6 +329,23 @@ if(USE_NETWORKING) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING) endif() +target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") + +if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch") + +nx_generate_nacp(Lylat.nacp + NAME "Lylat64" + AUTHOR "${PROJECT_TEAM}" + VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" +) + +nx_create_nro(${PROJECT_NAME} + NACP Lylat.nacp +) + +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lylat64.nro DESTINATION . COMPONENT ${PROJECT_NAME}) +endif() + ################################################################################ # Compile and link options ################################################################################ diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index c77bdb75..b8614a55 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -154,11 +154,11 @@ extern "C" uint8_t GameEngine_OTRSigCheck(const char* data) { } extern "C" float __cosf(float angle) { - return std::cosf(angle); + return cosf(angle); } extern "C" float __sinf(float angle) { - return std::sinf(angle); + return sinf(angle); } extern "C" float SIN_DEG(float angle) { @@ -183,7 +183,7 @@ uint64_t Timer_GetCurrentMillis() { return SDL_GetTicks(); } -extern "C" int32_t Timer_CreateTask(uint64_t time, TimerAction action, int32_t* address, int32_t value) { +extern "C" s32 Timer_CreateTask(u64 time, TimerAction action, s32* address, s32 value) { const auto millis = Timer_GetCurrentMillis(); TimedEntry entry = { .duration = millis + CYCLES_TO_MSEC_PC(time), diff --git a/src/port/resource/importers/MessageLookupFactory.cpp b/src/port/resource/importers/MessageLookupFactory.cpp index d1d20ac6..8eec7ffb 100644 --- a/src/port/resource/importers/MessageLookupFactory.cpp +++ b/src/port/resource/importers/MessageLookupFactory.cpp @@ -1,8 +1,8 @@ #include "MessageLookupFactory.h" #include "../type/Message.h" #include "spdlog/spdlog.h" - #include "resourcebridge.h" +#include "ResourceUtil.h" namespace SF64 { std::shared_ptr ResourceFactoryBinaryMessageLookupV0::ReadResource(std::shared_ptr file) { @@ -18,7 +18,7 @@ std::shared_ptr ResourceFactoryBinaryMessageLookupV0::ReadResour SPDLOG_INFO("Reading message lookup table entry {}", i); auto id = reader->ReadInt32(); - uint16_t* ptr = static_cast(ResourceGetDataByCrc(reader->ReadUInt64())); + uint16_t* ptr = LoadChild(reader->ReadUInt64()); table->mLookupTable.push_back({ id, ptr }); }