From 11ddc641c0279e8d77dbc7aadcadbdf33d1d9076 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Tue, 2 Apr 2024 09:39:25 -0600 Subject: [PATCH] Fixed compilation on windows --- .gitignore | 1 + CMakeLists.txt | 2 +- cmake/automate-vcpkg.cmake | 191 +++++++++++++++++++++++ cmake/modules/FindPulseAudio.cmake | 34 ++++ cmake/modules/FindlibUsb.cmake | 48 ++++++ cmake/modules/Findudev.cmake | 84 ++++++++++ cmake/toolchain-x86_64-w64-mingw32.cmake | 26 +++ include/libc/math.h | 2 +- include/sf64math.h | 5 +- libultraship | 2 +- src/audio/audio_general.c | 2 +- src/dmatable.c | 4 +- src/engine/fox_load.c | 103 ++++++------ src/port/Engine.cpp | 6 +- src/port/ui/ImguiUI.cpp | 2 +- 15 files changed, 441 insertions(+), 71 deletions(-) create mode 100644 cmake/automate-vcpkg.cmake create mode 100644 cmake/modules/FindPulseAudio.cmake create mode 100644 cmake/modules/FindlibUsb.cmake create mode 100644 cmake/modules/Findudev.cmake create mode 100644 cmake/toolchain-x86_64-w64-mingw32.cmake diff --git a/.gitignore b/.gitignore index 198c71ef..fbcc25df 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ assets/yaml/us/ast_test.yaml src/assets/* include/assets/* /build +build-new/ tools/mio0 tools/ido-recomp debug/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 31c81b1f..23dec58e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ endif() # Set game compilation version set(VERSION us) -set(USE_NETWORKING ON) +set(USE_NETWORKING OFF) # Add compile definitions for the target add_compile_definitions( diff --git a/cmake/automate-vcpkg.cmake b/cmake/automate-vcpkg.cmake new file mode 100644 index 00000000..ee07f6bf --- /dev/null +++ b/cmake/automate-vcpkg.cmake @@ -0,0 +1,191 @@ +#------------------------------------------------------------------------------------------------------------ +# +# Automate-VCPKG by Andre Taulien +# =============================== +# +# Project Repository: https://github.com/REGoth-project/Automate-VCPKG +# License ..........: MIT, see end of file. +# +# Based on: https://github.com/sutambe/cpptruths/blob/vcpkg_cmake_blog/cpp0x/vcpkg_test/CMakeLists.txt +# +# +# While [Vcpkg](https://github.com/microsoft/vcpkg) on it's own is awesome, it does add +# a little bit of complexity to getting a project to build. Even more if the one trying +# to compile your application is not too fond of the commandline. Additionally, CMake +# commands tend to get rather long with the toolchain path. +# +# To keep things simple for new users who just want to get the project to build, this +# script offers a solution. +# +# Lets assume your main `CMakelists.txt` looks something like this: +# +# cmake_minimum_required (VERSION 3.12.0) +# project (MyProject) +# +# add_executable(MyExecutable main.c) +# +# To integrate Vcpkg into that `CMakelists.txt`, simple put the following lines before the +# call to `project(MyProject)`: +# +# include(cmake/automate-vcpkg.cmake) +# +# vcpkg_bootstrap() +# vcpkg_install_packages(libsquish physfs) +# +# The call to `vcpkg_bootstrap()` will clone the official Vcpkg repository and bootstrap it. +# If it detected an existing environment variable defining a valid `VCPKG_ROOT`, it will +# update the existing installation of Vcpkg. +# +# Arguments to `vcpkg_install_packages()` are the packages you want to install using Vcpkg. +# +# If you want to keep the possibility for users to chose their own copy of Vcpkg, you can +# simply not run the code snippet mentioned above, something like this will work: +# +# option(SKIP_AUTOMATE_VCPKG "When ON, you will need to built the packages +# required by MyProject on your own or supply your own vcpkg toolchain.") +# +# if (NOT SKIP_AUTOMATE_VCPKG) +# include(cmake/automate-vcpkg.cmake) +# +# vcpkg_bootstrap() +# vcpkg_install_packages(libsquish physfs) +# endif() +# +# Then, the user has to supply the packages on their own, be it through Vcpkg or manually +# specifying their locations. +#------------------------------------------------------------------------------------------------------------ + +cmake_minimum_required (VERSION 3.12) + +if(WIN32) + set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before") +else() + set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/.vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before") +endif() + +# On Windows, Vcpkg defaults to x86, even on x64 systems. If we're +# doing a 64-bit build, we need to fix that. +if (WIN32) + + # Since the compiler checks haven't run yet, we need to figure + # out the value of CMAKE_SIZEOF_VOID_P ourselfs + + include(CheckTypeSize) + enable_language(C) + check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY) + + if (SIZEOF_VOID_P EQUAL 8) + message(STATUS "Using Vcpkg triplet 'x64-windows'") + + set(VCPKG_TRIPLET x64-windows) + endif() +endif() + +if(NOT DEFINED VCPKG_ROOT) + if(NOT DEFINED ENV{VCPKG_ROOT}) + set(VCPKG_ROOT ${VCPKG_FALLBACK_ROOT}) + else() + set(VCPKG_ROOT $ENV{VCPKG_ROOT}) + endif() +endif() + +# Installs a new copy of Vcpkg or updates an existing one +macro(vcpkg_bootstrap) + _install_or_update_vcpkg() + + # Find out whether the user supplied their own VCPKG toolchain file + if(NOT DEFINED ${CMAKE_TOOLCHAIN_FILE}) + # We know this wasn't set before so we need point the toolchain file to the newly found VCPKG_ROOT + set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "") + + # Just setting vcpkg.cmake as toolchain file does not seem to actually pull in the code + include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) + + set(AUTOMATE_VCPKG_USE_SYSTEM_VCPKG OFF) + else() + # VCPKG_ROOT has been defined by the toolchain file already + set(AUTOMATE_VCPKG_USE_SYSTEM_VCPKG ON) + endif() + + message(STATUS "Automate VCPKG status:") + message(STATUS " VCPKG_ROOT.....: ${VCPKG_ROOT}") + message(STATUS " VCPKG_EXEC.....: ${VCPKG_EXEC}") + message(STATUS " VCPKG_BOOTSTRAP: ${VCPKG_BOOTSTRAP}") +endmacro() + +macro(_install_or_update_vcpkg) + if(NOT EXISTS ${VCPKG_ROOT}) + message(STATUS "Cloning vcpkg in ${VCPKG_ROOT}") + execute_process(COMMAND git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT}) + + # If a reproducible build is desired (and potentially old libraries are # ok), uncomment the + # following line and pin the vcpkg repository to a specific githash. + # execute_process(COMMAND git checkout 745a0aea597771a580d0b0f4886ea1e3a94dbca6 WORKING_DIRECTORY ${VCPKG_ROOT}) + else() + # The following command has no effect if the vcpkg repository is in a detached head state. + message(STATUS "Auto-updating vcpkg in ${VCPKG_ROOT}") + execute_process(COMMAND git pull WORKING_DIRECTORY ${VCPKG_ROOT}) + endif() + + if(NOT EXISTS ${VCPKG_ROOT}/README.md) + message(FATAL_ERROR "***** FATAL ERROR: Could not clone vcpkg *****") + endif() + + if(WIN32) + set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg.exe) + set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.bat) + else() + set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg) + set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.sh) + endif() + + if(NOT EXISTS ${VCPKG_EXEC}) + message("Bootstrapping vcpkg in ${VCPKG_ROOT}") + execute_process(COMMAND ${VCPKG_BOOTSTRAP} WORKING_DIRECTORY ${VCPKG_ROOT}) + endif() + + if(NOT EXISTS ${VCPKG_EXEC}) + message(FATAL_ERROR "***** FATAL ERROR: Could not bootstrap vcpkg *****") + endif() + +endmacro() + +# Installs the list of packages given as parameters using Vcpkg +macro(vcpkg_install_packages) + + # Need the given list to be space-separated + #string (REPLACE ";" " " PACKAGES_LIST_STR "${ARGN}") + + message(STATUS "Installing/Updating the following vcpkg-packages: ${PACKAGES_LIST_STR}") + + if (VCPKG_TRIPLET) + set(ENV{VCPKG_DEFAULT_TRIPLET} "${VCPKG_TRIPLET}") + endif() + + execute_process( + COMMAND ${VCPKG_EXEC} install ${ARGN} + WORKING_DIRECTORY ${VCPKG_ROOT} + ) +endmacro() + +# MIT License +# +# Copyright (c) 2019 REGoth-project +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. diff --git a/cmake/modules/FindPulseAudio.cmake b/cmake/modules/FindPulseAudio.cmake new file mode 100644 index 00000000..fdcbc20f --- /dev/null +++ b/cmake/modules/FindPulseAudio.cmake @@ -0,0 +1,34 @@ +# - Find PulseAudio includes and libraries +# +# PULSEAUDIO_FOUND - True if PULSEAUDIO_INCLUDE_DIR & +# PULSEAUDIO_LIBRARY are found +# +# PULSEAUDIO_INCLUDE_DIR - where to find pulse/pulseaudio.h, etc. +# PULSEAUDIO_LIBRARY - the pulse library +# PULSEAUDIO_VERSION_STRING - the version of PulseAudio found +# + +find_path(PULSEAUDIO_INCLUDE_DIR + NAMES pulse/pulseaudio.h + DOC "The PulseAudio include directory" +) + +find_library(PULSEAUDIO_LIBRARY + NAMES pulse + DOC "The PulseAudio library" +) + +if(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h") + file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_str + REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)") + + string(REGEX REPLACE "^.*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*$" "\\1" + PULSEAUDIO_VERSION_STRING "${pulse_version_str}") + unset(pulse_version_str) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PulseAudio + REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR + VERSION_VAR PULSEAUDIO_VERSION_STRING +) diff --git a/cmake/modules/FindlibUsb.cmake b/cmake/modules/FindlibUsb.cmake new file mode 100644 index 00000000..3dea9f6c --- /dev/null +++ b/cmake/modules/FindlibUsb.cmake @@ -0,0 +1,48 @@ +if (MSVC) + set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS64/static") + + # check if we're using something else than 64bit.. + if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS32/static") + endif() +endif() + +if (MINGW) + set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW64/static") + # check if we're using something else than 64bit.. + if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW32/static") + endif() +endif() + +find_library (LIBUSB_LIBRARY + NAMES libusb libusb-1.0 usb-1.0 + PATHS "/usr/lib" "/usr/local/lib/" "${WINDOWS_LIBUSB_PATH}") + +find_path (LIBUSB_INCLUDEDIR + NAMES libusb.h libusb-1.0.h + PATHS "/usr/local/include/" "$ENV{LIBUSB_PATH}/include/libusb-1.0" + PATH_SUFFIXES "include" "libusb" "libusb-1.0") + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(libUsb DEFAULT_MSG + LIBUSB_LIBRARY + LIBUSB_INCLUDEDIR) + +if (LIBUSB_FOUND AND NOT TARGET libUsb::libUsb) + add_library(libUsb::libUsb STATIC IMPORTED) + set_target_properties( + libUsb::libUsb + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDEDIR}" + IMPORTED_LOCATION "${LIBUSB_LIBRARY}") + if (MSVC OR MINGW) + set_target_properties( + libUsb::libUsb + PROPERTIES + IMPORTED_IMPLIB "${LIBUSB_LIBRARY}" + ) + endif() +endif() + diff --git a/cmake/modules/Findudev.cmake b/cmake/modules/Findudev.cmake new file mode 100644 index 00000000..568cc9ce --- /dev/null +++ b/cmake/modules/Findudev.cmake @@ -0,0 +1,84 @@ +# - try to find the udev library +# +# Cache Variables: (probably not for direct use in your scripts) +# UDEV_INCLUDE_DIR +# UDEV_SOURCE_DIR +# UDEV_LIBRARY +# +# Non-cache variables you might use in your CMakeLists.txt: +# UDEV_FOUND +# UDEV_INCLUDE_DIRS +# UDEV_LIBRARIES +# +# Requires these CMake modules: +# FindPackageHandleStandardArgs (known included with CMake >=2.6.2) +# +# Original Authors: +# 2014, Kevin M. Godby +# 2021, Ryan Pavlik +# +# Copyright 2014, Kevin M. Godby +# Copyright 2021, Collabora, Ltd. +# +# SPDX-License-Identifier: BSL-1.0 +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(UDEV_ROOT_DIR + "${UDEV_ROOT_DIR}" + CACHE + PATH + "Directory to search for udev") + +if(NOT ANDROID) + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBUDEV QUIET libudev) + endif() +endif() + +find_library(UDEV_LIBRARY + NAMES + udev + PATHS + ${PC_LIBUDEV_LIBRARY_DIRS} + ${PC_LIBUDEV_LIBDIR} + HINTS + "${UDEV_ROOT_DIR}" + PATH_SUFFIXES + lib + ) + +get_filename_component(_libdir "${UDEV_LIBRARY}" PATH) + +find_path(UDEV_INCLUDE_DIR + NAMES + libudev.h + PATHS + ${PC_LIBUDEV_INCLUDE_DIRS} + ${PC_LIBUDEV_INCLUDEDIR} + HINTS + "${_libdir}" + "${_libdir}/.." + "${UDEV_ROOT_DIR}" + PATH_SUFFIXES + include + ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(udev + DEFAULT_MSG + UDEV_LIBRARY + UDEV_INCLUDE_DIR + ) + +if(UDEV_FOUND) + list(APPEND UDEV_LIBRARIES ${UDEV_LIBRARY}) + list(APPEND UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR}) + mark_as_advanced(UDEV_ROOT_DIR) +endif() + +mark_as_advanced(UDEV_INCLUDE_DIR + UDEV_LIBRARY) diff --git a/cmake/toolchain-x86_64-w64-mingw32.cmake b/cmake/toolchain-x86_64-w64-mingw32.cmake new file mode 100644 index 00000000..ae4b129c --- /dev/null +++ b/cmake/toolchain-x86_64-w64-mingw32.cmake @@ -0,0 +1,26 @@ +set (CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# specify the cross compiler +set (CMAKE_C_COMPILER x86_64-w64-mingw32-gcc CACHE STRING "The C compiler to use") +set (CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++ CACHE STRING "The C++ compiler to use") + +# where is the target environment +set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# search for programs in the build host directories +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# set the resource compiler (RHBZ #652435) +set (CMAKE_RC_COMPILER windres) +set (CMAKE_MC_COMPILER windmc) + +# override boost thread component suffix as mingw-w64-boost is compiled with threadapi=win32 +set (Boost_THREADAPI win32) + +set (CMAKE_AR:FILEPATH x86_64-w64-mingw32-ar) +set (CMAKE_RANLIB:FILEPATH x86_64-w64-mingw32-ranlib) \ No newline at end of file diff --git a/include/libc/math.h b/include/libc/math.h index c8b4b596..480edbf3 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -4,7 +4,7 @@ #include #include -#define M_PI 3.14159265358979323846264338327950288 +#define M_PI 3.14159265358979323846264338327950288f #define M_DTOR (M_PI / 180.0f) #define M_RTOD (180.0f / M_PI) #define M_SQRT2 1.41421356237309504880f diff --git a/include/sf64math.h b/include/sf64math.h index 839011bd..1302a5b6 100644 --- a/include/sf64math.h +++ b/include/sf64math.h @@ -2,6 +2,7 @@ #define SF64_MATH_H #include +#include typedef struct { /* 0x0 */ f32 x; @@ -98,10 +99,6 @@ f32 Math_FAcosF(f32); #define __sinf sinf #define __cosf cosf -s64 __ull_div(s64, s64); -s64 __ll_mul(s64, s64); -s64 __ll_rshift(s64, s64); - f32 Math_FloorF(f32); f32 Math_CeilF(f32); f64 Math_Fabs(f64); diff --git a/libultraship b/libultraship index f7c80fc8..5445aca7 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit f7c80fc8f7d77c5a1340afcac02a102731665d33 +Subproject commit 5445aca76255d8aa93a2dec4cfa99f5788fbdb92 diff --git a/src/audio/audio_general.c b/src/audio/audio_general.c index 7cd092a6..e4fc768b 100644 --- a/src/audio/audio_general.c +++ b/src/audio/audio_general.c @@ -2008,7 +2008,7 @@ s32 Audio_GetCurrentVoice(void) { s32 Audio_GetCurrentVoiceStatus(void) { // LAudioTODO: Stub for now - return 0; + return 1; SequenceChannel* channel = gSeqPlayers[SEQ_PLAYER_VOICE].channels[15]; SequenceLayer* layer = channel->layers[0]; diff --git a/src/dmatable.c b/src/dmatable.c index b8231e06..7d976fc5 100644 --- a/src/dmatable.c +++ b/src/dmatable.c @@ -5,7 +5,7 @@ #define DMA_ENTRY_NONE \ { NULL, { NULL, NULL }, false } -DmaEntry gDmaTable[90] = { +// DmaEntry gDmaTable[90] = { // { SEGMENT_ROM_START(makerom), { SEGMENT_ROM_START(makerom), SEGMENT_ROM_END(makerom) }, false }, // { SEGMENT_ROM_START(main), { SEGMENT_ROM_START(main), SEGMENT_ROM_END(main) }, false }, // { SEGMENT_ROM_START(dma_table), { SEGMENT_ROM_START(dma_table), SEGMENT_ROM_END(dma_table) }, false }, @@ -84,4 +84,4 @@ DmaEntry gDmaTable[90] = { // { SEGMENT_ROM_START(ovl_menu), { SEGMENT_ROM_START(ovl_menu), SEGMENT_ROM_END(ovl_menu) }, false }, // { SEGMENT_ROM_START(ovl_ending), { SEGMENT_ROM_START(ovl_ending), SEGMENT_ROM_END(ovl_ending) }, false }, // { SEGMENT_ROM_START(ovl_unused), { SEGMENT_ROM_START(ovl_unused), SEGMENT_ROM_END(ovl_unused) }, false }, -}; +// }; diff --git a/src/engine/fox_load.c b/src/engine/fox_load.c index 350c0fbe..cb5369e8 100644 --- a/src/engine/fox_load.c +++ b/src/engine/fox_load.c @@ -28,20 +28,9 @@ OverlayInit sCurrentOverlay = { void Overlay_LoadSegment(void* vRomAddress, void* dest, ptrdiff_t size) { s32 i; - for (i = 0; gDmaTable[i].pRom.end != NULL; i++) { - if (gDmaTable[i].vRomAddress == vRomAddress) { - if (gDmaTable[i].compFlag == 0) { - Lib_DmaRead(gDmaTable[i].pRom.start, dest, size); - } else { - Lib_FillScreen(true); - sFillTimer = 3; - D_80161A39 = true; - // Lib_DmaRead(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom)); - // Mio0_Decompress(gFrameBuffers, dest); - } - break; - } - } + Lib_FillScreen(true); + sFillTimer = 3; + D_80161A39 = true; } u8 Overlay_Init(OverlayInit* ovlInit) { @@ -49,51 +38,51 @@ u8 Overlay_Init(OverlayInit* ovlInit) { sCurrentOverlay = *ovlInit; return true; - u8* ramPtr = SEGMENT_VRAM_START(ovl_i1); - u8 segment; - u8 changeOvl = false; + // u8* ramPtr = SEGMENT_VRAM_START(ovl_i1); + // u8 segment; + // u8 changeOvl = false; - if (ovlInit->ovl.rom.start == (0, sCurrentOverlay.ovl.rom.start)) { // fake because D_800CBDD4 is probably 2D array - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.rom); - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.bss); - } else { - sCurrentOverlay.ovl.rom.start = ovlInit->ovl.rom.start; - sCurrentOverlay.ovl.rom.end = ramPtr; - if (ovlInit->ovl.rom.start != 0) { - changeOvl = true; - Overlay_LoadSegment(ovlInit->ovl.rom.start, ramPtr, SEGMENT_SIZE(ovlInit->ovl.rom)); - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.rom); - bzero(ovlInit->ovl.bss.start, SEGMENT_SIZE(ovlInit->ovl.bss)); - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.bss); - } - } - segment = 0; - while ((segment < 15) && (ovlInit->assets[segment].start == sCurrentOverlay.assets[segment].start) && - changeOvl == 0) { - if (ovlInit->assets[segment].start != 0) { - gSegments[segment + 1] = K0_TO_PHYS(ramPtr); - gSPSegment(gUnkDisp1++, segment + 1, K0_TO_PHYS(ramPtr)); - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->assets[segment]); - } - segment += 1; - } - for (segment; segment < 15; segment += 1) { - sCurrentOverlay.assets[segment].start = ovlInit->assets[segment].start; - sCurrentOverlay.assets[segment].end = ramPtr; - if (ovlInit->assets[segment].start != 0) { - gSegments[segment + 1] = K0_TO_PHYS(ramPtr); - gSPSegment(gUnkDisp1++, segment + 1, K0_TO_PHYS(ramPtr)); - Overlay_LoadSegment(ovlInit->assets[segment].start, ramPtr, SEGMENT_SIZE(ovlInit->assets[segment])); - ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->assets[segment]); - } - } + // if (ovlInit->ovl.rom.start == (0, sCurrentOverlay.ovl.rom.start)) { // fake because D_800CBDD4 is probably 2D array + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.rom); + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.bss); + // } else { + // sCurrentOverlay.ovl.rom.start = ovlInit->ovl.rom.start; + // sCurrentOverlay.ovl.rom.end = ramPtr; + // if (ovlInit->ovl.rom.start != 0) { + // changeOvl = true; + // Overlay_LoadSegment(ovlInit->ovl.rom.start, ramPtr, SEGMENT_SIZE(ovlInit->ovl.rom)); + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.rom); + // bzero(ovlInit->ovl.bss.start, SEGMENT_SIZE(ovlInit->ovl.bss)); + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->ovl.bss); + // } + // } + // segment = 0; + // while ((segment < 15) && (ovlInit->assets[segment].start == sCurrentOverlay.assets[segment].start) && + // changeOvl == 0) { + // if (ovlInit->assets[segment].start != 0) { + // gSegments[segment + 1] = K0_TO_PHYS(ramPtr); + // gSPSegment(gUnkDisp1++, segment + 1, K0_TO_PHYS(ramPtr)); + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->assets[segment]); + // } + // segment += 1; + // } + // for (segment; segment < 15; segment += 1) { + // sCurrentOverlay.assets[segment].start = ovlInit->assets[segment].start; + // sCurrentOverlay.assets[segment].end = ramPtr; + // if (ovlInit->assets[segment].start != 0) { + // gSegments[segment + 1] = K0_TO_PHYS(ramPtr); + // gSPSegment(gUnkDisp1++, segment + 1, K0_TO_PHYS(ramPtr)); + // Overlay_LoadSegment(ovlInit->assets[segment].start, ramPtr, SEGMENT_SIZE(ovlInit->assets[segment])); + // ramPtr = ramPtr + SEGMENT_SIZE(ovlInit->assets[segment]); + // } + // } - if (sFillTimer != 0) { - sFillTimer--; - } else if (gStartNMI == 0) { - Lib_FillScreen(false); - } - return changeOvl; + // if (sFillTimer != 0) { + // sFillTimer--; + // } else if (gStartNMI == 0) { + // Lib_FillScreen(false); + // } + // return changeOvl; } u8 Overlay_Load(u8 ovlSetup, u8 ovlStage) { diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 25ab55ac..d05f927c 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include @@ -122,10 +122,10 @@ extern "C" int GameEngine_OTRSigCheck(const char* data) { } extern "C" float SIN_DEG(float angle) { - return sinf(M_DTOR * angle); + return SDL_sinf(M_DTOR * angle); } extern "C" float COS_DEG(float angle) { - return cosf(M_DTOR * angle); + return SDL_cosf(M_DTOR * angle); } struct TimedEntry { diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index f4639cf4..779a4d7c 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -383,7 +383,7 @@ void DrawMenuBarIcon() { } void DrawGameMenu() { - if (UIWidgets::BeginMenu("Ghostship")) { + if (UIWidgets::BeginMenu("Lylat64")) { if (UIWidgets::MenuItem("Reset", #ifdef __APPLE__ "Command-R"