diff --git a/cmake/targets/dolphin.cmake b/cmake/targets/dolphin.cmake index a8cd9ddf..a3138633 100644 --- a/cmake/targets/dolphin.cmake +++ b/cmake/targets/dolphin.cmake @@ -12,27 +12,46 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_DOLPHIN_BUILD_TYPE="${DUSK_DOLPHIN_BUILD_TYPE}" ) - # Custom compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") -# Need PkgConfig -find_package(PkgConfig REQUIRED) -pkg_check_modules(zip IMPORTED_TARGET libzip) - # Disable all warnings target_compile_options(${DUSK_LIBRARY_TARGET_NAME} PRIVATE -w) -# Custom flags for cglm -set(CGLM_SHARED OFF CACHE BOOL "Build cglm shared" FORCE) -set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE) +# cglm: fetched at source level via Findcglm.cmake (FetchContent, headers only) find_package(cglm REQUIRED) -# Link libraries +# Pre-create ZLIB::ZLIB so any downstream cmake module that resolves it +# (FindZLIB, pkg-config IMPORTED_TARGET Requires processing) gets plain -lz +# rather than an unresolvable IMPORTED target that the PPC linker rejects. +if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB INTERFACE IMPORTED GLOBAL) + set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES "z") +endif() + +# Mark libzip as found so src/dusk/CMakeLists.txt skips Findlibzip.cmake. +# Findlibzip.cmake calls find_package(ZLIB) which can recreate a broken +# ZLIB::ZLIB IMPORTED target, bypassing the shim above. +set(libzip_FOUND TRUE CACHE BOOL "libzip found (devkitpro portlibs)" FORCE) + +# Locate zip.h in the devkitpro sysroot (respects CMAKE_FIND_ROOT_PATH). +find_path(_dusk_zip_inc NAMES zip.h) +if(_dusk_zip_inc) + target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE "${_dusk_zip_inc}") +endif() + +# Link libraries. +# zip/z/lzma use target_link_options (raw flags) to bypass cmake target +# resolution — pkg-config-generated targets for these carry ZLIB::ZLIB in +# INTERFACE_LINK_LIBRARIES which breaks the PPC link step. target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE cglm m - PkgConfig::zip + zip + bz2 + zstd + z + lzma ) if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO") @@ -48,4 +67,4 @@ add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD "$" "${DUSK_BINARY_TARGET_NAME_DOL}" COMMENT "Generating ${DUSK_BINARY_TARGET_NAME_DOL} from ${DUSK_BINARY_TARGET_NAME}" -) \ No newline at end of file +) diff --git a/docker/dolphin/Dockerfile b/docker/dolphin/Dockerfile index 055e04b5..6a39baf1 100644 --- a/docker/dolphin/Dockerfile +++ b/docker/dolphin/Dockerfile @@ -1,6 +1,7 @@ -FROM devkitpro/devkitppc +FROM ghcr.io/extremscorner/libogc2 WORKDIR /workdir RUN apt update && \ + dkp-pacman -Syu --noconfirm && \ apt install -y python3 python3-pip python3-polib python3-pil python3-dotenv python3-pyqt5 python3-opengl && \ - dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip + dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip libogc2 gamecube-tools ppc-libmad ppc-zlib-ng ppc-liblzma ppc-bzip2 ppc-zstd VOLUME ["/workdir"] \ No newline at end of file diff --git a/scripts/build-gamecube.sh b/scripts/build-gamecube.sh index 9328f10e..8d8a74cd 100755 --- a/scripts/build-gamecube.sh +++ b/scripts/build-gamecube.sh @@ -5,6 +5,9 @@ if [ -z "$DEVKITPRO" ]; then fi mkdir -p build-gamecube -cmake -S. -Bbuild-gamecube -DDUSK_TARGET_SYSTEM=gamecube -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/GameCube.cmake" +cmake -S. -Bbuild-gamecube \ + -DDUSK_TARGET_SYSTEM=gamecube \ + -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/GameCube.cmake" \ + -DDKP_OGC_PLATFORM_LIBRARY=libogc2 cd build-gamecube make -j$(nproc) VERBOSE=1 \ No newline at end of file diff --git a/src/duskdolphin/asset/assetdolphindvd.c b/src/duskdolphin/asset/assetdolphindvd.c index 86414cb4..7034e420 100644 --- a/src/duskdolphin/asset/assetdolphindvd.c +++ b/src/duskdolphin/asset/assetdolphindvd.c @@ -20,7 +20,7 @@ errorret_t assetInitDolphinDVD(void) { if(!hdr) errorThrow("Failed to read DVD disc header."); u32 fstOff = assetDolphinDVDReadBigEndian32(hdr + 0x424); u32 fstSize = assetDolphinDVDReadBigEndian32(hdr + 0x428); - free(hdr); + memoryFree(hdr); // Read the FST u8 *fst = (u8 *)assetDolphinDVDRead((s64)fstOff, fstSize); @@ -71,8 +71,8 @@ void *assetDolphinDVDRead(const s64 offset, const u32 size) { void *buf = memoryAlign(ASSET_DOLPHIN_DVD_ALIGN, padded); if(!buf) return NULL; DCInvalidateRange(buf, padded); - dvdcmdblk block; - if(DVD_ReadPrio(&block, buf, padded, offset, 0) <= 0) { + static dvdcmdblk block; + if(DVD_ReadAbs(&block, buf, padded, offset) <= 0) { memoryFree(buf); return NULL; } diff --git a/src/duskdolphin/duskplatform.h b/src/duskdolphin/duskplatform.h index c2e801fb..48b85832 100644 --- a/src/duskdolphin/duskplatform.h +++ b/src/duskdolphin/duskplatform.h @@ -9,7 +9,7 @@ #include #include -#include +#include #define consoleInit consoleInitDolhpin diff --git a/src/duskdolphin/time/timedolphin.c b/src/duskdolphin/time/timedolphin.c index 0d9e612f..bd7318d1 100644 --- a/src/duskdolphin/time/timedolphin.c +++ b/src/duskdolphin/time/timedolphin.c @@ -7,6 +7,9 @@ #include "time/timedolphin.h" +#define SYS_Time __SYS_GetSystemTime +#define PPCTicksToUs ticks_to_microsecs + double_t timeGetRealDolphin(void) { // "Returns time in ticks since 2000" u64 timeInUs = PPCTicksToUs(SYS_Time());