diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index ab91aca242..467849f761 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -68,13 +68,18 @@ body: required: true - type: dropdown - id: game-region + id: game-disc attributes: - label: Game Region - description: The game region you are playing on + label: Game Disc + description: The game disc you are playing on options: - - NTSC-U (North America) - - PAL (Europe) + - GameCube NTSC-U (North America) + - GameCube PAL (Europe) + - GameCube NTSC-J (Japan) + - Wii NTSC-U (North America) Revision 0 + - Wii NTSC-U (North America) Revision 2 + - Wii PAL (Europe) + - Wii NTSC-J (Japan) validations: required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80257624c5..41758382cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,10 +76,11 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v7 with: - name: dusklight-${{env.DUSK_VERSION}}-linux-${{matrix.preset}}-${{matrix.artifact_arch}} + name: dusklight-${{env.APP_VERSION}}-linux-${{matrix.preset}}-${{matrix.artifact_arch}} path: | build/install/Dusklight-*.AppImage build/install/debug.tar.* + build/install/sdk/ build-apple: name: Build Apple (${{matrix.name}}) @@ -144,10 +145,11 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v7 with: - name: dusklight-${{env.DUSK_VERSION}}-${{matrix.artifact_name}} + name: dusklight-${{env.APP_VERSION}}-${{matrix.artifact_name}} path: | build/install/Dusklight.app build/install/debug.tar.* + build/install/sdk/ build-android: name: Build Android (${{matrix.name}}) @@ -203,18 +205,24 @@ jobs: - name: Build native library run: cmake --build --preset ${{matrix.preset}} --target dusklight - - name: Stage stripped JNI library - run: ANDROID_STAGE_ABIS="${{matrix.abi}}" platforms/android/scripts/stage-jni-libs.sh + - name: Build bundled mods + run: cmake --build --preset ${{matrix.preset}} --target dusklight_mods - name: Build APK working-directory: platforms/android run: ./gradlew :app:assembleRelease --rerun-tasks + - name: Stage artifacts + run: | + mkdir -p upload/sdk + cp build/*/stub-android-*.so upload/sdk/ + cp platforms/android/app/build/outputs/apk/release/app-${{matrix.abi}}-release-unsigned.apk upload/ + - name: Upload artifacts uses: actions/upload-artifact@v7 with: - name: dusklight-${{env.DUSK_VERSION}}-android-${{matrix.artifact_arch}} - path: platforms/android/app/build/outputs/apk/release/app-${{matrix.abi}}-release-unsigned.apk + name: dusklight-${{env.APP_VERSION}}-android-${{matrix.artifact_arch}} + path: upload/ build-windows: name: Build Windows (${{matrix.name}}) @@ -275,9 +283,11 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v7 with: - name: dusklight-${{env.DUSK_VERSION}}-win32-msvc-${{matrix.artifact_arch}} + name: dusklight-${{env.APP_VERSION}}-win32-msvc-${{matrix.artifact_arch}} path: | build/install/*.exe build/install/*.dll build/install/res/ + build/install/mods/ build/install/debug.7z + build/install/sdk/ diff --git a/.gitmodules b/.gitmodules index b386c1754a..881f8f524b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,12 @@ [submodule "extern/aurora"] path = extern/aurora url = https://github.com/encounter/aurora.git +[submodule "extern/borealis"] + path = extern/borealis + url = https://github.com/encounter/borealis.git +[submodule "mods/randomizer"] + path = mods/randomizer + url = https://github.com/TwilitRealm/dusklight-randomizer.git +[submodule "mods/cosmetics"] + path = mods/cosmetics + url = https://github.com/TwilitRealm/dusklight-cosmetics diff --git a/CMakeLists.txt b/CMakeLists.txt index e62704fe1c..ec18d422bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,11 @@ if (NOT CMAKE_BUILD_TYPE) "Build type options: Debug Release RelWithDebInfo MinSizeRel" FORCE) endif () -include(cmake/DetectVersion.cmake) -detect_version() +include(extern/borealis/cmake/DetectVersion.cmake) +borealis_detect_version() message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") -project(dusklight LANGUAGES C CXX VERSION ${DUSK_VERSION_STRING}) +project(dusklight LANGUAGES C CXX VERSION ${BOREALIS_APP_VERSION}) + if (APPLE) enable_language(OBJC OBJCXX) endif () @@ -32,6 +33,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(CMAKE_COLOR_DIAGNOSTICS ON) # Folder-based instead of target-based organization # in Visual Studio and Xcode generators @@ -70,10 +72,13 @@ if (CMAKE_SYSTEM_NAME STREQUAL Linux) endif () set(AURORA_ENABLE_DVD ON CACHE BOOL "Enable DVD API support" FORCE) set(AURORA_ENABLE_CARD ON CACHE BOOL "Enable CARD API support" FORCE) +set(AURORA_ENABLE_THP ON CACHE BOOL "Enable THP decoder" FORCE) set(AURORA_ENABLE_RMLUI ON CACHE BOOL "Enable RmlUi UI support" FORCE) add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) target_compile_definitions(aurora_mtx PRIVATE MTX_USE_PS=1) +add_subdirectory(extern/borealis EXCLUDE_FROM_ALL) + add_subdirectory(libs/freeverb) if (CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -84,12 +89,38 @@ endif () option(DUSK_BUILD_WARNINGS "Enable compiler warnings (off by default)") option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled with optimizations on Debug, intending to make the game run at 30 FPS. Note for MSVC: you will need to remove '/RTC1' from your debug flags in CMake.") -option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) -option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON) -option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF) option(DUSK_PACKAGE_INSTALL "Install Dusklight with a Linux-native file structure" OFF) option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) -option(DUSK_ENABLE_CODE_MODS "Enable code mods" OFF) +option(DUSK_ENABLE_CODE_MODS "Enable code mods" ON) + +set(DUSK_HAS_FUNCHOOK OFF) +if (DUSK_ENABLE_CODE_MODS AND (NOT APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")) + set(DUSK_HAS_FUNCHOOK ON) +endif () +set(DUSK_HAS_FUNCHOOK ${DUSK_HAS_FUNCHOOK} CACHE INTERNAL "Enable funchook" FORCE) + +set(_target_architectures ${CMAKE_OSX_ARCHITECTURES}) +if (NOT _target_architectures) + set(_target_architectures ${CMAKE_SYSTEM_PROCESSOR}) +endif () +list(LENGTH _target_architectures _target_arch_count) +set(DUSK_HAS_PREPATCH OFF) +if (DUSK_ENABLE_CODE_MODS AND APPLE AND _target_arch_count EQUAL 1) + list(GET _target_architectures 0 _target_arch) + if (_target_arch STREQUAL "arm64") + set(DUSK_HAS_PREPATCH ON) + endif () +endif () +set(DUSK_HAS_PREPATCH ${DUSK_HAS_PREPATCH} CACHE INTERNAL "Enable symgen prepatch support" FORCE) + +if (DUSK_ENABLE_CODE_MODS AND CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS)$") + list(LENGTH CMAKE_OSX_ARCHITECTURES _mobile_arch_count) + if (NOT _mobile_arch_count EQUAL 1 OR NOT CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") + message(FATAL_ERROR + "iOS/tvOS code mods require a single arm64 architecture; got " + "CMAKE_OSX_ARCHITECTURES='${CMAKE_OSX_ARCHITECTURES}'") + endif () +endif () # Edit & Continue if (MSVC) @@ -102,86 +133,21 @@ if (MSVC) endif () endif () -if (DUSK_MOVIE_SUPPORT) - find_package(libjpeg-turbo 3.0 CONFIG QUIET) - if (libjpeg-turbo_FOUND) - message(STATUS "dusklight: Using system libjpeg-turbo") - else () - message(STATUS "dusklight: Fetching libjpeg-turbo") - include(ExternalProject) - set(_jpeg_install_dir ${CMAKE_BINARY_DIR}/libjpeg-turbo-install) - if (WIN32) - set(_jpeg_lib ${_jpeg_install_dir}/lib/turbojpeg-static.lib) - else () - set(_jpeg_lib ${_jpeg_install_dir}/lib/libturbojpeg.a) - endif () - set(_jpeg_cmake_args - -DCMAKE_INSTALL_PREFIX=${_jpeg_install_dir} - -DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsTargetProcessor.cmake - -DENABLE_SHARED=OFF - -DWITH_TURBOJPEG=ON - -DWITH_JAVA=OFF - ) - if (CMAKE_TOOLCHAIN_FILE) - get_filename_component(_jpeg_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") - list(APPEND _jpeg_cmake_args -DCMAKE_TOOLCHAIN_FILE=${_jpeg_toolchain_file}) - endif () - set(_jpeg_passthrough_vars - ANDROID_ABI - ANDROID_PLATFORM - CMAKE_BUILD_TYPE - CMAKE_C_COMPILER - CMAKE_C_COMPILER_LAUNCHER - CMAKE_MAKE_PROGRAM - CMAKE_MSVC_RUNTIME_LIBRARY - CMAKE_MSVC_DEBUG_INFORMATION_FORMAT - CMAKE_OSX_ARCHITECTURES - CMAKE_OSX_DEPLOYMENT_TARGET - CMAKE_OSX_SYSROOT - DEPLOYMENT_TARGET - ENABLE_ARC - ENABLE_BITCODE - PLATFORM - ) - foreach(_var IN LISTS _jpeg_passthrough_vars) - if (DEFINED ${_var}) - list(APPEND _jpeg_cmake_args -D${_var}=${${_var}}) - endif () - endforeach () - ExternalProject_Add(libjpeg-turbo-ext - URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/3.1.0.tar.gz - URL_HASH SHA256=35fec2e1ddfb05ecf6d93e50bc57c1e54bc81c16d611ddf6eff73fff266d8285 - CMAKE_ARGS ${_jpeg_cmake_args} - BUILD_BYPRODUCTS ${_jpeg_lib} - ) - file(MAKE_DIRECTORY ${_jpeg_install_dir}/include) - add_library(libjpeg-turbo::turbojpeg-static STATIC IMPORTED GLOBAL) - set_target_properties(libjpeg-turbo::turbojpeg-static PROPERTIES - IMPORTED_LOCATION ${_jpeg_lib} - INTERFACE_INCLUDE_DIRECTORIES ${_jpeg_install_dir}/include - ) - add_dependencies(libjpeg-turbo::turbojpeg-static libjpeg-turbo-ext) - endif () -endif () - -if (CMAKE_SYSTEM_NAME STREQUAL Linux) +if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") # -Wno-multichar: Multi-character constants ('ABCD') are implementation-defined but all compilers # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. # For >4-char literals (which GCC/Clang truncate to int), use the MULTI_CHAR() macro. # -Wdeprecated-declarations: JSystem uses std::iterator, deprecated in C++17 - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar -Wno-trigraphs -Wno-deprecated-declarations") - set(CMAKE_INSTALL_RPATH "$ORIGIN") - set(CMAKE_BUILD_RPATH "$ORIGIN") -elseif (APPLE) - add_compile_options(-Wno-declaration-after-statement -Wno-non-pod-varargs) - set(CMAKE_INSTALL_RPATH "$ORIGIN") - set(CMAKE_BUILD_RPATH "$ORIGIN") -elseif (MSVC) add_compile_options( - $<$:/bigobj> - $<$:/MP> - $<$:/FS> + $<$:-Wno-multichar> + $<$:-Wno-trigraphs> + $<$:-Wno-deprecated-declarations> + ) +elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + add_compile_options( + $<$:/bigobj> + $<$:/MP> + $<$:/FS> ) if (NOT DUSK_BUILD_WARNINGS) @@ -196,30 +162,34 @@ elseif (MSVC) add_compile_options($<$:/utf-8>) endif () +if (CMAKE_SYSTEM_NAME STREQUAL Linux) + set(CMAKE_INSTALL_RPATH "$ORIGIN") + set(CMAKE_BUILD_RPATH "$ORIGIN") +elseif (APPLE) + add_compile_options(-Wno-declaration-after-statement -Wno-non-pod-varargs) + set(CMAKE_INSTALL_RPATH "@loader_path") + set(CMAKE_BUILD_RPATH "@loader_path") +endif () + include(FetchContent) # Declare all dependencies first so CMake can download them in parallel -message(STATUS "dusklight: Fetching cxxopts") -FetchContent_Declare(cxxopts - URL https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.3.1.tar.gz - URL_HASH SHA256=3bfc70542c521d4b55a46429d808178916a579b28d048bd8c727ee76c39e2072 - DOWNLOAD_EXTRACT_TIMESTAMP FALSE -) -message(STATUS "dusklight: Fetching nlohmann/json") -FetchContent_Declare(json - URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz - URL_HASH SHA256=42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa - DOWNLOAD_EXTRACT_TIMESTAMP FALSE -) message(STATUS "dusklight: Fetching miniz") FetchContent_Declare(miniz URL https://github.com/richgel999/miniz/releases/download/3.0.2/miniz-3.0.2.zip DOWNLOAD_EXTRACT_TIMESTAMP TRUE EXCLUDE_FROM_ALL ) +message(STATUS "dusklight: Fetching PicoSHA2") +FetchContent_Declare(picosha2 + URL https://github.com/okdshin/PicoSHA2/archive/refs/tags/v1.0.1.tar.gz + URL_HASH SHA256=9983136544234e573fe07cc1a22fdf978ad7979043e7be2e9082f6d4991ff8a8 + DOWNLOAD_EXTRACT_TIMESTAMP TRUE + EXCLUDE_FROM_ALL +) -set(_fetch_content_deps cxxopts json miniz) -if (DUSK_ENABLE_CODE_MODS) +set(_fetch_content_deps miniz picosha2) +if (DUSK_HAS_FUNCHOOK) message(STATUS "dusklight: Fetching funchook") # cmake/PatchFunchook.cmake patches funchook's cmake/capstone.cmake.in to inject a # PATCH_COMMAND into capstone's inner ExternalProject. That PATCH_COMMAND runs @@ -253,30 +223,12 @@ if (DUSK_ENABLE_CODE_MODS) endif () FetchContent_MakeAvailable(${_fetch_content_deps}) -if (DUSK_ENABLE_SENTRY_NATIVE) - message(STATUS "dusklight: Fetching sentry-native") - set(SENTRY_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) - set(SENTRY_BACKEND crashpad CACHE STRING "" FORCE) - if (WIN32) - set(SENTRY_TRANSPORT winhttp CACHE STRING "" FORCE) - endif () - set(SENTRY_BUILD_TESTS OFF CACHE BOOL "" FORCE) - set(SENTRY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - set(SENTRY_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) - FetchContent_Declare(sentry_native - GIT_REPOSITORY https://github.com/getsentry/sentry-native.git - GIT_TAG 0.13.6 - GIT_SHALLOW TRUE - GIT_PROGRESS TRUE - GIT_SUBMODULES_RECURSE TRUE - ) - if (NOT sentry_native_POPULATED) - FetchContent_Populate(sentry_native) - set(_dusk_skip_install_rules ${CMAKE_SKIP_INSTALL_RULES}) - set(CMAKE_SKIP_INSTALL_RULES ON) - add_subdirectory(${sentry_native_SOURCE_DIR} ${sentry_native_BINARY_DIR} EXCLUDE_FROM_ALL) - set(CMAKE_SKIP_INSTALL_RULES ${_dusk_skip_install_rules}) - endif () +if (DUSK_HAS_FUNCHOOK AND APPLE) + target_sources(funchook-static PRIVATE src/dusk/mods/loader/code_patch_macos.cpp) + target_include_directories(funchook-static PRIVATE src/dusk/mods/loader) + set_source_files_properties(src/dusk/mods/loader/code_patch_macos.cpp + TARGET_DIRECTORY funchook-static PROPERTIES + COMPILE_OPTIONS "-O2;-fno-sanitize=all;-fno-stack-protector") endif () # Use signed char on ARM to match the original game (and x86) @@ -285,8 +237,6 @@ if(_arch MATCHES "^(arm|aarch64)" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQU add_compile_options(-fsigned-char) endif() -configure_version_header() - include(files.cmake) # TODO: version handling for res includes @@ -299,87 +249,29 @@ set(DUSK_PRODUCT_NAME "Dusklight") set(DUSK_COPYRIGHT "Copyright (C) Twilit Realm contributors") source_group("dolzel" FILES ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${REL_FILES}) -source_group("dusklight" FILES ${DUSK_FILES} ${DUSK_HTTP_BACKEND_FILES}) +source_group("dusklight" FILES ${DUSK_FILES}) include(cmake/GameABIConfig.cmake) find_package(Threads REQUIRED) -set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd - aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt - Threads::Threads zstd::libzstd dusklight_game_headers) -if (DUSK_ENABLE_CODE_MODS) +set(GAME_COMPILE_DEFS DUSK_BUILDING_GAME=1) +set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd aurora::thp + aurora::card borealis::http borealis::cli borealis::crash borealis::data borealis::disc borealis::discord borealis::file_select borealis::io borealis::log borealis::net borealis::presentation borealis::sentry borealis::update borealis::ws freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt + Threads::Threads zstd::libzstd dusklight_game_headers picosha2 PNG::PNG) +if (DUSK_HAS_FUNCHOOK) list(APPEND GAME_LIBS funchook-static) endif () -if (DUSK_ENABLE_SENTRY_NATIVE) - list(APPEND GAME_LIBS sentry) - list(APPEND GAME_COMPILE_DEFS DUSK_ENABLE_SENTRY_NATIVE=1 SENTRY_BUILD_STATIC=1) -endif () - if (WIN32) list(APPEND GAME_LIBS Ws2_32) - if (CMAKE_BUILD_TYPE STREQUAL Debug) - list(APPEND GAME_LIBS dbghelp) - list(APPEND GAME_COMPILE_DEFS DUSK_CRASH_DBGHELP=1) - endif () -endif () - -set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/no_backend.cpp) -if (DUSK_ENABLE_UPDATE_CHECKER) - list(APPEND GAME_COMPILE_DEFS DUSK_ENABLE_UPDATE_CHECKER=1) - if (WIN32) - set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/winhttp.cpp) - list(APPEND GAME_LIBS winhttp) - list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_WINHTTP=1) - message(STATUS "dusklight: Enabled update checker (WinHTTP)") - elseif (ANDROID) - set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/android.cpp) - list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_ANDROID=1) - message(STATUS "dusklight: Enabled update checker (Android)") - elseif (APPLE) - find_library(FOUNDATION_FRAMEWORK Foundation REQUIRED) - set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/url_session.mm) - set_source_files_properties(src/dusk/http/url_session.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) - list(APPEND GAME_LIBS ${FOUNDATION_FRAMEWORK}) - list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_URLSESSION=1) - message(STATUS "dusklight: Enabled update checker (NSURLSession)") - elseif (CMAKE_SYSTEM_NAME STREQUAL Linux) - find_package(CURL QUIET OPTIONAL_COMPONENTS HTTPS SSL) - if (CURL_FOUND AND CURL_HTTPS_FOUND AND CURL_SSL_FOUND) - set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/curl.cpp) - list(APPEND GAME_LIBS CURL::libcurl) - list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_LIBCURL=1) - message(STATUS "dusklight: Enabled update checker (libcurl)") - else () - message(STATUS "dusklight: Disabled update checker (libcurl + HTTPS/SSL not found)") - endif () - else () - message(STATUS "dusklight: Disabled update checker (unsupported platform)") - endif () -endif () -list(APPEND DUSK_FILES ${DUSK_HTTP_BACKEND_SOURCE}) - -if (DUSK_MOVIE_SUPPORT) - if (TARGET libjpeg-turbo::turbojpeg-static) - list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg-static) - else () - list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg) - endif () - list(APPEND GAME_COMPILE_DEFS MOVIE_SUPPORT=1) -endif () - -set(DUSK_ENABLE_DISCORD_DEFAULT ON) -if (DEFINED DUSK_ENABLE_DISCORD_RPC AND NOT DEFINED DUSK_ENABLE_DISCORD) - set(DUSK_ENABLE_DISCORD_DEFAULT ${DUSK_ENABLE_DISCORD_RPC}) -endif () -option(DUSK_ENABLE_DISCORD "Enable Discord Rich Presence support" ${DUSK_ENABLE_DISCORD_DEFAULT}) -if (DUSK_ENABLE_DISCORD AND NOT ANDROID AND NOT IOS AND NOT TVOS) - list(APPEND GAME_COMPILE_DEFS DUSK_DISCORD=1) endif () if (DUSK_ENABLE_CODE_MODS) list(APPEND GAME_COMPILE_DEFS DUSK_CODE_MODS=1) endif () +list(APPEND GAME_COMPILE_DEFS + DUSK_HAS_FUNCHOOK=$ + DUSK_HAS_PREPATCH=$) if (DUSK_PACKAGE_INSTALL) include(GNUInstallDirs) @@ -435,20 +327,31 @@ if (CMAKE_CXX_LINK_GROUP_USING_RESCAN_SUPPORTED OR CMAKE_LINK_GROUP_USING_RESCAN set(JSYSTEM_LINK_LIBRARIES "$") endif () -set(DUSK_FILES src/dusk/main.cpp ${GAME_BASE_FILES} ${GAME_DEBUG_FILES} ${miniz_SOURCE_DIR}/miniz.c) -if(ANDROID) - add_library(dusklight SHARED ${DUSK_FILES}) - set_target_properties(dusklight PROPERTIES OUTPUT_NAME main) -else () - add_executable(dusklight ${DUSK_FILES}) -endif () +set(_dusklight_all_files src/dusk/main.cpp ${GAME_BASE_FILES} ${GAME_DEBUG_FILES}) +set(DUSK_INTERNAL_FILES ${_dusklight_all_files}) +list(FILTER DUSK_INTERNAL_FILES INCLUDE REGEX "^src/dusk/") +set(GAME_FILES ${_dusklight_all_files}) +list(FILTER GAME_FILES EXCLUDE REGEX "^src/dusk/") + +add_library(dusk_internal OBJECT ${DUSK_INTERNAL_FILES}) if (ENABLE_ASAN) - target_sources(dusklight PRIVATE src/dusk/asan_options.c) + target_sources(dusk_internal PRIVATE src/dusk/asan_options.c) endif () +target_compile_definitions(dusk_internal PRIVATE ${GAME_COMPILE_DEFS}) +target_include_directories(dusk_internal PRIVATE ${miniz_SOURCE_DIR}) +target_link_libraries(dusk_internal PRIVATE aurora::main ${GAME_LIBS} ${JSYSTEM_LIBRARIES}) +target_precompile_headers(dusk_internal PRIVATE "$<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") + +if(ANDROID) + add_library(dusklight SHARED ${GAME_FILES} ${miniz_SOURCE_DIR}/miniz.c) +else () + add_executable(dusklight ${GAME_FILES} ${miniz_SOURCE_DIR}/miniz.c) +endif () +borealis_configure_android_application(dusklight) target_compile_definitions(dusklight PRIVATE ${GAME_COMPILE_DEFS}) target_include_directories(dusklight PRIVATE ${miniz_SOURCE_DIR}) -target_link_libraries(dusklight PRIVATE aurora::main ${GAME_LIBS} ${JSYSTEM_LINK_LIBRARIES}) +target_link_libraries(dusklight PRIVATE dusk_internal aurora::main ${GAME_LIBS} ${JSYSTEM_LINK_LIBRARIES}) target_precompile_headers(dusklight PRIVATE "$<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") if (DUSK_ENABLE_CODE_MODS) @@ -462,37 +365,89 @@ if (DUSK_ENABLE_CODE_MODS) setup_symbol_manifest(dusklight) endif () -# Hook reliability: guaranteed patchable entries on the game ABI surface, and no identical-code folding. -if (MSVC) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:/hotpatch>) +# Hook reliability: prevent auto-inlining, guarantee patchable function entries, +# and disable identical-code folding for game functions. +if (DUSK_ENABLE_CODE_MODS) + set(DUSK_GAME_ABI_INLINE_OPTIONS) + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS + $<$:-finline-hint-functions>) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + list(APPEND DUSK_GAME_ABI_INLINE_OPTIONS + $<$:-flive-patching=inline-clone> + $<$:-fno-inline-functions> + $<$:-fno-inline-small-functions> + $<$:-fno-inline-functions-called-once> + $<$:-fno-early-inlining> + $<$:-fno-ipa-cp> + $<$:-fno-ipa-cp-clone> + $<$:-fno-ipa-sra> + $<$:-fno-partial-inlining>) + endif () endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") - target_link_options(dusklight PRIVATE /FUNCTIONPADMIN:16 /OPT:NOICF) - else () - target_link_options(dusklight PRIVATE /FUNCTIONPADMIN /OPT:NOICF) + + if (DUSK_GAME_ABI_INLINE_OPTIONS) + target_compile_options(dusklight PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) + + foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) + target_compile_options(${jsystem_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) + endforeach() + foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_sdk_lib}) + get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) + if (NOT _sdk_lib_imported) + target_compile_options(${_sdk_lib} PRIVATE ${DUSK_GAME_ABI_INLINE_OPTIONS}) + endif () + endif () + endforeach () endif () -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=2,1>) - else () - set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=10,5>) + + if (MSVC) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:/hotpatch>) + endif () + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") + target_link_options(dusklight PRIVATE /FUNCTIONPADMIN:16 /OPT:NOICF) + else () + target_link_options(dusklight PRIVATE /FUNCTIONPADMIN /OPT:NOICF) + endif () + elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(AppleClang|Clang|GNU)$") + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=2,1>) + else () + set(DUSK_PATCHABLE_ENTRY_FLAG $<$:-fpatchable-function-entry=10,4>) + endif () + endif () + + if (DEFINED DUSK_PATCHABLE_ENTRY_FLAG) + target_compile_options(dusklight PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) + target_compile_options(${jsystem_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + endforeach() + foreach(_sdk_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_sdk_lib}) + get_target_property(_sdk_lib_imported ${_sdk_lib} IMPORTED) + if (NOT _sdk_lib_imported) + target_compile_options(${_sdk_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) + endif () + endif () + endforeach () endif () -endif () -if (DEFINED DUSK_PATCHABLE_ENTRY_FLAG) - target_compile_options(dusklight PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) - foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) - target_compile_options(${jsystem_lib} PRIVATE ${DUSK_PATCHABLE_ENTRY_FLAG}) - endforeach() endif () if (WIN32) target_link_libraries(dusklight PRIVATE Psapi) endif () if (APPLE) - # Mods resolve game symbols from the executable at dlopen time. - target_link_options(dusklight PRIVATE -Wl,-export_dynamic) -elseif (UNIX AND NOT ANDROID) + include(cmake/AppleExports.cmake) + setup_apple_exports(dusklight) +elseif (ANDROID) + include(cmake/AndroidExports.cmake) + setup_android_exports(dusklight) +elseif (UNIX) target_link_options(dusklight PRIVATE -rdynamic) endif () @@ -506,12 +461,6 @@ if (TARGET crashpad_handler) ) endif () -if (ANDROID) - # SDLActivity loads SDL_main via dlsym on Android. Since aurora::main is a static - # archive, force an undefined reference so the linker keeps the SDL_main object. - target_link_options(dusklight PRIVATE "-Wl,-u,SDL_main") -endif () - if (CMAKE_SYSTEM_NAME STREQUAL Linux) target_link_options(dusklight PRIVATE "-Wl,--build-id=sha1") target_link_libraries(dusklight PRIVATE dl) @@ -559,7 +508,15 @@ include(cmake/ModSDK.cmake) if (DUSK_ENABLE_CODE_MODS AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) add_custom_target(dusklight_mods) # Aggregate target for all in-tree mods - add_subdirectory(tools/mod_template) + add_subdirectory(mods/luau_runtime) + add_subdirectory(mods/template_mod) + add_subdirectory(mods/ao_mod) + add_subdirectory(mods/shadow_mod) + add_subdirectory(mods/window_demo) + add_subdirectory(mods/flow_demo) + add_subdirectory(mods/custom_actor_demo) + add_subdirectory(mods/cosmetics) + add_subdirectory(mods/randomizer) endif () if (APPLE) @@ -593,8 +550,8 @@ if (APPLE) MACOSX_BUNDLE TRUE MACOSX_BUNDLE_BUNDLE_NAME ${DUSK_BUNDLE_NAME} MACOSX_BUNDLE_GUI_IDENTIFIER ${DUSK_BUNDLE_IDENTIFIER} - MACOSX_BUNDLE_BUNDLE_VERSION ${DUSK_VERSION_STRING} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${DUSK_SHORT_VERSION_STRING} + MACOSX_BUNDLE_BUNDLE_VERSION ${BOREALIS_APP_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${BOREALIS_APP_SHORT_VERSION} MACOSX_BUNDLE_INFO_PLIST ${DUSK_INFO_PLIST} OUTPUT_NAME Dusklight XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "YES" @@ -604,13 +561,13 @@ if (APPLE) list(APPEND _apple_bundle_properties XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${DUSK_ENTITLEMENTS}) endif () - if (NOT IOS AND NOT TVOS) + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") list(APPEND _apple_bundle_properties XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES") endif () set_target_properties(dusklight PROPERTIES ${_apple_bundle_properties}) - if (NOT IOS AND NOT TVOS AND NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") set(_sign_nested_commands) if (TARGET crashpad_handler) list(APPEND _sign_nested_commands @@ -627,21 +584,6 @@ if (APPLE) endif () endif () -if (APPLE AND NOT IOS AND NOT TVOS) - find_library(APPKIT_FRAMEWORK AppKit REQUIRED) - target_sources(dusklight PRIVATE src/dusk/file_select_macos.mm) - set_source_files_properties(src/dusk/file_select_macos.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) - target_link_libraries(dusklight PRIVATE ${APPKIT_FRAMEWORK}) -endif () - -if (IOS) - find_library(UIKIT_FRAMEWORK UIKit REQUIRED) - find_library(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK UniformTypeIdentifiers REQUIRED) - target_sources(dusklight PRIVATE src/dusk/ios/FileSelectDialog.m) - set_source_files_properties(src/dusk/ios/FileSelectDialog.m PROPERTIES COMPILE_FLAGS -fobjc-arc) - target_link_libraries(dusklight PRIVATE ${UIKIT_FRAMEWORK} ${UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK}) -endif () - include(extern/aurora/cmake/AuroraCopyRuntimeDLLs.cmake) aurora_copy_runtime_dlls(dusklight) diff --git a/CMakePresets.json b/CMakePresets.json index 394a1ddef5..849e4161cd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -22,30 +22,18 @@ "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDLL" } }, - { - "name": "release", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDLL", - "CMAKE_INTERPROCEDURAL_OPTIMIZATION": { - "type": "BOOL", - "value": true - } - } - }, { "name": "ci", "hidden": true, "cacheVariables": { "CMAKE_C_COMPILER_LAUNCHER": "sccache", "CMAKE_CXX_COMPILER_LAUNCHER": "sccache", - "DUSK_ENABLE_SENTRY_NATIVE": { + "BOREALIS_ENABLE_SENTRY": { "type": "BOOL", "value": true }, - "DUSK_SENTRY_DSN": "$env{SENTRY_DSN}", - "DUSK_SENTRY_ENVIRONMENT": "production", + "BOREALIS_SENTRY_DSN": "$env{SENTRY_DSN}", + "BOREALIS_SENTRY_ENVIRONMENT": "production", "Rust_RUSTUP_INSTALL_MISSING_TARGET": { "type": "BOOL", "value": true @@ -72,11 +60,7 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - } + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -163,10 +147,6 @@ "CMAKE_C_COMPILER": "cl", "CMAKE_CXX_COMPILER": "cl", "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -208,17 +188,13 @@ { "name": "windows-arm64-msvc", "displayName": "Windows ARM64 (MSVC)", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "windows-msvc" + ], "architecture": { "value": "arm64", "strategy": "external" }, - "cacheVariables": { - "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" - }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ @@ -270,11 +246,7 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - } + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -330,6 +302,10 @@ "type": "BOOL", "value": false }, + "ENABLE_VISIBILITY": { + "type": "BOOL", + "value": true + }, "Rust_CARGO_TARGET": "aarch64-apple-ios", "BUILD_SHARED_LIBS": { "type": "BOOL", @@ -370,6 +346,10 @@ "type": "BOOL", "value": false }, + "ENABLE_VISIBILITY": { + "type": "BOOL", + "value": true + }, "Rust_CARGO_TARGET": "aarch64-apple-tvos", "Rust_TOOLCHAIN": "nightly", "BUILD_SHARED_LIBS": { @@ -406,10 +386,6 @@ "type": "BOOL", "value": false }, - "DUSK_ENABLE_CODE_MODS": { - "type": "BOOL", - "value": true - }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -445,11 +421,10 @@ "hidden": true, "inherits": [ "android-base", - "ci", - "release" + "ci" ], "cacheVariables": { - "DUSK_ENABLE_SENTRY_NATIVE": { + "BOREALIS_ENABLE_SENTRY": { "type": "BOOL", "value": false } diff --git a/README.md b/README.md index 7584c09c46..7445e43ea9 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Dusklight is a reverse-engineered reimplementation of Twilight Princess. It aims to be as accurate as possible to the original while also providing new options, enhancements, and tools to customize your experience. +> [!IMPORTANT] +> Dusklight's official website is https://twilitrealm.dev/, any other website is not affiliated and may be promoting AI-generated misinformation. + # Setup > [!IMPORTANT] @@ -26,7 +29,10 @@ It aims to be as accurate as possible to the original while also providing new o You must dump your own copy of the game. Please see [this article](https://wiki.dolphin-emu.org/index.php?title=Ripping_Games) for instructions. After dumping, you can use a program like [Dolphin](https://dolphin-emu.org/) or [nodtool](https://github.com/encounter/nod/releases) to convert the `.iso` to `.rvz` to save space. -Currently, only the GameCube USA and EUR releases are supported. Support for other versions of the game is planned in the future. +Dusklight currently supports all commercial discs except for Wii's Korean release. + +> [!NOTE] +> Dusklight is based on the [Twilight Princess decompilation](https://github.com/zeldaret/tp), which is currently only matching for GameCube. As a result, even when playing Dusklight with a Wii disc, you will be presented with the GameCube version's HUD and certain other specificities. ### 2. Install Dusklight diff --git a/ci/build-appimage.sh b/ci/build-appimage.sh index e12f1163b9..c4a0e82995 100755 --- a/ci/build-appimage.sh +++ b/ci/build-appimage.sh @@ -23,5 +23,5 @@ cp -r platforms/freedesktop/{16x16,32x32,48x48,64x64,128x128,256x256,512x512,102 cp platforms/freedesktop/dev.twilitrealm.dusk.desktop build/appdir/usr/share/applications cd build/install -VERSION="$DUSK_VERSION" NO_STRIP=1 "$linuxdeploy" \ +VERSION="$APP_VERSION" NO_STRIP=1 "$linuxdeploy" \ -l "$lib_dir/libusb-1.0.so" --appdir "$build_dir/appdir" --output appimage diff --git a/cmake/AndroidExports.cmake b/cmake/AndroidExports.cmake new file mode 100644 index 0000000000..a71c18a02b --- /dev/null +++ b/cmake/AndroidExports.cmake @@ -0,0 +1,61 @@ +include_guard(GLOBAL) + +get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) + +# Android mod linking: symgen scans and filters the game's exports, generating a version script used for the executable +# link step, and generates a shared object stub that mods can link against without having to build the whole game. +function(setup_android_exports target) + include("${_dir}/SymbolManifest.cmake") + ensure_symgen(TRUE) + add_dependencies(${target} symgen) + + set(_rsp_lines "$") + foreach (_lib IN LISTS JSYSTEM_LIBRARIES) + list(APPEND _rsp_lines "$") + endforeach () + list(JOIN _rsp_lines "\n" _rsp_content) + set(_rsp "${CMAKE_BINARY_DIR}/dusklight_exports_input.rsp") + file(GENERATE OUTPUT "${_rsp}" CONTENT "${_rsp_content}") + + set(_sdk_args) + foreach (_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_lib}) + list(APPEND _sdk_args --sdk-lib "$") + endif () + endforeach () + if (TARGET dawn::webgpu_dawn) + get_target_property(_dawn_type dawn::webgpu_dawn TYPE) + if (_dawn_type STREQUAL "STATIC_LIBRARY") + list(APPEND _sdk_args --sdk-lib "$") + endif () + endif () + + set(_vscript "${CMAKE_BINARY_DIR}/dusklight_exports.ver") + add_custom_command(TARGET ${target} PRE_LINK + COMMAND "${SYMGEN_EXE}" exports + "@${_rsp}" + --out "${_vscript}" + --format version-script + --exclude cmake_pch + --exclude miniz + # Resolved from the Java side; the SDL ones live in the statically-linked + # SDL archive, outside the provenance scan. + --extra-sym JNI_OnLoad + --extra-sym SDL_main + --extra-sym "Java_*" + ${_sdk_args} + COMMENT "Generating dusklight exports" + VERBATIM) + target_link_options(${target} PRIVATE "-Wl,--version-script=${_vscript}") + + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _arch) + set(_stub "${CMAKE_BINARY_DIR}/stub-android-${_arch}.so") + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${SYMGEN_EXE}" stub -f elf "$" -o "${_stub}" + --soname "$" --arch "${_arch}" + BYPRODUCTS "${_stub}" + COMMENT "Generating dusklight link stub" + VERBATIM) + install(FILES "${_stub}" DESTINATION sdk) +endfunction() diff --git a/cmake/AppleExports.cmake b/cmake/AppleExports.cmake new file mode 100644 index 0000000000..6397e353a5 --- /dev/null +++ b/cmake/AppleExports.cmake @@ -0,0 +1,88 @@ +include_guard(GLOBAL) + +get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) + +# Apple mod linking: symgen scans and filters the game's exports, generating an exports list used for the executable +# link step, and generates a MH_EXECUTE Mach-O stub that mods can link against without having to build the whole game. +function(setup_apple_exports target) + include("${_dir}/SymbolManifest.cmake") + ensure_symgen(TRUE) + set(_symgen "${SYMGEN_EXE}") + add_dependencies(${target} symgen) + + set(_config_subdir "") + if (CMAKE_CONFIGURATION_TYPES) + set(_config_subdir "$/") + endif () + + set(_rsp_lines "$") + foreach (_lib IN LISTS JSYSTEM_LIBRARIES) + list(APPEND _rsp_lines "$") + endforeach () + list(JOIN _rsp_lines "\n" _rsp_content) + set(_rsp "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_exports_input.rsp") + file(GENERATE OUTPUT "${_rsp}" CONTENT "${_rsp_content}") + + set(_sdk_args) + foreach (_lib aurora_card aurora_core aurora_dvd aurora_gd aurora_gx aurora_mtx + aurora_os aurora_pad aurora_si aurora_vi) + if (TARGET ${_lib}) + list(APPEND _sdk_args --sdk-lib "$") + endif () + endforeach () + + # Dawn is linked statically on Apple; mods reach wgpu* through the executable. + if (TARGET dawn::webgpu_dawn) + get_target_property(_dawn_type dawn::webgpu_dawn TYPE) + if (_dawn_type STREQUAL "STATIC_LIBRARY") + list(APPEND _sdk_args --sdk-lib "$") + endif () + endif () + + set(_exp "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_exports.exp") + add_custom_command(TARGET ${target} PRE_LINK + COMMAND "${_symgen}" exports + "@${_rsp}" + --out "${_exp}" + --exclude cmake_pch + --exclude miniz + ${_sdk_args} + COMMENT "Generating dusklight exports" + VERBATIM) + target_link_options(${target} PRIVATE -Xlinker -exported_symbols_list -Xlinker "${_exp}") + + # Generate the stub executable mods link against via -bundle_loader. + set(_stub_args) + if (IOS) + set(_stub_platform "ios") + list(APPEND _stub_args --platform ios) + elseif (TVOS) + set(_stub_platform "tvos") + list(APPEND _stub_args --platform tvos) + else () + set(_stub_platform "macos") + endif () + if (CMAKE_OSX_DEPLOYMENT_TARGET) + list(APPEND _stub_args --min-os "${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif () + if (CMAKE_OSX_ARCHITECTURES) + set(_archs "${CMAKE_OSX_ARCHITECTURES}") + else () + set(_archs "${CMAKE_SYSTEM_PROCESSOR}") + endif () + set(_arch_names "") + foreach (_arch IN LISTS _archs) + string(TOLOWER "${_arch}" _arch) + list(APPEND _stub_args --arch "${_arch}") + list(APPEND _arch_names "${_arch}") + endforeach () + list(JOIN _arch_names "_" _arch_name) + + set(_stub "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight-stub") + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${_symgen}" stub -f macho "${_exp}" -o "${_stub}" ${_stub_args} + BYPRODUCTS "${_stub}" + COMMENT "Generating dusklight link stub" + VERBATIM) + install(FILES "${_stub}" DESTINATION sdk RENAME "stub-${_stub_platform}-${_arch_name}") +endfunction() diff --git a/cmake/CopyModAssets.cmake b/cmake/CopyModAssets.cmake new file mode 100644 index 0000000000..ca16da6018 --- /dev/null +++ b/cmake/CopyModAssets.cmake @@ -0,0 +1,10 @@ +# Copies a mod asset directory for packaging, skipping dotfiles and dot-directories +# (.gitkeep, .DS_Store, ...). Usage: cmake -DSRC= -DDST= -P CopyModAssets.cmake +file(MAKE_DIRECTORY "${DST}") +file(GLOB_RECURSE _files RELATIVE "${SRC}" "${SRC}/*") +foreach (_file IN LISTS _files) + if (NOT _file MATCHES "(^|/)\\.") + get_filename_component(_dir "${_file}" DIRECTORY) + file(COPY "${SRC}/${_file}" DESTINATION "${DST}/${_dir}") + endif () +endforeach () diff --git a/cmake/DetectVersion.cmake b/cmake/DetectVersion.cmake deleted file mode 100644 index ec72a97a2e..0000000000 --- a/cmake/DetectVersion.cmake +++ /dev/null @@ -1,121 +0,0 @@ -# Version detection shared by the main build and the mod SDK (sdk/CMakeLists.txt) -include_guard(GLOBAL) - -get_filename_component(_DUSK_VERSION_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) - -set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") -set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") - -set(DUSK_VERSION_OVERRIDE "" CACHE STRING "Override version string (skips git detection and format validation)") - -macro(detect_version) - if (DUSK_VERSION_OVERRIDE) - set(DUSK_WC_DESCRIBE "${DUSK_VERSION_OVERRIDE}") - set(DUSK_VERSION_STRING "0.0.0.0") - set(DUSK_SHORT_VERSION_STRING "0.0.0") - set(DUSK_VERSION_CODE "1") - set(DUSK_WC_REVISION "") - set(DUSK_WC_BRANCH "") - set(DUSK_WC_DATE "") - message(STATUS "Dusklight version overridden to ${DUSK_WC_DESCRIBE}") - else () - # obtain revision info from git - find_package(Git) - if (GIT_FOUND) - # make sure version information gets re-run when the current Git HEAD changes - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD - OUTPUT_VARIABLE dusk_git_head_filename - OUTPUT_STRIP_TRAILING_WHITESPACE) - get_filename_component(dusk_git_head_filename "${dusk_git_head_filename}" ABSOLUTE BASE_DIR "${_DUSK_VERSION_ROOT}") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_filename}") - - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD - OUTPUT_VARIABLE dusk_git_head_symbolic - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} - COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${dusk_git_head_symbolic} - OUTPUT_VARIABLE dusk_git_head_symbolic_filename - OUTPUT_STRIP_TRAILING_WHITESPACE) - get_filename_component(dusk_git_head_symbolic_filename "${dusk_git_head_symbolic_filename}" ABSOLUTE BASE_DIR "${_DUSK_VERSION_ROOT}") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_symbolic_filename}") - - # defines DUSK_WC_REVISION - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - OUTPUT_VARIABLE DUSK_WC_REVISION - OUTPUT_STRIP_TRAILING_WHITESPACE) - # defines DUSK_WC_DESCRIBE - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --match "v*" - OUTPUT_VARIABLE DUSK_WC_DESCRIBE - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # remove the git hash, then collapse a clean "-0" suffix only - string(REGEX REPLACE "-[^-]+(-dirty|)$" "\\1" DUSK_WC_DESCRIBE "${DUSK_WC_DESCRIBE}") - string(REGEX REPLACE "-0$" "" DUSK_WC_DESCRIBE "${DUSK_WC_DESCRIBE}") - - # defines DUSK_WC_BRANCH - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD - OUTPUT_VARIABLE DUSK_WC_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE) - # defines DUSK_WC_DATE - execute_process(WORKING_DIRECTORY ${_DUSK_VERSION_ROOT} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad - OUTPUT_VARIABLE DUSK_WC_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE) - else () - message(STATUS "Unable to find git, commit information will not be available") - endif () - - if (DUSK_WC_DESCRIBE MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)([-+].*)?$") - set(DUSK_SHORT_VERSION_STRING "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") - set(_ver_major ${CMAKE_MATCH_1}) - set(_ver_minor ${CMAKE_MATCH_2}) - set(_ver_patch ${CMAKE_MATCH_3}) - set(DUSK_VERSION_TWEAK "0") - if (DUSK_WC_DESCRIBE MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+-([0-9]+)(-dirty)?$") - set(DUSK_VERSION_TWEAK "${CMAKE_MATCH_1}") - elseif (DUSK_WC_DESCRIBE MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9A-Za-z.-]+-([0-9]+)(-dirty)?$") - set(DUSK_VERSION_TWEAK "${CMAKE_MATCH_1}") - endif () - set(DUSK_VERSION_STRING "${DUSK_SHORT_VERSION_STRING}.${DUSK_VERSION_TWEAK}") - if (DUSK_VERSION_TWEAK GREATER 999) - set(_tweak 999) - else () - set(_tweak ${DUSK_VERSION_TWEAK}) - endif () - # encoding: major*1e7 + minor*1e5 + patch*1e3 + tweak; collision-free for major<210, minor<100, patch<100, tweak<=999 - math(EXPR DUSK_VERSION_CODE - "${_ver_major} * 10000000 + ${_ver_minor} * 100000 + ${_ver_patch} * 1000 + ${_tweak}") - else () - set(DUSK_WC_DESCRIBE "UNKNOWN-VERSION") - set(DUSK_VERSION_STRING "0.0.0.0") - set(DUSK_SHORT_VERSION_STRING "0.0.0") - set(DUSK_VERSION_CODE "1") - endif () - - endif () - - # Add version information to CI environment variables - if (DEFINED ENV{GITHUB_ENV}) - file(APPEND "$ENV{GITHUB_ENV}" "DUSK_VERSION=${DUSK_WC_DESCRIBE}\n") - file(APPEND "$ENV{GITHUB_ENV}" "DUSK_VERSION_CODE=${DUSK_VERSION_CODE}\n") - endif () - message(STATUS "Dusklight version set to ${DUSK_WC_DESCRIBE}") -endmacro() - -# Sets PLATFORM_NAME and configures version.h into the caller's binary dir. -macro(configure_version_header) - if (CMAKE_SYSTEM_NAME STREQUAL Windows) - set(PLATFORM_NAME win32) - elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin) - if (IOS) - set(PLATFORM_NAME ios) - elseif (TVOS) - set(PLATFORM_NAME tvos) - else () - set(PLATFORM_NAME macos) - endif () - else () - string(TOLOWER CMAKE_SYSTEM_NAME PLATFORM_NAME) - endif () - - configure_file(${_DUSK_VERSION_ROOT}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) -endmacro() diff --git a/cmake/GameABIConfig.cmake b/cmake/GameABIConfig.cmake index 030f1181a0..ef3b5818dc 100644 --- a/cmake/GameABIConfig.cmake +++ b/cmake/GameABIConfig.cmake @@ -9,19 +9,60 @@ if (ANDROID) list(APPEND _game_compile_defs TARGET_ANDROID=1) endif () -set(_game_include_dirs +# Public game headers +set(_game_abi_include_dirs ${_game_root}/include - ${_game_root}/src - ${_game_root}/assets/GZ2E01 # TODO: make this dynamic if needed? + ${_game_root}/assets/GZ2E01 ${_game_root}/libs/JSystem/include - ${_game_root}/libs ${_game_root}/extern/aurora/include/dolphin ${_game_root}/extern/aurora/include + ${_game_root}/sdk/include +) + +# Internal game headers +set(_game_include_dirs + ${_game_abi_include_dirs} + ${_game_root}/src ${_game_root}/extern ${CMAKE_CURRENT_BINARY_DIR} ) -# Interface target for mods and sub-projects to inherit game headers/defines. +# Mod API, including services +add_library(dusklight_mod_api INTERFACE) +target_include_directories(dusklight_mod_api INTERFACE ${_game_root}/sdk/include) + +# Full internal headers used to build the game add_library(dusklight_game_headers INTERFACE) target_include_directories(dusklight_game_headers INTERFACE ${_game_include_dirs}) target_compile_definitions(dusklight_game_headers INTERFACE ${_game_compile_defs}) + +# Public game ABI for mods +add_library(dusklight_game_abi_headers INTERFACE) +target_include_directories(dusklight_game_abi_headers INTERFACE ${_game_abi_include_dirs}) +target_compile_definitions(dusklight_game_abi_headers INTERFACE ${_game_compile_defs}) + +# Mod feature targets +add_library(dusklight_mod_feature_game INTERFACE) +target_link_libraries(dusklight_mod_feature_game INTERFACE + dusklight_mod_api + dusklight_game_abi_headers) +target_compile_definitions(dusklight_mod_feature_game INTERFACE DUSK_MOD_FEATURE_GAME=1) +# Game headers assume global.h comes first in the translation unit (it defines DUSK_GAME_DATA +# and friends); force-include it so mods don't depend on include order. +if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(dusklight_mod_feature_game INTERFACE + "$<$:/FIglobal.h>") +else () + target_compile_options(dusklight_mod_feature_game INTERFACE + "$<$:SHELL:-include global.h>") +endif () +target_sources(dusklight_mod_feature_game INTERFACE + ${_game_root}/sdk/src/game_feature.cpp) + +add_library(dusklight_mod_feature_webgpu INTERFACE) +target_link_libraries(dusklight_mod_feature_webgpu INTERFACE dusklight_mod_api) +target_compile_definitions(dusklight_mod_feature_webgpu INTERFACE DUSK_MOD_FEATURE_WEBGPU=1) + +add_library(dusklight_mod_feature_fmt INTERFACE) +target_link_libraries(dusklight_mod_feature_fmt INTERFACE dusklight_mod_api) +target_compile_definitions(dusklight_mod_feature_fmt INTERFACE DUSK_MOD_FEATURE_FMT=1) diff --git a/cmake/ModExports.exp b/cmake/ModExports.exp new file mode 100644 index 0000000000..3a9ec12942 --- /dev/null +++ b/cmake/ModExports.exp @@ -0,0 +1,5 @@ +_mod_ctx +_mod_initialize +_mod_meta +_mod_shutdown +_mod_update diff --git a/cmake/ModExports.ver b/cmake/ModExports.ver new file mode 100644 index 0000000000..9ddff1866c --- /dev/null +++ b/cmake/ModExports.ver @@ -0,0 +1,10 @@ +{ + global: + mod_ctx; + mod_initialize; + mod_meta; + mod_shutdown; + mod_update; + local: + *; +}; diff --git a/cmake/ModSDK.cmake b/cmake/ModSDK.cmake index c320dcb5f4..db3ca231d0 100644 --- a/cmake/ModSDK.cmake +++ b/cmake/ModSDK.cmake @@ -1,8 +1,11 @@ -# add_mod( SOURCES ... MOD_JSON [RES_DIR ] [OVERLAY_DIR ] +# add_mod( [FEATURES ...] SOURCES ... MOD_JSON +# [RUNTIME_LIBRARIES ...] [RES_DIR ] [OVERLAY_DIR ] # [TEXTURES_DIR ] [OUTPUT_DIR ] [BUNDLE]) set(DUSK_MODS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/mods" CACHE PATH "Directory to write mod packages into") +set(DUSKLIGHT_SDK_STUB_URL "https://github.com/encounter/dusklight/releases/download/sdk" + CACHE STRING "Base URL for game link stubs downloaded by out-of-tree mod builds") -function(_mod_lib_name out_var) +function(_mod_lib_info out_platform_var out_name_var) set(_arch "${CMAKE_SYSTEM_PROCESSOR}") if (APPLE AND CMAKE_OSX_ARCHITECTURES) list(LENGTH CMAKE_OSX_ARCHITECTURES _count) @@ -10,20 +13,62 @@ function(_mod_lib_name out_var) message(FATAL_ERROR "add_mod: universal binaries are not supported") endif () set(_arch "${CMAKE_OSX_ARCHITECTURES}") + elseif (WIN32) + set(_arch_id "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") + if (NOT _arch_id) + set(_arch_id "${CMAKE_C_COMPILER_ARCHITECTURE_ID}") + endif () + if (_arch_id MATCHES "^ARM64(EC)?$") + set(_arch "arm64") + elseif (_arch_id STREQUAL "x64") + set(_arch "amd64") + elseif (_arch_id STREQUAL "X86") + set(_arch "x86") + endif () endif () string(TOLOWER "${CMAKE_SYSTEM_NAME}" _platform) + if (_platform STREQUAL "darwin") + set(_platform "macos") + endif () string(TOLOWER "${_arch}" _arch) if (_arch MATCHES "^(i[3-6]86|x86)$") set(_arch "x86") endif () if (WIN32) set(_ext ".dll") - elseif (APPLE) - set(_ext ".dylib") else () set(_ext ".so") endif () - set(${out_var} "${_platform}-${_arch}${_ext}" PARENT_SCOPE) + set(${out_platform_var} "${_platform}-${_arch}" PARENT_SCOPE) + set(${out_name_var} "mod${_ext}" PARENT_SCOPE) +endfunction() + +# For out-of-tree builds without a game binary: download the version-independent link stub +# (generated by symgen) for the target platform. +function(_mod_download_link_stub out_var) + _mod_lib_info(_platform _lib_name) + if (WIN32) + set(_asset "${_platform}.lib") + elseif (ANDROID) + set(_asset "stub-${_platform}.so") + else () + set(_asset "stub-${_platform}") + endif () + set(_stub "${CMAKE_BINARY_DIR}/dusklight-sdk-stubs/${_asset}") + if (NOT EXISTS "${_stub}") + message(STATUS "Mod SDK: downloading link stub ${_asset}") + file(DOWNLOAD "${DUSKLIGHT_SDK_STUB_URL}/${_asset}" "${_stub}.tmp" STATUS _status) + list(GET _status 0 _code) + if (NOT _code EQUAL 0) + list(GET _status 1 _error) + file(REMOVE "${_stub}.tmp") + message(FATAL_ERROR + "Mod SDK: failed to download ${DUSKLIGHT_SDK_STUB_URL}/${_asset}: ${_error}\n" + "Set DUSK_GAME_EXE to a game binary or link stub to skip the download.") + endif () + file(RENAME "${_stub}.tmp" "${_stub}") + endif () + set(${out_var} "${_stub}" PARENT_SCOPE) endfunction() function(_mod_resolve_source_path out_var path) @@ -41,11 +86,62 @@ function(_mod_collect_assets out_var dir) endif () file(GLOB_RECURSE _files CONFIGURE_DEPENDS LIST_DIRECTORIES false "${dir}/*") - set(${out_var} ${_files} PARENT_SCOPE) + # Dotfiles (.gitkeep, .DS_Store, ...) are not packaged; see CopyModAssets.cmake. + set(_assets "") + foreach (_file IN LISTS _files) + file(RELATIVE_PATH _rel "${dir}" "${_file}") + if (NOT _rel MATCHES "(^|/)\\.") + list(APPEND _assets "${_file}") + endif () + endforeach () + set(${out_var} ${_assets} PARENT_SCOPE) +endfunction() + +function(_mod_add_webgpu_headers target_name) + if (NOT TARGET dawn::dawncpp_headers AND NOT TARGET dawn::webgpu_dawn) + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../extern/aurora/cmake/AuroraDependencyVersions.cmake") + set(AURORA_DAWN_PROVIDER "package" CACHE STRING "How to provide Dawn for the mod SDK") + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../extern/aurora/cmake/AuroraDawnProvider.cmake") + endif () + + if (TARGET dawn::dawncpp_headers) + target_link_libraries(${target_name} PRIVATE dawn::dawncpp_headers) + elseif (TARGET dawn::webgpu_dawn) + target_link_libraries(${target_name} PRIVATE dawn::webgpu_dawn) + else () + message(FATAL_ERROR "add_mod: FEATURES webgpu could not provide WebGPU headers") + endif () +endfunction() + +function(_mod_add_fmt target_name) + if (NOT TARGET fmt::fmt-header-only) + find_package(fmt 11 CONFIG QUIET GLOBAL) + endif () + + if (NOT TARGET fmt::fmt-header-only) + include(FetchContent) + message(STATUS "Mod SDK: fetching fmt") + # Keep the fallback version in sync with extern/aurora/extern/CMakeLists.txt. + FetchContent_Declare(fmt + URL https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz + URL_HASH SHA256=ea7de4299689e12b6dddd392f9896f08fb0777ac7168897a244a6d6085043fea + DOWNLOAD_EXTRACT_TIMESTAMP FALSE + EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(fmt) + endif () + + if (NOT TARGET fmt::fmt-header-only) + message(FATAL_ERROR "add_mod: FEATURES fmt could not provide fmt::fmt-header-only") + endif () + target_link_libraries(${target_name} PRIVATE fmt::fmt-header-only) endfunction() function(add_mod target_name) - cmake_parse_arguments(ARG "BUNDLE" "MOD_JSON;RES_DIR;OVERLAY_DIR;TEXTURES_DIR;OUTPUT_DIR" "SOURCES" ${ARGN}) + cmake_parse_arguments(ARG "BUNDLE" "MOD_JSON;RES_DIR;OVERLAY_DIR;TEXTURES_DIR;OUTPUT_DIR" + "SOURCES;RUNTIME_LIBRARIES;FEATURES" ${ARGN}) + if (ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "add_mod: unknown arguments: ${ARG_UNPARSED_ARGUMENTS}") + endif () if (NOT ARG_MOD_JSON) message(FATAL_ERROR "add_mod: MOD_JSON is required") endif () @@ -54,80 +150,156 @@ function(add_mod target_name) message(FATAL_ERROR "add_mod: MOD_JSON does not exist: ${_mod_json}") endif () - add_library(${target_name} SHARED ${ARG_SOURCES}) - _mod_lib_name(_lib_name) - set_target_properties(${target_name} PROPERTIES - PREFIX "" - C_VISIBILITY_PRESET hidden - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN ON - WINDOWS_EXPORT_ALL_SYMBOLS OFF) - target_compile_features(${target_name} PRIVATE cxx_std_20) - target_link_libraries(${target_name} PRIVATE dusklight_game_headers) - - if (NOT TARGET dusklight) - # Apply global compile options for out-of-tree mod builds - if (CMAKE_SYSTEM_NAME STREQUAL Linux) - target_compile_options(${target_name} PRIVATE - -Wno-multichar -Wno-trigraphs -Wno-deprecated-declarations) - elseif (APPLE) - target_compile_options(${target_name} PRIVATE - -Wno-declaration-after-statement -Wno-non-pod-varargs) - elseif (MSVC) - target_compile_options(${target_name} PRIVATE - "$<$:/bigobj>" - "$<$:/utf-8>") + set(_supported_features fmt game webgpu) + set(_features "") + foreach (_feature IN LISTS ARG_FEATURES) + list(FIND _supported_features "${_feature}" _feature_index) + if (_feature_index EQUAL -1) + list(JOIN _supported_features ", " _supported_features_text) + message(FATAL_ERROR + "add_mod: unknown feature '${_feature}' (supported: ${_supported_features_text})") endif () - # Use signed char on ARM to match the original game (and x86) - string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _mod_arch) - if (_mod_arch MATCHES "^(arm|aarch64)" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") - target_compile_options(${target_name} PRIVATE -fsigned-char) + list(FIND _features "${_feature}" _duplicate_index) + if (NOT _duplicate_index EQUAL -1) + message(FATAL_ERROR "add_mod: duplicate feature '${_feature}'") endif () + list(APPEND _features "${_feature}") + endforeach () + if (_features AND NOT ARG_SOURCES) + message(FATAL_ERROR "add_mod: FEATURES requires SOURCES") endif () - if (APPLE) - # Game symbols resolve against the host executable at dlopen time. - target_link_options(${target_name} PRIVATE -undefined dynamic_lookup) - elseif (ANDROID) - if (TARGET dusklight) - target_link_libraries(${target_name} PRIVATE dusklight) - elseif (DUSK_GAME_SOLIB) - target_link_libraries(${target_name} PRIVATE "${DUSK_GAME_SOLIB}") - else () - message(FATAL_ERROR "add_mod: DUSK_GAME_SOLIB is not set (libmain.so)") + set(_has_lib FALSE) + set(_needs_host_link FALSE) + set(_lib_platform "") + set(_lib_name "") + if (ARG_SOURCES) + set(_has_lib TRUE) + add_library(${target_name} MODULE ${ARG_SOURCES}) + _mod_lib_info(_lib_platform _lib_name) + set_target_properties(${target_name} PROPERTIES + PREFIX "" + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + WINDOWS_EXPORT_ALL_SYMBOLS OFF) + target_compile_features(${target_name} PRIVATE cxx_std_20) + target_link_libraries(${target_name} PRIVATE dusklight_mod_api) + + if (APPLE) + set(_mod_exports "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ModExports.exp") + target_link_options(${target_name} PRIVATE + -Xlinker -exported_symbols_list -Xlinker "${_mod_exports}") + set_property(TARGET ${target_name} APPEND PROPERTY LINK_DEPENDS "${_mod_exports}") + elseif (UNIX) + set(_mod_exports "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ModExports.ver") + target_link_options(${target_name} PRIVATE + "-Wl,--version-script=${_mod_exports}" + -Wl,--no-undefined-version) + set_property(TARGET ${target_name} APPEND PROPERTY LINK_DEPENDS "${_mod_exports}") endif () - elseif (UNIX) - target_link_options(${target_name} PRIVATE -Wl,--allow-shlib-undefined) - elseif (WIN32) - # Link against the generated import library (game ABI surface). Function calls - # resolve through import thunks. Data is toolchain dependent: - # - clang-cl: lld's mingw mode auto-imports data references, fixed up at load by - # the mod SDK's pseudo-relocation runtime (pseudo_reloc.cpp). - # - cl (MSVC): only DUSK_GAME_DATA-annotated data is reachable. Un-annotated - # references fail to link. - if (NOT DUSK_GAME_IMPLIB) - message(FATAL_ERROR "add_mod: DUSK_GAME_IMPLIB is not set.") - endif () - target_link_libraries(${target_name} PRIVATE "${DUSK_GAME_IMPLIB}") - set_target_properties(${target_name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") - target_compile_definitions(${target_name} PRIVATE _ITERATOR_DEBUG_LEVEL=0) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(${target_name} PRIVATE "$<$:/clang:-mcmodel=large>") - target_sources(${target_name} PRIVATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../sdk/pseudo_reloc.cpp") - # lld mingw mode rewrites /DEFAULTLIB directives to -l style and skips %LIB%, so - # the CRT libraries and search paths are spelled out explicitly. - target_link_options(${target_name} PRIVATE -lldmingw /nodefaultlib /INCREMENTAL:NO) - target_link_libraries(${target_name} PRIVATE - msvcrt.lib msvcprt.lib vcruntime.lib ucrt.lib - oldnames.lib uuid.lib kernel32.lib user32.lib) - set(_lib_dirs "$ENV{LIB}") - if ("${_lib_dirs}" STREQUAL "") - message(FATAL_ERROR "add_mod: %LIB% is empty; configure from a VS dev shell") + + foreach (_feature IN LISTS _features) + target_link_libraries(${target_name} PRIVATE dusklight_mod_feature_${_feature}) + if (_feature STREQUAL "webgpu") + _mod_add_webgpu_headers(${target_name}) + endif () + if (_feature STREQUAL "fmt") + _mod_add_fmt(${target_name}) + endif () + if (_feature STREQUAL "game" OR _feature STREQUAL "webgpu") + set(_needs_host_link TRUE) + endif () + endforeach () + + if (NOT TARGET dusklight) + # Apply global compile options for out-of-tree mod builds + if (CMAKE_SYSTEM_NAME STREQUAL Linux) + target_compile_options(${target_name} PRIVATE + -Wno-multichar -Wno-trigraphs -Wno-deprecated-declarations) + elseif (APPLE) + target_compile_options(${target_name} PRIVATE + -Wno-declaration-after-statement -Wno-non-pod-varargs) + elseif (MSVC) + target_compile_options(${target_name} PRIVATE + "$<$:/bigobj>" + "$<$:/utf-8>") + endif () + # Use signed char on ARM to match the original game (and x86) + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _mod_arch) + if (_mod_arch MATCHES "^(arm|aarch64)" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + target_compile_options(${target_name} PRIVATE -fsigned-char) endif () - foreach (_libdir IN LISTS _lib_dirs) - target_link_options(${target_name} PRIVATE "/libpath:${_libdir}") - endforeach () endif () + + if (APPLE) + if (_needs_host_link) + if (TARGET dusklight) + set(_game_exe "$") + add_dependencies(${target_name} dusklight) + elseif (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_exe "${DUSK_GAME_EXE}") + else () + _mod_download_link_stub(_game_exe) + endif () + target_link_options(${target_name} PRIVATE + -Xlinker -bundle_loader -Xlinker "${_game_exe}") + set_property(TARGET ${target_name} APPEND PROPERTY LINK_DEPENDS "${_game_exe}") + endif () + set_target_properties(${target_name} PROPERTIES + BUILD_RPATH "@loader_path" + INSTALL_RPATH "@loader_path") + elseif (ANDROID) + if (_needs_host_link) + if (TARGET dusklight) + target_link_libraries(${target_name} PRIVATE dusklight) + else () + if (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") + else () + _mod_download_link_stub(_game_lib) + endif () + target_link_libraries(${target_name} PRIVATE "${_game_lib}") + endif () + endif () + set_target_properties(${target_name} PROPERTIES + BUILD_RPATH "$ORIGIN" + INSTALL_RPATH "$ORIGIN") + elseif (UNIX) + if (_needs_host_link) + target_link_options(${target_name} PRIVATE -Wl,--allow-shlib-undefined) + endif () + set_target_properties(${target_name} PROPERTIES + BUILD_RPATH "$ORIGIN" + INSTALL_RPATH "$ORIGIN") + elseif (WIN32) + # Mods link against the game's import library (sdk/windows-.lib, generated by + # setup_windows_exports); cl and clang-cl both consume it in MSVC mode. Function + # calls resolve through import thunks; game data is reachable only through + # __declspec(dllimport), i.e. DUSK_GAME_DATA-annotated declarations. + if (_needs_host_link) + if (TARGET dusklight) + if (NOT DUSK_GAME_IMPLIB) + message(FATAL_ERROR + "add_mod: DUSK_GAME_IMPLIB is not set (see setup_windows_exports)") + endif () + set(_game_lib "${DUSK_GAME_IMPLIB}") + elseif (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") + if (NOT _game_lib MATCHES "\\.lib$") + message(FATAL_ERROR + "add_mod: DUSK_GAME_EXE must be an import library on Windows " + "(sdk/windows-.lib)") + endif () + else () + _mod_download_link_stub(_game_lib) + endif () + target_link_libraries(${target_name} PRIVATE "${_game_lib}") + endif () + endif () + endif () + if (ARG_RUNTIME_LIBRARIES AND NOT _has_lib) + message(FATAL_ERROR "add_mod: RUNTIME_LIBRARIES requires SOURCES") endif () set(_output_dir "${DUSK_MODS_OUTPUT_DIR}") @@ -137,18 +309,52 @@ function(add_mod target_name) set(_stage "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_stage") set(_out "${_output_dir}/${target_name}.dusk") - set(_zip_args "${_lib_name}" mod.json) + set(_zip_args mod.json) set(_package_deps "${_mod_json}") set(_package_inputs "${_mod_json}") set(_extra_cmds "") + set(_lib_copy_cmd "") + set(_lib_strip_cmd "") + set(_target_depend "") + if (_has_lib) + list(APPEND _zip_args lib) + set(_lib_copy_cmd + COMMAND ${CMAKE_COMMAND} -E make_directory "${_stage}/lib/${_lib_platform}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$" "${_stage}/lib/${_lib_platform}/${_lib_name}") + if (UNIX AND NOT APPLE) + set(_lib_strip_cmd COMMAND "${CMAKE_STRIP}" --strip-unneeded + "${_stage}/lib/${_lib_platform}/${_lib_name}") + endif () + set(_target_depend ${target_name}) + endif () + string(TOLOWER "${_lib_name}" _lib_name_key) + set(_runtime_lib_name_keys "${_lib_name_key}") + foreach (_runtime_lib IN LISTS ARG_RUNTIME_LIBRARIES) + _mod_resolve_source_path(_runtime_lib_path "${_runtime_lib}") + if (NOT EXISTS "${_runtime_lib_path}" OR IS_DIRECTORY "${_runtime_lib_path}") + message(FATAL_ERROR "add_mod: runtime library does not exist or is not a file: ${_runtime_lib_path}") + endif () + get_filename_component(_runtime_lib_name "${_runtime_lib_path}" NAME) + string(TOLOWER "${_runtime_lib_name}" _runtime_lib_name_key) + list(FIND _runtime_lib_name_keys "${_runtime_lib_name_key}" _runtime_lib_name_index) + if (NOT _runtime_lib_name_index EQUAL -1) + message(FATAL_ERROR "add_mod: duplicate runtime library filename: ${_runtime_lib_name}") + endif () + list(APPEND _runtime_lib_name_keys "${_runtime_lib_name_key}") + list(APPEND _package_deps "${_runtime_lib_path}") + list(APPEND _package_inputs "${_runtime_lib_path}") + list(APPEND _lib_copy_cmd COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${_runtime_lib_path}" "${_stage}/lib/${_lib_platform}/${_runtime_lib_name}") + endforeach () if (ARG_RES_DIR) _mod_resolve_source_path(_res_dir "${ARG_RES_DIR}") _mod_collect_assets(_res_deps "${_res_dir}") list(APPEND _package_deps ${_res_deps}) list(APPEND _package_inputs "${_res_dir}" ${_res_deps}) list(APPEND _zip_args res) - list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} -E copy_directory - "${_res_dir}" "${_stage}/res") + list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} "-DSRC=${_res_dir}" + "-DDST=${_stage}/res" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CopyModAssets.cmake") endif () if (ARG_OVERLAY_DIR) _mod_resolve_source_path(_overlay_dir "${ARG_OVERLAY_DIR}") @@ -156,8 +362,8 @@ function(add_mod target_name) list(APPEND _package_deps ${_overlay_deps}) list(APPEND _package_inputs "${_overlay_dir}" ${_overlay_deps}) list(APPEND _zip_args overlay) - list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} -E copy_directory - "${_overlay_dir}" "${_stage}/overlay") + list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} "-DSRC=${_overlay_dir}" + "-DDST=${_stage}/overlay" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CopyModAssets.cmake") endif () if (ARG_TEXTURES_DIR) _mod_resolve_source_path(_textures_dir "${ARG_TEXTURES_DIR}") @@ -165,8 +371,8 @@ function(add_mod target_name) list(APPEND _package_deps ${_textures_deps}) list(APPEND _package_inputs "${_textures_dir}" ${_textures_deps}) list(APPEND _zip_args textures) - list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} -E copy_directory - "${_textures_dir}" "${_stage}/textures") + list(APPEND _extra_cmds COMMAND ${CMAKE_COMMAND} "-DSRC=${_textures_dir}" + "-DDST=${_stage}/textures" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CopyModAssets.cmake") endif () set(_bundle_cmds "") @@ -177,6 +383,7 @@ function(add_mod target_name) set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_IDS "${_mod_id}") set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_STAGES "${_stage}") set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_PACKAGES "${_out}") + set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_LIB_PLATFORMS "${_lib_platform}") set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_LIB_NAMES "${_lib_name}") set(_bundle_cmds COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bundled_mods" @@ -194,12 +401,13 @@ function(add_mod target_name) add_custom_command(OUTPUT "${_out}" COMMAND ${CMAKE_COMMAND} -E rm -rf "${_stage}" COMMAND ${CMAKE_COMMAND} -E make_directory "${_stage}" "${_output_dir}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${_stage}/${_lib_name}" + ${_lib_copy_cmd} + ${_lib_strip_cmd} COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_mod_json}" "${_stage}/mod.json" ${_extra_cmds} COMMAND ${CMAKE_COMMAND} -E chdir "${_stage}" ${CMAKE_COMMAND} -E tar cvf "${_out}" --format=zip ${_zip_args} ${_bundle_cmds} - DEPENDS ${target_name} ${_package_deps} "${_package_inputs_file}" + DEPENDS ${_target_depend} ${_package_deps} "${_package_inputs_file}" COMMENT "Packaging ${target_name} -> ${_out}" COMMAND_EXPAND_LISTS VERBATIM @@ -215,9 +423,10 @@ endfunction() # user cache). # - Linux: pre-extracted stage dirs into /mods so native libs dlopen in place from # read-only installs. -# - macOS: pre-extracted stage dirs into the installed app's Contents/Resources/mods, dylibs -# ad-hoc signed in place, then the whole bundle re-signed. -# - iOS/tvOS: assets into /mods/ and the dylib into Frameworks/.dylib. +# - macOS: pre-extracted stage dirs into the installed app's Contents/Resources/mods, native +# libs ad-hoc signed in place, then the whole bundle re-signed. +# - iOS/tvOS: assets into /mods/, the mod library into Frameworks/.so, +# and runtime libraries alongside it. # - Android: nothing here; gradle packs ${CMAKE_BINARY_DIR}/bundled_mods into APK assets. function(install_bundled_mods) get_property(_targets GLOBAL PROPERTY DUSK_BUNDLED_MOD_TARGETS) @@ -226,6 +435,7 @@ function(install_bundled_mods) endif () get_property(_ids GLOBAL PROPERTY DUSK_BUNDLED_MOD_IDS) get_property(_stages GLOBAL PROPERTY DUSK_BUNDLED_MOD_STAGES) + get_property(_lib_platforms GLOBAL PROPERTY DUSK_BUNDLED_MOD_LIB_PLATFORMS) get_property(_lib_names GLOBAL PROPERTY DUSK_BUNDLED_MOD_LIB_NAMES) list(LENGTH _targets _count) math(EXPR _last "${_count} - 1") @@ -241,20 +451,67 @@ function(install_bundled_mods) list(GET _targets ${_i} _target) list(GET _ids ${_i} _id) list(GET _stages ${_i} _stage) + list(GET _lib_platforms ${_i} _lib_platform) list(GET _lib_names ${_i} _lib_name) install(DIRECTORY "${_stage}/" DESTINATION "${_bundle_dir}/mods/${_id}" - PATTERN "${_lib_name}" EXCLUDE) + PATTERN "lib" EXCLUDE) install(PROGRAMS "$" - DESTINATION "${_bundle_dir}/Frameworks" RENAME "${_id}.dylib") + DESTINATION "${_bundle_dir}/Frameworks" RENAME "${_id}.so") + install(DIRECTORY "${_stage}/lib/${_lib_platform}/" + DESTINATION "${_bundle_dir}/Frameworks" + PATTERN "${_lib_name}" EXCLUDE) endforeach () + if (DUSK_HAS_PREPATCH) + set(_prepatch_executable "${_bundle_dir}/Dusklight") + set(_prepatch_mod_args "") + foreach (_id IN LISTS _ids) + string(APPEND _prepatch_mod_args + " \"${_bundle_dir}/Frameworks/${_id}.so\"") + endforeach () + install(CODE " + execute_process( + COMMAND \"${SYMGEN_EXE}\" prepatch + --binary \"${_prepatch_executable}\" + --report \"${CMAKE_BINARY_DIR}/prepatch-report-$.json\" + ${_prepatch_mod_args} + COMMAND_ERROR_IS_FATAL ANY)") + endif () else () foreach (_i RANGE ${_last}) list(GET _ids ${_i} _id) list(GET _stages ${_i} _stage) + list(GET _lib_platforms ${_i} _lib_platform) list(GET _lib_names ${_i} _lib_name) install(DIRECTORY "${_stage}/" DESTINATION "${_bundle_dir}/Contents/Resources/mods/${_id}") - install(CODE "execute_process(COMMAND /usr/bin/codesign --force --sign - \"${_bundle_dir}/Contents/Resources/mods/${_id}/${_lib_name}\" COMMAND_ERROR_IS_FATAL ANY)") + install(CODE " + file(GLOB _mod_libs \"${_bundle_dir}/Contents/Resources/mods/${_id}/lib/${_lib_platform}/*\") + foreach (_mod_lib IN LISTS _mod_libs) + if (NOT IS_DIRECTORY \"\${_mod_lib}\") + execute_process(COMMAND /usr/bin/codesign --force --sign - \"\${_mod_lib}\" COMMAND_ERROR_IS_FATAL ANY) + endif () + endforeach ()") endforeach () + if (DUSK_HAS_PREPATCH) + set(_prepatch_executable "${_bundle_dir}/Contents/MacOS/Dusklight") + set(_prepatch_mod_args "") + foreach (_i RANGE ${_last}) + list(GET _ids ${_i} _id) + list(GET _lib_platforms ${_i} _lib_platform) + list(GET _lib_names ${_i} _lib_name) + string(APPEND _prepatch_mod_args + " \"${_bundle_dir}/Contents/Resources/mods/${_id}/lib/${_lib_platform}/${_lib_name}\"") + endforeach () + install(CODE " + execute_process( + COMMAND \"${SYMGEN_EXE}\" prepatch + --binary \"${_prepatch_executable}\" + --report \"${CMAKE_BINARY_DIR}/prepatch-report-$.json\" + ${_prepatch_mod_args} + COMMAND_ERROR_IS_FATAL ANY)") + endif () + if (TARGET crashpad_handler) + install(CODE "execute_process(COMMAND /usr/bin/codesign --force --sign - \"${_bundle_dir}/Contents/MacOS/$\" COMMAND_ERROR_IS_FATAL ANY)") + endif () install(CODE "execute_process(COMMAND /usr/bin/codesign --force --sign - --entitlements \"${DUSK_ENTITLEMENTS}\" \"${_bundle_dir}\" COMMAND_ERROR_IS_FATAL ANY)") endif () return () diff --git a/cmake/PatchFunchook.cmake b/cmake/PatchFunchook.cmake index 6d5a6e36b4..cbd91fc38e 100644 --- a/cmake/PatchFunchook.cmake +++ b/cmake/PatchFunchook.cmake @@ -2,59 +2,55 @@ file(READ "${SOURCE_DIR}/cmake/capstone.cmake.in" _content) # Insert PATCH_COMMAND before CONFIGURE_COMMAND in the ExternalProject_Add. # Bracket args prevent cmake from substituting ${...} while writing this file. -string(REPLACE - " CONFIGURE_COMMAND \"\"" - [=[ PATCH_COMMAND "${CMAKE_COMMAND}" -DDIR=${CMAKE_CURRENT_BINARY_DIR}/capstone-src -P "${CAPSTONE_FIX_SCRIPT}" +if (NOT _content MATCHES "CAPSTONE_FIX_SCRIPT") + string(REPLACE + " CONFIGURE_COMMAND \"\"" + [=[ PATCH_COMMAND "${CMAKE_COMMAND}" -DDIR=${CMAKE_CURRENT_BINARY_DIR}/capstone-src -P "${CAPSTONE_FIX_SCRIPT}" CONFIGURE_COMMAND ""]=] - _content "${_content}") - -file(WRITE "${SOURCE_DIR}/cmake/capstone.cmake.in" "${_content}") - -file(READ "${SOURCE_DIR}/src/funchook_unix.c" _unix_content) - -# macOS rejects the POSIX mprotect RWX/RW transition for executable image pages on arm64. -# Use Mach VM_PROT_COPY for the short patch window, then restore RX permissions. -if (NOT _unix_content MATCHES "VM_PROT_READ \\| VM_PROT_WRITE \\| VM_PROT_COPY") - string(REPLACE - [=[ rv = mprotect(mstate->addr, mstate->size, prot);]=] - [=[#ifdef __APPLE__ - kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)mstate->addr, - (vm_size_t)mstate->size, FALSE, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY); - if (kr == KERN_SUCCESS) { - funchook_log(funchook, " unprotect memory %p (size=%"PRIuPTR", prot=read,write,copy) <- %p (size=%"PRIuPTR")\n", - mstate->addr, mstate->size, start, len); - return 0; - } - funchook_set_error_message(funchook, "Failed to unprotect memory %p (size=%"PRIuPTR", prot=read,write,copy) <- %p (size=%"PRIuPTR", error=%s)", - mstate->addr, mstate->size, start, len, - mach_error_string(kr)); - return FUNCHOOK_ERROR_MEMORY_FUNCTION; -#endif - rv = mprotect(mstate->addr, mstate->size, prot);]=] - _unix_content "${_unix_content}") - - string(REPLACE - [=[ char errbuf[128]; - int rv = mprotect(mstate->addr, mstate->size, PROT_READ | PROT_EXEC);]=] - [=[ char errbuf[128]; -#ifdef __APPLE__ - kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)mstate->addr, - (vm_size_t)mstate->size, FALSE, - VM_PROT_READ | VM_PROT_EXECUTE); - - if (kr == KERN_SUCCESS) { - funchook_log(funchook, " protect memory %p (size=%"PRIuPTR", prot=read,exec)\n", - mstate->addr, mstate->size); - return 0; - } - funchook_set_error_message(funchook, "Failed to protect memory %p (size=%"PRIuPTR", prot=read,exec, error=%s)", - mstate->addr, mstate->size, - mach_error_string(kr)); - return FUNCHOOK_ERROR_MEMORY_FUNCTION; -#endif - int rv = mprotect(mstate->addr, mstate->size, PROT_READ | PROT_EXEC);]=] - _unix_content "${_unix_content}") + _content "${_content}") + file(WRITE "${SOURCE_DIR}/cmake/capstone.cmake.in" "${_content}") endif () -file(WRITE "${SOURCE_DIR}/src/funchook_unix.c" "${_unix_content}") +file(READ "${SOURCE_DIR}/src/funchook.c" _content) +if (NOT _content MATCHES "commit_code_patch") + string(REPLACE "#include \"funchook_internal.h\"" + "#include \"funchook_internal.h\"\n#ifdef __APPLE__\n#include \"code_patch_macos.hpp\"\n#endif" + _content "${_content}") + + foreach(_operation install uninstall) + if (_operation STREQUAL "install") + set(_expected old_code) + set(_replacement new_code) + else () + set(_expected new_code) + set(_replacement old_code) + endif () + set(_original " mem_state_t mstate; + int rv = funchook_unprotect_begin(funchook, &mstate, entry->target_func, JUMP32_BYTE_SIZE); + + if (rv != 0) { + return rv; + } + memcpy(entry->target_func, entry->${_replacement}, JUMP32_BYTE_SIZE); + rv = funchook_unprotect_end(funchook, &mstate); + if (rv != 0) { + return rv; + } + flush_instruction_cache(entry->target_func, JUMP32_BYTE_SIZE);") + string(FIND "${_content}" "${_original}" _position) + if (_position EQUAL -1) + message(FATAL_ERROR "Funchook ${_operation} patch site changed") + endif () + string(REPLACE "${_original}" "#ifdef __APPLE__ + int rv = commit_code_patch(entry->target_func, entry->${_expected}, + entry->${_replacement}, JUMP32_BYTE_SIZE); + if (rv != 0) { + funchook_set_error_message(funchook, \"Code patch commit failed (Mach error %d)\", rv); + return FUNCHOOK_ERROR_MEMORY_FUNCTION; + } +#else +${_original} +#endif" _content "${_content}") + endforeach () + file(WRITE "${SOURCE_DIR}/src/funchook.c" "${_content}") +endif () diff --git a/cmake/SymbolManifest.cmake b/cmake/SymbolManifest.cmake index ffaae9177e..7c7e09eaa1 100644 --- a/cmake/SymbolManifest.cmake +++ b/cmake/SymbolManifest.cmake @@ -2,40 +2,50 @@ include_guard(GLOBAL) get_filename_component(_SYMBOL_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(_SYMGEN_VERSION "1.1.0") +set(_SYMGEN_VERSION "1.3.4") set(_SYMGEN_RELEASE_BASE_URL "https://github.com/encounter/symgen/releases/download/v${_SYMGEN_VERSION}") set(SYMGEN_PATH "" CACHE FILEPATH "Path to a symgen executable; empty downloads the pinned release") mark_as_advanced(SYMGEN_PATH) -function(symgen_host_asset out_name) +function(symgen_host_asset out_name out_hash) string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" _host_processor) set(_asset "") + set(_asset_hash "") if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") if (_host_processor MATCHES "^(arm64|aarch64)$") set(_asset "symgen-macos-arm64") + set(_asset_hash "SHA256=983ef6278d30bee38f240f451ca736fd294da0e5705ee15029accac5c7a33829") elseif (_host_processor MATCHES "^(x86_64|amd64)$") set(_asset "symgen-macos-x86_64") + set(_asset_hash "SHA256=b6ab1720a4f04fadcf291f42d133e2ee68ef2e9a75d143e51584929e808af8a2") endif () elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") if (_host_processor MATCHES "^(aarch64|arm64)$") set(_asset "symgen-linux-aarch64") + set(_asset_hash "SHA256=ba84486ff1ceb753973e6213c9bc5f195b5ff6f220f5d3322fd861966cdc791c") elseif (_host_processor MATCHES "^(x86_64|amd64)$") set(_asset "symgen-linux-x86_64") + set(_asset_hash "SHA256=8b81a00a2ef8f5dd4b59adba1badfaca57e472bf272516bc12c4625cefb37718") elseif (_host_processor MATCHES "^(i[3-6]86|x86)$") set(_asset "symgen-linux-i686") + set(_asset_hash "SHA256=01aa85d84148a6806fdf69839dea7e962e6ac46956aed63b9ecb7d596f179f93") endif () elseif (CMAKE_HOST_WIN32) if (_host_processor MATCHES "^(arm64|aarch64)$") set(_asset "symgen-windows-arm64.exe") + set(_asset_hash "SHA256=e116099f859177d7e29fc3444d67083596330e5c4fb3a0461b21402c89249d96") elseif (_host_processor MATCHES "^(x86_64|amd64)$") set(_asset "symgen-windows-x86_64.exe") + set(_asset_hash "SHA256=57ef1c2f563e33fa4915c40194c4ced540f985c48d9cf081047c6bbcb585fa37") elseif (_host_processor MATCHES "^(i[3-6]86|x86)$") set(_asset "symgen-windows-x86.exe") + set(_asset_hash "SHA256=cc0ba337c798d3f63d8acbb2d16d531d0c2da878fbdd2b6307702334ec880528") endif () endif () set(${out_name} "${_asset}" PARENT_SCOPE) + set(${out_hash} "${_asset_hash}" PARENT_SCOPE) endfunction() function(ensure_symgen required) @@ -54,7 +64,7 @@ function(ensure_symgen required) return() endif () else () - symgen_host_asset(_asset) + symgen_host_asset(_asset _asset_hash) if (_asset STREQUAL "") if (required) message(FATAL_ERROR "symgen: no prebuilt binary for host " @@ -75,7 +85,8 @@ function(ensure_symgen required) file(DOWNLOAD "${_url}" "${_symgen}" TLS_VERIFY ON STATUS _download_status - SHOW_PROGRESS) + SHOW_PROGRESS + EXPECTED_HASH "${_asset_hash}") list(GET _download_status 0 _download_code) if (NOT _download_code EQUAL 0) list(GET _download_status 1 _download_message) @@ -106,20 +117,37 @@ function(setup_symbol_manifest target) endif () add_dependencies(${target} symgen) - if (WIN32) - set(_input --pdb "$") - set(_out "$/dusklight.symdb") - else () - set(_input --binary "$") - if (APPLE) - set(_out "$/Resources/dusklight.symdb") - else () - set(_out "$/dusklight.symdb") + # Reserve an ELF program-header entry when the linker supports it (mold). + # symgen can replace the PT_NULL entry without relocating the table, keeping later post-link tools safe. + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + include(CheckLinkerFlag) + check_linker_flag(CXX "LINKER:--spare-program-headers=1" _linker_supports_spare_program_headers) + if (_linker_supports_spare_program_headers) + target_link_options(${target} PRIVATE "LINKER:--spare-program-headers=1") endif () endif () + if (WIN32) + set(_input --pdb "$") + else () + set(_input --binary "$") + endif () + + if (APPLE) + # Room for the symbol manifest and several prepatch arenas. + target_link_options(${target} PRIVATE "LINKER:-headerpad,0x1000") + # ld64 may update an existing output, which breaks our symdb insertion. Remove it first. + add_custom_command(TARGET ${target} PRE_LINK + COMMAND "${CMAKE_COMMAND}" -E rm -f "$" + VERBATIM) + endif () + + # The manifest is embedded into the image as a new section, located at runtime through + # the descriptor manifest.cpp reserves. On Apple platforms this command must stay + # attached before the ad-hoc codesign POST_BUILD command: the patch removes any existing + # signature. add_custom_command(TARGET ${target} POST_BUILD - COMMAND "${SYMGEN_EXE}" manifest ${_input} --out "${_out}" - COMMENT "Generating symbol manifest" + COMMAND "${SYMGEN_EXE}" manifest ${_input} --embed "$" + COMMENT "Embedding symbol manifest" VERBATIM) endfunction() diff --git a/cmake/WindowsExports.cmake b/cmake/WindowsExports.cmake index 86dc9414f2..dae7f067c0 100644 --- a/cmake/WindowsExports.cmake +++ b/cmake/WindowsExports.cmake @@ -6,9 +6,16 @@ get_filename_component(_DUSK_WINDOWS_EXPORTS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FIL # import library mods link against. symgen scans the built objects, filters by source, and # writes a .def used by the main link and import library generation. function(setup_windows_exports target) - if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8) - message(WARNING "dusklight: Windows code-mod exports are x64-only for now; skipping") - return() + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _implib_arch) + if (_implib_arch STREQUAL "arm64") + set(_dlltool_machine "arm64") + set(_lib_machine "arm64") + elseif (_implib_arch MATCHES "^(amd64|x86_64)$") + set(_dlltool_machine "i386:x86-64") + set(_lib_machine "x64") + else () + message(FATAL_ERROR + "dusklight: no Windows mod linking support for ${CMAKE_SYSTEM_PROCESSOR}") endif () include("${_DUSK_WINDOWS_EXPORTS_CMAKE_DIR}/SymbolManifest.cmake") @@ -37,19 +44,27 @@ function(setup_windows_exports target) endif () endforeach () + set(_forward_args) + if (TARGET dawn::webgpu_dawn) + get_target_property(_dawn_type dawn::webgpu_dawn TYPE) + if (_dawn_type STREQUAL "SHARED_LIBRARY") + list(APPEND _forward_args + --forward-dll "$" + --forward-sym-prefix wgpu) + endif () + endif () + # Generate curated exports list from the main binary set(_def "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_exports.def") add_custom_command(TARGET ${target} PRE_LINK - # TODO: src/dusk/ is NOT excluded: inline code in game headers - # currently call into it (e.g. dusk::frame_interp::lookup_replacement). COMMAND "${_symgen}" def - --rsp "${_rsp}" + "@${_rsp}" --out "${_def}" --exclude cmake_pch --exclude miniz - --exclude asan_options --max-exports 58000 ${_sdk_args} + ${_forward_args} COMMENT "Generating dusklight exports" VERBATIM) target_link_options(${target} PRIVATE "/DEF:${_def}") @@ -59,11 +74,11 @@ function(setup_windows_exports target) get_filename_component(_compiler_dir "${CMAKE_CXX_COMPILER}" DIRECTORY) find_program(DUSK_LLVM_DLLTOOL llvm-dlltool HINTS "${_compiler_dir}") if (DUSK_LLVM_DLLTOOL) - set(_implib_cmd "${DUSK_LLVM_DLLTOOL}" -d "${_def}" -D dusklight.exe -m i386:x86-64 - -l "${_implib}") + set(_implib_cmd "${DUSK_LLVM_DLLTOOL}" -d "${_def}" -D dusklight.exe + -m "${_dlltool_machine}" -l "${_implib}") else () - set(_implib_cmd "${CMAKE_AR}" /nologo "/def:${_def}" /machine:x64 /name:dusklight.exe - "/out:${_implib}") + set(_implib_cmd "${CMAKE_AR}" /nologo "/def:${_def}" "/machine:${_lib_machine}" + /name:dusklight.exe "/out:${_implib}") endif () add_custom_command(TARGET ${target} POST_BUILD COMMAND ${_implib_cmd} @@ -71,9 +86,6 @@ function(setup_windows_exports target) COMMENT "Generating dusklight import library" VERBATIM) set(DUSK_GAME_IMPLIB "${_implib}" CACHE INTERNAL "Import library for Windows mod linking") - set(DUSK_GAME_DEF "${_def}" CACHE INTERNAL "Curated export .def for the game executable") - # Ship the import library as sdk/dusklight.lib in the install tree: mods may use it to - # compile against Dusklight without having to build the whole game. (See DUSK_GAME_IMPLIB) - install(FILES "${_implib}" DESTINATION sdk RENAME dusklight.lib) + install(FILES "${_implib}" DESTINATION sdk RENAME "windows-${_implib_arch}.lib") endfunction() diff --git a/docs/ios-install-altstore.md b/docs/ios-install-altstore.md index 5c0f071878..0c2e9e36a6 100644 --- a/docs/ios-install-altstore.md +++ b/docs/ios-install-altstore.md @@ -5,7 +5,13 @@ - A Windows, Linux, or macOS device - iOS device connected to computer via USB - Dusklight IPA file (download the latest `Dusklight-vX.X.X-ios-arm64.ipa` from the [releases page](https://github.com/TwilitRealm/dusklight/releases)) -- Legally acquired game disc - `GZ2E01` (Gamecube USA) or `GZ2PE01` (Gamecube PAL) +- Legally acquired game disc: + - `GZ2E01` (GameCube USA) + - `GZ2P01` (GameCube PAL) + - `GZ2J01` (GameCube JPN) + - `RZDE01` (Wii USA Rev. 0 *or* Rev. 2) + - `RZDP01` (Wii PAL) + - `RZDJ01` (Wii JPN) ## 1. Install iloader diff --git a/docs/modding.md b/docs/modding.md index 7b616989e8..7d7fa142a0 100644 --- a/docs/modding.md +++ b/docs/modding.md @@ -1,79 +1,36 @@ # Dusklight Mod API -Mods are `.dusk` bundles: zip archives that can contain code (in the form of native libraries), resources, DVD overlay +Mods are `.dusk` bundles: zip archives that can contain code (native libraries or scripts), resources, DVD overlay files, and texture replacements. Mods may be enabled, disabled and reloaded at runtime. -When code mods are loaded, they get dynamically linked by the operating system to the running game process. The mod -exports lifecycle functions that Dusklight calls into (`mod_initialize`, `mod_update`, `mod_shutdown`), and the mod -communicates with the host via **services**: plain C APIs, individually versioned. Dusklight exports several built-in -services, and mods may export services of their own, permitting framework mods and cross-mod integration. +There are three types of mods: -Beyond services, mods have full access to the original game's code: include game headers, call directly into any public -function, read and write data fields, and hook the vast majority of game functions. +- **Asset-only mods**: Mods that contain no code, and may replace files on the game disc ("overlays") and provide + replacement textures (texture packs). +- **Native mods (C++)**: Fully-featured, with the ability to interop with game code and hook functions. Must be compiled + for every supported platform. (See [mod-template](https://github.com/TwilitRealm/mod-template)) +- **Script mods (Luau)**: Simple, widely-compatible, but can only access provided services. ## Table of Contents -1. [Getting Started](#getting-started) -2. [mod.json](#modjson) -3. [Anatomy of a Code Mod](#anatomy-of-a-code-mod) -4. [Services](#services) -5. [Built-in Services](#built-in-services) -6. [Hooking Game Functions](#hooking-game-functions) -7. [Asset Overlays](#asset-overlays) -8. [Runtime Lifecycle](#runtime-lifecycle) -9. [Error Handling](#error-handling) -10. [Advanced: Exporting Services](#advanced-exporting-services) - ---- - -## Getting Started - -Fork the [mod template](../tools/mod_template/), a self-contained CMake project that uses the Dusklight mod SDK. - -``` -my_mod/ -├── CMakeLists.txt -├── mod.json -├── src/mod.cpp -├── res/ (optional bundled resources) -├── overlay/ (optional game file overrides) -└── textures/ (optional texture replacements) -``` - -**CMakeLists.txt:** - -```cmake -cmake_minimum_required(VERSION 3.25) -project(my_mod CXX) - -set(DUSKLIGHT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dusklight" CACHE PATH "Path to dusklight source root") -add_subdirectory("${DUSKLIGHT_DIR}/sdk" dusklight-sdk EXCLUDE_FROM_ALL) - -add_mod(my_mod - SOURCES src/mod.cpp - MOD_JSON mod.json - RES_DIR res # optional - OVERLAY_DIR overlay # optional - TEXTURES_DIR textures # optional -) -``` - -Building produces `my_mod.dusk` in `build//mods/` (configurable via the `DUSK_MODS_OUTPUT_DIR` cache variable). -Dusklight searches a `mods/` directory next to the app in addition to the user directory, so a dev build launched from -`build//` picks these up automatically: rebuild, relaunch (or click Reload), done. - -For a regular game install, copy the `.dusk` into the user mods folder: - -- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` -- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` -- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` - -Passing `--mods ` on the command line replaces the user directory with one of your choosing. +1. [mod.json](#modjson) +2. [Asset-only Mods](#asset-only-mods) +3. [Native Mods (C++)](#native-mods) +4. [Script Mods (Luau)](#script-mods) +5. [Services](#services) +6. [Built-in Services](#built-in-services) +7. [Hooking Game Functions](#hooking-game-functions) +8. [Asset Overlays](#asset-overlays) +9. [Runtime Lifecycle](#runtime-lifecycle) +10. [Error Handling](#error-handling) +11. [Advanced](#advanced) --- ## mod.json +Every mod starts with a single file, a `mod.json`: + ```json { "id": "com.example.my_mod", @@ -81,20 +38,60 @@ Passing `--mods ` on the command line replaces the user directory with one "version": "1.0.0", "author": "Your Name", "description": "A short description shown in the mod manager.", - "icon": "res/my_icon.png", - "banner": "res/my_banner.png" + "icon": "res/icon.png", + "banner": "res/banner.png" } ``` -`id` is required: a unique, stable identifier (reverse-DNS style; periods, underscores, and alphanumerics). Everything -else is optional but recommended. +`id` is required: a unique, stable identifier (reverse-DNS style; periods, underscores, and lowercase alphanumerics). +Everything else is optional but recommended. -`icon` and `banner` are bundle-relative paths to PNG images for the in-game mod manager: the square icon (e.g. -512x512), the banner (~3.5:1). If omitted, `res/icon.png` and `res/banner.png` are used automatically when present. +`icon` and `banner` are bundle paths to PNG images that display in the in-game mod manager and mod website. A square +icon (1:1), and a banner (~3.5:1, minimum 800px width). If omitted, `res/icon.png` and `res/banner.png` are used +automatically when present. + +Simply create a zip file with a `mod.json`, and rename it to `.dusk`. That's it! --- -## Anatomy of a Code Mod +## Asset-only Mods + +``` +my_mod.dusk +├── mod.json +├── res/ (optional bundled resources) +├── overlay/ (optional game file overrides) +└── textures/ (optional texture replacements) +``` + +Place files in `overlay/` to replace the disc version of that file. Examples: + +- `overlay/Movie/demo_movie98_00.thp`: Replaces `Movie/demo_movie98_00.thp` on disc. +- `overlay/res/Object/Kmdl/archive/bmwr/al.bmd`: Replaces `archive/bmwr/al.bmd` _within_ `res/Object/Kmdl.arc` without + overwriting the entire `.arc`. + +Place textures in `textures/` to automatically register them as texture replacements when active. These follow the same +[Dolphin-compatible naming scheme](#textureservice-modssvctextureh) as the user `/texture_replacements/` +directory. Directories are scanned recursively. Examples: + +- `textures/tex1_256x128_e6a4c7be9bf48305_14.dds`: Replaces the Hero's Clothes texture. + +Simply zip the `mod.json` and adjacent folders, then rename to `.dusk`. Then, copy the `.dusk` into the user mods +folder: + +- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` +- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` +- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` + +--- + +## Native Mods + +Mods built with [mod-template](https://github.com/TwilitRealm/mod-template) are native C++ mods. Native mods are very +powerful and can interact with and [hook](#hooking-game-functions) game code directly. All features are available to +native mods. + +Example C++ mod: ```cpp #include "mods/service.hpp" @@ -117,46 +114,200 @@ MOD_EXPORT ModResult mod_update(ModError* error) { // called every frame MOD_EXPORT ModResult mod_shutdown(ModError* error) { return MOD_OK; } + } ``` -All three lifecycle exports are required. `mod_ctx` is your mod's identity token, set by the loader before -`mod_initialize` runs. Pass it as the first argument to every service call. +When native mods are loaded, they get dynamically linked by the operating system to the running game process. The mod +exports lifecycle functions that Dusklight calls into (`mod_initialize`, `mod_update`, `mod_shutdown`), and the mod +communicates with the host via **services**: plain C APIs, individually versioned. Dusklight exports several built-in +services, and mods may export services of their own, permitting framework mods and cross-mod integration. + +Beyond services, native mods have full access to the original game's code: include game headers, call directly into any +public function, read and write data fields, and hook the vast majority of game functions. + +### Quick Start (Native Mods) + +Create a repository from +the [mod-template](https://github.com/new?template_name=mod-template&template_owner=TwilitRealm), +a self-contained CMake project that uses the Dusklight mod SDK. It includes a GitHub Actions CI workflow that builds the +mod for every supported platform. + +``` +my_mod/ +├── CMakeLists.txt +├── mod.json +├── src/mod.cpp +├── res/ (optional bundled resources) +├── overlay/ (optional game file overrides) +└── textures/ (optional texture replacements) +``` + +**CMakeLists.txt:** + +```cmake +cmake_minimum_required(VERSION 3.26) +project(my_mod CXX) + +if (NOT DUSKLIGHT_VERSION) + set(DUSKLIGHT_VERSION "76b56cd8b81809fce0a5c2a44e2f6d437591132f") +endif () +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchDusklight.cmake") +add_subdirectory("${DUSKLIGHT_DIR}/sdk" dusklight-sdk EXCLUDE_FROM_ALL) + +add_mod(my_mod + FEATURES game fmt # remove game for service-only mods; add webgpu for GfxService + SOURCES src/mod.cpp + MOD_JSON mod.json + RES_DIR res # mod resources, including icon.png and banner.png + OVERLAY_DIR overlay # game file overlays; remove if unused + TEXTURES_DIR textures # texture replacements; remove if unused +) +``` + +Available features: + +- `fmt`: Provides the header-only `{fmt}` library and the formatted logging helpers in + [`mods/svc/log.hpp`](../sdk/include/mods/svc/log.hpp). +- `game`: Allows calling into and hooking game code. Mods that **only** use services may omit it, providing a wider + range of compatibility with Dusklight versions and a slightly faster build process. +- `webgpu`: Allows importing the WebGPU API + ([`webgpu/webgpu.h`](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)). Must be enabled when using + [GfxService](#gfxservice-modssvcgfxh). + +Building produces `my_mod.dusk` in `build/mods/`. Copy the `.dusk` into the user mods folder: + +- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` +- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` +- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` + +Passing `--mods ` on the command line replaces the user directory with one of your choosing. + +--- + +## Script Mods + +For simpler use cases where direct game code access and hooks aren't necessary, Luau mods are also supported. +Luau mods do not need to be compiled, and are always supported on all platforms. However, they can only use services +that are provided as Luau modules. + +Mods can utilize Luau to add UI elements to their mod panel, use configuration variables, and dynamically swap out +models/textures at runtime (e.g. to switch model variants or disable certain replacements) while remaining widely +compatible. + +Example mod structure: + +``` +my_luau_mod.dusk +├── mod.json +└── res/ + ├── main.luau + └── lib/util.luau +``` + +Set the `runtime` to `dev.twilitrealm.luau@1.0` in `mod.json`: + +```json +{ + "id": "com.example.my_luau_mod", + "name": "My Script Mod", + "version": "1.0.0", + "runtime": "dev.twilitrealm.luau@1.0" +} +``` + +`res/main.luau` runs once when the mod activates. Register optional update and shutdown callbacks through +`dusklight.host`: + +```lua +local host = require("dusklight.host") +host.on_update(function() + -- Runs every frame +end) +host.on_shutdown(function() + -- Runs on mod deactivation +end) +``` + +Require script modules with `./` or `../` paths relative to the requiring file. The runtime appends `.luau` and rejects +paths that escape `res/`. + +The runtime provides these modules: + +- `dusklight.log`: `write`, `trace`, `debug`, `info`, `warn`, and `error`. +- `dusklight.host`: host `version`, mod metadata and directories, lifecycle callbacks, and `fail`. +- `dusklight.config`: bool, integer, float, and string variables with `get`, `set`, and subscriptions. +- `dusklight.resource`: binary-safe reads from the mod's `res/` tree. +- `dusklight.overlay`: file and copied-buffer overlays with removable handles. +- `dusklight.texture`: encoded-file and raw-data replacements with unregisterable handles. +- `dusklight.ui`: Mods panels, controls, lists, windows, dialogs, styles, menu tabs, toasts, and clipboard access. + +For completion and type checking, add `sdk/luau/dusklight.d.luau` to the `luau-lsp.types.definitionFiles` setting. + +Configurable overlay example: + +```lua +local config = require("dusklight.config") +local overlay = require("dusklight.overlay") + +local hood = config.register({ name = "hood", type = "bool", default = true }) +local current + +local function apply(enabled) + if current then current:remove() end + current = overlay.add_file("/res/Object/Alink.arc", + enabled and "res/alink_hood.arc" or "res/alink_nohood.arc") +end + +hood:subscribe(apply) +apply(hood:get()) +``` + +To create a script mod, copy `sdk/luau/template`, edit its manifest and source, then zip the `mod.json` and adjacent +folders and rename to `.dusk`. Copy the `.dusk` into the user mods folder: + +- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` +- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` +- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` + +**Restrictions:** The Luau VM has no raw filesystem, network, or game-code access. Each script mod has a 64 MiB memory +limit. Calls are interrupted after 250 ms for updates and UI callbacks or 5 seconds for lifecycle calls. An uncaught +error, timeout, or memory exhaustion fails and disables the mod. --- ## Services -A service is a struct of C function pointers with a version header. You declare what you use at file scope, and the -loader resolves it before your mod initializes: +A service is a struct of C function pointers with a version header. Import services at file scope, and the loader +resolves them before initializing the mod: ```cpp -IMPORT_SERVICE(LogService, svc_log); // required, any minor version -IMPORT_SERVICE_VERSION(LogService, svc_log, 2); // required, minor version >= 2 +IMPORT_SERVICE(LogService, svc_log); // required, latest minor version +IMPORT_SERVICE_VERSION(LogService, svc_log, 0); // required, minimum minor version 0 (for backwards compatibility) IMPORT_OPTIONAL_SERVICE(SomeService, svc_maybe); // may be null ``` +A service should be imported in only **one** file (usually your `mod.cpp`). Other files may simply use `svc_log` or +`mods::log::` after including the appropriate header. + Each service is individually versioned, and there may be multiple major versions of a service provided at once, allowing backwards compatibility with older mods while still changing services fundamentally if necessary. A **major** bump is a breaking change, treated as a different service entirely. For **additive** changes, a service appends new -functions to the end of the struct without breaking existing callers and simply bumps the minor version. Mods that -want the newer functions may use `IMPORT_SERVICE_VERSION` to require that minor at **load time**, or `SERVICE_HAS` to -check at **runtime** whether a specific function is available. +functions to the end of the struct without breaking existing callers and simply bumps the minor version. -The contract (see `include/mods/api.h` for the full version): - -- **A required import is guaranteed valid.** If the service is missing or too old, the mod fails to load with a clear - error. No need to null check at call sites. -- **Anything at or below the minor version you imported can be called unconditionally.** -- Optional imports may be null; check once in `mod_initialize`. -- Fields newer than your imported minor must be gated behind `SERVICE_HAS(service, ServiceType, field)` plus a null - check. +`IMPORT_SERVICE` and `IMPORT_OPTIONAL_SERVICE` require the latest minor version compiled against, guaranteeing that +every function is present. If a mod doesn't use (or may operate without) functions added in later minor versions, and +wants to remain compatible with older Dusklight versions, it may use `IMPORT_SERVICE_VERSION` or +`IMPORT_OPTIONAL_SERVICE_VERSION` to require an older minor version. It can then check `SERVICE_HAS` at runtime to see +if a newer function is present (i.e. running on a new enough Dusklight version). --- ## Built-in Services -### LogService (`mods/svc/log.h`) +### LogService ([`mods/svc/log.h`](../sdk/include/mods/svc/log.h)) + +**C++** ```cpp IMPORT_SERVICE(LogService, svc_log); @@ -167,14 +318,31 @@ svc_log->error(mod_ctx, "very bad"); svc_log->write(mod_ctx, LOG_LEVEL_DEBUG, "verbose details"); ``` -Messages appear in the console prefixed with your mod ID. Messages are plain UTF-8 strings and are copied before the -call returns; use `snprintf` or `fmt::format` for formatting. +**Luau** -### ResourceService (`mods/svc/resource.h`) +```lua +local log = require("dusklight.log") +log.info("spawned the thing") +``` + +Messages appear in the console prefixed with your mod ID. Messages are plain UTF-8 strings and are copied before the +call returns. C++ mods can enable `add_mod(... FEATURES fmt)` and use the formatted logging helpers in +[`mods/svc/log.hpp`](../sdk/include/mods/svc/log.hpp): + +```cpp +#include + +mods::log::info("spawned actor {} at ({}, {})", actorName, x, y); +mods::log::warn("health is down to {:.1f}%", healthPercent); +``` + +### ResourceService ([`mods/svc/resource.h`](../sdk/include/mods/svc/resource.h)) Loads files from the `res/` tree of your `.dusk` archive. Paths are relative to `res/` (pass `"config.txt"`, not `"res/config.txt"`); absolute paths and `..` are rejected. +**C++** + ```cpp IMPORT_SERVICE(ResourceService, svc_resource); @@ -185,28 +353,223 @@ if (svc_resource->load(mod_ctx, "config.txt", &buf) == MOD_OK) { } ``` -Missing files return `MOD_UNAVAILABLE`. Always `free` what you `load`. Note that the bundle is read-only; for writable -storage, use the directory from `svc_host->mod_dir(mod_ctx)`. +**Luau** -### HostService (`mods/svc/host.h`) +```lua +local resource = require("dusklight.resource") +local contents = resource.load("config.txt") +``` -Mod metadata and runtime interaction with the loader: +Missing files return `MOD_UNAVAILABLE`. Always `free` what you `load`. The bundle is read-only; use +`HostService::data_dir` for persistent storage. + +### FileService ([`mods/svc/file.h`](../sdk/include/mods/svc/file.h)) + +Provides file and folder pickers, file I/O, exports and folder enumeration. + +A location is an opaque UTF-8 string returned by `pick_*`, `export_file`, `join`, or `create_child`. +Save it and pass it back to the service. Never parse it or manually append path segments. + +```cpp +#include "mods/svc/file.hpp" + +IMPORT_SERVICE(FileService, svc_file); + +mods::file::PickOptions options; +options.filters.push_back({"Audio", "wav;ogg"}); +mods::file::pick_file(options, [](mods::file::PickResult result) { + if (result.status == MOD_OK && !result.locations.empty()) { + save_location(result.locations.front()); + } +}); +``` + +Use `check` before reopening a saved location because removable storage or an access grant may no longer be available. +`open` provides seekable streaming I/O. `read_all` allocates the entire file and should only be used when the file is +small. Folder locations support `list` and child resolution through `join`. Only one picker can be open at a time. + +`create_child` never replaces an existing file and returns `MOD_CONFLICT` if one exists. Use the returned location; +document providers may adjust the requested name. `write_all` is a convenience function over +`open`/`write`/`flush`/`close`. + +```cpp +std::string location; +if (mods::file::create_child(folder, "report.txt", location) == MOD_OK) { + mods::file::write_all(location, report); +} + +mods::file::export_file(location, "report.txt", [](mods::file::PickResult result) { + if (result.status == MOD_OK) { + remember_export_destination(result.locations.front()); + } +}); +``` + +`export_file` copies an existing file to a user-selected destination and returns the destination location in its +callback. Mod-owned persistent files belong in `HostService::data_dir`. + +### HttpService ([`mods/svc/http.h`](../sdk/include/mods/svc/http.h)) + +Asynchronous HTTPS requests supporting HTTP/2 and TLS 1.2+. C++ mods should use the helpers in +[`mods/svc/http.hpp`](../sdk/include/mods/svc/http.hpp): + +```cpp +#include "mods/svc/http.hpp" + +IMPORT_SERVICE(HttpService, svc_http); + +mods::http::Pending pendingRequest; + +void fetch_manifest() { + mods::http::Request request{ + .url = "https://example.com/manifest.json", + .maxBodyBytes = 256 * 1024, + }; + pendingRequest = mods::http::request(request, [](mods::http::Response response) { + if (!response.ok()) { + handle_fetch_error(response.error, response.statusCode); + return; + } + + std::string manifest{response.body.begin(), response.body.end()}; + use_manifest(manifest); + }); + if (!pendingRequest) { + handle_start_error(pendingRequest.result()); + } +} +``` + +Keep the returned `Pending` alive until completion. Dropping it or calling `cancel` requests cancellation. Callbacks run +on the game thread. + +`Response::ok()` requires a 2xx status. Other HTTP statuses are valid responses, not transport errors, so always check +`statusCode`. In-memory responses default to a 1 MiB limit; set `maxBodyBytes` to increase it if needed. + +For large responses, set `downloadPath` to an absolute path in the calling mod's `HostService::data_dir` or +`HostService::mod_dir`. The response is streamed to disk instead of loaded in memory. On success, the callback receives +an empty `body` and the final path in `downloadPath`. Check `Response::ok()` before using the file. +`Pending::progress()` reports download progress when the server provides a total size. + +### WebSocketService ([`mods/svc/websocket.h`](../sdk/include/mods/svc/websocket.h)) + +WebSocket client connections with text or binary messages. Secure `wss://` URLs are supported everywhere. Insecure +`ws://` is limited to `localhost`, `127.0.0.1`, and `[::1]`. + +```cpp +#include "mods/svc/websocket.hpp" + +IMPORT_SERVICE(WebSocketService, svc_websocket); + +mods::ws::Connection connection; + +MOD_EXPORT ModResult mod_initialize(ModError*) { + connection = mods::ws::connect({.url = "wss://example.com/events"}); + return connection ? MOD_OK : connection.result(); +} + +MOD_EXPORT ModResult mod_update(ModError*) { + mods::ws::Event event; + while (mods::ws::poll(event)) { + if (event.type == WEBSOCKET_EVENT_MESSAGE) { + consume(event.data); + } else if (event.type == WEBSOCKET_EVENT_CLOSED) { + schedule_reconnect(event.error); + } + } + return MOD_OK; +} +``` + +Keep the `Connection` alive and drain `mods::ws::poll()` regularly, usually on every `mod_update` tick. A connection +emits an (optional) `OPEN` event, zero to many `MESSAGE` events, and exactly one `CLOSED` event. + +**Restrictions:** A mod may only open four connections at once. Messages have a 1 MiB limit by default, and may request +up to 16 MiB. Unread data is limited to 16 MiB and the outbound queue to 4 MiB. `send` returns `MOD_CONFLICT` when the +outbound queue is full. Dropping the `Connection` or deactivating the mod attempts to gracefully close with code 1001, +until the close deadline expires. + +### NetService ([`mods/svc/net.h`](../sdk/include/mods/svc/net.h)) + +Asynchronous raw TCP and UDP networking. Endpoints can be `tcp://host:port` or `udp://host:port`. TCP connections and +`resolve` accept hostnames. Listeners and UDP endpoints require IP literals. + +```cpp +#include "mods/svc/net.hpp" + +IMPORT_SERVICE(NetService, svc_net); + +mods::net::BindOutcome bound; +mods::net::Socket listener; +mods::net::Socket client; + +MOD_EXPORT ModResult mod_initialize(ModError*) { + listener = mods::net::listen("tcp://127.0.0.1:0", &bound); + client = mods::net::connect(bound.local); + return listener && client ? MOD_OK : MOD_ERROR; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + mods::net::Event event; + while (mods::net::poll(event)) { + if (event.type == NET_EVENT_ACCEPTED) { + remember_client(mods::net::adopt(event.accepted)); + } else if (event.type == NET_EVENT_STREAM_DATA) { + consume(event.data); + } + } + return MOD_OK; +} +``` + +`send` and `send_to` copy the payload and return `MOD_CONFLICT` when the socket's outbound queue is full. `stats` +reports queued bytes, traffic, dropped inbound datagrams, and asynchronous UDP send failures. + +**Restrictions:** A mod may only have 32 streams, 4 listeners, 4 UDP sockets, and 8 DNS resolutions active at once. + +### HostService ([`mods/svc/host.h`](../sdk/include/mods/svc/host.h)) + +Mod metadata and runtime interaction with the loader. + +**C++** ```cpp IMPORT_SERVICE(HostService, svc_host); -const char* id = svc_host->mod_id(mod_ctx); -const char* dir = svc_host->mod_dir(mod_ctx); // writable per-mod directory -svc_host->fail(mod_ctx, MOD_ERROR, "something unrecoverable happened"); // disables the mod +// Temporary mod data directory, wiped on startup +const char* cacheDir = svc_host->mod_dir(mod_ctx); + +// Persistent mod data directory +const char* dataDir = nullptr; +if (svc_host->data_dir(mod_ctx, &dataDir) == MOD_OK) { + // ... +} + +// Report an error and disable the mod +svc_host->fail(mod_ctx, MOD_ERROR, "something unrecoverable happened"); ``` -`get_service`/`publish_service` provide dynamic service lookup; see [Advanced](#advanced-exporting-services). +**Luau** + +```lua +local host = require("dusklight.host") +local dataDir = host.data_dir() +host.on_update(function() + -- Runs every frame +end) +host.on_shutdown(function() + -- Runs on mod deactivation +end) +host.fail("something unrecoverable happened") +``` + +`get_service`/`publish_service` provide dynamic service lookup; see [Exporting Services](#exporting-services). **Lifecycle watches.** If your mod provides a service that hands out per-caller state (registrations, callbacks, handles), watch other mods' lifecycle and drop what you hold for a mod when it detaches. ```cpp -IMPORT_SERVICE_VERSION(HostService, svc_host, 1); +IMPORT_SERVICE(HostService, svc_host); void on_mod_lifecycle(ModContext* ctx, ModContext* subject, const char* subject_id, ModLifecycleEvent event, void* user_data) { @@ -222,37 +585,54 @@ svc_host->watch_mod_lifecycle(mod_ctx, on_mod_lifecycle, nullptr, &watch); `MOD_LIFECYCLE_DETACHED` fires on the game thread at a lifecycle safe point, after the subject's `mod_shutdown` ran and every service dropped its state. For your own mod's teardown, use `mod_shutdown` instead. -### HookService (`mods/svc/hook.h`) +### HookService ([`mods/svc/hook.h`](../sdk/include/mods/svc/hook.h)) Installs hooks on game functions and resolves symbols by name. You'll rarely call it directly; use the typed helpers in -`mods/hook.hpp` described in [Hooking Game Functions](#hooking-game-functions). +[`mods/svc/hook.hpp`](../sdk/include/mods/svc/hook.hpp) described in +[Hooking Game Functions](#hooking-game-functions). -### OverlayService (`mods/svc/overlay.h`) +### OverlayService ([`mods/svc/overlay.h`](../sdk/include/mods/svc/overlay.h)) Registers DVD file overlays at runtime: the dynamic counterpart to the static `overlay/` directory (see -[Asset Overlays](#asset-overlays)). Overlay a disc path with a file from your bundle, or with a caller-owned buffer -(copied on registration): +[Asset Overlays](#asset-overlays)). Overlay a disc path with a file from your bundle, a file within an archive, +or with a caller-owned buffer (copied on registration). + +**C++** ```cpp IMPORT_SERVICE(OverlayService, svc_overlay); OverlayHandle handle = 0; -svc_overlay->add_file(mod_ctx, "/res/Msgus.arc", "res/replacement.arc", &handle); +svc_overlay->add_file(mod_ctx, "/Movie/demo_movie98_00.thp", "res/replacement.thp", &handle); // Replaces the demo movie +svc_overlay->add_file(mod_ctx, "/res/Object/Kmdl/archive/bmwr/al.bmd", "res/link_model.bmd", &handle); // Replaces link's model svc_overlay->add_buffer(mod_ctx, "/generated.txt", data, size, nullptr); svc_overlay->remove(mod_ctx, handle); ``` +**Luau** + +```lua +local overlay = require("dusklight.overlay") +local replacement = overlay.add_file("/Movie/demo_movie98_00.thp", "res/replacement.thp") +replacement:remove() +``` + `disc_path` must be absolute (leading `/`) and is matched against the disc case-insensitively. Paths that don't exist on the disc are added as new files. Changes are applied at the next frame boundary, and data the game already read stays in memory until the file is re-read: sometimes a scene reload, and in the worst case, a full restart. +Dusklight reloads core archive files during scene transitions so modifications to Link, Midna or other globally-loaded +data get refreshed without a full restart. + See [Asset Overlays](#asset-overlays) for priority and conflict handling. -### TextureService (`mods/svc/texture.h`) +### TextureService ([`mods/svc/texture.h`](../sdk/include/mods/svc/texture.h)) Registers texture replacements at runtime: the dynamic counterpart to the static `textures/` directory (see [Asset Overlays](#asset-overlays)). Two forms: raw texel data with an explicit key, or an encoded `.dds`/`.png` from -your bundle whose filename encodes the key: +your bundle whose filename encodes the key. + +**C++** ```cpp IMPORT_SERVICE(TextureService, svc_texture); @@ -273,6 +653,14 @@ svc_texture->register_data(mod_ctx, &key, &data, nullptr); svc_texture->unregister(mod_ctx, handle); ``` +**Luau** + +```lua +local texture = require("dusklight.texture") +local replacement = texture.register_file("res/tex1_32x32_$_6.png") +replacement:unregister() +``` + Filenames use the same Dolphin-style convention as the user's `texture_replacements` directory: `tex1_{w}x{h}_{texhash}[_{tluthash}]_{fmt}.dds|.png`, where hashes may be `$` (wildcard). `_mipN` sidecar files next to a registered file are picked up automatically. Files are decoded lazily on first use by the renderer; raw data is copied @@ -280,11 +668,13 @@ at registration. Registrations follow your mod's lifecycle. See [Asset Overlays](#asset-overlays) for priority and conflict handling. -### ConfigService (`mods/svc/config.h`) +### ConfigService ([`mods/svc/config.h`](../sdk/include/mods/svc/config.h)) Persistent, mod-scoped configuration variables. Each var is stored in the user's `config.json` under `mod..` (escaping: `.` → `_`, `_` → `__`, so `com.example.my_mod` becomes `com_example_my__mod`), -next to the host's own settings: +next to the host's own settings. + +**C++** ```cpp IMPORT_SERVICE(ConfigService, svc_config); @@ -308,6 +698,17 @@ void on_speed_changed(ModContext* ctx, ConfigVarHandle var, const ConfigVarValue svc_config->subscribe(mod_ctx, var, on_speed_changed, nullptr, nullptr); ``` +**Luau** + +```lua +local config = require("dusklight.config") +local speed = config.register({ name = "speedMultiplier", type = "float", default = 1.0 }) +speed:subscribe(function(value, previous) + -- React to the new value. +end) +speed:set(2.0) +``` + Types: `CONFIG_VAR_BOOL` (`bool`), `CONFIG_VAR_INT` (`int64_t`), `CONFIG_VAR_FLOAT` (`double`), `CONFIG_VAR_STRING` (UTF-8; `get_string` copies into a caller buffer, pass a `NULL` buffer with size 0 to query the length). Accessors are typed and must match the registration. @@ -316,7 +717,89 @@ Change callbacks fire on the game thread whenever the value changes at runtime ( Writes that store the same value are silent. Values applied from `config.json` or `--cvar` at registration do **not** fire callbacks; read the value after `register_var` for the starting state. -### UiService (`mods/svc/ui.h`) +### SaveService ([`mods/svc/save.h`](../sdk/include/mods/svc/save.h)) + +Stores named binary blobs for each save slot. Blob names are scoped to the calling mod, and each mod may store up to +`SAVE_BLOB_BUDGET_BYTES` per slot. The service copies data passed to `set_blob`. + +```cpp +IMPORT_SERVICE(SaveService, svc_save); + +struct MySaveData { + uint32_t version; + uint32_t counter; +}; + +MySaveData state{1, 42}; +svc_save->set_blob(mod_ctx, "state", &state, sizeof(state)); + +MySaveData loaded{}; +size_t loadedSize = sizeof(loaded); +if (svc_save->get_blob(mod_ctx, "state", &loaded, &loadedSize) == MOD_OK && + loadedSize == sizeof(loaded)) { + apply_state(loaded); +} +``` + +`set_blob`, `get_blob`, and `delete_blob` operate on the current slot, which is available after creating or loading a +save and unavailable at file select. Blob changes are written with the next game save. File-select copy and erase +operations update the blob data as well. Use `peek_blob` to read the calling mod's data from any slot; it uses the same +buffer contract as `get_blob`. Pass a `NULL` buffer to either read function to query the blob size. + +`observe_saves` registers callbacks for new, loaded, and written saves. New-save callbacks run after the slot's blobs +are cleared. Observers are removed automatically when the mod is detached, so the output handle is only needed for +manual unregistration. Save callbacks run on the game thread. + +### StageService ([`mods/svc/stage.h`](../sdk/include/mods/svc/stage.h)) + +Allows making changes to a stage's "stage info" (contents of .dzs/.dzr files). +(Currently only supports editing actor nodes.) + +```cpp +IMPORT_SERVICE(StageService, svc_stage); + +stage_actor_data_class record = { + "carry00", + 0xFF000000, + cXyz(0.0f, 0.0f, 0.0f), + csXyz(0, 0, 0), + 0, +}; + +StageActorHandle handle{}; +svc_stage->patch_actor(mod_ctx, "F_SP102", 0, -1, record_crc, &record, sizeof(record), &handle); +``` + +``` +StageActorHandle handle{}; +svc_stage->delete_actor(mod_ctx, "F_SP102", 0, -1, record_crc, &handle); +``` + +Patch or remove actors from the original actor list as the room loads. +Given records must be of either `stage_actor_data_class` or `stage_tgsc_data_class` types. +`record_crc` is the CRC-32 of the unmodified original record used to identify the record to replace or remove. + +``` +stage_actor_data_class record = { + "carry00", + 0xFF000000, + cXyz(0.0f, 0.0f, 0.0f), + csXyz(0, 0, 0), + 0, +}; + +StageActorHandle handle{}; +svc_stage->add_actor(mod_ctx, "F_SP102", 0, -1, &record, sizeof(record), &handle); +``` + +Add a new actor to the actor list as the room loads. +Given records must be of either `stage_actor_data_class` or `stage_tgsc_data_class` types. + +Stage names may contain up to 8 characters. For patches and deletions, room `0xff` and layer `-1` match any room or +layer; additions require a specific room. Edits are removed when the mod is detached. If multiple mods edit the same +record, the later-loaded mod wins. + +### UiService ([`mods/svc/ui.h`](../sdk/include/mods/svc/ui.h)) Integrate seamlessly with Dusklight's UI system: add controls and buttons to your mod's detail pane in the Mods window, create custom windows and modal dialogs, apply custom RCSS stylesheets (anywhere!), and add menu bar tabs. @@ -326,6 +809,8 @@ content is rebuilt, and `update` runs every frame while that mod is selected. Wh pane carries your mod's id as a `mod-id` attribute (like custom window roots), so scoped RCSS can target it (e.g. `[mod-id="com.example.mod"]`). +**C++** + ```cpp IMPORT_SERVICE(UiService, svc_ui); @@ -349,14 +834,26 @@ panel.update = update; svc_ui->register_mods_panel(mod_ctx, &panel); ``` +**Luau** + +```lua +local ui = require("dusklight.ui") +ui.register_mods_panel({ + build = function(panel) + panel:add_section("Status") + panel:add_text("running") + end, +}) +``` + Element setters must match the element kind: `elem_set_text`/`elem_set_rml` on text rows, and `elem_set_progress` on progress bars. `elem_set_class` sets or clears an RCSS class on any element handle, for styling via scoped or per-window RCSS. A non-`MOD_OK` result from `build`/`update` fails your mod, as do exceptions thrown from any UI callback. **Controls:** `pane_add_control` adds an input row described by a `UiControlDesc`: `UI_CONTROL_BUTTON`, -`UI_CONTROL_TOGGLE`, `UI_CONTROL_NUMBER`, `UI_CONTROL_STRING`, or `UI_CONTROL_SELECT`. Values bind with callbacks or -directly to a config var. +`UI_CONTROL_GROUP`, `UI_CONTROL_TOGGLE`, `UI_CONTROL_NUMBER`, `UI_CONTROL_STRING`, `UI_CONTROL_SELECT`, or +`UI_CONTROL_COLOR`. Values bind with callbacks or directly to a config var. ```cpp UiControlDesc control = UI_CONTROL_DESC_INIT; @@ -369,9 +866,56 @@ svc_ui->pane_add_control(mod_ctx, leftPane, &control, nullptr); ``` `UI_BINDING_CONFIG_VAR` wires persistence, change notifications, and the modified indicator automatically. The var -type must match the control: `TOGGLE` = bool, `NUMBER` and `SELECT` = int, `STRING` = string. Float vars are not -bindable; use callbacks and convert. `help_rml` and `SELECT` option lists render in a help pane, so `SELECT` controls -are only available inside window tabs. +type must match the control: `TOGGLE` = bool, `NUMBER` and `SELECT` = int, `STRING` and `COLOR` = string. Float vars +are not bindable; use callbacks and convert. `help_rml` and `SELECT` option lists render in a help pane, so `SELECT` +controls are only available inside window tabs. + +`pane_add_group` adds a category button to a window tab's left pane. Focusing the button clears the paired right pane +and calls the group's build callback with that pane, which is useful for organizing related controls without adding +more tabs. + +**Lists:** `pane_add_list` adds a scrollable virtualized list of items that can be efficiently updated and filtered. +Keys must be unique and remain stable across replacements. + +```cpp +UiListHandle locationList = 0; + +void replace_locations(std::string_view query) { + std::vector items; + for (uint64_t i = 0; i < locations.size(); ++i) { + if (matches(locations[i], query)) { + UiListItem item = UI_LIST_ITEM_INIT; + item.key = i; + item.label = locations[i].c_str(); + items.push_back(item); + } + } + svc_ui->list_set_items(mod_ctx, locationList, items.data(), items.size()); +} + +void set_filter(ModContext*, void*, const UiControlValue* value) { + replace_locations(value->string_value); +} + +bool location_selected(ModContext*, UiListHandle, uint64_t key, void*) { + return selected_locations.contains(key); +} + +UiControlDesc filter = UI_CONTROL_DESC_INIT; +filter.kind = UI_CONTROL_STRING; +filter.label = "Filter"; +filter.get = get_filter; +filter.set = set_filter; +filter.string_set_mode = UI_STRING_SET_ON_CHANGE; /* invoke `set` while typing */ +svc_ui->pane_add_control(mod_ctx, pane, &filter, nullptr); + +UiListDesc list = UI_LIST_DESC_INIT; +/* items may be passed as a part of list creation, or set afterwards */ +list.on_pressed = location_pressed; +list.is_selected = location_selected; +svc_ui->pane_add_list(mod_ctx, pane, &list, &locationList); +replace_locations(""); /* calls `list_set_items` */ +``` **Windows:** `window_push` pushes a tabbed two-pane window onto the document stack and shows it. Each tab's `build` receives the window handle plus fresh left and right pane handles on every activation. The optional per-tab `update` @@ -393,10 +937,52 @@ svc_ui->window_push(mod_ctx, &desc, &window); ``` **Dialogs:** `dialog_push` shows a modal dialog. `variant` picks the style, `icon` optionally overrides the variant's -default icon, and actions become buttons. After an action's `on_pressed` returns, the dialog closes unless the action -sets `keep_open`. A `keep_open` action can close it later (or immediately) with `dialog_close`. Cancel fires -`on_dismiss` if present and always closes. `dialog_set_body`, `dialog_set_icon`, and `dialog_add_action` mutate a live -dialog. +default icon, and actions become buttons. The optional `build` callback allows you to add controls to a pane between +the body and actions. It uses the same text, progress, and control builders as panels. + +```cpp +ModResult build_dialog(ModContext*, UiElementHandle pane, void*, ModError*) { + UiControlDesc input = UI_CONTROL_DESC_INIT; + input.kind = UI_CONTROL_STRING; + input.label = "Name"; + input.get = get_name; + input.set = set_name; + return svc_ui->pane_add_control(mod_ctx, pane, &input, nullptr); +} + +UiDialogAction action = UI_DIALOG_ACTION_INIT; +action.label = "Save"; +action.on_pressed = save; +action.is_disabled = is_save_disabled; + +UiDialogDesc dialog = UI_DIALOG_DESC_INIT; +dialog.title = "New Preset"; +dialog.body_rml = "Choose a name for the preset."; +dialog.actions = &action; +dialog.action_count = 1; +dialog.build = build_dialog; +svc_ui->dialog_push(mod_ctx, &dialog, nullptr); +``` + +After an action's `on_pressed`, the dialog closes unless the action sets `keep_open`. It can then be closed later +(or immediately) with `dialog_close`. Cancel fires `on_dismiss` and always closes. `dialog_set_body` and +`dialog_set_icon` mutate a live dialog. + +**Toasts:** `push_toast` enqueues a notification. Titles and bodies accept RML. The optional `type` is applied as an +RCSS class; `warning` uses the built-in warning appearance, and mods can define their own types. A duration of 0 uses +the default of 5 seconds. + +Toasts have a `mod-id` attribute, so `UI_SCOPE_OVERLAY` styles can use selectors such as +`toast[mod-id="com.example.randomizer"].success`. + +```cpp +UiToastDesc toast = UI_TOAST_DESC_INIT; +toast.type = "success"; +toast.title_rml = "Randomizer"; +toast.body_rml = "Seed loaded successfully."; +toast.duration_ms = 3000; +svc_ui->push_toast(mod_ctx, &toast); +``` **Menu bar tabs:** `register_menu_tab` adds a tab to the in-game menu bar. `on_selected` fires when the user activates the tab: typically you'd push a window from it. The tab is removed by `unregister_menu_tab`, or automatically when the @@ -409,34 +995,334 @@ existing documents restyle immediately, and future ones pick it up when created. host styles and may override them. Scope selectors tightly (use `[mod-id="..."]`!), especially for `UI_SCOPE_WINDOW`, unless changing host UI is intentional. +### WindowService ([`mods/svc/window.h`](../sdk/include/mods/svc/window.h)) + +Allows creating new windows that can be rendered to via `GfxService`. + +```cpp +IMPORT_SERVICE(WindowService, svc_window); + +WindowDesc desc = WINDOW_DESC_INIT; +desc.title = "My auxiliary view"; +desc.on_event = on_window_event; +WindowHandle window = 0; +svc_window->create_window(mod_ctx, &desc, &window); +``` + +Window callbacks run on the game thread. A close event is only a request; call `destroy_window` when the mod is ready to +close it. A window attached to a GfxService present target cannot be destroyed until that target is unregistered. Only +one present target may be attached to a WindowService window at a time. + +New windows are hidden by default so a mod can finish attaching graphics before calling `show_window`. + +### GfxService ([`mods/svc/gfx.h`](../sdk/include/mods/svc/gfx.h)) + +**Requires `add_mod(... FEATURES webgpu)`** + +Direct WebGPU access at various stages of the rendering pipeline. Mods use the `wgpu*` C API (via +[`webgpu/webgpu.h`](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)) for custom draws and compute +dispatches. Mods must manage their own WebGPU state, including pipelines and bind groups. + +```cpp +IMPORT_SERVICE(GfxService, svc_gfx); + +GfxDeviceInfo info = GFX_DEVICE_INFO_INIT; +svc_gfx->get_device_info(mod_ctx, &info); +``` + +`register_stage_hook` runs a game-thread callback during frame recording. The public stages are: + +- `GFX_STAGE_SCENE_BEGIN`: world camera window after camera/projection/light setup +- `GFX_STAGE_SCENE_AFTER_TERRAIN`: after terrain/shadow lists, before object and translucent lists +- `GFX_STAGE_SCENE_AFTER_OPAQUE`: after sky/terrain/object opaque lists, before translucent lists +- `GFX_STAGE_FRAME_BEFORE_HUD`: 3D scene and wipe are complete, before 2D/HUD lists +- `GFX_STAGE_FRAME_AFTER_HUD`: full game scene, including HUD + +Inside a stage callback, record work with `push_draw`, stream per-frame data with `push_verts`, `push_indices`, +`push_uniform`, or `push_storage`, snapshot the current frame with `resolve_pass`, and use `create_pass`/`resolve_pass` +for temporary offscreen passes. Draw callbacks run later on the render worker thread with the live +`WGPURenderPassEncoder`; they may use only their `GfxDrawContext` handles and raw `wgpu*` calls. Compute callbacks +registered with `register_compute_type` follow the same worker-thread rule and run on the frame command encoder. + +All WGPU handles from the service are borrowed. Resolved target views are valid for the current frame only. GPU objects +created by a mod are owned by that mod and should be released in `mod_shutdown`. + +#### External presentation + +GfxService supports external presentation ("present targets") backed by either a WindowService window (via +`register_window_present_target`) or a plain `WGPUSurface` (via `register_present_target`). + +```cpp +GfxPresentTargetDesc target_desc = GFX_PRESENT_TARGET_DESC_INIT; +target_desc.render = render_auxiliary_view; +GfxPresentTargetHandle target = 0; +svc_gfx->register_window_present_target(mod_ctx, window, &target_desc, &target); + +// From a stage callback: +svc_gfx->push_present(mod_ctx, target, &payload, sizeof(payload)); +``` + +For WindowService windows, the surface is automatically reconfigured on window size changes. +For plain `WBPUSurface`s, `resize_present_target` must be used to resize. + +To create a `WGPUSurface` manually, `GfxDeviceInfo` holds the `WGPUInstance` and `WGPUAdapter` which can be used with +`wgpuInstanceCreateSurface` and a chained `WGPUSurfaceSource*` struct. + +`push_present` must be called every frame from a GfxService stage callback. If surface was lost, `push_present` returns +`MOD_ERROR`. Unregister and re-register the target before trying again. + +### CameraService ([`mods/svc/camera.h`](../sdk/include/mods/svc/camera.h)) + +Converts a game view provided by a render callback into WebGPU-convention camera data. Matrix fields are column-major +`float[16]` values using the matrix * column-vector convention (transpose of the game's row-major `Mtx`/`Mtx44` layout), +ready to copy into WGSL `mat4x4f` uniforms. + +```cpp +IMPORT_SERVICE(CameraService, svc_camera); + +CameraInfo camera = CAMERA_INFO_INIT; +if (svc_camera->get_camera(mod_ctx, game_view, &camera) == MOD_OK) { + // camera.view_from_world, camera.proj_from_view, camera.eye, ... +} +``` + +`get_camera` returns `MOD_UNAVAILABLE` while the view is not a valid perspective camera, such as before the +first in-game frame. Projection matrices match the renderer's WebGPU clip convention and renderer depth convention +(reversed-Z by default). + +Camera operators allow overriding the main camera. When an operator callback returns true, its values replace the camera +state for the current frame. Register and unregister using `register_camera_operator` / `unregister_camera_operator`. + +### GameModeService ([`mods/svc/game_mode.h`](../sdk/include/mods/svc/game_mode.h)) + +Allows a mod to register a game mode with callbacks for key gameplay and save lifecycle events. Registered game modes +appear in the prelaunch menu. Game modes may use a unique set of saves by configuring `save_name`; leave it empty to use +the vanilla `gczelda2` save. + +```cpp +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(HookService, svc_hook); +IMPORT_SERVICE(GameModeService, svc_game_mode); + +DEFINE_HOOK(fopAcM_createItem, CreateItem); + +#define MY_GAME_MODE_ID "game-mode-id" + +static HookAction my_function_hook(ModContext* ctx, void* args, void*, void*) { + // If we wish to have this hook only run while the gamemode is registered, we need to hook the function from the + // gamemode's onActivatedFunction, and uninstall the hook during the onDeactivatedFunction. Example below. + // Alternatively, check with `svc_game_mode->is_active(mod_ctx, MY_GAME_MODE_ID, &active) == MOD_OK && active`. + return HOOK_CONTINUE; +} + +ModResult on_game_mode_activated(void*, ModError* outError) { + // Setup the gamemode, Add any hooks that are gamemode specific + // Overlay any files that are gamemode specific + ModResult result = mods::hook_add_pre(svc_hook, my_function_hook); + if (result != MOD_OK) { + return mods::set_error(outError, result, "failed to install fopAcM_createItem hook"); + } + return MOD_OK; +} + +ModResult on_game_mode_deactivated(void*, ModError* outError) { + // Uninstall any hooks that are gamemode specific + // Remove any file overlays that are gamemode specific + ModResult result = mods::hook_uninstall(); + if (result != MOD_OK) { + return mods::set_error(outError, result, "failed to uninstall fopAcM_createItem hook"); + } + return MOD_OK; +} + +ModResult on_save_loaded(void*, ModError*) { + // This function will be invoked by the game as a save is loaded + return MOD_OK; +} + +const GameModeDesc gameModeDesc = { + .struct_size = sizeof(GameModeDesc), + .game_mode_id = MY_GAME_MODE_ID, + .full_name = "My Game Mode", + .save_name = "my-unique-save", + .user_data = nullptr, + .on_activated = on_game_mode_activated, + .on_deactivated = on_game_mode_deactivated, + .on_save_loaded = on_save_loaded, +}; +svc_game_mode->register_game_mode(mod_ctx, &gameModeDesc); +``` + +A game mode can also open UI for per-save settings when creating a new file. The state begins as +`GAME_MODE_STATE_PENDING` and remains valid until the mod selects `PROCEED` or `RETURN`. + +```cpp +IMPORT_SERVICE(GameModeService, svc_game_mode); +IMPORT_SERVICE(UiService, svc_ui); + +ModResult on_new_save_select(void*, GameModeNewSaveState* state, ModError* outError) { + static GameModeNewSaveState* newSaveState; + static UiWindowHandle windowHandle; + + newSaveState = state; + + UiTabDesc tabs[1]{}; + + tabs[0].struct_size = sizeof(UiTabDesc); + tabs[0].title = "Play"; + tabs[0].build = [](ModContext* ctx, UiWindowHandle, UiElementHandle leftPane, UiElementHandle rightPane, void*, ModError*) { + UiControlDesc desc = UI_CONTROL_DESC_INIT; + desc.kind = UI_CONTROL_BUTTON; + desc.label = "Play"; + desc.help_rml = "Play Button"; + desc.on_pressed = [](ModContext* ctx, void* userdata) { + *newSaveState = GAME_MODE_STATE_PROCEED; + svc_ui->window_close(ctx, *static_cast(userdata)); + }; + desc.user_data = &windowHandle; + svc_ui->pane_add_control(mod_ctx, leftPane, &desc, nullptr); + return MOD_OK; + }; + + UiWindowDesc desc = UI_WINDOW_DESC_INIT; + desc.tabs = tabs; + desc.tab_count = 1; + desc.on_closed = [](ModContext *, UiWindowHandle, void *userdata) { + // If closing the window through backing out, return to file select + if (*newSaveState == GAME_MODE_STATE_PENDING) { + *newSaveState = GAME_MODE_STATE_RETURN; + } + }; + + ModResult result = svc_ui->window_push(mod_ctx, &desc, &windowHandle); + if (result != MOD_OK) { + return mods::set_error(outError, result, "failed to open new-save settings"); + } + return MOD_OK; +} + +const GameModeDesc gameModeDesc = { + .struct_size = sizeof(GameModeDesc), + .game_mode_id = "my-game-mode-id", + .full_name = "My Game Mode", + .save_name = "my-unique-save", + .on_new_save_select = on_new_save_select, +}; +svc_game_mode->register_game_mode(mod_ctx, &gameModeDesc); + +``` + +### ActorService (`mods/svc/actor.h`) + +A service that manages registering and creating custom actors. These actors will be run by the game as if they are part of the engine. These actors can be created by the game either by its 16-bit actor name, or a 7-character long name that can +be loaded by a stage. + +```cpp +#include "mods/svc/actor.h" +IMPORT_SERVICE(ActorService, svc_actor); + +class myActor_c : public fopAc_ac_c {}; + +int myActor_Create(void* i_this) { + // Ran several times, until it returns cPhs_COMPLEATE_e to allow for async loading + return cPhs_COMPLEATE_e; +} + +int myActor_Delete(void* i_this) { + // Free resources here + return 1; +} + +int myActor_Execute(void* i_this) { + // Ran once per game tick + return 1; +} + +int myActor_IsDelete(void* i_this) { + // Returns 1 when the actor can be deleted + return 1; +} + +int myActor_Draw(void* i_this) { + // Code to draw the actor + return 1; +} + +s16 actor_name; // The process name that can be used by the game to load the actor +ActorHandle actor_handle; +ActorProfileDesc profDesc = { + .name = "AUnique", // The name used by the stage loader to load the actor with. + // It has a character limit of 7 and must be unique among active + // mod actors. Matching a game actor name overrides stage lookup. + .priority_group = 7, // When, relative to other actors _Execute should run + // See: mods/svc/actor.h + .process_size = sizeof(myActor_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // Defines when the actor should be drawn relative + // to other actors (see f_pc_draw_priority.h) + .status = fopAcStts_CULL_e | fopAcStts_UNK_0x4000_e | fopAcStts_UNK_0x40000_e, + .group = fopAc_ACTOR_e, // Can be fopAc_ACTOR_e, fopAc_PLAYER_e, fopAc_ENEMY_e, or fopAc_NPC_e + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = myActor_Create, + .delete_function = myActor_Delete, + .execute_function = myActor_Execute, + .is_delete_function = myActor_IsDelete, + .draw_function = myActor_Draw, +}; +svc_actor->register_actor(mod_ctx, &profDesc, &actor_name, &actor_handle); + +// Spawn the actor at the player's position +fopAc_ac_c* plr = dComIfGp_getPlayer(0); +if (plr) { + ActorSpawnParams spawnParams = { + .parameters = 0, + .argument = 0, + .room_num = fopAcM_GetRoomNo(plr), + .position = {plr->current.pos.x, plr->current.pos.y, plr->current.pos.z}, + .angle = {plr->current.angle.x, plr->current.angle.y, plr->current.angle.z}, + .scale = {1.0f, 1.0f, 1.0f} + }; + ActorId created_actor_id; + svc_actor->create_actor(mod_ctx, actor_name, &spawnParams, &created_actor_id); +} +``` + +See `mods/custom_actor_demo` for a more complete example. + --- ## Hooking Game Functions +**Requires `add_mod(... FEATURES game)`** + Mods may hook the vast majority of game functions, including file-local static, private and virtual functions. -`mods/hook.hpp` provides typed helpers over the hook service: +[`mods/svc/hook.hpp`](../sdk/include/mods/svc/hook.hpp) provides typed helpers over the hook service: ```cpp -#include "mods/hook.hpp" -#include "mods/svc/hook.h" +#include "mods/svc/hook.hpp" IMPORT_SERVICE(HookService, svc_hook); + +DEFINE_HOOK(&daAlink_c::posMove, LinkPosMove); +DEFINE_HOOK(&daAlink_c::execute, LinkExecute); ``` +Every hook target must be **declared** at namespace scope with `DEFINE_HOOK` (a target you can name in C++) or +`DEFINE_HOOK_SYMBOL` (a symbol name). + ### Pre-hooks Run before the original. Return `HOOK_SKIP_ORIGINAL` to cancel it (post-hooks still run). ```cpp HookAction on_pos_move_pre(ModContext*, void* args, void* retval, void* userdata) { - daAlink_c* link = dusk::mods::arg(args, 0); // arg 0 is `this` + daAlink_c* link = mods::arg(args, 0); // arg 0 is `this` if (link->shape_angle.y > 10000) { return HOOK_SKIP_ORIGINAL; } return HOOK_CONTINUE; } -dusk::mods::hook_add_pre<&daAlink_c::posMove>(svc_hook, on_pos_move_pre); +mods::hook::add_pre(on_pos_move_pre); ``` ### Post-hooks @@ -447,24 +1333,22 @@ if any. ```cpp void on_pos_move_post(ModContext*, void* args, void* retval, void* userdata) { ... } -dusk::mods::hook_add_post<&daAlink_c::posMove>(svc_hook, on_pos_move_post); +mods::hook::add_post(on_pos_move_post); ``` ### Replace-hooks -Substitute the original entirely. Call through to it via `Hook<...>::g_orig` if needed: +Substitute the original entirely. Call through to it via the declaration's `g_orig` if needed: ```cpp -using ExecuteEntry = dusk::mods::Hook<&daAlink_c::execute>; - void on_execute_replace(ModContext*, void* args, void* retval, void*) { - int result = ExecuteEntry::g_orig(dusk::mods::arg(args, 0)); + int result = LinkExecute::g_orig(mods::arg(args, 0)); if (retval != nullptr) { *static_cast(retval) = result; } } -dusk::mods::hook_replace<&daAlink_c::execute>(svc_hook, on_execute_replace); +mods::hook::replace(on_execute_replace); ``` By default a second replace-hook on the same function is a conflict; `HookOptions` (`replace_policy`, `priority`, @@ -477,63 +1361,16 @@ Functions you can't name in C++ (file-local statics, private class members, anyt symbol name instead. You must supply the signature along with the name. ```cpp -// static callback used by Link's hookshot collider in d_a_alink_hook.inc -using HookshotHit = dusk::mods::NamedHook< - "daAlink_hookshotAtHitCallBack", - void(fopAc_ac_c*, dCcD_GObjInf*, fopAc_ac_c*, dCcD_GObjInf*)>; +DEFINE_HOOK_SYMBOL("daAlink_hookshotAtHitCallBack", + void(fopAc_ac_c*, dCcD_GObjInf*, fopAc_ac_c*, dCcD_GObjInf*), HookshotHit); -dusk::mods::hook_add_pre(svc_hook, on_hookshot_hit_pre); +mods::hook::add_pre(on_hookshot_hit_pre); ... HookshotHit::g_orig(link, atObjInf, target, tgObjInf); // call through to the original ``` Class member functions must include `Class*` as the first argument. -The install fails with the resolve error when the name is missing (`MOD_UNAVAILABLE`), ambiguous (`MOD_CONFLICT`), -or the manifest is absent (`MOD_UNSUPPORTED`). Unlike `Hook<&Class::method>`, the signature is **not** -compiler-checked: a mismatched signature will corrupt the call. - -### Reading and writing arguments - -`args` is an array of pointers to the arguments. For member functions, index 0 is `this`; parameters follow in -declaration order. - -```cpp -T value = dusk::mods::arg(args, n); // copy -T& ref = dusk::mods::arg_ref(args, n); // read/write reference -``` - -```cpp -// fpc_ProcID fopAcM_createItem(..., int itemNo, ...): turn heart drops into green rupees -HookAction on_create_item_pre(ModContext*, void* args, void*, void*) { - int& itemNo = dusk::mods::arg_ref(args, 1); - if (itemNo == dItemNo_HEART_e) { - itemNo = dItemNo_GREEN_RUPEE_e; - } - return HOOK_CONTINUE; -} - -dusk::mods::hook_add_pre<&fopAcM_createItem>(svc_hook, on_create_item_pre); -``` - -For reference parameters (e.g. `const cXyz& pos`), `arg_ref` yields a direct reference. - -### Resolving symbols by name - -`resolve` looks a symbol up in the **symbol manifest**: a name→address map generated alongside every game build and -keyed to that exact binary. It covers the whole image, including functions that aren't exported (file-local statics), -which makes them hookable: - -```cpp -IMPORT_SERVICE(HookService, svc_hook); - -void* addr = nullptr; -uint32_t flags = 0; -if (svc_hook->resolve(mod_ctx, "GXSetProjection", &addr, &flags) == MOD_OK) { - // addr is the function's real address in the running game; hook or call it. -} -``` - Two spellings work on every platform: - **Display names** (`daAlink_c::posMove`, `fapGm_Before`): the qualified name with no parameter list. They carry no @@ -541,25 +1378,36 @@ Two spellings work on every platform: - **Decorated names** (`_ZN9daAlink_c7posMoveEv` / `?posMove@daAlink_c@@...`): the platform's mangled spelling in dlsym convention (no Mach-O leading underscore). The escape hatch for overloads. -`MOD_UNSUPPORTED` means the manifest is missing or was built for a different game binary. +Installing fails with `MOD_UNAVAILABLE` when it didn't resolve (missing, ambiguous, or no symbol manifest). Unlike +`DEFINE_HOOK`, the signature is **not** compiler-checked: a mismatched signature will corrupt the +call. -### Game code ABI contract +### Reading and writing arguments -A primary consideration when letting mods link against the game is maintaining ABI stability across Dusklight -versions. If your mod calls or hooks game code directly (anything beyond the service APIs), import `GameService` -(`mods/svc/game.h`): +`args` is an array of pointers to the arguments. For member functions, index 0 is `this`; parameters follow in +declaration order. ```cpp -IMPORT_SERVICE(GameService, svc_game); +T value = mods::arg(args, n); // copy +T& ref = mods::arg_ref(args, n); // read/write reference ``` -Its major version is the game code ABI epoch: it's bumped when game struct or vtable layouts change incompatibly, and -the ordinary service version check then rejects your mod with a clear error instead of letting it corrupt memory in a -version it wasn't built for. Service-only and asset-only mods should *not* import it and will continue to work across -game ABI changes. +```cpp +DEFINE_HOOK(fopAcM_createItem, CreateItem); -The more you can do through services, the better: a mod that avoids touching game code directly sidesteps future ABI -breaks entirely and plays nicer with other enabled mods. +// fpc_ProcID fopAcM_createItem(..., int itemNo, ...): turn heart drops into green rupees +HookAction on_create_item_pre(ModContext*, void* args, void*, void*) { + int& itemNo = mods::arg_ref(args, 1); + if (itemNo == dItemNo_HEART_e) { + itemNo = dItemNo_GREEN_RUPEE_e; + } + return HOOK_CONTINUE; +} + +mods::hook::add_pre(on_create_item_pre); +``` + +For reference parameters (e.g. `const cXyz& pos`), `arg_ref` yields a direct reference. --- @@ -567,6 +1415,11 @@ breaks entirely and plays nicer with other enabled mods. Files placed under `overlay/` in the `.dusk` archive override game files at the corresponding path, equivalent to replacing files in the .iso. This requires no code: an archive with just `mod.json` and `overlay/` is a complete mod. +To replace a file within an `.arc` archive, replace the archive suffix with a directory and place the replacement at +its path within the archive. + +- `overlay/Audiores/Stream/menu_select.ast` replaces the main title's audio stream. +- `overlay/res/Layout/main2D/main2d/timg/midona64.bti` replaces Midna's UI icon inside `main2D.arc`. Files placed under `textures/` register as texture replacements, and act just like the user's general `texture_replacements/` directory: Dolphin-style naming, matched by texture hash @@ -615,13 +1468,13 @@ the stack for the whole session (e.g. the outermost main loop); a mod that does Service calls report failure through `ModResult` return values (`MOD_OK`, `MOD_UNAVAILABLE`, `MOD_INVALID_ARGUMENT`, ...). Lifecycle exports additionally receive a `ModError*`: fill it (e.g. with -`dusk::mods::set_error(error, code, "message")`) and return the code, and the loader disables the mod and shows the +`mods::set_error(error, code, "message")`) and return the code, and the loader disables the mod and shows the message to the user. ```cpp MOD_EXPORT ModResult mod_initialize(ModError* error) { if (!load_my_data()) { - return dusk::mods::set_error(error, MOD_ERROR, "failed to load data"); + return mods::set_error(error, MOD_ERROR, "failed to load data"); } return MOD_OK; } @@ -632,7 +1485,9 @@ explicit results. --- -## Advanced: Exporting Services +## Advanced + +### Exporting Services Mods may export services of their own, permitting framework mods and cross-mod integration. Define the interface in a header both mods share: @@ -653,9 +1508,10 @@ typedef struct MyModService { #ifdef __cplusplus #include "mods/service.hpp" template <> -struct dusk::mods::ServiceTraits { +struct mods::ServiceTraits { static constexpr const char* id = MY_MOD_SERVICE_ID; static constexpr uint16_t major_version = MY_MOD_SERVICE_MAJOR; + static constexpr uint16_t minor_version = MY_MOD_SERVICE_MINOR; }; #endif ``` @@ -684,7 +1540,7 @@ svc_my_mod->do_thing(mod_ctx, 42); The loader registers all exports before resolving any imports, so declaration order between mods doesn't matter. Note that the `ctx` a provider receives identifies the *calling* mod. -### Dependencies between mods +#### Dependencies between mods Service imports are also dependency declarations: the loader initializes mods in dependency order, so by the time your `mod_initialize` runs, every mod you import services from (required *or* optional) has already finished its own @@ -714,3 +1570,31 @@ For services whose construction can't happen at static-init time, declare the ex and publish the pointer later via `svc_host->publish_service(...)`. Consumers can fetch services dynamically with `svc_host->get_service(...)`; prefer manifest imports whenever possible, since they give the loader dependency information and fail fast with good errors. + +### Native Runtime Libraries + +`RUNTIME_LIBRARIES` passed to `add_mod` are packaged beside the mod's native module in `lib//`. Dusklight +extracts the whole directory before loading the mod, so libraries linked by the mod resolve normally. The SDK links the +mod itself with `$ORIGIN` on Linux and `@loader_path` on Apple platforms; runtime libraries with their own non-system +dependencies must also be built with origin-relative lookup paths. On Windows, Dusklight uses an isolated DLL search +rooted at this directory. + +```cmake +add_mod(my_mod + SOURCES src/mod.cpp + MOD_JSON mod.json + RUNTIME_LIBRARIES "${VENDOR_RUNTIME_LIBRARY}") +``` + +SDKs that load plugins by directory can pass them the absolute runtime path from the current HostService: + +```cpp +IMPORT_SERVICE(HostService, svc_host); + +const char* nativeDir = svc_host->native_dir(mod_ctx); // read-only +``` + +Libraries loaded explicitly by the mod remain its responsibility: stop their threads and unload them during +`mod_shutdown`. Do not write into `native_dir`; use `data_dir` for persistent storage or `mod_dir` for temporary +(session) storage. Native library namespaces are process-wide on some platforms, so two mods cannot safely assume that +incompatible libraries with the same filename will remain isolated. diff --git a/extern/aurora b/extern/aurora index 0a5a5d90ef..d0c931da2e 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 0a5a5d90efd2dbc7b402ab61f1021922dbf7496f +Subproject commit d0c931da2ed3f41d0e42736c2ab52a78c7cf1a9d diff --git a/extern/borealis b/extern/borealis new file mode 160000 index 0000000000..0bdba6c50a --- /dev/null +++ b/extern/borealis @@ -0,0 +1 @@ +Subproject commit 0bdba6c50a46409c4862474c72b4a3a631fbe0ec diff --git a/files.cmake b/files.cmake index 15b64c3a3f..42a12c353c 100644 --- a/files.cmake +++ b/files.cmake @@ -244,7 +244,7 @@ set(DOLZEL_FILES src/CaptureScreen.cpp ) if(DEBUG) - list(APPEND DOLZEL_FILES src/d/d_event_debug.cpp) + list(APPEND DOLZEL_FILES src/d/d_event_debug.cpp) endif(DEBUG) set(Z2AUDIOLIB_FILES @@ -1404,117 +1404,223 @@ set(REL_FILES ) set(DOLPHIN_FILES - libs/dolphin/src/gf/GFGeometry.cpp - libs/dolphin/src/gf/GFLight.cpp - libs/dolphin/src/gf/GFPixel.cpp - libs/dolphin/src/gf/GFTev.cpp + libs/dolphin/src/gf/GFGeometry.cpp + libs/dolphin/src/gf/GFLight.cpp + libs/dolphin/src/gf/GFPixel.cpp + libs/dolphin/src/gf/GFTev.cpp ) set(DUSK_FILES - include/dusk/action_bindings.h - include/dusk/endian_gx.hpp - include/dusk/config.hpp - include/dusk/dvd_asset.hpp - include/dusk/scope_guard.hpp - src/dusk/dvd_asset.cpp + include/helpers/batch.hpp + include/helpers/bits.hpp + include/helpers/endian_gx.hpp src/d/actor/d_a_alink_dusk.cpp - src/dusk/android_frame_rate.hpp - src/dusk/android_frame_rate.cpp + src/dusk/OSContext.cpp + src/dusk/OSMutex.cpp + src/dusk/OSReport.cpp + src/dusk/OSThread.cpp + src/dusk/achievements.cpp + src/dusk/action_bindings.cpp + src/dusk/action_bindings.h + src/dusk/archive.cpp + src/dusk/archive.hpp src/dusk/asserts.cpp - src/dusk/batch.cpp - src/dusk/batch.hpp + src/dusk/autosave.cpp src/dusk/config.cpp - src/dusk/crash_handler.cpp - src/dusk/crash_reporting.cpp + src/dusk/config.hpp src/dusk/data.cpp src/dusk/data.hpp - src/dusk/endian.cpp + src/dusk/discord_presence.cpp + src/dusk/dvd_asset.cpp + src/dusk/dvd_asset.hpp src/dusk/extras.c - src/dusk/file_select.cpp - src/dusk/file_select.hpp - src/dusk/frame_interpolation.cpp + src/dusk/commands.cpp + src/dusk/commands.hpp src/dusk/game_clock.cpp + src/dusk/hash.hpp + src/dusk/game_mode.cpp + src/dusk/gamepad_color.cpp src/dusk/globals.cpp src/dusk/gyro.cpp - include/dusk/menu_pointer.h - src/dusk/menu_pointer.cpp - src/dusk/mouse.cpp - src/dusk/gamepad_color.cpp - src/dusk/autosave.cpp - src/dusk/http/http.hpp - src/dusk/io.cpp - src/dusk/layout.cpp - src/dusk/logging.cpp - src/dusk/settings.cpp - src/dusk/speedrun.cpp - src/dusk/string.cpp - src/dusk/stubs.cpp - include/dusk/texture_replacements.hpp - src/dusk/texture_replacements.cpp - src/dusk/touch_camera.cpp - src/dusk/update_check.cpp - src/dusk/update_check.hpp + src/dusk/game_combos.cpp + src/dusk/trigger_viewer.cpp #src/dusk/m_Do_ext_dusk.cpp - src/dusk/imgui/ImGuiConfig.hpp - src/dusk/imgui/ImGuiConsole.hpp - src/dusk/imgui/ImGuiConsole.cpp - src/dusk/imgui/ImGuiEngine.cpp - src/dusk/imgui/ImGuiEngine.hpp + src/dusk/hq_minimap.cpp + src/dusk/imgui/ImGuiActorSpawner.cpp src/dusk/imgui/ImGuiBloomWindow.cpp src/dusk/imgui/ImGuiBloomWindow.hpp + src/dusk/imgui/ImGuiCameraOverlay.cpp + src/dusk/imgui/ImGuiConfig.hpp + src/dusk/imgui/ImGuiConsole.cpp + src/dusk/imgui/ImGuiConsole.hpp + src/dusk/imgui/ImGuiControllerOverlay.cpp + src/dusk/imgui/ImGuiEngine.cpp + src/dusk/imgui/ImGuiEngine.hpp + src/dusk/imgui/ImGuiHeapOverlay.cpp src/dusk/imgui/ImGuiMenuTools.cpp src/dusk/imgui/ImGuiMenuTools.hpp - src/dusk/imgui/ImGuiActorSpawner.cpp src/dusk/imgui/ImGuiProcessOverlay.cpp - src/dusk/imgui/ImGuiCameraOverlay.cpp - src/dusk/imgui/ImGuiHeapOverlay.cpp - src/dusk/imgui/ImGuiControllerOverlay.cpp - src/dusk/imgui/ImGuiStubLog.cpp src/dusk/imgui/ImGuiSaveEditor.cpp - src/dusk/imgui/ImGuiStateShare.hpp src/dusk/imgui/ImGuiStateShare.cpp + src/dusk/imgui/ImGuiStateShare.hpp + src/dusk/imgui/ImGuiStubLog.cpp + src/dusk/interp/camera.cpp + src/dusk/interp/dual_buffer.cpp + src/dusk/interp/frame_interpolation.cpp + src/dusk/interp/line.cpp + src/dusk/io.cpp + src/dusk/iso_validate.cpp + src/dusk/language.cpp + src/dusk/language.hpp + src/dusk/layout.cpp + src/dusk/livesplit.cpp + src/dusk/logging.cpp + src/dusk/menu_pointer.cpp + src/dusk/menu_pointer.h + src/dusk/mods/loader/bundle_disk.cpp + src/dusk/mods/loader/bundle_zip.cpp + src/dusk/mods/loader/context.cpp + src/dusk/mods/loader/depgraph.cpp + src/dusk/mods/loader/depgraph.hpp + src/dusk/mods/loader/loader.cpp + src/dusk/mods/loader/loader.hpp + src/dusk/mods/loader/manifest.cpp + src/dusk/mods/loader/manifest.hpp + src/dusk/mods/loader/natives.cpp + src/dusk/mods/loader/natives.hpp + src/dusk/mods/loader/packages.cpp + src/dusk/mods/loader/packages.hpp + src/dusk/mods/loader/native_module.cpp + src/dusk/mods/loader/native_module.hpp + src/dusk/mods/loader/prepatch.cpp + src/dusk/mods/loader/prepatch.hpp + src/dusk/mods/catalog.cpp + src/dusk/mods/catalog.hpp + src/dusk/mods/queue.cpp + src/dusk/mods/queue.hpp + src/dusk/mods/item.hpp + src/dusk/mods/item_actor.cpp + src/dusk/mods/item_checks.cpp + src/dusk/mods/item_gives.cpp + src/dusk/mods/log_buffer.cpp + src/dusk/mods/log_buffer.hpp + src/dusk/mods/manifest.cpp + src/dusk/mods/manifest.hpp + src/dusk/mods/svc/actor.cpp + src/dusk/mods/svc/camera.cpp + src/dusk/mods/svc/config.cpp + src/dusk/mods/svc/config.hpp + src/dusk/mods/svc/file.cpp + src/dusk/mods/svc/game.cpp + src/dusk/mods/svc/gfx.cpp + src/dusk/mods/svc/flow.cpp + src/dusk/mods/svc/hook.cpp + src/dusk/mods/svc/host.cpp + src/dusk/mods/svc/http.cpp + src/dusk/mods/svc/net.cpp + src/dusk/mods/svc/net.hpp + src/dusk/mods/svc/websocket.cpp + src/dusk/mods/svc/item.cpp + src/dusk/mods/svc/item.hpp + src/dusk/mods/svc/log.cpp + src/dusk/mods/svc/overlay.cpp + src/dusk/mods/svc/registry.cpp + src/dusk/mods/svc/registry.hpp + src/dusk/mods/svc/resource.cpp + src/dusk/mods/svc/texture.cpp + src/dusk/mods/svc/ui.cpp + src/dusk/mods/svc/ui.hpp + src/dusk/mods/svc/game_mode.cpp + src/dusk/mods/svc/window.cpp + src/dusk/mods/svc/window.hpp + src/dusk/mods/svc/save.cpp + src/dusk/mods/svc/save.hpp + src/dusk/mods/svc/stage.cpp + src/dusk/mods/svc/stage.hpp + src/dusk/mouse.cpp + src/dusk/presentation.cpp + src/dusk/presentation.hpp + src/dusk/scope_guard.hpp + src/dusk/settings.cpp + src/dusk/speedrun.cpp + src/dusk/stubs.cpp + src/dusk/texture_replacements.cpp + src/dusk/texture_replacements.hpp + src/dusk/touch_camera.cpp src/dusk/ui/achievements.cpp src/dusk/ui/achievements.hpp + src/dusk/ui/command_console.cpp + src/dusk/ui/command_console.hpp src/dusk/ui/bool_button.cpp src/dusk/ui/bool_button.hpp src/dusk/ui/button.cpp src/dusk/ui/button.hpp + src/dusk/ui/color_input.cpp + src/dusk/ui/color_input.hpp src/dusk/ui/component.cpp src/dusk/ui/component.hpp - src/dusk/ui/controls.hpp src/dusk/ui/controller_config.cpp src/dusk/ui/controller_config.hpp + src/dusk/ui/controls.hpp src/dusk/ui/document.cpp src/dusk/ui/document.hpp + src/dusk/ui/drop_install_modal.cpp + src/dusk/ui/drop_install_modal.hpp src/dusk/ui/editor.cpp src/dusk/ui/editor.hpp src/dusk/ui/event.cpp src/dusk/ui/event.hpp src/dusk/ui/graphics_tuner.cpp src/dusk/ui/graphics_tuner.hpp - src/dusk/ui/input.cpp - src/dusk/ui/input.hpp + src/dusk/ui/group_button.cpp + src/dusk/ui/group_button.hpp + src/dusk/ui/file_button.cpp + src/dusk/ui/file_button.hpp src/dusk/ui/icon_provider.cpp src/dusk/ui/icon_provider.hpp + src/dusk/ui/input.cpp + src/dusk/ui/input.hpp src/dusk/ui/logs_window.cpp src/dusk/ui/logs_window.hpp + src/dusk/ui/list.cpp + src/dusk/ui/list.hpp + src/dusk/ui/menu_bar.cpp + src/dusk/ui/menu_bar.hpp + src/dusk/ui/mod_browser.cpp + src/dusk/ui/mod_browser.hpp + src/dusk/ui/queue_window.cpp + src/dusk/ui/queue_window.hpp + src/dusk/ui/package_row.cpp + src/dusk/ui/package_row.hpp src/dusk/ui/mod_texture_provider.cpp src/dusk/ui/mod_texture_provider.hpp + src/dusk/ui/remote_texture_provider.cpp + src/dusk/ui/remote_texture_provider.hpp + src/dusk/ui/runtime_image.cpp + src/dusk/ui/runtime_image.hpp src/dusk/ui/mod_window.cpp src/dusk/ui/mod_window.hpp src/dusk/ui/modal.cpp src/dusk/ui/modal.hpp + src/dusk/ui/mods_window.cpp + src/dusk/ui/mods_window.hpp src/dusk/ui/nav_types.hpp + src/dusk/ui/nav_group.cpp + src/dusk/ui/nav_group.hpp + src/dusk/ui/context_menu.cpp + src/dusk/ui/context_menu.hpp + src/dusk/ui/icon_button.cpp + src/dusk/ui/icon_button.hpp + src/dusk/ui/tooltip.cpp + src/dusk/ui/tooltip.hpp src/dusk/ui/number_button.cpp src/dusk/ui/number_button.hpp src/dusk/ui/overlay.cpp src/dusk/ui/overlay.hpp src/dusk/ui/pane.cpp src/dusk/ui/pane.hpp - src/dusk/ui/menu_bar.cpp - src/dusk/ui/menu_bar.hpp - src/dusk/ui/mods_window.cpp - src/dusk/ui/mods_window.hpp + src/dusk/ui/popover.cpp + src/dusk/ui/popover.hpp src/dusk/ui/prelaunch.cpp src/dusk/ui/prelaunch.hpp src/dusk/ui/preset.cpp @@ -1529,10 +1635,10 @@ set(DUSK_FILES src/dusk/ui/string_button.hpp src/dusk/ui/tab_bar.cpp src/dusk/ui/tab_bar.hpp - src/dusk/ui/touch_controls_common.cpp - src/dusk/ui/touch_controls_common.hpp src/dusk/ui/touch_controls.cpp src/dusk/ui/touch_controls.hpp + src/dusk/ui/touch_controls_common.cpp + src/dusk/ui/touch_controls_common.hpp src/dusk/ui/touch_controls_editor.cpp src/dusk/ui/touch_controls_editor.hpp src/dusk/ui/ui.cpp @@ -1541,50 +1647,10 @@ set(DUSK_FILES src/dusk/ui/warp.hpp src/dusk/ui/window.cpp src/dusk/ui/window.hpp - src/dusk/achievements.cpp - src/dusk/iso_validate.cpp - src/dusk/livesplit.cpp - src/dusk/offset_ptr.cpp - src/dusk/OSContext.cpp - src/dusk/OSReport.cpp - src/dusk/OSThread.cpp - src/dusk/OSMutex.cpp - src/dusk/mods/log_buffer.cpp - src/dusk/mods/log_buffer.hpp - src/dusk/mods/manifest.cpp - src/dusk/mods/manifest.hpp - src/dusk/mods/loader/bundle_disk.cpp - src/dusk/mods/loader/bundle_zip.cpp - src/dusk/mods/loader/context.cpp - src/dusk/mods/loader/depgraph.cpp - src/dusk/mods/loader/depgraph.hpp - src/dusk/mods/loader/loader.cpp - src/dusk/mods/loader/loader.hpp - src/dusk/mods/loader/native_module.cpp - src/dusk/mods/loader/native_module.hpp - src/dusk/mods/svc/config.cpp - src/dusk/mods/svc/config.hpp - src/dusk/mods/svc/game.cpp - src/dusk/mods/svc/hook.cpp - src/dusk/mods/svc/host.cpp - src/dusk/mods/svc/log.cpp - src/dusk/mods/svc/overlay.cpp - src/dusk/mods/svc/resource.cpp - src/dusk/mods/svc/texture.cpp - src/dusk/mods/svc/ui.cpp - src/dusk/mods/svc/ui.hpp - src/dusk/mods/svc/registry.cpp - src/dusk/mods/svc/registry.hpp - src/dusk/discord.cpp - src/dusk/discord.hpp - src/dusk/discord_presence.cpp src/dusk/version.cpp - src/dusk/action_bindings.cpp -) - -set(DUSK_HTTP_BACKEND_FILES - src/dusk/http/no_backend.cpp - src/dusk/http/curl.cpp - src/dusk/http/winhttp.cpp - src/dusk/http/url_session.mm + src/dusk/utilities.cpp + src/helpers/batch.cpp + src/helpers/endian.cpp + src/helpers/offset_ptr.cpp + src/helpers/string.cpp ) diff --git a/flake.nix b/flake.nix index 6be8c03aef..01a20fad2d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ description = "Dusklight — native PC port of the Twilight Princess decompilation"; inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + inputs.self.submodules = true; outputs = { self, nixpkgs }: @@ -58,21 +59,6 @@ hasNodPrebuilt = nodPrebuiltInfo ? ${system}; aurora = builtins.pathExists "${self}/extern/aurora/CMakeLists.txt"; - needSubmodules = '' - dusklight: The aurora submodule is not vendored. Add submodules=1 to build. - - As a flake input: - - dusklight.url = "git+https://github.com/TwilitRealm/dusklight?ref=main&submodules=1"; - - nix command: - - nix run 'git+https://github.com/TwilitRealm/dusklight?submodules=1' - - Local checkout: - - nix run '.?submodules=1#dusklight' - ''; dawn = pkgs.fetchzip { url = "https://github.com/encounter/dawn/releases/download/${dawnVersion}/dawn-${dawnInfo.${system}.triple}.tar.gz"; @@ -140,6 +126,14 @@ JSON = pkgs.nlohmann_json.src; XXHASH = pkgs.xxhash.src; ZSTD = pkgs.zstd.src; + + + MINIZ = pkgs.fetchzip { + url = "https://github.com/richgel999/miniz/releases/download/3.0.2/miniz-3.0.2.zip"; + hash = "sha256-DXysXkQEmoDAMMg1F8KexkwpXNyiHNzLJqXR9SMEkxk="; + stripRoot = false; + }; + FMT = pkgs.fetchzip { url = "https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz"; hash = "sha256-ZmI1Dv0ZabPlxa02OpERI47jp7zFfjpeWCy1WyuPYZ0="; @@ -165,19 +159,16 @@ }; dusklight = - if !aurora then - throw needSubmodules - else - pkgs.stdenv.mkDerivation { - pname = "dusklight"; - version = versionSuffix; - src = ./.; + pkgs.stdenv.mkDerivation { + pname = "dusklight"; + version = versionSuffix; + src = ./.; - postUnpack = '' - chmod -R u+w "$sourceRoot" - substituteInPlace "$sourceRoot/extern/aurora/CMakeLists.txt" \ - --replace-warn "add_subdirectory(tests)" "" - ''; + postUnpack = '' + chmod -R u+w "$sourceRoot" + substituteInPlace "$sourceRoot/extern/aurora/CMakeLists.txt" \ + --replace-warn "add_subdirectory(tests)" "" + ''; nativeBuildInputs = [ pkgs.cmake @@ -237,7 +228,7 @@ ninjaFlags = [ "dusklight" ]; cmakeFlags = [ - "-DDUSK_VERSION_OVERRIDE=${versionSuffix}" + "-DBOREALIS_APP_VERSION_OVERRIDE=${versionSuffix}" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DAURORA_DAWN_PROVIDER=package" "-DAURORA_DAWN_LINKAGE=static" diff --git a/include/DynamicLink.h b/include/DynamicLink.h index 7f6d8568eb..1f9a1c8eeb 100644 --- a/include/DynamicLink.h +++ b/include/DynamicLink.h @@ -88,9 +88,9 @@ struct DynamicModuleControl : DynamicModuleControlBase { /* 0x24 */ s32 mSize; /* 0x28 */ mDoDvdThd_callback_c* mAsyncLoadCallback; - static u32 sAllocBytes; - static JKRArchive* sArchive; - static JKRFileCache* sFileCache; + static DUSK_GAME_DATA u32 sAllocBytes; + static DUSK_GAME_DATA JKRArchive* sArchive; + static DUSK_GAME_DATA JKRFileCache* sFileCache; }; #endif /* DYNAMICLINK_H */ diff --git a/include/SSystem/SComponent/c_API.h b/include/SSystem/SComponent/c_API.h index 8fcd246b2d..2bb68e5cdd 100644 --- a/include/SSystem/SComponent/c_API.h +++ b/include/SSystem/SComponent/c_API.h @@ -12,6 +12,6 @@ struct cAPI_Interface { /* 0x14 */ cAPIGph_Mthd blankingOffMtd; }; -extern cAPI_Interface g_cAPI_Interface; +DUSK_GAME_EXTERN cAPI_Interface g_cAPI_Interface; #endif /* C_API_H */ diff --git a/include/SSystem/SComponent/c_angle.h b/include/SSystem/SComponent/c_angle.h index f851033eab..f5788f75d2 100644 --- a/include/SSystem/SComponent/c_angle.h +++ b/include/SSystem/SComponent/c_angle.h @@ -24,11 +24,11 @@ private: s16 mAngle; public: - const static cSAngle _0; - const static cSAngle _1; - const static cSAngle _90; - const static cSAngle _180; - const static cSAngle _270; + const static DUSK_GAME_DATA cSAngle _0; + const static DUSK_GAME_DATA cSAngle _1; + const static DUSK_GAME_DATA cSAngle _90; + const static DUSK_GAME_DATA cSAngle _180; + const static DUSK_GAME_DATA cSAngle _270; #ifdef __MWERKS__ cSAngle() {} ~cSAngle() {} diff --git a/include/SSystem/SComponent/c_bg_s_chk.h b/include/SSystem/SComponent/c_bg_s_chk.h index adbc0c1807..badc04679a 100644 --- a/include/SSystem/SComponent/c_bg_s_chk.h +++ b/include/SSystem/SComponent/c_bg_s_chk.h @@ -5,7 +5,6 @@ #include "f_pc/f_pc_base.h" #include "SSystem/SComponent/c_bg_s_grp_pass_chk.h" #include "SSystem/SComponent/c_bg_s_poly_pass_chk.h" -#include "dusk/endian.h" struct cBgD_Vtx_t : public Vec {}; diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 66c71a4ead..7a8400a55a 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -435,7 +435,7 @@ public: cM3dGAab& GetWorkAab() { return mAab; } - static cXyz m_virtual_center; + static DUSK_GAME_DATA cXyz m_virtual_center; }; STATIC_ASSERT(0x20 == sizeof(cCcD_ShapeAttr)); diff --git a/include/SSystem/SComponent/c_counter.h b/include/SSystem/SComponent/c_counter.h index 864554b1a7..c67524fb73 100644 --- a/include/SSystem/SComponent/c_counter.h +++ b/include/SSystem/SComponent/c_counter.h @@ -9,7 +9,7 @@ struct counter_class { u32 mTimer; }; -extern counter_class g_Counter; +DUSK_GAME_EXTERN counter_class g_Counter; void cCt_Counter(int resetCounter1); diff --git a/include/SSystem/SComponent/c_lib.h b/include/SSystem/SComponent/c_lib.h index 75d4544341..4be9645bc4 100644 --- a/include/SSystem/SComponent/c_lib.h +++ b/include/SSystem/SComponent/c_lib.h @@ -102,6 +102,6 @@ void MtxPosition(cXyz DUSK_CONST*, cXyz*); void MtxPush(void); void MtxPull(void); -extern Mtx* calc_mtx; +DUSK_GAME_EXTERN Mtx* calc_mtx; #endif diff --git a/include/SSystem/SComponent/c_m3d.h b/include/SSystem/SComponent/c_m3d.h index 94762d5a29..50c92a2934 100644 --- a/include/SSystem/SComponent/c_m3d.h +++ b/include/SSystem/SComponent/c_m3d.h @@ -20,7 +20,7 @@ struct cM3d_Range { }; #define G_CM3D_F_INF (1000000000.0f) -extern const f32 G_CM3D_F_ABS_MIN; +DUSK_GAME_EXTERN const f32 G_CM3D_F_ABS_MIN; static void cM3d_InDivPos1(const Vec*, const Vec*, f32, Vec*); void cM3d_InDivPos2(const Vec*, const Vec*, f32, Vec*); diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index cac178e064..cd535d66c3 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -2,7 +2,6 @@ #define C_M3D_G_TRI_H_ #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/endian.h" class cM3dGCyl; diff --git a/include/SSystem/SComponent/c_malloc.h b/include/SSystem/SComponent/c_malloc.h index 95b2d8f298..5eb775e033 100644 --- a/include/SSystem/SComponent/c_malloc.h +++ b/include/SSystem/SComponent/c_malloc.h @@ -6,7 +6,7 @@ class JKRHeap; struct cMl { - static JKRHeap* Heap; + static DUSK_GAME_DATA JKRHeap* Heap; static void init(JKRHeap*); static void* memalignB(int, u32); static void free(void*); diff --git a/include/SSystem/SComponent/c_sxyz.h b/include/SSystem/SComponent/c_sxyz.h index bfaa035de9..4b2ea4dd45 100644 --- a/include/SSystem/SComponent/c_sxyz.h +++ b/include/SSystem/SComponent/c_sxyz.h @@ -9,7 +9,7 @@ struct SVec { class csXyz : public SVec { public: - static const csXyz Zero; + static DUSK_GAME_DATA const csXyz Zero; ~csXyz() {} csXyz() {} csXyz(s16, s16, s16); diff --git a/include/SSystem/SComponent/c_xyz.h b/include/SSystem/SComponent/c_xyz.h index 66dff18fd2..87cd6648d1 100644 --- a/include/SSystem/SComponent/c_xyz.h +++ b/include/SSystem/SComponent/c_xyz.h @@ -14,14 +14,14 @@ struct cXy { }; struct cXyz : Vec { - static const cXyz Zero; - static const cXyz BaseX; - static const cXyz BaseY; - static const cXyz BaseZ; - static const cXyz BaseXY; - static const cXyz BaseXZ; - static const cXyz BaseYZ; - static const cXyz BaseXYZ; + static DUSK_GAME_DATA const cXyz Zero; + static DUSK_GAME_DATA const cXyz BaseX; + static DUSK_GAME_DATA const cXyz BaseY; + static DUSK_GAME_DATA const cXyz BaseZ; + static DUSK_GAME_DATA const cXyz BaseXY; + static DUSK_GAME_DATA const cXyz BaseXZ; + static DUSK_GAME_DATA const cXyz BaseYZ; + static DUSK_GAME_DATA const cXyz BaseXYZ; #ifdef __MWERKS__ cXyz() {} ~cXyz() {} diff --git a/include/Z2AudioCS/SpkMixingBuffer.h b/include/Z2AudioCS/SpkMixingBuffer.h index ccdb8902b0..5cdfcd74bb 100644 --- a/include/Z2AudioCS/SpkMixingBuffer.h +++ b/include/Z2AudioCS/SpkMixingBuffer.h @@ -13,7 +13,6 @@ public: bool update(s32 chan); void bzeroBuffer(s32 chan); -private: /* 0x00 */ s16* mBuffer[4]; }; diff --git a/include/Z2AudioCS/SpkSpeakerCtrl.h b/include/Z2AudioCS/SpkSpeakerCtrl.h index 7216eed07d..372d5b1835 100644 --- a/include/Z2AudioCS/SpkSpeakerCtrl.h +++ b/include/Z2AudioCS/SpkSpeakerCtrl.h @@ -41,7 +41,6 @@ public: static bool checkRadioSensitivity(s32 chan); static bool isSubmitPlayByRadioSensitivity(s32 chan); -private: }; #endif /* Z2AUDIOCS_SPKSPEAKERCTRL_H */ diff --git a/include/Z2AudioCS/SpkSystem.h b/include/Z2AudioCS/SpkSystem.h index 05541c72e5..03b30cda6e 100644 --- a/include/Z2AudioCS/SpkSystem.h +++ b/include/Z2AudioCS/SpkSystem.h @@ -28,7 +28,6 @@ public: inline SpkData* getData(void) const { return mData; } inline SpkMixingBuffer* getMixingBuffer(void) const { return mMixingBuffer; } -private: /* 0x00 */ JKRHeap* mHeap; /* 0x04 */ SpkData* mData; /* 0x08 */ SpkMixingBuffer* mMixingBuffer; diff --git a/include/Z2AudioCS/SpkTable.h b/include/Z2AudioCS/SpkTable.h index 862fdba3c1..f2234f5a06 100644 --- a/include/Z2AudioCS/SpkTable.h +++ b/include/Z2AudioCS/SpkTable.h @@ -31,7 +31,6 @@ public: return (SpkTableParams*)mEntryOffset + num; } - // private: /* 0x00 */ bool mIsInitialized; /* 0x04 */ s32 mNumOfSound; /* 0x08 */ u32 mEntryOffset; diff --git a/include/Z2AudioCS/SpkWave.h b/include/Z2AudioCS/SpkWave.h index 6a604d8a50..72cde1c0a0 100644 --- a/include/Z2AudioCS/SpkWave.h +++ b/include/Z2AudioCS/SpkWave.h @@ -25,7 +25,6 @@ public: inline const void* getResource(void) const { return mWaveData; } inline void* getResource(void) { return mWaveData; } -private: /* 0x00 */ void* mWaveData; }; diff --git a/include/Z2AudioLib/Z2Audience.h b/include/Z2AudioLib/Z2Audience.h index 75998e878b..e6d2f7da3a 100644 --- a/include/Z2AudioLib/Z2Audience.h +++ b/include/Z2AudioLib/Z2Audience.h @@ -256,7 +256,7 @@ inline Z2Audience* Z2GetAudience() { return JASGlobalInstance::getInstance(); } -extern s8 data_80451358; -extern s8 data_80451359; +DUSK_GAME_EXTERN s8 data_80451358; +DUSK_GAME_EXTERN s8 data_80451359; #endif /* Z2AUDIENCE_H */ diff --git a/include/Z2AudioLib/Z2AudioMgr.h b/include/Z2AudioLib/Z2AudioMgr.h index 0f8e5a17ea..82fbdee7e4 100644 --- a/include/Z2AudioLib/Z2AudioMgr.h +++ b/include/Z2AudioLib/Z2AudioMgr.h @@ -34,7 +34,7 @@ public: bool isResetting() { return mResettingFlag; } static Z2AudioMgr* getInterface() { return mAudioMgrPtr; } - static Z2AudioMgr* mAudioMgrPtr; + static DUSK_GAME_DATA Z2AudioMgr* mAudioMgrPtr; /* 0x0514 */ virtual bool startSound(JAISoundID soundID, JAISoundHandle* handle, const JGeometry::TVec3* posPtr); /* 0x0518 */ bool mResettingFlag; diff --git a/include/Z2AudioLib/Z2Calc.h b/include/Z2AudioLib/Z2Calc.h index e8eee29571..ded419e9f4 100644 --- a/include/Z2AudioLib/Z2Calc.h +++ b/include/Z2AudioLib/Z2Calc.h @@ -42,8 +42,8 @@ f32 getParamByExp(f32 value, f32 inMin, f32 inMax, f32 exponent, f32 outMin, f32 f32 getRandom(f32 magnitude, f32 exponent, f32 bias); f32 getRandom_0_1(); -extern const f32 cEqualCSlope; -extern const f32 cEqualPSlope; +DUSK_GAME_EXTERN const f32 cEqualCSlope; +DUSK_GAME_EXTERN const f32 cEqualPSlope; } // namespace Z2Calc #endif /* Z2CALC_H */ diff --git a/include/Z2AudioLib/Z2Creature.h b/include/Z2AudioLib/Z2Creature.h index c4f96ca742..c17394b75f 100644 --- a/include/Z2AudioLib/Z2Creature.h +++ b/include/Z2AudioLib/Z2Creature.h @@ -67,7 +67,6 @@ public: void playVoice(int); virtual Z2SoundHandlePool* startCreatureVoice(JAISoundID soundID, s8 reverb); -private: /* 0xA0 */ s8 mCitizenID; /* 0xA1 */ s8 field_0xa1; /* 0xA2 */ bool mLinkSearch; diff --git a/include/Z2AudioLib/Z2EnvSeMgr.h b/include/Z2AudioLib/Z2EnvSeMgr.h index 464da590de..f2f4dc175a 100644 --- a/include/Z2AudioLib/Z2EnvSeMgr.h +++ b/include/Z2AudioLib/Z2EnvSeMgr.h @@ -175,7 +175,7 @@ struct Z2EnvSeMgr : public JASGlobalInstance { STATIC_ASSERT(sizeof(Z2EnvSeMgr) == 0x30C); -extern Z2EnvSeMgr g_mEnvSeMgr; +DUSK_GAME_EXTERN Z2EnvSeMgr g_mEnvSeMgr; inline Z2EnvSeMgr* Z2GetEnvSeMgr() { return JASGlobalInstance::getInstance(); diff --git a/include/Z2AudioLib/Z2LinkMgr.h b/include/Z2AudioLib/Z2LinkMgr.h index cf05ed14d9..e64c1729eb 100644 --- a/include/Z2AudioLib/Z2LinkMgr.h +++ b/include/Z2AudioLib/Z2LinkMgr.h @@ -57,13 +57,12 @@ public: void setUsingIronBall(bool isUsingIronBall) { mUsingIronBall = isUsingIronBall; } void setMarkState(u8 state) { mMarkState = state; } - static Z2CreatureLink* mLinkPtr; + static DUSK_GAME_DATA Z2CreatureLink* mLinkPtr; static Z2CreatureLink* getLink() { return mLinkPtr; } friend class Z2LinkSoundStarter; friend struct Z2RideSoundStarter; -private: /* 0x90 Z2LinkSoundStarter */ /* 0x94 */ Z2SoundObjSimple mKantera; /* 0xB4 */ Vec field_0xb4; @@ -123,7 +122,6 @@ public: virtual void deleteObject(); -private: /* 0x90 */ // Z2RideSoundStarter mSoundStarter; /* 0x98 */ bool mLinkRiding; }; // Size: 0x9C @@ -136,7 +134,6 @@ public: Z2SoundHandlePool* startFireSound(u16); Z2SoundHandlePool* startSound(JAISoundID soundID, u32 mapinfo, s8 reverb); -private: /* 0x20 */ f32 field_0x20; }; diff --git a/include/Z2AudioLib/Z2Param.h b/include/Z2AudioLib/Z2Param.h index e6c8aac993..73e8b01256 100644 --- a/include/Z2AudioLib/Z2Param.h +++ b/include/Z2AudioLib/Z2Param.h @@ -4,72 +4,72 @@ #include struct Z2Param { - static f32 DISTANCE_MAX; - static f32 MAX_VOLUME_DISTANCE; - static f32 DOLBY_CENTER_VALUE; - static f32 DOLBY_FLONT_DISTANCE_MAX; - static f32 DOLBY_BEHIND_DISTANCE_MAX; - static f32 DISTANCE_FX_PARAM; - static f32 SONIC_SPEED; - static f32 VOL_BGM_DEFAULT; - static f32 VOL_SE_SYSTEM_DEFAULT; - static f32 VOL_SE_LINK_VOICE_DEFAULT; - static f32 VOL_SE_LINK_MOTION_DEFAULT; - static f32 VOL_SE_LINK_FOOTNOTE_DEFAULT; - static f32 VOL_SE_CHAR_VOICE_DEFAULT; - static f32 VOL_SE_CHAR_MOVE_DEFAULT; - static f32 VOL_SE_OBJECT_DEFAULT; - static f32 VOL_SE_ATMOSPHERE_DEFAULT; - static f32 VOL_BGM_TALKING; - static f32 VOL_SE_SYSTEM_TALKING; - static f32 VOL_SE_LINK_VOICE_TALKING; - static f32 VOL_SE_LINK_MOTION_TALKING; - static f32 VOL_SE_LINK_FOOTNOTE_TALKING; - static f32 VOL_SE_CHAR_VOICE_TALKING; - static f32 VOL_SE_CHAR_MOVE_TALKING; - static f32 VOL_SE_OBJECT_TALKING; - static f32 VOL_SE_ATMOSPHERE_TALKING; - static f32 VOL_BGM_PAUSING; - static f32 VOL_SE_SYSTEM_PAUSING; - static f32 VOL_SE_LINK_VOICE_PAUSING; - static f32 VOL_SE_LINK_MOTION_PAUSING; - static f32 VOL_SE_LINK_FOOTNOTE_PAUSING; - static f32 VOL_SE_CHAR_VOICE_PAUSING; - static f32 VOL_SE_CHAR_MOVE_PAUSING; - static f32 VOL_SE_OBJECT_PAUSING; - static f32 VOL_SE_ATMOSPHERE_PAUSING; - static f32 MIN_DISTANCE_VOLUME; - static f32 ENEMY_LASTHIT_MUTE_VOLUME; + static DUSK_GAME_DATA f32 DISTANCE_MAX; + static DUSK_GAME_DATA f32 MAX_VOLUME_DISTANCE; + static DUSK_GAME_DATA f32 DOLBY_CENTER_VALUE; + static DUSK_GAME_DATA f32 DOLBY_FLONT_DISTANCE_MAX; + static DUSK_GAME_DATA f32 DOLBY_BEHIND_DISTANCE_MAX; + static DUSK_GAME_DATA f32 DISTANCE_FX_PARAM; + static DUSK_GAME_DATA f32 SONIC_SPEED; + static DUSK_GAME_DATA f32 VOL_BGM_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_SYSTEM_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_LINK_VOICE_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_LINK_MOTION_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_LINK_FOOTNOTE_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_VOICE_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_MOVE_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_OBJECT_DEFAULT; + static DUSK_GAME_DATA f32 VOL_SE_ATMOSPHERE_DEFAULT; + static DUSK_GAME_DATA f32 VOL_BGM_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_SYSTEM_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_VOICE_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_MOTION_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_FOOTNOTE_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_VOICE_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_MOVE_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_OBJECT_TALKING; + static DUSK_GAME_DATA f32 VOL_SE_ATMOSPHERE_TALKING; + static DUSK_GAME_DATA f32 VOL_BGM_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_SYSTEM_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_VOICE_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_MOTION_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_LINK_FOOTNOTE_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_VOICE_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_CHAR_MOVE_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_OBJECT_PAUSING; + static DUSK_GAME_DATA f32 VOL_SE_ATMOSPHERE_PAUSING; + static DUSK_GAME_DATA f32 MIN_DISTANCE_VOLUME; + static DUSK_GAME_DATA f32 ENEMY_LASTHIT_MUTE_VOLUME; // made up names based on HIO labels - static u8 SCENE_CHANGE_BGM_FADEOUT_TIME; - static u8 BGM_CROSS_FADEIN_TIME; - static u8 BGM_CROSS_FADEOUT_TIME; - static u8 BATTLE_BGM_WAIT_TIME; + static DUSK_GAME_DATA u8 SCENE_CHANGE_BGM_FADEOUT_TIME; + static DUSK_GAME_DATA u8 BGM_CROSS_FADEIN_TIME; + static DUSK_GAME_DATA u8 BGM_CROSS_FADEOUT_TIME; + static DUSK_GAME_DATA u8 BATTLE_BGM_WAIT_TIME; static f32 ENEMY_NEARBY_DIST; static f32 BATTLE_FADEIN_DIST; static f32 BATTLE_FADEOUT_DIST; - static u8 FOUND_TRACK_FI_TIME; - static u8 FOUND_TRACK_FO_TIME; - static u8 CLOSE_BATTLE_TRACK_FI_TIME; - static u8 CLOSE_BATTLE_TRACK_FO_TIME; + static DUSK_GAME_DATA u8 FOUND_TRACK_FI_TIME; + static DUSK_GAME_DATA u8 FOUND_TRACK_FO_TIME; + static DUSK_GAME_DATA u8 CLOSE_BATTLE_TRACK_FI_TIME; + static DUSK_GAME_DATA u8 CLOSE_BATTLE_TRACK_FO_TIME; - static u8 ENDING_BLOW_VOL_DOWN_TIME; - static u8 ENDING_BLOW_VOL_LOWER_TIME; - static u8 ENDING_BLOW_VOL_LOWER_RECOVER_TIME; - static u8 ENDING_BLOW_MIN_FINISH_TIME; + static DUSK_GAME_DATA u8 ENDING_BLOW_VOL_DOWN_TIME; + static DUSK_GAME_DATA u8 ENDING_BLOW_VOL_LOWER_TIME; + static DUSK_GAME_DATA u8 ENDING_BLOW_VOL_LOWER_RECOVER_TIME; + static DUSK_GAME_DATA u8 ENDING_BLOW_MIN_FINISH_TIME; - static u8 DARK_SE_FILTER_ON; - static u8 DARK_SE_LOW_PASS_FILTER_SETTING; - static u8 SYSTEM_SE_USE_DARK_SE_SETTING; + static DUSK_GAME_DATA u8 DARK_SE_FILTER_ON; + static DUSK_GAME_DATA u8 DARK_SE_LOW_PASS_FILTER_SETTING; + static DUSK_GAME_DATA u8 SYSTEM_SE_USE_DARK_SE_SETTING; static f32 AUDIBLE_DELTA_RANGE_VOLUME; static f32 AUDIBLE_DELTA_RANGE_PAN; static f32 AUDIBLE_DELTA_RANGE_DOLBY; }; -extern u8 data_8045086C; +DUSK_GAME_EXTERN u8 data_8045086C; #endif /* Z2PARAM_H */ diff --git a/include/Z2AudioLib/Z2SceneMgr.h b/include/Z2AudioLib/Z2SceneMgr.h index 1b3ef2cc0b..739c53bb10 100644 --- a/include/Z2AudioLib/Z2SceneMgr.h +++ b/include/Z2AudioLib/Z2SceneMgr.h @@ -47,7 +47,6 @@ public: s32 getBgmLoadStatus(u32 wave) { return getWaveLoadStatus(wave, 1); } u8 getDemoSeWaveNum() { return loadedDemoWave; } -private: /* 0x00 */ JAISoundID BGM_ID; /* 0x04 */ int sceneNum; /* 0x08 */ int timer; diff --git a/include/Z2AudioLib/Z2SeMgr.h b/include/Z2AudioLib/Z2SeMgr.h index 3f8ca03eb3..7075308ef7 100644 --- a/include/Z2AudioLib/Z2SeMgr.h +++ b/include/Z2AudioLib/Z2SeMgr.h @@ -84,7 +84,6 @@ public: void homeMenuSeCallback(s32); #endif -private: /* 0x000 */ JAISoundHandle mSoundHandle[24]; /* 0x060 */ JAISoundHandles mSoundHandles; #if VERSION >= VERSION_WII_USA_R0 diff --git a/include/Z2AudioLib/Z2SoundHandles.h b/include/Z2AudioLib/Z2SoundHandles.h index 5915e5967b..1ad344c796 100644 --- a/include/Z2AudioLib/Z2SoundHandles.h +++ b/include/Z2AudioLib/Z2SoundHandles.h @@ -44,7 +44,6 @@ public: return (Z2SoundHandlePool*)getNth(index); } -private: /* 0xC */ u8 handleNum_; }; diff --git a/include/Z2AudioLib/Z2SoundMgr.h b/include/Z2AudioLib/Z2SoundMgr.h index cd6341b2cb..eabf9d2614 100644 --- a/include/Z2AudioLib/Z2SoundMgr.h +++ b/include/Z2AudioLib/Z2SoundMgr.h @@ -38,7 +38,6 @@ public: const JAISeqMgr* getSeqMgr() const { return &seqMgr_; } JAIStreamMgr* getStreamMgr() { return &streamMgr_; } -private: /* 0x004 */ JAISeMgr seMgr_; /* 0x728 */ JAISeqMgr seqMgr_; /* 0x79C */ JAIStreamMgr streamMgr_; diff --git a/include/Z2AudioLib/Z2SoundObjMgr.h b/include/Z2AudioLib/Z2SoundObjMgr.h index 687f9eaf0a..64bf058ba1 100644 --- a/include/Z2AudioLib/Z2SoundObjMgr.h +++ b/include/Z2AudioLib/Z2SoundObjMgr.h @@ -104,7 +104,6 @@ public: JSUList* getAllList() { return &allList_; } #endif -private: /* 0x00 */ JSUList field_0x0; #if PARTIAL_DEBUG || DEBUG /* 0x0C */ JSUList allList_; diff --git a/include/Z2AudioLib/Z2WolfHowlMgr.h b/include/Z2AudioLib/Z2WolfHowlMgr.h index 10b746a4c1..5376499715 100644 --- a/include/Z2AudioLib/Z2WolfHowlMgr.h +++ b/include/Z2AudioLib/Z2WolfHowlMgr.h @@ -70,7 +70,6 @@ public: u8 getReleaseTimer() { return mReleaseTimer; } u8 getCorrectCurveID() { return mCorrectCurveID; } -private: /* 0x00 */ JAISoundHandle mWolfHowlHandle; /* 0x04 */ JAISoundHandle mWindStoneHandle; /* 0x08 */ JAISoundHandle mGuideHandle; diff --git a/include/c/c_damagereaction.h b/include/c/c_damagereaction.h index e2c8bfe051..56b54825b7 100644 --- a/include/c/c_damagereaction.h +++ b/include/c/c_damagereaction.h @@ -12,18 +12,18 @@ public: BOOL cDmrNowMidnaTalk(); -extern u8 cDmr_SkipInfo; -extern u8 data_80450C99; -extern u8 data_80450C9A; -extern u8 data_80450C9B; -extern u8 data_80450C9C; -extern u8 data_80450C9D; -extern u8 data_80450C9E; -extern u8 cDmr_FishingWether; -extern u8 data_80450CA0; +DUSK_GAME_EXTERN u8 cDmr_SkipInfo; +DUSK_GAME_EXTERN u8 data_80450C99; +DUSK_GAME_EXTERN u8 data_80450C9A; +DUSK_GAME_EXTERN u8 data_80450C9B; +DUSK_GAME_EXTERN u8 data_80450C9C; +DUSK_GAME_EXTERN u8 data_80450C9D; +DUSK_GAME_EXTERN u8 data_80450C9E; +DUSK_GAME_EXTERN u8 cDmr_FishingWether; +DUSK_GAME_EXTERN u8 data_80450CA0; extern "C" { - extern JPTraceParticleCallBack4 JPTracePCB4; + DUSK_GAME_EXTERN JPTraceParticleCallBack4 JPTracePCB4; } void debug_actor_create(); diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index a1d78c6116..a0b70747bc 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -57,8 +57,8 @@ public: void setNowOffsetX(f32 i_offset) { mNowOffsetX = i_offset; } void setNowOffsetY(f32 i_offset) { mNowOffsetY = i_offset; } - static bool m_eye_move_flg; - static u8 m_morf_frame; + static DUSK_GAME_DATA bool m_eye_move_flg; + static DUSK_GAME_DATA u8 m_morf_frame; /* 0x0F4 */ mutable f32 field_0xf4; /* 0x0F8 */ mutable f32 field_0xf8; @@ -77,7 +77,6 @@ public: virtual void draw(); virtual ~daAlink_blur_c() {} - // private: /* 0x010 */ ResTIMG* m_blurTex; /* 0x014 */ int field_0x14; /* 0x018 */ u8 field_0x18[4]; @@ -113,7 +112,6 @@ public: void onAppearFlg() { mAppearFlg = true; } -private: /* 0x04 */ s16 mHitFlg; /* 0x06 */ s16 mAppearFlg; /* 0x08 */ f32 mKeepMinY; @@ -3913,20 +3911,20 @@ public: static u32 getOtherHeapSize() { return 0xF0A60; } - static daAlink_BckData const m_mainBckShield[20]; - static daAlink_BckData const m_mainBckSword[5]; - static daAlink_BckData const m_mainBckFishing[28]; - static daAlink_AnmData const m_anmDataTable[ANM_MAX]; - static daAlink_WlAnmData const m_wlAnmDataTable[WANM_MAX]; - static daAlink_FaceTexData const m_faceTexDataTable[]; - static Vec const m_handLeftOutSidePos; - static Vec const m_handRightOutSidePos; - static Vec const m_handLeftInSidePos; - static Vec const m_handRightInSidePos; + static DUSK_GAME_DATA daAlink_BckData const m_mainBckShield[20]; + static DUSK_GAME_DATA daAlink_BckData const m_mainBckSword[5]; + static DUSK_GAME_DATA daAlink_BckData const m_mainBckFishing[28]; + static DUSK_GAME_DATA daAlink_AnmData const m_anmDataTable[ANM_MAX]; + static DUSK_GAME_DATA daAlink_WlAnmData const m_wlAnmDataTable[WANM_MAX]; + static DUSK_GAME_DATA daAlink_FaceTexData const m_faceTexDataTable[]; + static DUSK_GAME_DATA Vec const m_handLeftOutSidePos; + static DUSK_GAME_DATA Vec const m_handRightOutSidePos; + static DUSK_GAME_DATA Vec const m_handLeftInSidePos; + static DUSK_GAME_DATA Vec const m_handRightInSidePos; - static const daAlink_procInitTable m_procInitTable[]; - static daAlink_procFunc m_demoInitTable[]; - static const EffParamProc m_fEffParamProc[]; + static DUSK_GAME_DATA const daAlink_procInitTable m_procInitTable[]; + static DUSK_GAME_DATA daAlink_procFunc m_demoInitTable[]; + static DUSK_GAME_DATA const EffParamProc m_fEffParamProc[]; /* 0x0062C */ request_of_phase_process_class mPhaseReq; /* 0x00634 */ const char* mArcName; @@ -4558,30 +4556,8 @@ public: bool checkAimContext(); bool checkAimInputContext(); - void onIronBallChainInterpCallback(); - - static const int IRON_BALL_CHAIN_COUNT = 102; - cXyz mIBChainInterpPrevPos[IRON_BALL_CHAIN_COUNT]; - cXyz mIBChainInterpCurrPos[IRON_BALL_CHAIN_COUNT]; - csXyz mIBChainInterpPrevAngle[IRON_BALL_CHAIN_COUNT]; - csXyz mIBChainInterpCurrAngle[IRON_BALL_CHAIN_COUNT]; - cXyz mIBChainInterpPrevHandRoot; - cXyz mIBChainInterpCurrHandRoot; - bool mIBChainInterpPrevValid; - bool mIBChainInterpCurrValid; - - cXyz mHsChainInterpPrevTop; - cXyz mHsChainInterpCurrTop; - cXyz mHsChainInterpPrevRoot; - cXyz mHsChainInterpCurrRoot; - cXyz mHsChainInterpPrevSubRoot; - cXyz mHsChainInterpCurrSubRoot; - cXyz mHsChainInterpPrevSubTop; - cXyz mHsChainInterpCurrSubTop; - bool mHsChainInterpPrevValid; - bool mHsChainInterpCurrValid; - bool mIsRollstab = false; + void* mAnmBuffers[3] = {}; #endif }; // Size: 0x385C @@ -4649,7 +4625,7 @@ struct daAlinkHIO_basic_c1 { class daAlinkHIO_basic_c0 { public: - static daAlinkHIO_basic_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_basic_c1 const m; }; class daAlinkHIO_basic_c : public daAlinkHIO_data_c { @@ -4700,7 +4676,7 @@ public: class daAlinkHIO_move_c0 { public: - static daAlinkHIO_move_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_move_c1 const m; }; class daAlinkHIO_move_c : public daAlinkHIO_data_c { @@ -4746,7 +4722,7 @@ public: class daAlinkHIO_atnMove_c0 { public: - static daAlinkHIO_atnMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_atnMove_c1 const m; }; class daAlinkHIO_atnMove_c : public daAlinkHIO_data_c { @@ -4792,7 +4768,7 @@ public: class daAlinkHIO_noActAtnMove_c0 { public: - static daAlinkHIO_noActAtnMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_noActAtnMove_c1 const m; }; class daAlinkHIO_noActAtnMove_c : public daAlinkHIO_data_c { @@ -4834,7 +4810,7 @@ public: class daAlinkHIO_frontRoll_c0 { public: - static daAlinkHIO_frontRoll_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_frontRoll_c1 const m; }; class daAlinkHIO_frontRoll_c : public daAlinkHIO_data_c { @@ -4864,7 +4840,7 @@ public: class daAlinkHIO_backJump_c0 { public: - static daAlinkHIO_backJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_backJump_c1 const m; }; class daAlinkHIO_backJump_c : public daAlinkHIO_data_c { @@ -4898,7 +4874,7 @@ public: class daAlinkHIO_sideStep_c0 { public: - static daAlinkHIO_sideStep_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_sideStep_c1 const m; }; class daAlinkHIO_sideStep_c : public daAlinkHIO_data_c { @@ -4936,7 +4912,7 @@ public: class daAlinkHIO_slide_c0 { public: - static daAlinkHIO_slide_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_slide_c1 const m; }; class daAlinkHIO_slide_c : public daAlinkHIO_data_c { @@ -4964,27 +4940,27 @@ public: class daAlinkHIO_cutNmV_c0 { public: - static daAlinkHIO_cutNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutNormal_c1 const m; }; class daAlinkHIO_cutNmL_c0 { public: - static daAlinkHIO_cutNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutNormal_c1 const m; }; class daAlinkHIO_cutNmR_c0 { public: - static daAlinkHIO_cutNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutNormal_c1 const m; }; class daAlinkHIO_cutNmSL_c0 { public: - static daAlinkHIO_cutNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutNormal_c1 const m; }; class daAlinkHIO_cutNmSR_c0 { public: - static daAlinkHIO_cutNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutNormal_c1 const m; }; class daAlinkHIO_cutNormal_c : public daAlinkHIO_data_c { @@ -5015,32 +4991,32 @@ public: class daAlinkHIO_cutFnL_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFnV_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFnS_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFnSl_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFnSm_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFnR_c0 { public: - static daAlinkHIO_cutFinish_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFinish_c1 const m; }; class daAlinkHIO_cutFinish_c : public daAlinkHIO_data_c { @@ -5077,7 +5053,7 @@ public: class daAlinkHIO_cutFnJU_c0 { public: - static daAlinkHIO_cutFnJU_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutFnJU_c1 const m; }; class daAlinkHIO_cutFnJU_c : public daAlinkHIO_data_c { @@ -5104,17 +5080,17 @@ public: class daAlinkHIO_cutDaL_c0 { public: - static daAlinkHIO_cutDash_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutDash_c1 const m; }; class daAlinkHIO_cutDaR_c0 { public: - static daAlinkHIO_cutDash_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutDash_c1 const m; }; class daAlinkHIO_cutDaCharge_c0 { public: - static daAlinkHIO_cutDash_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutDash_c1 const m; }; class daAlinkHIO_cutDash_c : public daAlinkHIO_data_c { @@ -5146,7 +5122,7 @@ public: class daAlinkHIO_cutJump_c0 { public: - static daAlinkHIO_cutJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutJump_c1 const m; }; class daAlinkHIO_cutJump_c : public daAlinkHIO_data_c { @@ -5197,7 +5173,7 @@ public: class daAlinkHIO_cutTurn_c0 { public: - static daAlinkHIO_cutTurn_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutTurn_c1 const m; }; class daAlinkHIO_cutTurn_c : public daAlinkHIO_data_c { @@ -5225,22 +5201,22 @@ public: class daAlinkHIO_hoCutLA_c0 { public: - static daAlinkHIO_hoCut_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hoCut_c1 const m; }; class daAlinkHIO_hoCutLB_c0 { public: - static daAlinkHIO_hoCut_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hoCut_c1 const m; }; class daAlinkHIO_hoCutRA_c0 { public: - static daAlinkHIO_hoCut_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hoCut_c1 const m; }; class daAlinkHIO_hoCutRB_c0 { public: - static daAlinkHIO_hoCut_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hoCut_c1 const m; }; class daAlinkHIO_hoCut_c : public daAlinkHIO_data_c { @@ -5273,7 +5249,7 @@ public: class daAlinkHIO_hoCutCharge_c0 { public: - static daAlinkHIO_hoCutCharge_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hoCutCharge_c1 const m; }; class daAlinkHIO_hoCutCharge_c : public daAlinkHIO_data_c { @@ -5307,7 +5283,7 @@ public: class daAlinkHIO_cutDown_c0 { public: - static daAlinkHIO_cutDown_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutDown_c1 const m; }; class daAlinkHIO_cutDown_c : public daAlinkHIO_data_c { @@ -5343,7 +5319,7 @@ public: class daAlinkHIO_cutHead_c0 { public: - static daAlinkHIO_cutHead_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutHead_c1 const m; }; class daAlinkHIO_cutHead_c : public daAlinkHIO_data_c { @@ -5380,7 +5356,7 @@ public: class daAlinkHIO_cutLargeJump_c0 { public: - static daAlinkHIO_cutLargeJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cutLargeJump_c1 const m; }; class daAlinkHIO_cutLargeJump_c : public daAlinkHIO_data_c { @@ -5457,7 +5433,7 @@ public: static daAlinkHIO_cutDown_c0 const mCutDown; static daAlinkHIO_cutHead_c0 const mCutHead; static daAlinkHIO_cutLargeJump_c0 const mCutLargeJump; - static daAlinkHIO_cut_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_cut_c1 const m; }; class daAlinkHIO_cut_c : public daAlinkHIO_data_c { @@ -5513,12 +5489,12 @@ public: class daAlinkHIO_gAtPush_c0 { public: - static daAlinkHIO_guardAttack_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_guardAttack_c1 const m; }; class daAlinkHIO_gAtKick_c0 { public: - static daAlinkHIO_guardAttack_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_guardAttack_c1 const m; }; class daAlinkHIO_guardAttack_c : public daAlinkHIO_data_c { @@ -5550,7 +5526,7 @@ public: class daAlinkHIO_turnMove_c0 { public: - static daAlinkHIO_turnMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_turnMove_c1 const m; }; class daAlinkHIO_turnMove_c : public daAlinkHIO_data_c { @@ -5595,7 +5571,7 @@ public: static daAlinkHIO_gAtPush_c0 const mAtPush; static daAlinkHIO_gAtKick_c0 const mAtKick; static daAlinkHIO_turnMove_c0 const mTurnMove; - static daAlinkHIO_guard_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_guard_c1 const m; }; class daAlinkHIO_guard_c : public daAlinkHIO_data_c { @@ -5634,7 +5610,7 @@ public: class daAlinkHIO_crouch_c0 { public: - static daAlinkHIO_crouch_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_crouch_c1 const m; }; class daAlinkHIO_crouch_c : public daAlinkHIO_data_c { @@ -5689,7 +5665,7 @@ public: class daAlinkHIO_autoJump_c0 { public: - static daAlinkHIO_autoJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_autoJump_c1 const m; }; class daAlinkHIO_autoJump_c : public daAlinkHIO_data_c { @@ -5719,7 +5695,7 @@ public: class daAlinkHIO_smallJump_c0 { public: - static daAlinkHIO_smallJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_smallJump_c1 const m; }; class daAlinkHIO_smallJump_c : public daAlinkHIO_data_c { @@ -5748,7 +5724,7 @@ public: class daAlinkHIO_wallCatch_c0 { public: - static daAlinkHIO_wallCatch_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wallCatch_c1 const m; }; class daAlinkHIO_wallCatch_c : public daAlinkHIO_data_c { @@ -5774,7 +5750,7 @@ public: class daAlinkHIO_wallFall_c0 { public: - static daAlinkHIO_wallFall_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wallFall_c1 const m; }; class daAlinkHIO_wallFall_c : public daAlinkHIO_data_c { @@ -5803,7 +5779,7 @@ public: class daAlinkHIO_wallMove_c0 { public: - static daAlinkHIO_wallMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wallMove_c1 const m; }; class daAlinkHIO_wallMove_c : public daAlinkHIO_data_c { @@ -5839,7 +5815,7 @@ public: static daAlinkHIO_wallCatch_c0 const mWallCatch; static daAlinkHIO_wallFall_c0 const mWallFall; static daAlinkHIO_wallMove_c0 const mWallMove; - static daAlinkHIO_wallHang_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wallHang_c1 const m; }; class daAlinkHIO_wallHang_c : public daAlinkHIO_data_c { @@ -5886,7 +5862,7 @@ public: class daAlinkHIO_pushpull_c0 { public: - static daAlinkHIO_pushpull_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_pushpull_c1 const m; }; class daAlinkHIO_pushpull_c : public daAlinkHIO_data_c { @@ -5920,7 +5896,7 @@ public: class daAlinkHIO_damNormal_c0 { public: - static daAlinkHIO_damNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damNormal_c1 const m; }; class daAlinkHIO_damNormal_c : public daAlinkHIO_data_c { @@ -5959,12 +5935,12 @@ public: class daAlinkHIO_damLarge_c0 { public: - static daAlinkHIO_damLaHu_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damLaHu_c1 const m; }; class daAlinkHIO_damHuge_c0 { public: - static daAlinkHIO_damLaHu_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damLaHu_c1 const m; }; class daAlinkHIO_damLaHu_c : public daAlinkHIO_data_c { @@ -5992,7 +5968,7 @@ public: class daAlinkHIO_damHorse_c0 { public: - static daAlinkHIO_damHorse_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damHorse_c1 const m; }; class daAlinkHIO_damHorse_c : public daAlinkHIO_data_c { @@ -6027,7 +6003,7 @@ public: class daAlinkHIO_damFall_c0 { public: - static daAlinkHIO_damFall_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damFall_c1 const m; }; class daAlinkHIO_damFall_c : public daAlinkHIO_data_c { @@ -6057,7 +6033,7 @@ public: class daAlinkHIO_damCaught_c0 { public: - static daAlinkHIO_damCaught_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damCaught_c1 const m; }; class daAlinkHIO_damCaught_c : public daAlinkHIO_data_c { @@ -6093,7 +6069,7 @@ public: class daAlinkHIO_damSwim_c0 { public: - static daAlinkHIO_damSwim_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damSwim_c1 const m; }; class daAlinkHIO_damSwim_c : public daAlinkHIO_data_c { @@ -6140,7 +6116,7 @@ public: class daAlinkHIO_damage_c0 { public: - static daAlinkHIO_damage_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_damage_c1 const m; static daAlinkHIO_damNormal_c0 const mDamNormal; static daAlinkHIO_damLarge_c0 const mDamLarge; static daAlinkHIO_damHuge_c0 const mDamHuge; @@ -6192,7 +6168,7 @@ public: class daAlinkHIO_horse_c0 { public: - static daAlinkHIO_horse_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_horse_c1 const m; }; class daAlinkHIO_horse_c : public daAlinkHIO_data_c { @@ -6231,7 +6207,7 @@ public: class daAlinkHIO_canoe_c0 { public: - static daAlinkHIO_canoe_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_canoe_c1 const m; }; class daAlinkHIO_canoe_c : public daAlinkHIO_data_c { @@ -6276,7 +6252,7 @@ public: class daAlinkHIO_bow_c0 { public: - static daAlinkHIO_bow_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_bow_c1 const m; }; class daAlinkHIO_bow_c : public daAlinkHIO_data_c { @@ -6312,7 +6288,7 @@ public: class daAlinkHIO_boom_c0 { public: - static daAlinkHIO_boom_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_boom_c1 const m; }; class daAlinkHIO_boom_c : public daAlinkHIO_data_c { @@ -6356,7 +6332,7 @@ public: class daAlinkHIO_bomb_c0 { public: - static daAlinkHIO_bomb_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_bomb_c1 const m; }; class daAlinkHIO_bomb_c : public daAlinkHIO_data_c { @@ -6391,7 +6367,7 @@ public: class daAlinkHIO_huLight_c0 { public: - static daAlinkHIO_huLight_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_huLight_c1 const m; }; class daAlinkHIO_wlLight_c1 { @@ -6410,7 +6386,7 @@ public: class daAlinkHIO_wlLight_c0 { public: - static daAlinkHIO_wlLight_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlLight_c1 const m; }; class daAlinkHIO_zwLight_c1 { // may be wrong @@ -6429,7 +6405,7 @@ public: class daAlinkHIO_zwLight_c0 { public: - static daAlinkHIO_zwLight_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_zwLight_c1 const m; }; class daAlinkHIO_light_c : public daAlinkHIO_data_c { @@ -6465,7 +6441,7 @@ public: class daAlinkHIO_kandelaar_c0 { public: - static daAlinkHIO_kandelaar_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_kandelaar_c1 const m; }; class daAlinkHIO_kandelaar_c : public daAlinkHIO_data_c { @@ -6504,7 +6480,7 @@ public: class daAlinkHIO_magneBoots_c0 { public: - static daAlinkHIO_magneBoots_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_magneBoots_c1 const m; }; class daAlinkHIO_magneBoots_c : public daAlinkHIO_data_c { @@ -6530,7 +6506,7 @@ public: class daAlinkHIO_fmChain_c0 { public: - static daAlinkHIO_fmChain_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_fmChain_c1 const m; }; class daAlinkHIO_fmChain_c : public daAlinkHIO_data_c { @@ -6570,7 +6546,7 @@ public: class daAlinkHIO_hookshot_c0 { public: - static daAlinkHIO_hookshot_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_hookshot_c1 const m; }; class daAlinkHIO_hookshot_c : public daAlinkHIO_data_c { @@ -6608,7 +6584,7 @@ public: class daAlinkHIO_spinner_c0 { public: - static daAlinkHIO_spinner_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_spinner_c1 const m; }; class daAlinkHIO_spinner_c : public daAlinkHIO_data_c { @@ -6664,7 +6640,7 @@ public: class daAlinkHIO_ironBall_c0 { public: - static daAlinkHIO_ironBall_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_ironBall_c1 const m; }; class daAlinkHIO_ironBall_c : public daAlinkHIO_data_c { @@ -6694,7 +6670,7 @@ public: class daAlinkHIO_copyRod_c0 { public: - static daAlinkHIO_copyRod_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_copyRod_c1 const m; }; class daAlinkHIO_copyRod_c : public daAlinkHIO_data_c { @@ -6722,7 +6698,7 @@ public: class daAlinkHIO_pickUp_c0 { public: - static daAlinkHIO_pickUp_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_pickUp_c1 const m; }; class daAlinkHIO_pickUp_c : public daAlinkHIO_data_c { @@ -6769,7 +6745,7 @@ public: class daAlinkHIO_board_c0 { public: - static daAlinkHIO_board_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_board_c1 const m; }; class daAlinkHIO_board_c : public daAlinkHIO_data_c { @@ -6802,7 +6778,7 @@ public: class daAlinkHIO_bottle_c0 { public: - static daAlinkHIO_bottle_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_bottle_c1 const m; }; class daAlinkHIO_bottle_c : public daAlinkHIO_data_c { @@ -6850,7 +6826,7 @@ public: static daAlinkHIO_ironBall_c0 const mIronBall; static daAlinkHIO_copyRod_c0 const mCopyRod; static daAlinkHIO_zwLight_c0 const mZoraArmorPL; - static daAlinkHIO_item_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_item_c1 const m; }; class daAlinkHIO_item_c : public daAlinkHIO_data_c { @@ -6909,7 +6885,7 @@ public: class daAlinkHIO_ladder_c0 { public: - static daAlinkHIO_ladder_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_ladder_c1 const m; }; class daAlinkHIO_ladder_c : public daAlinkHIO_data_c { @@ -6949,7 +6925,7 @@ public: class daAlinkHIO_roofHang_c0 { public: - static daAlinkHIO_roofHang_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_roofHang_c1 const m; }; class daAlinkHIO_roofHang_c : public daAlinkHIO_data_c { @@ -6987,7 +6963,7 @@ public: class daAlinkHIO_grab_c0 { public: - static daAlinkHIO_grab_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_grab_c1 const m; }; class daAlinkHIO_grab_c : public daAlinkHIO_data_c { @@ -7062,7 +7038,7 @@ public: class daAlinkHIO_swim_c0 { public: - static daAlinkHIO_swim_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_swim_c1 const m; }; class daAlinkHIO_swim_c : public daAlinkHIO_data_c { @@ -7138,7 +7114,7 @@ public: class daAlinkHIO_wlMove_c0 { public: - static daAlinkHIO_wlMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlMove_c1 const m; }; class daAlinkHIO_wlMove_c : public daAlinkHIO_data_c { @@ -7181,7 +7157,7 @@ public: class daAlinkHIO_wlMoveNoP_c0 { public: - static daAlinkHIO_wlMoveNoP_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlMoveNoP_c1 const m; }; class daAlinkHIO_wlMoveNoP_c : public daAlinkHIO_data_c { @@ -7220,7 +7196,7 @@ public: class daAlinkHIO_wlAtnMove_c0 { public: - static daAlinkHIO_wlAtnMove_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtnMove_c1 const m; }; class daAlinkHIO_wlAtnMove_c : public daAlinkHIO_data_c { @@ -7252,7 +7228,7 @@ public: class daAlinkHIO_wlHowl_c0 { public: - static daAlinkHIO_wlHowl_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlHowl_c1 const m; }; class daAlinkHIO_wlHowl_c : public daAlinkHIO_data_c { @@ -7286,7 +7262,7 @@ public: class daAlinkHIO_wlSideStep_c0 { public: - static daAlinkHIO_wlSideStep_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlSideStep_c1 const m; }; class daAlinkHIO_wlSideStep_c : public daAlinkHIO_data_c { @@ -7316,7 +7292,7 @@ public: class daAlinkHIO_wlBackJump_c0 { public: - static daAlinkHIO_wlBackJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlBackJump_c1 const m; }; class daAlinkHIO_wlBackJump_c : public daAlinkHIO_data_c { @@ -7361,7 +7337,7 @@ public: class daAlinkHIO_wlAutoJump_c0 { public: - static daAlinkHIO_wlAutoJump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAutoJump_c1 const m; }; class daAlinkHIO_wlAutoJump_c : public daAlinkHIO_data_c { @@ -7390,7 +7366,7 @@ public: class daAlinkHIO_wlPush_c0 { public: - static daAlinkHIO_wlPush_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlPush_c1 const m; }; class daAlinkHIO_wlPush_c : public daAlinkHIO_data_c { @@ -7426,7 +7402,7 @@ public: class daAlinkHIO_wlLie_c0 { public: - static daAlinkHIO_wlLie_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlLie_c1 const m; }; class daAlinkHIO_wlLie_c : public daAlinkHIO_data_c { @@ -7465,7 +7441,7 @@ public: class daAlinkHIO_wlWallHang_c0 { public: - static daAlinkHIO_wlWallHang_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlWallHang_c1 const m; }; class daAlinkHIO_wlWallHang_c : public daAlinkHIO_data_c { @@ -7497,7 +7473,7 @@ public: class daAlinkHIO_wlDamNormal_c0 { public: - static daAlinkHIO_wlDamNormal_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamNormal_c1 const m; }; class daAlinkHIO_wlDamNormal_c : public daAlinkHIO_data_c { @@ -7532,12 +7508,12 @@ public: class daAlinkHIO_wlDamLarge_c0 { public: - static daAlinkHIO_wlDamLaHu_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamLaHu_c1 const m; }; class daAlinkHIO_wlDamHuge_c0 { public: - static daAlinkHIO_wlDamLaHu_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamLaHu_c1 const m; }; class daAlinkHIO_wlDamLaHu_c : public daAlinkHIO_data_c { @@ -7566,7 +7542,7 @@ public: class daAlinkHIO_wlDamCaught_c0 { public: - static daAlinkHIO_wlDamCaught_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamCaught_c1 const m; }; class daAlinkHIO_wlDamCaught_c : public daAlinkHIO_data_c { @@ -7599,7 +7575,7 @@ public: class daAlinkHIO_wlDamFall_c0 { public: - static daAlinkHIO_wlDamFall_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamFall_c1 const m; }; class daAlinkHIO_wlDamFall_c : public daAlinkHIO_data_c { @@ -7626,7 +7602,7 @@ public: class daAlinkHIO_wlDamage_c0 { public: - static daAlinkHIO_wlDamage_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlDamage_c1 const m; static daAlinkHIO_wlDamNormal_c0 const mNormal; static daAlinkHIO_wlDamLarge_c0 const mLarge; static daAlinkHIO_wlDamHuge_c0 const mHuge; @@ -7676,7 +7652,7 @@ public: class daAlinkHIO_wlSlide_c0 { public: - static daAlinkHIO_wlSlide_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlSlide_c1 const m; }; class daAlinkHIO_wlSlide_c : public daAlinkHIO_data_c { @@ -7711,7 +7687,7 @@ public: class daAlinkHIO_wlRope_c0 { public: - static daAlinkHIO_wlRope_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlRope_c1 const m; }; class daAlinkHIO_wlRope_c : public daAlinkHIO_data_c { @@ -7747,17 +7723,17 @@ public: class daAlinkHIO_wlAtWaTl_c0 { public: - static daAlinkHIO_wlAtWait_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtWait_c1 const m; }; class daAlinkHIO_wlAtWaSc_c0 { public: - static daAlinkHIO_wlAtWait_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtWait_c1 const m; }; class daAlinkHIO_wlAtWaLr_c0 { public: - static daAlinkHIO_wlAtWait_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtWait_c1 const m; }; class daAlinkHIO_wlAtWait_c : public daAlinkHIO_data_c { @@ -7784,7 +7760,7 @@ public: class daAlinkHIO_wlAtRoll_c0 { public: - static daAlinkHIO_wlAtRoll_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtRoll_c1 const m; }; class daAlinkHIO_wlAtRoll_c : public daAlinkHIO_data_c { @@ -7819,7 +7795,7 @@ public: class daAlinkHIO_wlAtNjump_c0 { public: - static daAlinkHIO_wlAtNjump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtNjump_c1 const m; }; class daAlinkHIO_wlAtNjump_c : public daAlinkHIO_data_c { @@ -7860,7 +7836,7 @@ public: class daAlinkHIO_wlAtCjump_c0 { public: - static daAlinkHIO_wlAtCjump_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtCjump_c1 const m; }; class daAlinkHIO_wlAtCjump_c : public daAlinkHIO_data_c { @@ -7888,7 +7864,7 @@ public: class daAlinkHIO_wlAtLand_c0 { public: - static daAlinkHIO_wlAtLand_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtLand_c1 const m; }; class daAlinkHIO_wlAtLand_c : public daAlinkHIO_data_c { @@ -7924,7 +7900,7 @@ public: class daAlinkHIO_wlAtDown_c0 { public: - static daAlinkHIO_wlAtDown_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtDown_c1 const m; }; class daAlinkHIO_wlAtDown_c : public daAlinkHIO_data_c { @@ -7961,7 +7937,7 @@ public: class daAlinkHIO_wlAtLock_c0 { public: - static daAlinkHIO_wlAtLock_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtLock_c1 const m; }; class daAlinkHIO_wlAtLock_c : public daAlinkHIO_data_c { @@ -8001,7 +7977,7 @@ public: class daAlinkHIO_wlAtBite_c0 { public: - static daAlinkHIO_wlAtBite_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAtBite_c1 const m; }; class daAlinkHIO_wlAtBite_c : public daAlinkHIO_data_c { @@ -8046,7 +8022,7 @@ public: static daAlinkHIO_wlAtDown_c0 const mWlAtDown; static daAlinkHIO_wlAtLock_c0 const mWlAtLock; static daAlinkHIO_wlAtBite_c0 const mWlAtBite; - static daAlinkHIO_wlAttack_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlAttack_c1 const m; }; class daAlinkHIO_wlAttack_c : public daAlinkHIO_data_c { @@ -8093,7 +8069,7 @@ public: class daAlinkHIO_wlPoint_c0 { public: - static daAlinkHIO_wlPoint_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlPoint_c1 const m; }; class daAlinkHIO_wlPoint_c : public daAlinkHIO_data_c { @@ -8129,7 +8105,7 @@ public: class daAlinkHIO_wlChain_c0 { public: - static daAlinkHIO_wlChain_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlChain_c1 const m; }; class daAlinkHIO_wlChain_c : public daAlinkHIO_data_c { @@ -8186,7 +8162,7 @@ public: class daAlinkHIO_wlSwim_c0 { public: - static daAlinkHIO_wlSwim_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlSwim_c1 const m; }; class daAlinkHIO_wlSwim_c : public daAlinkHIO_data_c { @@ -8215,7 +8191,7 @@ public: class daAlinkHIO_wlGrab_c0 { public: - static daAlinkHIO_wlGrab_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlGrab_c1 const m; }; class daAlinkHIO_wlGrab_c : public daAlinkHIO_data_c { @@ -8245,7 +8221,7 @@ public: class daAlinkHIO_wlBall_c0 { public: - static daAlinkHIO_wlBall_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wlBall_c1 const m; }; class daAlinkHIO_wlBall_c : public daAlinkHIO_data_c { @@ -8300,7 +8276,7 @@ public: static daAlinkHIO_wlSwim_c0 const mWlSwim; static daAlinkHIO_wlGrab_c0 const mWlGrab; static daAlinkHIO_wlBall_c0 const mWlBall; - static daAlinkHIO_wolf_c1 const m; + static DUSK_GAME_DATA daAlinkHIO_wolf_c1 const m; }; class daAlinkHIO_wolf_c : public daAlinkHIO_data_c { @@ -8449,8 +8425,10 @@ struct daAlink_cutHorseParamTbl { /* 0xA */ u8 m_cutType; }; // Size: 0xC +#if !TARGET_PC inline BOOL dComIfGs_isTransformLV(int i_no); inline BOOL dComIfGs_isEventBit(const u16); +#endif static fopAc_ac_c* daAlink_searchPortal(fopAc_ac_c* i_actor, void* i_data); static fopAc_ac_c* daAlink_searchCanoe(fopAc_ac_c* i_actor, void* i_data); diff --git a/include/d/actor/d_a_arrow.h b/include/d/actor/d_a_arrow.h index 682ffd43d7..f15cf1aca8 100644 --- a/include/d/actor/d_a_arrow.h +++ b/include/d/actor/d_a_arrow.h @@ -110,7 +110,6 @@ public: void setModelMatrix(MtxP mtx) { mpModel->setBaseTRMtx(mtx); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ dBgS_ArrowLinChk field_0x56c; /* 0x5DC */ dBgS_ObjLinChk field_0x5dc; @@ -161,7 +160,7 @@ private: /* 0xA10 */ dPa_hermiteEcallBack_c field_0xa10; /* 0xA28 */ int (daArrow_c::*mProcFunc)(); - static s16 m_count; + static DUSK_GAME_DATA s16 m_count; }; STATIC_ASSERT(sizeof(daArrow_c) == 0xA34); diff --git a/include/d/actor/d_a_b_dr.h b/include/d/actor/d_a_b_dr.h index e15a6e7ca5..d9f72089f4 100644 --- a/include/d/actor/d_a_b_dr.h +++ b/include/d/actor/d_a_b_dr.h @@ -82,7 +82,6 @@ public: u8 onTarget() { return mTarget = true; } u8 isBack() { return arg0; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x05B8 */ J3DModel* mpPartModel; diff --git a/include/d/actor/d_a_b_ds.h b/include/d/actor/d_a_b_ds.h index ee737a955a..7013465e93 100644 --- a/include/d/actor/d_a_b_ds.h +++ b/include/d/actor/d_a_b_ds.h @@ -189,7 +189,6 @@ public: void onDemo() { mIsDemo = true; } void offDemo() { mIsDemo = false; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x05B8 */ mDoExt_McaMorfSO* mpSwordMorf; diff --git a/include/d/actor/d_a_b_gnd.h b/include/d/actor/d_a_b_gnd.h index 0827102eec..dcf6c94905 100644 --- a/include/d/actor/d_a_b_gnd.h +++ b/include/d/actor/d_a_b_gnd.h @@ -189,12 +189,6 @@ public: /* 0x2740 */ u8 field_0x2740; /* 0x2744 */ dMsgFlow_c mMsgFlow; #if TARGET_PC - cXyz mReinsInterpPrev[2][16]; - cXyz mReinsInterpCurr[2][16]; - cXyz mReinsTexInterpPrev[2]; - cXyz mReinsTexInterpCurr[2]; - bool mReinsInterpPrevValid; - bool mReinsInterpCurrValid; s8 mDemoCamSyncTicks; #endif }; diff --git a/include/d/actor/d_a_b_mgn.h b/include/d/actor/d_a_b_mgn.h index 272d02b1ef..1ad1dd5cf7 100644 --- a/include/d/actor/d_a_b_mgn.h +++ b/include/d/actor/d_a_b_mgn.h @@ -92,7 +92,6 @@ public: bool isDown() { return mDownFlag != 0; } bool isAppear() { return mAppearFlag != 0; } -private: /* 0x05AC */ request_of_phase_process_class mMgnPhase; /* 0x05B4 */ request_of_phase_process_class mMgnePhase; /* 0x05BC */ mDoExt_McaMorfSO* mpMgnModelMorf; diff --git a/include/d/actor/d_a_b_tn.h b/include/d/actor/d_a_b_tn.h index 7de1007d28..87b9cd2fae 100644 --- a/include/d/actor/d_a_b_tn.h +++ b/include/d/actor/d_a_b_tn.h @@ -131,7 +131,6 @@ public: int CreateHeap(); int create(); -private: /* 0x05AC */ request_of_phase_process_class mPhaseReq1; /* 0x05B4 */ request_of_phase_process_class mPhaseReq2; /* 0x05BC */ J3DModel* mpPartModels[16]; diff --git a/include/d/actor/d_a_b_yo.h b/include/d/actor/d_a_b_yo.h index a133d364d6..3550b95a1c 100644 --- a/include/d/actor/d_a_b_yo.h +++ b/include/d/actor/d_a_b_yo.h @@ -80,7 +80,6 @@ public: void setDrawOff() { mIsInactive = 1; } bool isEnemyDemoEnd() { return (u8)mIsEnemyDemoEnd != 0; } -private: /* 0x05AC */ request_of_phase_process_class mPhase1; /* 0x05B4 */ request_of_phase_process_class mPhase2; /* 0x05BC */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_b_yo_ice.h b/include/d/actor/d_a_b_yo_ice.h index 2ad2e5388d..e0f064fa9d 100644 --- a/include/d/actor/d_a_b_yo_ice.h +++ b/include/d/actor/d_a_b_yo_ice.h @@ -51,7 +51,6 @@ public: void setSubNumber(int i_subNumber) { mSubNumber = i_subNumber; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ J3DModel* mpModel; /* 0x5B8 */ Z2Creature mCreatureSound; diff --git a/include/d/actor/d_a_b_zant_magic.h b/include/d/actor/d_a_b_zant_magic.h index 0d05f9bd41..e37b055bfd 100644 --- a/include/d/actor/d_a_b_zant_magic.h +++ b/include/d/actor/d_a_b_zant_magic.h @@ -24,7 +24,6 @@ public: int _delete(); int create(); -private: /* 0x5AC */ Mtx field_0x5ac; /* 0x5DC */ cXyz field_0x5dc; /* 0x5E8 */ f32 field_0x5e8; diff --git a/include/d/actor/d_a_b_zant_mobile.h b/include/d/actor/d_a_b_zant_mobile.h index 3af85c56b1..18dcdbabc1 100644 --- a/include/d/actor/d_a_b_zant_mobile.h +++ b/include/d/actor/d_a_b_zant_mobile.h @@ -33,7 +33,6 @@ public: bool isSearchContinue() { return mSearchContinue != false; } void offSearchContinue() { mSearchContinue = false; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_brkAnm* mpBrk; diff --git a/include/d/actor/d_a_balloon_2D.h b/include/d/actor/d_a_balloon_2D.h index 193ecadbaa..80aa3e3b02 100644 --- a/include/d/actor/d_a_balloon_2D.h +++ b/include/d/actor/d_a_balloon_2D.h @@ -67,7 +67,7 @@ public: void hide() { mIsVisible = 0; } u8 isVisible() { return mIsVisible; } - static daBalloon2D_c* myclass; + static DUSK_GAME_DATA daBalloon2D_c* myclass; struct ScoreCount { cXyz field_0x0; diff --git a/include/d/actor/d_a_bg.h b/include/d/actor/d_a_bg.h index 0a9859198b..51407a06c8 100644 --- a/include/d/actor/d_a_bg.h +++ b/include/d/actor/d_a_bg.h @@ -57,7 +57,6 @@ public: inline int execute(); inline int isDelete(); -private: /* 0x568 */ u8 field_0x568[0x570 - 0x568]; /* 0x570 */ daBg_Part mBgParts[6]; /* 0x5E8 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_bg_obj.h b/include/d/actor/d_a_bg_obj.h index fc4df6ab4e..aab9572183 100644 --- a/include/d/actor/d_a_bg_obj.h +++ b/include/d/actor/d_a_bg_obj.h @@ -89,10 +89,10 @@ public: void setAction(u8 i_action) { mAction = i_action; } - static createHeapFunc mCreateHeapFunc[]; - static createInitFunc mCreateInitFunc[]; - static executeFunc mExecuteFunc[]; - static tgSetFunc mTgSetFunc[]; + static DUSK_GAME_DATA createHeapFunc mCreateHeapFunc[]; + static DUSK_GAME_DATA createInitFunc mCreateInitFunc[]; + static DUSK_GAME_DATA executeFunc mExecuteFunc[]; + static DUSK_GAME_DATA tgSetFunc mTgSetFunc[]; /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* field_0x5a8[2][2]; diff --git a/include/d/actor/d_a_boomerang.h b/include/d/actor/d_a_boomerang.h index 6dcff6ef9f..2b527afe45 100644 --- a/include/d/actor/d_a_boomerang.h +++ b/include/d/actor/d_a_boomerang.h @@ -25,7 +25,6 @@ public: void onReserve() { mReserve = 1; } void offReserve() { mReserve = 0; } -private: /* 0x04 */ J2DScreen* m_cursorYellowScrn; /* 0x08 */ J2DPane* m_cursorYellowAllPane; /* 0x0C */ J2DPane* m_cursorYellow0Pane; @@ -126,7 +125,6 @@ public: bool getLockCntMax() { return m_lockCnt >= BOOMERANG_LOCK_MAX; } void onLockDistanceCancel() { onStateFlg0(FLG0_LOCK_DIST_CANCEL); } -private: /* 0x568 */ J3DModel* mp_boomModel; /* 0x56C */ J3DModel* mp_shippuModel; /* 0x570 */ J3DAnmTextureSRTKey* m_windBtk; @@ -190,12 +188,12 @@ STATIC_ASSERT(sizeof(daBoomerang_c) == 0xDE4); class daBoomerang_HIO_c0 { public: - static u16 const m_lockWaitTime; - static f32 const m_minCircleR; - static f32 const m_middleCircleR; - static f32 const m_maxCircleR; - static f32 const m_scale; - static f32 const m_lockWindScale; + static DUSK_GAME_DATA u16 const m_lockWaitTime; + static DUSK_GAME_DATA f32 const m_minCircleR; + static DUSK_GAME_DATA f32 const m_middleCircleR; + static DUSK_GAME_DATA f32 const m_maxCircleR; + static DUSK_GAME_DATA f32 const m_scale; + static DUSK_GAME_DATA f32 const m_lockWindScale; }; #endif /* D_A_BOOMERANG_H */ diff --git a/include/d/actor/d_a_bullet.h b/include/d/actor/d_a_bullet.h index d6f9135654..d925502779 100644 --- a/include/d/actor/d_a_bullet.h +++ b/include/d/actor/d_a_bullet.h @@ -18,7 +18,7 @@ class daBullet_Param_c { public: virtual ~daBullet_Param_c() {} - static daBullet_HIOParam const m; + static DUSK_GAME_DATA daBullet_HIOParam const m; }; #if DEBUG @@ -80,8 +80,8 @@ public: int wait(void*); int move(void*); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; }; STATIC_ASSERT(sizeof(daBullet_c) == 0x95c); diff --git a/include/d/actor/d_a_canoe.h b/include/d/actor/d_a_canoe.h index bf34a5eee7..bcd7615e18 100644 --- a/include/d/actor/d_a_canoe.h +++ b/include/d/actor/d_a_canoe.h @@ -65,7 +65,6 @@ public: field_0x1456 = 15; } -private: /* 0x0568 */ request_of_phase_process_class mPhaseReq; /* 0x0570 */ J3DModel* mpModel; /* 0x0574 */ J3DModel* mpPaddleModel; diff --git a/include/d/actor/d_a_coach_fire.h b/include/d/actor/d_a_coach_fire.h index c5f890dc3d..1e8aa2d661 100644 --- a/include/d/actor/d_a_coach_fire.h +++ b/include/d/actor/d_a_coach_fire.h @@ -33,7 +33,7 @@ public: const CoachFireAttr& attr() { return M_attr; } - static CoachFireAttr const M_attr; + static DUSK_GAME_DATA CoachFireAttr const M_attr; inline ~daCoachFire_c(); @@ -42,7 +42,6 @@ public: void setNoHitTimer() { noHitTimer = 20; } inline int execute(); -private: /* 0x568 */ LIGHT_INFLUENCE mLightInfluence; /* 0x588 */ dCcD_Stts mStts; /* 0x5C4 */ dCcD_Sph mSph; diff --git a/include/d/actor/d_a_cow.h b/include/d/actor/d_a_cow.h index 403dc2aef6..e215256b91 100644 --- a/include/d/actor/d_a_cow.h +++ b/include/d/actor/d_a_cow.h @@ -208,7 +208,6 @@ public: u8 getCowIn() { return mCowIn; } u8 getNoNearCheckTimer() { return mNoNearCheckTimer; } -private: /* 0x568 */ u16 mFlags; /* 0x56c */ request_of_phase_process_class mPhase; /* 0x574 */ mDoExt_McaMorfSO* mpMorf; diff --git a/include/d/actor/d_a_crod.h b/include/d/actor/d_a_crod.h index 84938d454a..02311fbeb5 100644 --- a/include/d/actor/d_a_crod.h +++ b/include/d/actor/d_a_crod.h @@ -48,7 +48,6 @@ public: static f32 getFlyInitY() { return 40.0f; } static f32 getFlyInitZ() { return 50.0f; } -private: /* 0x568 */ J3DModel* mpBallModel; /* 0x56C */ mDoExt_bckAnm mBck; /* 0x588 */ J3DAnmTevRegKey* mpBallBrk; diff --git a/include/d/actor/d_a_cstaF.h b/include/d/actor/d_a_cstaF.h index 0e8b5c1ca7..982aa061a8 100644 --- a/include/d/actor/d_a_cstaF.h +++ b/include/d/actor/d_a_cstaF.h @@ -38,9 +38,8 @@ public: struct BckTbl { u16 idx[4]; }; - static const BckTbl m_bckIdxTable[]; + static DUSK_GAME_DATA const BckTbl m_bckIdxTable[]; -private: /* 0x5A0 */ const char* m_arcName; /* 0x5A4 */ request_of_phase_process_class m_phase; /* 0x5AC */ J3DModel* mp_model; diff --git a/include/d/actor/d_a_cstatue.h b/include/d/actor/d_a_cstatue.h index e20e683398..2b74240fb2 100644 --- a/include/d/actor/d_a_cstatue.h +++ b/include/d/actor/d_a_cstatue.h @@ -99,9 +99,8 @@ public: mWarpMode = daCstatueWarpMode_Active; } - static u16 const m_bckIdxTable[daCstatueType_N][7]; + static DUSK_GAME_DATA u16 const m_bckIdxTable[daCstatueType_N][7]; -private: /* 0x568 */ const char* mResName; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_demo_item.h b/include/d/actor/d_a_demo_item.h index ed6d195f5e..62780f572f 100644 --- a/include/d/actor/d_a_demo_item.h +++ b/include/d/actor/d_a_demo_item.h @@ -55,7 +55,6 @@ public: void setOffsetPos(cXyz i_pos) { mOffsetPos = i_pos; } void setMaxScale(f32 i_scale) { mMaxScale = i_scale; } -private: /* 0x92C */ cXyz mOffsetPos; /* 0x938 */ f32 mMaxScale; /* 0x93C */ u8 field_0x93c; diff --git a/include/d/actor/d_a_door_boss.h b/include/d/actor/d_a_door_boss.h index afd7984bf1..722afc0a84 100644 --- a/include/d/actor/d_a_door_boss.h +++ b/include/d/actor/d_a_door_boss.h @@ -50,7 +50,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpDoorModel; /* 0x574 */ J3DModel* mpLockModel; diff --git a/include/d/actor/d_a_door_bossL1.h b/include/d/actor/d_a_door_bossL1.h index 7e14025cd2..c0b8f2b44a 100644 --- a/include/d/actor/d_a_door_bossL1.h +++ b/include/d/actor/d_a_door_bossL1.h @@ -76,7 +76,6 @@ public: void setAction(u8 action) { mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_bossL5.h b/include/d/actor/d_a_door_bossL5.h index 832f575ac1..d876bab9c8 100644 --- a/include/d/actor/d_a_door_bossL5.h +++ b/include/d/actor/d_a_door_bossL5.h @@ -72,7 +72,6 @@ public: return 1; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_dbdoor00.h b/include/d/actor/d_a_door_dbdoor00.h index 9b2f65e756..ec976c7f6b 100644 --- a/include/d/actor/d_a_door_dbdoor00.h +++ b/include/d/actor/d_a_door_dbdoor00.h @@ -41,7 +41,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } -// private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ request_of_phase_process_class mPhaseReq2; /* 0x578 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_door_knob00.h b/include/d/actor/d_a_door_knob00.h index 577b26b58e..742b8921c9 100644 --- a/include/d/actor/d_a_door_knob00.h +++ b/include/d/actor/d_a_door_knob00.h @@ -73,7 +73,6 @@ public: void onFlag(u16 flag) { field_0x60c |= flag; } int checkFlag(u16 flag) { return field_0x60c & flag; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ J3DModel* mModel1; diff --git a/include/d/actor/d_a_door_mbossL1.h b/include/d/actor/d_a_door_mbossL1.h index 2bd95d920b..7b76f903bc 100644 --- a/include/d/actor/d_a_door_mbossL1.h +++ b/include/d/actor/d_a_door_mbossL1.h @@ -121,7 +121,6 @@ public: mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_push.h b/include/d/actor/d_a_door_push.h index 5beb3aa564..f648ef208b 100644 --- a/include/d/actor/d_a_door_push.h +++ b/include/d/actor/d_a_door_push.h @@ -49,7 +49,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } u32 getSceneNo() { return fopAcM_GetParamBit(this, 4, 6); } -// private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ dBgW* mpDoorBgW; diff --git a/include/d/actor/d_a_door_shutter.h b/include/d/actor/d_a_door_shutter.h index a8e99f1295..c3b134ddb8 100644 --- a/include/d/actor/d_a_door_shutter.h +++ b/include/d/actor/d_a_door_shutter.h @@ -123,7 +123,6 @@ public: bool checkFlag(u16 flag) { return field_0x68e & flag; } void setAction(u8 action) { mAction = action; } -private: /* 0x56C */ request_of_phase_process_class mPhase1; /* 0x574 */ request_of_phase_process_class mPhase2; /* 0x57C */ J3DModel* mModel1; diff --git a/include/d/actor/d_a_dshutter.h b/include/d/actor/d_a_dshutter.h index 479349c072..fb6d56ba97 100644 --- a/include/d/actor/d_a_dshutter.h +++ b/include/d/actor/d_a_dshutter.h @@ -65,15 +65,15 @@ public: f32 getCloseBoundSpeed() { return CLOSE_BOUND_SPEED; } f32 getCloseBoundRatio() { return CLOSE_BOUND_RATIO; } - static f32 const OPEN_SIZE; - static f32 const OPEN_ACCEL; - static f32 const OPEN_SPEED; - static f32 const OPEN_BOUND_SPEED; - static f32 const OPEN_BOUND_RATIO; - static f32 const CLOSE_ACCEL; - static f32 const CLOSE_SPEED; - static f32 const CLOSE_BOUND_SPEED; - static f32 const CLOSE_BOUND_RATIO; + static DUSK_GAME_DATA f32 const OPEN_SIZE; + static DUSK_GAME_DATA f32 const OPEN_ACCEL; + static DUSK_GAME_DATA f32 const OPEN_SPEED; + static DUSK_GAME_DATA f32 const OPEN_BOUND_SPEED; + static DUSK_GAME_DATA f32 const OPEN_BOUND_RATIO; + static DUSK_GAME_DATA f32 const CLOSE_ACCEL; + static DUSK_GAME_DATA f32 const CLOSE_SPEED; + static DUSK_GAME_DATA f32 const CLOSE_BOUND_SPEED; + static DUSK_GAME_DATA f32 const CLOSE_BOUND_RATIO; /* 0x5A0 */ dComIfG_resLoader_c mResLoader; /* 0x5B0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_e_ai.h b/include/d/actor/d_a_e_ai.h index d2f1b6ec06..78c4174338 100644 --- a/include/d/actor/d_a_e_ai.h +++ b/include/d/actor/d_a_e_ai.h @@ -48,7 +48,6 @@ public: int CreateHeap(); int Create(); -private: /* 0x5AC */ JPABaseEmitter* mpEmitter; /* 0x5B0 */ request_of_phase_process_class m_phase; /* 0x5B8 */ u8 field_0x5b8; diff --git a/include/d/actor/d_a_e_bg.h b/include/d/actor/d_a_e_bg.h index c14b0cf533..b3b0e1d8bf 100644 --- a/include/d/actor/d_a_e_bg.h +++ b/include/d/actor/d_a_e_bg.h @@ -45,7 +45,6 @@ public: void setBgId(unsigned int i_bgId) { mBgId = i_bgId; } bool isBomb() { return mIsBomb; } -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ mDoExt_brkAnm* mpBrkAnm; diff --git a/include/d/actor/d_a_e_db.h b/include/d/actor/d_a_e_db.h index 4f10715443..a95722a6d1 100644 --- a/include/d/actor/d_a_e_db.h +++ b/include/d/actor/d_a_e_db.h @@ -80,12 +80,6 @@ public: /* 0x125C */ u32 field_0x125c; /* 0x1260 */ u8 field_0x1260[0x126C - 0x1260]; /* 0x126C */ u8 HIOInit; -#if TARGET_PC - cXyz mStalkLineInterpPrev[12]; - cXyz mStalkLineInterpCurr[12]; - bool mStalkLineInterpPrevValid; - bool mStalkLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_db_class) == 0x1270); diff --git a/include/d/actor/d_a_e_dk.h b/include/d/actor/d_a_e_dk.h index 381f8e1a62..2c7d46b84f 100644 --- a/include/d/actor/d_a_e_dk.h +++ b/include/d/actor/d_a_e_dk.h @@ -45,7 +45,6 @@ public: int create(); daE_DK_c(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ mDoExt_McaMorfSO* mpCoreMorfSO; diff --git a/include/d/actor/d_a_e_dt.h b/include/d/actor/d_a_e_dt.h index 1296a78e5b..0fdb13f4e5 100644 --- a/include/d/actor/d_a_e_dt.h +++ b/include/d/actor/d_a_e_dt.h @@ -83,7 +83,6 @@ public: MtxP getBackMtx() { return mpMorf->getModel()->getAnmMtx(1); } fpc_ProcID getDemoId() { return mDemoID; } -private: /* 0x05AC */ request_of_phase_process_class mPhase[3]; /* 0x05C4 */ J3DModel* mpChestModel; /* 0x05C8 */ J3DModel* mpSpitModel; @@ -175,14 +174,14 @@ private: STATIC_ASSERT(sizeof(daE_DT_c) == 0x1174); struct E_DT_n { - static f32 eDt_ShakeFrame[10]; - static f32 eDt_ShakeFrameDemo[10]; - static dCcD_SrcSph cc_dt_body_src; - static dCcD_SrcSph cc_dt_tongue_src; - static int mDt_OtamaNum; - static int mDt_OtamaNo[20]; - static int m_fall_no; - static cXyz m_tongue_pos; + static DUSK_GAME_DATA f32 eDt_ShakeFrame[10]; + static DUSK_GAME_DATA f32 eDt_ShakeFrameDemo[10]; + static DUSK_GAME_DATA dCcD_SrcSph cc_dt_body_src; + static DUSK_GAME_DATA dCcD_SrcSph cc_dt_tongue_src; + static DUSK_GAME_DATA int mDt_OtamaNum; + static DUSK_GAME_DATA int mDt_OtamaNo[20]; + static DUSK_GAME_DATA int m_fall_no; + static DUSK_GAME_DATA cXyz m_tongue_pos; }; diff --git a/include/d/actor/d_a_e_fb.h b/include/d/actor/d_a_e_fb.h index a4494c5e7a..ae48f77ea6 100644 --- a/include/d/actor/d_a_e_fb.h +++ b/include/d/actor/d_a_e_fb.h @@ -40,7 +40,6 @@ public: cPhs_Step create(); daE_FB_c(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_invisibleModel mInvisibleModel; diff --git a/include/d/actor/d_a_e_fk.h b/include/d/actor/d_a_e_fk.h index 390e4e3420..fb18f74792 100644 --- a/include/d/actor/d_a_e_fk.h +++ b/include/d/actor/d_a_e_fk.h @@ -52,7 +52,6 @@ public: void CreateChk(); int Create(); -private: /* 0x5AC */ u8 field_0x5AC[0x5B1 - 0x5AC]; /* 0x5B1 */ u8 mUpDownMode; /* 0x5B2 */ u8 field_0x5B2[0x5B6 - 0x5B2]; diff --git a/include/d/actor/d_a_e_fz.h b/include/d/actor/d_a_e_fz.h index e0b838aa51..e40232b74f 100644 --- a/include/d/actor/d_a_e_fz.h +++ b/include/d/actor/d_a_e_fz.h @@ -63,7 +63,6 @@ public: s32 CreateHeap(); s32 create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /**< Phase request used when creating the actor. */ /* 0x5B4 */ J3DModel* mpModel; /**< Pointer to the Mini Freezard's model. */ /* 0x5B8 */ mDoExt_invisibleModel mInvisibleModel; /**< Invisible model used for the Mini Freezard. */ diff --git a/include/d/actor/d_a_e_ge.h b/include/d/actor/d_a_e_ge.h index c202e75231..3c4d4ffbee 100644 --- a/include/d/actor/d_a_e_ge.h +++ b/include/d/actor/d_a_e_ge.h @@ -61,7 +61,6 @@ public: u8 getGroupNo() { return mGroupNo; } -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ Z2CreatureEnemy mSound; @@ -101,7 +100,7 @@ private: /* 0xB9E */ u8 field_0xb9e; /* 0xB9F */ u8 mHIOInit; - static actionFunc l_actionmenu[9]; + static DUSK_GAME_DATA actionFunc l_actionmenu[9]; }; STATIC_ASSERT(sizeof(daE_GE_c) == 0xBA0); diff --git a/include/d/actor/d_a_e_gi.h b/include/d/actor/d_a_e_gi.h index adadfd03b8..a731797f32 100644 --- a/include/d/actor/d_a_e_gi.h +++ b/include/d/actor/d_a_e_gi.h @@ -47,7 +47,6 @@ public: bool isBattleOn() { return mIsBattleOn; } bool isAttackStart() { return mIsAttackStart; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x05B8 */ J3DModel* mpSwordModel; diff --git a/include/d/actor/d_a_e_gm.h b/include/d/actor/d_a_e_gm.h index 370dea9150..de8c0d6acc 100644 --- a/include/d/actor/d_a_e_gm.h +++ b/include/d/actor/d_a_e_gm.h @@ -62,7 +62,6 @@ public: BOOL checkAction(actionFunc action) { return mAction == action; } BOOL checkOldAction(actionFunc action) { return mOldAction == action; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ dBgS_AcchCir mAcchCir; /* 0x5F4 */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_e_hb.h b/include/d/actor/d_a_e_hb.h index 3069bcd325..a7e0241007 100644 --- a/include/d/actor/d_a_e_hb.h +++ b/include/d/actor/d_a_e_hb.h @@ -73,12 +73,6 @@ public: /* 0x124C */ f32 field_0x124c; /* 0x1250 */ u8 field_0x1250[0x1264 - 0x1250]; /* 0x1264 */ u8 HIOInit; -#if TARGET_PC - cXyz mStalkLineInterpPrev[12]; - cXyz mStalkLineInterpCurr[12]; - bool mStalkLineInterpPrevValid; - bool mStalkLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_hb_class) == 0x1268); diff --git a/include/d/actor/d_a_e_hm.h b/include/d/actor/d_a_e_hm.h index 85f6e5422c..9be48a53f3 100644 --- a/include/d/actor/d_a_e_hm.h +++ b/include/d/actor/d_a_e_hm.h @@ -65,7 +65,6 @@ public: void CheckWall(); void CreateStyle(); int Create(); -private: /* 0x5AC */ u8 field_0x5ac; /* 0x5AD */ u8 field_0x5ad; /* 0x5AE */ u8 field_0x5ae; diff --git a/include/d/actor/d_a_e_hp.h b/include/d/actor/d_a_e_hp.h index 8941f1e2a6..86b092f915 100644 --- a/include/d/actor/d_a_e_hp.h +++ b/include/d/actor/d_a_e_hp.h @@ -96,6 +96,9 @@ public: /* 0xDE0 */ cXyz field_0xde0; /* 0xDEC */ u8 field_0xdec[0xdf9 - 0xdec]; /* 0xDF9 */ u8 field_0xdf9; +#if TARGET_PC + bool mItemCheckHandled; +#endif }; STATIC_ASSERT(sizeof(daE_HP_c) == 0xdfc); diff --git a/include/d/actor/d_a_e_hz.h b/include/d/actor/d_a_e_hz.h index 539d808cf5..e48a72ee69 100644 --- a/include/d/actor/d_a_e_hz.h +++ b/include/d/actor/d_a_e_hz.h @@ -64,7 +64,6 @@ public: void setInitPos(); int create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ request_of_phase_process_class mPhaseReq2; /* 0x5BC */ mDoExt_McaMorfSO* mpMorfSO; diff --git a/include/d/actor/d_a_e_kk.h b/include/d/actor/d_a_e_kk.h index 890da0eba2..a249cafc74 100644 --- a/include/d/actor/d_a_e_kk.h +++ b/include/d/actor/d_a_e_kk.h @@ -49,7 +49,6 @@ public: int CreateHeap(); int create(); -private: /* 0x05AC */ request_of_phase_process_class mPhaseReq; /* 0x05B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x05B8 */ mDoExt_McaMorfSO* mpWeaponMorfSO; diff --git a/include/d/actor/d_a_e_mb.h b/include/d/actor/d_a_e_mb.h index 527cf30eac..f36c744879 100644 --- a/include/d/actor/d_a_e_mb.h +++ b/include/d/actor/d_a_e_mb.h @@ -44,12 +44,6 @@ public: /* 0x88C */ u8 field_0x88C[0x8C8 - 0x88C]; /* 0x8C8 */ s8 field_0x8c8; /* 0x8C9 */ u8 mInitHIO; -#if TARGET_PC - cXyz mRopeInterpPrev[16]; - cXyz mRopeInterpCurr[16]; - bool mRopeInterpPrevValid; - bool mRopeInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_mb_class) == 0x8cc); diff --git a/include/d/actor/d_a_e_oc.h b/include/d/actor/d_a_e_oc.h index ada1b5310b..2d40d9bcbc 100644 --- a/include/d/actor/d_a_e_oc.h +++ b/include/d/actor/d_a_e_oc.h @@ -87,7 +87,6 @@ public: daE_OC_c* getTalkOc() { return mpTalk; } J3DModel* getOcModel() { return mpMorf->getModel(); } -private: /* 0x5a0 */ request_of_phase_process_class mPhaseReqs[2]; /* 0x5bc */ mDoExt_McaMorfSO* mpMorf; /* 0x5c0 */ J3DModel* mpModel; @@ -159,14 +158,14 @@ private: STATIC_ASSERT(sizeof(daE_OC_c) == 0xe88); struct E_OC_n { - static f32 const oc_attackb_trans[10]; - static f32 const oc_attackc_trans[10]; - static dCcD_SrcSph cc_sph_src; - static dCcD_SrcSph at_sph_src; - static daE_OC_c* m_battle_oc; - static daE_OC_c* m_damage_oc; - static daE_OC_c* m_death_oc; - static daE_OC_c* m_talk_oc; + static DUSK_GAME_DATA f32 const oc_attackb_trans[10]; + static DUSK_GAME_DATA f32 const oc_attackc_trans[10]; + static DUSK_GAME_DATA dCcD_SrcSph cc_sph_src; + static DUSK_GAME_DATA dCcD_SrcSph at_sph_src; + static DUSK_GAME_DATA daE_OC_c* m_battle_oc; + static DUSK_GAME_DATA daE_OC_c* m_damage_oc; + static DUSK_GAME_DATA daE_OC_c* m_death_oc; + static DUSK_GAME_DATA daE_OC_c* m_talk_oc; }; #endif /* D_A_E_OC_H */ diff --git a/include/d/actor/d_a_e_oct_bg.h b/include/d/actor/d_a_e_oct_bg.h index cd5b6b27cd..9033e03736 100644 --- a/include/d/actor/d_a_e_oct_bg.h +++ b/include/d/actor/d_a_e_oct_bg.h @@ -54,7 +54,6 @@ public: u32 checkAction(actionFunc func) { return field_0xb58 == func; } bool checkNormalAttk() { return checkAction(&daE_OctBg_c::normal_attack); } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* field_0x5b4; /* 0x5B8 */ mDoExt_brkAnm* field_0x5b8; diff --git a/include/d/actor/d_a_e_ot.h b/include/d/actor/d_a_e_ot.h index 54e8399b7b..3505062e3c 100644 --- a/include/d/actor/d_a_e_ot.h +++ b/include/d/actor/d_a_e_ot.h @@ -54,7 +54,6 @@ public: /* 0x4 */ ACT_DAMAGE, }; -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ J3DModel* mpEggModel; diff --git a/include/d/actor/d_a_e_pm.h b/include/d/actor/d_a_e_pm.h index edec93c6a2..35368eff61 100644 --- a/include/d/actor/d_a_e_pm.h +++ b/include/d/actor/d_a_e_pm.h @@ -84,7 +84,6 @@ public: u8 SwitchChk() { return mStage; } u8 DoorChk() { return mDoorAction; } -private: /* 0x5AC */ fpc_ProcID mPuppetID[4]; /* 0x5BC */ u8 field_0x5bc[0x5DC - 0x5BC]; /* 0x5DC */ u8 mDoorAction; diff --git a/include/d/actor/d_a_e_s1.h b/include/d/actor/d_a_e_s1.h index 5cbae84696..a631ba47ac 100644 --- a/include/d/actor/d_a_e_s1.h +++ b/include/d/actor/d_a_e_s1.h @@ -81,15 +81,6 @@ public: /* 0x306D */ u8 field_0x306D[0x307C - 0x306D]; /* 0x307C */ u32 mBodyEffEmtrID; /* 0x3080 */ u8 mInitHIO; - -#if TARGET_PC - static const int HAIR_STRAND_COUNT = 22; - static const int HAIR_SEGMENT_COUNT = 16; - cXyz mHairInterpPrev[HAIR_STRAND_COUNT * HAIR_SEGMENT_COUNT]; - cXyz mHairInterpCurr[HAIR_STRAND_COUNT * HAIR_SEGMENT_COUNT]; - bool mHairInterpPrevValid; - bool mHairInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_s1_class) == 0x3084); diff --git a/include/d/actor/d_a_e_sb.h b/include/d/actor/d_a_e_sb.h index e015ecc5bc..bd7d8c9bdc 100644 --- a/include/d/actor/d_a_e_sb.h +++ b/include/d/actor/d_a_e_sb.h @@ -57,7 +57,6 @@ public: int Delete(); void setBaseMtx(); cPhs_Step Create(); -private: /* 0x5AC */ int field_0x5ac; /* 0x5B0 */ int field_0x5b0; /* 0x5B4 */ int field_0x5b4; @@ -78,7 +77,6 @@ private: public: /* 0x5EC */ cXyz* field_0x5ec; /* 0x5F0 */ f32 field_0x5f0; -private: /* 0x5F4 */ cXyz field_0x5f4; /* 0x600 */ s16 field_0x600; /* 0x602 */ u8 field_0x602; diff --git a/include/d/actor/d_a_e_sw.h b/include/d/actor/d_a_e_sw.h index b073dae952..6f6a71f16d 100644 --- a/include/d/actor/d_a_e_sw.h +++ b/include/d/actor/d_a_e_sw.h @@ -82,7 +82,6 @@ public: bool d_checkOldAction(void (daE_SW_c::*action)()) { return field_0xb0c == action; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x5B8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_e_tt.h b/include/d/actor/d_a_e_tt.h index f3b79a69b3..38dc53ac3f 100644 --- a/include/d/actor/d_a_e_tt.h +++ b/include/d/actor/d_a_e_tt.h @@ -47,7 +47,6 @@ public: int CreateHeap(); int create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ request_of_phase_process_class mPhaseReq2; /* 0x5BC */ mDoExt_McaMorfSO* mpMorfSO; diff --git a/include/d/actor/d_a_e_vt.h b/include/d/actor/d_a_e_vt.h index 4b6082adae..b55bb4891a 100644 --- a/include/d/actor/d_a_e_vt.h +++ b/include/d/actor/d_a_e_vt.h @@ -146,7 +146,6 @@ public: int create(); daE_VA_c(); -private: /* 0x005AC */ request_of_phase_process_class mPhase; /* 0x005B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x005B8 */ mDoExt_McaMorfSO* mpEndEfMorf; diff --git a/include/d/actor/d_a_e_wb.h b/include/d/actor/d_a_e_wb.h index aecbac96a1..770e537f2e 100644 --- a/include/d/actor/d_a_e_wb.h +++ b/include/d/actor/d_a_e_wb.h @@ -221,12 +221,6 @@ public: /* 0x17E4 */ u8 field_0x17e4[0x17e8 - 0x17e4]; /* 0x17E8 */ f32 ride_speed_max; ///< @brief Speed rate for riding calculations. #if TARGET_PC - cXyz himo_mat_interp_prev[2][16]; - cXyz himo_mat_interp_curr[2][16]; - cXyz himo_tex_interp_prev[2]; - cXyz himo_tex_interp_curr[2]; - bool himo_interp_prev_valid; - bool himo_interp_curr_valid; s8 demo_cam_sync_ticks; #endif }; diff --git a/include/d/actor/d_a_e_ww.h b/include/d/actor/d_a_e_ww.h index fc1083c34e..f1ebac248a 100644 --- a/include/d/actor/d_a_e_ww.h +++ b/include/d/actor/d_a_e_ww.h @@ -59,7 +59,6 @@ public: void setAttack() { mActionMode = 10; } f32 const getSpeedF() { return speedF; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x5B8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_e_yd.h b/include/d/actor/d_a_e_yd.h index 44d6036600..188e435ba5 100644 --- a/include/d/actor/d_a_e_yd.h +++ b/include/d/actor/d_a_e_yd.h @@ -74,12 +74,6 @@ public: /* 0x1250 */ f32 field_0x1250; /* 0x1254 */ u8 field_0x1254[0x1268 - 0x1254]; /* 0x1268 */ u8 field_0x1268; -#if TARGET_PC - cXyz mLineMatInterpPrev[12]; - cXyz mLineMatInterpCurr[12]; - bool mLineMatInterpPrevValid; - bool mLineMatInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yd_class) == 0x126c); diff --git a/include/d/actor/d_a_e_yg.h b/include/d/actor/d_a_e_yg.h index 6be19933cb..69a85430a8 100644 --- a/include/d/actor/d_a_e_yg.h +++ b/include/d/actor/d_a_e_yg.h @@ -63,15 +63,6 @@ public: /* 0x0BB4 */ yg_ke_s mYgKes[13]; /* 0x1880 */ mDoExt_3DlineMat0_c mLineMat; /* 0x189C */ u8 mIsFirstSpawn; - -#if TARGET_PC - static const int TENTACLE_STRAND_COUNT = 13; - static const int TENTACLE_SEGMENT_COUNT = 10; - cXyz mTentacleInterpPrev[TENTACLE_STRAND_COUNT * TENTACLE_SEGMENT_COUNT]; - cXyz mTentacleInterpCurr[TENTACLE_STRAND_COUNT * TENTACLE_SEGMENT_COUNT]; - bool mTentacleInterpPrevValid; - bool mTentacleInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yg_class) == 0x18a0); diff --git a/include/d/actor/d_a_e_yh.h b/include/d/actor/d_a_e_yh.h index 63e8ac1882..519e5e2779 100644 --- a/include/d/actor/d_a_e_yh.h +++ b/include/d/actor/d_a_e_yh.h @@ -77,12 +77,6 @@ public: /* 0x1260 */ u32 field_0x1260; /* 0x1260 */ u8 field_0x1264[0x1270 - 0x1264]; /* 0x1270 */ bool mIsHIOOwner; -#if TARGET_PC - cXyz mLineInterpPrev[12]; - cXyz mLineInterpCurr[12]; - bool mLineInterpPrevValid; - bool mLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yh_class) == 0x1274); diff --git a/include/d/actor/d_a_e_ym.h b/include/d/actor/d_a_e_ym.h index 3217592e13..699d14d98f 100644 --- a/include/d/actor/d_a_e_ym.h +++ b/include/d/actor/d_a_e_ym.h @@ -122,7 +122,6 @@ public: u8 getSwitchBit() { return mSwitchBit; } u8 isHide() { return mIsHide; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_brkAnm* mpBrk; @@ -215,7 +214,7 @@ private: STATIC_ASSERT(sizeof(daE_YM_c) == 0xAF8); struct E_YM_n { - static dCcD_SrcSph cc_sph_src; + static DUSK_GAME_DATA dCcD_SrcSph cc_sph_src; }; diff --git a/include/d/actor/d_a_e_zs.h b/include/d/actor/d_a_e_zs.h index d15b384650..93dbd82d89 100644 --- a/include/d/actor/d_a_e_zs.h +++ b/include/d/actor/d_a_e_zs.h @@ -39,7 +39,6 @@ public: int CreateHeap(); int create(); -private: /* 0x5ac */ request_of_phase_process_class mPhase; /* 0x5b4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5b8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_formation_mng.h b/include/d/actor/d_a_formation_mng.h index 79163f9cec..c308eb5352 100644 --- a/include/d/actor/d_a_formation_mng.h +++ b/include/d/actor/d_a_formation_mng.h @@ -311,10 +311,10 @@ struct daFmtMng_c : public fopAc_ac_c { } static FmtMngAttributes const& attr() { return M_attr; } - static FmtMngAttributes const M_attr; + static DUSK_GAME_DATA FmtMngAttributes const M_attr; typedef void (daFmtMng_c::*ActionFunc)(); - static daFmtMng_c::ActionFunc ActionTable[10]; + static DUSK_GAME_DATA daFmtMng_c::ActionFunc ActionTable[10]; /* 0x568 */ FmtPos_c* mPos; /* 0x56C */ FmtMember_c* mMember; diff --git a/include/d/actor/d_a_grass.h b/include/d/actor/d_a_grass.h index 4b07bea1d5..fa887b546a 100644 --- a/include/d/actor/d_a_grass.h +++ b/include/d/actor/d_a_grass.h @@ -41,9 +41,9 @@ public: static void deleteRoomGrass(int); static void deleteRoomFlower(int); - static daGrass_c* m_myObj; - static dGrass_packet_c* m_grass; - static dFlower_packet_c* m_flower; + static DUSK_GAME_DATA daGrass_c* m_myObj; + static DUSK_GAME_DATA dGrass_packet_c* m_grass; + static DUSK_GAME_DATA dFlower_packet_c* m_flower; /* 0x568 */ u8 unk_0x568[0x570 - 0x568]; }; diff --git a/include/d/actor/d_a_horse.h b/include/d/actor/d_a_horse.h index 7e8ef8c343..2074570517 100644 --- a/include/d/actor/d_a_horse.h +++ b/include/d/actor/d_a_horse.h @@ -196,9 +196,6 @@ public: void copyReinPos(); void setReinPosHandSubstance(int); void setReinPosNormalSubstance(); -#if TARGET_PC - void lerpControlPoints(f32 alpha); -#endif void bgCheck(); bool checkSpecialWallHitSubstance(cXyz const&) const; void setServiceWaitTimer(); @@ -351,8 +348,8 @@ public: m_modelData->getMaterialNodePointer(5)->getShape()->hide(); } - static u16 const m_footJointTable[]; - static f32 const m_callLimitDistance2; + static DUSK_GAME_DATA u16 const m_footJointTable[]; + static DUSK_GAME_DATA f32 const m_callLimitDistance2; /* 0x0568 */ request_of_phase_process_class m_phase; /* 0x0570 */ J3DModel* m_model; @@ -567,7 +564,7 @@ public: class daHorse_hio_c0 { public: - static const daHorse_hio_c1 m; + static DUSK_GAME_DATA const daHorse_hio_c1 m; }; class daHorse_hio_c : public JORReflexible { diff --git a/include/d/actor/d_a_hozelda.h b/include/d/actor/d_a_hozelda.h index 0c640e779c..d87542ccbc 100644 --- a/include/d/actor/d_a_hozelda.h +++ b/include/d/actor/d_a_hozelda.h @@ -29,8 +29,8 @@ public: static void setMorfFrame(u8 i_frame) { mMorfFrame = i_frame; } static void decMorfFrame() { cLib_calcTimer(&mMorfFrame); } - static u8 mEyeMoveFlg; - static u8 mMorfFrame; + static DUSK_GAME_DATA u8 mEyeMoveFlg; + static DUSK_GAME_DATA u8 mMorfFrame; /* 0x0F4 */ f32 field_0xf4; /* 0x0F8 */ f32 field_0xf8; @@ -50,7 +50,7 @@ struct daHoZelda_hio_c1 { struct daHoZelda_hio_c0 { daHoZelda_hio_c0() {} - static daHoZelda_hio_c1 const m; + static DUSK_GAME_DATA daHoZelda_hio_c1 const m; }; class daHoZelda_hio_c : public JORReflexible { diff --git a/include/d/actor/d_a_itembase.h b/include/d/actor/d_a_itembase.h index fa4d246062..374e4b7df2 100644 --- a/include/d/actor/d_a_itembase.h +++ b/include/d/actor/d_a_itembase.h @@ -32,6 +32,12 @@ struct daItemBase_data { class daItemBase_c : public fopAc_ac_c { public: u8 getItemNo(); +#if TARGET_PC + u8 getDisplayItemNo() const { + return mDisplayItemNo != 0xFF ? mDisplayItemNo : m_itemNo; + } + void setDisplayItemNo(u8 itemNo) { mDisplayItemNo = itemNo; } +#endif void hide(); void show(); void changeDraw(); @@ -60,7 +66,7 @@ public: virtual u8 getCollisionH(); virtual u8 getCollisionR(); - static daItemBase_data const m_data; + static DUSK_GAME_DATA daItemBase_data const m_data; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; @@ -79,6 +85,9 @@ public: /* 0x928 */ s16 m_get_timer; /* 0x92A */ u8 m_itemNo; /* 0x92B */ u8 field_0x92b; +#if TARGET_PC + u8 mDisplayItemNo = 0xFF; +#endif }; #endif /* D_A_D_A_ITEMBASE_H */ diff --git a/include/d/actor/d_a_kago.h b/include/d/actor/d_a_kago.h index 33ec51672f..ba0e77a37c 100644 --- a/include/d/actor/d_a_kago.h +++ b/include/d/actor/d_a_kago.h @@ -140,7 +140,6 @@ public: void setEatYm() { field_0x6d8 |= (u8) 4; } MtxP getMouthMtx() { return mAnm_p->getModel()->getAnmMtx(7); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ mDoExt_McaMorfSO* mAnm_p; /* 0x574 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_mant.h b/include/d/actor/d_a_mant.h index 6d5b173d1a..e6f3d71a9c 100644 --- a/include/d/actor/d_a_mant.h +++ b/include/d/actor/d_a_mant.h @@ -92,10 +92,7 @@ public: /* 0x39A4 */ cM_rnd_c mMantRng; #endif }; -#if TARGET_PC -STATIC_ASSERT(sizeof(mant_class) == 0x39ac); -#else + STATIC_ASSERT(sizeof(mant_class) == 0x39a4); -#endif #endif /* D_A_MANT_H */ diff --git a/include/d/actor/d_a_mg_rod.h b/include/d/actor/d_a_mg_rod.h index 97a0bb1c72..76863f33d5 100644 --- a/include/d/actor/d_a_mg_rod.h +++ b/include/d/actor/d_a_mg_rod.h @@ -299,13 +299,6 @@ public: /* 0x168C */ u8 field_0x168c; /* 0x168D */ u8 field_0x168d; /* 0x168E */ u8 HIOInit; - -#if TARGET_PC - cXyz mLineInterpPrev[MG_ROD_LURE_LINE_LEN]; - cXyz mLineInterpCurr[MG_ROD_LURE_LINE_LEN]; - bool mLineInterpPrevValid; - bool mLineInterpCurrValid; -#endif }; #endif /* D_A_MG_ROD_H */ diff --git a/include/d/actor/d_a_midna.h b/include/d/actor/d_a_midna.h index c9e84ee9d4..1371dce12c 100644 --- a/include/d/actor/d_a_midna.h +++ b/include/d/actor/d_a_midna.h @@ -32,7 +32,7 @@ public: class daMidna_hio_c0 { public: - static daMidna_hio_c1 const m; + static DUSK_GAME_DATA daMidna_hio_c1 const m; }; STATIC_ASSERT(sizeof(daMidna_hio_c0::m) == 0x20); @@ -87,8 +87,8 @@ public: /* 0x0FC */ f32 mNowOffsetX; /* 0x100 */ f32 mNowOffsetY; - static bool sEyeMoveFlg; - static u8 sMorfFrame; + static DUSK_GAME_DATA bool sEyeMoveFlg; + static DUSK_GAME_DATA u8 sMorfFrame; }; STATIC_ASSERT(sizeof(daMidna_matAnm_c) == 0x104); @@ -420,10 +420,9 @@ public: static u32 getOtherHeapSize() { return 0x1D0; } - static daMidna_texData_s const m_texDataTable[21]; - static daMidna_anmData_s const m_anmDataTable[53]; + static DUSK_GAME_DATA daMidna_texData_s const m_texDataTable[21]; + static DUSK_GAME_DATA daMidna_anmData_s const m_anmDataTable[53]; -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModel* mpShadowModel; diff --git a/include/d/actor/d_a_mirror.h b/include/d/actor/d_a_mirror.h index e2f9a51e30..ecf1c127be 100644 --- a/include/d/actor/d_a_mirror.h +++ b/include/d/actor/d_a_mirror.h @@ -58,8 +58,8 @@ public: static u32 getMirrorRoomPrm() { return 0xFF03; } typedef int (daMirror_c::*entryModelFunc)(J3DModel*); - static entryModelFunc m_entryModel; - static daMirror_c* m_myObj; + static DUSK_GAME_DATA entryModelFunc m_entryModel; + static DUSK_GAME_DATA daMirror_c* m_myObj; /* 0x570 */ dMirror_packet_c mPacket; /* 0x6f8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index c382e0d1f7..785f9458ab 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -4,6 +4,7 @@ #if !TARGET_PC #include #else +#include #include #include #endif @@ -17,29 +18,6 @@ struct daMP_THPReadBuffer { }; #if TARGET_PC -// Copying here because thp.h is probably erroneous in the dolphin lib, -// and it's kind of a problem being there (Aurora owns the headers). -// TODO: Move this stuff in decomp? -typedef struct THPAudioRecordHeader { - BE(u32) offsetNextChannel; - BE(u32) sampleSize; - BE(s16) lCoef[8][2]; - BE(s16) rCoef[8][2]; - BE(s16) lYn1; - BE(s16) lYn2; - BE(s16) rYn1; - BE(s16) rYn2; -} THPAudioRecordHeader; - -typedef struct THPAudioDecodeInfo { - u8* encodeData; - u32 offsetNibbles; - u8 predictor; - u8 scale; - s16 yn1; - s16 yn2; -} THPAudioDecodeInfo; - typedef struct THPTextureSet { u8* ytexture; u8* utexture; @@ -86,21 +64,11 @@ typedef struct THPHeader { /* 0x2C */ BE(u32) finalFrameDataOffsets; } THPHeader; -static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); -static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); -static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); - #define THP_AUDIO_BUFFER_COUNT 3 #define THP_READ_BUFFER_COUNT 10 #define THP_TEXTURE_SET_COUNT 3 #endif -#if TARGET_PC -namespace dusk { - void MoviePlayerShutdown(); -} -#endif - struct daMP_THPPlayer { /* 0x000 */ DVDFileInfo fileInfo; /* 0x03C */ THPHeader header; @@ -170,9 +138,8 @@ public: static int daMP_c_Callback_Main(daMP_c*); static int daMP_c_Callback_Draw(daMP_c*); - static daMP_c* m_myObj; + static DUSK_GAME_DATA daMP_c* m_myObj; -private: /* 0x568 */ u32 (*mpGetMovieRestFrame)(void); /* 0x56C */ void (*mpSetPercentMovieVol)(f32); /* 0x570 */ u32 (*mpTHPGetTotalFrame)(void); diff --git a/include/d/actor/d_a_myna.h b/include/d/actor/d_a_myna.h index 0ef55d11ad..511f7b11e6 100644 --- a/include/d/actor/d_a_myna.h +++ b/include/d/actor/d_a_myna.h @@ -131,8 +131,8 @@ public: typedef void (daMyna_c::*ProcFunc)(); typedef int (daMyna_c::*BaseMotionFunc)(int); - static dCcD_SrcSph const mCcDSph; - static daMyna_c::BaseMotionFunc mBaseMotionTBL[7]; + static DUSK_GAME_DATA dCcD_SrcSph const mCcDSph; + static DUSK_GAME_DATA daMyna_c::BaseMotionFunc mBaseMotionTBL[7]; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ mDoExt_McaMorfSO* mpMorf; diff --git a/include/d/actor/d_a_nbomb.h b/include/d/actor/d_a_nbomb.h index 4c5eb820ff..15c91043ff 100644 --- a/include/d/actor/d_a_nbomb.h +++ b/include/d/actor/d_a_nbomb.h @@ -91,7 +91,7 @@ public: s16 getExTime() { return mExTime; } - static const char* m_arcNameList[6]; + static DUSK_GAME_DATA const char* m_arcNameList[6]; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_npc.h b/include/d/actor/d_a_npc.h index 70e3e01270..51425bb912 100644 --- a/include/d/actor/d_a_npc.h +++ b/include/d/actor/d_a_npc.h @@ -29,7 +29,7 @@ struct daNpc_GetParam3 { // name unknown }; class daNpcT_ActorMngr_c { -private: +public: /* 0x0 */ fpc_ProcID mActorID; public: @@ -44,7 +44,7 @@ public: }; class daNpcT_MatAnm_c : public J3DMaterialAnm { -private: +public: /* 0x0F4 */ mutable f32 field_0xF4; /* 0x0F8 */ mutable f32 field_0xF8; /* 0x0FC */ f32 mNowOffsetX; @@ -102,7 +102,6 @@ public: } void setOffset(int i_offset) { mOffset = i_offset; } -private: /* 0x00 */ sequenceStepData_c const* mpSeqData; /* 0x04 */ int mStepNum; /* 0x08 */ int mNo; @@ -217,7 +216,7 @@ public: }; class daNpcT_JntAnm_c { -private: +public: /* 0x000 */ daNpcT_ActorMngr_c mActrMngr; /* 0x008 */ cXyz mPos; /* 0x014 */ cXyz mAttnPos; @@ -776,12 +775,12 @@ public: return chkFindActor(daPy_getPlayerActorClass(), param_0, param_1); } - static dCcD_SrcGObjInf const mCcDObjData; - static dCcD_SrcCyl mCcDCyl; - static dCcD_SrcSph mCcDSph; - static fopAc_ac_c* mFindActorPtrs[50]; - static s16 mSrchName; - static int mFindCount; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjData; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA fopAc_ac_c* mFindActorPtrs[50]; + static DUSK_GAME_DATA s16 mSrchName; + static DUSK_GAME_DATA int mFindCount; enum Mode { /* 0 */ MODE_ENTER, diff --git a/include/d/actor/d_a_npc2.h b/include/d/actor/d_a_npc2.h index 58343a47b0..2453ba1f30 100644 --- a/include/d/actor/d_a_npc2.h +++ b/include/d/actor/d_a_npc2.h @@ -15,7 +15,6 @@ public: fopAc_ac_c* getActor(); virtual ~daBaseNpc_acMngr_c() {} -private: /* 0x04 */ fpc_ProcID mActorId; }; @@ -113,9 +112,9 @@ public: virtual void drawOtherMdls(); virtual bool dbgDraw(); - static dCcD_SrcGObjInf const mCcDObj; - static dCcD_SrcCyl mCcDCyl; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObj; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; public: /* 0x56C */ dBgS_ObjAcch mAcch; @@ -173,9 +172,9 @@ public: virtual int ToFore() { return 1; } virtual int ToBack() { return 1; } - static const char* m_name; - static int m_dzb_id; - static MoveBGActor_SetFunc m_set_func; + static DUSK_GAME_DATA const char* m_name; + static DUSK_GAME_DATA int m_dzb_id; + static DUSK_GAME_DATA MoveBGActor_SetFunc m_set_func; public: /* 0xA14 */ dBgW* mpBgw; diff --git a/include/d/actor/d_a_npc4.h b/include/d/actor/d_a_npc4.h index 6532d92842..1bf39f54ec 100644 --- a/include/d/actor/d_a_npc4.h +++ b/include/d/actor/d_a_npc4.h @@ -12,7 +12,7 @@ #include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" class daNpcF_ActorMngr_c { -private: +public: /* 0x0 */ fpc_ProcID mActorID; public: @@ -52,7 +52,7 @@ BOOL daNpcF_chkPassed(cXyz i_pos, dPnt* i_points, u16 i_idx, u16 i_num, BOOL i_i BOOL daNpcF_chkDoBtnEqSpeak(fopAc_ac_c* i_actor_p); class daNpcF_SPCurve_c { -private: +public: /* 0x00 */ u16 mNurbs; /* 0x02 */ u16 field_0x02; /* 0x04 */ u8 mIsReversed; @@ -119,7 +119,7 @@ public: }; // Size: 0x630 class daNpcF_MatAnm_c : public J3DMaterialAnm { -private: +public: /* 0x0F4 */ mutable f32 field_0xF4; /* 0x0F8 */ mutable f32 field_0xF8; /* 0x0FC */ f32 mNowOffsetX; @@ -138,7 +138,7 @@ public: }; class daNpcF_Lookat_c { -private: +public: /* 0x00 */ cXyz mJointPos[4]; /* 0x30 */ cXyz* mAttnPos_p; /* 0x34 */ csXyz mAngularMoveDis[4]; @@ -394,19 +394,18 @@ public: void onHide() { mHide = true; } void offHide() { mHide = false; } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; - static dCcD_SrcSph mCcDSph; - static fopAc_ac_c* mFindActorPList[100]; - static s32 mFindCount; - static s16 mSrchActorName; - static char mFileNameBuf[0x15]; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA fopAc_ac_c* mFindActorPList[100]; + static DUSK_GAME_DATA s32 mFindCount; + static DUSK_GAME_DATA s16 mSrchActorName; + static DUSK_GAME_DATA char mFileNameBuf[0x15]; }; STATIC_ASSERT(sizeof(daNpcF_c) == 0xB48); class daNpcF_MoveBgActor_c : public daNpcF_c { -private: public: // these functions are inferred based on daBaseNpc_moveBgActor_c - // defining them in this order fixes weak function order for this class in d_a_npc diff --git a/include/d/actor/d_a_npc_aru.h b/include/d/actor/d_a_npc_aru.h index a0a30a676f..a41e45acba 100644 --- a/include/d/actor/d_a_npc_aru.h +++ b/include/d/actor/d_a_npc_aru.h @@ -17,7 +17,7 @@ class daNpc_Aru_Param_c { public: virtual ~daNpc_Aru_Param_c() {} - static daNpc_Aru_HIOParam const m; + static DUSK_GAME_DATA daNpc_Aru_HIOParam const m; }; #if DEBUG @@ -171,10 +171,9 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } void setLastIn() { mLastGoatIn = true; } - static char DUSK_CONST* DUSK_CONST mCutNameList[7]; - static cutFunc DUSK_CONST mCutList[7]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0xE40 */ NPC_ARU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_ash.h b/include/d/actor/d_a_npc_ash.h index 084569a66e..e9f6e3427a 100644 --- a/include/d/actor/d_a_npc_ash.h +++ b/include/d/actor/d_a_npc_ash.h @@ -12,7 +12,7 @@ public: daNpcAsh_Param_c() {} virtual ~daNpcAsh_Param_c() {} - static const daNpcAsh_HIOParam m; + static DUSK_GAME_DATA const daNpcAsh_HIOParam m; }; #if DEBUG @@ -143,9 +143,8 @@ public: inline bool step(s16, bool); inline void playExpression(); - static EventFn mEvtSeqList[6]; + static DUSK_GAME_DATA EventFn mEvtSeqList[6]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ J3DModel* mModelBow; /* 0xBDC */ J3DModel* mModelQuiver; diff --git a/include/d/actor/d_a_npc_ashB.h b/include/d/actor/d_a_npc_ashB.h index 12037188c6..9b158acf2d 100644 --- a/include/d/actor/d_a_npc_ashB.h +++ b/include/d/actor/d_a_npc_ashB.h @@ -12,7 +12,7 @@ class daNpcAshB_Param_c { public: virtual ~daNpcAshB_Param_c() {} - static const daNpcAshB_HIOParam m; + static DUSK_GAME_DATA const daNpcAshB_HIOParam m; }; #if DEBUG @@ -135,9 +135,8 @@ public: inline bool step(s16, int, f32); inline void playExpression(); - static EventFn DUSK_CONST mEvtSeqList[2]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[2]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_npc_bans.h b/include/d/actor/d_a_npc_bans.h index b09143caa7..0da1a71b92 100644 --- a/include/d/actor/d_a_npc_bans.h +++ b/include/d/actor/d_a_npc_bans.h @@ -22,7 +22,7 @@ class daNpc_Bans_Param_c { public: virtual ~daNpc_Bans_Param_c() {} - static daNpc_Bans_HIOParam const m; + static DUSK_GAME_DATA daNpc_Bans_HIOParam const m; }; #if DEBUG @@ -117,8 +117,8 @@ public: return rv; } - static char DUSK_CONST* DUSK_CONST mCutNameList[4]; - static cutFunc DUSK_CONST mCutList[4]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[4]; /* 0x0F7C */ mDoExt_McaMorfSO* mpScoopMorf; /* 0x0F80 */ NPC_BANS_HIO_CLASS* mHIO; diff --git a/include/d/actor/d_a_npc_besu.h b/include/d/actor/d_a_npc_besu.h index f0e26e1538..04579f595b 100644 --- a/include/d/actor/d_a_npc_besu.h +++ b/include/d/actor/d_a_npc_besu.h @@ -15,7 +15,7 @@ class daNpc_Besu_Param_c { public: virtual ~daNpc_Besu_Param_c() {} - static const daNpc_Besu_HIOParam m; + static DUSK_GAME_DATA const daNpc_Besu_HIOParam m; }; #if DEBUG @@ -140,10 +140,9 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xff00) >> 8; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } - static char DUSK_CONST* DUSK_CONST mCutNameList[15]; - static cutFunc DUSK_CONST mCutList[15]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[15]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[15]; -private: /* 0x0E40 */ mDoExt_McaMorfSO* mpCupModelMorf; /* 0x0E44 */ NPC_BESU_HIO_CLASS* mpHIO; /* 0x0E48 */ J3DModel* mpClothModel[1]; diff --git a/include/d/actor/d_a_npc_blue_ns.h b/include/d/actor/d_a_npc_blue_ns.h index 8920bc1be5..8235ad7b25 100644 --- a/include/d/actor/d_a_npc_blue_ns.h +++ b/include/d/actor/d_a_npc_blue_ns.h @@ -14,7 +14,7 @@ class daNpcBlueNS_Param_c { public: virtual ~daNpcBlueNS_Param_c() {} - static const daNpcBlueNS_HIOParam m; + static DUSK_GAME_DATA const daNpcBlueNS_HIOParam m; }; #if DEBUG @@ -124,7 +124,7 @@ public: return var_r30; } - static EventFn DUSK_CONST mEvtSeqList[]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[]; /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ u8 field_0xBD8[0xBDC - 0xBD8]; diff --git a/include/d/actor/d_a_npc_bou.h b/include/d/actor/d_a_npc_bou.h index 25dd490fd9..d0379b9a1b 100644 --- a/include/d/actor/d_a_npc_bou.h +++ b/include/d/actor/d_a_npc_bou.h @@ -16,7 +16,7 @@ struct daNpc_Bou_HIOParam { public: virtual ~daNpc_Bou_Param_c() {} - static const daNpc_Bou_HIOParam m; + static DUSK_GAME_DATA const daNpc_Bou_HIOParam m; }; #if DEBUG @@ -114,8 +114,8 @@ public: virtual int drawDbgInfo(); virtual void changeAnm(int*, int*); - static char DUSK_CONST* DUSK_CONST mCutNameList[9]; - static cutFunc DUSK_CONST mCutList[9]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[9]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[9]; int getFlowNodeNo() { u16 nodeNo = home.angle.x; @@ -168,7 +168,6 @@ public: return 0; } -private: /* 0xE40 */ NPC_BOU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl1; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_bouS.h b/include/d/actor/d_a_npc_bouS.h index 27eafb48fd..7d6f48fb53 100644 --- a/include/d/actor/d_a_npc_bouS.h +++ b/include/d/actor/d_a_npc_bouS.h @@ -29,7 +29,7 @@ class daNpcBouS_Param_c { public: virtual ~daNpcBouS_Param_c() {} - static daNpcBouS_HIOParam const m; + static DUSK_GAME_DATA daNpcBouS_HIOParam const m; }; #if DEBUG @@ -128,9 +128,8 @@ public: mForcibleTalk = 1; } - static eventFunc mEvtSeqList[4]; + static DUSK_GAME_DATA eventFunc mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_cd.h b/include/d/actor/d_a_npc_cd.h index 3f942a5988..21483c29c1 100644 --- a/include/d/actor/d_a_npc_cd.h +++ b/include/d/actor/d_a_npc_cd.h @@ -25,7 +25,7 @@ public: J3DModelData* getObjMdlDataP(int); virtual ~daNpcCd_c() {} - static dCcD_SrcCyl const m_cylDat; + static DUSK_GAME_DATA dCcD_SrcCyl const m_cylDat; /* 0x56C */ request_of_phase_process_class mPhase1; /* 0x574 */ request_of_phase_process_class mPhase2; @@ -101,7 +101,7 @@ public: STATIC_ASSERT(sizeof(daNpcCd_HIO_c) == 0x29BC); -extern daNpcCd_HIO_c l_Cd_HIO; +DUSK_GAME_EXTERN daNpcCd_HIO_c l_Cd_HIO; inline f32 HIO_atnOfs(int param_1) { s16 rv; if (param_1 < 16) { diff --git a/include/d/actor/d_a_npc_cd2.h b/include/d/actor/d_a_npc_cd2.h index 3d2eaa87c5..d37a09f99e 100644 --- a/include/d/actor/d_a_npc_cd2.h +++ b/include/d/actor/d_a_npc_cd2.h @@ -87,7 +87,7 @@ struct daNpcCd2_HIO_c : public fOpAcm_HIO_entry_c { /* 0x20C4 */ daNpcCd2_HIO_WChild_c field_0x20c4[14]; }; -extern daNpcCd2_HIO_c l_Cd2_HIO; +DUSK_GAME_EXTERN daNpcCd2_HIO_c l_Cd2_HIO; inline s16 Cd2_HIO_atnOfs(int param_1) { s16 rv; @@ -269,7 +269,7 @@ public: J3DAnmTexPattern* getTexAnmP(int); virtual ~daNpcCd2_c() {} - static dCcD_SrcCyl const m_cylDat; + static DUSK_GAME_DATA dCcD_SrcCyl const m_cylDat; /* 0x56C */ request_of_phase_process_class mPhase1; /* 0x574 */ request_of_phase_process_class mPhase2; diff --git a/include/d/actor/d_a_npc_cdn3.h b/include/d/actor/d_a_npc_cdn3.h index 84a98ebd74..f3b920c81c 100644 --- a/include/d/actor/d_a_npc_cdn3.h +++ b/include/d/actor/d_a_npc_cdn3.h @@ -334,52 +334,52 @@ public: actionFunc mExecFn; }; - static const ActionPair ActionTable[8]; - static seqFunc* m_funcTbl[44]; - static seqFunc m_seq00_funcTbl[2]; - static seqFunc m_seq01_funcTbl[2]; - static seqFunc m_seq02_funcTbl[2]; - static seqFunc m_seq03_funcTbl[2]; - static seqFunc m_seq04_funcTbl[2]; - static seqFunc m_seq05_funcTbl[4]; - static seqFunc m_seq06_funcTbl[4]; - static seqFunc m_seq07_funcTbl[2]; - static seqFunc m_seq08_funcTbl[7]; - static seqFunc m_seq09_funcTbl[2]; - static seqFunc m_seq10_funcTbl[2]; - static seqFunc m_seq11_funcTbl[6]; - static seqFunc m_seq12_funcTbl[2]; - static seqFunc m_seq13_funcTbl[6]; - static seqFunc m_seq14_funcTbl[2]; - static seqFunc m_seq15_funcTbl[2]; - static seqFunc m_seq16_funcTbl[7]; - static seqFunc m_seq17_funcTbl[2]; - static seqFunc m_seq18_funcTbl[2]; - static seqFunc m_seq19_funcTbl[7]; - static seqFunc m_seq20_funcTbl[2]; - static seqFunc m_seq21_funcTbl[2]; - static seqFunc m_seq22_funcTbl[4]; - static seqFunc m_seq23_funcTbl[7]; - static seqFunc m_seq24_funcTbl[5]; - static seqFunc m_seq25_funcTbl[7]; - static seqFunc m_seq26_funcTbl[3]; - static seqFunc m_seq27_funcTbl[2]; - static seqFunc m_seq28_funcTbl[3]; - static seqFunc m_seq29_funcTbl[3]; - static seqFunc m_seq30_funcTbl[6]; - static seqFunc m_seq31_funcTbl[6]; - static seqFunc m_seq32_funcTbl[7]; - static seqFunc m_seq33_funcTbl[7]; - static seqFunc m_seq34_funcTbl[9]; - static seqFunc m_seq35_funcTbl[2]; - static seqFunc m_seq36_funcTbl[4]; - static seqFunc m_seq37_funcTbl[2]; - static seqFunc m_seq38_funcTbl[2]; - static seqFunc m_seq39_funcTbl[2]; - static seqFunc m_seq40_funcTbl[3]; - static seqFunc m_seq41_funcTbl[2]; - static seqFunc m_seq42_funcTbl[2]; - static seqFunc m_seq43_funcTbl[3]; + static DUSK_GAME_DATA const ActionPair ActionTable[8]; + static DUSK_GAME_DATA seqFunc* m_funcTbl[44]; + static DUSK_GAME_DATA seqFunc m_seq00_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq01_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq02_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq03_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq04_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq05_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq06_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq07_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq08_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq09_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq10_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq11_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq12_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq13_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq14_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq15_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq16_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq17_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq18_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq19_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq20_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq21_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq22_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq23_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq24_funcTbl[5]; + static DUSK_GAME_DATA seqFunc m_seq25_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq26_funcTbl[3]; + static DUSK_GAME_DATA seqFunc m_seq27_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq28_funcTbl[3]; + static DUSK_GAME_DATA seqFunc m_seq29_funcTbl[3]; + static DUSK_GAME_DATA seqFunc m_seq30_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq31_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq32_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq33_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq34_funcTbl[9]; + static DUSK_GAME_DATA seqFunc m_seq35_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq36_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq37_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq38_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq39_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq40_funcTbl[3]; + static DUSK_GAME_DATA seqFunc m_seq41_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq42_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq43_funcTbl[3]; /* 0xAC8 */ J3DModel* field_0xac8; /* 0xACC */ J3DModel* field_0xacc; diff --git a/include/d/actor/d_a_npc_chat.h b/include/d/actor/d_a_npc_chat.h index a835a4c49d..88ddc9a8b3 100644 --- a/include/d/actor/d_a_npc_chat.h +++ b/include/d/actor/d_a_npc_chat.h @@ -11,7 +11,7 @@ class daNpcChat_Param_c { public: virtual ~daNpcChat_Param_c() {} - static daNpcChat_HIOParam const m; + static DUSK_GAME_DATA daNpcChat_HIOParam const m; }; #if DEBUG @@ -102,9 +102,8 @@ public: void setFear() { mFear = true; } void setTalkFlag() { mTalkFlag = true; } - static eventFunc DUSK_CONST mEvtSeqList[1]; + static DUSK_GAME_DATA eventFunc DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0xBF0 */ J3DModel* mObjModel; diff --git a/include/d/actor/d_a_npc_chin.h b/include/d/actor/d_a_npc_chin.h index e4bfdb6a61..1e87de4e9f 100644 --- a/include/d/actor/d_a_npc_chin.h +++ b/include/d/actor/d_a_npc_chin.h @@ -12,7 +12,7 @@ class daNpcChin_Param_c { public: virtual ~daNpcChin_Param_c() {} - static daNpcChin_HIOParam const m; + static DUSK_GAME_DATA daNpcChin_HIOParam const m; }; #if DEBUG @@ -183,7 +183,7 @@ public: inline void ForcibleTalk_Off() { field_0xe06 = 0; } inline u8 getForcibleTalk2() { return field_0xe06; } - static eventFunc mEvtSeqList[8]; + static DUSK_GAME_DATA eventFunc mEvtSeqList[8]; /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_clerka.h b/include/d/actor/d_a_npc_clerka.h index 92236edb03..6479bae503 100644 --- a/include/d/actor/d_a_npc_clerka.h +++ b/include/d/actor/d_a_npc_clerka.h @@ -14,7 +14,7 @@ class daNpc_clerkA_Param_c { public: virtual ~daNpc_clerkA_Param_c() {} - static const daNpc_clerkA_HIOParam m; + static DUSK_GAME_DATA const daNpc_clerkA_HIOParam m; }; #if DEBUG @@ -124,10 +124,9 @@ public: u8 getMaxNumItem() { return (fopAcM_GetParam(this) & 0xF000000) >> 24; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_CLERKA_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_clerkb.h b/include/d/actor/d_a_npc_clerkb.h index 79e13f3a0e..9bc2a39a3a 100644 --- a/include/d/actor/d_a_npc_clerkb.h +++ b/include/d/actor/d_a_npc_clerkb.h @@ -15,7 +15,7 @@ class daNpc_clerkB_Param_c { public: virtual ~daNpc_clerkB_Param_c() {} - static const daNpc_clerkB_HIOParam m; + static DUSK_GAME_DATA const daNpc_clerkB_HIOParam m; }; #if DEBUG @@ -137,10 +137,9 @@ public: u8 getMaxNumItem() { return (fopAcM_GetParam(this) & 0xF000000) >> 24; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ mDoExt_bpkAnm mBpkAnm2; /* 0x0F7C */ NPC_CLERKB_HIO_CLASS* mpHIO; /* 0x0F98 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_clerkt.h b/include/d/actor/d_a_npc_clerkt.h index e21f000c32..a476f83449 100644 --- a/include/d/actor/d_a_npc_clerkt.h +++ b/include/d/actor/d_a_npc_clerkt.h @@ -12,7 +12,7 @@ class daNpcClerkt_Param_c { public: virtual ~daNpcClerkt_Param_c() {} - static const daNpcClerkt_HIOParam m; + static DUSK_GAME_DATA const daNpcClerkt_HIOParam m; }; #if DEBUG @@ -125,10 +125,9 @@ public: } } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_CLERKT_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_coach.h b/include/d/actor/d_a_npc_coach.h index 3917d6f11c..e0ecd63fc2 100644 --- a/include/d/actor/d_a_npc_coach.h +++ b/include/d/actor/d_a_npc_coach.h @@ -295,9 +295,8 @@ public: const daNpcCoach_Attr_c& attr() const { return M_attr; } - static daNpcCoach_Attr_c const M_attr; + static DUSK_GAME_DATA daNpcCoach_Attr_c const M_attr; static u16 const ParticleName[10]; -private: /* 0x0568 */ daNpcChHorse_c mChHorse; /* 0x0E7C */ daNpcChHarness_c mChHarness; /* 0x15D0 */ daNpcChCoach_c mChCoach; diff --git a/include/d/actor/d_a_npc_doc.h b/include/d/actor/d_a_npc_doc.h index 7d9c6dabfe..191a2e5bf2 100644 --- a/include/d/actor/d_a_npc_doc.h +++ b/include/d/actor/d_a_npc_doc.h @@ -12,7 +12,7 @@ class daNpc_Doc_Param_c { public: virtual ~daNpc_Doc_Param_c() {} - static const daNpc_Doc_HIOParam m; + static DUSK_GAME_DATA const daNpc_Doc_HIOParam m; }; #if DEBUG @@ -133,10 +133,9 @@ public: return (fopAcM_GetParam(this) & 0xFF00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_DOC_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_doorboy.h b/include/d/actor/d_a_npc_doorboy.h index 7d6cb47436..3fd6ef1ce8 100644 --- a/include/d/actor/d_a_npc_doorboy.h +++ b/include/d/actor/d_a_npc_doorboy.h @@ -12,7 +12,7 @@ class daNpcDoorBoy_Param_c { public: virtual ~daNpcDoorBoy_Param_c() {} - static daNpcDoorBoy_HIOParam const m; + static DUSK_GAME_DATA daNpcDoorBoy_HIOParam const m; }; #if DEBUG @@ -78,9 +78,8 @@ public: inline int getTimeHour(); inline bool isDummyTalk(); - static EventFn DUSK_CONST mEvtSeqList[1]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0xBF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_drainSol.h b/include/d/actor/d_a_npc_drainSol.h index d61fb243b3..7a197a8a1f 100644 --- a/include/d/actor/d_a_npc_drainSol.h +++ b/include/d/actor/d_a_npc_drainSol.h @@ -11,7 +11,7 @@ class daNpcDrSol_Param_c { public: virtual ~daNpcDrSol_Param_c() {} - static const daNpcDrSol_HIOParam m; + static DUSK_GAME_DATA const daNpcDrSol_HIOParam m; }; #if DEBUG diff --git a/include/d/actor/d_a_npc_fairy.h b/include/d/actor/d_a_npc_fairy.h index d5c1d2fa0e..ff2df4260b 100644 --- a/include/d/actor/d_a_npc_fairy.h +++ b/include/d/actor/d_a_npc_fairy.h @@ -94,7 +94,7 @@ class daNpc_Fairy_Param_c { public: virtual ~daNpc_Fairy_Param_c() {} - static daNpc_Fairy_HIOParam const m; + static DUSK_GAME_DATA daNpc_Fairy_HIOParam const m; }; #if DEBUG @@ -294,9 +294,8 @@ public: u8 getSceneNo1() { return (fopAcM_GetParam(this) >> 8) & 0xFF; } u8 getSceneNo2() { return (fopAcM_GetParam(this) >> 16) & 0xFF; } - static char DUSK_CONST* DUSK_CONST mCutNameList[18]; - static cutFunc DUSK_CONST mCutList[18]; -private: + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[18]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[18]; /* 0x0E40 */ NPC_FAIRY_HIO_CLASS* mHIO; /* 0x0E44 */ dCcD_Cyl mCyl; /* 0x0F80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_fairy_seirei.h b/include/d/actor/d_a_npc_fairy_seirei.h index 62b3cbcc6c..d47b2a17eb 100644 --- a/include/d/actor/d_a_npc_fairy_seirei.h +++ b/include/d/actor/d_a_npc_fairy_seirei.h @@ -13,7 +13,7 @@ class daNpc_FairySeirei_Param_c { public: virtual ~daNpc_FairySeirei_Param_c() {} - static daNpc_FairySeirei_HIOParam const m; + static DUSK_GAME_DATA daNpc_FairySeirei_HIOParam const m; }; #if DEBUG @@ -90,10 +90,9 @@ public: int getSeneNo() { return (fopAcM_GetParam(this) >> 8) & 0xFF; } - static DUSK_CONST char* mCutNameList[1]; - static DUSK_CONST cutFunc mCutList[1]; + static DUSK_GAME_DATA DUSK_CONST char* mCutNameList[1]; + static DUSK_GAME_DATA DUSK_CONST cutFunc mCutList[1]; -private: /* 0xE40 */ NPC_FAIRY_SEIREI_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_gnd.h b/include/d/actor/d_a_npc_gnd.h index d76fae5d61..cb0289055e 100644 --- a/include/d/actor/d_a_npc_gnd.h +++ b/include/d/actor/d_a_npc_gnd.h @@ -11,7 +11,7 @@ class daNpc_Gnd_Param_c { public: virtual ~daNpc_Gnd_Param_c() {} - static const daNpc_Gnd_HIOParam m; + static DUSK_GAME_DATA const daNpc_Gnd_HIOParam m; }; #if DEBUG @@ -96,10 +96,9 @@ public: s32 getNeckJointNo() { return 3; } s32 getBackboneJointNo() { return 1; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_GND_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl1; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_gra.h b/include/d/actor/d_a_npc_gra.h index 117aa9ade0..f16b445195 100644 --- a/include/d/actor/d_a_npc_gra.h +++ b/include/d/actor/d_a_npc_gra.h @@ -21,7 +21,7 @@ class daNpc_grA_Param_c { public: virtual ~daNpc_grA_Param_c() {} - static daNpc_grA_HIOParam const m; + static DUSK_GAME_DATA daNpc_grA_HIOParam const m; }; #if DEBUG @@ -138,11 +138,10 @@ public: void addCarryNum() { field_0x1692++; } u8 getPathNoFromParam() { return home.angle.z; } void setGateWalk() { field_0x14D0 = 1; } - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[12]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[12]; typedef BOOL (daNpc_grA_c::*cut_type)(int); - static cut_type DUSK_CONST mEvtCutList[]; + static DUSK_GAME_DATA cut_type DUSK_CONST mEvtCutList[]; -private: typedef BOOL (daNpc_grA_c::*daNpc_grA_c_Action)(void*); /* 0x0B48 */ Z2Creature mCreature; diff --git a/include/d/actor/d_a_npc_grc.h b/include/d/actor/d_a_npc_grc.h index 072a4f9fd2..53a483b51d 100644 --- a/include/d/actor/d_a_npc_grc.h +++ b/include/d/actor/d_a_npc_grc.h @@ -12,7 +12,7 @@ class daNpc_grC_Param_c { public: virtual ~daNpc_grC_Param_c() {} - static daNpc_grC_HIOParam const m; + static DUSK_GAME_DATA daNpc_grC_HIOParam const m; }; #if DEBUG @@ -89,10 +89,9 @@ public: void setPrtcl(); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList; - static EventFn DUSK_CONST mEvtCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ int field_0xbd8; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grd.h b/include/d/actor/d_a_npc_grd.h index e8a9e19baf..64afa3ef2c 100644 --- a/include/d/actor/d_a_npc_grd.h +++ b/include/d/actor/d_a_npc_grd.h @@ -11,7 +11,7 @@ class daNpc_Grd_Param_c { public: virtual ~daNpc_Grd_Param_c() {} - static daNpc_Grd_HIOParam const m; + static DUSK_GAME_DATA daNpc_Grd_HIOParam const m; }; #if DEBUG @@ -81,10 +81,9 @@ public: BOOL ECut_nodToGrz(int); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; - static cutFunc DUSK_CONST mEvtCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grm.h b/include/d/actor/d_a_npc_grm.h index addd5485be..c820eabbc3 100644 --- a/include/d/actor/d_a_npc_grm.h +++ b/include/d/actor/d_a_npc_grm.h @@ -12,7 +12,7 @@ class daNpc_grM_Param_c { public: virtual ~daNpc_grM_Param_c() {} - static daNpc_grM_HIOParam const m; + static DUSK_GAME_DATA daNpc_grM_HIOParam const m; }; #if DEBUG @@ -131,10 +131,9 @@ public: BOOL checkChangeJoint(int param_0) { return param_0 == JNT_HEAD; } BOOL checkRemoveJoint(int param_0) { return param_0 == JNT_MOUTH; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0F7C */ NPC_GRM_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_grmc.h b/include/d/actor/d_a_npc_grmc.h index 4d1752c266..1d87c39a4d 100644 --- a/include/d/actor/d_a_npc_grmc.h +++ b/include/d/actor/d_a_npc_grmc.h @@ -38,7 +38,7 @@ class daNpc_grMC_Param_c { public: virtual ~daNpc_grMC_Param_c() {} - static daNpc_grMC_HIOParam const m; + static DUSK_GAME_DATA daNpc_grMC_HIOParam const m; }; class daNpc_grMC_c : public dShopSystem_c { @@ -124,10 +124,9 @@ public: BOOL checkRemoveJoint(int param_1) { return param_1 == JNT_MOUTH; } u16 getEyeballMaterialNo() { return 1; }; - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_GRMC_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_gro.h b/include/d/actor/d_a_npc_gro.h index 0881270516..8bc6c8c93e 100644 --- a/include/d/actor/d_a_npc_gro.h +++ b/include/d/actor/d_a_npc_gro.h @@ -20,7 +20,7 @@ class daNpc_grO_Param_c { public: virtual ~daNpc_grO_Param_c() {} - static daNpc_grO_HIOParam const m; + static DUSK_GAME_DATA daNpc_grO_HIOParam const m; }; #if DEBUG @@ -85,10 +85,9 @@ public: int test(void*); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; - static cutFunc DUSK_CONST mEvtCutList[3]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[3]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpOtherModel[1]; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_grr.h b/include/d/actor/d_a_npc_grr.h index 280df27a48..4caf927d75 100644 --- a/include/d/actor/d_a_npc_grr.h +++ b/include/d/actor/d_a_npc_grr.h @@ -11,7 +11,7 @@ class daNpc_grR_Param_c { public: virtual ~daNpc_grR_Param_c() {} - static daNpc_grR_HIOParam const m; + static DUSK_GAME_DATA daNpc_grR_HIOParam const m; }; #if DEBUG @@ -83,10 +83,9 @@ public: int test(void*); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList; - static cutFunc DUSK_CONST mEvtCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grs.h b/include/d/actor/d_a_npc_grs.h index d08b4ec008..9c1ac788dc 100644 --- a/include/d/actor/d_a_npc_grs.h +++ b/include/d/actor/d_a_npc_grs.h @@ -11,7 +11,7 @@ class daNpc_grS_Param_c { public: virtual ~daNpc_grS_Param_c() {} - static const daNpc_grS_HIOParam m; + static DUSK_GAME_DATA const daNpc_grS_HIOParam m; }; #if DEBUG @@ -84,10 +84,9 @@ public: void setPrtcl(); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; - static cutFunc DUSK_CONST mEvtCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_npc_grz.h b/include/d/actor/d_a_npc_grz.h index 555b1f09e2..249720276f 100644 --- a/include/d/actor/d_a_npc_grz.h +++ b/include/d/actor/d_a_npc_grz.h @@ -28,7 +28,7 @@ class daNpc_Grz_Param_c { public: virtual ~daNpc_Grz_Param_c() {} - static daNpc_Grz_HIOParam const m; + static DUSK_GAME_DATA daNpc_Grz_HIOParam const m; }; #if DEBUG @@ -116,10 +116,9 @@ public: u8 getPathNoFromParam() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[7]; - static cutFunc DUSK_CONST mEvtCutList[7]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[7]; -private: /* 0x0B48 */ Z2Creature mSound; /* 0x0BD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0x0BDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_guard.h b/include/d/actor/d_a_npc_guard.h index bae98e223c..59a6719c9d 100644 --- a/include/d/actor/d_a_npc_guard.h +++ b/include/d/actor/d_a_npc_guard.h @@ -60,9 +60,8 @@ public: u32 getPathID() { return fopAcM_GetParam(this) >> 0x10 & 0xFF; } - static actionFunc ActionTable[7][2]; + static DUSK_GAME_DATA actionFunc ActionTable[7][2]; -private: /* 0xAC8 */ J3DModel* mpModel; /* 0xACC */ J3DModel* mpModel2; /* 0xAD0 */ J3DAnmTransformKey* mpAnmKey; diff --git a/include/d/actor/d_a_npc_gwolf.h b/include/d/actor/d_a_npc_gwolf.h index e9c37a38bb..f7f4bc5a8e 100644 --- a/include/d/actor/d_a_npc_gwolf.h +++ b/include/d/actor/d_a_npc_gwolf.h @@ -19,7 +19,7 @@ class daNpc_GWolf_Param_c { public: virtual ~daNpc_GWolf_Param_c() {} - static daNpc_GWolf_HIOParam const m; + static DUSK_GAME_DATA daNpc_GWolf_HIOParam const m; }; #if DEBUG @@ -104,10 +104,9 @@ public: void setHowlingEndFlag() { field_0xe1c = 2; } void setHowlingFlag() { field_0xe1c = 1; } - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[5]; - static cutFunc DUSK_CONST mEvtCutList[5]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[5]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[5]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_hanjo.h b/include/d/actor/d_a_npc_hanjo.h index 6e912cb638..76d354b743 100644 --- a/include/d/actor/d_a_npc_hanjo.h +++ b/include/d/actor/d_a_npc_hanjo.h @@ -23,7 +23,7 @@ class daNpc_Hanjo_Param_c { public: virtual ~daNpc_Hanjo_Param_c() {} - static const daNpc_Hanjo_HIOParam m; + static DUSK_GAME_DATA const daNpc_Hanjo_HIOParam m; }; #if DEBUG @@ -217,11 +217,10 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xff00) >> 8; } - static dCcD_SrcGObjInf const mStoneCcDObjInfo; - static char DUSK_CONST* DUSK_CONST mCutNameList[6]; - static cutFunc DUSK_CONST mCutList[6]; - static dCcD_SrcSph DUSK_CONST mStoneCcDSph; -private: + static DUSK_GAME_DATA dCcD_SrcGObjInf const mStoneCcDObjInfo; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[6]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[6]; + static DUSK_GAME_DATA dCcD_SrcSph DUSK_CONST mStoneCcDSph; /* 0x0E40 */ NPC_HANJO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mModel1; /* 0x0E48 */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_npc_henna0.h b/include/d/actor/d_a_npc_henna0.h index 112904d144..63da974cde 100644 --- a/include/d/actor/d_a_npc_henna0.h +++ b/include/d/actor/d_a_npc_henna0.h @@ -12,7 +12,7 @@ * */ class d_a_npc_henna0 : public fopAc_ac_c { - private: + public: /* 0x568 */ u8 field_0x568[0x828 - 0x568]; }; diff --git a/include/d/actor/d_a_npc_hoz.h b/include/d/actor/d_a_npc_hoz.h index 72ec648696..57a2169c78 100644 --- a/include/d/actor/d_a_npc_hoz.h +++ b/include/d/actor/d_a_npc_hoz.h @@ -13,7 +13,7 @@ class daNpc_Hoz_Param_c { public: virtual ~daNpc_Hoz_Param_c() {} - static const daNpc_Hoz_HIOParam m; + static DUSK_GAME_DATA const daNpc_Hoz_HIOParam m; }; #if DEBUG @@ -125,10 +125,9 @@ public: bool getGameStartFlag() { return mGameStartFlag; } void setPotBreakFlag() { mPotBreakFlag = true; } - static char DUSK_CONST* DUSK_CONST mCutNameList[8]; - static cutFunc DUSK_CONST mCutList[]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[8]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[]; -private: /* 0xE40 */ NPC_HOZ_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_impal.h b/include/d/actor/d_a_npc_impal.h index 7b8234717a..f6753be0e2 100644 --- a/include/d/actor/d_a_npc_impal.h +++ b/include/d/actor/d_a_npc_impal.h @@ -12,7 +12,7 @@ class daNpcImpal_Param_c { public: virtual ~daNpcImpal_Param_c() {} - static const daNpcImpal_HIOParam m; + static DUSK_GAME_DATA const daNpcImpal_HIOParam m; }; #if DEBUG @@ -121,9 +121,8 @@ public: inline void setLookMode(int i_lookMode); inline void deleteObstacle(); - static EventFn mEvtSeqList[4]; + static DUSK_GAME_DATA EventFn mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_ins.h b/include/d/actor/d_a_npc_ins.h index 3f8b40a9a0..fd133a7a79 100644 --- a/include/d/actor/d_a_npc_ins.h +++ b/include/d/actor/d_a_npc_ins.h @@ -12,7 +12,7 @@ class daNpcIns_Param_c { public: virtual ~daNpcIns_Param_c() {} - static daNpcIns_HIOParam const m; + static DUSK_GAME_DATA daNpcIns_HIOParam const m; }; #if DEBUG @@ -119,9 +119,8 @@ public: inline void playExpression(); BOOL chkAction(actionFunc action) { return action == mAction; } - static eventFunc mEvtSeqList[1]; + static DUSK_GAME_DATA eventFunc mEvtSeqList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpUmbrellaModel; /* 0xBDC */ J3DModel* mpKagoModel; diff --git a/include/d/actor/d_a_npc_jagar.h b/include/d/actor/d_a_npc_jagar.h index 3c4a4ac723..e933d28bf4 100644 --- a/include/d/actor/d_a_npc_jagar.h +++ b/include/d/actor/d_a_npc_jagar.h @@ -25,7 +25,7 @@ class daNpc_Jagar_Param_c { public: virtual ~daNpc_Jagar_Param_c() {} - static const daNpc_Jagar_HIOParam m; + static DUSK_GAME_DATA const daNpc_Jagar_HIOParam m; }; #if DEBUG @@ -223,9 +223,8 @@ public: return 0; } - static char DUSK_CONST* DUSK_CONST mCutNameList[7]; - static cutFunc DUSK_CONST mCutList[7]; -private: + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; /* 0x0E40 */ NPC_JAGAR_HIO_CLASS* mpHIO; /* 0x0E44 */ dCcD_Cyl mCyl1; /* 0x0F80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_kakashi.h b/include/d/actor/d_a_npc_kakashi.h index 7a5cca61f3..a21117376d 100644 --- a/include/d/actor/d_a_npc_kakashi.h +++ b/include/d/actor/d_a_npc_kakashi.h @@ -14,7 +14,7 @@ class daNpc_Kakashi_Param_c { public: virtual ~daNpc_Kakashi_Param_c() {} - static const daNpc_Kakashi_HIOParam m; + static DUSK_GAME_DATA const daNpc_Kakashi_HIOParam m; }; #if DEBUG @@ -113,10 +113,9 @@ public: u8 getBitSW() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u8 getBitSW2() { return (fopAcM_GetParam(this) & 0xFF0000) >> 16; } - static char DUSK_CONST* DUSK_CONST mCutNameList[4]; - static int (daNpc_Kakashi_c::* DUSK_CONST mCutList[])(int); + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; + static DUSK_GAME_DATA int (daNpc_Kakashi_c::* DUSK_CONST mCutList[])(int); -private: /* 0x0E40 */ NPC_KAKASHI_HIO_CLASS* mpHIO; /* 0x0E44 */ Z2SoundObjSimple mSound; /* 0x0E64 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_npc_kasi_hana.h b/include/d/actor/d_a_npc_kasi_hana.h index e355ed8c55..302c3d84ab 100644 --- a/include/d/actor/d_a_npc_kasi_hana.h +++ b/include/d/actor/d_a_npc_kasi_hana.h @@ -25,7 +25,7 @@ class daNpcKasiHana_Param_c { public: virtual ~daNpcKasiHana_Param_c() {} - static daNpcKasiHana_HIOParam const m; + static DUSK_GAME_DATA daNpcKasiHana_HIOParam const m; }; #if DEBUG @@ -201,12 +201,11 @@ public: BOOL pl_front_check() { return actor_front_check(daPy_getPlayerActorClass()); } void setEscapePathDir() { if (pl_front_check()) mPath.reverse(); } - static EventFn mEvtSeqList[6]; - static daTagEscape_c* mTargetTag; - static f32 mTargetTagDist; - static s16 mWolfAngle; + static DUSK_GAME_DATA EventFn mEvtSeqList[6]; + static DUSK_GAME_DATA daTagEscape_c* mTargetTag; + static DUSK_GAME_DATA f32 mTargetTagDist; + static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kasi_kyu.h b/include/d/actor/d_a_npc_kasi_kyu.h index 8353648675..8ba34391c7 100644 --- a/include/d/actor/d_a_npc_kasi_kyu.h +++ b/include/d/actor/d_a_npc_kasi_kyu.h @@ -14,7 +14,7 @@ class daNpcKasiKyu_Param_c { public: virtual ~daNpcKasiKyu_Param_c() {} - static daNpcKasiKyu_HIOParam const m; + static DUSK_GAME_DATA daNpcKasiKyu_HIOParam const m; }; #if DEBUG @@ -120,12 +120,11 @@ public: void chgWeightLight() { mCcStts.SetWeight(0xD8); } BOOL pl_front_check() { return actor_front_check(daPy_getPlayerActorClass()); } - static EventFn DUSK_CONST mEvtSeqList[1]; - static daTagEscape_c* mTargetTag; - static f32 mTargetTagDist; - static s16 mWolfAngle; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; + static DUSK_GAME_DATA daTagEscape_c* mTargetTag; + static DUSK_GAME_DATA f32 mTargetTagDist; + static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kasi_mich.h b/include/d/actor/d_a_npc_kasi_mich.h index 460c5c191a..08361fe134 100644 --- a/include/d/actor/d_a_npc_kasi_mich.h +++ b/include/d/actor/d_a_npc_kasi_mich.h @@ -23,7 +23,7 @@ class daNpcKasiMich_Param_c { public: virtual ~daNpcKasiMich_Param_c() {} - static daNpcKasiMich_HIOParam const m; + static DUSK_GAME_DATA daNpcKasiMich_HIOParam const m; }; #if DEBUG @@ -121,12 +121,11 @@ public: void chgWeightLight() { mCcStts.SetWeight(0xD8); } BOOL pl_front_check() { return actor_front_check(daPy_getPlayerActorClass()); } - static EventFn DUSK_CONST mEvtSeqList[1]; - static daTagEscape_c* mTargetTag; - static f32 mTargetTagDist; - static s16 mWolfAngle; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; + static DUSK_GAME_DATA daTagEscape_c* mTargetTag; + static DUSK_GAME_DATA f32 mTargetTagDist; + static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kdk.h b/include/d/actor/d_a_npc_kdk.h index 6f701e33af..a647cc706d 100644 --- a/include/d/actor/d_a_npc_kdk.h +++ b/include/d/actor/d_a_npc_kdk.h @@ -12,7 +12,7 @@ * */ class daNpcKdk_c : public fopAc_ac_c { -private: +public: /* 0x568 */ u8 field_0x568[0xFA0 - 0x568]; }; diff --git a/include/d/actor/d_a_npc_kkri.h b/include/d/actor/d_a_npc_kkri.h index a5e74880a9..1265f6e27f 100644 --- a/include/d/actor/d_a_npc_kkri.h +++ b/include/d/actor/d_a_npc_kkri.h @@ -11,7 +11,7 @@ class daNpc_Kkri_Param_c { public: virtual ~daNpc_Kkri_Param_c() {} - static const daNpc_Kkri_HIOParam m; + static DUSK_GAME_DATA const daNpc_Kkri_HIOParam m; }; #if DEBUG @@ -118,10 +118,9 @@ public: return mpMorf[0]->getModel()->getAnmMtx(5); } - static char DUSK_CONST* DUSK_CONST mCutNameList[3]; - static int (daNpc_Kkri_c::* DUSK_CONST mCutList[])(int); + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[3]; + static DUSK_GAME_DATA int (daNpc_Kkri_c::* DUSK_CONST mCutList[])(int); -private: /* 0xE40 */ NPC_KKRI_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_kn.h b/include/d/actor/d_a_npc_kn.h index 37b248fbe5..7df2cfa247 100644 --- a/include/d/actor/d_a_npc_kn.h +++ b/include/d/actor/d_a_npc_kn.h @@ -25,7 +25,7 @@ class daNpc_Kn_Param_c { public: virtual ~daNpc_Kn_Param_c() {} - static const daNpc_Kn_HIOParam m; + static DUSK_GAME_DATA const daNpc_Kn_HIOParam m; }; #if DEBUG @@ -412,16 +412,15 @@ public: virtual ~daNpc_Kn_c(); virtual bool afterSetMotionAnm(int, int, f32, int); - static const dCcD_SrcGObjInf mCcDObjData; - static char DUSK_CONST* DUSK_CONST mCutNameList[21]; - static cutFunc DUSK_CONST mCutList[21]; - static dCcD_SrcCyl mCcDCyl; - static dCcD_SrcSph mCcDSph; - static s16 mSrchName; - static fopAc_ac_c* mFindActorPtrs[50]; - static int mFindCount; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjData; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[21]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[21]; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA s16 mSrchName; + static DUSK_GAME_DATA fopAc_ac_c* mFindActorPtrs[50]; + static DUSK_GAME_DATA int mFindCount; -private: /* 0x0E44 */ J3DModel* mpPodModel; /* 0x0E48 */ mDoExt_invisibleModel mInvisModel; /* 0x0E50 */ dKy_tevstr_c mTevStr; diff --git a/include/d/actor/d_a_npc_knj.h b/include/d/actor/d_a_npc_knj.h index 8aa5ff860a..7738d231b2 100644 --- a/include/d/actor/d_a_npc_knj.h +++ b/include/d/actor/d_a_npc_knj.h @@ -11,7 +11,7 @@ class daNpc_Knj_Param_c { public: virtual ~daNpc_Knj_Param_c() {} - static const daNpc_Knj_HIOParam m; + static DUSK_GAME_DATA const daNpc_Knj_HIOParam m; }; #if DEBUG @@ -80,10 +80,9 @@ public: i_faceMotionStepNum, i_motionSequenceData, i_motionStepNum, i_evtData, i_arcNames) {} - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_KNJ_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mNextAction; diff --git a/include/d/actor/d_a_npc_kolin.h b/include/d/actor/d_a_npc_kolin.h index 819eb81078..860ae1b942 100644 --- a/include/d/actor/d_a_npc_kolin.h +++ b/include/d/actor/d_a_npc_kolin.h @@ -18,7 +18,7 @@ class daNpc_Kolin_Param_c { public: virtual ~daNpc_Kolin_Param_c() {} - static daNpc_Kolin_HIOParam const m; + static DUSK_GAME_DATA daNpc_Kolin_HIOParam const m; }; #if DEBUG @@ -120,8 +120,8 @@ public: virtual void changeAnm(int*, int*); virtual void changeBck(int*, int*); - static char DUSK_CONST* DUSK_CONST mCutNameList[11]; - static cutFunc DUSK_CONST mCutList[11]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; u32 getFlowNodeNo() { u16 nodeNo = home.angle.x; @@ -161,7 +161,6 @@ public: return 0; } -private: /* 0x0E40 */ NPC_KOLIN_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpClothModel; /* 0x0E48 */ dCcD_Cyl field_0xe48; diff --git a/include/d/actor/d_a_npc_kolinb.h b/include/d/actor/d_a_npc_kolinb.h index b3858a908e..4655234347 100644 --- a/include/d/actor/d_a_npc_kolinb.h +++ b/include/d/actor/d_a_npc_kolinb.h @@ -12,7 +12,7 @@ class daNpc_Kolinb_Param_c { public: virtual ~daNpc_Kolinb_Param_c() {} - static daNpc_Kolinb_HIOParam const m; + static DUSK_GAME_DATA daNpc_Kolinb_HIOParam const m; }; #if DEBUG @@ -150,8 +150,8 @@ public: s32 getBackboneJointNo() { return mType == 2 ? ZRCB_JNT_BACKBONE1 : KOLINB_JNT_BACKBONE1; } s32 getNeckJointNo() { return mType == 2 ? ZRCB_JNT_NECK : KOLINB_JNT_NECK; } - static char DUSK_CONST* DUSK_CONST mCutNameList[7]; - static cutFunc DUSK_CONST mCutList[7]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; u32 getFlowNodeNo() { u16 nodeNo = home.angle.x; @@ -166,7 +166,6 @@ public: u32 getModelType() { return fopAcM_GetParam(this) >> 28; } -private: /* 0xE40 */ NPC_KOLINB_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ Mtx mMtx; diff --git a/include/d/actor/d_a_npc_kyury.h b/include/d/actor/d_a_npc_kyury.h index 62ba0433cf..7322dfd905 100644 --- a/include/d/actor/d_a_npc_kyury.h +++ b/include/d/actor/d_a_npc_kyury.h @@ -11,7 +11,7 @@ class daNpc_Kyury_Param_c { public: virtual ~daNpc_Kyury_Param_c() {} - static const daNpc_Kyury_HIOParam m; + static DUSK_GAME_DATA const daNpc_Kyury_HIOParam m; }; #if DEBUG @@ -123,10 +123,9 @@ public: return nodeNo; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_KYURY_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpModel[2]; /* 0xE4C */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_len.h b/include/d/actor/d_a_npc_len.h index da5a0e0777..b22a0059e0 100644 --- a/include/d/actor/d_a_npc_len.h +++ b/include/d/actor/d_a_npc_len.h @@ -14,7 +14,7 @@ class daNpc_Len_Param_c { public: virtual ~daNpc_Len_Param_c() {} - static const daNpc_Len_HIOParam m; + static DUSK_GAME_DATA const daNpc_Len_HIOParam m; }; #if DEBUG @@ -100,8 +100,8 @@ public: s32 getFootRJointNo() { return 32; } BOOL chkXYItems() { return TRUE; } - static char DUSK_CONST* DUSK_CONST mCutNameList[4]; - static cutFunc DUSK_CONST mCutList[4]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[4]; int getFlowNodeNo() { u16 nodeNo = home.angle.x; @@ -113,7 +113,6 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } -private: /* 0xE40 */ NPC_LEN_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_lud.h b/include/d/actor/d_a_npc_lud.h index b84e6aafac..a2be5fa65d 100644 --- a/include/d/actor/d_a_npc_lud.h +++ b/include/d/actor/d_a_npc_lud.h @@ -12,7 +12,7 @@ class daNpc_Lud_Param_c { public: virtual ~daNpc_Lud_Param_c() {} - static const daNpc_Lud_HIOParam m; + static DUSK_GAME_DATA const daNpc_Lud_HIOParam m; }; #if DEBUG @@ -111,10 +111,9 @@ public: } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } - static char DUSK_CONST* DUSK_CONST mCutNameList[8]; - static cutFunc DUSK_CONST mCutList[8]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[8]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[8]; -private: /* 0xE40 */ mDoExt_McaMorfSO* mpBowlMorf; /* 0xE44 */ NPC_LUD_HIO_CLASS* mpHIO; /* 0xE48 */ J3DModel* mpModel[2]; diff --git a/include/d/actor/d_a_npc_maro.h b/include/d/actor/d_a_npc_maro.h index b8ec85b9fb..8acd11e43c 100644 --- a/include/d/actor/d_a_npc_maro.h +++ b/include/d/actor/d_a_npc_maro.h @@ -14,7 +14,7 @@ class daNpc_Maro_Param_c { public: virtual ~daNpc_Maro_Param_c() {} - static const daNpc_Maro_HIOParam m; + static DUSK_GAME_DATA const daNpc_Maro_HIOParam m; }; #if DEBUG @@ -167,8 +167,8 @@ public: void startChoccai() { field_0x1134 = 1; } void endChoccai() { field_0x1134 = 0; } - static char DUSK_CONST* DUSK_CONST mCutNameList[17]; - static cutFunc DUSK_CONST mCutList[17]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[17]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[17]; u8 getGroupId() { return (fopAcM_GetParam(this) & 0xF0000000) >> 28; @@ -187,7 +187,6 @@ public: return (fopAcM_GetParam(this) & 0xF000000) >> 24; } -private: /* 0x0F7C */ NPC_MARO_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl1; /* 0x10BC */ int field_0x10bc; diff --git a/include/d/actor/d_a_npc_midp.h b/include/d/actor/d_a_npc_midp.h index 810f9eca45..3021051d77 100644 --- a/include/d/actor/d_a_npc_midp.h +++ b/include/d/actor/d_a_npc_midp.h @@ -20,7 +20,7 @@ class daNpc_midP_Param_c { public: virtual ~daNpc_midP_Param_c() {} - static const daNpc_midP_HIOParam m; + static DUSK_GAME_DATA const daNpc_midP_HIOParam m; }; #if DEBUG @@ -148,10 +148,9 @@ public: return nodeNo; } - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_MIDP_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_moi.h b/include/d/actor/d_a_npc_moi.h index eb00654fd9..94e1ef8861 100644 --- a/include/d/actor/d_a_npc_moi.h +++ b/include/d/actor/d_a_npc_moi.h @@ -26,7 +26,7 @@ class daNpc_Moi_Param_c { public: virtual ~daNpc_Moi_Param_c() {} - static const daNpc_Moi_HIOParam m; + static DUSK_GAME_DATA const daNpc_Moi_HIOParam m; }; #if DEBUG @@ -158,10 +158,9 @@ public: bool chkSFight() { return field_0x166b == 1; } u8 getPathID() { return (fopAcM_GetParam(this) & 0xff00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[5]; - static cutFunc DUSK_CONST mCutList[5]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[5]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[5]; -private: /* 0x0E40 */ NPC_MOI_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModel[6]; /* 0x0E5C */ dCcD_Cyl mCyl[4]; diff --git a/include/d/actor/d_a_npc_moir.h b/include/d/actor/d_a_npc_moir.h index 0cc8be336a..f217ab7698 100644 --- a/include/d/actor/d_a_npc_moir.h +++ b/include/d/actor/d_a_npc_moir.h @@ -23,7 +23,7 @@ class daNpcMoiR_Param_c { public: virtual ~daNpcMoiR_Param_c() {} - static daNpcMoiR_HIOParam const m; + static DUSK_GAME_DATA daNpcMoiR_HIOParam const m; }; #if DEBUG @@ -212,9 +212,8 @@ public: inline void setLookMode(int i_lookMode); inline void searchActors(); - static EventFn mEvtSeqList[4]; + static DUSK_GAME_DATA EventFn mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpHeadgearModel; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_myna2.h b/include/d/actor/d_a_npc_myna2.h index 4cb0356832..e2172eb4cd 100644 --- a/include/d/actor/d_a_npc_myna2.h +++ b/include/d/actor/d_a_npc_myna2.h @@ -13,7 +13,7 @@ class daNpc_myna2_Param_c { public: virtual ~daNpc_myna2_Param_c() {} - static const daNpc_myna2_HIOParam m; + static DUSK_GAME_DATA const daNpc_myna2_HIOParam m; }; #if DEBUG @@ -87,8 +87,8 @@ public: int getType() { return mType; } - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[5]; - static EventFn DUSK_CONST mEvtCutList[]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[5]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[]; /* 0xB48 */ u8 field_0xB48[0xB4C - 0xB48]; /* 0xB4C */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_pachi_besu.h b/include/d/actor/d_a_npc_pachi_besu.h index be623faf38..2cc79d2364 100644 --- a/include/d/actor/d_a_npc_pachi_besu.h +++ b/include/d/actor/d_a_npc_pachi_besu.h @@ -11,7 +11,7 @@ class daNpc_Pachi_Besu_Param_c { public: virtual ~daNpc_Pachi_Besu_Param_c() {} - static daNpc_Pachi_Besu_HIOParam const m; + static DUSK_GAME_DATA daNpc_Pachi_Besu_HIOParam const m; }; #if DEBUG @@ -144,10 +144,9 @@ public: void setTagPos(cXyz const& i_pos) { mTagPos = i_pos; } void setLookPos(cXyz const& i_pos) { mLookPos = i_pos; } - static char DUSK_CONST* DUSK_CONST mCutNameList[11]; - static cutFunc DUSK_CONST mCutList[11]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0xE40 */ NPC_PACHI_BESU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_pachi_maro.h b/include/d/actor/d_a_npc_pachi_maro.h index ffb33d1fbc..be398f85e0 100644 --- a/include/d/actor/d_a_npc_pachi_maro.h +++ b/include/d/actor/d_a_npc_pachi_maro.h @@ -21,7 +21,7 @@ class daNpc_Pachi_Maro_Param_c { public: virtual ~daNpc_Pachi_Maro_Param_c() {} - static daNpc_Pachi_Maro_HIOParam const m; + static DUSK_GAME_DATA daNpc_Pachi_Maro_HIOParam const m; }; #if DEBUG @@ -184,10 +184,9 @@ public: void setFMotion_Niramu_to_Besu() { mFMotion = 1; } void setFMotion_LookNone() { mFMotion = 2; } - static char DUSK_CONST* DUSK_CONST mCutNameList[11]; - static cutFunc DUSK_CONST mCutList[11]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0xE40 */ NPC_PACHI_MARO_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_pachi_taro.h b/include/d/actor/d_a_npc_pachi_taro.h index 9faee13c23..e424292f6c 100644 --- a/include/d/actor/d_a_npc_pachi_taro.h +++ b/include/d/actor/d_a_npc_pachi_taro.h @@ -20,7 +20,7 @@ class daNpc_Pachi_Taro_Param_c { public: virtual ~daNpc_Pachi_Taro_Param_c() {} - static daNpc_Pachi_Taro_HIOParam const m; + static DUSK_GAME_DATA daNpc_Pachi_Taro_HIOParam const m; }; #if DEBUG @@ -196,10 +196,9 @@ public: void setTagPos(cXyz const& i_pos) { mTagPos = i_pos; } void setLookPos(cXyz const& i_pos) { mLookPos = i_pos; } - static char DUSK_CONST* DUSK_CONST mCutNameList[11]; - static cutFunc DUSK_CONST mCutList[11]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0x0E40 */ NPC_PACHI_TARO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModels[2]; /* 0x0E4C */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_passer.h b/include/d/actor/d_a_npc_passer.h index f6c05ae7a5..e166e635b9 100644 --- a/include/d/actor/d_a_npc_passer.h +++ b/include/d/actor/d_a_npc_passer.h @@ -92,38 +92,37 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) >> 16) & 0xFF; } BOOL isStop() { return TRUE; } - static actionFunc ActionTable[5][2]; - static seqFunc* m_funcTbl[28]; - static seqFunc m_seq00_funcTbl[2]; - static seqFunc m_seq01_funcTbl[2]; - static seqFunc m_seq02_funcTbl[2]; - static seqFunc m_seq03_funcTbl[2]; - static seqFunc m_seq04_funcTbl[2]; - static seqFunc m_seq05_funcTbl[4]; - static seqFunc m_seq06_funcTbl[4]; - static seqFunc m_seq07_funcTbl[2]; - static seqFunc m_seq08_funcTbl[7]; - static seqFunc m_seq09_funcTbl[2]; - static seqFunc m_seq10_funcTbl[2]; - static seqFunc m_seq11_funcTbl[6]; - static seqFunc m_seq12_funcTbl[2]; - static seqFunc m_seq13_funcTbl[6]; - static seqFunc m_seq14_funcTbl[2]; - static seqFunc m_seq15_funcTbl[2]; - static seqFunc m_seq16_funcTbl[7]; - static seqFunc m_seq17_funcTbl[2]; - static seqFunc m_seq18_funcTbl[2]; - static seqFunc m_seq19_funcTbl[7]; - static seqFunc m_seq20_funcTbl[2]; - static seqFunc m_seq21_funcTbl[2]; - static seqFunc m_seq22_funcTbl[4]; - static seqFunc m_seq23_funcTbl[7]; - static seqFunc m_seq24_funcTbl[5]; - static seqFunc m_seq25_funcTbl[7]; - static seqFunc m_seq26_funcTbl[3]; - static seqFunc m_seq27_funcTbl[1]; + static DUSK_GAME_DATA actionFunc ActionTable[5][2]; + static DUSK_GAME_DATA seqFunc* m_funcTbl[28]; + static DUSK_GAME_DATA seqFunc m_seq00_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq01_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq02_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq03_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq04_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq05_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq06_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq07_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq08_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq09_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq10_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq11_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq12_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq13_funcTbl[6]; + static DUSK_GAME_DATA seqFunc m_seq14_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq15_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq16_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq17_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq18_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq19_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq20_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq21_funcTbl[2]; + static DUSK_GAME_DATA seqFunc m_seq22_funcTbl[4]; + static DUSK_GAME_DATA seqFunc m_seq23_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq24_funcTbl[5]; + static DUSK_GAME_DATA seqFunc m_seq25_funcTbl[7]; + static DUSK_GAME_DATA seqFunc m_seq26_funcTbl[3]; + static DUSK_GAME_DATA seqFunc m_seq27_funcTbl[1]; -private: /* 0xAC8 */ J3DModel* mpModel; /* 0xACC */ PathTrace_c m_path; /* 0xAF4 */ daNpcPasser_c::actionFunc* mAction; diff --git a/include/d/actor/d_a_npc_passer2.h b/include/d/actor/d_a_npc_passer2.h index 529b99fc35..148a3b2981 100644 --- a/include/d/actor/d_a_npc_passer2.h +++ b/include/d/actor/d_a_npc_passer2.h @@ -51,9 +51,8 @@ public: u8 getRunMotionType() { return fopAcM_GetParam(this) >> 30; } u8 getPathID() { return (fopAcM_GetParam(this) >> 16) & 0xFF; } - static actionFunc ActionTable[1][2]; + static DUSK_GAME_DATA actionFunc ActionTable[1][2]; -private: /* 0x9EC */ J3DModel* mpModel; /* 0x9F0 */ PathTrace_c m_path; /* 0xA18 */ actionFunc* mAction; diff --git a/include/d/actor/d_a_npc_post.h b/include/d/actor/d_a_npc_post.h index 5450dbfe68..ef44f7ee1e 100644 --- a/include/d/actor/d_a_npc_post.h +++ b/include/d/actor/d_a_npc_post.h @@ -22,7 +22,7 @@ class daNpc_Post_Param_c { public: virtual ~daNpc_Post_Param_c() {} - static daNpc_Post_HIOParam const m; + static DUSK_GAME_DATA daNpc_Post_HIOParam const m; }; #if DEBUG @@ -153,10 +153,9 @@ public: u8 getBitSW() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0E40 */ mDoExt_McaMorfSO* mpFlagModelMorf; /* 0x0E44 */ NPC_POST_HIO_CLASS* mHIO; /* 0x0E48 */ J3DModel* mpLetterModels[2]; diff --git a/include/d/actor/d_a_npc_pouya.h b/include/d/actor/d_a_npc_pouya.h index c94f777d87..4af1d1ce68 100644 --- a/include/d/actor/d_a_npc_pouya.h +++ b/include/d/actor/d_a_npc_pouya.h @@ -11,7 +11,7 @@ class daNpc_Pouya_Param_c { public: virtual ~daNpc_Pouya_Param_c() {} - static const daNpc_Pouya_HIOParam m; + static DUSK_GAME_DATA const daNpc_Pouya_HIOParam m; }; #if DEBUG @@ -146,10 +146,9 @@ public: MtxP getHeadMtx() { return mpMorf[0]->getModel()->getAnmMtx(4); } - static char DUSK_CONST* DUSK_CONST mCutNameList[3]; - static cutFunc DUSK_CONST mCutList[3]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[3]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[3]; -private: /* 0xE40 */ NPC_POUYA_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpModel[1]; /* 0xE48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_prayer.h b/include/d/actor/d_a_npc_prayer.h index fd1afa2ddf..438bc784f9 100644 --- a/include/d/actor/d_a_npc_prayer.h +++ b/include/d/actor/d_a_npc_prayer.h @@ -11,7 +11,7 @@ class daNpcPray_Param_c { public: virtual ~daNpcPray_Param_c() {} - static const daNpcPray_HIOParam m; + static DUSK_GAME_DATA const daNpcPray_HIOParam m; }; #if DEBUG @@ -77,9 +77,8 @@ public: s16 getMessageNo() { return (fopAcM_GetParam(this) >> 8) & 0xFFFF; } - static EvtSeq DUSK_CONST mEvtSeqList[]; + static DUSK_GAME_DATA EvtSeq DUSK_CONST mEvtSeqList[]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xBEC[0xBF0 - 0xBEC]; /* 0xBF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_raca.h b/include/d/actor/d_a_npc_raca.h index 985f370dbb..187ca700c7 100644 --- a/include/d/actor/d_a_npc_raca.h +++ b/include/d/actor/d_a_npc_raca.h @@ -20,7 +20,7 @@ class daNpc_Raca_Param_c { public: virtual ~daNpc_Raca_Param_c() {} - static daNpc_Raca_HIOParam const m; + static DUSK_GAME_DATA daNpc_Raca_HIOParam const m; }; #if DEBUG @@ -145,10 +145,9 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xFF0000) >> 16; } - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_RACA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_rafrel.h b/include/d/actor/d_a_npc_rafrel.h index ae804cf15a..0bb9e76194 100644 --- a/include/d/actor/d_a_npc_rafrel.h +++ b/include/d/actor/d_a_npc_rafrel.h @@ -22,7 +22,7 @@ class daNpcRafrel_Param_c { public: virtual ~daNpcRafrel_Param_c() {} - static const daNpcRafrel_HIOParam m; + static DUSK_GAME_DATA const daNpcRafrel_HIOParam m; }; class daNpcRafrel_HIO_c : public mDoHIO_entry_c { @@ -105,9 +105,8 @@ public: s16 getMessageNo() { return (fopAcM_GetParam(this) >> 8) & 0xFFFF; } - static int (daNpcRafrel_c::*mEvtSeqList[])(int); + static DUSK_GAME_DATA int (daNpcRafrel_c::*mEvtSeqList[])(int); -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpItemModel; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_saru.h b/include/d/actor/d_a_npc_saru.h index 05535786fe..dce1d7b4a3 100644 --- a/include/d/actor/d_a_npc_saru.h +++ b/include/d/actor/d_a_npc_saru.h @@ -21,7 +21,7 @@ class daNpc_Saru_Param_c { public: virtual ~daNpc_Saru_Param_c() {} - static const daNpc_Saru_HIOParam m; + static DUSK_GAME_DATA const daNpc_Saru_HIOParam m; }; #if DEBUG @@ -133,9 +133,8 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[4]; - static cutFunc DUSK_CONST mCutList[4]; -private: + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[4]; /* 0xE40 */ NPC_SARU_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpRoseModels[2]; /* 0xE4C */ dCcD_Cyl field_0xe4c; diff --git a/include/d/actor/d_a_npc_seib.h b/include/d/actor/d_a_npc_seib.h index b7af300cee..855be4ac41 100644 --- a/include/d/actor/d_a_npc_seib.h +++ b/include/d/actor/d_a_npc_seib.h @@ -13,7 +13,7 @@ class daNpc_seiB_Param_c { public: virtual ~daNpc_seiB_Param_c() {}; - static const daNpc_seiB_HIOParam m; + static DUSK_GAME_DATA const daNpc_seiB_HIOParam m; }; #if DEBUG @@ -84,10 +84,9 @@ public: daNpcT_c(param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8) {} - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEIB_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mActionFunc1; diff --git a/include/d/actor/d_a_npc_seic.h b/include/d/actor/d_a_npc_seic.h index bbdaf19431..609d38588b 100644 --- a/include/d/actor/d_a_npc_seic.h +++ b/include/d/actor/d_a_npc_seic.h @@ -22,7 +22,7 @@ class daNpc_seiC_Param_c { public: virtual ~daNpc_seiC_Param_c() {} - static const daNpc_seiC_HIOParam m; + static DUSK_GAME_DATA const daNpc_seiC_HIOParam m; }; #if DEBUG @@ -87,10 +87,9 @@ public: i_faceMotionStepNum, i_motionSequenceData, i_motionStepNum, i_evtData, i_arcNames) {}; - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEIC_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE45 */ u8 field_0xe45[0xe48 - 0xe45]; diff --git a/include/d/actor/d_a_npc_seid.h b/include/d/actor/d_a_npc_seid.h index f83d8a2909..91a1920598 100644 --- a/include/d/actor/d_a_npc_seid.h +++ b/include/d/actor/d_a_npc_seid.h @@ -22,7 +22,7 @@ class daNpc_seiD_Param_c { public: virtual ~daNpc_seiD_Param_c() {} - static const daNpc_seiD_HIOParam m; + static DUSK_GAME_DATA const daNpc_seiD_HIOParam m; }; #if DEBUG @@ -86,10 +86,9 @@ public: i_faceMotionStepNum, i_motionSequenceData, i_motionStepNum, i_evtData, i_arcNames) {}; - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEID_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mAction; diff --git a/include/d/actor/d_a_npc_seira.h b/include/d/actor/d_a_npc_seira.h index 0528dd5c01..c4f2ef1a96 100644 --- a/include/d/actor/d_a_npc_seira.h +++ b/include/d/actor/d_a_npc_seira.h @@ -12,7 +12,7 @@ class daNpc_Seira_Param_c { public: virtual ~daNpc_Seira_Param_c() {} - static const daNpc_Seira_HIOParam m; + static DUSK_GAME_DATA const daNpc_Seira_HIOParam m; }; #if DEBUG @@ -114,10 +114,9 @@ public: BOOL checkChangeJoint(int val) { return val == 4; } BOOL checkRemoveJoint(int val) { return val == 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0F7C */ mDoExt_McaMorfSO* mpSeiraMorf; /* 0x0F80 */ NPC_SEIRA_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_seira2.h b/include/d/actor/d_a_npc_seira2.h index b3157b2924..13aeb71e65 100644 --- a/include/d/actor/d_a_npc_seira2.h +++ b/include/d/actor/d_a_npc_seira2.h @@ -12,7 +12,7 @@ class daNpc_Seira2_Param_c { public: virtual ~daNpc_Seira2_Param_c() {} - static const daNpc_Seira2_HIOParam m; + static DUSK_GAME_DATA const daNpc_Seira2_HIOParam m; }; #if DEBUG @@ -106,10 +106,9 @@ public: BOOL checkChangeJoint(int val) { return val == 4; } BOOL checkRemoveJoint(int val) { return val == 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ mDoExt_McaMorfSO* mpSeiraMorf; /* 0x0F80 */ NPC_SEIRA2_HIO_CLASS* mpHIO; /* 0x0F84 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_seirei.h b/include/d/actor/d_a_npc_seirei.h index ca0c7f9985..b27f6084fc 100644 --- a/include/d/actor/d_a_npc_seirei.h +++ b/include/d/actor/d_a_npc_seirei.h @@ -13,7 +13,7 @@ class daNpc_Seirei_Param_c { public: virtual ~daNpc_Seirei_Param_c() {} - static daNpc_Seirei_HIOParam const m; + static DUSK_GAME_DATA daNpc_Seirei_HIOParam const m; }; #if DEBUG @@ -99,10 +99,9 @@ public: u32 getBitSW() { return (fopAcM_GetParam(this) & 0xFF000) >> 12; } bool getDoBtnChkFlag() { return (fopAcM_GetParam(this) & 0x100) == 0; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_SEIREI_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE45 */ u8 arg0; diff --git a/include/d/actor/d_a_npc_shad.h b/include/d/actor/d_a_npc_shad.h index d33a6af350..59f1901059 100644 --- a/include/d/actor/d_a_npc_shad.h +++ b/include/d/actor/d_a_npc_shad.h @@ -12,7 +12,7 @@ class daNpcShad_Param_c : public JORReflexible { public: virtual ~daNpcShad_Param_c() {} - static const daNpcShad_HIOParam m; + static DUSK_GAME_DATA const daNpcShad_HIOParam m; }; #if DEBUG @@ -184,7 +184,7 @@ public: void lookat(); BOOL drawDbgInfo(); - static EventFn DUSK_CONST mEvtSeqList[14]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[14]; u8 getPathID() { return (fopAcM_GetParam(this) >> 8) & 0xFF; } s16 getMessageNo() { return shape_angle.x; } @@ -237,7 +237,6 @@ public: } } -private: /* 0xB48 */ J3DModel* mBookKnifeModel; /* 0xB4C */ J3DModel* mKomonshoModel; /* 0xB50 */ Z2Creature mSound; diff --git a/include/d/actor/d_a_npc_shaman.h b/include/d/actor/d_a_npc_shaman.h index 76231f2756..1a462a7d00 100644 --- a/include/d/actor/d_a_npc_shaman.h +++ b/include/d/actor/d_a_npc_shaman.h @@ -20,7 +20,7 @@ class daNpc_Sha_Param_c { public: virtual ~daNpc_Sha_Param_c() {} - static daNpc_Sha_HIOParam const m; + static DUSK_GAME_DATA daNpc_Sha_HIOParam const m; }; #if DEBUG @@ -110,14 +110,13 @@ public: return nodeNo == 0xFFFF ? -1 : nodeNo; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; - static const u16 mEvtBitLabels[6]; - static const u16 mTmpBitLabels[6]; - static const int mSceneChangeNoTable[48]; - static queryFunc mQueries[48]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA const u16 mEvtBitLabels[6]; + static DUSK_GAME_DATA const u16 mTmpBitLabels[6]; + static DUSK_GAME_DATA const int mSceneChangeNoTable[48]; + static DUSK_GAME_DATA queryFunc mQueries[48]; -private: /* 0xE40 */ NPC_SHA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_shoe.h b/include/d/actor/d_a_npc_shoe.h index 67b746546b..b93259b60f 100644 --- a/include/d/actor/d_a_npc_shoe.h +++ b/include/d/actor/d_a_npc_shoe.h @@ -11,7 +11,7 @@ class daNpcShoe_Param_c { public: virtual ~daNpcShoe_Param_c() {} - static const daNpcShoe_HIOParam m; + static DUSK_GAME_DATA const daNpcShoe_HIOParam m; }; STATIC_ASSERT(sizeof(daNpcShoe_Param_c::m) == 0x6C); @@ -110,9 +110,8 @@ public: inline bool chkFindPlayer(); inline void playMotion(); - static EventFn DUSK_CONST mEvtSeqList[1]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ J3DModel* mpModel1; /* 0xB4C */ J3DModel* mpModel2; /* 0xB50 */ Z2CreatureCitizen mCreature; diff --git a/include/d/actor/d_a_npc_shop0.h b/include/d/actor/d_a_npc_shop0.h index 21e6916ac1..aa6d9cdf33 100644 --- a/include/d/actor/d_a_npc_shop0.h +++ b/include/d/actor/d_a_npc_shop0.h @@ -22,7 +22,7 @@ public: /* 0x8 */ u32 mParam3; }; - static param const mParam; + static DUSK_GAME_DATA param const mParam; }; @@ -52,7 +52,7 @@ public: int wait(void*); int talk(void*); - static dCcD_SrcCyl const mCylDat; + static DUSK_GAME_DATA dCcD_SrcCyl const mCylDat; /* 0x56c */ u8 mParam; /* 0x570 */ mDoExt_bckAnm mBckAnm; diff --git a/include/d/actor/d_a_npc_sola.h b/include/d/actor/d_a_npc_sola.h index 7b622d121c..b7fff5b57b 100644 --- a/include/d/actor/d_a_npc_sola.h +++ b/include/d/actor/d_a_npc_sola.h @@ -11,7 +11,7 @@ class daNpc_solA_Param_c { public: virtual ~daNpc_solA_Param_c() {} - static daNpc_solA_HIOParam const m; + static DUSK_GAME_DATA daNpc_solA_HIOParam const m; }; #if DEBUG @@ -111,10 +111,9 @@ public: s32 getNeckJointNo() { return JNT_NECK; } s32 getBackboneJointNo() { return JNT_BACKBONE1; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SOLA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 field_0xf80; diff --git a/include/d/actor/d_a_npc_soldierA.h b/include/d/actor/d_a_npc_soldierA.h index f7c9153dd9..aaca72ec8b 100644 --- a/include/d/actor/d_a_npc_soldierA.h +++ b/include/d/actor/d_a_npc_soldierA.h @@ -20,7 +20,7 @@ class daNpc_SoldierA_Param_c { public: virtual ~daNpc_SoldierA_Param_c() {} - static daNpc_SoldierA_HIOParam const m; + static DUSK_GAME_DATA daNpc_SoldierA_HIOParam const m; }; #if DEBUG @@ -79,10 +79,9 @@ public: u8 getType() { return mType; } - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; - static cutFunc DUSK_CONST mEvtCutList[3]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[3]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mSpearModel; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_soldierB.h b/include/d/actor/d_a_npc_soldierB.h index a99e10a813..d39f54edc5 100644 --- a/include/d/actor/d_a_npc_soldierB.h +++ b/include/d/actor/d_a_npc_soldierB.h @@ -11,7 +11,7 @@ class daNpc_SoldierB_Param_c { public: virtual ~daNpc_SoldierB_Param_c() {} - static daNpc_SoldierB_HIOParam const m; + static DUSK_GAME_DATA daNpc_SoldierB_HIOParam const m; }; #if DEBUG @@ -75,10 +75,9 @@ public: int ECut_listenLake(int); int test(void*); - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; - static cutFunc DUSK_CONST mEvtCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mSpearModel; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_taro.h b/include/d/actor/d_a_npc_taro.h index 6e7e394406..83ff47fc07 100644 --- a/include/d/actor/d_a_npc_taro.h +++ b/include/d/actor/d_a_npc_taro.h @@ -14,7 +14,7 @@ class daNpc_Taro_Param_c { public: virtual ~daNpc_Taro_Param_c() {} - static daNpc_Taro_HIOParam const m; + static DUSK_GAME_DATA daNpc_Taro_HIOParam const m; }; #if DEBUG @@ -156,10 +156,9 @@ public: u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } u8 getBitSW2() { return (fopAcM_GetParam(this) & 0xff000000) >> 24; } - static char DUSK_CONST* DUSK_CONST mCutNameList[17]; - static cutFunc DUSK_CONST mCutList[17]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[17]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[17]; -private: /* 0x0E40 */ NPC_TARO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mModels[2]; /* 0x0E4C */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_the.h b/include/d/actor/d_a_npc_the.h index c131d442f6..2a230afb8e 100644 --- a/include/d/actor/d_a_npc_the.h +++ b/include/d/actor/d_a_npc_the.h @@ -12,7 +12,7 @@ class daNpcThe_Param_c { public: virtual ~daNpcThe_Param_c() {} - static const daNpcThe_HIOParam m; + static DUSK_GAME_DATA const daNpcThe_HIOParam m; }; STATIC_ASSERT(sizeof(daNpcThe_Param_c::m) == 0x6C); @@ -208,7 +208,6 @@ public: } } -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; @@ -231,8 +230,8 @@ private: /* 0xE1D */ bool field_0xe1d; /* 0xE1E */ u8 mType; - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[4]; - static EventFn DUSK_CONST mEvtCutList[4]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[4]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[4]; }; STATIC_ASSERT(sizeof(daNpcThe_c) == 0xE20); diff --git a/include/d/actor/d_a_npc_theB.h b/include/d/actor/d_a_npc_theB.h index 9179ddd652..e2bc9d410d 100644 --- a/include/d/actor/d_a_npc_theB.h +++ b/include/d/actor/d_a_npc_theB.h @@ -19,7 +19,7 @@ struct daNpcTheB_HIOParam { struct daNpcTheB_Param_c { virtual ~daNpcTheB_Param_c() {} - static daNpcTheB_HIOParam const m; + static DUSK_GAME_DATA daNpcTheB_HIOParam const m; }; #if DEBUG @@ -149,9 +149,8 @@ public: } } - static cutFunc mEvtSeqList[6]; + static DUSK_GAME_DATA cutFunc mEvtSeqList[6]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_tkc.h b/include/d/actor/d_a_npc_tkc.h index ab2c871be2..6ec0150e5c 100644 --- a/include/d/actor/d_a_npc_tkc.h +++ b/include/d/actor/d_a_npc_tkc.h @@ -36,7 +36,7 @@ class daNpcTkc_Param_c { public: virtual ~daNpcTkc_Param_c() {} - static daNpcTkc_HIOParam const m; + static DUSK_GAME_DATA daNpcTkc_HIOParam const m; }; #if DEBUG @@ -106,9 +106,8 @@ public: BOOL chkAction(actionFunc action) { return action == mAction; } void lookat(); - static evtFunc mEvtSeqList[4]; + static DUSK_GAME_DATA evtFunc mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_ActorMngr_c mActorMngr[1]; diff --git a/include/d/actor/d_a_npc_tkj.h b/include/d/actor/d_a_npc_tkj.h index dc0e595cb7..3191f1ee3b 100644 --- a/include/d/actor/d_a_npc_tkj.h +++ b/include/d/actor/d_a_npc_tkj.h @@ -11,7 +11,7 @@ class daNpc_Tkj_Param_c { public: virtual ~daNpc_Tkj_Param_c() {} - static const daNpc_Tkj_HIOParam m; + static DUSK_GAME_DATA const daNpc_Tkj_HIOParam m; }; #if DEBUG @@ -94,10 +94,9 @@ public: int getPath() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static int (daNpcTkj_c::* DUSK_CONST mCutList[])(int); + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA int (daNpcTkj_c::* DUSK_CONST mCutList[])(int); -private: /* 0xE40 */ NPC_TKJ_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_tks.h b/include/d/actor/d_a_npc_tks.h index c2f7e6ff53..837a0c89ec 100644 --- a/include/d/actor/d_a_npc_tks.h +++ b/include/d/actor/d_a_npc_tks.h @@ -31,7 +31,7 @@ class daNpcTks_Param_c { public: virtual ~daNpcTks_Param_c() {} - static daNpcTks_HIOParam const m; + static DUSK_GAME_DATA daNpcTks_HIOParam const m; }; #if DEBUG @@ -134,7 +134,6 @@ public: inline void playTsuboAnm(); inline int getPlayerArea(); -private: /* 0x0B48 */ Z2Creature mSound; /* 0x0BD8 */ daNpcTksTsubo_c mTksTsubo; /* 0x1160 */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_toby.h b/include/d/actor/d_a_npc_toby.h index 7cce8adf7e..9abb7c032f 100644 --- a/include/d/actor/d_a_npc_toby.h +++ b/include/d/actor/d_a_npc_toby.h @@ -16,7 +16,7 @@ class daNpc_Toby_Param_c { public: virtual ~daNpc_Toby_Param_c() {} - static const daNpc_Toby_HIOParam m; + static DUSK_GAME_DATA const daNpc_Toby_HIOParam m; }; #if DEBUG @@ -129,10 +129,9 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xFF0000) >> 16; } - static char DUSK_CONST* DUSK_CONST mCutNameList[7]; - static cutFunc DUSK_CONST mCutList[7]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0x0E40 */ NPC_TOBY_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpTobyModels[1]; /* 0x0E48 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_uri.h b/include/d/actor/d_a_npc_uri.h index 0c29bd56ee..2650de4d64 100644 --- a/include/d/actor/d_a_npc_uri.h +++ b/include/d/actor/d_a_npc_uri.h @@ -22,7 +22,7 @@ class daNpc_Uri_Param_c { public: virtual ~daNpc_Uri_Param_c() {} - static const daNpc_Uri_HIOParam m; + static DUSK_GAME_DATA const daNpc_Uri_HIOParam m; }; #if DEBUG @@ -136,10 +136,9 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xff00) >> 8; } - static const char* mCutNameList[7]; - static cutFunc DUSK_CONST mCutList[7]; + static DUSK_GAME_DATA const char* mCutNameList[7]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0x0E40 */ NPC_URI_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModel[1]; /* 0x0E48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_wrestler.h b/include/d/actor/d_a_npc_wrestler.h index e4c98c8abb..c840259074 100644 --- a/include/d/actor/d_a_npc_wrestler.h +++ b/include/d/actor/d_a_npc_wrestler.h @@ -77,7 +77,7 @@ class daNpcWrestler_Param_c { public: virtual ~daNpcWrestler_Param_c() {} - static daNpcWrestler_HIOParam const m; + static DUSK_GAME_DATA daNpcWrestler_HIOParam const m; }; class daNpcWrestler_HIO_Node_c: public JORReflexible { @@ -230,9 +230,8 @@ public: inline void initDemoCamera_ReadyWrestler(); inline void playExpression(); - static EventFn DUSK_CONST mEvtSeqList[7]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[7]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcWrestler_HIOParam* field_0xbd8; /* 0xBDC */ daNpcWrestler_HIOParamSub* field_0xbdc; diff --git a/include/d/actor/d_a_npc_yamid.h b/include/d/actor/d_a_npc_yamid.h index 3133cbd84f..b9bb6bb288 100644 --- a/include/d/actor/d_a_npc_yamid.h +++ b/include/d/actor/d_a_npc_yamid.h @@ -20,7 +20,7 @@ class daNpc_yamiD_Param_c { public: virtual ~daNpc_yamiD_Param_c() {} - static daNpc_yamiD_HIOParam const m; + static DUSK_GAME_DATA daNpc_yamiD_HIOParam const m; }; #if DEBUG @@ -129,10 +129,9 @@ public: field_0xe44.OffTgSetBit(); } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMID_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yamis.h b/include/d/actor/d_a_npc_yamis.h index edf87ee174..272b0d5b72 100644 --- a/include/d/actor/d_a_npc_yamis.h +++ b/include/d/actor/d_a_npc_yamis.h @@ -11,7 +11,7 @@ class daNpc_yamiS_Param_c { public: virtual ~daNpc_yamiS_Param_c() {} - static const daNpc_yamiS_HIOParam m; + static DUSK_GAME_DATA const daNpc_yamiS_HIOParam m; }; #if DEBUG @@ -124,10 +124,9 @@ public: field_0xe44.OffTgSetBit(); } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMIS_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yamit.h b/include/d/actor/d_a_npc_yamit.h index 4f7a5393f8..0a12c2875d 100644 --- a/include/d/actor/d_a_npc_yamit.h +++ b/include/d/actor/d_a_npc_yamit.h @@ -12,7 +12,7 @@ class daNpc_yamiT_Param_c { public: virtual ~daNpc_yamiT_Param_c() {} - static const daNpc_yamiT_HIOParam m; + static DUSK_GAME_DATA const daNpc_yamiT_HIOParam m; }; #if DEBUG @@ -123,10 +123,9 @@ public: } u8 _is_stopper_off() { return fopAcM_isSwitch(this, 0x3D) && fopAcM_isSwitch(this, 0x3E); } - static char DUSK_CONST* DUSK_CONST mCutNameList[2]; - static cutFunc DUSK_CONST mCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMIT_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yelia.h b/include/d/actor/d_a_npc_yelia.h index fb934a25c5..c86d8e6ac6 100644 --- a/include/d/actor/d_a_npc_yelia.h +++ b/include/d/actor/d_a_npc_yelia.h @@ -11,7 +11,7 @@ class daNpc_Yelia_Param_c { public: virtual ~daNpc_Yelia_Param_c() {} - static daNpc_Yelia_HIOParam const m; + static DUSK_GAME_DATA daNpc_Yelia_HIOParam const m; }; #if DEBUG @@ -102,9 +102,8 @@ public: return no; } - static char DUSK_CONST* DUSK_CONST mCutNameList[6]; - static int (daNpc_Yelia_c::*mCutList[6])(int); -private: + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[6]; + static DUSK_GAME_DATA int (daNpc_Yelia_c::*mCutList[6])(int); /* 0xE40 */ NPC_YELIA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_ykm.h b/include/d/actor/d_a_npc_ykm.h index 391203948d..5bbb5077f6 100644 --- a/include/d/actor/d_a_npc_ykm.h +++ b/include/d/actor/d_a_npc_ykm.h @@ -38,7 +38,7 @@ class daNpc_ykM_Param_c { public: virtual ~daNpc_ykM_Param_c() {} - static daNpc_ykM_HIOParam const m; + static DUSK_GAME_DATA daNpc_ykM_HIOParam const m; }; #if DEBUG @@ -285,9 +285,8 @@ public: int getBitTRB() { return (u8)((fopAcM_GetParam(this) & 0x3F0000) >> 16); } u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } - static char DUSK_CONST* DUSK_CONST mCutNameList[10]; - static cutFunc DUSK_CONST mCutList[10]; -private: + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[10]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[10]; /* 0x0E40 */ mDoExt_McaMorfSO* mFishModelMorf; /* 0x0E44 */ mDoExt_McaMorfSO* mLeafModelMorf; /* 0x0E48 */ NPC_YKM_HIO_CLASS* mpHIO; diff --git a/include/d/actor/d_a_npc_ykw.h b/include/d/actor/d_a_npc_ykw.h index 91517d4e17..43b3bca276 100644 --- a/include/d/actor/d_a_npc_ykw.h +++ b/include/d/actor/d_a_npc_ykw.h @@ -131,8 +131,8 @@ public: return (fopAcM_GetParam(this) & 0xf0) >> 4; } - static const char* mCutNameList[8]; - static cutFunc DUSK_CONST mCutList[8]; + static DUSK_GAME_DATA const char* mCutNameList[8]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[8]; void setDialogueTmr1(int param_1) { field_0x1024 = param_1; @@ -216,7 +216,7 @@ class daNpc_ykW_Param_c { public: virtual ~daNpc_ykW_Param_c() {} - static const daNpc_ykW_HIOParam m; + static DUSK_GAME_DATA const daNpc_ykW_HIOParam m; }; #endif /* D_A_NPC_YKW_H */ diff --git a/include/d/actor/d_a_npc_zanb.h b/include/d/actor/d_a_npc_zanb.h index 6feaf3fc72..78c37f6c76 100644 --- a/include/d/actor/d_a_npc_zanb.h +++ b/include/d/actor/d_a_npc_zanb.h @@ -20,7 +20,7 @@ class daNpc_zanB_Param_c { public: virtual ~daNpc_zanB_Param_c() {} - static daNpc_zanB_HIOParam const m; + static DUSK_GAME_DATA daNpc_zanB_HIOParam const m; }; #if DEBUG @@ -99,10 +99,9 @@ public: return nodeNo; } - static char DUSK_CONST* DUSK_CONST mCutNameList[1]; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZANB_HIO_CLASS* mHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zant.h b/include/d/actor/d_a_npc_zant.h index d2d1949bda..f9cd1c5b9b 100644 --- a/include/d/actor/d_a_npc_zant.h +++ b/include/d/actor/d_a_npc_zant.h @@ -11,7 +11,7 @@ class daNpc_Zant_Param_c { public: virtual ~daNpc_Zant_Param_c() {} - static const daNpc_Zant_HIOParam m; + static DUSK_GAME_DATA const daNpc_Zant_HIOParam m; }; #if DEBUG @@ -83,10 +83,9 @@ public: daNpcT_evtData_c const* param_7, char DUSK_CONST* DUSK_CONST* param_8) : daNpcT_c(param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8) {} - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZANT_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelR.h b/include/d/actor/d_a_npc_zelR.h index ce3314c694..bfe7d963a0 100644 --- a/include/d/actor/d_a_npc_zelR.h +++ b/include/d/actor/d_a_npc_zelR.h @@ -20,7 +20,7 @@ class daNpc_ZelR_Param_c { public: virtual ~daNpc_ZelR_Param_c() {}; - static const daNpc_ZelR_HIOParam m; + static DUSK_GAME_DATA const daNpc_ZelR_HIOParam m; }; #if DEBUG @@ -93,10 +93,9 @@ public: BOOL checkChangeJoint(int param_1) { return param_1 == 3; }; BOOL checkRemoveJoint(int param_1) { return param_1 == 13; }; - static char DUSK_CONST* DUSK_CONST mCutNameList; - static EventFn mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA EventFn mCutList[1]; -private: /* 0xE40 */ NPC_ZELR_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelRo.h b/include/d/actor/d_a_npc_zelRo.h index 40e0b3e391..a57235bff9 100644 --- a/include/d/actor/d_a_npc_zelRo.h +++ b/include/d/actor/d_a_npc_zelRo.h @@ -20,7 +20,7 @@ class daNpc_ZelRo_Param_c { public: virtual ~daNpc_ZelRo_Param_c() {} - static daNpc_ZelRo_HIOParam const m; + static DUSK_GAME_DATA daNpc_ZelRo_HIOParam const m; }; #if DEBUG @@ -147,10 +147,9 @@ public: BOOL checkChangeJoint(int i_joint) { return i_joint == JNT_HEAD; } BOOL checkRemoveJoint(int i_joint) { return i_joint == JNT_MOUTH; } - static char DUSK_CONST* DUSK_CONST mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZELRO_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelda.h b/include/d/actor/d_a_npc_zelda.h index 5a2d70b658..e4be31296e 100644 --- a/include/d/actor/d_a_npc_zelda.h +++ b/include/d/actor/d_a_npc_zelda.h @@ -14,7 +14,7 @@ class daNpc_Zelda_Param_c { public: virtual ~daNpc_Zelda_Param_c() {} - static const daNpc_Zelda_HIOParam m; + static DUSK_GAME_DATA const daNpc_Zelda_HIOParam m; }; #if DEBUG @@ -100,10 +100,9 @@ public: int checkChangeJoint(int param_0) { return param_0 == 4; } int checkRemoveJoint(int param_0) { return param_0 == 17; } - static const char* mCutNameList; - static cutFunc DUSK_CONST mCutList[1]; + static DUSK_GAME_DATA const char* mCutNameList; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZELDA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 field_0xf80; diff --git a/include/d/actor/d_a_npc_zra.h b/include/d/actor/d_a_npc_zra.h index 31ea1431b7..825076e192 100644 --- a/include/d/actor/d_a_npc_zra.h +++ b/include/d/actor/d_a_npc_zra.h @@ -32,7 +32,7 @@ class daNpc_zrA_Param_c { public: virtual ~daNpc_zrA_Param_c() {} - static daNpc_zrA_HIOParam const m; + static DUSK_GAME_DATA daNpc_zrA_HIOParam const m; }; #if DEBUG @@ -370,6 +370,9 @@ public: u32 getAngleNoFromParam() { return (u8)(fopAcM_GetParam(this) >> 8); } void setBlastFlag(u8 i_flag) { mBlastFlag = i_flag; } MtxP getHeadMtx() { return mAnm_p->getModel()->getAnmMtx(4); } +#if TARGET_PC + friend void daNpc_zrA_interp_callback(void* pUserWork); +#endif /* 0x0B48 */ Z2Creature mCreatureSound; /* 0x0BD8 */ J3DModel* mpObjectModel[3]; @@ -443,8 +446,8 @@ public: /* 0x15C0 */ u8 field_0x15c0; /* 0x15C1 */ bool mBlastFlag; - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[11]; - static EventFn DUSK_CONST mEvtCutList[11]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[11]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[11]; }; STATIC_ASSERT(sizeof(daNpc_zrA_c) == 0x15C4); diff --git a/include/d/actor/d_a_npc_zrc.h b/include/d/actor/d_a_npc_zrc.h index 184a4e31c0..e9992ae157 100644 --- a/include/d/actor/d_a_npc_zrc.h +++ b/include/d/actor/d_a_npc_zrc.h @@ -16,7 +16,7 @@ class daNpc_zrC_Param_c { public: virtual ~daNpc_zrC_Param_c() {} - static daNpc_zrC_HIOParam const m; + static DUSK_GAME_DATA daNpc_zrC_HIOParam const m; }; #if DEBUG @@ -93,10 +93,9 @@ public: BOOL ECut_earringGet(int); void adjustShapeAngle() {} - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; - static EventFn DUSK_CONST mEvtCutList[2]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_zrz.h b/include/d/actor/d_a_npc_zrz.h index a9a294b97f..a02ebb8227 100644 --- a/include/d/actor/d_a_npc_zrz.h +++ b/include/d/actor/d_a_npc_zrz.h @@ -20,7 +20,7 @@ class daNpc_zrZ_Param_c { public: virtual ~daNpc_zrZ_Param_c() {} - static daNpc_zrZ_HIOParam const m; + static DUSK_GAME_DATA daNpc_zrZ_HIOParam const m; }; STATIC_ASSERT(sizeof(daNpc_zrZ_HIOParam) == 0x84); @@ -114,7 +114,6 @@ public: void himoCalc(); void adjustShapeAngle() {} -private: /* 0x0B48 */ Z2Creature mCreatureSound; /* 0x0BD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0x0BDC */ mDoExt_invisibleModel mInvisibleModel; @@ -160,8 +159,8 @@ private: /* 0x14C0 */ BOOL mMusicSet; /* 0x14C4 */ bool mSealReleased; - static char DUSK_CONST* DUSK_CONST mEvtCutNameList[8]; - static EventFn DUSK_CONST mEvtCutList[8]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[8]; + static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[8]; enum Animation { /* 0x0 */ ANM_NONE, diff --git a/include/d/actor/d_a_obj_Lv5Key.h b/include/d/actor/d_a_obj_Lv5Key.h index 6e0251b151..11e2bd3019 100644 --- a/include/d/actor/d_a_obj_Lv5Key.h +++ b/include/d/actor/d_a_obj_Lv5Key.h @@ -65,7 +65,6 @@ public: cXyz& getLocalOffset() { return mLocalOffset; } -private: /* 0x568 */ u8 field_0x568[0x56C - 0x568]; /* 0x56C */ Z2SoundObjSimple mSound; /* 0x58C */ u8 field_0x58C[0x590 - 0x58C]; diff --git a/include/d/actor/d_a_obj_Turara.h b/include/d/actor/d_a_obj_Turara.h index d8a45097d9..16f27d8550 100644 --- a/include/d/actor/d_a_obj_Turara.h +++ b/include/d/actor/d_a_obj_Turara.h @@ -53,10 +53,9 @@ public: int getItemTbleNum() { return shape_angle.x >> 8 & 0xff; } int getState() { return shape_angle.x; } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5b8 */ request_of_phase_process_class mPhaseReq; /* 0x5c0 */ J3DModel* mpModel[2]; /* 0x5c8 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_TvCdlst.h b/include/d/actor/d_a_obj_TvCdlst.h index 7d94a35676..5329727f6a 100644 --- a/include/d/actor/d_a_obj_TvCdlst.h +++ b/include/d/actor/d_a_obj_TvCdlst.h @@ -26,14 +26,13 @@ public: int Draw(); int Delete(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; u8 getLightType() { return fopAcM_GetParamBit(this,8,8); } u8 getOnSw() { return fopAcM_GetParamBit(this,0,8); } u8 getOffSw() { return fopAcM_GetParamBit(this,0x10,8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_Y_taihou.h b/include/d/actor/d_a_obj_Y_taihou.h index 0e96cf62ed..002b85d853 100644 --- a/include/d/actor/d_a_obj_Y_taihou.h +++ b/include/d/actor/d_a_obj_Y_taihou.h @@ -37,7 +37,6 @@ public: s32 getIronBallId() { return mIronBallId; } void startBomb() { mStartBomb = 0xffff; } -private: /* 0x5b8 */ Mtx mMtx; /* 0x5e8 */ J3DModel* mpModel; /* 0x5ec */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_amiShutter.h b/include/d/actor/d_a_obj_amiShutter.h index b0e881c4c0..9fabc75220 100644 --- a/include/d/actor/d_a_obj_amiShutter.h +++ b/include/d/actor/d_a_obj_amiShutter.h @@ -62,7 +62,6 @@ public: bool isShutterOpen() { return mOpen; } -private: /* 0x5b8 */ request_of_phase_process_class mPhaseReq; /* 0x5c0 */ J3DModel* mpModel; /* 0x5c4 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_ari.h b/include/d/actor/d_a_obj_ari.h index a771b054f1..03b80016bd 100644 --- a/include/d/actor/d_a_obj_ari.h +++ b/include/d/actor/d_a_obj_ari.h @@ -40,7 +40,6 @@ public: bool CreateChk(); cPhs_Step create(); -private: /* 0x590 */ dBgS_GndChk mGndChk; /* 0x5E4 */ u8 field_0x5e4[4]; /* 0x5E8 */ u8 mAction; diff --git a/include/d/actor/d_a_obj_automata.h b/include/d/actor/d_a_obj_automata.h index 3468ccc3e8..17e470af99 100644 --- a/include/d/actor/d_a_obj_automata.h +++ b/include/d/actor/d_a_obj_automata.h @@ -15,7 +15,7 @@ class daObj_AutoMata_Param_c { public: virtual ~daObj_AutoMata_Param_c() {} - static daObj_AutoMata_HIOParam const m; + static DUSK_GAME_DATA daObj_AutoMata_HIOParam const m; }; #if DEBUG @@ -44,7 +44,7 @@ public: * */ class daObj_AutoMata_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_AUTOMATA_HIO_CLASS* mpHIO; /* 0x56C */ mDoExt_McaMorfSO* mpMorf; /* 0x570 */ Z2Creature mCreature; diff --git a/include/d/actor/d_a_obj_avalanche.h b/include/d/actor/d_a_obj_avalanche.h index 89de60d2e8..ef72babdef 100644 --- a/include/d/actor/d_a_obj_avalanche.h +++ b/include/d/actor/d_a_obj_avalanche.h @@ -46,7 +46,6 @@ public: u8 getEvId() { return fopAcM_GetParamBit(this, 8, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ mDoExt_bckAnm* mBckAnm; diff --git a/include/d/actor/d_a_obj_barDesk.h b/include/d/actor/d_a_obj_barDesk.h index 427e18ebdb..fc4c1cf4df 100644 --- a/include/d/actor/d_a_obj_barDesk.h +++ b/include/d/actor/d_a_obj_barDesk.h @@ -36,8 +36,8 @@ public: /* 0x5EC */ dCcD_Cyl mColCyl; /* 0x728 */ u8 field_0x728[8]; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daBarDesk_c) == 0x730); diff --git a/include/d/actor/d_a_obj_batta.h b/include/d/actor/d_a_obj_batta.h index fca663390b..a1eaefc45e 100644 --- a/include/d/actor/d_a_obj_batta.h +++ b/include/d/actor/d_a_obj_batta.h @@ -43,7 +43,6 @@ public: return mActionFunc == i_func; } -private: /* 0x590 */ Z2Creature mCreature; /* 0x620 */ mDoExt_McaMorfSO* mpMorf; /* 0x624 */ mDoExt_brkAnm* mBrk; diff --git a/include/d/actor/d_a_obj_bbox.h b/include/d/actor/d_a_obj_bbox.h index 7ee461b557..1f7c2eef60 100644 --- a/include/d/actor/d_a_obj_bbox.h +++ b/include/d/actor/d_a_obj_bbox.h @@ -26,7 +26,6 @@ public: u32 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_bed.h b/include/d/actor/d_a_obj_bed.h index 883dd64f73..c6d76f0005 100644 --- a/include/d/actor/d_a_obj_bed.h +++ b/include/d/actor/d_a_obj_bed.h @@ -19,7 +19,7 @@ class daObj_Bed_Param_c { public: virtual ~daObj_Bed_Param_c() {} - static daObj_Bed_HIOParam const m; + static DUSK_GAME_DATA daObj_Bed_HIOParam const m; }; #if DEBUG diff --git a/include/d/actor/d_a_obj_bemos.h b/include/d/actor/d_a_obj_bemos.h index 713794c3b1..3d0c10790d 100644 --- a/include/d/actor/d_a_obj_bemos.h +++ b/include/d/actor/d_a_obj_bemos.h @@ -50,12 +50,12 @@ public: void wall_pos(fopAc_ac_c const*, daObjBm_c::BgcSrc_c const*, int, s16, f32); bool chk_wall_pre(fopAc_ac_c const*, daObjBm_c::BgcSrc_c const*, int, s16); - static const daObjBm_c::BgcSrc_c M_lin5[]; - static const daObjBm_c::BgcSrc_c M_lin20[]; + static DUSK_GAME_DATA const daObjBm_c::BgcSrc_c M_lin5[]; + static DUSK_GAME_DATA const daObjBm_c::BgcSrc_c M_lin20[]; - static dBgS_ObjGndChk M_gnd_work[23]; - static dBgS_WtrChk M_wrt_work; - static dBgS_ObjLinChk M_wall_work[23]; + static DUSK_GAME_DATA dBgS_ObjGndChk M_gnd_work[23]; + static DUSK_GAME_DATA dBgS_WtrChk M_wrt_work; + static DUSK_GAME_DATA dBgS_ObjLinChk M_wall_work[23]; /* 0x000 */ f32 field_0x0[23]; /* 0x05C */ int field_0x5c; @@ -130,8 +130,7 @@ public: #endif int Delete(); - static s16 const M_dir_base[4]; - // private: + static DUSK_GAME_DATA s16 const M_dir_base[4]; /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ mDoExt_brkAnm* mSerchBrk; diff --git a/include/d/actor/d_a_obj_bhashi.h b/include/d/actor/d_a_obj_bhashi.h index 7600d73f67..7ce2cd1c23 100644 --- a/include/d/actor/d_a_obj_bhashi.h +++ b/include/d/actor/d_a_obj_bhashi.h @@ -50,7 +50,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x05A0 */ u8 field_0x5A0[0x05A4 - 0x05A0]; /* 0x05A4 */ int mMode; /* 0x05A8 */ s16 field_0x5a8; diff --git a/include/d/actor/d_a_obj_bkdoor.h b/include/d/actor/d_a_obj_bkdoor.h index 69d3191028..793d86f09c 100644 --- a/include/d/actor/d_a_obj_bkdoor.h +++ b/include/d/actor/d_a_obj_bkdoor.h @@ -26,7 +26,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ csXyz mRotation; diff --git a/include/d/actor/d_a_obj_bky_rock.h b/include/d/actor/d_a_obj_bky_rock.h index 99f23557e4..1214a610c9 100644 --- a/include/d/actor/d_a_obj_bky_rock.h +++ b/include/d/actor/d_a_obj_bky_rock.h @@ -60,10 +60,9 @@ public: u8 getSwBit1() { return fopAcM_GetParamBit(this, 12, 8); } s8 getNameNo() { return fopAcM_GetParamBit(this, 0, 4); } - static dCcD_SrcCyl const s_CcDCyl; - static exeProc s_exeProc[3]; + static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; + static DUSK_GAME_DATA exeProc s_exeProc[3]; -private: /* 0x568 */ int mVibrationTimer; /* 0x578 */ u8 mMode; /* 0x579 */ bool field_0x579; diff --git a/include/d/actor/d_a_obj_bmWindow.h b/include/d/actor/d_a_obj_bmWindow.h index 85b5ab8f86..a3d71fa9c2 100644 --- a/include/d/actor/d_a_obj_bmWindow.h +++ b/include/d/actor/d_a_obj_bmWindow.h @@ -39,7 +39,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; @@ -66,8 +65,8 @@ private: /* 0xEDE */ u8 field_0xede; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daBmWindow_c) == 0xEE0); diff --git a/include/d/actor/d_a_obj_bmshutter.h b/include/d/actor/d_a_obj_bmshutter.h index c114421fe8..6ca4c05fe9 100644 --- a/include/d/actor/d_a_obj_bmshutter.h +++ b/include/d/actor/d_a_obj_bmshutter.h @@ -46,7 +46,6 @@ public: void setAction(u8 action) { mAction = action; } void setMoveMode(u8 mode) { mMoveMode = mode; } -private: /* 0x5a0 */ request_of_phase_process_class mPhase; /* 0x5a8 */ J3DModel* mModel; /* 0x5ac */ s16 mEventIdx; diff --git a/include/d/actor/d_a_obj_bombf.h b/include/d/actor/d_a_obj_bombf.h index 1d175caa94..661450e397 100644 --- a/include/d/actor/d_a_obj_bombf.h +++ b/include/d/actor/d_a_obj_bombf.h @@ -21,7 +21,6 @@ public: int execute(); int draw(); -private: /* 0x568 */ request_of_phase_process_class field_0x568; /* 0x570 */ J3DModel* field_0x570; /* 0x574 */ u32 field_0x574; diff --git a/include/d/actor/d_a_obj_bosswarp.h b/include/d/actor/d_a_obj_bosswarp.h index 9b62f1a0f6..4f6c6e4282 100644 --- a/include/d/actor/d_a_obj_bosswarp.h +++ b/include/d/actor/d_a_obj_bosswarp.h @@ -60,7 +60,6 @@ public: bool isFirst() { return fopAcM_GetParamBit(this, 0x1b, 1); } void setAction(u8 action) { mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtkAnm[2]; diff --git a/include/d/actor/d_a_obj_boumato.h b/include/d/actor/d_a_obj_boumato.h index 3a988d9b4b..6a0266e548 100644 --- a/include/d/actor/d_a_obj_boumato.h +++ b/include/d/actor/d_a_obj_boumato.h @@ -21,7 +21,7 @@ class daObj_BouMato_Param_c { public: virtual ~daObj_BouMato_Param_c() {} - static daObj_BouMato_HIOParam const m; + static DUSK_GAME_DATA daObj_BouMato_HIOParam const m; }; #if DEBUG @@ -50,7 +50,7 @@ public: * */ class daObj_BouMato_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_BOUMATO_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_bsGate.h b/include/d/actor/d_a_obj_bsGate.h index b40c5dcf6d..0c9730d63d 100644 --- a/include/d/actor/d_a_obj_bsGate.h +++ b/include/d/actor/d_a_obj_bsGate.h @@ -35,7 +35,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_bubblePilar.h b/include/d/actor/d_a_obj_bubblePilar.h index b9abdd1fdd..e19cbbae2f 100644 --- a/include/d/actor/d_a_obj_bubblePilar.h +++ b/include/d/actor/d_a_obj_bubblePilar.h @@ -36,10 +36,9 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this, 8, 4); } u8 getSw() { return fopAcM_GetParamBit(this, 0, 8); } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModels[2]; /* 0x5B0 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_burnbox.h b/include/d/actor/d_a_obj_burnbox.h index f87678dccc..dc4634ea85 100644 --- a/include/d/actor/d_a_obj_burnbox.h +++ b/include/d/actor/d_a_obj_burnbox.h @@ -28,7 +28,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpBoxModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_carry.h b/include/d/actor/d_a_obj_carry.h index 621b8efabb..54c8c73043 100644 --- a/include/d/actor/d_a_obj_carry.h +++ b/include/d/actor/d_a_obj_carry.h @@ -304,11 +304,11 @@ public: make_prm(o_params, o_paramsEx, 6, i_itemNo, i_itemBit, i_itemType, param_5); } - static const daObjCarry_dt_t mData[]; - static cXyz mPos[5]; - static u8 mSttsFlag[5]; - static s8 mRoomNo[5]; - static bool mSaveFlag; + static DUSK_GAME_DATA const daObjCarry_dt_t mData[]; + static DUSK_GAME_DATA cXyz mPos[5]; + static DUSK_GAME_DATA u8 mSttsFlag[5]; + static DUSK_GAME_DATA s8 mRoomNo[5]; + static DUSK_GAME_DATA bool mSaveFlag; public: /* 0x568 */ request_of_phase_process_class mPhaseReq; @@ -407,7 +407,6 @@ public: /* 0xE26 */ u8 field_0xe26; /* 0xE27 */ u8 field_0xe27; -private: u16 getType_private() { return field_0xd18 >> 1 & 0x1f; } }; diff --git a/include/d/actor/d_a_obj_catdoor.h b/include/d/actor/d_a_obj_catdoor.h index dd7141d920..c352c25806 100644 --- a/include/d/actor/d_a_obj_catdoor.h +++ b/include/d/actor/d_a_obj_catdoor.h @@ -80,7 +80,6 @@ public: Z2GetAudioMgr()->seStart(Z2SE_OBJ_GZ_NE_DOOR_OP, ¤t.pos, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ daObjCatDoor_Door_c mDoor1; /* 0x660 */ daObjCatDoor_Door_c mDoor2; @@ -88,7 +87,7 @@ private: /* 0x790 */ s16 mRotSpeed; public: - static const daObjCatDoor_Attr_c M_attr; + static DUSK_GAME_DATA const daObjCatDoor_Attr_c M_attr; }; #endif /* D_A_OBJ_CATDOOR_H */ diff --git a/include/d/actor/d_a_obj_cblock.h b/include/d/actor/d_a_obj_cblock.h index 04881776ec..75454ebb5d 100644 --- a/include/d/actor/d_a_obj_cblock.h +++ b/include/d/actor/d_a_obj_cblock.h @@ -49,7 +49,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 16, 8); } u8 getPathID() { return fopAcM_GetParamBit(this, 24, 8); } -private: /* 0x5A0 */ request_of_phase_process_class phase; /* 0x5A8 */ J3DModel* model1; /* 0x5AC */ J3DModel* model2; diff --git a/include/d/actor/d_a_obj_cboard.h b/include/d/actor/d_a_obj_cboard.h index 52a5f753e4..9bcdb51ed5 100644 --- a/include/d/actor/d_a_obj_cboard.h +++ b/include/d/actor/d_a_obj_cboard.h @@ -28,7 +28,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this, 4, 4); } u8 getSwNo() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ Mtx field_0x5a8; }; diff --git a/include/d/actor/d_a_obj_cdoor.h b/include/d/actor/d_a_obj_cdoor.h index ee06fd790c..60d54539e9 100644 --- a/include/d/actor/d_a_obj_cdoor.h +++ b/include/d/actor/d_a_obj_cdoor.h @@ -51,7 +51,6 @@ public: int getSwitchNum() { return mSw; } void setChainID(u32 i_id) { mChainID = i_id; } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ bool mEnd; diff --git a/include/d/actor/d_a_obj_chandelier.h b/include/d/actor/d_a_obj_chandelier.h index 4aae0160d8..a0592f4374 100644 --- a/include/d/actor/d_a_obj_chandelier.h +++ b/include/d/actor/d_a_obj_chandelier.h @@ -49,7 +49,6 @@ public: void moveHookOn() { field_0x60a = 1; } -private: /* 0x5A8 */ cXyz field_0x5a8; /* 0x5B4 */ Mtx mMtx; /* 0x5E4 */ u8 field_0x5e4[4]; @@ -67,7 +66,7 @@ private: /* 0x60A */ u8 field_0x60a; /* 0x60B */ u8 field_0x60b; - static daObjChandelier_proc s_exeProc[5]; + static DUSK_GAME_DATA daObjChandelier_proc s_exeProc[5]; }; STATIC_ASSERT(sizeof(daObjChandelier_c) == 0x60C); diff --git a/include/d/actor/d_a_obj_chest.h b/include/d/actor/d_a_obj_chest.h index a5caedae86..e225c4a254 100644 --- a/include/d/actor/d_a_obj_chest.h +++ b/include/d/actor/d_a_obj_chest.h @@ -39,7 +39,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } u32 getArg0() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_obj_cho.h b/include/d/actor/d_a_obj_cho.h index 49dd5332b1..adb3faef58 100644 --- a/include/d/actor/d_a_obj_cho.h +++ b/include/d/actor/d_a_obj_cho.h @@ -46,7 +46,6 @@ public: cPhs_Step create(); inline int Draw(); -private: /* 0x590 */ dBgS_AcchCir mAcchCir; /* 0x5D0 */ dBgS_ObjAcch mAcch; /* 0x7A8 */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_cowdoor.h b/include/d/actor/d_a_obj_cowdoor.h index 1ed34370d8..a084ca0188 100644 --- a/include/d/actor/d_a_obj_cowdoor.h +++ b/include/d/actor/d_a_obj_cowdoor.h @@ -22,7 +22,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class field_0x5a0; /* 0x5A8 */ J3DModel* field_0x5a8; }; diff --git a/include/d/actor/d_a_obj_crope.h b/include/d/actor/d_a_obj_crope.h index bde25e379c..e0f0220000 100644 --- a/include/d/actor/d_a_obj_crope.h +++ b/include/d/actor/d_a_obj_crope.h @@ -52,7 +52,6 @@ public: mCoCancelTimer = 30; } -private: /* 0x0568 */ request_of_phase_process_class mPhase; /* 0x0570 */ dCcD_Stts mCcStts; /* 0x05AC */ dCcD_Sph mCollider; diff --git a/include/d/actor/d_a_obj_crvfence.h b/include/d/actor/d_a_obj_crvfence.h index dd760bb43f..9b6298553f 100644 --- a/include/d/actor/d_a_obj_crvfence.h +++ b/include/d/actor/d_a_obj_crvfence.h @@ -34,7 +34,6 @@ public: int Draw(); int Delete(); -private: /* 0x05A0 */ int field_0x5a0; /* 0x05A4 */ int mAction; /* 0x05A8 */ u8 field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvgate.h b/include/d/actor/d_a_obj_crvgate.h index 1fb4d1a12b..fed7868085 100644 --- a/include/d/actor/d_a_obj_crvgate.h +++ b/include/d/actor/d_a_obj_crvgate.h @@ -50,7 +50,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ s32 mEventID; /* 0x5A4 */ bool mFlagGateClosed; /* 0x5A5 */ bool field_0x5a5; diff --git a/include/d/actor/d_a_obj_crvlh_down.h b/include/d/actor/d_a_obj_crvlh_down.h index ce1c31bfa8..06ad6c89f0 100644 --- a/include/d/actor/d_a_obj_crvlh_down.h +++ b/include/d/actor/d_a_obj_crvlh_down.h @@ -28,7 +28,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ fpc_ProcID field_0x5a0; /* 0x5A4 */ fpc_ProcID field_0x5a4; /* 0x5A8 */ cXyz field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvlh_up.h b/include/d/actor/d_a_obj_crvlh_up.h index 7f24ba03a6..950018311a 100644 --- a/include/d/actor/d_a_obj_crvlh_up.h +++ b/include/d/actor/d_a_obj_crvlh_up.h @@ -26,7 +26,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x568 */ u8 field_0x568[0x5a4 - 0x5a0]; /* 0x5A4 */ fpc_ProcID field_0x5a4; /* 0x5A8 */ fpc_ProcID field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvsteel.h b/include/d/actor/d_a_obj_crvsteel.h index a8d6305495..09ddc5be2a 100644 --- a/include/d/actor/d_a_obj_crvsteel.h +++ b/include/d/actor/d_a_obj_crvsteel.h @@ -29,7 +29,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ u32 mSmokeParticle1; /* 0x5A4 */ u32 mSmokeParticle2; /* 0x5A8 */ s16 mAction; diff --git a/include/d/actor/d_a_obj_crystal.h b/include/d/actor/d_a_obj_crystal.h index 0d6fcc1fc6..3c2fbfb110 100644 --- a/include/d/actor/d_a_obj_crystal.h +++ b/include/d/actor/d_a_obj_crystal.h @@ -22,7 +22,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel[2]; /* 0x578 */ JPABaseEmitter* mpEmitter; diff --git a/include/d/actor/d_a_obj_cwall.h b/include/d/actor/d_a_obj_cwall.h index 396729be80..66d760a337 100644 --- a/include/d/actor/d_a_obj_cwall.h +++ b/include/d/actor/d_a_obj_cwall.h @@ -61,7 +61,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 4, 4); } u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mWallModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_damCps.h b/include/d/actor/d_a_obj_damCps.h index 1ce75cc663..d92a38184c 100644 --- a/include/d/actor/d_a_obj_damCps.h +++ b/include/d/actor/d_a_obj_damCps.h @@ -26,7 +26,6 @@ public: int _delete(); u8 getSwNo(); -private: /* 0x0570 */ dCcD_Stts mStts; /* 0x05AC */ dCcD_Cps mCps; /* 0x06F0 */ cM3dGCpsS mCapsule; diff --git a/include/d/actor/d_a_obj_dan.h b/include/d/actor/d_a_obj_dan.h index 15caef361a..3e3b62fc9b 100644 --- a/include/d/actor/d_a_obj_dan.h +++ b/include/d/actor/d_a_obj_dan.h @@ -39,7 +39,6 @@ public: bool CreateChk(); cPhs_Step create(); -private: /* 0x590 */ dCcD_Stts mCcStts; /* 0x5CC */ dCcD_Sph mCcSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_digholl.h b/include/d/actor/d_a_obj_digholl.h index 33f078a1ea..f985bbe165 100644 --- a/include/d/actor/d_a_obj_digholl.h +++ b/include/d/actor/d_a_obj_digholl.h @@ -21,7 +21,6 @@ public: void onDigStart() { field_0x568 = 1; } s16 getSceneNum() const { return field_0x56c; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_obj_digplace.h b/include/d/actor/d_a_obj_digplace.h index 404b35aff4..0b29ff11f6 100644 --- a/include/d/actor/d_a_obj_digplace.h +++ b/include/d/actor/d_a_obj_digplace.h @@ -17,7 +17,6 @@ public: int create(); int execute(); -private: /* 0x568 */ u8 mType; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 mDigFlg; diff --git a/include/d/actor/d_a_obj_digsnow.h b/include/d/actor/d_a_obj_digsnow.h index 09af66d091..4ef3de5958 100644 --- a/include/d/actor/d_a_obj_digsnow.h +++ b/include/d/actor/d_a_obj_digsnow.h @@ -50,7 +50,6 @@ public: void startDig() { mMode = ACTION_DIG_e; } void endDig() { mMode = ACTION_END_e; } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_enemy_create.h b/include/d/actor/d_a_obj_enemy_create.h index 3b29caddab..64da7b5203 100644 --- a/include/d/actor/d_a_obj_enemy_create.h +++ b/include/d/actor/d_a_obj_enemy_create.h @@ -22,7 +22,6 @@ public: void NameChk(); int create(); -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mEnemyNum; /* 0x56A */ u8 mActivateSw; diff --git a/include/d/actor/d_a_obj_fallobj.h b/include/d/actor/d_a_obj_fallobj.h index 0c4efed3f3..f59a58991a 100644 --- a/include/d/actor/d_a_obj_fallobj.h +++ b/include/d/actor/d_a_obj_fallobj.h @@ -50,7 +50,6 @@ public: return this->speed.y != 0.0f; }; -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ Mtx mMtx; /* 0x5D8 */ u8 field_0x5d8; diff --git a/include/d/actor/d_a_obj_fan.h b/include/d/actor/d_a_obj_fan.h index 1ababac7a6..a4907c01a1 100644 --- a/include/d/actor/d_a_obj_fan.h +++ b/include/d/actor/d_a_obj_fan.h @@ -29,7 +29,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this,0,4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ dBgW* field_0x5ac; diff --git a/include/d/actor/d_a_obj_fchain.h b/include/d/actor/d_a_obj_fchain.h index 7c4ae74faf..e9250fbe24 100644 --- a/include/d/actor/d_a_obj_fchain.h +++ b/include/d/actor/d_a_obj_fchain.h @@ -31,11 +31,6 @@ public: csXyz* getAngle() { return field_0x8a4; } J3DModelData* getModelData() { return mModelData; } -#if TARGET_PC - void onInterpCallback(); -#endif - -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModelData* mModelData; /* 0x574 */ daObjFchain_shape_c mShape; @@ -46,14 +41,6 @@ private: /* 0x694 */ cXyz field_0x694[22]; /* 0x79C */ cXyz field_0x79c[22]; /* 0x8A4 */ csXyz field_0x8a4[22]; - -#if TARGET_PC - static const int CHAIN_COUNT = 22; - cXyz mChainInterpPrev[CHAIN_COUNT]; - cXyz mChainInterpCurr[CHAIN_COUNT]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(daObjFchain_c) == 0x928); diff --git a/include/d/actor/d_a_obj_fireWood.h b/include/d/actor/d_a_obj_fireWood.h index 116af1203c..5ce85234de 100644 --- a/include/d/actor/d_a_obj_fireWood.h +++ b/include/d/actor/d_a_obj_fireWood.h @@ -24,10 +24,9 @@ public: int Draw(); int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ dCcD_Stts mCcStts; /* 0x5B0 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_obj_fireWood2.h b/include/d/actor/d_a_obj_fireWood2.h index 3b288edeeb..209ccf8ffd 100644 --- a/include/d/actor/d_a_obj_fireWood2.h +++ b/include/d/actor/d_a_obj_fireWood2.h @@ -25,10 +25,9 @@ public: int Draw(); int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ dCcD_Stts mCcStts; /* 0x5B0 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_obj_firepillar.h b/include/d/actor/d_a_obj_firepillar.h index 620373422a..8490a1c488 100644 --- a/include/d/actor/d_a_obj_firepillar.h +++ b/include/d/actor/d_a_obj_firepillar.h @@ -47,7 +47,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ int field_0x570; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_firepillar2.h b/include/d/actor/d_a_obj_firepillar2.h index 359cbf6bb3..579342b8dc 100644 --- a/include/d/actor/d_a_obj_firepillar2.h +++ b/include/d/actor/d_a_obj_firepillar2.h @@ -51,7 +51,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this,8,8); } u8 getSwNo() { return fopAcM_GetParamBit(this,0,8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mModel; /* 0x574 */ mDoExt_bckAnm* mBck; diff --git a/include/d/actor/d_a_obj_flag.h b/include/d/actor/d_a_obj_flag.h index eee36b0842..8ac8662fb9 100644 --- a/include/d/actor/d_a_obj_flag.h +++ b/include/d/actor/d_a_obj_flag.h @@ -28,7 +28,7 @@ public: * */ class daObjFlag_c : public fopAc_ac_c { -private: +public: /* 0x568 */ J3DModel* mpModel1; /* 0x56c */ J3DModel* mpModel2; /* 0x570 */ request_of_phase_process_class mPhase; @@ -86,7 +86,7 @@ public: /* 0x30 */ f32 field_0x30; }; - static M_attrs const M_attr; + static DUSK_GAME_DATA M_attrs const M_attr; M_attrs const& attr() const { return M_attr; } }; diff --git a/include/d/actor/d_a_obj_flag2.h b/include/d/actor/d_a_obj_flag2.h index 54b3777ac6..676da2141d 100644 --- a/include/d/actor/d_a_obj_flag2.h +++ b/include/d/actor/d_a_obj_flag2.h @@ -81,9 +81,8 @@ public: const daObjFlag2_Attr_c& attr() const { return M_attr; } - static daObjFlag2_Attr_c const M_attr; + static DUSK_GAME_DATA daObjFlag2_Attr_c const M_attr; -private: /* 0x0568 */ J3DModel* mModel; /* 0x056C */ request_of_phase_process_class mFlagPhase; /* 0x0574 */ request_of_phase_process_class mArcPhase; diff --git a/include/d/actor/d_a_obj_flag3.h b/include/d/actor/d_a_obj_flag3.h index c6a94f6538..26bfd5b506 100644 --- a/include/d/actor/d_a_obj_flag3.h +++ b/include/d/actor/d_a_obj_flag3.h @@ -93,10 +93,9 @@ public: inline int draw(); inline void initBaseMtx(); - static daObjFlag3_Attr_c const M_attr; + static DUSK_GAME_DATA daObjFlag3_Attr_c const M_attr; const daObjFlag3_Attr_c& attr() const { return M_attr; } -private: /* 0x0568 */ J3DModel* mModel; /* 0x056C */ request_of_phase_process_class mFlagPhase; /* 0x0574 */ request_of_phase_process_class mArcPhase; diff --git a/include/d/actor/d_a_obj_gadget.h b/include/d/actor/d_a_obj_gadget.h index db7f5a53f7..a52f9ab27b 100644 --- a/include/d/actor/d_a_obj_gadget.h +++ b/include/d/actor/d_a_obj_gadget.h @@ -17,7 +17,7 @@ class daObj_Gadget_HIO_c; * */ class daObj_Gadget_c : public fopAc_ac_c { -private: +public: /* 0x568 */ daObj_Gadget_HIO_c* field_0x568; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; @@ -117,7 +117,7 @@ class daObj_Gadget_Param_c { public: virtual ~daObj_Gadget_Param_c() {} - static daObj_Gadget_HIOParam const m; + static DUSK_GAME_DATA daObj_Gadget_HIOParam const m; }; diff --git a/include/d/actor/d_a_obj_ganonwall.h b/include/d/actor/d_a_obj_ganonwall.h index 02d0cd1d99..c5e6f7d06a 100644 --- a/include/d/actor/d_a_obj_ganonwall.h +++ b/include/d/actor/d_a_obj_ganonwall.h @@ -26,7 +26,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } u32 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtkAnm; diff --git a/include/d/actor/d_a_obj_ganonwall2.h b/include/d/actor/d_a_obj_ganonwall2.h index a938a32141..0026094a8d 100644 --- a/include/d/actor/d_a_obj_ganonwall2.h +++ b/include/d/actor/d_a_obj_ganonwall2.h @@ -25,7 +25,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm* mpBtkAnm; diff --git a/include/d/actor/d_a_obj_gb.h b/include/d/actor/d_a_obj_gb.h index 3f5a354f5e..2bc435b2df 100644 --- a/include/d/actor/d_a_obj_gb.h +++ b/include/d/actor/d_a_obj_gb.h @@ -36,5 +36,4 @@ public: STATIC_ASSERT(sizeof(obj_gb_class) == 0x6bc); - #endif /* D_A_OBJ_GB_H */ diff --git a/include/d/actor/d_a_obj_geyser.h b/include/d/actor/d_a_obj_geyser.h index 54a7f3bcb8..244d3b1fcf 100644 --- a/include/d/actor/d_a_obj_geyser.h +++ b/include/d/actor/d_a_obj_geyser.h @@ -62,7 +62,6 @@ public: u8 getArg3() { return fopAcM_GetParamBit(this, 24, 8); } u8 getSwNo() { return 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_glowSphere.h b/include/d/actor/d_a_obj_glowSphere.h index f620306408..062a9ce7d5 100644 --- a/include/d/actor/d_a_obj_glowSphere.h +++ b/include/d/actor/d_a_obj_glowSphere.h @@ -30,7 +30,6 @@ public: bool isSet() { return mIsSet; } daGlwSph_c* getpSph() { return mpSph; } -private: /* 0x0 */ daGlwSph_c* mpSph; /* 0x4 */ s8 mIsSet; }; @@ -68,8 +67,8 @@ public: _clrLstBuf(); } - static u16 mSphSe; - static s16 mSeClrTmr; + static DUSK_GAME_DATA u16 mSphSe; + static DUSK_GAME_DATA s16 mSeClrTmr; /* 0x0 */ int field_0x0; /* 0x4 */ _GlSph_LstInfo_c mListBuf[120]; @@ -135,9 +134,9 @@ public: saveGetFlag(); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcSph mCcDSph; - static _GlSph_Mng_c mSphMng; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA _GlSph_Mng_c mSphMng; /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_goGate.h b/include/d/actor/d_a_obj_goGate.h index a0a66c7f32..8ed98a43e6 100644 --- a/include/d/actor/d_a_obj_goGate.h +++ b/include/d/actor/d_a_obj_goGate.h @@ -40,7 +40,6 @@ public: u32 getLR() { return fopAcM_GetParamBit(this, 8, 8); } u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_gomikabe.h b/include/d/actor/d_a_obj_gomikabe.h index 441fff371f..a0a01c4e20 100644 --- a/include/d/actor/d_a_obj_gomikabe.h +++ b/include/d/actor/d_a_obj_gomikabe.h @@ -41,7 +41,6 @@ public: int Draw(); int Delete(); -private: /* 0x05A0 */ u8 mSwBit; /* 0x05A1 */ u8 mAction; /* 0x05A2 */ u8 field_0x5a2; diff --git a/include/d/actor/d_a_obj_gpTaru.h b/include/d/actor/d_a_obj_gpTaru.h index 79ed31b3ae..1ab93b2586 100644 --- a/include/d/actor/d_a_obj_gpTaru.h +++ b/include/d/actor/d_a_obj_gpTaru.h @@ -43,10 +43,9 @@ public: virtual int Draw(); virtual int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; /* 0x578 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_gra2.h b/include/d/actor/d_a_obj_gra2.h index 59fd35343b..4add220bcd 100644 --- a/include/d/actor/d_a_obj_gra2.h +++ b/include/d/actor/d_a_obj_gra2.h @@ -234,8 +234,8 @@ public: void setCrazyThrowLeft() { field_0xa48 |= (u16)8; } void setCrazyThrowRight() { field_0xa48 |= (u16)0x10; } - static MotionFunc mBaseMotionList[22]; - static MotionFunc mFaceMotionList[14]; + static DUSK_GAME_DATA MotionFunc mBaseMotionList[22]; + static DUSK_GAME_DATA MotionFunc mFaceMotionList[14]; bool isFirstGra() { return isFisrtGra(); } bool isFisrtGra() { return field_0x1fe8 == 0; } @@ -243,7 +243,6 @@ public: void setDemoMode(s16 mDemoMode) { mDemoCamMode = mDemoMode; } s16 getDemoMode() { return mDemoCamMode; } -private: /* 0x0A48 */ u16 field_0xa48; /* 0x0A4C */ OBJ_GRA_HIO_CLASS* mpHIO; /* 0x0A50 */ Process field_0xa50; diff --git a/include/d/actor/d_a_obj_graWall.h b/include/d/actor/d_a_obj_graWall.h index ebcd1cdb58..037767547a 100644 --- a/include/d/actor/d_a_obj_graWall.h +++ b/include/d/actor/d_a_obj_graWall.h @@ -20,7 +20,6 @@ public: void col_init(); void col_set(); -private: /* 0x568 */ dCcD_Stts mStts; /* 0x5A4 */ dCcD_Cyl mCyl; /* 0x6E0 */ u8 field_0x6e0; diff --git a/include/d/actor/d_a_obj_gra_rock.h b/include/d/actor/d_a_obj_gra_rock.h index e3cf568871..21ec800563 100644 --- a/include/d/actor/d_a_obj_gra_rock.h +++ b/include/d/actor/d_a_obj_gra_rock.h @@ -31,9 +31,8 @@ public: int Draw(); int Delete(); - static dCcD_SrcCyl const mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcCyl const mCcDCyl; -private: /* 0x5A0 */ request_of_phase_process_class mPhases[5]; /* 0x5C8 */ J3DModel* mModel; /* 0x5CC */ mDoExt_btpAnm mBtp; diff --git a/include/d/actor/d_a_obj_grave_stone.h b/include/d/actor/d_a_obj_grave_stone.h index dee38757a3..9155a2f54c 100644 --- a/include/d/actor/d_a_obj_grave_stone.h +++ b/include/d/actor/d_a_obj_grave_stone.h @@ -36,7 +36,6 @@ public: int Draw(); int Delete(); -private: friend class daNpc_zrZ_c; /* 0x5A0 */ request_of_phase_process_class mPhase; @@ -49,8 +48,8 @@ private: /* 0x978 */ daObj_GrvStn_prtclMngr_c mPrtclMngr[4]; /* 0xAE8 */ s16 mTimer; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl const mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl const mCcDCyl; }; STATIC_ASSERT(sizeof(daGraveStone_c) == 0xAEC); diff --git a/include/d/actor/d_a_obj_groundwater.h b/include/d/actor/d_a_obj_groundwater.h index 5e9061d89c..1fc0f0ef37 100644 --- a/include/d/actor/d_a_obj_groundwater.h +++ b/include/d/actor/d_a_obj_groundwater.h @@ -47,7 +47,6 @@ public: u8 getSw() { return fopAcM_GetParamBit(this, 8, 8); } u8 getSw2() { return fopAcM_GetParamBit(this, 16, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_obj_grz_rock.h b/include/d/actor/d_a_obj_grz_rock.h index cd65d2e906..4c8f382071 100644 --- a/include/d/actor/d_a_obj_grz_rock.h +++ b/include/d/actor/d_a_obj_grz_rock.h @@ -28,7 +28,6 @@ public: void setSmashFlag(u8 i_smashFlag) { mSmashFlag = i_smashFlag; } -private: /* 0x568 */ request_of_phase_process_class mPhase[1]; /* 0x5A0 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mBgc; diff --git a/include/d/actor/d_a_obj_hakai_brl.h b/include/d/actor/d_a_obj_hakai_brl.h index 394cab0366..9bd109da7c 100644 --- a/include/d/actor/d_a_obj_hakai_brl.h +++ b/include/d/actor/d_a_obj_hakai_brl.h @@ -32,9 +32,8 @@ public: } void callEmt(); - static dCcD_SrcCyl const s_CcDCyl; + static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ dCcD_Stts mStts; /* 0x5B4 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_obj_hakai_ftr.h b/include/d/actor/d_a_obj_hakai_ftr.h index cc94ba6021..ac7f749860 100644 --- a/include/d/actor/d_a_obj_hakai_ftr.h +++ b/include/d/actor/d_a_obj_hakai_ftr.h @@ -29,9 +29,8 @@ public: bool chkHit(); void callEmt(); - static dCcD_SrcCyl const s_CcDCyl; + static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; -private: /* 0x574 */ Mtx mMtx; /* 0x5A4 */ dBgW* field_0x5a4; /* 0x5A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_hasu2.h b/include/d/actor/d_a_obj_hasu2.h index 9c36c0d180..203b4ff159 100644 --- a/include/d/actor/d_a_obj_hasu2.h +++ b/include/d/actor/d_a_obj_hasu2.h @@ -29,7 +29,6 @@ public: virtual ~daObjMHasu_c() {}; void setRideFlag(bool i_ride) { mRideFlag = i_ride; } -private: /* 0x5A8 */ Mtx mMtx; /* 0x5D8 */ Mtx mMtx2; /* 0x608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_hbombkoya.h b/include/d/actor/d_a_obj_hbombkoya.h index 9f9c0a5149..b1d76f819b 100644 --- a/include/d/actor/d_a_obj_hbombkoya.h +++ b/include/d/actor/d_a_obj_hbombkoya.h @@ -39,7 +39,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } int getSw2No() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A8 */ // dEvLib_callback_c /* 0x5B8 */ Mtx mBgMtx; /* 0x5E8 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_hfuta.h b/include/d/actor/d_a_obj_hfuta.h index 77015715d0..4f4ee44eeb 100644 --- a/include/d/actor/d_a_obj_hfuta.h +++ b/include/d/actor/d_a_obj_hfuta.h @@ -37,7 +37,6 @@ public: void setMode(u8 mode) { mMode = mode; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ cXyz mTransM; diff --git a/include/d/actor/d_a_obj_hsTarget.h b/include/d/actor/d_a_obj_hsTarget.h index 1e0e775e12..50a497eb8e 100644 --- a/include/d/actor/d_a_obj_hsTarget.h +++ b/include/d/actor/d_a_obj_hsTarget.h @@ -23,7 +23,6 @@ public: u8 getModelType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mIndex; diff --git a/include/d/actor/d_a_obj_iceleaf.h b/include/d/actor/d_a_obj_iceleaf.h index da79be5bc5..42ad6237e7 100644 --- a/include/d/actor/d_a_obj_iceleaf.h +++ b/include/d/actor/d_a_obj_iceleaf.h @@ -61,7 +61,6 @@ public: u8 checkRideStatus() { return fopAcM_GetParamBit(this, 0x10, 8); } u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_itamato.h b/include/d/actor/d_a_obj_itamato.h index 0aece512cd..b9080f7db7 100644 --- a/include/d/actor/d_a_obj_itamato.h +++ b/include/d/actor/d_a_obj_itamato.h @@ -27,7 +27,7 @@ class daObj_ItaMato_Param_c { public: virtual ~daObj_ItaMato_Param_c() {} - static daObj_ItaMato_HIOParam const m; + static DUSK_GAME_DATA daObj_ItaMato_HIOParam const m; }; #if DEBUG @@ -46,7 +46,7 @@ public: #endif class daObj_ItaMato_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_ITAMATO_HIO_CLASS* mHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModels[2]; diff --git a/include/d/actor/d_a_obj_kabuto.h b/include/d/actor/d_a_obj_kabuto.h index 9738147885..2b9d6255ee 100644 --- a/include/d/actor/d_a_obj_kabuto.h +++ b/include/d/actor/d_a_obj_kabuto.h @@ -47,7 +47,6 @@ public: cPhs_Step create(); inline int Draw(); -private: /* 0x590 */ dCcD_Stts mCcStts; /* 0x5CC */ dCcD_Sph mCcSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kag.h b/include/d/actor/d_a_obj_kag.h index 58692d7a8c..09c9a088a0 100644 --- a/include/d/actor/d_a_obj_kag.h +++ b/include/d/actor/d_a_obj_kag.h @@ -39,7 +39,6 @@ public: void kag_setParticle(); inline int CreateHeap(); inline int draw(); -private: /* 0x590 */ request_of_phase_process_class mPhase; /* 0x598 */ Z2Creature mSound; /* 0x628 */ mDoExt_McaMorfSO* mpModelMorf; diff --git a/include/d/actor/d_a_obj_kago.h b/include/d/actor/d_a_obj_kago.h index c2ea85d8f2..4a6ed74730 100644 --- a/include/d/actor/d_a_obj_kago.h +++ b/include/d/actor/d_a_obj_kago.h @@ -24,7 +24,7 @@ class daObj_Kago_Param_c { public: virtual ~daObj_Kago_Param_c() {} - static const daObj_Kago_HIOParam m; + static DUSK_GAME_DATA const daObj_Kago_HIOParam m; }; #if DEBUG @@ -125,7 +125,6 @@ public: field_0xb68 = 0.0f; } -private: /* 0x568 */ OBJ_KAGO_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* field_0x574; diff --git a/include/d/actor/d_a_obj_kaisou.h b/include/d/actor/d_a_obj_kaisou.h index 3398c24884..36d6f568df 100644 --- a/include/d/actor/d_a_obj_kaisou.h +++ b/include/d/actor/d_a_obj_kaisou.h @@ -28,7 +28,6 @@ public: inline int CreateHeap(); inline int Draw(); -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 field_0x56a[0x56e - 0x56a]; diff --git a/include/d/actor/d_a_obj_kamakiri.h b/include/d/actor/d_a_obj_kamakiri.h index 3b2d56e533..52b648ea48 100644 --- a/include/d/actor/d_a_obj_kamakiri.h +++ b/include/d/actor/d_a_obj_kamakiri.h @@ -56,7 +56,6 @@ public: u8 CreateChk(); int create(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSphere; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kantera.h b/include/d/actor/d_a_obj_kantera.h index 0228b51fd5..fbe230ed16 100644 --- a/include/d/actor/d_a_obj_kantera.h +++ b/include/d/actor/d_a_obj_kantera.h @@ -33,7 +33,6 @@ public: void setStatus(u8 i_status) { mStatus = i_status; } -private: /* 0x92C */ u32 field_0x92c; /* 0x930 */ s32 field_0x930; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_katatsumuri.h b/include/d/actor/d_a_obj_katatsumuri.h index e481d3eb3a..93b9368fb5 100644 --- a/include/d/actor/d_a_obj_katatsumuri.h +++ b/include/d/actor/d_a_obj_katatsumuri.h @@ -55,7 +55,6 @@ public: bool CreateChk(); int create(); -private: /* 0x590 */ dBgS_ObjAcch mAcch; /* 0x768 */ dBgS_GndChk mGndChk; /* 0x7BC */ u8 field_0x7bc[0x7c0 - 0x7bc]; diff --git a/include/d/actor/d_a_obj_kazeneko.h b/include/d/actor/d_a_obj_kazeneko.h index 3ac12b40f3..164612ecfc 100644 --- a/include/d/actor/d_a_obj_kazeneko.h +++ b/include/d/actor/d_a_obj_kazeneko.h @@ -45,8 +45,7 @@ public: const KazoNekoAttr& attr() { return M_attr; } - static KazoNekoAttr const M_attr; -private: + static DUSK_GAME_DATA KazoNekoAttr const M_attr; /* 0x568 */ J3DModel* mModel; /* 0x56C */ J3DModel* mArmModels[4]; /* 0x57C */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_kbacket.h b/include/d/actor/d_a_obj_kbacket.h index f3855fc8ca..214c4dcc7c 100644 --- a/include/d/actor/d_a_obj_kbacket.h +++ b/include/d/actor/d_a_obj_kbacket.h @@ -25,7 +25,7 @@ class daObj_KBacket_Param_c { public: virtual ~daObj_KBacket_Param_c() {} - static const daObj_KBacket_HIOParam m; + static DUSK_GAME_DATA const daObj_KBacket_HIOParam m; }; #if DEBUG diff --git a/include/d/actor/d_a_obj_keyhole.h b/include/d/actor/d_a_obj_keyhole.h index b8a813776d..fd39641ad8 100644 --- a/include/d/actor/d_a_obj_keyhole.h +++ b/include/d/actor/d_a_obj_keyhole.h @@ -66,18 +66,9 @@ public: /* 0x2CA7 */ s8 hide_lock; /* 0x2CA8 */ cXyz field_0x2ca8; /* 0x2CB4 */ u8 field_0x2cb4; - -#if TARGET_PC - Mtx mChainInterpPrev[6][16]; - Mtx mChainInterpCurr[6][16]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif }; -#if !TARGET_PC STATIC_ASSERT(sizeof(obj_keyhole_class) == 0x2CB8); -#endif class daObj_Keyhole_HIO_c : public JORReflexible { public: diff --git a/include/d/actor/d_a_obj_kgate.h b/include/d/actor/d_a_obj_kgate.h index 96798028b2..f7fe72767c 100644 --- a/include/d/actor/d_a_obj_kgate.h +++ b/include/d/actor/d_a_obj_kgate.h @@ -46,7 +46,6 @@ public: u8 getEventID() { return fopAcM_GetParamBit(this, 0x14, 8); } u8 getNameArg() { return fopAcM_GetParamBit(this, 0x10, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpGateModel; /* 0x5AC */ J3DModel* mpGateModel2; diff --git a/include/d/actor/d_a_obj_kiPot.h b/include/d/actor/d_a_obj_kiPot.h index 01d7cf76c0..248daa2d46 100644 --- a/include/d/actor/d_a_obj_kiPot.h +++ b/include/d/actor/d_a_obj_kiPot.h @@ -23,7 +23,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ u8 mMode; /* 0x575 */ u8 field_0x575; diff --git a/include/d/actor/d_a_obj_kita.h b/include/d/actor/d_a_obj_kita.h index 1e343c78ce..09eff51298 100644 --- a/include/d/actor/d_a_obj_kita.h +++ b/include/d/actor/d_a_obj_kita.h @@ -17,7 +17,6 @@ public: STATIC_ASSERT(sizeof(kita_s) == 0x60); - /** * @ingroup actors-objects * @class obj_kita_class diff --git a/include/d/actor/d_a_obj_kjgjs.h b/include/d/actor/d_a_obj_kjgjs.h index 495750bd89..189c672c7d 100644 --- a/include/d/actor/d_a_obj_kjgjs.h +++ b/include/d/actor/d_a_obj_kjgjs.h @@ -25,7 +25,6 @@ public: u32 getType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A8 */ Mtx mMtx[2]; /* 0x608 */ J3DModel* mpModel; /* 0x60C */ s32 field_0x60c; diff --git a/include/d/actor/d_a_obj_klift00.h b/include/d/actor/d_a_obj_klift00.h index ab5403d51b..a41c5c7b5c 100644 --- a/include/d/actor/d_a_obj_klift00.h +++ b/include/d/actor/d_a_obj_klift00.h @@ -26,14 +26,13 @@ public: int Delete(); #if TARGET_PC - void onInterpCallback(); + void onInterpPresentation(); #endif enum Param_e { LOCK_e = (1 << 6), NO_BASE_DISP = (1 << 7) }; -private: struct ChainPos { cXyz mDeltaPosVector; cXyz mCurrentPos; @@ -54,13 +53,6 @@ private: /* 0x1020 */ dCcD_Cyl mCylinderCollider; /* 0x115C */ s32 mStopSwingingFrames; -#if TARGET_PC - cXyz mChainInterpPrev[64]; - cXyz mChainInterpCurr[64]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif - // Number of chain models u32 getArg0() { return fopAcM_GetParamBit(this, 0, 6); diff --git a/include/d/actor/d_a_obj_knBullet.h b/include/d/actor/d_a_obj_knBullet.h index e8056fbb25..fa2d5397a2 100644 --- a/include/d/actor/d_a_obj_knBullet.h +++ b/include/d/actor/d_a_obj_knBullet.h @@ -26,7 +26,6 @@ public: u8 getActionMode() { return mActionMode; } void setActionMode(u8 i_action) { mActionMode = i_action; } -private: /* 0x568 */ Mtx mMtx; /* 0x598 */ dCcD_Stts mCcStts; /* 0x5D4 */ dCcD_Sph mCcSph; diff --git a/include/d/actor/d_a_obj_kshutter.h b/include/d/actor/d_a_obj_kshutter.h index b217adef2d..a0a2204c0d 100644 --- a/include/d/actor/d_a_obj_kshutter.h +++ b/include/d/actor/d_a_obj_kshutter.h @@ -64,7 +64,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 8, 8); } u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase1; /* 0x5A8 */ request_of_phase_process_class mPhase2; /* 0x5B0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_ktOnFire.h b/include/d/actor/d_a_obj_ktOnFire.h index bd0e23a82d..7d292bf286 100644 --- a/include/d/actor/d_a_obj_ktOnFire.h +++ b/include/d/actor/d_a_obj_ktOnFire.h @@ -23,10 +23,9 @@ public: int Draw(); int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ dCcD_Stts mCcStts; /* 0x5A4 */ dCcD_Cyl mCcCyl; /* 0x6E0 */ u8 mWaitTime; diff --git a/include/d/actor/d_a_obj_kuwagata.h b/include/d/actor/d_a_obj_kuwagata.h index 9df3f0bc35..a14b0544bc 100644 --- a/include/d/actor/d_a_obj_kuwagata.h +++ b/include/d/actor/d_a_obj_kuwagata.h @@ -47,7 +47,6 @@ public: int create(); inline int Draw(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kwheel00.h b/include/d/actor/d_a_obj_kwheel00.h index ceaf132fd6..2d58cb32f1 100644 --- a/include/d/actor/d_a_obj_kwheel00.h +++ b/include/d/actor/d_a_obj_kwheel00.h @@ -41,7 +41,6 @@ public: enum Type_e { TYPE_LARGE_GOLD, TYPE_SMALL_PLATINUM }; -private: enum QuadrantalAngle_e { DEG_INVALID = -1, DEG_0, DEG_90, DEG_180, DEG_270, DEG_MAX}; /* 0x5B8 */ Mtx mNewBgMtx; diff --git a/include/d/actor/d_a_obj_kwheel01.h b/include/d/actor/d_a_obj_kwheel01.h index 40bc025db4..9c6fa31075 100644 --- a/include/d/actor/d_a_obj_kwheel01.h +++ b/include/d/actor/d_a_obj_kwheel01.h @@ -27,7 +27,6 @@ public: int Delete(); bool eventStart(); -private: /* 0x5B8 */ Mtx mNewBgMtx; /* 0x5E8 */ Mtx mTransformMtx; /* 0x618 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_kznkarm.h b/include/d/actor/d_a_obj_kznkarm.h index 343285f8f8..3838d1f9ff 100644 --- a/include/d/actor/d_a_obj_kznkarm.h +++ b/include/d/actor/d_a_obj_kznkarm.h @@ -60,10 +60,9 @@ public: inline ~daObjKznkarm_c(); inline daObjKznkarm_Attr_c* attr() const; - static daObjKznkarm_Attr_c const M_attr; - static actionFunc ActionTable[4][2]; + static DUSK_GAME_DATA daObjKznkarm_Attr_c const M_attr; + static DUSK_GAME_DATA actionFunc ActionTable[4][2]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ dBgS_AcchCir mAcchCir; diff --git a/include/d/actor/d_a_obj_ladder.h b/include/d/actor/d_a_obj_ladder.h index eb48cf0f16..b46bf99603 100644 --- a/include/d/actor/d_a_obj_ladder.h +++ b/include/d/actor/d_a_obj_ladder.h @@ -74,9 +74,8 @@ namespace daObjLadder { return(Type_e)daObj::PrmAbstract(this,PRM_3, PRM_0); } - static char const M_arcname[5]; - static Mtx M_tmp_mtx; -private: + static DUSK_GAME_DATA char const M_arcname[5]; + static DUSK_GAME_DATA Mtx M_tmp_mtx; /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ Type_e mType; diff --git a/include/d/actor/d_a_obj_laundry.h b/include/d/actor/d_a_obj_laundry.h index 7d50dfa28e..3dd76c6a39 100644 --- a/include/d/actor/d_a_obj_laundry.h +++ b/include/d/actor/d_a_obj_laundry.h @@ -56,8 +56,7 @@ public: inline int daObjLdy_Draw(); inline int daObjLdy_Execute(); -private: - static const daObjLdy_Attr_c mAttr; + static DUSK_GAME_DATA const daObjLdy_Attr_c mAttr; /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_btkAnm* mpBtkAnm; diff --git a/include/d/actor/d_a_obj_laundry_rope.h b/include/d/actor/d_a_obj_laundry_rope.h index 4dba2250dc..85d76cbe8d 100644 --- a/include/d/actor/d_a_obj_laundry_rope.h +++ b/include/d/actor/d_a_obj_laundry_rope.h @@ -55,10 +55,9 @@ public: }; #endif - static const daObjLndRope_Attr_c mAttr; + static DUSK_GAME_DATA const daObjLndRope_Attr_c mAttr; static const daObjLndRope_Hio_c M_Hio; -private: /* 0x0568 */ mDoExt_3DlineMat1_c mRopeMat; /* 0x05a4 */ request_of_phase_process_class mPhase; /* 0x05ac */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_life_container.h b/include/d/actor/d_a_obj_life_container.h index 14187d8289..a7b209cb94 100644 --- a/include/d/actor/d_a_obj_life_container.h +++ b/include/d/actor/d_a_obj_life_container.h @@ -64,7 +64,6 @@ public: current.pos = new_pos; } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int mCounter; /* 0x934 */ u8 mStatus; @@ -88,6 +87,12 @@ private: /* 0x99C */ dPa_followEcallBack mEffect2; /* 0x9B0 */ Z2SoundObjSimple mSound; /* 0x9D0 */ u8 mIsHookCarry; +#if TARGET_PC + u8 mOriginalItemNo; + bool mItemOverridden; + bool mOverrideHover; + bool mGoldenWolfItem; +#endif }; STATIC_ASSERT(sizeof(daObjLife_c) == 0x9d4); diff --git a/include/d/actor/d_a_obj_lv1Candle00.h b/include/d/actor/d_a_obj_lv1Candle00.h index 48fca4acb6..c70d484930 100644 --- a/include/d/actor/d_a_obj_lv1Candle00.h +++ b/include/d/actor/d_a_obj_lv1Candle00.h @@ -30,7 +30,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; @@ -46,8 +45,8 @@ private: /* 0x730 */ u8 mTgHit; /* 0x734 */ Z2SoundObjSimple mSound; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daLv1Cdl00_c) == 0x754); diff --git a/include/d/actor/d_a_obj_lv1Candle01.h b/include/d/actor/d_a_obj_lv1Candle01.h index 66524cc4dc..1f1dbe4ee4 100644 --- a/include/d/actor/d_a_obj_lv1Candle01.h +++ b/include/d/actor/d_a_obj_lv1Candle01.h @@ -27,7 +27,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mStts; @@ -42,8 +41,8 @@ private: /* 0x768 */ u8 mTgHit; /* 0x76C */ Z2SoundObjSimple mSound; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daLv1Cdl01_c) == 0x78C); diff --git a/include/d/actor/d_a_obj_lv2Candle.h b/include/d/actor/d_a_obj_lv2Candle.h index 767480d550..424dd844fd 100644 --- a/include/d/actor/d_a_obj_lv2Candle.h +++ b/include/d/actor/d_a_obj_lv2Candle.h @@ -37,7 +37,6 @@ public: u8 getSwType() { return fopAcM_GetParamBit(this, 8, 4); } u8 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; @@ -60,8 +59,8 @@ private: /* 0x738 */ u8 mTgHit; /* 0x73C */ Z2SoundObjSimple mSound; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daLv2Candle_c) == 0x75C); diff --git a/include/d/actor/d_a_obj_lv3Candle.h b/include/d/actor/d_a_obj_lv3Candle.h index b82ad0b8c4..76edaaac77 100644 --- a/include/d/actor/d_a_obj_lv3Candle.h +++ b/include/d/actor/d_a_obj_lv3Candle.h @@ -29,7 +29,6 @@ public: int getSwBit() { return fopAcM_GetParamBit(this, 0, 8); } int getType() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u8 mType; @@ -44,8 +43,8 @@ private: /* 0x730 */ u8 mTgHit; /* 0x734 */ Z2SoundObjSimple mSound; - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; }; // Size: 0x754 diff --git a/include/d/actor/d_a_obj_lv3Water.h b/include/d/actor/d_a_obj_lv3Water.h index de4ff03356..82f5be1661 100644 --- a/include/d/actor/d_a_obj_lv3Water.h +++ b/include/d/actor/d_a_obj_lv3Water.h @@ -45,7 +45,6 @@ public: int getParamType() { return (shape_angle.x & 0xFF00) >> 8; } u8 getType() { return mType; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel1; /* 0x5C4 */ J3DModel* mpModel2; diff --git a/include/d/actor/d_a_obj_lv3Water2.h b/include/d/actor/d_a_obj_lv3Water2.h index be13ef4819..4227e8bcb0 100644 --- a/include/d/actor/d_a_obj_lv3Water2.h +++ b/include/d/actor/d_a_obj_lv3Water2.h @@ -29,7 +29,6 @@ public: int Delete(); bool eventStart(); -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ mDoExt_btkAnm mRefractionAnm; // Applied to water surface diff --git a/include/d/actor/d_a_obj_lv3saka00.h b/include/d/actor/d_a_obj_lv3saka00.h index f08f4a5d19..5207e74de8 100644 --- a/include/d/actor/d_a_obj_lv3saka00.h +++ b/include/d/actor/d_a_obj_lv3saka00.h @@ -28,7 +28,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } u8 getType() { return fopAcM_GetParamBit(this, 28, 4) & 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ dBgW* mpBgW2; }; diff --git a/include/d/actor/d_a_obj_lv3waterEff.h b/include/d/actor/d_a_obj_lv3waterEff.h index fdf7b204dc..a612168fac 100644 --- a/include/d/actor/d_a_obj_lv3waterEff.h +++ b/include/d/actor/d_a_obj_lv3waterEff.h @@ -18,7 +18,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ cXyz mSePositions[2]; /* 0x580 */ JPABaseEmitter* mParticles[4]; /* 0x590 */ u8 unused_0x590[0x594 - 0x590]; diff --git a/include/d/actor/d_a_obj_lv4CandleDemoTag.h b/include/d/actor/d_a_obj_lv4CandleDemoTag.h index 58378ecd4e..4ac8618776 100644 --- a/include/d/actor/d_a_obj_lv4CandleDemoTag.h +++ b/include/d/actor/d_a_obj_lv4CandleDemoTag.h @@ -43,7 +43,6 @@ public: virtual ~dalv4CandleDemoTag_c() {} virtual bool eventStart(); -private: /* 0x584 */ u8 mMode; /* 0x585 */ u8 mPathID; /* 0x586 */ u8 mSwNG; diff --git a/include/d/actor/d_a_obj_lv4EdShutter.h b/include/d/actor/d_a_obj_lv4EdShutter.h index a19de47873..992431c64d 100644 --- a/include/d/actor/d_a_obj_lv4EdShutter.h +++ b/include/d/actor/d_a_obj_lv4EdShutter.h @@ -45,7 +45,6 @@ public: u8 getZenmetuSw() { return shape_angle.z & 0xFF; } u8 getStatus() { return mStatus; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4HsTarget.h b/include/d/actor/d_a_obj_lv4HsTarget.h index fbb1c8862a..c618aec40e 100644 --- a/include/d/actor/d_a_obj_lv4HsTarget.h +++ b/include/d/actor/d_a_obj_lv4HsTarget.h @@ -23,7 +23,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; }; diff --git a/include/d/actor/d_a_obj_lv4PoGate.h b/include/d/actor/d_a_obj_lv4PoGate.h index 480885fa0a..bd46dd30c4 100644 --- a/include/d/actor/d_a_obj_lv4PoGate.h +++ b/include/d/actor/d_a_obj_lv4PoGate.h @@ -52,7 +52,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4RailWall.h b/include/d/actor/d_a_obj_lv4RailWall.h index 7cffceedc0..39858be708 100644 --- a/include/d/actor/d_a_obj_lv4RailWall.h +++ b/include/d/actor/d_a_obj_lv4RailWall.h @@ -50,7 +50,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ dBgS_ObjAcch field_0x5bc; diff --git a/include/d/actor/d_a_obj_lv4SlideWall.h b/include/d/actor/d_a_obj_lv4SlideWall.h index fcafa19dfc..1e08e68206 100644 --- a/include/d/actor/d_a_obj_lv4SlideWall.h +++ b/include/d/actor/d_a_obj_lv4SlideWall.h @@ -32,7 +32,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4chandelier.h b/include/d/actor/d_a_obj_lv4chandelier.h index d0e7c53515..2b965d5831 100644 --- a/include/d/actor/d_a_obj_lv4chandelier.h +++ b/include/d/actor/d_a_obj_lv4chandelier.h @@ -43,7 +43,6 @@ public: int getAddChain2() { return fopAcM_GetParamBit(this, 12, 4); } int getSw() { return fopAcM_GetParamBit(this, 16, 8); } -private: /* 0x05A8 */ Mtx field_0x5a8; /* 0x05D8 */ Mtx field_0x5d8; /* 0x0608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_lv4floor.h b/include/d/actor/d_a_obj_lv4floor.h index 7b6681419d..704ccece93 100644 --- a/include/d/actor/d_a_obj_lv4floor.h +++ b/include/d/actor/d_a_obj_lv4floor.h @@ -38,7 +38,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ f32 mMoveYPos; diff --git a/include/d/actor/d_a_obj_lv4gear.h b/include/d/actor/d_a_obj_lv4gear.h index 5e649c0722..9c3d4920c1 100644 --- a/include/d/actor/d_a_obj_lv4gear.h +++ b/include/d/actor/d_a_obj_lv4gear.h @@ -31,7 +31,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 8, 4); } u8 checkSE() { return fopAcM_GetParamBit(this, 12, 4); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ s16 mTarget; diff --git a/include/d/actor/d_a_obj_lv4prelvtr.h b/include/d/actor/d_a_obj_lv4prelvtr.h index 2fd50068ac..9e4846671c 100644 --- a/include/d/actor/d_a_obj_lv4prelvtr.h +++ b/include/d/actor/d_a_obj_lv4prelvtr.h @@ -26,7 +26,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A8 */ Mtx mMtx1; /* 0x5D8 */ Mtx mMtx2; /* 0x608 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_lv4sand.h b/include/d/actor/d_a_obj_lv4sand.h index 0ff6420e27..1b6272440b 100644 --- a/include/d/actor/d_a_obj_lv4sand.h +++ b/include/d/actor/d_a_obj_lv4sand.h @@ -46,7 +46,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_lv5FloorBoard.h b/include/d/actor/d_a_obj_lv5FloorBoard.h index f4f5c50582..e8ae0d18b2 100644 --- a/include/d/actor/d_a_obj_lv5FloorBoard.h +++ b/include/d/actor/d_a_obj_lv5FloorBoard.h @@ -35,10 +35,9 @@ public: int getSwBit1() { return fopAcM_GetParamBit(this, 0, 8); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5IceWall.h b/include/d/actor/d_a_obj_lv5IceWall.h index 737aaf9318..e04d413249 100644 --- a/include/d/actor/d_a_obj_lv5IceWall.h +++ b/include/d/actor/d_a_obj_lv5IceWall.h @@ -39,10 +39,9 @@ public: int getScaleY() { return fopAcM_GetParamBit(this, 0x15, 5); } int getScaleZ() { return fopAcM_GetParamBit(this, 0x1A, 5); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl[2]; /* 0x854 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5SwIce.h b/include/d/actor/d_a_obj_lv5SwIce.h index 7c61e04d3b..9e990e3da7 100644 --- a/include/d/actor/d_a_obj_lv5SwIce.h +++ b/include/d/actor/d_a_obj_lv5SwIce.h @@ -35,10 +35,9 @@ public: int getSwBit1() { return fopAcM_GetParamBit(this, 0, 8); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5ychndlr.h b/include/d/actor/d_a_obj_lv5ychndlr.h index 8db78c0afa..dc3a8f1ce2 100644 --- a/include/d/actor/d_a_obj_lv5ychndlr.h +++ b/include/d/actor/d_a_obj_lv5ychndlr.h @@ -26,7 +26,6 @@ public: virtual int Delete(); virtual ~daObjYchndlr_c() {} -private: /* 0x5A8 */ Mtx field_0x5a8; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mpChandlierModel; diff --git a/include/d/actor/d_a_obj_lv6ChangeGate.h b/include/d/actor/d_a_obj_lv6ChangeGate.h index b918037950..48f532da3f 100644 --- a/include/d/actor/d_a_obj_lv6ChangeGate.h +++ b/include/d/actor/d_a_obj_lv6ChangeGate.h @@ -45,8 +45,8 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } int getSw2() { return shape_angle.x & 0xFF; } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; /* 0x05B8 */ request_of_phase_process_class mPhase; /* 0x05C0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_lv6FurikoTrap.h b/include/d/actor/d_a_obj_lv6FurikoTrap.h index b09952df78..5257bc540a 100644 --- a/include/d/actor/d_a_obj_lv6FurikoTrap.h +++ b/include/d/actor/d_a_obj_lv6FurikoTrap.h @@ -25,10 +25,9 @@ public: int Draw(); int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv6Lblock.h b/include/d/actor/d_a_obj_lv6Lblock.h index 0dbe6a330a..80080c702b 100644 --- a/include/d/actor/d_a_obj_lv6Lblock.h +++ b/include/d/actor/d_a_obj_lv6Lblock.h @@ -34,7 +34,6 @@ public: int getUpMax() { return fopAcM_GetParamBit(this, 8, 4); } int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv6SwGate.h b/include/d/actor/d_a_obj_lv6SwGate.h index 964c073c1d..e2844e06ee 100644 --- a/include/d/actor/d_a_obj_lv6SwGate.h +++ b/include/d/actor/d_a_obj_lv6SwGate.h @@ -36,9 +36,8 @@ public: int getSwState() { return fopAcM_GetParamBit(this, 12, 4); } int getSw2() { return fopAcM_GetParamBit(this, 16, 8); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; -private: + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcDCyls[12]; /* 0x14AC */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv6SzGate.h b/include/d/actor/d_a_obj_lv6SzGate.h index 80601341ec..db3ec0ccce 100644 --- a/include/d/actor/d_a_obj_lv6SzGate.h +++ b/include/d/actor/d_a_obj_lv6SzGate.h @@ -45,7 +45,6 @@ public: u32 getWaitTime() { return fopAcM_GetParamBit(this, 8, 8); } u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* field_0x5a8; /* 0x5AC */ J3DModel* field_0x5ac; diff --git a/include/d/actor/d_a_obj_lv6Tenbin.h b/include/d/actor/d_a_obj_lv6Tenbin.h index 6cdd8e3538..429ecb58be 100644 --- a/include/d/actor/d_a_obj_lv6Tenbin.h +++ b/include/d/actor/d_a_obj_lv6Tenbin.h @@ -27,7 +27,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_obj_lv6TogeRoll.h b/include/d/actor/d_a_obj_lv6TogeRoll.h index 6e6357d552..4fc557b8b4 100644 --- a/include/d/actor/d_a_obj_lv6TogeRoll.h +++ b/include/d/actor/d_a_obj_lv6TogeRoll.h @@ -60,13 +60,12 @@ public: u32 getPathID() { return fopAcM_GetParamBit(this, 0, 8); } u32 getSpeed() { return fopAcM_GetParamBit(this, 8, 4); } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcGObjInf const mCcDObjInfo2; - static f32 const mSpeed[]; - static dCcD_SrcSph mCcDSph; - static dCcD_SrcCps mCcDCps; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo2; + static DUSK_GAME_DATA f32 const mSpeed[]; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcCps mCcDCps; -private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ u8 mPathID; diff --git a/include/d/actor/d_a_obj_lv6TogeTrap.h b/include/d/actor/d_a_obj_lv6TogeTrap.h index 29e68aad24..e0f0a2102d 100644 --- a/include/d/actor/d_a_obj_lv6TogeTrap.h +++ b/include/d/actor/d_a_obj_lv6TogeTrap.h @@ -62,11 +62,11 @@ public: int getModelType() { return fopAcM_GetParamBit(this, 20, 4); } int getHankei2() { return fopAcM_GetParamBit(this, 24, 8); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static const dCcD_SrcGObjInf mCcDObjInfo2; - static const f32 mSpeed[16]; - static dCcD_SrcSph mCcDSph; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo2; + static DUSK_GAME_DATA const f32 mSpeed[16]; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_lv6elevta.h b/include/d/actor/d_a_obj_lv6elevta.h index b98ff06f58..192c568552 100644 --- a/include/d/actor/d_a_obj_lv6elevta.h +++ b/include/d/actor/d_a_obj_lv6elevta.h @@ -33,7 +33,6 @@ public: int getSw2No() { return fopAcM_GetParamBit(this, 8, 8); }; int getEvent() { return fopAcM_GetParamBit(this, 0x10, 8); }; -private: /* 0x5B8 */ Mtx mMtx1; /* 0x5E8 */ Mtx mMtx2; /* 0x618 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_lv7bridge.h b/include/d/actor/d_a_obj_lv7bridge.h index 938b87e08f..f53b24e708 100644 --- a/include/d/actor/d_a_obj_lv7bridge.h +++ b/include/d/actor/d_a_obj_lv7bridge.h @@ -45,7 +45,6 @@ public: void setDestroyAnmA() { field_0xa94 = 0; } void setDestroyAnmB() { field_0xa94 = 1; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_lv8KekkaiTrap.h b/include/d/actor/d_a_obj_lv8KekkaiTrap.h index aa68df0114..423e59a500 100644 --- a/include/d/actor/d_a_obj_lv8KekkaiTrap.h +++ b/include/d/actor/d_a_obj_lv8KekkaiTrap.h @@ -32,7 +32,6 @@ public: int getType() { return fopAcM_GetParamBit(this, 0, 4); } int getSwBit() { return fopAcM_GetParamBit(this, 4, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mIsSwitch; diff --git a/include/d/actor/d_a_obj_lv8Lift.h b/include/d/actor/d_a_obj_lv8Lift.h index c327f4cf3c..4f243d0906 100644 --- a/include/d/actor/d_a_obj_lv8Lift.h +++ b/include/d/actor/d_a_obj_lv8Lift.h @@ -59,16 +59,15 @@ public: int Draw(); int Delete(); #if TARGET_PC - friend void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork); + friend void daL8Lift_interp_callback(void* pUserWork); #endif u8 getPthID() { return fopAcM_GetParamBit(this, 0, 8); } u8 getMoveSpeed() { return fopAcM_GetParamBit(this, 8, 4); } int getSw() { return fopAcM_GetParamBit(this, 12, 8); } - static f32 const mSpeed[16]; + static DUSK_GAME_DATA f32 const mSpeed[16]; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_lv8OptiLift.h b/include/d/actor/d_a_obj_lv8OptiLift.h index 5a437079c7..cd33551685 100644 --- a/include/d/actor/d_a_obj_lv8OptiLift.h +++ b/include/d/actor/d_a_obj_lv8OptiLift.h @@ -62,7 +62,7 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } int getArg1() { return fopAcM_GetParamBit(this, 0x14, 4); } - static f32 const mSpeed[]; + static DUSK_GAME_DATA f32 const mSpeed[]; /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_lv9SwShutter.h b/include/d/actor/d_a_obj_lv9SwShutter.h index 06607f5c1c..44e0eef556 100644 --- a/include/d/actor/d_a_obj_lv9SwShutter.h +++ b/include/d/actor/d_a_obj_lv9SwShutter.h @@ -31,7 +31,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_magLift.h b/include/d/actor/d_a_obj_magLift.h index e9b4e8bcf3..7c15edb05e 100644 --- a/include/d/actor/d_a_obj_magLift.h +++ b/include/d/actor/d_a_obj_magLift.h @@ -47,9 +47,8 @@ public: int getMoveSpeed() { return fopAcM_GetParamBit(this, 0x8, 4); } - static f32 const mSpeed[16]; + static DUSK_GAME_DATA f32 const mSpeed[16]; -private: /* 0x5a0 */ request_of_phase_process_class mPhaseReq; /* 0x5a8 */ J3DModel* mpModel; /* 0x5ac */ u8 field_0x5ac [0x5ae - 0x5ac]; diff --git a/include/d/actor/d_a_obj_magLiftRot.h b/include/d/actor/d_a_obj_magLiftRot.h index 647fcee80a..04621f7ddc 100644 --- a/include/d/actor/d_a_obj_magLiftRot.h +++ b/include/d/actor/d_a_obj_magLiftRot.h @@ -29,7 +29,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_master_sword.h b/include/d/actor/d_a_obj_master_sword.h index e99b8832d7..e462e61481 100644 --- a/include/d/actor/d_a_obj_master_sword.h +++ b/include/d/actor/d_a_obj_master_sword.h @@ -48,10 +48,9 @@ public: u8 getEventID() { return (fopAcM_GetParam(this) >> 0x10) & 0xFF; } u16 getFlagNo() { return fopAcM_GetParam(this) & 0xFFFF; } - static daObjMasterSword_Attr_c const mAttr; - static actionFunc ActionTable[]; + static DUSK_GAME_DATA daObjMasterSword_Attr_c const mAttr; + static DUSK_GAME_DATA actionFunc ActionTable[]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_metalbox.h b/include/d/actor/d_a_obj_metalbox.h index b7f2fb10cd..10c6462547 100644 --- a/include/d/actor/d_a_obj_metalbox.h +++ b/include/d/actor/d_a_obj_metalbox.h @@ -15,7 +15,7 @@ * */ class daObjMBox_c : public dBgS_MoveBgActor { -private: +public: /* 0x5a0 */ request_of_phase_process_class mPhase; /* 0x5a8 */ J3DModel* mpModel; /* 0x5ac */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_mgate.h b/include/d/actor/d_a_obj_mgate.h index 5b86c8aa17..9dc0d63114 100644 --- a/include/d/actor/d_a_obj_mgate.h +++ b/include/d/actor/d_a_obj_mgate.h @@ -39,7 +39,6 @@ public: bool checkLock() { return fopAcM_GetParamBit(this, 5, 1); } u8 checkOpen() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ request_of_phase_process_class mKeyPhase; /* 0x5B0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_mhole.h b/include/d/actor/d_a_obj_mhole.h index aa692338d2..c9818708fd 100644 --- a/include/d/actor/d_a_obj_mhole.h +++ b/include/d/actor/d_a_obj_mhole.h @@ -36,7 +36,6 @@ public: u8 getKind() { return fopAcM_GetParamBit(this, 12, 4); } u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_brkAnm* mpBrkAnm; diff --git a/include/d/actor/d_a_obj_mie.h b/include/d/actor/d_a_obj_mie.h index 0f1df429be..faa413e204 100644 --- a/include/d/actor/d_a_obj_mie.h +++ b/include/d/actor/d_a_obj_mie.h @@ -24,7 +24,7 @@ class daObj_Mie_Param_c { public: virtual ~daObj_Mie_Param_c() {} - static const daObj_Mie_HIOParam m; + static DUSK_GAME_DATA const daObj_Mie_HIOParam m; }; #if DEBUG @@ -54,7 +54,7 @@ public: * */ class daObj_Mie_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_MIE_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_mirror_6pole.h b/include/d/actor/d_a_obj_mirror_6pole.h index 702b1cb66b..1a53d23399 100644 --- a/include/d/actor/d_a_obj_mirror_6pole.h +++ b/include/d/actor/d_a_obj_mirror_6pole.h @@ -54,9 +54,8 @@ public: inline void callInit(); inline void callExecute(); - static const actionFunc ActionTable[][2]; + static DUSK_GAME_DATA const actionFunc ActionTable[][2]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm* mpBck; /* 0x570 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_mirror_chain.h b/include/d/actor/d_a_obj_mirror_chain.h index 106272f116..e04ab228d5 100644 --- a/include/d/actor/d_a_obj_mirror_chain.h +++ b/include/d/actor/d_a_obj_mirror_chain.h @@ -47,7 +47,6 @@ public: u8 getSwitchNo() { return (fopAcM_GetParam(this) >> 8) & 0xff; } void setAnmSpeed(f32 speed) { mpBckAnm->setPlaySpeed(speed); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ J3DModel* mpPortalModel; /* 0x570 */ mDoExt_bckAnm* mpBckAnm; diff --git a/include/d/actor/d_a_obj_mirror_sand.h b/include/d/actor/d_a_obj_mirror_sand.h index db27ccfaeb..ea7a8a6f30 100644 --- a/include/d/actor/d_a_obj_mirror_sand.h +++ b/include/d/actor/d_a_obj_mirror_sand.h @@ -37,7 +37,6 @@ public: dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[354]); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm* mpBck; /* 0x570 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_mirror_screw.h b/include/d/actor/d_a_obj_mirror_screw.h index feeb6bf294..7cdf294f9b 100644 --- a/include/d/actor/d_a_obj_mirror_screw.h +++ b/include/d/actor/d_a_obj_mirror_screw.h @@ -65,7 +65,6 @@ public: (this->*mpActionFunc[1])(); } -private: /* 0x5A0 */ J3DModel* mpModel; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ daObjMirrorScrew_actionFunc* mpActionFunc; @@ -80,8 +79,8 @@ private: /* 0x5D0 */ u8 field_0x5d0[8]; /* 0x5D8 */ cBgS_PolyInfo field_0x5d8; - static attr const M_attr; - static daObjMirrorScrew_actionFunc ActionTable[2][2]; + static DUSK_GAME_DATA attr const M_attr; + static DUSK_GAME_DATA daObjMirrorScrew_actionFunc ActionTable[2][2]; }; STATIC_ASSERT(sizeof(daObjMirrorScrew_c) == 0x5E8); diff --git a/include/d/actor/d_a_obj_movebox.h b/include/d/actor/d_a_obj_movebox.h index 0e8bf4e87a..4007a46ecc 100644 --- a/include/d/actor/d_a_obj_movebox.h +++ b/include/d/actor/d_a_obj_movebox.h @@ -122,12 +122,12 @@ struct Bgc_c { bool chk_wall_touch(daObjMovebox::Act_c const*, daObjMovebox::BgcSrc_c const*, s16); bool chk_wall_touch2(daObjMovebox::Act_c const*, daObjMovebox::BgcSrc_c const*, int, s16); - static const daObjMovebox::BgcSrc_c M_lin5[]; - static const daObjMovebox::BgcSrc_c M_lin20[]; + static DUSK_GAME_DATA const daObjMovebox::BgcSrc_c M_lin5[]; + static DUSK_GAME_DATA const daObjMovebox::BgcSrc_c M_lin20[]; - static dBgS_ObjGndChk M_gnd_work[23]; - static dBgS_WtrChk M_wrt_work; - static dBgS_ObjLinChk M_wall_work[23]; + static DUSK_GAME_DATA dBgS_ObjGndChk M_gnd_work[23]; + static DUSK_GAME_DATA dBgS_WtrChk M_wrt_work; + static DUSK_GAME_DATA dBgS_ObjLinChk M_wall_work[23]; /* 0x000 */ f32 field_0x0[23]; /* 0x05C */ int field_0x5c; @@ -213,11 +213,11 @@ struct Act_c : public dBgS_MoveBgActor { int getType() { return prm_get_type(); } - static const s16 M_dir_base[4]; - static const char* const M_arcname[8]; - static const dCcD_SrcCyl M_cyl_src; + static DUSK_GAME_DATA const s16 M_dir_base[4]; + static DUSK_GAME_DATA const char* const M_arcname[8]; + static DUSK_GAME_DATA const dCcD_SrcCyl M_cyl_src; - static const daObjMovebox::Attr_c M_attr[8]; + static DUSK_GAME_DATA const daObjMovebox::Attr_c M_attr[8]; /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_nagaisu.h b/include/d/actor/d_a_obj_nagaisu.h index 107691d338..2d1e97dd17 100644 --- a/include/d/actor/d_a_obj_nagaisu.h +++ b/include/d/actor/d_a_obj_nagaisu.h @@ -29,7 +29,7 @@ public: mPos.z = i_pos.z; } - static const dCcD_SrcCyl s_CcDCyl; + static DUSK_GAME_DATA const dCcD_SrcCyl s_CcDCyl; /* 0x004 */ dMdl_obj_c mMdlObj; /* 0x038 */ Vec mPos; @@ -59,7 +59,7 @@ public: void init(); void setIsu(); - static const int REMOVE_ISU_IDX[]; + static DUSK_GAME_DATA const int REMOVE_ISU_IDX[]; /* 0x574 */ J3DModel* mpModel; /* 0x578 */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_nameplate.h b/include/d/actor/d_a_obj_nameplate.h index 97b313099c..7d5140838a 100644 --- a/include/d/actor/d_a_obj_nameplate.h +++ b/include/d/actor/d_a_obj_nameplate.h @@ -40,10 +40,10 @@ public: /* 0x1F */ u8 field_0x1F; }; - static M_attrs const M_attr; + static DUSK_GAME_DATA M_attrs const M_attr; static M_attrs const& attr() { return M_attr; } - static char DUSK_CONST* DUSK_CONST l_arcName; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST l_arcName; ~daObjNameplate_c() { dComIfG_resDelete(&this->mPhase, l_arcName); } @@ -51,7 +51,6 @@ public: inline int draw(); inline int createHeap(); -private: /* 0x568 */ J3DModel* model; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_nan.h b/include/d/actor/d_a_obj_nan.h index 708d75199e..f1c9881764 100644 --- a/include/d/actor/d_a_obj_nan.h +++ b/include/d/actor/d_a_obj_nan.h @@ -42,7 +42,6 @@ public: inline int CreateHeap(); inline int draw(); -private: /* 0x590 */ request_of_phase_process_class mPhase; /* 0x598 */ Z2Creature mCreatureSound; /* 0x628 */ mDoExt_McaMorfSO* mMorf; diff --git a/include/d/actor/d_a_obj_nougu.h b/include/d/actor/d_a_obj_nougu.h index 3e8e004e36..b8ea5aff06 100644 --- a/include/d/actor/d_a_obj_nougu.h +++ b/include/d/actor/d_a_obj_nougu.h @@ -16,7 +16,7 @@ class daObj_Nougu_Param_c { public: virtual ~daObj_Nougu_Param_c() {} - static const daObj_Nougu_HIOParam m; + static DUSK_GAME_DATA const daObj_Nougu_HIOParam m; }; #if DEBUG @@ -73,7 +73,7 @@ public: int getType() { return 0; } - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; }; STATIC_ASSERT(sizeof(daObj_Nougu_c) == 0xe30); diff --git a/include/d/actor/d_a_obj_octhashi.h b/include/d/actor/d_a_obj_octhashi.h index 4b5ef5459a..9bb21ce9a4 100644 --- a/include/d/actor/d_a_obj_octhashi.h +++ b/include/d/actor/d_a_obj_octhashi.h @@ -33,7 +33,6 @@ public: int Draw(); int Delete(); -private: /* 0x5a0 */ cXyz field_0x5a0[8]; /* 0x600 */ cXyz field_0x600[8]; /* 0x660 */ csXyz field_0x660[8]; @@ -53,7 +52,6 @@ private: public: /* 0x6e8 */ s16 field_0x6e8; /* 0x6ec */ Z2Creature mSound; -private: /* 0x077c */ u8 field_0x77c[4]; /* 0x0780 */ J3DModel* mpModel[8]; /* 0x07a0 */ u8 field_0x7a0[0x7a4 - 0x7a0]; diff --git a/include/d/actor/d_a_obj_oiltubo.h b/include/d/actor/d_a_obj_oiltubo.h index fa1dc47fd9..58aeba161d 100644 --- a/include/d/actor/d_a_obj_oiltubo.h +++ b/include/d/actor/d_a_obj_oiltubo.h @@ -33,10 +33,9 @@ public: BOOL chkEvent(); int wait(void*); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl DUSK_CONST mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModel* mpBModel; diff --git a/include/d/actor/d_a_obj_onsen.h b/include/d/actor/d_a_obj_onsen.h index 64af56f1d5..43ba02bc25 100644 --- a/include/d/actor/d_a_obj_onsen.h +++ b/include/d/actor/d_a_obj_onsen.h @@ -25,7 +25,6 @@ public: u32 getType() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_onsenTaru.h b/include/d/actor/d_a_obj_onsenTaru.h index c7e992bb11..98c6d40aee 100644 --- a/include/d/actor/d_a_obj_onsenTaru.h +++ b/include/d/actor/d_a_obj_onsenTaru.h @@ -52,8 +52,8 @@ public: bool getTempStat() { return mTempStat; } void startTimer() { mStartTimer = true; } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_ornament_cloth.h b/include/d/actor/d_a_obj_ornament_cloth.h index e0ea54b63d..69f509ebb3 100644 --- a/include/d/actor/d_a_obj_ornament_cloth.h +++ b/include/d/actor/d_a_obj_ornament_cloth.h @@ -61,7 +61,7 @@ public: const daObjOnCloth_Attr_c& attr() const { return M_attr; } - static daObjOnCloth_Attr_c const M_attr; + static DUSK_GAME_DATA daObjOnCloth_Attr_c const M_attr; /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_btkAnm* mBtkAnm; diff --git a/include/d/actor/d_a_obj_pdtile.h b/include/d/actor/d_a_obj_pdtile.h index 1dcb327acc..05e04063aa 100644 --- a/include/d/actor/d_a_obj_pdtile.h +++ b/include/d/actor/d_a_obj_pdtile.h @@ -35,7 +35,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A8 */ Mtx mBgMtx; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_pdwall.h b/include/d/actor/d_a_obj_pdwall.h index 45e8213f39..698ac6a6bb 100644 --- a/include/d/actor/d_a_obj_pdwall.h +++ b/include/d/actor/d_a_obj_pdwall.h @@ -26,7 +26,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A8 */ Mtx field_0x5a8; /* 0x5D8 */ J3DModel* mpModels[10]; /* 0x600 */ Mtx field_0x600[10]; diff --git a/include/d/actor/d_a_obj_picture.h b/include/d/actor/d_a_obj_picture.h index 3460b60077..af175f93e9 100644 --- a/include/d/actor/d_a_obj_picture.h +++ b/include/d/actor/d_a_obj_picture.h @@ -39,13 +39,12 @@ public: #if DEBUG const #endif - static dCcD_SrcCps s_CcDCps; + static DUSK_GAME_DATA dCcD_SrcCps s_CcDCps; #if DEBUG const #endif - static dCcD_SrcCyl s_CcDCyl_pic_at; + static DUSK_GAME_DATA dCcD_SrcCyl s_CcDCyl_pic_at; -private: /* 0x574 */ dCcD_Stts field_0x574; /* 0x5B0 */ dCcD_Stts field_0x5b0; /* 0x5EC */ dCcD_Stts field_0x5ec; diff --git a/include/d/actor/d_a_obj_pleaf.h b/include/d/actor/d_a_obj_pleaf.h index 3571bb4026..12f14a2bad 100644 --- a/include/d/actor/d_a_obj_pleaf.h +++ b/include/d/actor/d_a_obj_pleaf.h @@ -15,7 +15,7 @@ class daObj_Pleaf_Param_c { public: virtual ~daObj_Pleaf_Param_c() {} - static daObj_Pleaf_HIOParam const m; + static DUSK_GAME_DATA daObj_Pleaf_HIOParam const m; }; #if DEBUG @@ -44,7 +44,7 @@ public: * */ class daObj_Pleaf_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_PLEAF_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_poCandle.h b/include/d/actor/d_a_obj_poCandle.h index defcdb7858..c76356d2df 100644 --- a/include/d/actor/d_a_obj_poCandle.h +++ b/include/d/actor/d_a_obj_poCandle.h @@ -48,7 +48,6 @@ public: u8 getIDNum() { return mIDNum; } void setFireFlag(u8 flag) { mFireFlag = flag; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ cXyz mFirePos; diff --git a/include/d/actor/d_a_obj_poFire.h b/include/d/actor/d_a_obj_poFire.h index b8c9198b7c..10a91cbf34 100644 --- a/include/d/actor/d_a_obj_poFire.h +++ b/include/d/actor/d_a_obj_poFire.h @@ -68,7 +68,6 @@ public: u8 getMoveEnd() { return mMoveEnd; } u32 getID() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x584 */ request_of_phase_process_class mPhase; /* 0x58C */ int mStaffID; /* 0x590 */ s16 unk590; diff --git a/include/d/actor/d_a_obj_poTbox.h b/include/d/actor/d_a_obj_poTbox.h index 714f7338d3..44b18117e6 100644 --- a/include/d/actor/d_a_obj_poTbox.h +++ b/include/d/actor/d_a_obj_poTbox.h @@ -33,7 +33,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } int getStat() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpBoxModel; /* 0x5AC */ J3DModel* mpAnimModel; diff --git a/include/d/actor/d_a_obj_prop.h b/include/d/actor/d_a_obj_prop.h index d61025630b..157f8dde6b 100644 --- a/include/d/actor/d_a_obj_prop.h +++ b/include/d/actor/d_a_obj_prop.h @@ -26,7 +26,6 @@ public: u32 getNameArg_0() { return fopAcM_GetParamBit(this, 0, 4); } u32 getArg_0() { return fopAcM_GetParamBit(this, 4, 4); } -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ u8 mArg; }; diff --git a/include/d/actor/d_a_obj_pumpkin.h b/include/d/actor/d_a_obj_pumpkin.h index b1b36bfa1f..74ba8f3026 100644 --- a/include/d/actor/d_a_obj_pumpkin.h +++ b/include/d/actor/d_a_obj_pumpkin.h @@ -28,7 +28,7 @@ class daObj_Pumpkin_Param_c { public: virtual ~daObj_Pumpkin_Param_c() {} - static const daObj_Pumpkin_HIOParam m; + static DUSK_GAME_DATA const daObj_Pumpkin_HIOParam m; }; #if DEBUG @@ -56,7 +56,7 @@ public: * */ class daObj_Pumpkin_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_PUMPKIN_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_rcircle.h b/include/d/actor/d_a_obj_rcircle.h index 43811a0702..5ef1324f2c 100644 --- a/include/d/actor/d_a_obj_rcircle.h +++ b/include/d/actor/d_a_obj_rcircle.h @@ -25,7 +25,6 @@ public: int getSwBit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } -private: /* 0x574 */ mDoExt_brkAnm mBrk; /* 0x58C */ mDoExt_btkAnm mBtk; /* 0x5A4 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_rfHole.h b/include/d/actor/d_a_obj_rfHole.h index d053d6800c..00a873229c 100644 --- a/include/d/actor/d_a_obj_rfHole.h +++ b/include/d/actor/d_a_obj_rfHole.h @@ -42,7 +42,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_rope_bridge.h b/include/d/actor/d_a_obj_rope_bridge.h index 90532c9ba7..8eababd778 100644 --- a/include/d/actor/d_a_obj_rope_bridge.h +++ b/include/d/actor/d_a_obj_rope_bridge.h @@ -44,7 +44,6 @@ public: u8 getSwbit2() { return fopAcM_GetParamBit(this, 24, 8); } u8 getType() { return fopAcM_GetParamBit(this, 16, 2); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ request_of_phase_process_class mRopePhase; /* 0x5B0 */ J3DModel* mpBrgModel; diff --git a/include/d/actor/d_a_obj_rotTrap.h b/include/d/actor/d_a_obj_rotTrap.h index 4b7b669afc..069bfe285c 100644 --- a/include/d/actor/d_a_obj_rotTrap.h +++ b/include/d/actor/d_a_obj_rotTrap.h @@ -34,10 +34,9 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_roten.h b/include/d/actor/d_a_obj_roten.h index 9b4b17a19d..ea78731b77 100644 --- a/include/d/actor/d_a_obj_roten.h +++ b/include/d/actor/d_a_obj_roten.h @@ -25,7 +25,6 @@ public: char DUSK_CONST* getResName(); virtual ~daObj_Roten_c(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ JPABaseEmitter* mEmitters[2]; diff --git a/include/d/actor/d_a_obj_rstair.h b/include/d/actor/d_a_obj_rstair.h index 053692ba9e..6c31ff4648 100644 --- a/include/d/actor/d_a_obj_rstair.h +++ b/include/d/actor/d_a_obj_rstair.h @@ -58,7 +58,6 @@ public: u8 getEventID() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ J3DModel* mWaterModels[2]; diff --git a/include/d/actor/d_a_obj_saidan.h b/include/d/actor/d_a_obj_saidan.h index ef38588f00..f421cf55ad 100644 --- a/include/d/actor/d_a_obj_saidan.h +++ b/include/d/actor/d_a_obj_saidan.h @@ -35,7 +35,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_sakuita.h b/include/d/actor/d_a_obj_sakuita.h index 29b101586d..621084a592 100644 --- a/include/d/actor/d_a_obj_sakuita.h +++ b/include/d/actor/d_a_obj_sakuita.h @@ -43,9 +43,8 @@ public: const daObjSakuita_Attr_c& attr() const { return M_attr; } - static daObjSakuita_Attr_c const M_attr; + static DUSK_GAME_DATA daObjSakuita_Attr_c const M_attr; -private: /* 0x568 */ J3DModel* mModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_sakuita_rope.h b/include/d/actor/d_a_obj_sakuita_rope.h index 9567b7f25f..37df115ea9 100644 --- a/include/d/actor/d_a_obj_sakuita_rope.h +++ b/include/d/actor/d_a_obj_sakuita_rope.h @@ -80,9 +80,8 @@ public: return field_0x62c * (pos->z - getRopeStartPos()->z); } - static daObjItaRope_Attr_c const M_attr; + static DUSK_GAME_DATA daObjItaRope_Attr_c const M_attr; -private: /* 0x570 */ mDoExt_3DlineMat1_c mLineMat; /* 0x5A4 */ request_of_phase_process_class mPhase; /* 0x5AC */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_scannon.h b/include/d/actor/d_a_obj_scannon.h index 9aa871bd77..e376f55d40 100644 --- a/include/d/actor/d_a_obj_scannon.h +++ b/include/d/actor/d_a_obj_scannon.h @@ -76,14 +76,13 @@ public: int getSw1() { return fopAcM_GetParamBit(this, 0, 8); } int getSw2() { return fopAcM_GetParamBit(this, 8, 8); } - static const demoTable_s s_demoTable[]; - static void (daSCannon_c::*DUSK_CONST s_exeProc[])(); - static void (daSCannon_c::*DUSK_CONST s_demoExeProc_WarpEnd[][2])(); - static void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireTks[][2])(); - static void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireFirst[][2])(); - static void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireSecond[][2])(); + static DUSK_GAME_DATA const demoTable_s s_demoTable[]; + static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_exeProc[])(); + static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_WarpEnd[][2])(); + static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireTks[][2])(); + static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireFirst[][2])(); + static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireSecond[][2])(); -private: /* 0x574 */ request_of_phase_process_class mZevPhase; /* 0x57C */ request_of_phase_process_class mPtlPhase; /* 0x584 */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_obj_scannon_crs.h b/include/d/actor/d_a_obj_scannon_crs.h index e390c60128..12369f58fd 100644 --- a/include/d/actor/d_a_obj_scannon_crs.h +++ b/include/d/actor/d_a_obj_scannon_crs.h @@ -49,9 +49,8 @@ public: int getWarpId() { return fopAcM_GetParamBit(this, 8, 8); } u16 getMsgId() { return home.angle.x; } - static void (daSCannonCrs_c::*s_exeProc[])(daMidna_c*); + static DUSK_GAME_DATA void (daSCannonCrs_c::*s_exeProc[])(daMidna_c*); -private: /* 0x574 */ cXyz mPortalWaitPos; /* 0x580 */ dMsgFlow_c mMsgFlow; /* 0x5CC */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_obj_scannon_ten.h b/include/d/actor/d_a_obj_scannon_ten.h index 503a1e0522..ce6c840cfe 100644 --- a/include/d/actor/d_a_obj_scannon_ten.h +++ b/include/d/actor/d_a_obj_scannon_ten.h @@ -57,10 +57,9 @@ public: void exeEmtLine(); void delEmtAll(); - static const ExeProc s_exeProc[]; - static const ExeProc s_demoExeProc[][2]; + static DUSK_GAME_DATA const ExeProc s_exeProc[]; + static DUSK_GAME_DATA const ExeProc s_demoExeProc[][2]; -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ mDoExt_bckAnm mBck; /* 0x594 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_sekidoor.h b/include/d/actor/d_a_obj_sekidoor.h index ae4ff9acd4..8f2791a673 100644 --- a/include/d/actor/d_a_obj_sekidoor.h +++ b/include/d/actor/d_a_obj_sekidoor.h @@ -14,7 +14,7 @@ class daObj_SekiDoor_Param_c { public: virtual ~daObj_SekiDoor_Param_c() {}; - static daObj_SekiDoor_HIOParam const m; + static DUSK_GAME_DATA daObj_SekiDoor_HIOParam const m; }; #if DEBUG @@ -59,7 +59,6 @@ public: void open() { mOpening = true; } bool chkDestroy() { return (mDestroyed == true); } -private: /* 0x5A0 */ OBJ_SEKIDOOR_HIO_CLASS* mpHIO; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_sekizo.h b/include/d/actor/d_a_obj_sekizo.h index 54fa84f5df..2011417a96 100644 --- a/include/d/actor/d_a_obj_sekizo.h +++ b/include/d/actor/d_a_obj_sekizo.h @@ -10,7 +10,7 @@ struct daObj_Sekizo_HIOParam { class daObj_Sekizo_Param_c { public: virtual ~daObj_Sekizo_Param_c() {} - static daObj_Sekizo_HIOParam const m; + static DUSK_GAME_DATA daObj_Sekizo_HIOParam const m; }; #if DEBUG @@ -50,7 +50,6 @@ public: void initBaseMtx(); void setBaseMtx(); -private: /* 0x5A0 */ OBJ_SEKIZO_HIO_CLASS* mpHIO; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_sekizoa.h b/include/d/actor/d_a_obj_sekizoa.h index ce924915e1..b5c6abd9c3 100644 --- a/include/d/actor/d_a_obj_sekizoa.h +++ b/include/d/actor/d_a_obj_sekizoa.h @@ -57,7 +57,7 @@ class daObj_Sekizoa_Param_c { public: virtual ~daObj_Sekizoa_Param_c() {} - static daObj_Sekizoa_HIOParam const m; + static DUSK_GAME_DATA daObj_Sekizoa_HIOParam const m; }; #if DEBUG @@ -268,8 +268,8 @@ public: -300.0f, 0); } - static char DUSK_CONST* DUSK_CONST mCutNameList[9]; - static cutFunc DUSK_CONST mCutList[9]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[9]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[9]; /* 0x0E40 */ mDoExt_McaMorfSO* mpMcaMorf; /* 0x0E44 */ mDoExt_invisibleModel mInvModel; diff --git a/include/d/actor/d_a_obj_shield.h b/include/d/actor/d_a_obj_shield.h index 11b4a2668d..248c26be5b 100644 --- a/include/d/actor/d_a_obj_shield.h +++ b/include/d/actor/d_a_obj_shield.h @@ -59,7 +59,6 @@ public: void setStatus(u8 status) { mStatus = status; } void setAction(u8 action) { mAction = action; } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int mRotAngleCoeff; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_sm_door.h b/include/d/actor/d_a_obj_sm_door.h index bec15a0ae8..bd6553c0d2 100644 --- a/include/d/actor/d_a_obj_sm_door.h +++ b/include/d/actor/d_a_obj_sm_door.h @@ -31,7 +31,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ bool mUseAlphaModel; /* 0x5A1 */ u8 field_0x5a1[0x5AC - 0x5A1]; /* 0x5AC */ s16 mMode; @@ -54,5 +53,4 @@ private: STATIC_ASSERT(sizeof(daObjSM_DOOR_c) == 0x858); - #endif /* D_A_OBJ_SM_DOOR_H */ diff --git a/include/d/actor/d_a_obj_smallkey.h b/include/d/actor/d_a_obj_smallkey.h index 2becc9bae2..7bf38de4af 100644 --- a/include/d/actor/d_a_obj_smallkey.h +++ b/include/d/actor/d_a_obj_smallkey.h @@ -14,7 +14,7 @@ * */ class daKey_c : public daItemBase_c { -private: +public: void seStartTwinkle_private(u32); public: diff --git a/include/d/actor/d_a_obj_smgdoor.h b/include/d/actor/d_a_obj_smgdoor.h index aad2800ece..b22734b3e3 100644 --- a/include/d/actor/d_a_obj_smgdoor.h +++ b/include/d/actor/d_a_obj_smgdoor.h @@ -53,7 +53,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ s16 field_0x5b0; diff --git a/include/d/actor/d_a_obj_smoke.h b/include/d/actor/d_a_obj_smoke.h index 61a3b56a51..abd172afbe 100644 --- a/include/d/actor/d_a_obj_smoke.h +++ b/include/d/actor/d_a_obj_smoke.h @@ -24,7 +24,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ JPABaseEmitter* mParticle; }; diff --git a/include/d/actor/d_a_obj_smtile.h b/include/d/actor/d_a_obj_smtile.h index 1832a7c4b8..c85000e7b8 100644 --- a/include/d/actor/d_a_obj_smtile.h +++ b/include/d/actor/d_a_obj_smtile.h @@ -12,7 +12,7 @@ class daObj_SMTile_Param_c { public: virtual ~daObj_SMTile_Param_c() {} - static daObj_SMTile_HIOParam const m; + static DUSK_GAME_DATA daObj_SMTile_HIOParam const m; }; #if DEBUG @@ -41,7 +41,7 @@ public: * */ class daObj_SMTile_c : public fopAc_ac_c { -private: +public: /* 0x568 */ mDoExt_brkAnm mBrk; /* 0x580 */ OBJ_SMTILE_HIO_CLASS* mpHIO; /* 0x584 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_smw_stone.h b/include/d/actor/d_a_obj_smw_stone.h index 02f58284ff..05913cd339 100644 --- a/include/d/actor/d_a_obj_smw_stone.h +++ b/include/d/actor/d_a_obj_smw_stone.h @@ -29,7 +29,6 @@ public: u8 getSwBit0() { return fopAcM_GetParamBit(this, 0, 8); } void deleteStone() { mDelete = true; } -private: /* 0x574 */ cBgS_PolyInfo mPolyInfo; /* 0x584 */ J3DModel* mpModel; /* 0x588 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_snowEffTag.h b/include/d/actor/d_a_obj_snowEffTag.h index 748106cc81..bc995c749c 100644 --- a/include/d/actor/d_a_obj_snowEffTag.h +++ b/include/d/actor/d_a_obj_snowEffTag.h @@ -23,7 +23,6 @@ public: int getArg0() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ bool mPlayedSound; /* 0x56C */ f32 mMaxSize; diff --git a/include/d/actor/d_a_obj_snow_soup.h b/include/d/actor/d_a_obj_snow_soup.h index 91c23c8f85..3b96cd566f 100644 --- a/include/d/actor/d_a_obj_snow_soup.h +++ b/include/d/actor/d_a_obj_snow_soup.h @@ -28,7 +28,6 @@ public: void createSmkEmtChange(int); void deleteSmkEmtChange(int); -private: /* 0x574 */ cXyz mFirewoodPos; /* 0x580 */ cXyz mBubblePos; /* 0x58C */ JPABaseEmitter* mpSmkEmtCommon[4]; diff --git a/include/d/actor/d_a_obj_spinLift.h b/include/d/actor/d_a_obj_spinLift.h index 548df3f910..d2f0a50b03 100644 --- a/include/d/actor/d_a_obj_spinLift.h +++ b/include/d/actor/d_a_obj_spinLift.h @@ -40,7 +40,6 @@ public: u8 getTimer() { return (current.angle.x & 0xff00) >> 8; } int getEndSw() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 field_0x5ac; diff --git a/include/d/actor/d_a_obj_ss_base.h b/include/d/actor/d_a_obj_ss_base.h index 4d275a43cd..2101dd3237 100644 --- a/include/d/actor/d_a_obj_ss_base.h +++ b/include/d/actor/d_a_obj_ss_base.h @@ -18,7 +18,6 @@ public: u16 getValueNumber() { return mValueNum; } void setValueNumber(u16 valueNum) { mValueNum = valueNum; } -private: /* 0x56C */ void* mpParentPtr; /* 0x570 */ u16 field_0x570; /* 0x572 */ u16 mFlowNodeNum; diff --git a/include/d/actor/d_a_obj_ss_drink.h b/include/d/actor/d_a_obj_ss_drink.h index c20992163b..c4c0a1a72b 100644 --- a/include/d/actor/d_a_obj_ss_drink.h +++ b/include/d/actor/d_a_obj_ss_drink.h @@ -47,10 +47,9 @@ public: virtual ~daObj_SSDrink_c(); virtual void setSoldOut(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl DUSK_CONST mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x578 */ mDoExt_btpAnm* mpBtpAnm; /* 0x57C */ mDoExt_brkAnm* mpBrkAnm; /* 0x580 */ u8 field_0x580; diff --git a/include/d/actor/d_a_obj_ss_item.h b/include/d/actor/d_a_obj_ss_item.h index 2b05046e28..59f8f56407 100644 --- a/include/d/actor/d_a_obj_ss_item.h +++ b/include/d/actor/d_a_obj_ss_item.h @@ -46,10 +46,9 @@ public: int buy(void* param_0); int cancel(void* param_0); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl DUSK_CONST mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x578 */ request_of_phase_process_class mPhase; /* 0x580 */ J3DModel* mpModel; /* 0x584 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_stairBlock.h b/include/d/actor/d_a_obj_stairBlock.h index 63a0c5b178..1b04d0bcc1 100644 --- a/include/d/actor/d_a_obj_stairBlock.h +++ b/include/d/actor/d_a_obj_stairBlock.h @@ -23,10 +23,9 @@ public: virtual int Draw(); virtual int Delete(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x056C */ request_of_phase_process_class mPhaseReq; /* 0x0574 */ J3DModel* mpModel[10]; /* 0x059C */ mDoExt_bckAnm mBckAnm[10]; diff --git a/include/d/actor/d_a_obj_stick.h b/include/d/actor/d_a_obj_stick.h index fe43aabd15..ce72273254 100644 --- a/include/d/actor/d_a_obj_stick.h +++ b/include/d/actor/d_a_obj_stick.h @@ -16,7 +16,7 @@ class daObj_Stick_Param_c { public: virtual ~daObj_Stick_Param_c() {} - static const daObj_Stick_HIOParam m; + static DUSK_GAME_DATA const daObj_Stick_HIOParam m; }; #if DEBUG @@ -45,7 +45,7 @@ public: * */ class daObj_Stick_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_STICK_HIO_CLASS* mpHIO; /* 0x56c */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; @@ -73,7 +73,7 @@ public: u32 getType() { return 0; } - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; }; STATIC_ASSERT(sizeof(daObj_Stick_c) == 0x950); diff --git a/include/d/actor/d_a_obj_stone.h b/include/d/actor/d_a_obj_stone.h index b5f4da8c39..dfeb11f539 100644 --- a/include/d/actor/d_a_obj_stone.h +++ b/include/d/actor/d_a_obj_stone.h @@ -56,7 +56,6 @@ public: int draw(); int _delete(); -private: /* 0x0568 */ request_of_phase_process_class mPhase; /* 0x0570 */ J3DModel* mpModel; /* 0x0574 */ dBgS_ObjAcch mChkObj; diff --git a/include/d/actor/d_a_obj_stoneMark.h b/include/d/actor/d_a_obj_stoneMark.h index fbe56ce31d..04540fd9c7 100644 --- a/include/d/actor/d_a_obj_stoneMark.h +++ b/include/d/actor/d_a_obj_stoneMark.h @@ -23,7 +23,6 @@ public: int draw(); int _delete(); -private: /* 0x0568 */ request_of_phase_process_class mpPhase; /* 0x0570 */ TGXTexObj mTexObj; /* 0x0590 */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_obj_stopper.h b/include/d/actor/d_a_obj_stopper.h index 9a100c754b..62eda0ae39 100644 --- a/include/d/actor/d_a_obj_stopper.h +++ b/include/d/actor/d_a_obj_stopper.h @@ -59,7 +59,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } u8 getSwNo2() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ u8 field_0x5a0[8]; // unused /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_stopper2.h b/include/d/actor/d_a_obj_stopper2.h index 7ec86cb818..ccae3af298 100644 --- a/include/d/actor/d_a_obj_stopper2.h +++ b/include/d/actor/d_a_obj_stopper2.h @@ -35,7 +35,6 @@ public: u32 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 i_action) { mAction = i_action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ f32 mOffsetY; diff --git a/include/d/actor/d_a_obj_suisya.h b/include/d/actor/d_a_obj_suisya.h index c92146f5af..59067d84a4 100644 --- a/include/d/actor/d_a_obj_suisya.h +++ b/include/d/actor/d_a_obj_suisya.h @@ -20,7 +20,6 @@ public: int CreateHeap(); int create(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u32 mShadowKey; diff --git a/include/d/actor/d_a_obj_swBallA.h b/include/d/actor/d_a_obj_swBallA.h index 1785565a4e..910c031050 100644 --- a/include/d/actor/d_a_obj_swBallA.h +++ b/include/d/actor/d_a_obj_swBallA.h @@ -41,7 +41,6 @@ public: void onFlag(u8 idx, u8 val) { field_0x5af[idx] |= val; } u8 checkFlag(u8 idx, u8 val) { return field_0x5af[idx] & val; } -private: /* 0x57C */ request_of_phase_process_class field_0x57c; /* 0x584 */ J3DModel* mModel; /* 0x588 */ mDoExt_btkAnm* field_0x588; diff --git a/include/d/actor/d_a_obj_swBallB.h b/include/d/actor/d_a_obj_swBallB.h index 31a7971232..31a8f4210e 100644 --- a/include/d/actor/d_a_obj_swBallB.h +++ b/include/d/actor/d_a_obj_swBallB.h @@ -44,7 +44,6 @@ public: void setLightOn() { field_0x5ac = 1; } void setLightOff() { field_0x5ad = 1; } -private: /* 0x57C */ request_of_phase_process_class field_0x57c; /* 0x584 */ J3DModel* mModel; /* 0x588 */ mDoExt_btkAnm* field_0x588; diff --git a/include/d/actor/d_a_obj_swLight.h b/include/d/actor/d_a_obj_swLight.h index 1a9fc50cca..9d84030e96 100644 --- a/include/d/actor/d_a_obj_swLight.h +++ b/include/d/actor/d_a_obj_swLight.h @@ -47,7 +47,6 @@ public: u8 getOnTime() { return fopAcM_GetParamBit(this, 16, 8); } u8 getEvent() { return (u8)field_0xb22; } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x6F4 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_swchain.h b/include/d/actor/d_a_obj_swchain.h index 270fb8f5ab..8bd68b4478 100644 --- a/include/d/actor/d_a_obj_swchain.h +++ b/include/d/actor/d_a_obj_swchain.h @@ -80,7 +80,6 @@ public: return FALSE; } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModelData* mChainModelData; diff --git a/include/d/actor/d_a_obj_swhang.h b/include/d/actor/d_a_obj_swhang.h index 097da890b3..37ddbb3ea2 100644 --- a/include/d/actor/d_a_obj_swhang.h +++ b/include/d/actor/d_a_obj_swhang.h @@ -78,7 +78,6 @@ public: u16 checkFlag(u16 flag) { return mFlags & flag; } s16 getAngleY() { return shape_angle.y; } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_sword.h b/include/d/actor/d_a_obj_sword.h index 163175ddec..63bc7d576a 100644 --- a/include/d/actor/d_a_obj_sword.h +++ b/include/d/actor/d_a_obj_sword.h @@ -31,7 +31,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } void setStatus(u8 status) { mStatus = status; } -private: /* 0x92c */ u32 field_0x92c; /* 0x930 */ fpc_ProcID mProcID; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_swpush.h b/include/d/actor/d_a_obj_swpush.h index 5c73d2b310..77b7557d69 100644 --- a/include/d/actor/d_a_obj_swpush.h +++ b/include/d/actor/d_a_obj_swpush.h @@ -142,12 +142,12 @@ namespace daObjSwpush { int Mthd_Execute(); int Mthd_Draw(); - static s16 const M_bmd[3]; - static s16 const M_dzb[3]; - static u32 const M_heap_size[3]; - static Hio_c::Attr_c const M_attr[5]; - static u8 const M_op_vtx[4]; - static DUSK_CONST char* M_arcname[3]; + static DUSK_GAME_DATA s16 const M_bmd[3]; + static DUSK_GAME_DATA s16 const M_dzb[3]; + static DUSK_GAME_DATA u32 const M_heap_size[3]; + static DUSK_GAME_DATA Hio_c::Attr_c const M_attr[5]; + static DUSK_GAME_DATA u8 const M_op_vtx[4]; + static DUSK_GAME_DATA DUSK_CONST char* M_arcname[3]; /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ dBgWSv* mpBgW; diff --git a/include/d/actor/d_a_obj_swpush2.h b/include/d/actor/d_a_obj_swpush2.h index a99800e4c4..751c35abf6 100644 --- a/include/d/actor/d_a_obj_swpush2.h +++ b/include/d/actor/d_a_obj_swpush2.h @@ -128,8 +128,8 @@ namespace daObjSwpush2 { void off_switch() const { fopAcM_offSwitch(this, prm_get_swSave()); } void rev_switch() const { fopAcM_revSwitch(this, prm_get_swSave()); } - static const char M_arcname[]; - static const Attr_c M_attr[4]; + static DUSK_GAME_DATA const char M_arcname[]; + static DUSK_GAME_DATA const Attr_c M_attr[4]; #if DEBUG static Hio_c M_hio; diff --git a/include/d/actor/d_a_obj_syRock.h b/include/d/actor/d_a_obj_syRock.h index 0af85cbaa6..3fa10456f8 100644 --- a/include/d/actor/d_a_obj_syRock.h +++ b/include/d/actor/d_a_obj_syRock.h @@ -43,10 +43,9 @@ public: int Draw(); int Delete(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModels[2]; /* 0x5C8 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_szbridge.h b/include/d/actor/d_a_obj_szbridge.h index eff6a17a9c..8702506280 100644 --- a/include/d/actor/d_a_obj_szbridge.h +++ b/include/d/actor/d_a_obj_szbridge.h @@ -25,7 +25,6 @@ public: int Delete(); virtual ~daObjSZbridge_c() {} -private: /* 0x5A8 */ Mtx mBgMtx; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_taFence.h b/include/d/actor/d_a_obj_taFence.h index 5d18cf5cc0..6ab2e31f0a 100644 --- a/include/d/actor/d_a_obj_taFence.h +++ b/include/d/actor/d_a_obj_taFence.h @@ -32,8 +32,8 @@ public: virtual int Draw(); virtual int Delete(); - static const dCcD_SrcGObjInf mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_table.h b/include/d/actor/d_a_obj_table.h index cea036783c..44de1d1a47 100644 --- a/include/d/actor/d_a_obj_table.h +++ b/include/d/actor/d_a_obj_table.h @@ -27,7 +27,6 @@ public: s16 getMessageNo() { return fopAcM_GetParam(this) & 0xFFFF; } -private: /* 0x5A0 */ J3DModel* mpModel; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ dMsgFlow_c mMsgFlow; diff --git a/include/d/actor/d_a_obj_takaraDai.h b/include/d/actor/d_a_obj_takaraDai.h index b745683dd6..657e032bcc 100644 --- a/include/d/actor/d_a_obj_takaraDai.h +++ b/include/d/actor/d_a_obj_takaraDai.h @@ -26,7 +26,6 @@ public: u32 getSwBit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpBaseModel; /* 0x5AC */ J3DModel* mpTopModel; diff --git a/include/d/actor/d_a_obj_tgake.h b/include/d/actor/d_a_obj_tgake.h index 1871794df9..6862ad4979 100644 --- a/include/d/actor/d_a_obj_tgake.h +++ b/include/d/actor/d_a_obj_tgake.h @@ -28,7 +28,6 @@ public: u16 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } u8 getType() { return fopAcM_GetParamBit(this, 0x14, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u16 mEventBit1; diff --git a/include/d/actor/d_a_obj_thashi.h b/include/d/actor/d_a_obj_thashi.h index 3796ee0629..1934b57c56 100644 --- a/include/d/actor/d_a_obj_thashi.h +++ b/include/d/actor/d_a_obj_thashi.h @@ -25,8 +25,6 @@ public: int Draw(); int Delete(); -// private: - /* 0x5A0 */ dBgW* unk5A0; /* 0x5A4 */ u32 unk5A4; /* 0x5A8 */ u32 unk5A8; diff --git a/include/d/actor/d_a_obj_timeFire.h b/include/d/actor/d_a_obj_timeFire.h index 62fb3460d9..0b7a5ab5ec 100644 --- a/include/d/actor/d_a_obj_timeFire.h +++ b/include/d/actor/d_a_obj_timeFire.h @@ -28,7 +28,6 @@ public: u8 getEndTime() { return fopAcM_GetParamBit(this, 16, 8); } u8 getScale() { return fopAcM_GetParamBit(this, 24, 8); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 mStartTime; diff --git a/include/d/actor/d_a_obj_timer.h b/include/d/actor/d_a_obj_timer.h index 120a23b3a9..5778bf5ca1 100644 --- a/include/d/actor/d_a_obj_timer.h +++ b/include/d/actor/d_a_obj_timer.h @@ -54,7 +54,6 @@ class Act_c : public fopAc_ac_c { return daObj::PrmAbstract(this, PRM_2, PRM_24); } - private: /* 0x568 */ int field_0x568; /* 0x56C */ int field_0x56c; /* 0x570 */ u8 field_0x570; diff --git a/include/d/actor/d_a_obj_tks.h b/include/d/actor/d_a_obj_tks.h index 9d98f8cd0b..2180e99494 100644 --- a/include/d/actor/d_a_obj_tks.h +++ b/include/d/actor/d_a_obj_tks.h @@ -17,7 +17,7 @@ class daObjTks_Param_c { public: virtual ~daObjTks_Param_c() {} - static const daObjTks_HIOParam m; + static DUSK_GAME_DATA const daObjTks_HIOParam m; }; #if DEBUG diff --git a/include/d/actor/d_a_obj_tmoon.h b/include/d/actor/d_a_obj_tmoon.h index 4bf3c3620c..2992316782 100644 --- a/include/d/actor/d_a_obj_tmoon.h +++ b/include/d/actor/d_a_obj_tmoon.h @@ -25,7 +25,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } u32 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u16 field_0x574; diff --git a/include/d/actor/d_a_obj_toaru_maki.h b/include/d/actor/d_a_obj_toaru_maki.h index 4f7e8d2645..d980f9410f 100644 --- a/include/d/actor/d_a_obj_toaru_maki.h +++ b/include/d/actor/d_a_obj_toaru_maki.h @@ -25,7 +25,6 @@ public: u32 getNameArg_0() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ dBgW* mpBgW; /* 0x57C */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_togeTrap.h b/include/d/actor/d_a_obj_togeTrap.h index 161c958ce0..a67451ea0a 100644 --- a/include/d/actor/d_a_obj_togeTrap.h +++ b/include/d/actor/d_a_obj_togeTrap.h @@ -44,10 +44,9 @@ public: u8 getSwBit() { return fopAcM_GetParamBit(this, 0, 8); } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mStts; /* 0x5DC */ dCcD_Cyl mCyls[4]; /* 0xACC */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_tombo.h b/include/d/actor/d_a_obj_tombo.h index 5dfdcb6451..288d35611e 100644 --- a/include/d/actor/d_a_obj_tombo.h +++ b/include/d/actor/d_a_obj_tombo.h @@ -48,7 +48,6 @@ public: inline int Draw(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_tornado.h b/include/d/actor/d_a_obj_tornado.h index 30e8e2c1e3..c3330d73f9 100644 --- a/include/d/actor/d_a_obj_tornado.h +++ b/include/d/actor/d_a_obj_tornado.h @@ -30,7 +30,6 @@ public: u8 getTimer() { return fopAcM_GetParamBit(this, 0, 8); } u8 getSwbit() { return fopAcM_GetParamBit(this, 0x18, 8); } -private: /* 0x568 */ dCcD_Stts mStts; /* 0x5A4 */ dCcD_Cps mCps; /* 0x6E8 */ cM3dGCpsS mWindCps; diff --git a/include/d/actor/d_a_obj_twGate.h b/include/d/actor/d_a_obj_twGate.h index 683a7f18fb..0a00c2b834 100644 --- a/include/d/actor/d_a_obj_twGate.h +++ b/include/d/actor/d_a_obj_twGate.h @@ -23,7 +23,6 @@ public: int getGateType() { return fopAcM_GetParamBit(this, 4, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_vground.h b/include/d/actor/d_a_obj_vground.h index fed893aef1..bd9e266ebf 100644 --- a/include/d/actor/d_a_obj_vground.h +++ b/include/d/actor/d_a_obj_vground.h @@ -24,7 +24,6 @@ public: u32 getSwbit() { return (u8) fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_volcball.h b/include/d/actor/d_a_obj_volcball.h index ddd299a26e..cb1e895e8f 100644 --- a/include/d/actor/d_a_obj_volcball.h +++ b/include/d/actor/d_a_obj_volcball.h @@ -113,7 +113,6 @@ public: void setAction(u8 i_action) { mMode = i_action; } -private: /* 0x057C */ request_of_phase_process_class mPhase; /* 0x0584 */ dBgS_AcchCir mAcchCir; /* 0x05C4 */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_volcbom.h b/include/d/actor/d_a_obj_volcbom.h index 17f9db911d..60401dca2d 100644 --- a/include/d/actor/d_a_obj_volcbom.h +++ b/include/d/actor/d_a_obj_volcbom.h @@ -84,7 +84,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this, 16, 8); } u16 getMsgID() { return mMsgID; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ mDoExt_btkAnm* mBtk1; diff --git a/include/d/actor/d_a_obj_waterGate.h b/include/d/actor/d_a_obj_waterGate.h index 66a076be78..ae81773aec 100644 --- a/include/d/actor/d_a_obj_waterGate.h +++ b/include/d/actor/d_a_obj_waterGate.h @@ -33,7 +33,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_waterPillar.h b/include/d/actor/d_a_obj_waterPillar.h index 6bcad283da..987abc3923 100644 --- a/include/d/actor/d_a_obj_waterPillar.h +++ b/include/d/actor/d_a_obj_waterPillar.h @@ -55,10 +55,10 @@ public: int draw(); int _delete(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcGObjInf const mCcDObjCoInfo; - static dCcD_SrcCps mCcDCps; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjCoInfo; + static DUSK_GAME_DATA dCcD_SrcCps mCcDCps; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; void onRockFlag() { mCarryingStalactite = true; @@ -76,7 +76,6 @@ public: mStartStalactiteShake = false; } -private: /* 0x584 */ request_of_phase_process_class mPhase; /* 0x58C */ J3DModel* mpModel; /* 0x590 */ mDoExt_btkAnm mVTexScrollAnm; diff --git a/include/d/actor/d_a_obj_waterfall.h b/include/d/actor/d_a_obj_waterfall.h index e7c143910d..7a69938455 100644 --- a/include/d/actor/d_a_obj_waterfall.h +++ b/include/d/actor/d_a_obj_waterfall.h @@ -24,7 +24,6 @@ public: void push_player(); int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ u8 pad[4]; /* 0x574 */ dCcD_Stts mCylColliderStts; diff --git a/include/d/actor/d_a_obj_wchain.h b/include/d/actor/d_a_obj_wchain.h index b9f791d058..d9377d327a 100644 --- a/include/d/actor/d_a_obj_wchain.h +++ b/include/d/actor/d_a_obj_wchain.h @@ -57,7 +57,6 @@ public: mDown = true; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpHandleModel; /* 0x574 */ J3DModelData* mpChainModelData; diff --git a/include/d/actor/d_a_obj_wdStick.h b/include/d/actor/d_a_obj_wdStick.h index c82b115b84..e68f5a4a8e 100644 --- a/include/d/actor/d_a_obj_wdStick.h +++ b/include/d/actor/d_a_obj_wdStick.h @@ -50,10 +50,9 @@ public: virtual int Draw(); virtual int Delete(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; /* 0x578 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_well_cover.h b/include/d/actor/d_a_obj_well_cover.h index b25ad59abe..f4fb2250d0 100644 --- a/include/d/actor/d_a_obj_well_cover.h +++ b/include/d/actor/d_a_obj_well_cover.h @@ -29,7 +29,6 @@ public: u8 getSwNo() { return fopAcM_GetParam(this); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 field_0x5AC[0x5B0 - 0x5AC]; diff --git a/include/d/actor/d_a_obj_wind_stone.h b/include/d/actor/d_a_obj_wind_stone.h index f5e52dfc94..107cecc92c 100644 --- a/include/d/actor/d_a_obj_wind_stone.h +++ b/include/d/actor/d_a_obj_wind_stone.h @@ -36,7 +36,6 @@ public: u32 getSwBit2() { return fopAcM_GetParamBit(this, 8, 8); } u32 getDelEveFlgId() { return fopAcM_GetParamBit(this, 0x10, 0x10); } -private: /* 0x574 */ cBgS_PolyInfo mPolyInfo; /* 0x584 */ J3DModel* mpModel; /* 0x588 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_window.h b/include/d/actor/d_a_obj_window.h index 83b62740a4..8d1b0412d7 100644 --- a/include/d/actor/d_a_obj_window.h +++ b/include/d/actor/d_a_obj_window.h @@ -27,7 +27,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 8); } u8 getLightInf() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_bckAnm* mpBckAnm; diff --git a/include/d/actor/d_a_obj_wood_pendulum.h b/include/d/actor/d_a_obj_wood_pendulum.h index 1a1ee024b3..9ee5126ad8 100644 --- a/include/d/actor/d_a_obj_wood_pendulum.h +++ b/include/d/actor/d_a_obj_wood_pendulum.h @@ -26,7 +26,6 @@ public: u32 getArg0() { return fopAcM_GetParamBit(this, 0, 8); } u32 getArg1() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_wood_statue.h b/include/d/actor/d_a_obj_wood_statue.h index c0214679db..3ddd94bc62 100644 --- a/include/d/actor/d_a_obj_wood_statue.h +++ b/include/d/actor/d_a_obj_wood_statue.h @@ -52,7 +52,6 @@ public: void setStatus(u8 status) { mStatus = status; } u8 getSwbit2() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int field_0x930; /* 0x934 */ int mStaffIdx; diff --git a/include/d/actor/d_a_obj_wsword.h b/include/d/actor/d_a_obj_wsword.h index aa611af336..2860313c19 100644 --- a/include/d/actor/d_a_obj_wsword.h +++ b/include/d/actor/d_a_obj_wsword.h @@ -25,7 +25,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_yel_bag.h b/include/d/actor/d_a_obj_yel_bag.h index 69b428da49..9c3f452a11 100644 --- a/include/d/actor/d_a_obj_yel_bag.h +++ b/include/d/actor/d_a_obj_yel_bag.h @@ -24,7 +24,7 @@ class daObj_YBag_Param_c { public: virtual ~daObj_YBag_Param_c() {} - static daObj_YBag_HIOParam const m; + static DUSK_GAME_DATA daObj_YBag_HIOParam const m; }; #if DEBUG @@ -53,7 +53,7 @@ public: * */ class daObj_YBag_c : public fopAc_ac_c { -private: +public: /* 0x568 */ request_of_phase_process_class mPhases[3]; /* 0x580 */ J3DModel* mModel; /* 0x584 */ OBJ_YBAG_HIO_CLASS* mpHIO; @@ -109,8 +109,8 @@ public: void setWaterPrtcl(); void setHamonPrtcl(); - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daObj_YBag_c) == 0xa3c); diff --git a/include/d/actor/d_a_obj_yobikusa.h b/include/d/actor/d_a_obj_yobikusa.h index 9c1ee2a746..ed1019c7ad 100644 --- a/include/d/actor/d_a_obj_yobikusa.h +++ b/include/d/actor/d_a_obj_yobikusa.h @@ -76,8 +76,8 @@ public: inline cPhs_Step create(); inline ~daObjYobikusa_c(); - static attributes const M_attr; - static actionFuncEntry ActionTable[3]; + static DUSK_GAME_DATA attributes const M_attr; + static DUSK_GAME_DATA actionFuncEntry ActionTable[3]; const attributes* attr() const { return &M_attr; } int getType() { return argument & 0x7F; } @@ -87,7 +87,6 @@ public: return var_r31 > 0; } -private: /* 0x568 */ J3DModel* mpActiveModel; /* 0x56C */ J3DModel* mpModelTypeA; /* 0x570 */ J3DModel* mpModelTypeB; diff --git a/include/d/actor/d_a_obj_zrTurara.h b/include/d/actor/d_a_obj_zrTurara.h index 9f48464cf9..c52a21f2cc 100644 --- a/include/d/actor/d_a_obj_zrTurara.h +++ b/include/d/actor/d_a_obj_zrTurara.h @@ -29,7 +29,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ dCcD_Stts mCcStatus; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhaseReq; @@ -50,8 +49,8 @@ public: int getSwBit2() { return fopAcM_GetParamBit(this, 8, 8); } int getScale() { return fopAcM_GetParamBit(this, 0x10, 8); } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcCyl mCcDCyl; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; }; STATIC_ASSERT(sizeof(daZrTurara_c) == 0x76C); diff --git a/include/d/actor/d_a_obj_zrTuraraRock.h b/include/d/actor/d_a_obj_zrTuraraRock.h index 4590cff2cf..922948ee9c 100644 --- a/include/d/actor/d_a_obj_zrTuraraRock.h +++ b/include/d/actor/d_a_obj_zrTuraraRock.h @@ -30,7 +30,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ dCcD_Stts mCcStatus; /* 0x5A4 */ dCcD_Sph mCcSph; /* 0x6DC */ request_of_phase_process_class mPhaseReq; @@ -45,8 +44,8 @@ private: public: u8 getScale() { return fopAcM_GetParamBit(this, 0, 8); } - static dCcD_SrcGObjInf const mCcDObjInfo; - static dCcD_SrcSph mCcDSph; + static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; }; STATIC_ASSERT(sizeof(daZrTuraRc_c) == 0x938); diff --git a/include/d/actor/d_a_obj_zra_rock.h b/include/d/actor/d_a_obj_zra_rock.h index 586fc176c5..925c49a5ee 100644 --- a/include/d/actor/d_a_obj_zra_rock.h +++ b/include/d/actor/d_a_obj_zra_rock.h @@ -28,7 +28,6 @@ public: void setDemoStart() { mDemoStart = 1; } -private: friend class daNpc_zrZ_c; /* 0x5A0 */ request_of_phase_process_class mPhaseReq; diff --git a/include/d/actor/d_a_passer_mng.h b/include/d/actor/d_a_passer_mng.h index 230432336c..a3aa50db35 100644 --- a/include/d/actor/d_a_passer_mng.h +++ b/include/d/actor/d_a_passer_mng.h @@ -257,9 +257,8 @@ public: int field_0x04[0]; }; - static const Group* mGroupTbl[4]; + static DUSK_GAME_DATA const Group* mGroupTbl[4]; -private: /* 0x568 */ fpc_ProcID* childProcIds; /* 0x56C */ dPath* mPath; /* 0x570 */ int startTime; diff --git a/include/d/actor/d_a_peru.h b/include/d/actor/d_a_peru.h index 9ea1ce80c1..8a997b7a85 100644 --- a/include/d/actor/d_a_peru.h +++ b/include/d/actor/d_a_peru.h @@ -59,7 +59,7 @@ class daPeru_Param_c { public: virtual ~daPeru_Param_c() {} - static daPeru_HIOParam const m; + static DUSK_GAME_DATA daPeru_HIOParam const m; }; #if DEBUG @@ -186,10 +186,9 @@ public: void setCnt(int cnt) { field_0xe6a = cnt; } int getCnt() { return field_0xe6a; } - static const char* mCutNameList[3]; - static cutAppearFunc mCutList[3]; + static DUSK_GAME_DATA const char* mCutNameList[3]; + static DUSK_GAME_DATA cutAppearFunc mCutList[3]; -private: /* 0x0E40 */ daNpcT_ActorMngr_c mActors[3]; /* 0x0E58 */ int field_0xe58; /* 0x0E5C */ actionFunc mActionFunc; diff --git a/include/d/actor/d_a_player.h b/include/d/actor/d_a_player.h index 1dfbec8783..ff8a165ef8 100644 --- a/include/d/actor/d_a_player.h +++ b/include/d/actor/d_a_player.h @@ -25,7 +25,6 @@ public: mNowSetFlg = 0; } -private: /* 0x14 */ u16 mEndFlg; /* 0x16 */ u16 mNowSetFlg; }; @@ -67,10 +66,9 @@ public: static void offEventKeepFlg() { m_eventKeepFlg = 0; } static void onEventKeepFlg() { m_eventKeepFlg = 1; } - static s16 m_dropAngleY; - static s16 m_eventKeepFlg; + static DUSK_GAME_DATA s16 m_dropAngleY; + static DUSK_GAME_DATA s16 m_eventKeepFlg; -private: /* 0x0 */ u8 field_0x0; /* 0x2 */ s16 field_0x2; /* 0x4 */ f32 m_offsetY; @@ -91,6 +89,14 @@ private: #define PLAYER_CREATE_ANM_HEAP(heap, type, name) (heap).createHeap(type) #endif +#if TARGET_PC +inline u32 daPy_getAnmResourceSize(u16 i_resId, u32 i_minSize) { + JKRArchive* archive = dComIfGp_getAnmArchive(); + u32 size = archive->getFileSize(archive->findIdxResource(i_resId)); + return size > i_minSize ? size : i_minSize; +} +#endif + class daPy_anmHeap_c { public: enum daAlinkHEAP_TYPE { @@ -107,6 +113,9 @@ public: void* mallocBuffer(); #if TARGET_PC void createHeap(daAlinkHEAP_TYPE i_heapType, const char* name); + void reserveBuffer(u16 i_resId); + void* allocTempBuffer(u16 i_resId, u32* io_size); + void freeTempBuffers(); #else void createHeap(daAlinkHEAP_TYPE i_heapType); #endif @@ -136,6 +145,10 @@ public: /* 0x08 */ u32 mBufferSize; /* 0x0C */ u8* mBuffer; /* 0x10 */ JKRSolidHeap* mAnimeHeap; +#if TARGET_PC + u8* mOwnedBuffer = NULL; + void** mTempBuffers = NULL; +#endif }; // Size = 0x14 class daPy_actorKeep_c { @@ -151,7 +164,6 @@ public: fopAc_ac_c* getActor() const { return mActor; } fopAc_ac_c* getActorConst() const { return mActor; } -private: /* 0x0 */ fpc_ProcID mID; /* 0x4 */ fopAc_ac_c* mActor; }; // Size: 0x8 @@ -296,7 +308,6 @@ public: void resetDemoType() { setDemoType(0); } void setStartDemoType() { setDemoType(DEMO_TYPE_START_e); } -private: /* 0x00 */ u16 mDemoType; /* 0x02 */ s16 mDemoMoveAngle; /* 0x04 */ s16 mTimer; @@ -311,9 +322,11 @@ private: class daMidna_c; class daSpinner_c; class daPy_py_c; +#if !TARGET_PC inline daPy_py_c* dComIfGp_getLinkPlayer(); inline BOOL dComIfGs_isEventBit(const u16); inline u32 dComIfGs_getLastSceneMode(); +#endif class daPy_py_c : public fopAc_ac_c { public: @@ -1213,7 +1226,7 @@ public: onEndResetFlg0(ERFLG0_FISHING_RELEASE); } - static daMidna_c* m_midnaActor; + static DUSK_GAME_DATA daMidna_c* m_midnaActor; void setGiantPuzzle() { mMode = SMODE_WOLF_PUZZLE; } void setGiantPuzzleEnd() { mMode = 0; } diff --git a/include/d/actor/d_a_ppolamp.h b/include/d/actor/d_a_ppolamp.h index f1e1a9f26d..d55754d97b 100644 --- a/include/d/actor/d_a_ppolamp.h +++ b/include/d/actor/d_a_ppolamp.h @@ -25,7 +25,6 @@ public: void moveSwing(); void initParam(); -private: /* 0x574 */ J3DModel* mModel1; /* 0x578 */ J3DModel* mModel2; /* 0x57C */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_spinner.h b/include/d/actor/d_a_spinner.h index 1dac4594a3..0ef81f3947 100644 --- a/include/d/actor/d_a_spinner.h +++ b/include/d/actor/d_a_spinner.h @@ -99,7 +99,6 @@ public: void forceDelete() { mDeleteFlg = true; } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm mBck; /* 0x588 */ J3DAnmTransform* mpSpoutBck; diff --git a/include/d/actor/d_a_suspend.h b/include/d/actor/d_a_suspend.h index 32cdf76864..9475aae38e 100644 --- a/include/d/actor/d_a_suspend.h +++ b/include/d/actor/d_a_suspend.h @@ -69,9 +69,9 @@ public: u8 getSw() { return fopAcM_GetParam(this) & 0xFF; } u8 getRoom() { return fopAcM_GetParam(this) >> 10; } - static data_c mData[0x20]; - static room_c mRoom[0x40]; - static s16 mSetTop; + static DUSK_GAME_DATA data_c mData[0x20]; + static DUSK_GAME_DATA room_c mRoom[0x40]; + static DUSK_GAME_DATA s16 mSetTop; }; #endif /* D_A_SUSPEND_H */ diff --git a/include/d/actor/d_a_swBall.h b/include/d/actor/d_a_swBall.h index 74bfa90593..df4877e04b 100644 --- a/include/d/actor/d_a_swBall.h +++ b/include/d/actor/d_a_swBall.h @@ -30,7 +30,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 24, 4); } bool checkPullLBall() { return fopAcM_GetParamBit(this, 28, 2) == 0; } -private: /* 0x568 */ fpc_ProcID mBallIDs[8]; /* 0x588 */ u8 mTimer; /* 0x589 */ u8 mAction; diff --git a/include/d/actor/d_a_swLBall.h b/include/d/actor/d_a_swLBall.h index 0a633fcb5b..c3d132a40f 100644 --- a/include/d/actor/d_a_swLBall.h +++ b/include/d/actor/d_a_swLBall.h @@ -42,7 +42,6 @@ public: return fopAcM_GetParamBit(this,28,2) == 0; } -private: /* 0x568 */ fpc_ProcID mProcIds[2]; /* 0x570 */ u8 mRunTimer; /* 0x571 */ u8 mAction; diff --git a/include/d/actor/d_a_swTime.h b/include/d/actor/d_a_swTime.h index b3b96fa104..f61d5a5e7f 100644 --- a/include/d/actor/d_a_swTime.h +++ b/include/d/actor/d_a_swTime.h @@ -30,7 +30,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ u8 mTime; /* 0x569 */ u8 mSwbit; /* 0x56A */ u8 mSwbit2; diff --git a/include/d/actor/d_a_tag_CstaSw.h b/include/d/actor/d_a_tag_CstaSw.h index b40a9d178e..e73fd18662 100644 --- a/include/d/actor/d_a_tag_CstaSw.h +++ b/include/d/actor/d_a_tag_CstaSw.h @@ -16,7 +16,6 @@ public: u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 mSwitch; /* 0x569 */ u8 unused[0x570 - 0x569]; diff --git a/include/d/actor/d_a_tag_TWgate.h b/include/d/actor/d_a_tag_TWgate.h index e5952da286..683d01449b 100644 --- a/include/d/actor/d_a_tag_TWgate.h +++ b/include/d/actor/d_a_tag_TWgate.h @@ -112,13 +112,12 @@ public: inline void setAction(Mode_e i_action); - static daTagTWGate_Attr_c const mAttr; + static DUSK_GAME_DATA daTagTWGate_Attr_c const mAttr; #if DEBUG static daTagTWGate_Hio_c mHio; #endif - static const actionFunc ActionTable[][2]; + static DUSK_GAME_DATA const actionFunc ActionTable[][2]; -private: /* 0x568 */ mDoExt_McaMorfSO* mpMorf; /* 0x56C */ request_of_phase_process_class mPhaseZevArc; /* 0x574 */ request_of_phase_process_class mPhaseMdRes; diff --git a/include/d/actor/d_a_tag_bottle_item.h b/include/d/actor/d_a_tag_bottle_item.h index cd122c8cad..3cc2a274d4 100644 --- a/include/d/actor/d_a_tag_bottle_item.h +++ b/include/d/actor/d_a_tag_bottle_item.h @@ -8,7 +8,7 @@ class daTag_BottleItem_c; typedef int (daTag_BottleItem_c::*ProcessFunc)(void*); class daTag_BottleItem_c : public fopAc_ac_c { -private: +public: /* 0x0568 */ ProcessFunc mProcessFunc; /* 0x056C */ u16 mEventType; /* 0x0576 */ u8 mBottleItemType; diff --git a/include/d/actor/d_a_tag_chkpoint.h b/include/d/actor/d_a_tag_chkpoint.h index 4871ec3946..51fa95e17d 100644 --- a/include/d/actor/d_a_tag_chkpoint.h +++ b/include/d/actor/d_a_tag_chkpoint.h @@ -45,7 +45,6 @@ public: return cPhs_COMPLEATE_e; } -private: /* 0x568 */ u8 field_0x568[8]; /* 0x570 */ cXyz mVtxA; /* 0x57C */ cXyz mVtxB; diff --git a/include/d/actor/d_a_tag_evt.h b/include/d/actor/d_a_tag_evt.h index fda3192704..6d9b85221b 100644 --- a/include/d/actor/d_a_tag_evt.h +++ b/include/d/actor/d_a_tag_evt.h @@ -17,7 +17,7 @@ public: int doEvtCutTalk(int); int doEvtCutNext(int); - static DUSK_CONST char* mEvtCutList[3]; + static DUSK_GAME_DATA DUSK_CONST char* mEvtCutList[3]; /* 0x568 */ char field_0x568[8]; /* 0x570 */ u16 field_0x570; diff --git a/include/d/actor/d_a_tag_evtarea.h b/include/d/actor/d_a_tag_evtarea.h index 4bf0ec404e..f83e034aa1 100644 --- a/include/d/actor/d_a_tag_evtarea.h +++ b/include/d/actor/d_a_tag_evtarea.h @@ -45,7 +45,6 @@ public: void noEffect() { field_0x56c = 1; } -private: /* 0x568 vtable */ /* 0x56C */ u8 field_0x56c; }; diff --git a/include/d/actor/d_a_tag_evtmsg.h b/include/d/actor/d_a_tag_evtmsg.h index 33a8d41f49..a1011ee8e4 100644 --- a/include/d/actor/d_a_tag_evtmsg.h +++ b/include/d/actor/d_a_tag_evtmsg.h @@ -32,8 +32,8 @@ public: virtual ~daTag_EvtMsg_c(); - static DUSK_CONST char* mEvtCutNameList[]; - static EvtCutFunc mEvtCutList[]; + static DUSK_GAME_DATA DUSK_CONST char* mEvtCutNameList[]; + static DUSK_GAME_DATA EvtCutFunc mEvtCutList[]; }; #endif /* D_A_TAG_EVTMSG_H */ diff --git a/include/d/actor/d_a_tag_hstop.h b/include/d/actor/d_a_tag_hstop.h index 6a5ae38beb..97b0a68f7b 100644 --- a/include/d/actor/d_a_tag_hstop.h +++ b/include/d/actor/d_a_tag_hstop.h @@ -22,8 +22,8 @@ public: } } - static daTagHstop_c* m_top; - static dMsgFlow_c m_msgFlow; + static DUSK_GAME_DATA daTagHstop_c* m_top; + static DUSK_GAME_DATA dMsgFlow_c m_msgFlow; /* 0x568 */ daTagHstop_c* mNext; /* 0x568 */ daTagHstop_c* mPrev; diff --git a/include/d/actor/d_a_tag_lantern.h b/include/d/actor/d_a_tag_lantern.h index c0e0c0d152..ed9cbef3e3 100644 --- a/include/d/actor/d_a_tag_lantern.h +++ b/include/d/actor/d_a_tag_lantern.h @@ -12,7 +12,7 @@ class daTag_Lantern_Param_c { public: inline virtual ~daTag_Lantern_Param_c() {} - static daTag_Lantern_HIOParam const m; + static DUSK_GAME_DATA daTag_Lantern_HIOParam const m; }; #if DEBUG diff --git a/include/d/actor/d_a_tag_lv6CstaSw.h b/include/d/actor/d_a_tag_lv6CstaSw.h index 17b58e4b28..384d9bd6d9 100644 --- a/include/d/actor/d_a_tag_lv6CstaSw.h +++ b/include/d/actor/d_a_tag_lv6CstaSw.h @@ -16,7 +16,6 @@ public: u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 mSwitch; /* 0x569 */ u8 unused[0x570 - 0x569]; }; diff --git a/include/d/actor/d_a_tag_magne.h b/include/d/actor/d_a_tag_magne.h index 2b2db66517..bfdc788e37 100644 --- a/include/d/actor/d_a_tag_magne.h +++ b/include/d/actor/d_a_tag_magne.h @@ -19,7 +19,7 @@ public: u8 getSwNo2() { return fopAcM_GetParamBit(this, 8, 8); } u8 getSwNo3() { return fopAcM_GetParamBit(this, 16, 8); } - static daTagMagne_c* mTagMagne; + static DUSK_GAME_DATA daTagMagne_c* mTagMagne; /* 0x568 */ u8 mSwNo1; /* 0x569 */ u8 mSwNo2; diff --git a/include/d/actor/d_a_tag_mhint.h b/include/d/actor/d_a_tag_mhint.h index e4c5260079..c573467ae0 100644 --- a/include/d/actor/d_a_tag_mhint.h +++ b/include/d/actor/d_a_tag_mhint.h @@ -26,7 +26,6 @@ public: NULL); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_tag_mist.h b/include/d/actor/d_a_tag_mist.h index 9579ff62d5..3c4973075a 100644 --- a/include/d/actor/d_a_tag_mist.h +++ b/include/d/actor/d_a_tag_mist.h @@ -17,7 +17,7 @@ public: static u8 getPlayerNo(); static void setPlayerNo(u8 i_playerNo) { mPlayerNo = i_playerNo; } - static u8 mPlayerNo; + static DUSK_GAME_DATA u8 mPlayerNo; /* 0x568 */ u8 unused_0x568[0x570 - 0x568]; /* 0x570 */ cXyz mVertices[4]; diff --git a/include/d/actor/d_a_tag_mmsg.h b/include/d/actor/d_a_tag_mmsg.h index 9fdd0b3c66..bcafa0c37d 100644 --- a/include/d/actor/d_a_tag_mmsg.h +++ b/include/d/actor/d_a_tag_mmsg.h @@ -14,7 +14,6 @@ public: void onUseFlg() { mUseFlg = true; } bool checkNoAttention() const { return mAttention == 0xFF; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 mAttention; diff --git a/include/d/actor/d_a_tag_msg.h b/include/d/actor/d_a_tag_msg.h index b1104d6846..b0b65e2795 100644 --- a/include/d/actor/d_a_tag_msg.h +++ b/include/d/actor/d_a_tag_msg.h @@ -13,7 +13,7 @@ class daTag_Msg_Param_c { public: virtual ~daTag_Msg_Param_c() {} - static const daTag_Msg_HIO_Param_c m; + static DUSK_GAME_DATA const daTag_Msg_HIO_Param_c m; }; #if DEBUG @@ -47,7 +47,7 @@ public: void getParam(); BOOL cut_speak(int, BOOL); - static DUSK_CONST char* mEvtCutTBL[2]; + static DUSK_GAME_DATA DUSK_CONST char* mEvtCutTBL[2]; /* 0x56C */ char mStaffName[8]; /* 0x574 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_tag_mstop.h b/include/d/actor/d_a_tag_mstop.h index dd27dbb005..774af17007 100644 --- a/include/d/actor/d_a_tag_mstop.h +++ b/include/d/actor/d_a_tag_mstop.h @@ -17,7 +17,6 @@ public: int execute(); bool checkNoAttention() const { return field_0x56b == 0xFF; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_tag_myna2.h b/include/d/actor/d_a_tag_myna2.h index 7eecb0c1d7..70605612e3 100644 --- a/include/d/actor/d_a_tag_myna2.h +++ b/include/d/actor/d_a_tag_myna2.h @@ -12,7 +12,6 @@ public: int getMode() { return fopAcM_GetParam(this) & 0xFF; } f32 getExtent() { return scale.x * 100.0f;} -private: /* 0x568 */ u32 mSwitchNo; /* 0x56C */ u32 mMode; /* 0x570 */ s16 mTimer; diff --git a/include/d/actor/d_a_tag_setBall.h b/include/d/actor/d_a_tag_setBall.h index 6e75928c6b..0619e2a677 100644 --- a/include/d/actor/d_a_tag_setBall.h +++ b/include/d/actor/d_a_tag_setBall.h @@ -16,7 +16,6 @@ public: s32 getType() { return mType; } -private: u8 getType_private() { return fopAcM_GetParamBit(this, 8, 4); } /* 0x568 */ u8 mType; diff --git a/include/d/actor/d_a_tag_statue_evt.h b/include/d/actor/d_a_tag_statue_evt.h index 1bdc0d4f52..59237c09eb 100644 --- a/include/d/actor/d_a_tag_statue_evt.h +++ b/include/d/actor/d_a_tag_statue_evt.h @@ -25,7 +25,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mArcPhase; /* 0x570 */ request_of_phase_process_class mEvArcPhase; /* 0x578 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_tag_stream.h b/include/d/actor/d_a_tag_stream.h index 7c3b3eb4ac..f30abfec15 100644 --- a/include/d/actor/d_a_tag_stream.h +++ b/include/d/actor/d_a_tag_stream.h @@ -42,7 +42,7 @@ public: /* 0x570 */ daTagStream_c* field_0x570; /* 0x574 */ daTagStream_c* mNext; - static daTagStream_c* m_top; + static DUSK_GAME_DATA daTagStream_c* m_top; }; #endif /* D_A_TAG_STREAM_H */ diff --git a/include/d/actor/d_a_tag_telop.h b/include/d/actor/d_a_tag_telop.h index 6e28231138..0d6fbeb7a1 100644 --- a/include/d/actor/d_a_tag_telop.h +++ b/include/d/actor/d_a_tag_telop.h @@ -13,7 +13,6 @@ public: u16 getMessageNo() { return home.angle.z; } -private: /* 0x568 */ u16 mMessageNo; /* 0x56C */ int mMessageStatus; }; diff --git a/include/d/actor/d_a_tag_waterfall.h b/include/d/actor/d_a_tag_waterfall.h index 80ffe7bec2..6076e53042 100644 --- a/include/d/actor/d_a_tag_waterfall.h +++ b/include/d/actor/d_a_tag_waterfall.h @@ -22,7 +22,6 @@ public: int _delete(); cPhs_Step create(); -private: /* 0x568 */ f32 mCylinderRadiusA; /* 0x56C */ f32 mCylinderRadiusB; /* 0x570 */ f32 mCylinderHeight; diff --git a/include/d/actor/d_a_tag_yami.h b/include/d/actor/d_a_tag_yami.h index 8410899186..fc17586688 100644 --- a/include/d/actor/d_a_tag_yami.h +++ b/include/d/actor/d_a_tag_yami.h @@ -36,7 +36,6 @@ public: void setCoR(f32 i_value) { mCoR = i_value; } void setCoH(f32 i_value) { mCoH = i_value; } -private: /* 0x568 */ dCcD_Cyl mCyl; /* 0x6A4 */ dCcD_Stts mStts; /* 0x6E0 */ u8 mCoHitValid; diff --git a/include/d/actor/d_a_talk.h b/include/d/actor/d_a_talk.h index 9c86f88610..b7715d88cd 100644 --- a/include/d/actor/d_a_talk.h +++ b/include/d/actor/d_a_talk.h @@ -22,7 +22,6 @@ public: u16 getStatus(); u32 messageSet(); -private: /* 0x568 */ dMsgFlow_c mMsgFlow; /* 0x5B4 */ u32 mMessageID; }; diff --git a/include/d/actor/d_a_tbox.h b/include/d/actor/d_a_tbox.h index 2b48a156eb..6b07594577 100644 --- a/include/d/actor/d_a_tbox.h +++ b/include/d/actor/d_a_tbox.h @@ -148,7 +148,6 @@ public: field_0x9fc = 1; } -private: /* 0x718 */ u8 field_0x718; /* 0x71C */ request_of_phase_process_class mPhase; /* 0x724 */ J3DModel* mpModel; @@ -194,6 +193,9 @@ private: /* 0x9FC */ u8 field_0x9fc; /* 0x9FD */ u8 field_0x9fd; /* 0xA00 */ Mtx mDrawMtx; +#if TARGET_PC + u8 mOriginalItemNo; +#endif }; STATIC_ASSERT(sizeof(daTbox_c) == 0xA30); diff --git a/include/d/actor/d_a_tbox2.h b/include/d/actor/d_a_tbox2.h index 3f176ade5e..29df2d8389 100644 --- a/include/d/actor/d_a_tbox2.h +++ b/include/d/actor/d_a_tbox2.h @@ -67,7 +67,6 @@ public: u8 getModelType() { return fopAcM_GetParamBit(this, 8, 4); } u8 getItemNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x718 */ u8 mReturnRupee; /* 0x71C */ request_of_phase_process_class mPhase; /* 0x724 */ J3DModel* mpModel; @@ -83,6 +82,10 @@ private: /* 0xAC0 */ u8 field_0xAC0[0xAC4 - 0xAC0]; /* 0xAC4 */ int mStaffIdx; /* 0xAC8 */ dBgW* mBoxBgW; +#if TARGET_PC + bool mParamsInit; + u8 mOriginalItemNo; +#endif }; STATIC_ASSERT(sizeof(daTbox2_c) == 0xACC); diff --git a/include/d/actor/d_a_title.h b/include/d/actor/d_a_title.h index 465fe689c1..691e2df3e3 100644 --- a/include/d/actor/d_a_title.h +++ b/include/d/actor/d_a_title.h @@ -50,7 +50,6 @@ public: void KeyWaitPosMove(); #endif -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ JKRHeap* mpHeap; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_ykgr.h b/include/d/actor/d_a_ykgr.h index 472ceefc4a..c23f530c67 100644 --- a/include/d/actor/d_a_ykgr.h +++ b/include/d/actor/d_a_ykgr.h @@ -57,12 +57,12 @@ public: int _execute(); bool _draw(); - static JPABaseEmitter* m_emitter; - static bool m_flag; - static bool m_alpha_flag; - static u8 m_alpha; - static f32 m_aim_rate; - static dPath* m_path; + static DUSK_GAME_DATA JPABaseEmitter* m_emitter; + static DUSK_GAME_DATA bool m_flag; + static DUSK_GAME_DATA bool m_alpha_flag; + static DUSK_GAME_DATA u8 m_alpha; + static DUSK_GAME_DATA f32 m_aim_rate; + static DUSK_GAME_DATA dPath* m_path; /* 0x568 */ u8 field_0x568[0x570 - 0x568]; /* 0x570 */ Mtx field_0x570; diff --git a/include/d/actor/d_flower.h b/include/d/actor/d_flower.h index f63847956a..db8661b92f 100644 --- a/include/d/actor/d_flower.h +++ b/include/d/actor/d_flower.h @@ -5,7 +5,7 @@ #include "SSystem/SComponent/c_xyz.h" #if TARGET_PC -#include "dusk/batch.hpp" +#include "helpers/batch.hpp" #endif class cCcD_Obj; @@ -74,7 +74,7 @@ public: return m_deleteRoom; } - static deleteFunc m_deleteRoom; + static DUSK_GAME_DATA deleteFunc m_deleteRoom; dFlower_anm_c* getAnm(int i_idx) { return &m_anm[i_idx]; } dFlower_anm_c* getAnm() { return &m_anm[0]; } @@ -112,11 +112,11 @@ public: TGXTexObj mTexObj_l_J_Ohana00_64TEX; TGXTexObj mTexObj_l_J_Ohana01_64128_0419TEX; - dusk::batch::LeafTemplate mTplHana00; // l_J_hana00DL - dusk::batch::LeafTemplate mTplHana00Cut; // l_J_hana00_cDL - dusk::batch::LeafTemplate mTplHana01; // l_J_hana01DL - dusk::batch::LeafTemplate mTplHana01Cut00; // l_J_hana01_c_00DL - dusk::batch::LeafTemplate mTplHana01Cut; // l_J_hana01_c_01DL + batch::LeafTemplate mTplHana00; // l_J_hana00DL + batch::LeafTemplate mTplHana00Cut; // l_J_hana00_cDL + batch::LeafTemplate mTplHana01; // l_J_hana01DL + batch::LeafTemplate mTplHana01Cut00; // l_J_hana01_c_00DL + batch::LeafTemplate mTplHana01Cut; // l_J_hana01_c_01DL #endif }; // Size: 0x12A54 diff --git a/include/d/actor/d_grass.h b/include/d/actor/d_grass.h index b7cc3d7d95..4eee08c0e8 100644 --- a/include/d/actor/d_grass.h +++ b/include/d/actor/d_grass.h @@ -5,7 +5,7 @@ #include "SSystem/SComponent/c_xyz.h" #if TARGET_PC -#include "../../../src/dusk/batch.hpp" +#include #endif class cCcD_Obj; @@ -84,7 +84,7 @@ public: return m_deleteRoom; } - static deleteFunc m_deleteRoom; + static DUSK_GAME_DATA deleteFunc m_deleteRoom; dGrass_anm_c* getAnm() { return m_anm; } dGrass_anm_c* getAnm(int i_no) { return &m_anm[i_no]; } @@ -115,9 +115,9 @@ public: TGXTexObj mTexObj_l_M_Hijiki00TEX; TGXTexObj mTexObj_l_M_kusa05_RGBATEX; - dusk::batch::LeafTemplate mTplKusa9q; // l_M_Kusa_9qDL - dusk::batch::LeafTemplate mTplKusa9qCut; // l_M_Kusa_9q_cDL - dusk::batch::LeafTemplate mTplTengusa; // l_M_TenGusaDL + batch::LeafTemplate mTplKusa9q; // l_M_Kusa_9qDL + batch::LeafTemplate mTplKusa9qCut; // l_M_Kusa_9q_cDL + batch::LeafTemplate mTplTengusa; // l_M_TenGusaDL #endif }; // Size: 0x1D718 diff --git a/include/d/d_a_item_static.h b/include/d/d_a_item_static.h index 10869c5733..6b8b321b2b 100644 --- a/include/d/d_a_item_static.h +++ b/include/d/d_a_item_static.h @@ -114,9 +114,9 @@ public: bool checkBoomWindTgTimer() { return mBoomWindTgTimer == 0; } - static procFunc mFuncPtr[]; - static const dCcD_SrcCyl m_cyl_src; - static s32 m_timer_max; + static DUSK_GAME_DATA procFunc mFuncPtr[]; + static DUSK_GAME_DATA const dCcD_SrcCyl m_cyl_src; + static DUSK_GAME_DATA s32 m_timer_max; /* 0x92C */ s16 field_0x92c; /* 0x92E */ u16 field_0x92e; @@ -145,6 +145,10 @@ public: /* 0x9BC */ u8 field_0x9bc[4]; /* 0x9C0 */ u8 field_0x9c0; /* 0x9C1 */ u8 field_0x9c1; +#if TARGET_PC + u8 mOriginalItemNo; + bool mItemOverridden; +#endif }; // Size: 0x9C4 #endif /* D_A_D_A_ITEM_STATIC_H */ diff --git a/include/d/d_a_itembase_static.h b/include/d/d_a_itembase_static.h index 36a0f55899..38ecb323eb 100644 --- a/include/d/d_a_itembase_static.h +++ b/include/d/d_a_itembase_static.h @@ -1,10 +1,15 @@ #ifndef D_A_D_A_ITEMBASE_STATIC_H #define D_A_D_A_ITEMBASE_STATIC_H +#include "dolphin/types.h" class fopAc_ac_c; int CheckFieldItemCreateHeap(fopAc_ac_c* actor); int CheckItemCreateHeap(fopAc_ac_c* i_this); +#if TARGET_PC +const char* dItem_fieldModelArc(u8 itemNo); +#endif + #endif /* D_A_D_A_ITEMBASE_STATIC_H */ diff --git a/include/d/d_a_shop_item_static.h b/include/d/d_a_shop_item_static.h index 0091c0b83c..e79973fc65 100644 --- a/include/d/d_a_shop_item_static.h +++ b/include/d/d_a_shop_item_static.h @@ -50,6 +50,9 @@ public: csXyz* getRotateP(); cXyz* getPosP(); const char* getShopArcname(); +#if TARGET_PC + const ResourceData& getResourceData() const; +#endif u16 getHeapSize(); void CreateInit(); void set_mtx(); @@ -74,8 +77,8 @@ public: s16 getAngleY() const { return mAngleY; } void setAngleY(s16 angle) { mAngleY = angle;} - static ResourceData const mData[23]; - static f32 const m_cullfar_max; + static DUSK_GAME_DATA ResourceData const mData[23]; + static DUSK_GAME_DATA f32 const m_cullfar_max; enum { SHOP_ITEMNO_SOLD, @@ -104,12 +107,15 @@ public: SHOP_ITEMNO_MAX, }; -private: /* 0x92C */ Mtx mMtx; /* 0x95C */ int field_0x95c; /* 0x960 */ s16 mAngleX; /* 0x962 */ s16 mAngleY; /* 0x964 */ u8 mShopItemID; +#if TARGET_PC + ResourceData mOverrideData; + bool mItemOverridden; +#endif }; int CheckShopItemCreateHeap(fopAc_ac_c* i_this); diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 5b8930b5dd..b1c269651f 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -18,7 +18,6 @@ public: fopAc_ac_c* getZHintTarget() { return convPId(field_0x8); } -private: /* 0x0 */ fpc_ProcID mHintActorID; /* 0x4 */ int mPriority; /* 0x8 */ fpc_ProcID field_0x8; @@ -34,7 +33,6 @@ public: fopAc_ac_c* getCatghTarget() { return convPId(mCatghTargetID); } u8 getChangeItem() { return mChangeItem; } -private: /* 0x00 */ fpc_ProcID mRequestActorID; /* 0x04 */ int field_0x4; /* 0x08 */ f32 mDistance; @@ -120,7 +118,6 @@ public: fopAc_ac_c* getLookTarget() { return convPId(mLookTargetID); } -private: fpc_ProcID mRequestActorID; int field_0x4; f32 mDistance; @@ -286,13 +283,13 @@ public: void keepLock(int timer) { mAttnBlockTimer = timer; } bool Lockon() { return LockonTruth() || chkFlag(0x20000000); } // only matches with -O2? - static type_tbl_entry loc_type_tbl[3]; - static type_tbl_entry act_type_tbl[5]; - static dist_entry dist_table[234]; - static int loc_type_num; - static int act_type_num; - static type_tbl_entry chk_type_tbl[1]; - static int chk_type_num; + static DUSK_GAME_DATA type_tbl_entry loc_type_tbl[3]; + static DUSK_GAME_DATA type_tbl_entry act_type_tbl[5]; + static DUSK_GAME_DATA dist_entry dist_table[234]; + static DUSK_GAME_DATA int loc_type_num; + static DUSK_GAME_DATA int act_type_num; + static DUSK_GAME_DATA type_tbl_entry chk_type_tbl[1]; + static DUSK_GAME_DATA int chk_type_num; public: /* 0x000 */ fopAc_ac_c* mpPlayer; diff --git a/include/d/d_bg_parts.h b/include/d/d_bg_parts.h index a8dba41165..b77199182f 100644 --- a/include/d/d_bg_parts.h +++ b/include/d/d_bg_parts.h @@ -237,8 +237,8 @@ public: static void drawShare(); static void entryShare(packet_c*); - static JKRSolidHeap* mShareHeap; - static share_c* mShare; + static DUSK_GAME_DATA JKRSolidHeap* mShareHeap; + static DUSK_GAME_DATA share_c* mShare; /* 0x000 */ void* mPointer; /* 0x004 */ char mArcName[8]; diff --git a/include/d/d_bg_plc.h b/include/d/d_bg_plc.h index da360fd0e4..f5361ff883 100644 --- a/include/d/d_bg_plc.h +++ b/include/d/d_bg_plc.h @@ -20,7 +20,6 @@ public: static const int ZELDA_CODE_SIZE = sizeof(sBgPc); -private: /* 0x00 */ sBgPlc* m_base; }; diff --git a/include/d/d_bg_s_acch.h b/include/d/d_bg_s_acch.h index 04a388c61b..a1a1517cc4 100644 --- a/include/d/d_bg_s_acch.h +++ b/include/d/d_bg_s_acch.h @@ -13,7 +13,7 @@ class fopAc_ac_c; class dBgS_AcchCir : public cBgS_PolyInfo { -private: +public: /* 0x10 */ u32 m_flags; /* 0x14 */ cM3dGCir m_cir; /* 0x28 */ f32 m_wall_rr; @@ -197,7 +197,6 @@ public: f32 GetCx() const { return pm_pos->x; } f32 GetCz() const { return pm_pos->z; } -private: /* 0x02C */ u32 m_flags; /* 0x030 */ cXyz* pm_pos; /* 0x034 */ cXyz* pm_old_pos; @@ -237,7 +236,6 @@ public: /* 0x0DC */ dBgS_GndChk m_gnd; /* 0x130 */ dBgS_RoofChk m_roof; /* 0x180 */ dBgS_WtrChk m_wtr; -private: /* 0x1D4 */ u8 m_wtr_mode; }; // Size: 0x1D8 diff --git a/include/d/d_bg_s_grp_pass_chk.h b/include/d/d_bg_s_grp_pass_chk.h index eea3414b98..6253f67f18 100644 --- a/include/d/d_bg_s_grp_pass_chk.h +++ b/include/d/d_bg_s_grp_pass_chk.h @@ -25,7 +25,6 @@ public: void OnAll() { mGrp |= FULL_GRP; } u32 MaskNormalGrp() { return mGrp & NORMAL_GRP; } u32 MaskWaterGrp() { return mGrp & WATER_GRP; } -private: /* 0x4 */ u32 mGrp; }; diff --git a/include/d/d_bg_s_movebg_actor.h b/include/d/d_bg_s_movebg_actor.h index be09052ee5..bd9e5351b6 100644 --- a/include/d/d_bg_s_movebg_actor.h +++ b/include/d/d_bg_s_movebg_actor.h @@ -35,9 +35,9 @@ public: virtual int ToFore(); virtual int ToBack(); - static const char* m_name; - static int m_dzb_id; - static MoveBGActor_SetFunc m_set_func; + static DUSK_GAME_DATA const char* m_name; + static DUSK_GAME_DATA int m_dzb_id; + static DUSK_GAME_DATA MoveBGActor_SetFunc m_set_func; }; STATIC_ASSERT(sizeof(dBgS_MoveBgActor) == 0x5a0); diff --git a/include/d/d_bg_s_poly_pass_chk.h b/include/d/d_bg_s_poly_pass_chk.h index 6f7778189a..759321c6da 100644 --- a/include/d/d_bg_s_poly_pass_chk.h +++ b/include/d/d_bg_s_poly_pass_chk.h @@ -42,7 +42,6 @@ public: void SetStatue(); void SetUnderwaterRoof(); -private: /* 0x4 */ bool mObject; /* 0x5 */ bool mCamera; /* 0x6 */ bool mLink; diff --git a/include/d/d_bg_s_roof_chk.h b/include/d/d_bg_s_roof_chk.h index 387c05fff2..e404eef0c4 100644 --- a/include/d/d_bg_s_roof_chk.h +++ b/include/d/d_bg_s_roof_chk.h @@ -17,7 +17,6 @@ public: f32 GetNowY() { return mNowY; } cXyz* GetPosP() { return &m_pos; } -private: /* 0x3C */ cXyz m_pos; /* 0x48 */ int field_0x48; /* 0x4C */ f32 mNowY; diff --git a/include/d/d_bg_s_spl_grp_chk.h b/include/d/d_bg_s_spl_grp_chk.h index 447bbf4d73..46df7df35a 100644 --- a/include/d/d_bg_s_spl_grp_chk.h +++ b/include/d/d_bg_s_spl_grp_chk.h @@ -30,7 +30,6 @@ public: cXyz& GetPosP() { return m_ground; } f32 GetRoof() { return m_roof; } -private: /* 0x3C */ cXyz m_ground; /* 0x48 */ f32 m_roof; /* 0x4C */ f32 m_height; diff --git a/include/d/d_bg_w.h b/include/d/d_bg_w.h index 580e22d904..c9692a7c61 100644 --- a/include/d/d_bg_w.h +++ b/include/d/d_bg_w.h @@ -6,9 +6,12 @@ #include "d/d_bg_w_base.h" #include #include -#include "dusk/offset_ptr.h" -#include "dusk/endian.h" -#include "dusk/endian_ssystem.h" + +#if TARGET_PC +#include "helpers/endian.h" +#include "helpers/endian_ssystem.h" +#include "helpers/offset_ptr.h" +#endif class cBgS_GrpPassChk; class cBgS_PolyPassChk; @@ -346,7 +349,6 @@ public: void SetArrowStickCallback(dBgW_ArrowStickCallback func) { m_arrow_stick_callback = func; } void OnMoveFlag() { m_flags |= (u8)1; } -private: /* 0xB0 */ dBgW_CrrFunc m_crr_func; /* 0xB4 */ dBgW_RideCallback m_ride_callback; /* 0xB8 */ dBgW_ArrowStickCallback m_arrow_stick_callback; diff --git a/include/d/d_bg_w_base.h b/include/d/d_bg_w_base.h index 6940df06fa..f30604d2d3 100644 --- a/include/d/d_bg_w_base.h +++ b/include/d/d_bg_w_base.h @@ -124,7 +124,6 @@ public: void OnPushPullOk() { m_pushPull_Ok = true; } void OffPushPullOk() { m_pushPull_Ok = false; } -private: /* 0x08 */ u8 m_priority; /* 0x09 */ u8 m_roomId; /* 0x0A */ u8 field_0xa; diff --git a/include/d/d_bg_w_kcol.h b/include/d/d_bg_w_kcol.h index 1fc812dd98..b0abe32102 100644 --- a/include/d/d_bg_w_kcol.h +++ b/include/d/d_bg_w_kcol.h @@ -6,7 +6,10 @@ #include "d/d_bg_plc.h" #include "d/d_bg_s_sph_chk.h" #include "d/d_bg_w_base.h" -#include "dusk/offset_ptr.h" + +#if TARGET_PC +#include "helpers/offset_ptr.h" +#endif class cBgS_GrpPassChk; class cBgS_PolyPassChk; @@ -117,7 +120,6 @@ public: void getTri1Pos(KC_PrismData* pd, Vec** nrm) const { *nrm = &m_pkc_head->m_pos_data[pd->pos_i]; } -private: /* 0x18 */ KC_Header* m_pkc_head; /* 0x1C */ dBgPlc m_code; /* 0x20 */ cM3dGAab m_bnd; diff --git a/include/d/d_camera.h b/include/d/d_camera.h index f98667d988..6c95d1ce51 100644 --- a/include/d/d_camera.h +++ b/include/d/d_camera.h @@ -1169,7 +1169,7 @@ public: return mCamSetup.Far(); } - static engine_fn engine_tbl[]; + static DUSK_GAME_DATA engine_fn engine_tbl[]; /* 0x000 */ camera_class* field_0x0; #if PARTIAL_DEBUG || DEBUG // Ensure struct layout consistent in all TUs. diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index 19f0430498..739abdcaa4 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -179,7 +179,6 @@ public: cXyz* GetHitPosP() { return &mHitPos; } void ClrHit() { dCcD_GAtTgCoCommonBase::ClrActorInfo(); } - // private: /* 0x1C */ u8 mSe; /* 0x1D */ u8 mMtrl; /* 0x1E */ u8 mHitMark; @@ -215,7 +214,6 @@ public: u8 GetSe() { return mSe; } void ClrHit() { dCcD_GAtTgCoCommonBase::ClrActorInfo(); } -private: /* 0x1C */ u8 mSe; /* 0x1D */ u8 mMtrl; /* 0x1E */ u8 mHitMark; @@ -258,7 +256,6 @@ public: void SetTgSpl(dCcG_Tg_Spl spl) { mTg = spl; } void OnNoActor() { field_0x1C |= 1; } - // private: /* 0x04 */ u8 mAt; /* 0x05 */ u8 mTg; /* 0x06 */ u8 mRoomId; @@ -424,7 +421,7 @@ public: bool ChkTgShieldHit() { return mGObjTg.ChkRPrm(2); } bool ChkTgSpinnerReflect() { return mGObjTg.ChkSPrm(0x200); } - static const Z2SoundID m_hitSeID[24]; + static DUSK_GAME_DATA const Z2SoundID m_hitSeID[24]; protected: /* 0x058 */ dCcD_GObjAt mGObjAt; diff --git a/include/d/d_cc_mass_s.h b/include/d/d_cc_mass_s.h index 672adb913a..291cb4552c 100644 --- a/include/d/d_cc_mass_s.h +++ b/include/d/d_cc_mass_s.h @@ -6,7 +6,7 @@ typedef void (*dCcMassS_ObjCallback)(fopAc_ac_c*, cXyz*, u32); class dCcMassS_Obj { -private: +public: /* 0x00 */ cCcD_Obj* mpObj; /* 0x04 */ u8 mPriority; /* 0x08 */ dCcMassS_ObjCallback mpAreaCheckFunc; @@ -28,7 +28,7 @@ public: STATIC_ASSERT(0x20 == sizeof(dCcMassS_Obj)); class dCcMassS_HitInf { -private: +public: /* 0x00 */ cCcD_Obj* mpArea; /* 0x04 */ cCcD_Obj* mpAtObj; /* 0x08 */ cCcD_Obj* mpCoObj; diff --git a/include/d/d_cc_s.h b/include/d/d_cc_s.h index d156867cce..0ebf4a5265 100644 --- a/include/d/d_cc_s.h +++ b/include/d/d_cc_s.h @@ -75,7 +75,7 @@ public: BOOL ChkLine(cXyz&, cXyz&, f32, fopAc_ac_c**); #endif - static bool m_mtrl_hit_tbl[64]; + static DUSK_GAME_DATA bool m_mtrl_hit_tbl[64]; // /* 0x0000 */ cCcS mCCcS; /* 0x284C */ dCcMassS_Mng mMass_Mng; diff --git a/include/d/d_com_inf_actor.h b/include/d/d_com_inf_actor.h index da5e5fc62f..5ebd30c33c 100644 --- a/include/d/d_com_inf_actor.h +++ b/include/d/d_com_inf_actor.h @@ -14,8 +14,8 @@ public: /* 0x4 */ bool mPause; }; -extern dComIfGoat_info_c g_dComIfGoat_gameInfo; -extern dComIfAc_info_c g_dComIfAc_gameInfo; +DUSK_GAME_EXTERN dComIfGoat_info_c g_dComIfGoat_gameInfo; +DUSK_GAME_EXTERN dComIfAc_info_c g_dComIfAc_gameInfo; inline bool dComIfA_PauseCheck() { return g_dComIfAc_gameInfo.mPause; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index b66c1ee8e8..dcf681162f 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -17,7 +17,10 @@ #include "m_Do/m_Do_graphic.h" #include -#include "dusk/profiling.hpp" +#if defined(DUSK_BUILDING_GAME) +#include +#include "dusk/settings.h" +#endif enum dComIfG_ButtonStatus { /* 0x00 */ BUTTON_STATUS_NONE, @@ -246,7 +249,6 @@ public: ~dComIfG_resLoader_c(); int load(char const**, JKRHeap*); -private: /* 0x0 */ const char** mResNameTable; /* 0x4 */ request_of_phase_process_class mPhase; /* 0xC */ u8 mLoadIndex; @@ -1049,11 +1051,11 @@ public: STATIC_ASSERT(122384 == sizeof(dComIfG_inf_c)); -extern dComIfG_inf_c g_dComIfG_gameInfo; -extern GXColor g_blackColor; -extern GXColor g_clearColor; -extern GXColor g_whiteColor; -extern GXColor g_saftyWhiteColor; +DUSK_GAME_EXTERN dComIfG_inf_c g_dComIfG_gameInfo; +DUSK_GAME_EXTERN GXColor g_blackColor; +DUSK_GAME_EXTERN GXColor g_clearColor; +DUSK_GAME_EXTERN GXColor g_whiteColor; +DUSK_GAME_EXTERN GXColor g_saftyWhiteColor; int dComLbG_PhaseHandler(request_of_phase_process_class*, request_of_phase_process_fn*, void*); @@ -1268,6 +1270,938 @@ int dComIfGd_setShadow(u32 param_0, s8 param_1, J3DModel* param_2, cXyz* param_3 f32 param_5, f32 param_6, f32 param_7, cBgS_PolyInfo& param_8, dKy_tevstr_c* param_9, s16 param_10, f32 param_11, TGXTexObj* param_12); +#if TARGET_PC +DUSK_NOINLINE dSv_info_c* dComIfGs_getSaveInfo(); +DUSK_NOINLINE dSv_save_c* dComIfGs_getSaveData(); +DUSK_NOINLINE u16 dComIfGs_getMaxLife(); +DUSK_NOINLINE void dComIfGs_setMaxLife(u8 i_maxLife); +DUSK_NOINLINE u16 dComIfGs_getLife(); +DUSK_NOINLINE void dComIfGs_setLife(u16 i_life); +DUSK_NOINLINE u16 dComIfGs_getRupee(); +DUSK_NOINLINE void dComIfGs_setRupee(u16 i_rupees); +DUSK_NOINLINE u16 dComIfGs_getMaxOil(); +DUSK_NOINLINE void dComIfGs_setMaxOil(u16 i_maxOil); +DUSK_NOINLINE u16 dComIfGs_getOil(); +DUSK_NOINLINE void dComIfGs_setOil(u16 i_oil); +DUSK_NOINLINE u8 dComIfGs_getSelectEquipClothes(); +DUSK_NOINLINE u8 dComIfGs_getSelectEquipSword(); +DUSK_NOINLINE u8 dComIfGs_getSelectEquipShield(); +DUSK_NOINLINE u8 dComIfGs_getCollectSmell(); +DUSK_NOINLINE void dComIfGs_setCollectSmell(u8 smell); +DUSK_NOINLINE u8 dComIfGs_getBButtonItemKey(); +DUSK_NOINLINE void dComIfGs_setBButtonItemKey(u8 i_itemNo); +DUSK_NOINLINE u8 dComIfGs_getWalletSize(); +DUSK_NOINLINE void dComIfGs_setWalletSize(u8 i_size); +DUSK_NOINLINE u8 dComIfGs_getMaxMagic(); +DUSK_NOINLINE void dComIfGs_setMaxMagic(u8 i_maxMagic); +DUSK_NOINLINE u8 dComIfGs_getMagic(); +DUSK_NOINLINE void dComIfGs_setMagic(u8 i_magic); +DUSK_NOINLINE u8 dComIfGs_getTransformStatus(); +DUSK_NOINLINE void dComIfGs_setTransformStatus(u8 i_status); +DUSK_NOINLINE u8 dComIfGs_getSelectItemIndex(int i_no); +DUSK_NOINLINE u16 dComIfGs_getRupeeMax(); +DUSK_NOINLINE void dComIfGs_offGetMagicUseFlag(); +DUSK_NOINLINE s32 dComIfGs_isGetMagicUseFlag(); +DUSK_NOINLINE f32 dComIfGs_getTime(); +DUSK_NOINLINE void dComIfGs_setTime(f32 i_time); +DUSK_NOINLINE u16 dComIfGs_getDate(); +DUSK_NOINLINE void dComIfGs_setDate(u16 i_date); +DUSK_NOINLINE void dComIfGs_onDarkClearLV(int i_no); +DUSK_NOINLINE void dComIfGs_offDarkClearLV(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isDarkClearLV(int i_no); +DUSK_NOINLINE void dComIfGs_onTransformLV(int i_no); +DUSK_NOINLINE void dComIfGs_offTransformLV(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isTransformLV(int i_no); +DUSK_NOINLINE cXyz dComIfGs_getHorseRestartPos(); +DUSK_NOINLINE s16 dComIfGs_getHorseRestartAngleY(); +DUSK_NOINLINE const char* dComIfGs_getHorseRestartStageName(); +DUSK_NOINLINE s8 dComIfGs_getHorseRestartRoomNo(); +DUSK_NOINLINE void dComIfGs_setHorseRestart( + const char* i_stageName, cXyz& i_pos, s16 i_angle, s8 i_roomNo); +DUSK_NOINLINE cXyz dComIfGs_getPlayerFieldLastStayPos(); +DUSK_NOINLINE s16 dComIfGs_getPlayerFieldLastStayAngleY(); +DUSK_NOINLINE char* dComIfGs_getPlayerFieldLastStayName(); +DUSK_NOINLINE u8 dComIfGs_getPlayerFieldLastStayRegionNo(); +DUSK_NOINLINE bool dComIfGs_isPlayerFieldLastStayFieldDataExistFlag(); +DUSK_NOINLINE void dComIfGs_offPlayerFieldLastStayFieldDataExistFlag(); +DUSK_NOINLINE void dComIfGs_onPlayerFieldLastStayFieldDataExistFlag(); +DUSK_NOINLINE BOOL dComIfGs_isRegionBit(int i_region); +DUSK_NOINLINE void dComIfGs_onRegionBit(int i_region); +DUSK_NOINLINE void dComIfGs_setPlayerFieldLastStayInfo( + const char* i_stage, cXyz& i_pos, s16 i_angle, s8 i_point, u8 i_region); +DUSK_NOINLINE cXyz dComIfGs_getLastWarpMarkPlayerPos(); +DUSK_NOINLINE s16 dComIfGs_getLastWarpMarkPlayerAngleY(); +DUSK_NOINLINE const char* dComIfGs_getLastWarpMarkStageName(); +DUSK_NOINLINE u8 dComIfGs_getLastWarpMarkRoomNo(); +DUSK_NOINLINE s8 dComIfGs_getLastWarpAcceptStage(); +DUSK_NOINLINE void dComIfGs_setLastWarpAcceptStage(s8 param_0); +DUSK_NOINLINE void dComIfGs_resetLastWarpAcceptStage(); +DUSK_NOINLINE void dComIfGs_setItem(int i_slotNo, u8 i_itemNo); +DUSK_NOINLINE u8 dComIfGs_getItem(int i_slotNo, bool i_checkCombo); +DUSK_NOINLINE void dComIfGs_setLineUpItem(); +DUSK_NOINLINE u8 dComIfGs_getLineUpItem(int i_slotNo); +DUSK_NOINLINE void dComIfGs_setBottleItemIn(u8 curItem, u8 newItem); +DUSK_NOINLINE void dComIfGs_setEmptyBottleItemIn(u8 i_itemNo); +DUSK_NOINLINE void dComIfGs_setEmptyBottle(); +DUSK_NOINLINE void dComIfGs_setEmptyBottle(u8 i_itemNo); +DUSK_NOINLINE void dComIfGs_setEquipBottleItemIn(u8 i_curItem, u8 i_newItem); +DUSK_NOINLINE void dComIfGs_setEquipBottleItemEmpty(u8 i_curItem); +DUSK_NOINLINE u8 dComIfGs_checkBottle(u8 i_itemNo); +DUSK_NOINLINE u8 dComIfGs_checkInsectBottle(); +DUSK_NOINLINE u8 dComIfGs_checkEmptyBottle(); +DUSK_NOINLINE void dComIfGs_setEmptyBombBagItemIn(u8 i_newBomb, bool i_setNum); +DUSK_NOINLINE void dComIfGs_setEmptyBombBagItemIn(u8 i_newBomb, u8 i_bombNum, bool i_setNum); +DUSK_NOINLINE void dComIfGs_setEmptyBombBag(); +DUSK_NOINLINE void dComIfGs_setEmptyBombBag(u8 i_newBomb, u8 i_bombNum); +DUSK_NOINLINE u8 dComIfGs_checkBombBag(u8 i_itemNo); +DUSK_NOINLINE void dComIfGs_setWarashibeItem(u8 i_itemNo); +DUSK_NOINLINE void dComIfGs_setRodTypeLevelUp(); +DUSK_NOINLINE void dComIfGs_setBaitItem(u8 i_item); +DUSK_NOINLINE void dComIfGs_onItemFirstBit(u8 i_itemNo); +DUSK_NOINLINE void dComIfGs_offItemFirstBit(u8 i_itemNo); +DUSK_NOINLINE int dComIfGs_isItemFirstBit(u8 i_no); +DUSK_NOINLINE u8 dComIfGs_getArrowNum(); +DUSK_NOINLINE void dComIfGs_setArrowNum(u8 i_arrowNum); +DUSK_NOINLINE u8 dComIfGs_getPachinkoNum(); +DUSK_NOINLINE void dComIfGs_setPachinkoNum(u8 i_num); +DUSK_NOINLINE u8 dComIfGs_getPachinkoMax(); +DUSK_NOINLINE void dComIfGs_setBombNum(u8 i_num); +DUSK_NOINLINE void dComIfGs_setBombNum(u8 i_bagIdx, u8 i_bombNum); +DUSK_NOINLINE u8 dComIfGs_getBombNum(u8 i_bagIdx); +DUSK_NOINLINE void dComIfGs_setBottleNum(u8 i_bottleIdx, u8 i_bottleNum); +DUSK_NOINLINE void dComIfGs_addBottleNum(u8 i_bottleIdx, s16 i_num); +DUSK_NOINLINE u8 dComIfGs_getBottleNum(u8 i_bottleIdx); +DUSK_NOINLINE u8 dComIfGs_getArrowMax(); +DUSK_NOINLINE void dComIfGs_setArrowMax(u8 i_arrowMax); +DUSK_NOINLINE void dComIfGs_setBombMax(u8 i_max); +DUSK_NOINLINE void dComIfGs_setBombMax(u8 i_type, u8 i_max); +DUSK_NOINLINE u8 dComIfGs_getBombMax(); +DUSK_NOINLINE u8 dComIfGs_getBombMax(u8 i_bombType); +DUSK_NOINLINE void dComIfGs_setPohSpiritNum(u8 i_num); +DUSK_NOINLINE u8 dComIfGs_getPohSpiritNum(); +DUSK_NOINLINE void dComIfGs_addPohSpiritNum(); +DUSK_NOINLINE BOOL dComIfGs_isCollectClothes(u8 i_clothesNo); +DUSK_NOINLINE void dComIfGs_setCollectClothes(u8 i_clothesNo); +DUSK_NOINLINE void dComIfGs_setCollectSword(u8 i_swordNo); +DUSK_NOINLINE void dComIfGs_setCollectShield(u8 i_shieldNo); +DUSK_NOINLINE BOOL dComIfGs_isCollectClothing(u8 i_clothesNo); +DUSK_NOINLINE void dComIfGs_offCollectClothes(u8 i_clothesNo); +DUSK_NOINLINE BOOL dComIfGs_isCollectSword(u8 i_swordNo); +DUSK_NOINLINE void dComIfGs_offCollectSword(u8 i_swordNo); +DUSK_NOINLINE BOOL dComIfGs_isCollectShield(u8 i_item); +DUSK_NOINLINE void dComIfGs_offCollectShield(u8 i_shieldNo); +DUSK_NOINLINE void dComIfGs_onCollectCrystal(u8 i_item); +DUSK_NOINLINE void dComIfGs_offCollectCrystal(u8 i_item); +DUSK_NOINLINE bool dComIfGs_isCollectCrystal(u8 i_item); +DUSK_NOINLINE void dComIfGs_onCollectMirror(u8 i_item); +DUSK_NOINLINE void dComIfGs_offCollectMirror(u8 i_item); +DUSK_NOINLINE bool dComIfGs_isCollectMirror(u8 i_item); +DUSK_NOINLINE void dComIfGs_setLightDropNum(u8 i_level, u8 i_num); +DUSK_NOINLINE u8 dComIfGs_getLightDropNum(u8 i_nowLevel); +DUSK_NOINLINE void dComIfGs_onLightDropGetFlag(u8 i_nowLevel); +DUSK_NOINLINE void dComIfGs_offLightDropGetFlag(u8 i_level); +DUSK_NOINLINE BOOL dComIfGs_isLightDropGetFlag(u8 i_nowLevel); +DUSK_NOINLINE void dComIfGs_onLetterGetFlag(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isLetterGetFlag(int i_no); +DUSK_NOINLINE void dComIfGs_onLetterReadFlag(int i_no); +DUSK_NOINLINE int dComIfGs_isLetterReadFlag(int i_no); +DUSK_NOINLINE u8 dComIfGs_getGetNumber(int i_no); +DUSK_NOINLINE void dComIfGs_setGetNumber(int i_no, u8 i_value); +DUSK_NOINLINE void dComIfGs_addFishNum(u8 param_0); +DUSK_NOINLINE u16 dComIfGs_getFishNum(u8 param_0); +DUSK_NOINLINE u8 dComIfGs_getFishSize(u8 param_0); +DUSK_NOINLINE void dComIfGs_setFishSize(u8 param_0, u8 param_1); +DUSK_NOINLINE OSTime dComIfGs_getTotalTime(); +DUSK_NOINLINE void dComIfGs_addDeathCount(); +DUSK_NOINLINE u16 dComIfGs_getDeathCount(); +DUSK_NOINLINE TEXT_SPAN dComIfGs_getPlayerName(); +DUSK_NOINLINE void dComIfGs_setPlayerName(const char* i_name); +DUSK_NOINLINE TEXT_SPAN dComIfGs_getHorseName(); +DUSK_NOINLINE void dComIfGs_setHorseName(const char* i_name); +DUSK_NOINLINE u8 dComIfGs_getClearCount(); + +// Ruby inline names are from TWW debug. +DUSK_NOINLINE u8 dComIfGs_getOptRuby(); +DUSK_NOINLINE void dComIfGs_setOptRuby(u8 i_ruby); +DUSK_NOINLINE u8 dComIfGs_getOptAttentionType(); +DUSK_NOINLINE void dComIfGs_setOptAttentionType(u8 i_attentionType); +DUSK_NOINLINE void dComIfGs_setOptCalibrateDist(u16 i_calibrateDist); +DUSK_NOINLINE void dComIfGs_setOptCalValue(s8 i_calValue); +DUSK_NOINLINE u8 dComIfGs_getOptCameraControl(); +DUSK_NOINLINE void dComIfGs_setOptCameraControl(u8 i_cameraControl); +DUSK_NOINLINE u8 dComIfGs_getOptPointer(); +DUSK_NOINLINE void dComIfGs_setOptPointer(u8 i_pointer); +DUSK_NOINLINE u8 dComIfGs_checkOptVibration(); +DUSK_NOINLINE u8 dComIfGs_getOptSound(); +DUSK_NOINLINE void dComIfGs_setOptSound(u8 i_mode); +DUSK_NOINLINE u8 dComIfGs_getOptVibration(); +DUSK_NOINLINE void dComIfGs_setOptVibration(u8 i_status); +DUSK_NOINLINE u8 dComIfGs_getPalLanguage(); +DUSK_NOINLINE BOOL dComIfGs_isSaveTbox(int i_stageNo, int i_no); +DUSK_NOINLINE void dComIfGs_onSaveSwitch(int i_stageNo, int i_no); +DUSK_NOINLINE void dComIfGs_offSaveSwitch(int i_stageNo, int i_no); +DUSK_NOINLINE BOOL dComIfGs_isSaveSwitch(int i_stageNo, int i_no); +DUSK_NOINLINE void dComIfGs_onSaveVisitedRoom(int param_0, int i_roomNo); +DUSK_NOINLINE void dComIfGs_offSaveVisitedRoom(int param_0, int i_roomNo); +DUSK_NOINLINE BOOL dComIfGs_isSaveVisitedRoom(int param_0, int i_roomNo); +DUSK_NOINLINE void* dComIfGs_getPEventBit(); +DUSK_NOINLINE void dComIfGs_onEventBit(const u16 i_flag); +DUSK_NOINLINE void dComIfGs_offEventBit(const u16 i_flag); +DUSK_NOINLINE BOOL dComIfGs_isEventBit(const u16 i_flag); +DUSK_NOINLINE void dComIfGs_setEventReg(u16 reg, u8 value); +DUSK_NOINLINE u8 dComIfGs_getEventReg(u16 reg); +DUSK_NOINLINE int dComIfGs_getHookGameTime(); +DUSK_NOINLINE void dComIfGs_setHookGameTime(u32 i_time); +DUSK_NOINLINE u32 dComIfGs_getBalloonScore(); +DUSK_NOINLINE void dComIfGs_setBalloonScore(u32 i_score); +DUSK_NOINLINE int dComIfGs_getRaceGameTime(); +DUSK_NOINLINE void dComIfGs_setRaceGameTime(int i_time); +DUSK_NOINLINE u8 dComIfGs_getKeyNum(); +DUSK_NOINLINE void dComIfGs_setKeyNum(u8 i_keyNum); +DUSK_NOINLINE void dComIfGs_onDungeonItemMap(); +DUSK_NOINLINE void dComIfGs_offDungeonItemMap(); +DUSK_NOINLINE s32 dComIfGs_isDungeonItemMap(); +DUSK_NOINLINE void dComIfGs_onDungeonItemCompass(); +DUSK_NOINLINE void dComIfGs_offDungeonItemCompass(); +DUSK_NOINLINE s32 dComIfGs_isDungeonItemCompass(); +DUSK_NOINLINE void dComIfGs_onDungeonItemBossKey(); +DUSK_NOINLINE void dComIfGs_offDungeonItemBossKey(); +DUSK_NOINLINE s32 dComIfGs_isDungeonItemBossKey(); +DUSK_NOINLINE void dComIfGs_onStageBossEnemy(); +DUSK_NOINLINE void dComIfGs_offStageBossEnemy(); +DUSK_NOINLINE s32 dComIfGs_isStageBossEnemy(); +DUSK_NOINLINE void dComIfGs_onStageLife(); +DUSK_NOINLINE void dComIfGs_offStageLife(); +DUSK_NOINLINE s32 dComIfGs_isStageLife(); +DUSK_NOINLINE void dComIfGs_onStageBossDemo(); +DUSK_NOINLINE void dComIfGs_offStageBossDemo(); +DUSK_NOINLINE s32 dComIfGs_isStageBossDemo(); +DUSK_NOINLINE void dComIfGs_onDungeonItemWarp(); +DUSK_NOINLINE void dComIfGs_offDungeonItemWarp(); +DUSK_NOINLINE s32 dComIfGs_isDungeonItemWarp(); +DUSK_NOINLINE void dComIfGs_onStageMiddleBoss(); +DUSK_NOINLINE void dComIfGs_offStageMiddleBoss(); +DUSK_NOINLINE BOOL dComIfGs_isStageMiddleBoss(); +DUSK_NOINLINE void dComIfGs_onTbox(int i_no); +DUSK_NOINLINE void dComIfGs_offTbox(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isTbox(int i_no); +DUSK_NOINLINE void dComIfGs_onSaveSwitch(int i_no); +DUSK_NOINLINE void dComIfGs_offSaveSwitch(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isSaveSwitch(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isSaveItem(int i_no); +DUSK_NOINLINE void dComIfGs_onSaveDunSwitch(int i_swNo); +DUSK_NOINLINE void dComIfGs_offSaveDunSwitch(int i_swNo); +DUSK_NOINLINE BOOL dComIfGs_isSaveDunSwitch(int i_no); +DUSK_NOINLINE BOOL dComIfGs_isSaveDunItem(int i_no); +DUSK_NOINLINE void dComIfGs_resetDan(); +DUSK_NOINLINE void dComIfGs_initDan(s8 i_stageNo); +DUSK_NOINLINE void dComIfGs_clearRoomSwitch(int i_zoneNo); +DUSK_NOINLINE void dComIfGs_clearRoomItem(int i_zoneNo); +DUSK_NOINLINE void dComIfGs_onSvZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_offSvZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE BOOL dComIfGs_isSvZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_onSvOneZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_offSvOneZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE BOOL dComIfGs_isSvOneZoneSwitch(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_onSvZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_offSvZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE BOOL dComIfGs_isSvZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_onSvOneZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_offSvOneZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE BOOL dComIfGs_isSvOneZoneItem(int i_zoneNo, int i_swBit); +DUSK_NOINLINE void dComIfGs_removeZone(int i_zoneNo); +DUSK_NOINLINE s8 dComIfGs_getRestartRoomNo(); +DUSK_NOINLINE s16 dComIfGs_getStartPoint(); +DUSK_NOINLINE void dComIfGs_setStartPoint(s16 i_point); +DUSK_NOINLINE s16 dComIfGs_getRestartRoomAngleY(); +DUSK_NOINLINE const cXyz& dComIfGs_getRestartRoomPos(); +DUSK_NOINLINE u32 dComIfGs_getRestartRoomParam(); +DUSK_NOINLINE void dComIfGs_setRestartRoomParam(u32 i_param); +DUSK_NOINLINE f32 dComIfGs_getLastSceneSpeedF(); +DUSK_NOINLINE u32 dComIfGs_getLastSceneMode(); +DUSK_NOINLINE s16 dComIfGs_getLastSceneAngleY(); +DUSK_NOINLINE void dComIfGs_setRestartRoom(const cXyz& i_position, s16 i_angle, s8 i_roomNo); +DUSK_NOINLINE void dComIfGs_onTmpBit(const u16 i_flag); +DUSK_NOINLINE void dComIfGs_offTmpBit(const u16 i_flag); +DUSK_NOINLINE BOOL dComIfGs_isTmpBit(const u16 i_flag); +DUSK_NOINLINE void dComIfGs_setTmpReg(u16 i_reg, u8 i_no); +DUSK_NOINLINE u8 dComIfGs_getTmpReg(const u16 i_reg); +DUSK_NOINLINE dSv_turnRestart_c& dComIfGs_getTurnRestart(); +DUSK_NOINLINE const cXyz& dComIfGs_getTurnRestartPos(); +DUSK_NOINLINE u32 dComIfGs_getTurnRestartParam(); +DUSK_NOINLINE s16 dComIfGs_getTurnRestartAngleY(); +DUSK_NOINLINE s8 dComIfGs_getTurnRestartRoomNo(); +DUSK_NOINLINE void dComIfGs_setTurnRestart( + const cXyz& i_position, s16 i_angle, s8 param_2, u32 i_param); +DUSK_NOINLINE u8 dComIfGs_getDataNum(); +DUSK_NOINLINE void dComIfGs_setDataNum(u8 i_num); +DUSK_NOINLINE u8 dComIfGs_getNewFile(); +DUSK_NOINLINE void dComIfGs_setNewFile(u8 i_fileNo); +DUSK_NOINLINE u8 dComIfGs_getNoFile(); +DUSK_NOINLINE void dComIfGs_setNoFile(u8 i_file); +DUSK_NOINLINE s64 dComIfGs_getSaveStartTime(); +DUSK_NOINLINE void dComIfGs_setSaveStartTime(s64 i_time); +DUSK_NOINLINE s64 dComIfGs_getSaveTotalTime(); +DUSK_NOINLINE void dComIfGs_setSaveTotalTime(s64 i_time); +DUSK_NOINLINE void dComIfGs_init(); +DUSK_NOINLINE void dComIfGs_getSave(int i_stageNo); +DUSK_NOINLINE void dComIfGs_putSave(int i_stageNo); +DUSK_NOINLINE void dComIfGs_initZone(); +DUSK_NOINLINE int dComIfGs_createZone(int roomNo); +DUSK_NOINLINE void dComIfGs_onSwitch(int i_no, int i_roomNo); +DUSK_NOINLINE void dComIfGs_offSwitch(int i_no, int i_roomNo); +DUSK_NOINLINE BOOL dComIfGs_isSwitch(int i_no, int i_roomNo); +DUSK_NOINLINE void dComIfGs_revSwitch(int i_no, int i_roomNo); +DUSK_NOINLINE void dComIfGs_onItem(int i_bitNo, int i_roomNo); +DUSK_NOINLINE bool dComIfGs_isItem(int i_bitNo, int i_roomNo); +DUSK_NOINLINE void dComIfGs_onActor(int i_bitNo, int i_roomNo); +DUSK_NOINLINE void dComIfGs_offActor(int i_no, int i_roomNo); +DUSK_NOINLINE BOOL dComIfGs_isActor(int i_no, int i_roomNo); +DUSK_NOINLINE void dComIfGs_setMemoryToCard(u8* i_saveData, int i_dataNum); +DUSK_NOINLINE void dComIfGs_setCardToMemory(u8* card_ptr, int dataNum); +DUSK_NOINLINE void dComIfGs_setInitDataToCard(u8* i_saveData, int i_dataNum); +DUSK_NOINLINE u8 dComIfGs_getWolfAbility(int i_idx); +DUSK_NOINLINE s8 dComIfGs_Grass_hide_Check(); +DUSK_NOINLINE dStage_startStage_c* dComIfGp_getStartStage(); +DUSK_NOINLINE void dComIfGp_setStartStage(dStage_startStage_c* p_startStage); +DUSK_NOINLINE const char* dComIfGp_getStartStageName(); +DUSK_NOINLINE s16 dComIfGp_getStartStagePoint(); +DUSK_NOINLINE s8 dComIfGp_getStartStageRoomNo(); +DUSK_NOINLINE s8 dComIfGp_getStartStageLayer(); +DUSK_NOINLINE void dComIfGp_setStartStageLayer(s8 layer); +DUSK_NOINLINE s8 dComIfGp_getStartStageDarkArea(); +DUSK_NOINLINE void dComIfGp_setStartStageDarkArea(s8 darkArea); +DUSK_NOINLINE dStage_startStage_c* dComIfGp_getNextStartStage(); +DUSK_NOINLINE const char* dComIfGp_getNextStageName(); +DUSK_NOINLINE s16 dComIfGp_getNextStagePoint(); +DUSK_NOINLINE s16 dComIfGp_getNextStageRoomNo(); +DUSK_NOINLINE s16 dComIfGp_getNextStageLayer(); +DUSK_NOINLINE BOOL dComIfGp_isEnableNextStage(); +DUSK_NOINLINE void dComIfGp_offEnableNextStage(); +DUSK_NOINLINE s8 dComIfGp_getNextStageWipe(); +DUSK_NOINLINE u8 dComIfGp_getNextStageWipeSpeed(); +DUSK_NOINLINE dStage_stageDt_c* dComIfGp_getStage(); +DUSK_NOINLINE roomRead_class* dComIfGp_getStageRoom(); +DUSK_NOINLINE stage_palette_info_class* dComIfGp_getStagePaletteInfo(); +DUSK_NOINLINE stage_pselect_info_class* dComIfGp_getStagePselectInfo(); +DUSK_NOINLINE stage_envr_info_class* dComIfGp_getStageEnvrInfo(); +DUSK_NOINLINE stage_vrboxcol_info_class* dComIfGp_getStageVrboxcolInfo(); +DUSK_NOINLINE stage_plight_info_class* dComIfGp_getStagePlightInfo(); +DUSK_NOINLINE int dComIfGp_getStagePaletteNumInfo(); +DUSK_NOINLINE int dComIfGp_getStagePselectNumInfo(); +DUSK_NOINLINE int dComIfGp_getStageEnvrNumInfo(); +DUSK_NOINLINE int dComIfGp_getStageVrboxcolNumInfo(); +DUSK_NOINLINE int dComIfGp_getStagePlightNumInfo(); +DUSK_NOINLINE stage_stag_info_class* dComIfGp_getStageStagInfo(); +DUSK_NOINLINE stage_scls_info_dummy_class* dComIfGp_getStageSclsInfo(); +DUSK_NOINLINE dStage_Multi_c* dComIfGp_getMulti(); +DUSK_NOINLINE void dComIfGp_setOldMulti(); +DUSK_NOINLINE void dComIfGp_resetOldMulti(); +DUSK_NOINLINE s16 dComIfGp_getStageWorldRollAngleX(); +DUSK_NOINLINE s16 dComIfGp_getStageWorldRollDirAngleY(); +DUSK_NOINLINE int dComIfGp_roomControl_getStayNo(); +DUSK_NOINLINE BOOL dComIfGp_roomControl_getTimePass(); +DUSK_NOINLINE void dComIfGp_roomControl_setTimePass(int isPassing); +DUSK_NOINLINE dKy_tevstr_c* dComIfGp_roomControl_getTevStr(int i_roomNo); +DUSK_NOINLINE void dComIfGp_roomControl_setStatusFlag(int i_roomNo, u8 flag); +DUSK_NOINLINE void dComIfGp_roomControl_onStatusFlag(int i_roomNo, u8 flag); +DUSK_NOINLINE void dComIfGp_roomControl_offStatusFlag(int i_roomNo, u8 flag); +DUSK_NOINLINE u8 dComIfGp_roomControl_checkStatusFlag(int i_roomNo, u8 flag); +DUSK_NOINLINE s32 dComIfGp_roomControl_getZoneNo(int i_roomNo); +DUSK_NOINLINE void dComIfGp_roomControl_setZoneNo(int roomNo, int zoneNo); +DUSK_NOINLINE void dComIfGp_roomControl_init(); +DUSK_NOINLINE void dComIfGp_roomControl_initZone(); +DUSK_NOINLINE dStage_roomDt_c* dComIfGp_roomControl_getStatusRoomDt(int room_no); +DUSK_NOINLINE void dComIfGp_roomControl_setStayNo(int stayNo); +DUSK_NOINLINE BOOL dComIfGp_roomControl_checkRoomDisp(int i_roomNo); +DUSK_NOINLINE int dComIfGp_roomControl_loadRoom(int param_0, u8* param_1, bool param_2); +DUSK_NOINLINE void dComIfGp_roomControl_zoneCountCheck(int i_roomNo); +DUSK_NOINLINE dEvt_control_c* dComIfGp_getEvent(); +DUSK_NOINLINE u16 dComIfGp_event_chkEventFlag(u16 i_flag); +DUSK_NOINLINE void dComIfGp_event_onEventFlag(u16 i_flag); +DUSK_NOINLINE void dComIfGp_event_onHindFlag(u16 i_flag); +DUSK_NOINLINE void dComIfGp_event_offHindFlag(u16 i_flag); +DUSK_NOINLINE u8 dComIfGp_event_getMode(); +DUSK_NOINLINE BOOL dComIfGp_event_runCheck(); +DUSK_NOINLINE u16 dComIfGp_event_checkHind(u16 i_hindFlag); +DUSK_NOINLINE BOOL dComIfGp_event_chkTalkXY(); +DUSK_NOINLINE u8 dComIfGp_event_getPreItemNo(); +DUSK_NOINLINE f32 dComIfGp_event_getCullRate(); +DUSK_NOINLINE void dComIfGp_event_setCullRate(f32 i_rate); +DUSK_NOINLINE int dComIfGp_event_order(u16 i_type, u16 i_prio, u16 i_flags, u16 i_hindFlags, + void* i_requestActor, void* i_targetActor, s16 i_eventID, u8 i_mapToolId); +DUSK_NOINLINE void dComIfGp_event_reset(); +DUSK_NOINLINE int dComIfGp_event_moveApproval(void* i_actor); +DUSK_NOINLINE BOOL dComIfGp_event_compulsory( + void* i_actor, const char* i_eventname, u16 i_hindFlag); +DUSK_NOINLINE void dComIfGp_event_remove(); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_event_getPt1(); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_event_getPt2(); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_event_getTalkPartner(); +DUSK_NOINLINE void dComIfGp_event_setTalkPartner(void* i_actor); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_event_getItemPartner(); +DUSK_NOINLINE void dComIfGp_event_setItemPartner(void* i_actor); +DUSK_NOINLINE void dComIfGp_event_setItemPartnerId(fpc_ProcID i_id); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_event_getDoorPartner(); +DUSK_NOINLINE void dComIfGp_event_setDoorPartner(void* i_partner); +DUSK_NOINLINE u8 dComIfGp_event_getGtItm(); +DUSK_NOINLINE void dComIfGp_event_setGtItm(u8 i_itemNo); +DUSK_NOINLINE dEvent_manager_c& dComIfGp_getEventManager(); +DUSK_NOINLINE dEvent_manager_c* dComIfGp_getPEvtManager(); +DUSK_NOINLINE int dComIfGp_evmng_cameraPlay(); +DUSK_NOINLINE int dComIfGp_evmng_startDemo(int i_mapToolId); +DUSK_NOINLINE void dComIfGp_evmng_create(); +DUSK_NOINLINE void dComIfGp_evmng_remove(); +DUSK_NOINLINE bool dComIfGp_evmng_existence(s16 eventId); +DUSK_NOINLINE s16 dComIfGp_evmng_getEventIdx(const char* eventName, u8 mapToolID); +DUSK_NOINLINE bool dComIfGp_evmng_existence(const char* eventname); +DUSK_NOINLINE BOOL dComIfGp_evmng_isMapToolCamera(u8 mapToolID); +DUSK_NOINLINE BOOL dComIfGp_evmng_startCheck(s16 i_eventId); +DUSK_NOINLINE BOOL dComIfGp_evmng_startCheck(char const* i_eventname); +DUSK_NOINLINE BOOL dComIfGp_evmng_endCheck(s16 i_eventID); +DUSK_NOINLINE BOOL dComIfGp_evmng_endCheck(const char* i_eventname); +DUSK_NOINLINE int dComIfGp_evmng_getMyStaffId( + const char* i_staffname, fopAc_ac_c* i_actor, int i_tagId); +DUSK_NOINLINE int dComIfGp_evmng_getIsAddvance(int i_staffId); +DUSK_NOINLINE int dComIfGp_evmng_getMyActIdx(int i_staffId, DUSK_CONST char* DUSK_CONST* i_actions, + int i_actionNum, BOOL param_3, BOOL param_4); +DUSK_NOINLINE f32* dComIfGp_evmng_getMyFloatP(int i_staffId, DUSK_CONST char* i_dataname); +DUSK_NOINLINE cXyz* dComIfGp_evmng_getMyXyzP(int i_staffId, DUSK_CONST char* i_dataname); +DUSK_NOINLINE int* dComIfGp_evmng_getMyIntegerP(int i_staffId, DUSK_CONST char* i_dataname); +DUSK_NOINLINE char* dComIfGp_evmng_getMyStringP(int i_staffId, DUSK_CONST char* i_dataname); +DUSK_NOINLINE int dComIfGp_evmng_getMySubstanceNum(int i_staffId, DUSK_CONST char* i_dataname); +DUSK_NOINLINE void dComIfGp_evmng_cutEnd(int i_staffId); +DUSK_NOINLINE void dComIfGp_evmng_setGoal(cXyz* i_pos); +DUSK_NOINLINE cXyz* dComIfGp_evmng_getGoal(); +DUSK_NOINLINE BOOL dComIfGp_evmng_ChkPresentEnd(); +DUSK_NOINLINE int dComIfGp_evmng_checkStartDemo(); +DUSK_NOINLINE dAttention_c* dComIfGp_getAttention(); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_att_getZHint(); +DUSK_NOINLINE int dComIfGp_att_ZHintRequest(fopAc_ac_c* param_1, int param_2); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_att_getCatghTarget(); +DUSK_NOINLINE u8 dComIfGp_att_getCatchChgItem(); +DUSK_NOINLINE int dComIfGp_att_CatchRequest(fopAc_ac_c* param_0, u8 param_1, f32 i_horizontalDist, + f32 i_upDist, f32 i_downDist, s16 i_angle, int param_5); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_att_getLookTarget(); +DUSK_NOINLINE void dComIfGp_att_LookRequest(fopAc_ac_c* param_0, f32 i_horizontalDist, f32 i_upDist, + f32 i_downDist, s16 i_angle, int param_5); +DUSK_NOINLINE dVibration_c& dComIfGp_getVibration(); +DUSK_NOINLINE JKRAramArchive* dComIfGp_getFieldMapArchive2(); +DUSK_NOINLINE void dComIfGp_setFieldMapArchive2(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getMsgArchive(int idx); +DUSK_NOINLINE void dComIfGp_setMsgArchive(int i, JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getDemoMsgArchive(); +DUSK_NOINLINE void dComIfGp_setDemoMsgArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getMeterButtonArchive(); +DUSK_NOINLINE void dComIfGp_setMeterButtonArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getFontArchive(); +DUSK_NOINLINE void dComIfGp_setFontArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getRubyArchive(); +DUSK_NOINLINE void dComIfGp_setRubyArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getAnmArchive(); +DUSK_NOINLINE void dComIfGp_setAnmArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getCollectResArchive(); +DUSK_NOINLINE void dComIfGp_setCollectResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getFmapResArchive(); +DUSK_NOINLINE void dComIfGp_setFmapResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getDmapResArchive(); +DUSK_NOINLINE void dComIfGp_setDmapResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getOptionResArchive(); +DUSK_NOINLINE void dComIfGp_setOptionResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getItemIconArchive(); +DUSK_NOINLINE void dComIfGp_setItemIconArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getNameResArchive(); +DUSK_NOINLINE void dComIfGp_setNameResArchive(JKRArchive* arc); +DUSK_NOINLINE void dComIfGp_setErrorResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getAllMapArchive(); +DUSK_NOINLINE void dComIfGp_setAllMapArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getMsgCommonArchive(); +DUSK_NOINLINE void dComIfGp_setMsgCommonArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getRingResArchive(); +DUSK_NOINLINE void dComIfGp_setRingResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getCardIconResArchive(); +DUSK_NOINLINE void dComIfGp_setCardIconResArchive(JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getMsgDtArchive(); +DUSK_NOINLINE JKRArchive* dComIfGp_getMsgDtArchive(int idx); +DUSK_NOINLINE void dComIfGp_setMsgDtArchive(int i, JKRArchive* arc); +DUSK_NOINLINE JKRArchive* dComIfGp_getMain2DArchive(); +DUSK_NOINLINE void dComIfGp_setMain2DArchive(JKRArchive* arc); +DUSK_NOINLINE JKRExpHeap* dComIfGp_particle_getResHeap(); +DUSK_NOINLINE void dComIfGp_particle_levelExecute(u32 param_0); +DUSK_NOINLINE void dComIfGp_particle_createCommon(const void* data); +DUSK_NOINLINE void dComIfGp_particle_readScene(u8 particle_no, mDoDvdThd_toMainRam_c** param_1); +DUSK_NOINLINE void dComIfGp_particle_createScene(const void* param_0); +DUSK_NOINLINE void dComIfGp_particle_removeScene(bool param_0); +DUSK_NOINLINE void dComIfGp_particle_cleanup(); +DUSK_NOINLINE void dComIfGp_particle_calc3D(); +DUSK_NOINLINE void dComIfGp_particle_calc2D(); +DUSK_NOINLINE void dComIfGp_particle_calcMenu(); +DUSK_NOINLINE void dComIfGp_particle_draw(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFog(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawP1(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawProjection(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawNormalPri0_A(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawNormalPri0_B(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri0_A(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri0_B(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri1(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri2(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri3(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawFogPri4(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawDarkworld(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_drawScreen(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_draw2Dgame(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_draw2Dfore(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_draw2Dback(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_draw2DmenuFore(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_particle_draw2DmenuBack(JPADrawInfo* i_drawInfo); +DUSK_NOINLINE void dComIfGp_setHitMark(u16 i_hitmark, fopAc_ac_c* param_1, const cXyz* param_2, + const csXyz* param_3, const cXyz* param_4, u32 i_atType); +DUSK_NOINLINE void dComIfGp_particle_setWaterRipple(u32* param_0, cBgS_PolyInfo& param_1, + const cXyz* param_2, f32 param_3, const dKy_tevstr_c* param_4, const cXyz* param_5, s8 param_6); +DUSK_NOINLINE u32 dComIfGp_particle_setPolyColor(u32 param_0, u16 param_1, cBgS_PolyInfo& param_2, + const cXyz* param_3, const dKy_tevstr_c* param_4, const csXyz* param_5, const cXyz* param_6, + int param_7, dPa_levelEcallBack* param_8, s8 param_9, const cXyz* param_10); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_setPolyColor(u16 param_1, cBgS_PolyInfo& param_2, + const cXyz* param_3, const dKy_tevstr_c* param_4, const csXyz* param_5, const cXyz* param_6, + int param_7, dPa_levelEcallBack* param_8, s8 param_9, const cXyz* param_10); +DUSK_NOINLINE void dComIfGp_particle_setSimple(u16 param_0, cXyz* i_pos, u8 param_2, + GXColor& param_3, GXColor& param_4, int param_5, float param_6); +DUSK_NOINLINE u32 dComIfGp_particle_setStopContinue(u32 param_0); +DUSK_NOINLINE u32 dComIfGp_particle_setSimpleFoot(u32 param_0, u32* param_1, cBgS_PolyInfo& param_2, + cXyz const* param_3, dKy_tevstr_c const* param_4, int param_5, csXyz const* param_6, + cXyz const* param_7, dPa_levelEcallBack* param_8, s8 param_9, cXyz const* param_10); +DUSK_NOINLINE u16 dComIfGp_particle_setCommonPoly(u32* param_0, cBgS_PolyInfo* param_1, + const cXyz* param_2, const cXyz* param_3, const dKy_tevstr_c* param_4, u32 param_5, u32 param_6, + const csXyz* param_7, const cXyz* param_8, s8 param_9); +DUSK_NOINLINE void dComIfGp_particle_levelEmitterOnEventMove(u32 param_0); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_getEmitter(u32 param_0); +DUSK_NOINLINE u32 dComIfGp_particle_set(u32 param_0, u16 param_1, const cXyz* i_pos, + const dKy_tevstr_c* param_3, const csXyz* i_rotation, const cXyz* i_scale, u8 i_alpha, + dPa_levelEcallBack* param_7, s8 param_8, const GXColor* param_9, const GXColor* param_10, + const cXyz* param_11); +DUSK_NOINLINE u32 dComIfGp_particle_set(u32 param_0, u16 param_1, const cXyz* i_pos, + const csXyz* i_rotation, const cXyz* i_scale, u8 param_5, dPa_levelEcallBack* param_6, + s8 param_7, const GXColor* param_8, const GXColor* param_9, const cXyz* param_10); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_set(u16 i_resID, const cXyz* i_pos, + const dKy_tevstr_c* param_3, const csXyz* i_rotation, const cXyz* i_scale, u8 i_alpha, + dPa_levelEcallBack* i_callback, s8 param_8, const GXColor* i_prmColor, + const GXColor* i_envColor, const cXyz* i_particleScale); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_set(u16 i_resID, const cXyz* i_pos, + const csXyz* i_rotation, const cXyz* i_scale, u8 i_alpha, dPa_levelEcallBack* i_callback, + s8 param_7, const GXColor* i_prmColor, const GXColor* i_envColor, const cXyz* i_particleScale); +DUSK_NOINLINE u32 dComIfGp_particle_set( + u32 param_0, u16 param_1, const cXyz* i_pos, const dKy_tevstr_c* param_3); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_set( + u16 i_resID, const cXyz* i_pos, const csXyz* i_rotation, const cXyz* i_scale); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_set(u16 i_resID, const cXyz* i_pos, + const dKy_tevstr_c* param_2, const csXyz* i_rotation, const cXyz* i_scale); +DUSK_NOINLINE u32 dComIfGp_particle_set( + u32 param_0, u16 param_1, const cXyz* i_pos, const csXyz* param_3, const cXyz* param_4); +DUSK_NOINLINE u32 dComIfGp_particle_setColor(u32 param_0, u16 param_1, const cXyz* i_pos, + const dKy_tevstr_c* param_3, const GXColor* param_4, const GXColor* param_5, f32 param_6, + u8 param_7, const csXyz* param_8, const cXyz* param_9, dPa_levelEcallBack* param_10, + s8 param_11, const cXyz* param_12); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_setColor(u16 param_0, const cXyz* i_pos, + const dKy_tevstr_c* param_2, const GXColor* param_3, const GXColor* param_4, f32 param_5, + u8 param_6, const csXyz* param_7, const cXyz* param_8, dPa_levelEcallBack* param_9, s8 param_10, + const cXyz* param_11); +DUSK_NOINLINE JPABaseEmitter* dComIfGp_particle_setColor(u16 param_0, const cXyz* i_pos, + const dKy_tevstr_c* param_2, const GXColor* param_3, const GXColor* param_4, f32 param_5, + u8 param_6); +DUSK_NOINLINE u32 dComIfGp_particle_getHeapSize(); +DUSK_NOINLINE u32 dComIfGp_particle_getSceneHeapSize(); +DUSK_NOINLINE int dComIfGp_particle_getEmitterNum(); +DUSK_NOINLINE int dComIfGp_particle_getParticleNum(); +DUSK_NOINLINE dSmplMdl_draw_c* dComIfGp_getSimpleModel(); +DUSK_NOINLINE int dComIfGp_getWindowNum(); +DUSK_NOINLINE void dComIfGp_setWindowNum(int num); +DUSK_NOINLINE s8 dComIfGp_getLayerOld(); +DUSK_NOINLINE s32 dComIfGp_checkStatus(u16 flags); +DUSK_NOINLINE void dComIfGp_setStatus(u16 status); +DUSK_NOINLINE void dComIfGp_onStatus(u16 i_status); +DUSK_NOINLINE dDlst_window_c* dComIfGp_getWindow(int i); +DUSK_NOINLINE void dComIfGp_setWindow(u8 i, f32 param_1, f32 param_2, f32 param_3, f32 param_4, + f32 param_5, f32 param_6, int camID, int mode); +DUSK_NOINLINE camera_process_class* dComIfGp_getCamera(int idx); +DUSK_NOINLINE void dComIfGp_setCamera(int i, camera_class* cam); +DUSK_NOINLINE int dComIfGp_getCameraWinID(int idx); +DUSK_NOINLINE int dComIfGp_getCameraPlayer1ID(int idx); +DUSK_NOINLINE int dComIfGp_getCameraPlayer2ID(int idx); +DUSK_NOINLINE u32 dComIfGp_getCameraAttentionStatus(int i_no); +DUSK_NOINLINE BOOL dComIfGp_checkCameraAttentionStatus(int i, u32 flag); +DUSK_NOINLINE void dComIfGp_onCameraAttentionStatus(int i, u32 flag); +DUSK_NOINLINE void dComIfGp_offCameraAttentionStatus(int i, u32 flag); +DUSK_NOINLINE void dComIfGp_setCameraInfo( + int camIdx, camera_class* p_cam, int param_2, int param_3, int param_4); +DUSK_NOINLINE f32 dComIfGp_getCameraZoomScale(int i_no); +DUSK_NOINLINE void dComIfGp_setCameraZoomScale(int i_no, f32 i_scale); +DUSK_NOINLINE f32 dComIfGp_getCameraZoomForcus(int i_no); +DUSK_NOINLINE void dComIfGp_setCameraZoomForcus(int i_no, f32 i_focus); +DUSK_NOINLINE const char* dComIfGp_getCameraParamFileName(int i); +DUSK_NOINLINE void dComIfGp_setCameraParamFileName(int i, char* name); +DUSK_NOINLINE void dComIfGp_saveCameraPosition( + int i, cXyz* i_pos, cXyz* i_target, f32 i_fovy, s16 i_bank); +DUSK_NOINLINE void dComIfGp_loadCameraPosition( + int i, cXyz* o_pos, cXyz* o_target, f32* o_fovy, s16* o_bank); +DUSK_NOINLINE fopAc_ac_c* dComIfGp_getPlayer(int idx); +DUSK_NOINLINE void dComIfGp_setPlayer(int i, fopAc_ac_c* player); +DUSK_NOINLINE int dComIfGp_getPlayerCameraID(int idx); +DUSK_NOINLINE void dComIfGp_setPlayerInfo(int plyrIdx, fopAc_ac_c* ptr, int camIdx); +DUSK_NOINLINE daPy_py_c* dComIfGp_getLinkPlayer(); +DUSK_NOINLINE daHorse_c* dComIfGp_getHorseActor(); +DUSK_NOINLINE void dComIfGp_setLinkPlayer(fopAc_ac_c* ptr); +DUSK_NOINLINE void dComIfGp_setHorseActor(fopAc_ac_c* i_horse); +DUSK_NOINLINE void dComIfGp_setPlayerPtr(int i, fopAc_ac_c* ptr); +DUSK_NOINLINE dMsgObject_c* dComIfGp_getMsgObjectClass(); +DUSK_NOINLINE void dComIfGp_setMsgObjectClass(dMsgObject_c* obj); +DUSK_NOINLINE f32 dComIfGp_getItemLifeCount(); +DUSK_NOINLINE u8 dComIfGp_getItemLifeCountType(); +DUSK_NOINLINE void dComIfGp_setItemLifeCount(f32 amount, u8 type); +DUSK_NOINLINE void dComIfGp_clearItemLifeCount(); +DUSK_NOINLINE s32 dComIfGp_getItemRupeeCount(); +DUSK_NOINLINE void dComIfGp_setItemRupeeCount(s32 amount); +DUSK_NOINLINE void dComIfGp_clearItemRupeeCount(); +DUSK_NOINLINE s16 dComIfGp_getItemKeyNumCount(); +DUSK_NOINLINE void dComIfGp_setItemKeyNumCount(s16 count); +DUSK_NOINLINE void dComIfGp_clearItemKeyNumCount(); +DUSK_NOINLINE s16 dComIfGp_getItemMaxLifeCount(); +DUSK_NOINLINE void dComIfGp_setItemMaxLifeCount(s16 count); +DUSK_NOINLINE void dComIfGp_clearItemMaxLifeCount(); +DUSK_NOINLINE void dComIfGp_setItemMagicCount(s16 count); +DUSK_NOINLINE void dComIfGp_setItemNowMagic(s16 magic); +DUSK_NOINLINE void dComIfGp_setItemMaxMagicCount(s16 count); +DUSK_NOINLINE s32 dComIfGp_getItemOilCount(); +DUSK_NOINLINE void dComIfGp_setItemOilCount(s32 oil); +DUSK_NOINLINE void dComIfGp_setItemMaxOilCount(s32 oil); +DUSK_NOINLINE void dComIfGp_clearItemOilCount(); +DUSK_NOINLINE s32 dComIfGp_getItemNowOil(); +DUSK_NOINLINE void dComIfGp_setItemNowOil(s32 oil); +DUSK_NOINLINE s32 dComIfGp_getItemMaxOilCount(); +DUSK_NOINLINE void dComIfGp_clearItemMaxOilCount(); +DUSK_NOINLINE int dComIfGp_getOxygen(); +DUSK_NOINLINE void dComIfGp_setOxygen(s32 oxygen); +DUSK_NOINLINE int dComIfGp_getNowOxygen(); +DUSK_NOINLINE void dComIfGp_setNowOxygen(s32 oxygen); +DUSK_NOINLINE s32 dComIfGp_getMaxOxygen(); +DUSK_NOINLINE void dComIfGp_setMaxOxygen(s32 i_oxygen); +DUSK_NOINLINE s32 dComIfGp_getOxygenCount(); +DUSK_NOINLINE void dComIfGp_setOxygenCount(s32 oxygen); +DUSK_NOINLINE void dComIfGp_clearOxygenCount(); +DUSK_NOINLINE void dComIfGp_setMaxOxygenCount(s32 oxygen); +DUSK_NOINLINE s32 dComIfGp_getMaxOxygenCount(); +DUSK_NOINLINE void dComIfGp_clearMaxOxygenCount(); +DUSK_NOINLINE s16 dComIfGp_getItemArrowNumCount(); +DUSK_NOINLINE void dComIfGp_setItemArrowNumCount(s16 count); +DUSK_NOINLINE void dComIfGp_clearItemArrowNumCount(); +DUSK_NOINLINE s16 dComIfGp_getItemPachinkoNumCount(); +DUSK_NOINLINE void dComIfGp_setItemPachinkoNumCount(s16 count); +DUSK_NOINLINE void dComIfGp_clearItemPachinkoNumCount(); +DUSK_NOINLINE s16 dComIfGp_getItemMaxArrowNumCount(); +DUSK_NOINLINE int dComIfGp_getMessageCountNumber(); +DUSK_NOINLINE void dComIfGp_setMessageCountNumber(s32 number); +DUSK_NOINLINE u16 dComIfGp_getItemNowLife(); +DUSK_NOINLINE void dComIfGp_setItemNowLife(u16 life); +DUSK_NOINLINE u8 dComIfGp_getMesgStatus(); +DUSK_NOINLINE u8 dComIfGp_getRStatus(); +DUSK_NOINLINE bool dComIfGp_isRSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setRStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getRStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getRSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setRStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getAStatus(); +DUSK_NOINLINE bool dComIfGp_isASetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setAStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getAStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getASetFlagForce(); +DUSK_NOINLINE void dComIfGp_setAStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getNunStatus(); +DUSK_NOINLINE bool dComIfGp_isNunSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setNunStatus(u8 status, u8 param_1, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getBottleStatus(); +DUSK_NOINLINE bool dComIfGp_isBottleSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setBottleStatus(u8 param_0, u8 param_1); +DUSK_NOINLINE u8 dComIfGp_getBottleStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getBottleSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setBottleStatusForce(u8 param_0, u8 param_1); +DUSK_NOINLINE u8 dComIfGp_getRemoConStatus(); +DUSK_NOINLINE bool dComIfGp_isRemoConSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setRemoConStatus(u8 status, u8 param_1, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getDoStatus(); +DUSK_NOINLINE bool dComIfGp_isDoSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setDoStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getDoStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getDoSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setDoStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_get3DStatus(); +DUSK_NOINLINE u8 dComIfGp_get3DDirection(); +DUSK_NOINLINE bool dComIfGp_is3DSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_set3DStatus(u8 status, u8 direction, u8 flag); +DUSK_NOINLINE u8 dComIfGp_get3DStatusForce(); +DUSK_NOINLINE u8 dComIfGp_get3DDirectionForce(); +DUSK_NOINLINE u8 dComIfGp_get3DSetFlagForce(); +DUSK_NOINLINE void dComIfGp_set3DStatusForce(u8 status, u8 direction, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getCStickStatus(); +DUSK_NOINLINE u8 dComIfGp_getCStickDirection(); +DUSK_NOINLINE bool dComIfGp_isCStickSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setCStickStatus(u8 status, u8 param_1, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getCStickStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getCStickDirectionForce(); +DUSK_NOINLINE u8 dComIfGp_getCStickSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setCStickStatusForce(u8 status, u8 param_1, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getSButtonStatus(); +DUSK_NOINLINE bool dComIfGp_isSButtonSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setSButtonStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getSButtonStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getSButtonSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setSButtonStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getZStatus(); +DUSK_NOINLINE bool dComIfGp_isZSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setZStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getZStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getZSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setZStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getXStatus(); +DUSK_NOINLINE bool dComIfGp_isXSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setXStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getXStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getXSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setXStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getYStatus(); +DUSK_NOINLINE bool dComIfGp_isYSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setYStatus(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getYStatusForce(); +DUSK_NOINLINE u8 dComIfGp_getYSetFlagForce(); +DUSK_NOINLINE void dComIfGp_setYStatusForce(u8 status, u8 flag); +DUSK_NOINLINE u8 dComIfGp_getNunZStatus(); +DUSK_NOINLINE bool dComIfGp_isNunZSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setNunZStatus(u8 param_0, u8 param_1); +DUSK_NOINLINE u8 dComIfGp_getNunCStatus(); +DUSK_NOINLINE bool dComIfGp_isNunCSetFlag(u8 flag); +DUSK_NOINLINE void dComIfGp_setNunCStatus(u8 param_0, u8 param_1); +DUSK_NOINLINE void dComIfGp_setSelectEquipClothes(u8 i_clothNo); +DUSK_NOINLINE void dComIfGp_setSelectEquipSword(u8 i_swordNo); +DUSK_NOINLINE void dComIfGp_setSelectEquipShield(u8 i_shieldNo); +DUSK_NOINLINE u8 dComIfGp_getMesgAnimeAttrInfo(); +DUSK_NOINLINE void dComIfGp_setMesgAnimeAttrInfo(u8 param_1); +DUSK_NOINLINE void dComIfGp_clearMesgAnimeAttrInfo(); +DUSK_NOINLINE u8 dComIfGp_getMesgFaceAnimeAttrInfo(); +DUSK_NOINLINE void dComIfGp_setMesgFaceAnimeAttrInfo(u8 id); +DUSK_NOINLINE void dComIfGp_clearMesgFaceAnimeAttrInfo(); +DUSK_NOINLINE void dComIfGp_clearMesgAnimeTagInfo(); +DUSK_NOINLINE void dComIfGp_setItem(u8 slot, u8 i_no); +DUSK_NOINLINE u8 dComIfGp_getAdvanceDirection(); +DUSK_NOINLINE void dComIfGp_setAdvanceDirection(u8 i_dir); +DUSK_NOINLINE u8 dComIfGp_checkMesgCancelButton(); +DUSK_NOINLINE void dComIfGp_setMesgCancelButton(u8 button); +DUSK_NOINLINE u8 dComIfGp_getGameoverStatus(); +DUSK_NOINLINE void dComIfGp_setGameoverStatus(u8 i_status); +DUSK_NOINLINE u8 dComIfGp_isHeapLockFlag(); +DUSK_NOINLINE u8 dComIfGp_getSubHeapLockFlag(int idx); +DUSK_NOINLINE void dComIfGp_setSubHeapLockFlag(int idx, u8 status); +DUSK_NOINLINE u8 dComIfGp_getNeedLightDropNum(); +DUSK_NOINLINE void dComIfGp_setNeedLightDropNum(u8 i_num); +DUSK_NOINLINE u8 dComIfGp_checkMesgBgm(); +DUSK_NOINLINE void dComIfGp_setMesgBgmOff(); +DUSK_NOINLINE void dComIfGp_setMesgBgmOn(); +DUSK_NOINLINE u8 dComIfGp_isPauseFlag(); +DUSK_NOINLINE void dComIfGp_offPauseFlag(); +DUSK_NOINLINE void dComIfGp_onPauseFlag(); +DUSK_NOINLINE u8 dComIfGp_getOxygenShowFlag(); +DUSK_NOINLINE void dComIfGp_offOxygenShowFlag(); +DUSK_NOINLINE void dComIfGp_onOxygenShowFlag(); +DUSK_NOINLINE u8 dComIfGp_2dShowCheck(); +DUSK_NOINLINE void dComIfGp_2dShowOn(); +DUSK_NOINLINE void dComIfGp_2dShowOff(); +DUSK_NOINLINE JKRExpHeap* dComIfGp_getExpHeap2D(); +DUSK_NOINLINE void dComIfGp_setExpHeap2D(void* heap); +DUSK_NOINLINE JKRExpHeap* dComIfGp_getSubExpHeap2D(int idx); +DUSK_NOINLINE void dComIfGp_setSubExpHeap2D(int idx, void* heap); +DUSK_NOINLINE JKRExpHeap* dComIfGp_getMsgExpHeap(); +DUSK_NOINLINE void dComIfGp_setMsgExpHeap(void* heap); +DUSK_NOINLINE dComIfG_MesgCamInfo_c* dComIfGp_getMesgCameraInfo(); +DUSK_NOINLINE void dComIfGp_setMesgCameraTagInfo(int id); +DUSK_NOINLINE void dComIfGp_clearMesgCameraTagInfo(); +DUSK_NOINLINE void dComIfGp_setMesgCameraAttrInfo(int param_1); +DUSK_NOINLINE void dComIfGp_clearMesgCameraAttrInfo(); +DUSK_NOINLINE void dComIfGp_setMesgCameraInfoActor(fopAc_ac_c* param_1, fopAc_ac_c* param_2, + fopAc_ac_c* param_3, fopAc_ac_c* param_4, fopAc_ac_c* param_5, fopAc_ac_c* param_6, + fopAc_ac_c* param_7, fopAc_ac_c* param_8, fopAc_ac_c* param_9, fopAc_ac_c* param_10); +DUSK_NOINLINE u32 dComIfGp_checkPlayerStatus0(int param_0, u32 flag); +DUSK_NOINLINE u32 dComIfGp_checkPlayerStatus1(int param_0, u32 flag); +DUSK_NOINLINE void dComIfGp_setPlayerStatus0(int param_0, u32 flag); +DUSK_NOINLINE void dComIfGp_setPlayerStatus1(int param_0, u32 flag); +DUSK_NOINLINE void dComIfGp_clearPlayerStatus0(int param_0, u32 flag); +DUSK_NOINLINE void dComIfGp_clearPlayerStatus1(int param_0, u32 flag); +DUSK_NOINLINE void dComIfGp_setCurrentWindow(dDlst_window_c* i_window); +DUSK_NOINLINE void dComIfGp_setCurrentView(view_class* i_view); +DUSK_NOINLINE void dComIfGp_setCurrentViewport(view_port_class* i_viewport); +DUSK_NOINLINE J2DGrafContext* dComIfGp_getCurrentGrafPort(); +DUSK_NOINLINE void dComIfGp_setCurrentGrafPort(J2DOrthoGraph* i_graf); +DUSK_NOINLINE void* dComIfGp_getItemTable(); +DUSK_NOINLINE void dComIfGp_setItemTable(void* data); +DUSK_NOINLINE char* dComIfGp_getLastPlayStageName(); +DUSK_NOINLINE void dComIfGp_setLastPlayStageName(char* name); +DUSK_NOINLINE void dComIfGp_init(); +DUSK_NOINLINE void dComIfGp_itemDataInit(); +DUSK_NOINLINE void dComIfGp_setItemBombNumCount(u8 i_item, s16 count); +DUSK_NOINLINE s16 dComIfGp_getItemBombNumCount(u8 i_no); +DUSK_NOINLINE void dComIfGp_clearItemBombNumCount(u8 i_no); +DUSK_NOINLINE s16 dComIfGp_getItemMaxBombNumCount(); +DUSK_NOINLINE void dComIfGp_setNowVibration(u8 status); +DUSK_NOINLINE u32 dComIfGp_getNowVibration(); +DUSK_NOINLINE void dComIfGp_particle_create(); +DUSK_NOINLINE void dComIfGp_createSimpleModel(); +DUSK_NOINLINE void dComIfGp_deleteSimpleModel(); +DUSK_NOINLINE void dComIfGp_drawSimpleModel(); +DUSK_NOINLINE int dComIfGp_addSimpleModel(J3DModelData* i_modelData, int roomNo, u8 i_drawBG); +DUSK_NOINLINE void dComIfGp_removeSimpleModel(J3DModelData* i_modelData, int roomNo); +DUSK_NOINLINE void dComIfGp_entrySimpleModel(J3DModel* model, int roomNo); +DUSK_NOINLINE void dComIfG_ct(); +DUSK_NOINLINE dBgS& dComIfG_Bgsp(); +DUSK_NOINLINE dCcS* dComIfG_Ccsp(); +DUSK_NOINLINE dCcS& dComIfG_Ccsp2(); +DUSK_NOINLINE void dComIfG_setTimerNowTimeMs(int time); +DUSK_NOINLINE int dComIfG_getTimerNowTimeMs(); +DUSK_NOINLINE void dComIfG_setTimerLimitTimeMs(int i_time); +DUSK_NOINLINE int dComIfG_getTimerLimitTimeMs(); +DUSK_NOINLINE void dComIfG_setTimerMode(int mode); +DUSK_NOINLINE int dComIfG_getTimerMode(); +DUSK_NOINLINE void dComIfG_setTimerType(u8 i_type); +DUSK_NOINLINE u8 dComIfG_getTimerType(); +DUSK_NOINLINE void dComIfG_setTimerPtr(dTimer_c* i_ptr); +DUSK_NOINLINE dTimer_c* dComIfG_getTimerPtr(); + +/** + * Attempts to add a new Object Resource Archive (*.arc) into the Resource Control. + * @param i_arcName Name of archive to be added + * @param i_mountDirection The direction to mount the archive. mDoDvd_MOUNT_DIRECTION_HEAD or + * mDoDvd_MOUNT_DIRECTION_TAIL + * @param i_heap Pointer to heap to load resources into + * @return TRUE if successful, FALSE otherwise + */ +DUSK_NOINLINE int dComIfG_setObjectRes(const char* i_arcName, u8 i_mountDirection, JKRHeap* i_heap); +DUSK_NOINLINE int dComIfG_setObjectRes( + const char* i_arcName, void* i_archiveRes, u32 i_bufferSize, JKRHeap* i_heap); + +/** + * Attempts to add a new Stage Resource Archive (*.arc) into the Resource Control. + * @param i_arcName Name of archive to be added + * @param i_heap Pointer to heap to load resources into + * @return TRUE if successful, FALSE otherwise + */ +DUSK_NOINLINE int dComIfG_setStageRes(const char* i_arcName, JKRHeap* i_heap); +DUSK_NOINLINE int dComIfG_syncObjectRes(const char* i_arcName); +DUSK_NOINLINE int dComIfG_syncStageRes(const char* i_arcName); +DUSK_NOINLINE int dComIfG_deleteObjectResMain(const char* i_arcName); +DUSK_NOINLINE int dComIfG_deleteStageRes(const char* i_arcName); +DUSK_NOINLINE void* dComIfG_getStageRes(const char* i_arcName, const char* i_resName); +DUSK_NOINLINE void* dComIfG_getObjectRes(const char* i_arcName, const char* i_resName); +DUSK_NOINLINE void* dComIfG_getObjectRes(const char* i_arcName, int i_index); +DUSK_NOINLINE void dComIfG_dumpResControl(); +DUSK_NOINLINE dRes_info_c* dComIfG_getObjectResInfo(const char* i_arcName); +DUSK_NOINLINE dRes_info_c* dComIfG_getStageResInfo(const char* i_arcName); +DUSK_NOINLINE int dComIfG_syncAllObjectRes(); +DUSK_NOINLINE void* dComIfG_getObjectIDRes(const char* i_arcName, u16 i_resID); +DUSK_NOINLINE int dComIfG_getObjctResName2Index(const char* i_arcName, const char* i_resName); +DUSK_NOINLINE u8 dComIfG_getBrightness(); +DUSK_NOINLINE void dComIfG_setBrightness(u8 brightness); +DUSK_NOINLINE BOOL dComIfG_isDebugMode(); +DUSK_NOINLINE u32 dComIfG_getTrigB(u32 i_padNo); +#if DEBUG +DUSK_NOINLINE u32 dComIfG_getObjectAllSize(); +DUSK_NOINLINE u32 dComIfG_getStageAllSize(); +DUSK_NOINLINE u32 dComIfG_getObjectSize(const char* i_arcName); +DUSK_NOINLINE u32 dComIfG_getStageSize(const char* i_arcName); +DUSK_NOINLINE void dComIfG_initStopwatch(); +#endif + +DUSK_NOINLINE int dComIfGd_setRealShadow(u32 param_0, s8 param_1, J3DModel* param_2, cXyz* param_3, + f32 param_4, f32 param_5, dKy_tevstr_c* param_6); +DUSK_NOINLINE int dComIfGd_setSimpleShadow( + cXyz* pos, f32 param_1, f32 param_2, cXyz* param_3, s16 angle, f32 param_5, TGXTexObj* tex); +DUSK_NOINLINE bool dComIfGd_addRealShadow(u32 key, J3DModel* model); +DUSK_NOINLINE void dComIfGd_drawListItem3d(); + +#if VERSION > VERSION_GCN_JPN +DUSK_NOINLINE void dComIfGd_drawListCursor(); +#endif + +DUSK_NOINLINE void dComIfGd_reset(); +DUSK_NOINLINE void dComIfGd_set2DOpa(dDlst_base_c* dlst); +DUSK_NOINLINE void dComIfGd_set2DXlu(dDlst_base_c* dlst); +DUSK_NOINLINE void dComIfGd_set2DOpaTop(dDlst_base_c* dlst); +DUSK_NOINLINE void dComIfGd_setCopy2D(dDlst_base_c* dlst); +DUSK_NOINLINE view_class* dComIfGd_getView(); +DUSK_NOINLINE Mtx44* dComIfGd_getProjViewMtx(); +DUSK_NOINLINE MtxP dComIfGd_getInvViewMtx(); +DUSK_NOINLINE view_port_class* dComIfGd_getViewport(); +DUSK_NOINLINE MtxP dComIfGd_getViewRotMtx(); +DUSK_NOINLINE MtxP dComIfGd_getViewMtx(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getListFilter(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getOpaListIndScreen(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getListPacket(); +DUSK_NOINLINE void dComIfGd_setListSky(); +DUSK_NOINLINE void dComIfGd_setListDark(); +DUSK_NOINLINE void dComIfGd_setListInvisisble(); +DUSK_NOINLINE void dComIfGd_setListDarkBG(); +DUSK_NOINLINE void dComIfGd_setXluListDarkBG(); +DUSK_NOINLINE void dComIfGd_setList(); +DUSK_NOINLINE void dComIfGd_setListItem3D(); +DUSK_NOINLINE void dComIfGd_setList3Dlast(); +DUSK_NOINLINE void dComIfGd_setXluList2DScreen(); +DUSK_NOINLINE void dComIfGd_setXluListBG(); +DUSK_NOINLINE void dComIfGd_setListBG(); +DUSK_NOINLINE void dComIfGd_setListIndScreen(); +DUSK_NOINLINE void dComIfGd_setListMiddle(); +DUSK_NOINLINE void dComIfGd_setListZxlu(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getOpaList(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getOpaListBG(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getOpaListDark(); +DUSK_NOINLINE J3DDrawBuffer* dComIfGd_getXluListBG(); +DUSK_NOINLINE void dComIfGd_setListFilter(); +DUSK_NOINLINE void dComIfGd_init(); +DUSK_NOINLINE void dComIfGd_peekZ(s16 param_0, s16 param_1, u32* param_2); +DUSK_NOINLINE void dComIfGd_peekZdata(); +DUSK_NOINLINE void dComIfGd_setView(view_class* view); +DUSK_NOINLINE void dComIfGd_setWindow(dDlst_window_c* window); +DUSK_NOINLINE void dComIfGd_setViewport(view_port_class* port); +DUSK_NOINLINE void dComIfGd_entryZSortListZxlu(J3DPacket* i_packet, cXyz& param_1); +DUSK_NOINLINE void dComIfGd_entryZSortXluList(J3DPacket* i_packet, cXyz& param_1); +DUSK_NOINLINE void dComIfGd_drawCopy2D(); +DUSK_NOINLINE void dComIfGd_drawOpaListSky(); +DUSK_NOINLINE void dComIfGd_drawXluListSky(); +DUSK_NOINLINE void dComIfGd_drawOpaListBG(); +DUSK_NOINLINE void dComIfGd_drawOpaListDarkBG(); +DUSK_NOINLINE void dComIfGd_drawOpaListMiddle(); +DUSK_NOINLINE void dComIfGd_drawOpaList(); +DUSK_NOINLINE void dComIfGd_drawOpaListDark(); +DUSK_NOINLINE void dComIfGd_drawOpaListPacket(); +DUSK_NOINLINE void dComIfGd_drawXluListBG(); +DUSK_NOINLINE void dComIfGd_drawXluListDarkBG(); +DUSK_NOINLINE void dComIfGd_drawXluList(); +DUSK_NOINLINE void dComIfGd_drawXluListDark(); +DUSK_NOINLINE void dComIfGd_drawXluListInvisible(); +DUSK_NOINLINE void dComIfGd_drawOpaListInvisible(); +DUSK_NOINLINE void dComIfGd_drawXluListZxlu(); +DUSK_NOINLINE void dComIfGd_drawXluList2DScreen(); +DUSK_NOINLINE void dComIfGd_drawOpaList3Dlast(); +DUSK_NOINLINE void dComIfGd_draw2DOpa(); +DUSK_NOINLINE void dComIfGd_draw2DOpaTop(); +DUSK_NOINLINE void dComIfGd_draw2DXlu(); +DUSK_NOINLINE void dComIfGd_drawOpaListFilter(); +DUSK_NOINLINE void dComIfGd_drawIndScreen(); +DUSK_NOINLINE void dComIfGd_drawListZxlu(); +DUSK_NOINLINE void dComIfGd_drawShadow(Mtx param_0); +DUSK_NOINLINE void dComIfGd_imageDrawShadow(Mtx param_0); +DUSK_NOINLINE void dComIfGd_set3DlineMat(mDoExt_3DlineMat_c* param_0); +DUSK_NOINLINE void dComIfGd_set3DlineMatDark(mDoExt_3DlineMat_c* param_0); + +#if PLATFORM_WII || VERSION == VERSION_SHIELD_DEBUG +DUSK_NOINLINE void dComIfGd_setListCursor(); +#endif + +#else inline dSv_info_c* dComIfGs_getSaveInfo() { return &g_dComIfG_gameInfo.info; } @@ -1432,11 +2366,7 @@ inline BOOL dComIfGs_isTransformLV(int i_no) { return g_dComIfG_gameInfo.info.getPlayer().getPlayerStatusB().isTransformLV(i_no); } -#if TARGET_PC -inline cXyz dComIfGs_getHorseRestartPos() { -#else inline cXyz& dComIfGs_getHorseRestartPos() { -#endif return g_dComIfG_gameInfo.info.getPlayer().getHorsePlace().getPos(); } @@ -1457,11 +2387,7 @@ inline void dComIfGs_setHorseRestart(const char* i_stageName, cXyz& i_pos, s16 i g_dComIfG_gameInfo.info.getPlayer().getHorsePlace().set(i_stageName, i_pos, i_angle, i_roomNo); } -#if TARGET_PC -inline cXyz dComIfGs_getPlayerFieldLastStayPos() { -#else inline cXyz& dComIfGs_getPlayerFieldLastStayPos() { -#endif return g_dComIfG_gameInfo.info.getPlayer().getPlayerFieldLastStayInfo().getPos(); } @@ -1503,11 +2429,7 @@ inline void dComIfGs_setPlayerFieldLastStayInfo(const char* i_stage, cXyz& i_pos i_point, i_region); } -#if TARGET_PC -inline cXyz dComIfGs_getLastWarpMarkPlayerPos() { -#else inline cXyz& dComIfGs_getLastWarpMarkPlayerPos() { -#endif return g_dComIfG_gameInfo.info.getPlayer().getPlayerLastMarkInfo().getPos(); } @@ -1845,12 +2767,6 @@ inline void dComIfGs_addDeathCount() { g_dComIfG_gameInfo.info.getPlayer().getPlayerInfo().addDeathCount(); } -#if TARGET_PC -inline u16 dComIfGs_getDeathCount() { - return g_dComIfG_gameInfo.info.getPlayer().getPlayerInfo().getDeathCount(); -} -#endif - inline TEXT_SPAN dComIfGs_getPlayerName() { return g_dComIfG_gameInfo.info.getPlayer().getPlayerInfo().getPlayerName(); } @@ -3117,133 +4033,114 @@ inline void dComIfGp_particle_calcMenu() { } inline void dComIfGp_particle_draw(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawNormal(i_drawInfo); } } inline void dComIfGp_particle_drawFog(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawNormalFog(i_drawInfo); } } inline void dComIfGp_particle_drawP1(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawNormalP1(i_drawInfo); } } inline void dComIfGp_particle_drawProjection(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawProjection(i_drawInfo); } } inline void dComIfGp_particle_drawNormalPri0_A(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawNormalPri0_A(i_drawInfo); } } inline void dComIfGp_particle_drawNormalPri0_B(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawNormalPri0_B(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri0_A(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri0_A(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri0_B(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri0_B(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri1(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri1(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri2(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri2(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri3(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri3(i_drawInfo); } } inline void dComIfGp_particle_drawFogPri4(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogPri4(i_drawInfo); } } inline void dComIfGp_particle_drawDarkworld(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawDarkworld(i_drawInfo); } } inline void dComIfGp_particle_drawScreen(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->drawFogScreen(i_drawInfo); } } inline void dComIfGp_particle_draw2Dgame(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->draw2Dgame(i_drawInfo); } } inline void dComIfGp_particle_draw2Dfore(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->draw2Dfore(i_drawInfo); } } inline void dComIfGp_particle_draw2Dback(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->draw2Dback(i_drawInfo); } } inline void dComIfGp_particle_draw2DmenuFore(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->draw2DmenuFore(i_drawInfo); } } inline void dComIfGp_particle_draw2DmenuBack(JPADrawInfo* i_drawInfo) { - ZoneScoped; if (g_dComIfG_gameInfo.play.getParticle() != NULL) { g_dComIfG_gameInfo.play.getParticle()->draw2DmenuBack(i_drawInfo); } @@ -4763,154 +5660,114 @@ inline void dComIfGd_setViewport(view_port_class* port) { } inline void dComIfGd_entryZSortListZxlu(J3DPacket* i_packet, cXyz& param_1) { - ZoneScoped; g_dComIfG_gameInfo.drawlist.entryZSortListZxlu(i_packet, param_1); } inline void dComIfGd_entryZSortXluList(J3DPacket* i_packet, cXyz& param_1) { - ZoneScoped; g_dComIfG_gameInfo.drawlist.entryZSortXluList(i_packet, param_1); } inline void dComIfGd_drawCopy2D() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawCopy2D(); } inline void dComIfGd_drawOpaListSky() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListSky(); } inline void dComIfGd_drawXluListSky() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListSky(); } inline void dComIfGd_drawOpaListBG() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListBG(); } inline void dComIfGd_drawOpaListDarkBG() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListDarkBG(); } inline void dComIfGd_drawOpaListMiddle() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListMiddle(); } inline void dComIfGd_drawOpaList() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaList(); } inline void dComIfGd_drawOpaListDark() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListDark(); } inline void dComIfGd_drawOpaListPacket() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListPacket(); } inline void dComIfGd_drawXluListBG() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListBG(); } inline void dComIfGd_drawXluListDarkBG() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListDarkBG(); } inline void dComIfGd_drawXluList() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluList(); } inline void dComIfGd_drawXluListDark() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListDark(); } inline void dComIfGd_drawXluListInvisible() { - ZoneScoped; -#ifdef TARGET_PC - if (!dusk::getSettings().game.disableWaterRefraction) { -#endif - g_dComIfG_gameInfo.drawlist.drawXluListInvisible(); -#ifdef TARGET_PC - } -#endif + g_dComIfG_gameInfo.drawlist.drawXluListInvisible(); } inline void dComIfGd_drawOpaListInvisible() { - ZoneScoped; -#ifdef TARGET_PC - if (!dusk::getSettings().game.disableWaterRefraction) { -#endif - g_dComIfG_gameInfo.drawlist.drawOpaListInvisible(); -#ifdef TARGET_PC - } -#endif + g_dComIfG_gameInfo.drawlist.drawOpaListInvisible(); } inline void dComIfGd_drawXluListZxlu() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListZxlu(); } inline void dComIfGd_drawXluList2DScreen() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluList2DScreen(); } inline void dComIfGd_drawOpaList3Dlast() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaList3Dlast(); } inline void dComIfGd_draw2DOpa() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.draw2DOpa(); } inline void dComIfGd_draw2DOpaTop() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.draw2DOpaTop(); } inline void dComIfGd_draw2DXlu() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.draw2DXlu(); } inline void dComIfGd_drawOpaListFilter() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListFilter(); } inline void dComIfGd_drawIndScreen() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawOpaListP0(); } inline void dComIfGd_drawListZxlu() { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawXluListZxlu(); } inline void dComIfGd_drawShadow(Mtx param_0) { - ZoneScoped; g_dComIfG_gameInfo.drawlist.drawShadow(param_0); } inline void dComIfGd_imageDrawShadow(Mtx param_0) { - ZoneScoped; g_dComIfG_gameInfo.drawlist.imageDrawShadow(param_0); } @@ -4929,4 +5786,6 @@ inline void dComIfGd_setListCursor() { } #endif +#endif + #endif /* D_COM_D_COM_INF_GAME_H */ diff --git a/include/d/d_cursor_mng.h b/include/d/d_cursor_mng.h index 38ba03f214..9837e6f1cb 100644 --- a/include/d/d_cursor_mng.h +++ b/include/d/d_cursor_mng.h @@ -95,7 +95,7 @@ class dCsr_mng_c { BOOL set(mDoGph_gInf_c::csr_c* i_csr, u16, u8, u8); }; -private: +public: dCsr_mng_c() : is_csr_on(true) { } @@ -116,7 +116,6 @@ public: static dCsr_mng_c* m_myObj; -private: /* 0x00 */ list_c m_csr_list; /* 0x08 */ list_c m_obj_list; /* 0x10 */ bool is_csr_on; diff --git a/include/d/d_debug_pad.h b/include/d/d_debug_pad.h index 4c5658adf4..b68e8f8b9b 100644 --- a/include/d/d_debug_pad.h +++ b/include/d/d_debug_pad.h @@ -29,6 +29,6 @@ public: /* 0x4 */ s32 mMode; }; -extern dDebugPad_c dDebugPad; +DUSK_GAME_EXTERN dDebugPad_c dDebugPad; #endif diff --git a/include/d/d_demo.h b/include/d/d_demo.h index e72698ed9a..a35c44e0ed 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -155,7 +155,6 @@ public: f32 getAnmTransition() { return mAnmTransition; } u32 getShapeId() { return mShape; } -private: /* 0x04 */ u16 mFlags; /* 0x08 */ cXyz mTrans; /* 0x14 */ cXyz mScale; @@ -220,7 +219,6 @@ public: f32 getFovy() { return mProjFovy; } f32 getRoll() { return mViewRoll; } -private: /* 0x04 */ u8 mFlags; /* 0x08 */ f32 mProjNear; /* 0x0C */ f32 mProjFar; @@ -247,7 +245,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x05 */ GXColor mColor; }; @@ -275,7 +272,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x08 */ JStage::TELight mLightType; /* 0x0C */ GXDistAttnFn mDistAttenFn; @@ -309,7 +305,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x05 */ s8 mFogType; /* 0x08 */ f32 mStartZ; @@ -327,7 +322,6 @@ public: void setObject(dDemo_object_c* i_object) { mpObject = i_object; } -private: /* 0x4 */ dDemo_object_c* mpObject; }; @@ -381,26 +375,26 @@ public: return m_object->getActiveCamera(); } - static s16 m_branchId; + static DUSK_GAME_DATA s16 m_branchId; static u16 m_branchNum; - static dDemo_system_c* m_system; - static JStudio::TControl* m_control; - static JStudio_JStage::TCreateObject* m_stage; - static JStudio_JAudio2::TCreateObject* m_audio; - static dDemo_particle_c* m_particle; - static JStudio::TCreateObject* m_message; - static JStudio::TFactory* m_factory; - static jmessage_tControl* m_mesgControl; - static dDemo_object_c* m_object; - static const u8* m_data; - static int m_frame; - static cXyz* m_translation; - static f32 m_rotationY; - static u32 m_frameNoMsg; - static s32 m_mode; - static u32 m_status; - static u16 m_branchType; - static const u8* m_branchData; + static DUSK_GAME_DATA dDemo_system_c* m_system; + static DUSK_GAME_DATA JStudio::TControl* m_control; + static DUSK_GAME_DATA JStudio_JStage::TCreateObject* m_stage; + static DUSK_GAME_DATA JStudio_JAudio2::TCreateObject* m_audio; + static DUSK_GAME_DATA dDemo_particle_c* m_particle; + static DUSK_GAME_DATA JStudio::TCreateObject* m_message; + static DUSK_GAME_DATA JStudio::TFactory* m_factory; + static DUSK_GAME_DATA jmessage_tControl* m_mesgControl; + static DUSK_GAME_DATA dDemo_object_c* m_object; + static DUSK_GAME_DATA const u8* m_data; + static DUSK_GAME_DATA int m_frame; + static DUSK_GAME_DATA cXyz* m_translation; + static DUSK_GAME_DATA f32 m_rotationY; + static DUSK_GAME_DATA u32 m_frameNoMsg; + static DUSK_GAME_DATA s32 m_mode; + static DUSK_GAME_DATA u32 m_status; + static DUSK_GAME_DATA u16 m_branchType; + static DUSK_GAME_DATA const u8* m_branchData; }; #endif /* D_D_DEMO_H */ diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 8368c9e92e..4baf6ed324 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -5,10 +5,13 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/gx_helper.h" #include "f_op/f_op_view.h" -#include "global.h" #include "m_Do/m_Do_ext.h" +#include "global.h" + +#if TARGET_PC +#include "helpers/gx_helper.h" +#endif class J3DDrawBuffer; class J3DModel; @@ -107,7 +110,6 @@ public: mRnd.init(r0, r1, r2); } -private: /* 0x04 */ cM_rnd_c mRnd; /* 0x10 */ cXyz field_0x10; /* 0x1C */ GXColor mLineColor; @@ -129,7 +131,6 @@ public: void setAlpha(u8 alpha) { mAlpha = alpha; } J2DPicture* getPicture() { return &mpPicture; } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ J2DPicture mpPicture; /* 0x158 */ s16 mPosX; @@ -271,7 +272,6 @@ public: void setZsortNext(dDlst_shadowReal_c* next) { mZsortNext = next; } void setZsortPre(dDlst_shadowReal_c* pre) { mZsortPre = pre; } -private: /* 0x0000 */ u8 mState; /* 0x0001 */ u8 field_0x1; /* 0x0002 */ u8 mModelNum; @@ -301,9 +301,8 @@ public: static TGXTexObj* getSimpleTex() { return &mSimpleTexObj; } - static TGXTexObj mSimpleTexObj; + static DUSK_GAME_DATA TGXTexObj mSimpleTexObj; -private: /* 0x00000 */ u8 field_0x0; /* 0x00001 */ u8 mRealNum; /* 0x00002 */ u8 mSimpleNum; @@ -332,7 +331,6 @@ public: view_port_class* getViewPort() { return &mViewport; } scissor_class* getScissor() { return &mViewport.scissor; } -private: /* 0x00 */ view_port_class mViewport; /* 0x28 */ s8 mCameraID; /* 0x29 */ u8 mMode; @@ -443,7 +441,7 @@ public: } #if TARGET_PC - void refresh3DlineMats(const cXyz& eye); + void refresh3DlineMats(); #endif void peekZdata() { mPeekZ.peekData(); } @@ -512,13 +510,12 @@ public: static void offWipe() { mWipe = 0; } static f32 getWipeRate() { return mWipeRate; } - static dDlst_2DT2_c mWipeDlst; - static GXColor mWipeColor; - static f32 mWipeRate; - static f32 mWipeSpeed; - static u8 mWipe; + static DUSK_GAME_DATA dDlst_2DT2_c mWipeDlst; + static DUSK_GAME_DATA GXColor mWipeColor; + static DUSK_GAME_DATA f32 mWipeRate; + static DUSK_GAME_DATA f32 mWipeSpeed; + static DUSK_GAME_DATA u8 mWipe; -private: /* 0x00000 */ J3DDrawBuffer* mDrawBuffers[DB_LIST_MAX]; /* 0x00054 */ dDlst_base_c* mpCopy2DDrawLists[4]; /* 0x00064 */ dDlst_base_c** mpCopy2DStart; diff --git a/include/d/d_event_data.h b/include/d/d_event_data.h index ee9b868af4..786088250f 100644 --- a/include/d/d_event_data.h +++ b/include/d/d_event_data.h @@ -3,7 +3,10 @@ #include "global.h" #include "f_pc/f_pc_base.h" -#include "dusk/endian.h" + +#if TARGET_PC +#include "helpers/endian.h" +#endif struct msg_class; @@ -190,7 +193,6 @@ public: int getCurrentCut() { return mCurrentCut; } int getStartCut() { return mStartCut; } - // private: /* 0x00 */ char mName[8]; /* 0x08 */ u8 mWork[0x18]; // PROBLEM: this buffer is now too small for StaffWork to fit in /* 0x20 */ BE(s32) mTagID; @@ -293,7 +295,6 @@ public: static const int FlagMax = 0x2800; -private: u32 mFlags[320]; }; // Size = 0x500 @@ -346,7 +347,6 @@ public: void setIDataP(int* p_idata) { mIDataP = p_idata; } void setSDataP(char* p_sdata) { mSDataP = p_sdata; } - // private: /* 0x00 */ event_binary_data_header* mHeaderP; /* 0x04 */ dEvDtEvent_c* mEventP; /* 0x08 */ dEvDtStaff_c* mStaffP; diff --git a/include/d/d_event_manager.h b/include/d/d_event_manager.h index de046797ff..75aa5a4a03 100644 --- a/include/d/d_event_manager.h +++ b/include/d/d_event_manager.h @@ -112,7 +112,6 @@ public: dEvM_HIO_c& getEventHIO(); #endif -private: /* 0x000 */ dEvDtBase_c mEventList[BASE_MAX]; /* 0x18C */ int mCameraPlay; /* 0x190 */ dEvent_exception_c mException; diff --git a/include/d/d_eye_hl.h b/include/d/d_eye_hl.h index e7a4d82d3c..23f93cf83d 100644 --- a/include/d/d_eye_hl.h +++ b/include/d/d_eye_hl.h @@ -17,7 +17,7 @@ public: JUT_ASSERT(51, m_obj == NULL); } - static dEyeHL_c* m_obj; + static DUSK_GAME_DATA dEyeHL_c* m_obj; }; class dEyeHL_c { diff --git a/include/d/d_file_sel_info.h b/include/d/d_file_sel_info.h index 973349c469..89c4272b22 100644 --- a/include/d/d_file_sel_info.h +++ b/include/d/d_file_sel_info.h @@ -37,7 +37,6 @@ public: CPaneMgrAlpha* getNoDatBase() { return mNoDatBase; } void draw() { _draw(); } -private: /* 0x04 */ JKRArchive* mArchive; /* 0x08 */ dDlst_FileInfo_c mFileInfo; /* 0x1C */ u8 field_0x1c[4]; diff --git a/include/d/d_file_select.h b/include/d/d_file_select.h index 634c0db352..dd4d5a3aae 100644 --- a/include/d/d_file_select.h +++ b/include/d/d_file_select.h @@ -9,42 +9,13 @@ #include "JSystem/J3DGraphLoader/J3DModelLoader.h" #include "JSystem/J3DGraphLoader/J3DAnmLoader.h" +#if TARGET_PC +#include "mods/svc/game_mode.h" +#endif + class dFile_info_c; class J2DPicture; -#if TARGET_PC -static PaneCache mSelDtPanes[] = { - {MULTI_CHAR('tate_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('tate_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('ken_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('ken_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n2'), 0.0f, 0.0f, false}, - {MULTI_CHAR('gray_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('b_base'), 0.0f, 0.0f, false}, - {MULTI_CHAR('b_base1'), 0.0f, 0.0f, false}, -}; - -static PaneCache fileSelPanes[] = { - {MULTI_CHAR('w_uzu00'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu01'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu02'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu03'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu04'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu05'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu06'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu07'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu08'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_uzu09'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_er_msg'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_er_msE'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_er_msR'), 0.0f, 0.0f, false}, - {MULTI_CHAR('er_for0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('er_for1'), 0.0f, 0.0f, false}, -}; -#endif - class dDlst_FileSel_c : public dDlst_base_c { public: void draw(); @@ -420,6 +391,13 @@ public: bool pointerMenuSelect(); bool pointerCopyDataToSelect(); bool pointerYesNoSelect(bool errorSelect); + void backToDataSelectMove() { + headerTxtSet(0x43, 1, 0); + fileRecScaleAnmInitSet2(0.0f, 1.0f); + nameMoveAnmInitSet(0xd29, 0xd1f); + modoruTxtDispAnmInit(0); + mDataSelProc = DATASELPROC_NAME_TO_DATA_SELECT_MOVE; + } #endif void _draw(); void errorMoveAnmInitSet(int, int); @@ -728,24 +706,23 @@ public: /* 0x2374 */ u8 mFadeFlag; /* 0x2375 */ bool mHasDrawn; - #if PLATFORM_GCN +#if PLATFORM_GCN /* 0x2378 */ J2DPicture* mpFadePict; - #endif -#ifdef TARGET_PC - dDlst_FileSelFade_c mFadeDlst; #endif - #if PLATFORM_WII || PLATFORM_SHIELD +#if PLATFORM_WII || PLATFORM_SHIELD /* 0x2376 */ u8 field_0x2376[SAVEFILE_SIZE]; /* 0x4332 */ u8 field_0x4332; /* 0x4333 */ u8 field_0x4333; - #endif -}; - -#ifdef TARGET_PC -STATIC_ASSERT(sizeof(dFile_select_c) == 0x237C + sizeof(dDlst_FileSelFade_c)); -#else -STATIC_ASSERT(sizeof(dFile_select_c) == 0x237C); #endif +#if TARGET_PC + dDlst_FileSelFade_c mFadeDlst; + bool mGameModeSaveStartBuildUi = true; + GameModeNewSaveState mGameModeNewSaveState = GAME_MODE_STATE_PENDING; +#endif +}; + +STATIC_ASSERT(sizeof(dFile_select_c) == 0x237C); + #endif /* D_FILE_D_FILE_SELECT_H */ diff --git a/include/d/d_item.h b/include/d/d_item.h index 0d379c0578..bf1252f9d6 100644 --- a/include/d/d_item.h +++ b/include/d/d_item.h @@ -8,10 +8,12 @@ public: static void setItemData(u8* data) { mData = data; } static u8* getItemData() { return mData; } - static u8* mData; + static DUSK_GAME_DATA u8* mData; }; -void execItemGet(u8 item_id); +class fopAc_ac_c; +void execItemGet( + u8 item_id IF_DUSK_ARG(u32 item_give_tag = 0) IF_DUSK_ARG(fopAc_ac_c* giver = NULL)); void item_func_HEART(); void item_func_GREEN_RUPEE(); diff --git a/include/d/d_item_data.h b/include/d/d_item_data.h index a1770be241..7672174c87 100644 --- a/include/d/d_item_data.h +++ b/include/d/d_item_data.h @@ -86,9 +86,9 @@ struct dItem_data { static u16 getFieldHeapSize(u8 index) { return field_item_res[index].mHeapSize; } - static dItem_itemResource item_resource[255]; - static dItem_fieldItemResource field_item_res[255]; - static dItem_itemInfo item_info[255]; + static DUSK_GAME_DATA dItem_itemResource item_resource[255]; + static DUSK_GAME_DATA dItem_fieldItemResource field_item_res[255]; + static DUSK_GAME_DATA dItem_itemInfo item_info[255]; }; enum { @@ -142,7 +142,12 @@ enum { /* 0x2F */ dItemNo_WEAR_KOKIRI_e, /* 0x30 */ dItemNo_ARMOR_e, /* 0x31 */ dItemNo_WEAR_ZORA_e, +#if TARGET_PC /* 0x32 */ dItemNo_MAGIC_LV1_e, + dItemNo_SHADOW_CRYSTAL_e = dItemNo_MAGIC_LV1_e, +#else + /* 0x32 */ dItemNo_MAGIC_LV1_e, +#endif /* 0x33 */ dItemNo_DUNGEON_EXIT_2_e, /* 0x34 */ dItemNo_WALLET_LV1_e, /* 0x35 */ dItemNo_WALLET_LV2_e, diff --git a/include/d/d_k_wmark.h b/include/d/d_k_wmark.h index 0190c94467..b4f28d1263 100644 --- a/include/d/d_k_wmark.h +++ b/include/d/d_k_wmark.h @@ -13,7 +13,7 @@ public: inline int execute(); inline int draw(); - static int m_nowID; + static DUSK_GAME_DATA int m_nowID; static void setFootMark(cXyz* i_pos, s16 param_1, int param_2) { fopKyM_create(fpcNm_WMARK_e, param_2 | (param_1 << 0x10), i_pos, NULL, NULL); diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index 06c8f0eb56..1a43d811f7 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -471,7 +471,7 @@ public: /* 0x130C */ u8 staffroll_next_timer; }; // Size: 0x1310 -extern dScnKy_env_light_c g_env_light; +DUSK_GAME_EXTERN dScnKy_env_light_c g_env_light; STATIC_ASSERT(sizeof(dScnKy_env_light_c) == 4880); @@ -967,7 +967,7 @@ public: /* 0x7A0 */ dKankyo_ParticlelightHIO_c particleLight; }; -extern dKankyo_HIO_c g_kankyoHIO; +DUSK_GAME_EXTERN dKankyo_HIO_c g_kankyoHIO; enum dKy_dice_wether_mode { DICE_MODE_SUNNY_e, diff --git a/include/d/d_kantera_icon_meter.h b/include/d/d_kantera_icon_meter.h index 04466df8be..cf1464e82f 100644 --- a/include/d/d_kantera_icon_meter.h +++ b/include/d/d_kantera_icon_meter.h @@ -13,7 +13,6 @@ public: void setScreen(J2DScreen* screen) { mp_scrn = screen; } J2DScreen* getScreen() { return mp_scrn; } -private: /* 0x04 */ J2DScreen* mp_scrn; }; @@ -30,7 +29,6 @@ public: void drawSelf() { mpKanteraIcon->draw(); } -private: /* 0x04 */ dDlst_KanteraIcon_c* mpKanteraIcon; /* 0x08 */ CPaneMgr* mpParent; /* 0x0C */ CPaneMgr* mpGauge; diff --git a/include/d/d_ky_thunder.h b/include/d/d_ky_thunder.h index 1e174ad6f8..5a72252a9a 100644 --- a/include/d/d_ky_thunder.h +++ b/include/d/d_ky_thunder.h @@ -25,7 +25,6 @@ public: ~dThunder_c() { mDoExt_destroySolidHeap(mpHeap); } -private: /* 0x0F8 */ JKRSolidHeap* mpHeap; /* 0x0FC */ dThunder_modelInfo_c mModelInfo; /* 0x138 */ cXyz field_0x138; diff --git a/include/d/d_lib.h b/include/d/d_lib.h index 1d3103ce96..c4f8fed7bb 100644 --- a/include/d/d_lib.h +++ b/include/d/d_lib.h @@ -85,11 +85,11 @@ struct dLib_time_c { static void stopTime(); static void startTime(); - static OSTime m_diffTime; - static OSTime m_stopTime; - static bool m_timeStopped; + static DUSK_GAME_DATA OSTime m_diffTime; + static DUSK_GAME_DATA OSTime m_stopTime; + static DUSK_GAME_DATA bool m_timeStopped; }; -extern Quaternion ZeroQuat; +DUSK_GAME_EXTERN Quaternion ZeroQuat; #endif /* D_D_LIB_H */ diff --git a/include/d/d_map.h b/include/d/d_map.h index 1cddbf3944..b70238cc46 100644 --- a/include/d/d_map.h +++ b/include/d/d_map.h @@ -87,7 +87,7 @@ struct dMap_HIO_prm_res_src_s { }; struct dMap_HIO_prm_res_dst_s { - static dMap_prm_res_s* m_res; + static DUSK_GAME_DATA dMap_prm_res_s* m_res; static dMap_HIO_prm_other_s m_other; }; @@ -134,7 +134,6 @@ public: static const int PALETTE_NUMBER = 50; #endif -private: /* 0x34 */ s32 m_outSideBlackLineCnt; /* 0x38 */ s32 field_0x38; /* 0x3C */ s32 field_0x3c; @@ -199,7 +198,6 @@ public: static dMap_c* m_mySelfPointer; -private: /* 0x40 */ dMap_prm_res_s* m_res_src; /* 0x44 */ dMap_prm_res_s* m_res; /* 0x48 */ ResTIMG* mResTIMG; diff --git a/include/d/d_map_path.h b/include/d/d_map_path.h index 495fdf396a..885c7ade87 100644 --- a/include/d/d_map_path.h +++ b/include/d/d_map_path.h @@ -260,7 +260,7 @@ struct dMpath_n { /* 0x0 */ TGXTexObj* mp_texObj[TEX_OBJ_NUMBER]; }; - static dTexObjAggregate_c m_texObjAgg; + static DUSK_GAME_DATA dTexObjAggregate_c m_texObjAgg; }; STATIC_ASSERT(sizeof(dMpath_n::dTexObjAggregate_c) == 28); diff --git a/include/d/d_map_path_dmap.h b/include/d/d_map_path_dmap.h index bbffcd7809..7d23be73c9 100644 --- a/include/d/d_map_path_dmap.h +++ b/include/d/d_map_path_dmap.h @@ -33,17 +33,17 @@ public: static f32 getCenterX() { return mAllCenterX; } static f32 getCenterZ() { return mAllCenterZ; } - static dDrawPath_c::layer_data* mLayerList; // this doesn't seem right, but can't figure it out atm - static f32 mMinX; - static f32 mMaxX; - static f32 mMinZ; - static f32 mMaxZ; - static f32 mAllCenterX; - static f32 mAllCenterZ; - static f32 mAllSizeX; - static f32 mAllSizeZ; - static s8 mBottomFloorNo; - static s8 mTopFloorNo; + static DUSK_GAME_DATA dDrawPath_c::layer_data* mLayerList; // this doesn't seem right, but can't figure it out atm + static DUSK_GAME_DATA f32 mMinX; + static DUSK_GAME_DATA f32 mMaxX; + static DUSK_GAME_DATA f32 mMinZ; + static DUSK_GAME_DATA f32 mMaxZ; + static DUSK_GAME_DATA f32 mAllCenterX; + static DUSK_GAME_DATA f32 mAllCenterZ; + static DUSK_GAME_DATA f32 mAllSizeX; + static DUSK_GAME_DATA f32 mAllSizeZ; + static DUSK_GAME_DATA s8 mBottomFloorNo; + static DUSK_GAME_DATA s8 mTopFloorNo; }; struct dMapInfo_n { @@ -90,10 +90,10 @@ public: static void setNextRoomNoForMapPat0(int i_roomNo) { mNextRoomNo = i_roomNo; } static int getNextRoomNoForMapPat0() { return mNextRoomNo; } - static int mNextRoomNo; - static int mNowStayRoomNo; - static s8 mNowStayFloorNo; - static u8 mNowStayFloorNoDecisionFlg; + static DUSK_GAME_DATA int mNextRoomNo; + static DUSK_GAME_DATA int mNowStayRoomNo; + static DUSK_GAME_DATA s8 mNowStayFloorNo; + static DUSK_GAME_DATA u8 mNowStayFloorNoDecisionFlg; }; class renderingDAmap_c : public dRenderingFDAmap_c { diff --git a/include/d/d_menu_collect.h b/include/d/d_menu_collect.h index d99b8f17cb..d2a4028b2e 100644 --- a/include/d/d_menu_collect.h +++ b/include/d/d_menu_collect.h @@ -15,49 +15,6 @@ class dMenu_Fishing_c; class dMenu_Skill_c; class dMenu_Insect_c; class dSelect_cursor_c; - -#if TARGET_PC -struct PaneCache { - u64 tag; - f32 origTransX; - f32 origTransY; - bool cached; -}; - -static PaneCache mpScreenPanes[] = { - {MULTI_CHAR('sa_tex_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('op_tex_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('heart_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('wolf_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('item_0_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('item_1_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('item_2_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fish_3_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('lett_4_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('maki_5_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('fuku_n2'), 0.0f, 0.0f, false}, - {MULTI_CHAR('tate_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('tate_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('ken_n0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('ken_n1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('kabu_6n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('t_t00'), 0.0f, 0.0f, false}, - {MULTI_CHAR('f_t00'), 0.0f, 0.0f, false}, - {MULTI_CHAR('itemn_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('infotxtn'), 0.0f, 0.0f, false}, - {MULTI_CHAR('sa_op_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('title_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('menu_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('w_er_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('center_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('info_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('lavel_n'), 0.0f, 0.0f, false}, - {MULTI_CHAR('modelbgn'), 0.0f, 0.0f, false}, -}; -#endif - class dMenu_Collect2D_c; class dMenu_Collect2DTop_c : public dDlst_base_c { public: @@ -172,7 +129,6 @@ public: J2DPicture* getBlackTex() { return mpBlackTex; } u8 getSubWindowOpenCheck() { return mSubWindowOpenCheck; } -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRExpHeap* mpSubHeap; /* 0x00C */ void* field_0xc; @@ -266,9 +222,8 @@ public: mViewOffsetY = i_offset; } - static f32 mViewOffsetY; + static DUSK_GAME_DATA f32 mViewOffsetY; -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRSolidHeap* mpSolidHeap; /* 0x00C */ dMenu_Collect2D_c* mpCollect2D; @@ -303,7 +258,6 @@ public: bool isKeyCheck() { return mpCollect2D->isKeyCheck(); } bool isOutCheck() { return mpCollect2D->isOutCheck(); } -private: /* 0x4 */ dMenu_Collect2D_c* mpCollect2D; /* 0x8 */ dMenu_Collect3D_c* mpCollect3D; }; diff --git a/include/d/d_menu_dmap.h b/include/d/d_menu_dmap.h index 7740927f4e..039b42aab2 100644 --- a/include/d/d_menu_dmap.h +++ b/include/d/d_menu_dmap.h @@ -253,9 +253,8 @@ public: s8 getFloorPos(s8 param_0) { return param_0 - mBottomFloor; } u16 getCMessageNum() { return mCMessageNum; } - static dMenu_Dmap_c* myclass; + static DUSK_GAME_DATA dMenu_Dmap_c* myclass; -private: /* 0x004 */ dMenu_DmapMapCtrl_c* mMapCtrl; /* 0x008 */ dMenu_DmapBg_c* mpDrawBg; /* 0x00C */ u8 field_0xc[0x10 - 0xC]; diff --git a/include/d/d_menu_dmap_map.h b/include/d/d_menu_dmap_map.h index f1a5432391..3f3eb37a0f 100644 --- a/include/d/d_menu_dmap_map.h +++ b/include/d/d_menu_dmap_map.h @@ -151,10 +151,10 @@ public: ResTIMG* getResTIMGPointer(int i_no) const { return dMenu_DmapMap_c::getResTIMGPointer(i_no); } - static f32 m_zoomCenterMinX; - static f32 m_zoomCenterMaxX; - static f32 m_zoomCenterMinZ; - static f32 m_zoomCenterMaxZ; + static DUSK_GAME_DATA f32 m_zoomCenterMinX; + static DUSK_GAME_DATA f32 m_zoomCenterMaxX; + static DUSK_GAME_DATA f32 m_zoomCenterMinZ; + static DUSK_GAME_DATA f32 m_zoomCenterMaxZ; /* 0x88 */ u8 field_0x88[0x8C - 0x88]; /* 0x8C */ dTres_c::typeGroupData_c* field_0x8c; diff --git a/include/d/d_menu_fishing.h b/include/d/d_menu_fishing.h index 972aa8f7c4..b3b451c968 100644 --- a/include/d/d_menu_fishing.h +++ b/include/d/d_menu_fishing.h @@ -43,7 +43,6 @@ public: u8 getStatus() { return mStatus; } -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_fmap.h b/include/d/d_menu_fmap.h index 48db37fef3..3104d7e76b 100644 --- a/include/d/d_menu_fmap.h +++ b/include/d/d_menu_fmap.h @@ -268,9 +268,8 @@ public: /* 0x1D */ PROC_HOWL_DEMO3, }; - static dMenu_Fmap_c* MyClass; + static DUSK_GAME_DATA dMenu_Fmap_c* MyClass; -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRExpHeap* mpTalkHeap; /* 0x00C */ STControl* mpStick; @@ -356,7 +355,7 @@ public: /* 0x10 */ u8 mBaseBackAlpha; /* 0x11 */ u8 mMoyaAlpha; - static dMf_HIO_c* mMySelfPointer; + static DUSK_GAME_DATA dMf_HIO_c* mMySelfPointer; }; const char* dMenuFmap_getStartStageName(void* param_0); diff --git a/include/d/d_menu_fmap_map.h b/include/d/d_menu_fmap_map.h index 95294ffb35..b0d1063d18 100644 --- a/include/d/d_menu_fmap_map.h +++ b/include/d/d_menu_fmap_map.h @@ -28,7 +28,7 @@ struct dMfm_prm_res_s { struct dMfm_HIO_prm_res_src_s { /* 0x0 */ u8 mFlashDuration; - static const dMfm_HIO_prm_res_src_s m_other; + static DUSK_GAME_DATA const dMfm_HIO_prm_res_src_s m_other; }; struct dMfm_HIO_prm_res_dst_s { diff --git a/include/d/d_menu_insect.h b/include/d/d_menu_insect.h index 90cfca7d5a..43f4af0602 100644 --- a/include/d/d_menu_insect.h +++ b/include/d/d_menu_insect.h @@ -60,7 +60,6 @@ public: u8 getStatus() { return mStatus; } -private: /* 0x04 */ JKRExpHeap* mpHeap; /* 0x08 */ JKRArchive* mpArchive; /* 0x0C */ STControl* mpStick; diff --git a/include/d/d_menu_item_explain.h b/include/d/d_menu_item_explain.h index 7b79ebbad5..59d212e53f 100644 --- a/include/d/d_menu_item_explain.h +++ b/include/d/d_menu_item_explain.h @@ -51,7 +51,6 @@ public: field_0xd8 = y; } -private: /* 0x04 */ JKRExpHeap* mpHeap; /* 0x08 */ JKRArchive* mpArchive; /* 0x0C */ dMsgString_c* mpInfoString; diff --git a/include/d/d_menu_letter.h b/include/d/d_menu_letter.h index 208f8b65a9..8e112f04d2 100644 --- a/include/d/d_menu_letter.h +++ b/include/d/d_menu_letter.h @@ -64,7 +64,6 @@ public: u8 getStatus() { return mStatus; } -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_option.h b/include/d/d_menu_option.h index 03aca42808..ff4b84f5e3 100644 --- a/include/d/d_menu_option.h +++ b/include/d/d_menu_option.h @@ -17,6 +17,20 @@ class dSelect_cursor_c; class dMenu_Option_c : public dDlst_base_c { public: + enum { + PROC_ATTEN_e, +#if TARGET_PC || VERSION == VERSION_GCN_JPN + PROC_RUBY_e, +#endif + PROC_VIB_e, + PROC_SOUND_e, + PROC_CHANGE_MOVE_e, + PROC_CONFIRM_OPEN_MOVE_e, + PROC_CONFIRM_MOVE_MOVE_e, + PROC_CONFIRM_SELECT_MOVE_e, + PROC_CONFIRM_CLOSE_MOVE_e, + }; + dMenu_Option_c(JKRArchive*, STControl*); void _create(); void _delete(); @@ -31,7 +45,7 @@ public: bool _close(); void atten_init(); void atten_move(); -#if VERSION == VERSION_GCN_JPN +#if TARGET_PC || VERSION == VERSION_GCN_JPN void ruby_init(); void ruby_move(); #endif @@ -103,7 +117,6 @@ public: return ((u8)mUseFlag & (u8)i_flag) != 0 ? true : false; } -private: /* 0x004 */ J2DScreen* mpBackScreen; /* 0x008 */ J2DScreen* mpScreen; /* 0x00C */ J2DScreen* mpClipScreen; @@ -189,7 +202,7 @@ private: /* 0x3E2 */ u8 field_0x3e2; /* 0x3E3 */ u8 field_0x3e3; /* 0x3E4 */ u8 field_0x3e4; -#if VERSION == VERSION_GCN_JPN +#if TARGET_PC || VERSION == VERSION_GCN_JPN /* 0x3E5 */ u8 field_0x3e5_JPN; #endif /* 0x3E5 */ u8 field_0x3e5; diff --git a/include/d/d_menu_ring.h b/include/d/d_menu_ring.h index c7467d2a4b..fa4f97496f 100644 --- a/include/d/d_menu_ring.h +++ b/include/d/d_menu_ring.h @@ -84,7 +84,6 @@ public: void drawFlag0() { mDrawFlag = 0; } void setStatus(u8 i_status) { mStatus = i_status; } -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ STControl* mpStick; /* 0x00C */ CSTControl* mpCStick; diff --git a/include/d/d_menu_save.h b/include/d/d_menu_save.h index d9d052aa33..a237bbb849 100644 --- a/include/d/d_menu_save.h +++ b/include/d/d_menu_save.h @@ -27,7 +27,6 @@ public: void setScrnExplain(dMsgScrnExplain_c* p_scrn) { mpScrn = p_scrn; } -private: /* 0x4 */ dMsgScrnExplain_c* mpScrn; }; @@ -278,7 +277,6 @@ public: u8 getEndStatus() { return mEndStatus; } void setUseType(u8 type) { mUseType = type; } -private: /* 0x0004 */ JKRArchive* mpArchive; /* 0x0008 */ mDoDvdThd_mountArchive_c* mpMount; /* 0x000C */ STControl* stick; diff --git a/include/d/d_menu_skill.h b/include/d/d_menu_skill.h index 2f9097b165..2c2dc445d1 100644 --- a/include/d/d_menu_skill.h +++ b/include/d/d_menu_skill.h @@ -58,7 +58,6 @@ public: u8 getStatus() { return mStatus; } -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_window.h b/include/d/d_menu_window.h index 65e415077d..1c5aeadbe5 100644 --- a/include/d/d_menu_window.h +++ b/include/d/d_menu_window.h @@ -193,7 +193,6 @@ public: bool isShowFlag() { return (mShowFlag & 1) != 0; } bool isFadeNowCheck() { return mDoGph_gInf_c::getFader()->getStatus() == 1; } -private: /* 0x0FC */ int field_0xfc; /* 0x100 */ JKRExpHeap* mpHeap; /* 0x104 */ STControl* mpStick; diff --git a/include/d/d_menu_window_HIO.h b/include/d/d_menu_window_HIO.h index b5d5c81fb4..7ac32267c8 100644 --- a/include/d/d_menu_window_HIO.h +++ b/include/d/d_menu_window_HIO.h @@ -31,7 +31,7 @@ public: /* 0x1E5 */ u8 mMidBossClearCopy[32]; }; -extern dMw_DHIO_c g_mwDHIO; +DUSK_GAME_EXTERN dMw_DHIO_c g_mwDHIO; class dMw_HIO_c : public JORReflexible { public: @@ -131,6 +131,6 @@ public: /* 0x12A */ u8 mMirrorShardCopy[4]; }; // Size: 0x130 -extern dMw_HIO_c g_mwHIO; +DUSK_GAME_EXTERN dMw_HIO_c g_mwHIO; #endif /* D_MENU_D_MENU_WINDOW_HIO_H */ diff --git a/include/d/d_meter2.h b/include/d/d_meter2.h index c8dc17bca8..4246d9249d 100644 --- a/include/d/d_meter2.h +++ b/include/d/d_meter2.h @@ -100,7 +100,6 @@ public: bool isShowFlag(int i_no) { return field_0x1e6 & (1 << i_no); } void onShowFlag(int i_no) { field_0x1e6 |= (1 << i_no); } -private: /* 0x0FC */ int field_0xfc; /* 0x100 */ JKRExpHeap* mpHeap; /* 0x104 */ JKRExpHeap* mpSubHeap; diff --git a/include/d/d_meter2_draw.h b/include/d/d_meter2_draw.h index 10cded803d..c9dc8217e9 100644 --- a/include/d/d_meter2_draw.h +++ b/include/d/d_meter2_draw.h @@ -154,7 +154,6 @@ public: } #endif -private: /* 0x004 */ item_params mItemParams[4]; /* 0x074 */ JKRExpHeap* heap; /* 0x078 */ J2DScreen* mpScreen; diff --git a/include/d/d_meter2_info.h b/include/d/d_meter2_info.h index 683e555386..377f51c34b 100644 --- a/include/d/d_meter2_info.h +++ b/include/d/d_meter2_info.h @@ -21,7 +21,7 @@ struct dMenu_Letter { static u16 getLetterText(int idx) { return letter_data[idx].mText; } static u16 getLetterEventFlag(int idx) { return letter_data[idx].mEventFlag; } - static dMenu_LetterData letter_data[64]; + static DUSK_GAME_DATA dMenu_LetterData letter_data[64]; }; class dMw_c; @@ -301,7 +301,7 @@ public: /* 0xF3 */ u8 unk_0xf3[5]; }; -extern dMeter2Info_c g_meter2_info; +DUSK_GAME_EXTERN dMeter2Info_c g_meter2_info; void dMeter2Info_setSword(u8 i_itemId, bool i_offItemBit); void dMeter2Info_setCloth(u8 i_clothId, bool i_offItemBit); @@ -328,6 +328,150 @@ void dMeter2Info_onWide2D(); void dMeter2Info_offWide2D(); #endif +#if TARGET_PC +DUSK_NOINLINE void dMeter2Info_Initialize(); +DUSK_NOINLINE dMeterMap_c* dMeter2Info_getMeterMapClass(); +DUSK_NOINLINE dMw_c* dMeter2Info_getMenuWindowClass(); +DUSK_NOINLINE void dMeter2Info_setWindowStatus(u8 i_status); +DUSK_NOINLINE CPaneMgr* dMeter2Info_getMeterItemPanePtr(s32 i_idx); +DUSK_NOINLINE void dMeter2Info_getString( + u32 i_stringID, TEXT_SPAN o_string, JMSMesgEntry_c* i_msgEntry); +DUSK_NOINLINE void dMeter2Info_getStringKanji( + u32 i_stringID, TEXT_SPAN o_string, JMSMesgEntry_c* i_msgEntry); +DUSK_NOINLINE void dMeter2Info_getStringKana( + u32 i_stringID, TEXT_SPAN o_string, JMSMesgEntry_c* i_msgEntry); +DUSK_NOINLINE f32 dMeter2Info_getStringLength( + JUTFont* i_font, f32 param_2, f32 param_3, char* i_string); +DUSK_NOINLINE f32 dMeter2Info_getStringLength(J2DTextBox* i_textbox, char* i_string); +DUSK_NOINLINE void dMeter2Info_setHotSpringTimer(u8 i_slotNo); +DUSK_NOINLINE u16 dMeter2Info_getOilGaugeBackUp(); +DUSK_NOINLINE void dMeter2Info_setOilGaugeBackUp(u16 param_1); +DUSK_NOINLINE void dMeter2Info_setSaveStageName(const char* i_stageName); +DUSK_NOINLINE u8 dMeter2Info_getInsectSelectType(); +DUSK_NOINLINE void dMeter2Info_setInsectSelectType(u8 i_type); +DUSK_NOINLINE u8 dMeter2Info_getWarpStatus(); +DUSK_NOINLINE void dMeter2Info_setWarpStatus(u8 i_status); +DUSK_NOINLINE int dMeter2Info_readItemTexture(u8 i_itemNo, void* i_texBuf1, J2DPicture* i_pic1, + void* i_texBuf2, J2DPicture* i_pic2, void* i_texBuf3, J2DPicture* i_pic3, void* i_texBuf4, + J2DPicture* i_pic4, int param_9); +DUSK_NOINLINE void dMeter2Info_setItemColor( + u8 i_itemNo, J2DPicture* i_pic1, J2DPicture* i_pic2, J2DPicture* i_pic3, J2DPicture* i_pic4); +DUSK_NOINLINE u8 dMeter2Info_getWarpRoomNo(); +DUSK_NOINLINE u8 dMeter2Info_getWarpPlayerNo(); +DUSK_NOINLINE cXyz& dMeter2Info_getWarpPos(); +DUSK_NOINLINE const char* dMeter2Info_getWarpStageName(); +DUSK_NOINLINE void dMeter2Info_setNowCount(u8 i_count); +DUSK_NOINLINE void dMeter2Info_setMaxCount(u8 i_count); +DUSK_NOINLINE BOOL dMeter2Info_isDirectUseItem(int param_0); +DUSK_NOINLINE bool dMeter2Info_isUseButton(int i_buttonBit); +DUSK_NOINLINE void dMeter2Info_setMeterMapClass(dMeterMap_c* i_map); +DUSK_NOINLINE void dMeter2Info_decHotSpringTimer(); +DUSK_NOINLINE void dMeter2Info_allUseButton(); +DUSK_NOINLINE void dMeter2Info_offUseButton(int i_buttonBit); +DUSK_NOINLINE void dMeter2Info_resetGameStatus(); +DUSK_NOINLINE void dMeter2Info_onGameStatus(int i_status); +DUSK_NOINLINE void dMeter2Info_setMapStatus(u8 i_status); +DUSK_NOINLINE u8 dMeter2Info_getMapStatus(); +DUSK_NOINLINE void dMeter2Info_setPauseStatus(u8 i_status); +DUSK_NOINLINE void dMeter2Info_resetPauseStatus(); +DUSK_NOINLINE u8 dMeter2Info_getPauseStatus(); +DUSK_NOINLINE bool dMeter2Info_isGameStatus(int i_status); +DUSK_NOINLINE bool dMeter2Info_isTouchKeyCheck(int i_status); +DUSK_NOINLINE void dMeter2Info_setMapKeyDirection(u16 i_direction); +DUSK_NOINLINE bool dMeter2Info_isSub2DStatus(int i_flag); +DUSK_NOINLINE void dMeter2Info_offMenuInForce(int i_flag); +DUSK_NOINLINE bool dMeter2Info_isMenuInForce(int i_flag); +DUSK_NOINLINE void dMeter2Info_setMenuWindowClass(dMw_c* i_menu); +DUSK_NOINLINE void dMeter2Info_resetWarpStatus(); +DUSK_NOINLINE u16 dMeter2Info_getMapKeyDirection(); +DUSK_NOINLINE u8 dMeter2Info_getWindowStatus(); +DUSK_NOINLINE void dMeter2Info_setMsgResource(void* i_res); +DUSK_NOINLINE void dMeter2Info_setStageMsgResource(void* i_res); +DUSK_NOINLINE void dMeter2Info_setMsgUnitResource(void* i_res); +DUSK_NOINLINE void* dMeter2Info_getMsgResource(); +DUSK_NOINLINE void* dMeter2Info_getStageMsgResource(); +DUSK_NOINLINE void* dMeter2Info_getMsgUnitResource(); +DUSK_NOINLINE u8 dMeter2Info_getLightDropGetFlag(int i_no); +DUSK_NOINLINE s32 dMeter2Info_getMeterStringType(); +DUSK_NOINLINE void dMeter2Info_setMeterClass(dMeter2_c* i_meter); +DUSK_NOINLINE void dMeter2Info_onLifeGaugeSE(); +DUSK_NOINLINE void dMeter2Info_offLifeGaugeSE(); +DUSK_NOINLINE u8 dMeter2Info_getLifeGaugeSE(); +DUSK_NOINLINE const char* dMeter2Info_getSaveStageName(); +DUSK_NOINLINE void dMeter2Info_onShopTalkFlag(); +DUSK_NOINLINE void dMeter2Info_setLightDropGetFlag(int i_no, u8 i_flag); +DUSK_NOINLINE u8 dMeter2Info_getRentalBombBag(); +DUSK_NOINLINE u8 dMeter2Info_getMiniGameItemSetFlag(); +DUSK_NOINLINE void dMeter2Info_setMiniGameItem(u8 i_minigameFlag); +DUSK_NOINLINE void dMeter2Info_resetMiniGameItem(bool i_saveItem); +DUSK_NOINLINE void dMeter2Info_setTableMapRegionNo(u8 i_regionNo); +DUSK_NOINLINE void dMeter2Info_setGoldWolfMapType(u8 i_mapType); +DUSK_NOINLINE void dMeter2Info_changeWater(u8 i_slotNo); +DUSK_NOINLINE void dMeter2Info_warpInProc(); +DUSK_NOINLINE void dMeter2Info_warpOutProc(); +DUSK_NOINLINE dMeter2_c* dMeter2Info_getMeterClass(); +DUSK_NOINLINE s16 dMeter2Info_getMsgKeyWaitTimer(); +DUSK_NOINLINE void dMeter2Info_onDirectUseItem(int param_0); +DUSK_NOINLINE void dMeter2Info_setFloatingFlow(u16 i_flowID, s16 i_msgTimer, bool i_wakuVisible); +DUSK_NOINLINE u8 dMeter2Info_getGameOverType(); +DUSK_NOINLINE void dMeter2Info_setGameOverType(u8 i_gameoverType); +DUSK_NOINLINE void dMeter2Info_setMsgKeyWaitTimer(s16 i_waitTimer); +DUSK_NOINLINE s32 dMeter2Info_getMsgTimeMs(); +DUSK_NOINLINE s32 dMeter2Info_getTimeMs(); +DUSK_NOINLINE void dMeter2Info_setMsgTimeMs(s32 i_msgTime); +DUSK_NOINLINE void dMeter2Info_setTimeMs(s32 i_time); +DUSK_NOINLINE u8 dMeter2Info_getNowCount(); +DUSK_NOINLINE u8 dMeter2Info_getMaxCount(); +DUSK_NOINLINE void dMeter2Info_setScopeZoomPointer(u8 param_0); +DUSK_NOINLINE void dMeter2Info_decMsgKeyWaitTimer(); +DUSK_NOINLINE bool dMeter2Info_isFloatingMessageVisible(); +DUSK_NOINLINE u8 dMeter2Info_getItemExplainWindowStatus(); +DUSK_NOINLINE void dMeter2Info_setItemExplainWindowStatus(u8 i_value); +DUSK_NOINLINE void dMeter2Info_resetDirectUseItem(); +DUSK_NOINLINE u16 dMeter2Info_getFloatingFlowID(); +DUSK_NOINLINE u8 dMeter2Info_getCollectCursorPosX(); +DUSK_NOINLINE u8 dMeter2Info_getCollectCursorPosY(); +DUSK_NOINLINE void dMeter2Info_setCollectCursorPosXY(u8 x, u8 y); +DUSK_NOINLINE void dMeter2Info_onBlinkButton(int i_flag); +DUSK_NOINLINE bool dMeter2Info_isFloatingMessageWakuVisible(); +DUSK_NOINLINE bool dMeter2Info_isBlinkButton(int i_flag); +DUSK_NOINLINE void dMeter2Info_resetBlinkButton(); +DUSK_NOINLINE void dMeter2Info_resetFloatingMessage(); +DUSK_NOINLINE s16 dMeter2Info_decFloatingMessageTimer(); +DUSK_NOINLINE s16 dMeter2Info_getFloatingMessageTimer(); +DUSK_NOINLINE u16 dMeter2Info_getFloatingMessageID(); +DUSK_NOINLINE s16 dMeter2Info_getHorseLifeCount(); +DUSK_NOINLINE void dMeter2Info_setMeterString(s32 i_string); +DUSK_NOINLINE void dMeter2Info_resetMeterString(); +DUSK_NOINLINE void dMeter2Info_setMeterItemPanePtr(int i_no, CPaneMgr* i_pane); +DUSK_NOINLINE bool dMeter2Info_isShopTalkFlag(); +DUSK_NOINLINE void dMeter2Info_setMapDrugFlag(bool i_flag); +DUSK_NOINLINE bool dMeter2Info_isTempBit(int i_bit); +DUSK_NOINLINE void dMeter2Info_offSub2DStatus(int i_bit); +DUSK_NOINLINE void dMeter2Info_onSub2DStatus(int i_bit); +DUSK_NOINLINE void dMeter2Info_set2DWidth(f32 i_width); +DUSK_NOINLINE void dMeter2Info_set2DHeight(f32 i_height); +DUSK_NOINLINE void dMeter2Info_set2DPosH(f32 i_posH); +DUSK_NOINLINE void dMeter2Info_set2DPosV(f32 i_posV); +DUSK_NOINLINE void dMeter2Info_offShopTalkFlag(); +DUSK_NOINLINE void dMeter2Info_onUseButton(int i_button); +DUSK_NOINLINE f32 dMeter2Info_get2DWidth(); +DUSK_NOINLINE f32 dMeter2Info_get2DHeight(); +DUSK_NOINLINE void dMeter2Info_setWarpInfo(const char* i_stageName, const cXyz& i_position, + s16 i_angle, u8 i_roomNo, u8 param_4, u8 i_warpPlayerNo); +DUSK_NOINLINE u8 dMeter2Info_getTableMapRegionNo(); +DUSK_NOINLINE u8 dMeter2Info_getGoldWolfMapType(); +DUSK_NOINLINE bool dMeter2Info_isWindowAccept(int param_0); +DUSK_NOINLINE void dMeter2Info_setHorseLifeCount(s16 i_count); +DUSK_NOINLINE void dMeter2Info_offTempBit(int i_bit); +DUSK_NOINLINE void dMeter2Info_onTempBit(int i_bit); +DUSK_NOINLINE void dMeter2Info_setFloatingMessage(u16 i_msgID, s16 i_msgTimer, bool i_wakuVisible); +DUSK_NOINLINE void dMeter2Info_setMiniGameCount(s8 i_count); +DUSK_NOINLINE void dMeter2Info_onWindowAccept(int param_0); +DUSK_NOINLINE void dMeter2Info_offWindowAccept(int param_0); +DUSK_NOINLINE void dMeter2Info_onMenuInForce(int param_0); + +#else inline void dMeter2Info_Initialize() { g_meter2_info.init(); } @@ -865,4 +1009,6 @@ inline void dMeter2Info_onMenuInForce(int param_0) { g_meter2_info.onMenuInForce(param_0); } +#endif + #endif /* D_METER_D_METER2_INFO_H */ diff --git a/include/d/d_meter_HIO.h b/include/d/d_meter_HIO.h index e52051095f..037b17779b 100644 --- a/include/d/d_meter_HIO.h +++ b/include/d/d_meter_HIO.h @@ -1332,10 +1332,10 @@ public: STATIC_ASSERT(sizeof(dMeter_cursorHIO_c) == 68); -extern dMeter_menuHIO_c g_menuHIO; -extern dMeter_drawHIO_c g_drawHIO; -extern dMeter_ringHIO_c g_ringHIO; -extern dMeter_fmapHIO_c g_fmapHIO; -extern dMeter_cursorHIO_c g_cursorHIO; +DUSK_GAME_EXTERN dMeter_menuHIO_c g_menuHIO; +DUSK_GAME_EXTERN dMeter_drawHIO_c g_drawHIO; +DUSK_GAME_EXTERN dMeter_ringHIO_c g_ringHIO; +DUSK_GAME_EXTERN dMeter_fmapHIO_c g_fmapHIO; +DUSK_GAME_EXTERN dMeter_cursorHIO_c g_cursorHIO; #endif /* D_METER_D_METER_HIO_H */ diff --git a/include/d/d_meter_map.h b/include/d/d_meter_map.h index b17f51846e..648fb5aef5 100644 --- a/include/d/d_meter_map.h +++ b/include/d/d_meter_map.h @@ -102,7 +102,6 @@ public: /* 0x04 */ u8 field_0x4_debug; /* 0x08 */ int field_0x8_debug; #endif -private: /* 0x04 */ J2DPicture* mMapJ2DPicture; /* 0x08 */ dMap_c* mMap; /* 0x0C */ s32 mIsCompass; diff --git a/include/d/d_model.h b/include/d/d_model.h index 2dd1abaabf..466592d89c 100644 --- a/include/d/d_model.h +++ b/include/d/d_model.h @@ -33,7 +33,6 @@ public: u16 getMaterialId() { return mMaterialId; } dKy_tevstr_c* getTevstr() { return mpTevstr; } -private: /* 0x10 */ J3DModelData* mpModelData; /* 0x14 */ dKy_tevstr_c* mpTevstr; /* 0x18 */ u16 mMaterialId; @@ -53,9 +52,8 @@ public: static void remove(); static void reset(); - static dMdl_mng_c* m_myObj; + static DUSK_GAME_DATA dMdl_mng_c* m_myObj; -private: /* 0x00 */ dMdl_c field_0x0[4]; /* 0x80 */ u8 field_0x80; }; diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index 307d48f291..49a99a6ef1 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -4,10 +4,15 @@ #include "JSystem/JMessage/control.h" #include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" -#include "dusk/endian.h" -#include "dusk/string.hpp" -#if REGION_JPN +#if TARGET_PC +#include "helpers/endian.h" +#include "helpers/string.hpp" + +#define D_MSG_CLASS_PAGE_CNT_MAX 40 +#define D_MSG_CLASS_CHAR_CNT_MAX 0x210 +#define D_MSG_CLASS_LINE_MAX 12 +#elif REGION_JPN #define D_MSG_CLASS_PAGE_CNT_MAX 30 #define D_MSG_CLASS_CHAR_CNT_MAX 0x210 #define D_MSG_CLASS_LINE_MAX 9 @@ -23,18 +28,20 @@ public: // Attributes /* 0x04 */ BE(u16) message_id; - /* 0x06 */ BE(u16) event_label_id; - /* 0x08 */ u8 se_speaker; - /* 0x09 */ u8 fuki_kind; - /* 0x0A */ u8 output_type; - /* 0x0B */ u8 fuki_pos_type; - /* 0x0C */ u8 unk_0xc; - /* 0x0D */ u8 unk_0xd; - /* 0x0E */ u8 se_mood; - /* 0x0F */ u8 camera_id; - /* 0x10 */ u8 base_anm_id; - /* 0x11 */ u8 face_anm_id; - /* 0x12 */ BE(u16) unk_0x12; + /* 0x06 */ BE(u16) event_label_id; // saveBitLabels index set when the message displays + /* 0x08 */ u8 speaker; // Z2SpeechMgr2 voice bank ID + /* 0x09 */ u8 box_kind; // screen class, see dMsgObject_c::talkStartInit + /* 0x0A */ u8 draw_type; // text pacing, see jmessage_tSequenceProcessor::do_begin + /* 0x0B */ u8 box_position; // see dMsgObject_c::fukiPosCalc + /* 0x0C */ u8 item_no; // unused; legacy dItemNo, 0xFF = none + /* 0x0D */ u8 line_alignment; // 0 centered (JP only), 1 left; also copied to + // jmessage_tReference::mForm + /* 0x0E */ u8 speaker_mood; // grunt emotion index for the voice bank + /* 0x0F */ u8 camera_attr; // 1-10 talk-actor slot, >=11 talk-camera style + /* 0x10 */ u8 talk_anim; // NPC talk motion attribute + /* 0x11 */ u8 face_anim; // NPC talk face attribute + /* 0x12 */ u8 lines_per_page; // unused; runtime uses getLineMax() + /* 0x13 */ u8 _pad; }; class JMSMesgInfo_c { @@ -115,6 +122,25 @@ struct jmessage_tReference : public JMessage::TReference { void setDemoFrame(u32 i_frame) { mDemoFrame = i_frame; } void setTopColorType(u8 i_colorType) { mTopColorType = i_colorType; } void setNowColorType(u8 i_colorType) { mNowColorType = i_colorType; } +#if TARGET_PC + void resetColors() { + mNowCCColor = 0xFFFFFFFF; + mNowGCColor = 0xFFFFFFFF; + mTopCCColor = 0xFFFFFFFF; + mTopGCColor = 0xFFFFFFFF; + mNowFullColor = false; + mTopFullColor = false; + } + void setFullColor(u32 ccColor, u32 gcColor) { + mNowCCColor = ccColor; + mNowGCColor = gcColor; + mNowFullColor = true; + } + void clearNowFullColor() { mNowFullColor = false; } + bool hasTopFullColor() { return mTopFullColor; } + u32 getTopCCColor() { return mTopCCColor; } + u32 getTopGCColor() { return mTopGCColor; } +#endif void setTopTagScale(u16 i_tagScale) { mTopTagScale = i_tagScale; } void setNowTagScale(u16 i_tagScale) { mNowTagScale = i_tagScale; } void setRevoMessageID(u32 i_msgID) { mRevoMessageID = i_msgID; } @@ -359,6 +385,14 @@ struct jmessage_tReference : public JMessage::TReference { /* 0x1274 */ bool mSelectSetCancelFlag; /* 0x1275 */ bool mBombNameUseFlag; /* 0x1276 */ u8 mBatchColorFlag; +#if TARGET_PC + u32 mNowCCColor; + u32 mNowGCColor; + u32 mTopCCColor; + u32 mTopGCColor; + bool mNowFullColor; + bool mTopFullColor; +#endif }; // Size: 0x1278 struct jmessage_tMeasureProcessor : public JMessage::TRenderingProcessor { @@ -456,6 +490,9 @@ struct jmessage_tRenderingProcessor : public JMessage::TRenderingProcessor { void do_selwidthcenter(int); void do_heightcenter(); void do_color(u8); +#if TARGET_PC + void do_fullcolor(u32 ccColor, u32 gcColor); +#endif void do_scale(f32); void do_linedown(s16); void do_transY(s16, bool); @@ -634,6 +671,9 @@ struct jmessage_string_tRenderingProcessor : public JMessage::TRenderingProcesso void do_rubystrcat(char*); void do_outfont(u8); void do_color(u8); +#if TARGET_PC + void do_fullcolor(u32 ccColor, u32 gcColor); +#endif void do_scale(f32); void do_linedown(s16); void do_numset(s16); diff --git a/include/d/d_msg_flow.h b/include/d/d_msg_flow.h index cd9a7c4e5f..b7ffb11fc7 100644 --- a/include/d/d_msg_flow.h +++ b/include/d/d_msg_flow.h @@ -2,7 +2,10 @@ #define D_MSG_D_MSG_FLOW_H #include -#include "dusk/endian.h" + +#if TARGET_PC +#include "helpers/endian.h" +#endif enum { NODETYPE_MESSAGE_e = 1, @@ -22,7 +25,7 @@ struct msg_class; // all mesg_flow_node structs members might be wrong struct mesg_flow_node { /* 0x00 */ u8 type; - /* 0x01 */ u8 field_0x1; + /* 0x01 */ u8 subtype; /* 0x02 */ BE(u16) msg_index; /* 0x04 */ BE(u16) next_node_idx; /* 0x06 */ BE(u16) unk_0x6; @@ -30,7 +33,7 @@ struct mesg_flow_node { struct mesg_flow_node_branch { /* 0x00 */ u8 type; - /* 0x01 */ u8 field_0x1; + /* 0x01 */ u8 result_count; /* 0x02 */ BE(u16) query_idx; /* 0x04 */ BE(u16) param; /* 0x06 */ BE(u16) next_node_idx; @@ -185,10 +188,9 @@ public: void setMsg(u32 msg) { mMsg = msg; } bool checkEndFlow() { return (u32)field_0x26 == 1; } - static queryFunc mQueryList[53]; - static eventFunc mEventList[43]; + static DUSK_GAME_DATA queryFunc mQueryList[53]; + static DUSK_GAME_DATA eventFunc mEventList[43]; -private: /* 0x04 */ u8* mFlow_p; /* 0x08 */ u8* mLabelInfo_p; /* 0x0C */ union mesg_flow { diff --git a/include/d/d_msg_object.h b/include/d/d_msg_object.h index d4d8bb7f47..3e8c535800 100644 --- a/include/d/d_msg_object.h +++ b/include/d/d_msg_object.h @@ -280,13 +280,13 @@ public: /* 0x150 */ f32 field_0x150; /* 0x154 */ u32 mMessageID; /* 0x158 */ u32 field_0x158; - /* 0x15C */ u32 field_0x15c; + /* 0x15C */ u32 mSelectMessageID; // message ID of the selection options message; 1000 = none /* 0x160 */ int mIdx; /* 0x164 */ u16 mNodeIdx; /* 0x166 */ u16 field_0x166; /* 0x168 */ u16 field_0x168; /* 0x16A */ s16 field_0x16a; - /* 0x16C */ s16 field_0x16c; + /* 0x16C */ s16 mCurrentGroupID; // group whose BMG is parsed; -1 none, 0 common, 1-8 stage /* 0x16E */ s16 field_0x16e; /* 0x170 */ s16 mNowTalkFlowNo; /* 0x172 */ s16 field_0x172; @@ -771,6 +771,6 @@ public: /* 0x35C */ dMsgObject_HowlHIO_c mHowlHIO; }; -extern dMsgObject_HIO_c g_MsgObject_HIO_c; +DUSK_GAME_EXTERN dMsgObject_HIO_c g_MsgObject_HIO_c; #endif /* D_MSG_D_MSG_OBJECT_H */ diff --git a/include/d/d_msg_out_font.h b/include/d/d_msg_out_font.h index 2b2d0fa33d..3bd41ca825 100644 --- a/include/d/d_msg_out_font.h +++ b/include/d/d_msg_out_font.h @@ -25,7 +25,6 @@ public: void setTextBoxPtr(J2DTextBox* p_textBox) { mpTextBoxPtr = p_textBox; } void resetType() { mType = 0x47; } -private: /* 0x04 */ J2DTextBox* mpTextBoxPtr; /* 0x08 */ f32 mPosX; /* 0x0C */ f32 mPosY; @@ -53,7 +52,6 @@ public: void setRupeeColor(u8 color) { mRupeeColor = color; } -private: /* 0x004 */ COutFontSet_c* mpOfs[35]; /* 0x090 */ J2DPicture* mpPane[70]; /* 0x1A8 */ f32 mAlphaRatio; diff --git a/include/d/d_msg_scrn_3select.h b/include/d/d_msg_scrn_3select.h index 1cb92e5be6..35c831d3c5 100644 --- a/include/d/d_msg_scrn_3select.h +++ b/include/d/d_msg_scrn_3select.h @@ -60,7 +60,6 @@ public: void offAnimeUpdate(int param_0) { field_0x114 &= ~(u8)(1 << param_0); } u8 getDPDPoint() { return mDPDPoint; } -private: /* 0x004 */ J2DScreen* mpScreen; /* 0x008 */ J2DAnmTransform* mpAnmBck; /* 0x00C */ J2DAnmColorKey* mpAnmBpk; diff --git a/include/d/d_msg_scrn_boss.h b/include/d/d_msg_scrn_boss.h index d72c992b39..3adcc57289 100644 --- a/include/d/d_msg_scrn_boss.h +++ b/include/d/d_msg_scrn_boss.h @@ -15,7 +15,6 @@ public: virtual void fontAlpha(f32); virtual void fukiAlpha(f32); -private: /* 0xC4 */ CPaneMgr* mpBaseParent; /* 0xC8 */ CPaneMgr* mpFontParent; }; diff --git a/include/d/d_msg_scrn_explain.h b/include/d/d_msg_scrn_explain.h index 20931ec9ac..1b638f9b83 100644 --- a/include/d/d_msg_scrn_explain.h +++ b/include/d/d_msg_scrn_explain.h @@ -49,7 +49,6 @@ public: void onForceSelect() { mForceSelect = 1; } void setKeyWaitTimer(s16 timer) { mKeyWaitTimer = timer; } -private: /* 0x04 */ dMsgString_c* mpString_c; /* 0x08 */ CPaneMgr* mpTm_c[2]; /* 0x10 */ CPaneMgr* mpTmr_c[2]; diff --git a/include/d/d_msg_string.h b/include/d/d_msg_string.h index 45a148b401..2d92939141 100644 --- a/include/d/d_msg_string.h +++ b/include/d/d_msg_string.h @@ -39,7 +39,6 @@ public: drawOutFontLocal(param_0, param_1); } -private: /* 0x24 */ COutFont_c* mpOutFont; /* 0x28 */ u8 field_0x28; }; diff --git a/include/d/d_msg_string_base.h b/include/d/d_msg_string_base.h index 4624393f06..020c557f85 100644 --- a/include/d/d_msg_string_base.h +++ b/include/d/d_msg_string_base.h @@ -30,7 +30,6 @@ public: virtual void drawOutFontLocal(J2DTextBox*, f32); virtual void drawFontLocal(J2DTextBox*, u8, f32, f32, f32, f32, u32, u8); -private: /* 0x04 */ JMessage::TResourceContainer* mpResCont; /* 0x08 */ jmessage_string_tControl* mpCtrl; /* 0x0C */ jmessage_string_tReference* mpRefer; diff --git a/include/d/d_msg_unit.h b/include/d/d_msg_unit.h index 47e40e31cf..59e0a81183 100644 --- a/include/d/d_msg_unit.h +++ b/include/d/d_msg_unit.h @@ -8,10 +8,14 @@ public: dMsgUnit_c(); void setTag(int, int, TEXT_SPAN, bool); +#if TARGET_PC + void setTag_jpn(int, int, TEXT_SPAN, bool); +#endif + virtual ~dMsgUnit_c(); }; -extern dMsgUnit_c g_msg_unit; +DUSK_GAME_EXTERN dMsgUnit_c g_msg_unit; inline void dMsgUnit_setTag(int param_0, int param_1, TEXT_SPAN param_2) { g_msg_unit.setTag(param_0, param_1, param_2, true); diff --git a/include/d/d_name.h b/include/d/d_name.h index 68a4930baf..de084defb3 100644 --- a/include/d/d_name.h +++ b/include/d/d_name.h @@ -12,34 +12,6 @@ class J2DTextBox; class JUTFont; class STControl; -#if TARGET_PC -struct PaneCache { - u64 tag; - f32 origTransX; - f32 origTransY; - bool cached; -}; - -static PaneCache l_tagName[] = { - {MULTI_CHAR('m_00_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_00_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_00_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_00_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_00_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_01_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_01_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_01_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_01_3'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m_01_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_02_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_02_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_02_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_02_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_02_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m03_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m03_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m03_2'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m03_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m03_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_04_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_04_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_04_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_04_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_04_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_05_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_05_1'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m_05_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_05_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_05_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_06_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_06_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_06_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_06_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_06_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_07_0'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m_07_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_07_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_07_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_07_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_08_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_08_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_08_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_08_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_08_4'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m_09_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_09_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_09_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_09_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_09_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_10_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_10_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_10_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_10_3'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m_10_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_11_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_11_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_11_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_11_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m_11_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('m12_0'), 0.0f, 0.0f, false}, {MULTI_CHAR('m12_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('m12_2'), 0.0f, 0.0f, false}, - {MULTI_CHAR('m12_3'), 0.0f, 0.0f, false}, {MULTI_CHAR('m12_4'), 0.0f, 0.0f, false}, {MULTI_CHAR('p_end_2'), 0.0f, 0.0f, false}, {MULTI_CHAR('p_end_1'), 0.0f, 0.0f, false}, {MULTI_CHAR('p_end_0'), 0.0f, 0.0f, false}, -}; - -static PaneCache l_nameTagName[] = { - {MULTI_CHAR('name_00'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_01'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_02'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_03'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_04'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_05'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_06'), 0.0f, 0.0f, false}, {MULTI_CHAR('name_07'), 0.0f, 0.0f, false}, -}; - -static PaneCache l_nameCurTagName[] = { - {MULTI_CHAR('s__n_00'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_01'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_02'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_03'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_04'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_05'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_06'), 0.0f, 0.0f, false}, {MULTI_CHAR('s__n_07'), 0.0f, 0.0f, false}, -}; -#endif - class dNm_HIO_c { public: dNm_HIO_c(); @@ -158,7 +130,6 @@ public: void setNextNameStr(char* i_name) { SAFE_STRCPY(mNextNameStr,i_name); } void draw() { _draw(); } -private: /* 0x004 */ STControl* stick; /* 0x008 */ JKRArchive* archive; /* 0x00C */ dDlst_NameIN_c nameIn; diff --git a/include/d/d_pane_class.h b/include/d/d_pane_class.h index 345cae1274..ffc067e411 100644 --- a/include/d/d_pane_class.h +++ b/include/d/d_pane_class.h @@ -93,7 +93,6 @@ public: JUtility::TColor getInitBlack() { return mInitBlack; } JUtility::TColor getInitWhite() { return mInitWhite; } -private: /* 0x1C */ void* mpFirstStackSize; /* 0x20 */ s16* field_0x20; /* 0x24 */ JGeometry::TVec2 mInitPos; diff --git a/include/d/d_pane_class_alpha.h b/include/d/d_pane_class_alpha.h index 82590e5f02..cf38229b97 100644 --- a/include/d/d_pane_class_alpha.h +++ b/include/d/d_pane_class_alpha.h @@ -54,7 +54,6 @@ public: virtual ~CPaneMgrAlphaMorf(); -private: /* 0x1C */ void* mpFirstSaveAlpha; /* 0x20 */ u8* field_0x20; /* 0x24 */ void* mpFirstGetAlpha; diff --git a/include/d/d_particle.h b/include/d/d_particle.h index 3098dbd521..a5849288f3 100644 --- a/include/d/d_particle.h +++ b/include/d/d_particle.h @@ -116,10 +116,10 @@ public: } static dPa_modelEcallBack& getEcallback() { return mEcallback; } - static dPa_modelEcallBack mEcallback; + static DUSK_GAME_DATA dPa_modelEcallBack mEcallback; - static dPa_modelPcallBack mPcallback; - static model_c* mModel; + static DUSK_GAME_DATA dPa_modelPcallBack mPcallback; + static DUSK_GAME_DATA model_c* mModel; #if DEBUG static u8 mNum; #endif @@ -261,7 +261,6 @@ public: void setRate(f32 rate) { mRate = rate; } void setMaxCnt(int i_maxCnt) { mMaxCnt = i_maxCnt; } -private: /* 0x04 */ f32 mRate; /* 0x08 */ int mMaxCnt; /* 0x0C */ cXyz const* field_0xc; @@ -313,7 +312,6 @@ public: u16 getNameId() { return mNameId; } dPa_levelEcallBack* getCallback() { return mCallback; } - private: /* 0x00 */ u32 mId; /* 0x04 */ u16 mNameId; /* 0x06 */ u8 mStatus; @@ -495,22 +493,21 @@ public: return &mWaterBubblePcallBack; } - static dPa_selectTexEcallBack mTsubo[8]; - static dPa_setColorEcallBack mLifeBall[3]; - static Mtx mWindViewMatrix; - static JPAEmitterManager* mEmitterMng; - static dPa_wbPcallBack_c mWaterBubblePcallBack; - static dPa_fsenthPcallBack mFsenthPcallBack; - static dPa_light8EcallBack mLight8EcallBack; - static dPa_light8PcallBack mLight8PcallBack; - static dPa_gen_b_light8EcallBack m_b_Light8EcallBack; - static dPa_gen_b_light8PcallBack m_b_Light8PcallBack; - static dPa_gen_d_light8EcallBack m_d_Light8EcallBack; - static dPa_gen_d_light8PcallBack m_d_Light8PcallBack; - static dPa_particleTracePcallBack_c mParticleTracePCB; - static u8 mStatus; + static DUSK_GAME_DATA dPa_selectTexEcallBack mTsubo[8]; + static DUSK_GAME_DATA dPa_setColorEcallBack mLifeBall[3]; + static DUSK_GAME_DATA Mtx mWindViewMatrix; + static DUSK_GAME_DATA JPAEmitterManager* mEmitterMng; + static DUSK_GAME_DATA dPa_wbPcallBack_c mWaterBubblePcallBack; + static DUSK_GAME_DATA dPa_fsenthPcallBack mFsenthPcallBack; + static DUSK_GAME_DATA dPa_light8EcallBack mLight8EcallBack; + static DUSK_GAME_DATA dPa_light8PcallBack mLight8PcallBack; + static DUSK_GAME_DATA dPa_gen_b_light8EcallBack m_b_Light8EcallBack; + static DUSK_GAME_DATA dPa_gen_b_light8PcallBack m_b_Light8PcallBack; + static DUSK_GAME_DATA dPa_gen_d_light8EcallBack m_d_Light8EcallBack; + static DUSK_GAME_DATA dPa_gen_d_light8PcallBack m_d_Light8PcallBack; + static DUSK_GAME_DATA dPa_particleTracePcallBack_c mParticleTracePCB; + static DUSK_GAME_DATA u8 mStatus; -private: /* 0x000 */ JKRSolidHeap* mHeap; /* 0x004 */ JPAResourceManager* mCommonResMng; /* 0x008 */ JKRExpHeap* m_resHeap; diff --git a/include/d/d_particle_copoly.h b/include/d/d_particle_copoly.h index c50b71387e..7bc8621546 100644 --- a/include/d/d_particle_copoly.h +++ b/include/d/d_particle_copoly.h @@ -78,8 +78,8 @@ public: return (this->*m_emitterTwoData[param_0])(param_1, param_2); } - static const effTypeFunc m_typeTwoData[]; - static const emitterFunc m_emitterTwoData[]; + static DUSK_GAME_DATA const effTypeFunc m_typeTwoData[]; + static DUSK_GAME_DATA const emitterFunc m_emitterTwoData[]; /* 0x38 */ u32 mLeftEmitter[2][4]; /* 0x58 */ u32 mRightEmitter[2][4]; @@ -117,8 +117,8 @@ public: return (this->*m_emitterFourData[param_0])(param_1, param_2); } - static const effTypeFunc m_typeFourData[]; - static const emitterFunc m_emitterFourData[]; + static DUSK_GAME_DATA const effTypeFunc m_typeFourData[]; + static DUSK_GAME_DATA const emitterFunc m_emitterFourData[]; /* 0x80 */ u32 mBackLeftEmitter[2][4]; /* 0xA0 */ u32 mBackRightEmitter[2][4]; diff --git a/include/d/d_particle_name.h b/include/d/d_particle_name.h index 193cd9c96d..b5df5421a7 100644 --- a/include/d/d_particle_name.h +++ b/include/d/d_particle_name.h @@ -10,9 +10,9 @@ struct dPa_name { static DUSK_CONST char* getName(u32 i_id); - static u16 j_o_id[5]; - static u16 s_o_id[14]; - static DUSK_CONST char* jpaName[]; + static DUSK_GAME_DATA u16 j_o_id[5]; + static DUSK_GAME_DATA u16 s_o_id[14]; + static DUSK_GAME_DATA DUSK_CONST char* jpaName[]; }; // enum names made up based on debug strings diff --git a/include/d/d_resorce.h b/include/d/d_resorce.h index b70d2d5452..3330ff5b3d 100644 --- a/include/d/d_resorce.h +++ b/include/d/d_resorce.h @@ -51,7 +51,6 @@ public: static const int NAME_MAX = 9; #endif -private: /* 0x00 */ char mArchiveName[11]; /* 0x0C */ u16 mCount; /* 0x10 */ mDoDvdThd_mountArchive_c* mDMCommand; diff --git a/include/d/d_s_name.h b/include/d/d_s_name.h index 72a44c02de..c32b4b903c 100644 --- a/include/d/d_s_name.h +++ b/include/d/d_s_name.h @@ -56,7 +56,6 @@ public: void tex_data_set(); #endif -private: #if VERSION == VERSION_GCN_PAL u8 field_0x1c4_pal[0x28]; #endif diff --git a/include/d/d_s_play.h b/include/d/d_s_play.h index 45b60220b0..936f29b277 100644 --- a/include/d/d_s_play.h +++ b/include/d/d_s_play.h @@ -83,8 +83,8 @@ public: #endif static void setPauseTimer(s8 time) { nextPauseTimer = time; } - static s8 pauseTimer; - static s8 nextPauseTimer; + static DUSK_GAME_DATA s8 pauseTimer; + static DUSK_GAME_DATA s8 nextPauseTimer; #if DEBUG void onDebugPause() { @@ -104,8 +104,8 @@ public: /* 0x1D4 */ u8 field_0x1d4; }; -extern dScnPly_env_HIO_c g_envHIO; -extern dScnPly_reg_HIO_c g_regHIO; +DUSK_GAME_EXTERN dScnPly_env_HIO_c g_envHIO; +DUSK_GAME_EXTERN dScnPly_reg_HIO_c g_regHIO; #if DEBUG extern dScnPly_preset_HIO_c g_presetHIO; diff --git a/include/d/d_save.h b/include/d/d_save.h index fc54e541f4..ec10360034 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -8,7 +8,10 @@ #include "d/d_item_data.h" #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JHostIO/JORReflexible.h" -#include "dusk/endian.h" + +#if TARGET_PC +#include "helpers/endian.h" +#endif static const int DEFAULT_SELECT_ITEM_INDEX = 0; static const int MAX_SELECT_ITEM = 4; @@ -494,7 +497,7 @@ public: #endif void setPlayerName(const char* i_name) { #if AVOID_UB - dusk::SafeStringCopyTruncate(mPlayerName, i_name); + SafeStringCopyTruncate(mPlayerName, i_name); #else strcpy(mPlayerName, i_name); #endif @@ -506,7 +509,7 @@ public: #endif void setHorseName(const char* i_name) { #if AVOID_UB - dusk::SafeStringCopyTruncate(mHorseName, i_name); + SafeStringCopyTruncate(mHorseName, i_name); #else strcpy(mHorseName, i_name); #endif @@ -594,7 +597,6 @@ public: dSv_player_info_c& getPlayerInfo() { return mPlayerInfo; } dSv_player_config_c& getConfig() { return mConfig; } -private: /* 0x000 */ dSv_player_status_a_c mPlayerStatusA; /* 0x028 */ dSv_player_status_b_c mPlayerStatusB; /* 0x040 */ dSv_horse_place_c mHorsePlace; @@ -892,7 +894,6 @@ public: class dSv_reserve_c { public: -private: u8 unk[80]; }; @@ -1049,7 +1050,7 @@ public: #else u16 #endif - static saveBitLabels[822]; + static DUSK_GAME_DATA saveBitLabels[822]; }; class dSv_event_tmp_flag_c { @@ -1058,7 +1059,7 @@ public: #include "d/d_save_temp_bit_labels.inc" }; - static u16 const tempBitLabels[185]; + static DUSK_GAME_DATA u16 const tempBitLabels[185]; }; #endif /* D_SAVE_D_SAVE_H */ diff --git a/include/d/d_save_HIO.h b/include/d/d_save_HIO.h index e149f7fcb9..f7d4770e08 100644 --- a/include/d/d_save_HIO.h +++ b/include/d/d_save_HIO.h @@ -10,7 +10,6 @@ public: virtual ~dSvBit_childTransformHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 WF[4]; /* 0x09 */ u8 field_0x9[4]; @@ -23,7 +22,6 @@ public: virtual ~dSvBit_childDarknessHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 TW[6]; /* 0x0B */ u8 field_0xB[6]; @@ -36,7 +34,6 @@ public: virtual ~dSvBit_childOtherHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 mDropNum; /* 0x06 */ u8 field_0x6; @@ -51,7 +48,6 @@ public: virtual ~dSvBit_childTbPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x40]; /* 0x45 */ u8 field_0x45[0x40]; @@ -64,7 +60,6 @@ public: mPerfectSave.init(); } -private: /* 0x04 */ u8 field_0x4; /* 0x08 */ dSvBit_childTbPerfectionHIO_c mPerfectSave; }; @@ -76,7 +71,6 @@ public: virtual ~dSvBit_childSwZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ bool field_0x5[0x20]; /* 0x25 */ bool field_0x25[0x20]; @@ -89,7 +83,6 @@ public: virtual ~dSvBit_childSwPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x80]; /* 0x85 */ u8 field_0x85[0x80]; @@ -102,7 +95,6 @@ public: virtual ~dSvBit_childSwOneZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ bool field_0x5[0x10]; /* 0x15 */ bool field_0x15[0x10]; @@ -115,7 +107,6 @@ public: virtual ~dSvBit_childSwDungeonHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x40]; /* 0x45 */ u8 field_0x45[0x40]; @@ -131,7 +122,6 @@ public: field_0x1e0.init(); } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ dSvBit_childSwPerfectionHIO_c field_0x8; /* 0x110 */ dSvBit_childSwDungeonHIO_c field_0x110; @@ -146,7 +136,6 @@ public: virtual ~dSvBit_childItZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x20]; /* 0x25 */ u8 field_0x25[0x20]; @@ -159,7 +148,6 @@ public: virtual ~dSvBit_childItPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x20]; /* 0x25 */ u8 field_0x25[0x20]; @@ -172,7 +160,6 @@ public: virtual ~dSvBit_childItOneZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x10]; /* 0x15 */ u8 field_0x15[0x10]; @@ -185,7 +172,6 @@ public: virtual ~dSvBit_childItDungeonHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x80]; /* 0x85 */ u8 field_0x85[0x80]; @@ -201,7 +187,6 @@ public: mOneZoneSave.init(); } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ dSvBit_childItPerfectionHIO_c mFullSave; /* 0x050 */ dSvBit_childItDungeonHIO_c mDungeonSave; @@ -229,6 +214,6 @@ public: STATIC_ASSERT(sizeof(dSvBit_HIO_c) == 0x4A0); -extern dSvBit_HIO_c g_save_bit_HIO; +DUSK_GAME_EXTERN dSvBit_HIO_c g_save_bit_HIO; #endif /* D_SAVE_D_SAVE_HIO_H */ diff --git a/include/d/d_select_cursor.h b/include/d/d_select_cursor.h index e98db19731..766463b5b3 100644 --- a/include/d/d_select_cursor.h +++ b/include/d/d_select_cursor.h @@ -66,7 +66,6 @@ public: void onPlayAllAnime() { field_0xb4 = 0xff; } void offPlayAllAnime() { field_0xb4 = 0; } -private: /* 0x04 */ J2DScreen* mpScreen; /* 0x08 */ J2DPane* mpPane; /* 0x0C */ dSelect_icon_c* mpSelectIcon; diff --git a/include/d/d_shop_item_ctrl.h b/include/d/d_shop_item_ctrl.h index 9016be18ea..61ed325241 100644 --- a/include/d/d_shop_item_ctrl.h +++ b/include/d/d_shop_item_ctrl.h @@ -18,7 +18,6 @@ public: void setMessageIndex(int i, u16 messageIndex) { mMessageIndex[i] = messageIndex; } u16 getMessageIndex(int i) { return mMessageIndex[i]; } -private: /* 0x04 */ u32 mItemIndex[7]; /* 0x20 */ u16 mMessageIndex[7]; }; diff --git a/include/d/d_simple_model.h b/include/d/d_simple_model.h index 25b9e6e2d1..e87462c318 100644 --- a/include/d/d_simple_model.h +++ b/include/d/d_simple_model.h @@ -36,7 +36,6 @@ public: void setIdx(u8 idx) { this->idx = idx; } #endif -private: /* 0x00 */ JKRSolidHeap* mpHeap; /* 0x04 */ J3DModel* mpModel; /* 0x08 */ int mCreateNum; @@ -59,7 +58,6 @@ public: virtual ~dSmplMdl_draw_c(); -private: /* 0x04 */ diff_model_c mModel[8]; /* 0xA4 */ int mListCount; /* 0xA8 */ modelList_c mList[500]; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 83a1c808fd..fb8fd3124b 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -4,10 +4,14 @@ #include "SSystem/SComponent/c_lib.h" #include "d/d_kankyo.h" #include "d/d_kankyo_data.h" -#include "dusk/offset_ptr.h" #include "f_op/f_op_actor_mng.h" #include "global.h" + +#if TARGET_PC +#include "helpers/offset_ptr.h" + #include "os_report.h" +#endif enum StageType { /* 0x0 */ ST_FIELD, @@ -547,7 +551,6 @@ public: /* vt[91] */ virtual void setElst(dStage_Elst_c*) = 0; /* vt[92] */ virtual dStage_Elst_c* getElst(void) = 0; -private: /* 0x04 */ s8 mRoomNo; }; @@ -1237,20 +1240,20 @@ public: static const int MEMORY_BLOCK_MAX = 19; - static JKRExpHeap* mMemoryBlock[MEMORY_BLOCK_MAX]; - static char mArcBank[32][10]; - static dStage_roomStatus_c mStatus[0x40]; - static char mDemoArcName[10]; - static fpc_ProcID mProcID; - static dStage_bankName* mArcBankName; - static dStage_bankData* mArcBankData; - static roomDzs_c m_roomDzs; - static s8 mStayNo; - static s8 mOldStayNo; - static s8 mNextStayNo; - static u8 m_time_pass; - static u8 mNoChangeRoom; - static s8 mRoomReadId; + static DUSK_GAME_DATA JKRExpHeap* mMemoryBlock[MEMORY_BLOCK_MAX]; + static DUSK_GAME_DATA char mArcBank[32][10]; + static DUSK_GAME_DATA dStage_roomStatus_c mStatus[0x40]; + static DUSK_GAME_DATA char mDemoArcName[10]; + static DUSK_GAME_DATA fpc_ProcID mProcID; + static DUSK_GAME_DATA dStage_bankName* mArcBankName; + static DUSK_GAME_DATA dStage_bankData* mArcBankData; + static DUSK_GAME_DATA roomDzs_c m_roomDzs; + static DUSK_GAME_DATA s8 mStayNo; + static DUSK_GAME_DATA s8 mOldStayNo; + static DUSK_GAME_DATA s8 mNextStayNo; + static DUSK_GAME_DATA u8 m_time_pass; + static DUSK_GAME_DATA u8 mNoChangeRoom; + static DUSK_GAME_DATA s8 mRoomReadId; #if DEBUG static void onNoArcBank() { @@ -1261,7 +1264,6 @@ public: static u8 mNoArcBank; #endif -private: /* 0x0 */ u8 field_0x0[4]; }; @@ -1276,7 +1278,6 @@ public: s8 getDarkArea() const { return mDarkArea; } void setDarkArea(s8 darkArea) { mDarkArea = darkArea; } -private: /* 0x0 */ char mName[8]; /* 0x8 */ s16 mPoint; /* 0xA */ s8 mRoomNo; @@ -1291,12 +1292,12 @@ public: } void set(const char*, s8, s16, s8, s8, u8); void offEnable() { enabled = 0; } + void onEnable() { enabled = 1; } BOOL isEnable() const { return enabled; } s8 getWipe() const { return wipe; } u8 getWipeSpeed() const { return wipe_speed; } dStage_startStage_c* getStartStage() { return this; } -private: s8 enabled; s8 wipe; u8 wipe_speed; @@ -1351,6 +1352,9 @@ enum dStage_SaveTbl { const char* dStage_getName2(s16, s8); dStage_objectNameInf* dStage_searchName(const char*); +#if TARGET_PC +dStage_objectNameInf* dStage_searchNameCI(const char*); +#endif static int dStage_stageKeepTresureInit(dStage_dt_c*, void*, int, void*); static int dStage_filiInfo2Init(dStage_dt_c*, void*, int, void*); static int dStage_mapPathInitCommonLayer(dStage_dt_c*, void*, int, void*); diff --git a/include/d/d_timer.h b/include/d/d_timer.h index 9d3bd7ce1f..de145650ac 100644 --- a/include/d/d_timer.h +++ b/include/d/d_timer.h @@ -52,7 +52,7 @@ public: s32 createStart(u16); bool checkStartAnimeEnd(); void playBckAnimation(f32); -#if VERSION == VERSION_GCN_JPN +#if TARGET_PC || VERSION == VERSION_GCN_JPN bool isLeadByte(int); #endif void drawPikari(int); @@ -77,7 +77,6 @@ public: mTimerTransY = y; } -private: /* 0x004 */ J2DScreen* mpScreen; /* 0x008 */ J2DScreen* mpGetInScreen; /* 0x00C */ J2DAnmTransform* mpGetInBck; @@ -145,7 +144,6 @@ public: u8 isReadyFlag() { return m_is_ready; } -private: /* 0x0FC */ dDlst_TimerScrnDraw_c* mp_tm_scrn; /* 0x100 */ JKRExpHeap* mp_heap; /* 0x104 */ u8 field_0x104[4]; diff --git a/include/d/d_tresure.h b/include/d/d_tresure.h index 236e2690c6..4335a6a215 100644 --- a/include/d/d_tresure.h +++ b/include/d/d_tresure.h @@ -2,7 +2,10 @@ #define D_D_TRESURE_H #include -#include "dusk/offset_ptr.h" + +#if TARGET_PC +#include "helpers/offset_ptr.h" +#endif class dTres_c { public: @@ -113,10 +116,10 @@ public: return mTypeGroupData; } - static u8 const typeToTypeGroup[17][2]; - static type_group_list mTypeGroupListAll[17]; - static typeGroupData_c* mTypeGroupData; - static u16 mNum; + static DUSK_GAME_DATA u8 const typeToTypeGroup[17][2]; + static DUSK_GAME_DATA type_group_list mTypeGroupListAll[17]; + static DUSK_GAME_DATA typeGroupData_c* mTypeGroupData; + static DUSK_GAME_DATA u16 mNum; static void setNpcYkmPosition(int param_1, Vec* param_2) { setPosition(param_1, 13, param_2, -1); diff --git a/include/d/d_vibration.h b/include/d/d_vibration.h index ee87f7dcc4..6e886a314b 100644 --- a/include/d/d_vibration.h +++ b/include/d/d_vibration.h @@ -89,12 +89,11 @@ public: int testShake(); #endif - static const vib_pattern MS_patt[VIBMODE_S_MAX]; - static const vib_pattern CS_patt[VIBMODE_S_MAX]; - static const vib_pattern MQ_patt[VIBMODE_Q_MAX]; - static const vib_pattern CQ_patt[VIBMODE_Q_MAX]; + static DUSK_GAME_DATA const vib_pattern MS_patt[VIBMODE_S_MAX]; + static DUSK_GAME_DATA const vib_pattern CS_patt[VIBMODE_S_MAX]; + static DUSK_GAME_DATA const vib_pattern MQ_patt[VIBMODE_Q_MAX]; + static DUSK_GAME_DATA const vib_pattern CQ_patt[VIBMODE_Q_MAX]; -private: #if DEBUG /* 0x00 */ dVibTest_c mVibTest; #elif PARTIAL_DEBUG @@ -133,7 +132,7 @@ private: /* 0x8C */ s32 mMode; }; // Size: 0x90 -extern const char* shock_names[VIBMODE_S_MAX]; -extern const char* quake_names[VIBMODE_Q_MAX]; +DUSK_GAME_EXTERN const char* shock_names[VIBMODE_S_MAX]; +DUSK_GAME_EXTERN const char* quake_names[VIBMODE_Q_MAX]; #endif /* D_D_VIBRATION_H */ diff --git a/include/d/dolzel.h b/include/d/dolzel.h index d51eb22372..d4f53c842d 100644 --- a/include/d/dolzel.h +++ b/include/d/dolzel.h @@ -8,7 +8,7 @@ #endif #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif #endif // dolzel.h diff --git a/include/dusk/app_info.hpp b/include/dusk/app_info.hpp deleted file mode 100644 index e08fe680d9..0000000000 --- a/include/dusk/app_info.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef DUSK_APPNAME_HPP -#define DUSK_APPNAME_HPP - -namespace dusk { - /** - * \brief The internal application name for the game. - * - * This gets used for file paths and such, and cannot be changed! - */ - constexpr auto AppName = "Dusklight"; - - /** - * Previous AppName to migrate data from. - */ - constexpr auto LegacyAppName = "Dusk"; - - /** - * \brief The internal organization name for the game. - * - * This gets used for file paths and such, and cannot be changed! - */ - constexpr auto OrgName = "TwilitRealm"; -} - -#endif // DUSK_APPNAME_HPP diff --git a/include/dusk/crash_handler.h b/include/dusk/crash_handler.h deleted file mode 100644 index c2cfadf5d1..0000000000 --- a/include/dusk/crash_handler.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace dusk::crash_handler { - -void install(); - -} // namespace dusk::crash_handler diff --git a/include/dusk/crash_reporting.h b/include/dusk/crash_reporting.h deleted file mode 100644 index c42079a6f6..0000000000 --- a/include/dusk/crash_reporting.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -namespace dusk::crash_reporting { - -enum class Consent { - Unavailable, - Unknown, - Given, - Revoked, -}; - -void initialize(); -void shutdown(); -Consent get_consent(); -void set_consent(bool enabled); - -} // namespace dusk::crash_reporting diff --git a/include/dusk/frame_interpolation.h b/include/dusk/frame_interpolation.h deleted file mode 100644 index 5f2f3d134b..0000000000 --- a/include/dusk/frame_interpolation.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "settings.h" - -class camera_process_class; -class view_class; - -#ifdef __cplusplus -namespace dusk { -namespace frame_interp { - -void ensure_initialized(); - -void begin_record(); -void end_record(); -void begin_sim_tick(); -uint64_t sim_tick_seq(); -void begin_frame(FrameInterpMode mode, bool is_sim_frame, float step); -void interpolate(); -float get_interpolation_step(); - -void request_presentation_sync(); -bool presentation_sync_active(); - -bool is_enabled(); - -// TODO: These should be phased out as UI is progressively updated to use game_clock -void set_ui_tick_pending(bool value); -bool get_ui_tick_pending(); - -bool is_sim_frame(); - -void record_camera(::camera_process_class* cam, int camera_id); -void interp_view(::view_class* view); -void record_final_mtx(Mtx m, const void *key); -void record_final_mtx(Mtx m); - -bool lookup_replacement(const void* key, Mtx out); -bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); - -typedef void (*InterpolationCallBack)(bool isSimFrame, void* pUserWork); -// call on a sim tick, will get called during presentation -void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork); - -void begin_presentation_camera(); -void end_presentation_camera(); - -} // namespace frame_interp -} // namespace dusk -#endif diff --git a/include/dusk/game_clock.h b/include/dusk/game_clock.h deleted file mode 100644 index 8bb277e070..0000000000 --- a/include/dusk/game_clock.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -namespace dusk::game_clock { - -void ensure_initialized(); -void reset_frame_timer(); - -constexpr float sim_pace() { return 1.0f / 30.0f; } -constexpr float period_for_original_frames(float frame_count) { return frame_count * sim_pace(); } -constexpr float ui_maximum_dt() { return 0.05f; } -constexpr float ui_initial_dt() { return 1.0f / 60.0f; } - -struct MainLoopPacer { - float presentation_dt_seconds; - bool is_interpolating; - int sim_ticks_to_run; - float sim_pace; -}; - -MainLoopPacer advance_main_loop(); -void commit_sim_tick(); -float sample_interpolation_step(); - -float consume_interval(const void* consumer); - -} // namespace dusk::game_clock diff --git a/include/dusk/imgui.h b/include/dusk/imgui.h deleted file mode 100644 index 5c761fb026..0000000000 --- a/include/dusk/imgui.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _SRC_IMGUI_H_ -#define _SRC_IMGUI_H_ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - void imgui_main(const AuroraInfo* info); - void frame_limiter(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/dusk/logging.h b/include/dusk/logging.h deleted file mode 100644 index 54350af4bf..0000000000 --- a/include/dusk/logging.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef DUSK_LOGGING_H -#define DUSK_LOGGING_H - -#include -#include - -#include - -void aurora_log_callback(AuroraLogLevel level, const char* module, const char* message, unsigned int len); - -namespace dusk { - void InitializeFileLogging(const std::filesystem::path& configDir, AuroraLogLevel logLevel); - void ShutdownFileLogging(); - const char* GetLogFilePath(); - int GetLogFileDescriptor(); - void SendToStubLog(AuroraLogLevel level, const char* module, const char* message); -} - -extern bool StubLogEnabled; - -extern aurora::Module DuskLog; - -#ifndef NDEBUG -#define STUB_LOG() DuskLog.debug("{} is a stub", __FUNCTION__) -#else -#define STUB_LOG() -#endif - -#if TARGET_PC -#define STUB_RET(...) \ - STUB_LOG(); \ - return __VA_ARGS__; - -#else -#define STUB_RET() (void)0 -#endif - -#endif diff --git a/include/dusk/profiling.hpp b/include/dusk/profiling.hpp deleted file mode 100644 index 82dab45216..0000000000 --- a/include/dusk/profiling.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#if defined(__has_include) -#if __has_include() -#include -#endif -#endif - -#ifndef ZoneScoped -#define ZoneScoped -#define ZoneScopedN(name) -#endif diff --git a/include/dusk/speedrun.h b/include/dusk/speedrun.h deleted file mode 100644 index c1a92e4a50..0000000000 --- a/include/dusk/speedrun.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include - -namespace dusk { - -struct SpeedrunInfo { - void startRun() { - m_isRunStarted = true; - m_startTimestamp = OSGetTime(); - } - - void stopRun() { - m_isRunStarted = false; - m_endTimestamp = OSGetTime() - m_startTimestamp; - } - - void reset() { - m_isRunStarted = false; - m_startTimestamp = 0; - m_endTimestamp = 0; - m_isPauseIGT = false; - m_loadStartTimestamp = 0; - m_totalLoadTime = 0; - m_igtTimer = 0; - } - - bool m_isRunStarted = false; - OSTime m_startTimestamp = 0; - OSTime m_endTimestamp = 0; - - bool m_isPauseIGT = false; - OSTime m_loadStartTimestamp = 0; - OSTime m_totalLoadTime = 0; - OSTime m_igtTimer = 0; -}; - -extern SpeedrunInfo m_speedrunInfo; - -void resetForSpeedrunMode(); - -} // namespace dusk diff --git a/include/f_ap/f_ap_game.h b/include/f_ap/f_ap_game.h index fca2e70705..aa2c9dbd9d 100644 --- a/include/f_ap/f_ap_game.h +++ b/include/f_ap/f_ap_game.h @@ -75,7 +75,7 @@ public: static u8 mCaptureMagnification; - static u8 mCaptureScreenDivH; + static DUSK_GAME_DATA u8 mCaptureScreenDivH; static u8 mCaptureScreenDivV; static u8 mPackArchiveMode; @@ -115,7 +115,7 @@ public: /* 0x3E */ u8 mBackgroundAlpha; }; // Size: 0x40 -extern fapGm_HIO_c g_HIO; +DUSK_GAME_EXTERN fapGm_HIO_c g_HIO; inline void fapGmHIO_offMenu() { g_HIO.mDisplayPrint &= (u8)~2; diff --git a/include/f_op/f_op_actor.h b/include/f_op/f_op_actor.h index ed0126eefa..2ac262ced1 100644 --- a/include/f_op/f_op_actor.h +++ b/include/f_op/f_op_actor.h @@ -318,6 +318,11 @@ public: /* 0x566 */ s8 field_0x566; /* 0x567 */ s8 field_0x567; +#if TARGET_PC + u32 mItemGiveTag; + u8 mItemGiveOriginalNo; +#endif + #if !__MWERKS__ s8 actor_last_base_field; #endif @@ -332,7 +337,7 @@ public: static u32 getStopStatus() { return stopStatus; } static void setStopStatus(u32 status) { stopStatus = status; } - static u32 stopStatus; + static DUSK_GAME_DATA u32 stopStatus; }; // Size: 0x568 STATIC_ASSERT(sizeof(fopAc_ac_c) == 0x568); @@ -431,6 +436,6 @@ public: BOOL fopAc_IsActor(void* i_actor); -extern actor_method_class g_fopAc_Method; +DUSK_GAME_EXTERN actor_method_class g_fopAc_Method; #endif diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 76a9f8517c..29dfac1389 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -12,9 +12,10 @@ #include "f_pc/f_pc_manager.h" #include "m_Do/m_Do_hostIO.h" #include "SSystem/SComponent/c_phase.h" -#include "dusk/endian_ssystem.h" -#if !__MWERKS__ +#if TARGET_PC +#include "helpers/endian_ssystem.h" + // mwerks compiler makes value initialization act like default initialization so we need // to be explicit about default initialization in modern compilers #define fopAcM_ct_placement(ptr, ClassName) JKR_NEW_ARGS (ptr) ClassName @@ -23,13 +24,10 @@ #endif #define fopAcM_ct(ptr, ClassName) \ - if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "UH OH"); } \ if (!fopAcM_CheckCondition(ptr, fopAcCnd_INIT_e)) { \ fopAcM_ct_placement(ptr, ClassName); \ fopAcM_OnCondition(ptr, fopAcCnd_INIT_e); \ - } \ - if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "Oh come on"); } - + } #define fopAcM_RegisterDeleteID(i_this, actor_name_str) \ ("Delete -> " actor_name_str "(id=%d)\n", fopAcM_GetID(i_this)) @@ -50,14 +48,14 @@ class cM3dGPla; s8 dComIfGp_getReverb(int roomNo); namespace fopAcM { -extern u8 HeapAdjustEntry; -extern u8 HeapAdjustUnk; -extern u8 HeapAdjustVerbose; -extern u8 HeapAdjustQuiet; -extern u8 HeapDummyCreate; -extern u8 HeapDummyCheck; -extern u8 HeapSkipMargin; -extern int HeapAdjustMargin; +DUSK_GAME_EXTERN u8 HeapAdjustEntry; +DUSK_GAME_EXTERN u8 HeapAdjustUnk; +DUSK_GAME_EXTERN u8 HeapAdjustVerbose; +DUSK_GAME_EXTERN u8 HeapAdjustQuiet; +DUSK_GAME_EXTERN u8 HeapDummyCreate; +DUSK_GAME_EXTERN u8 HeapDummyCheck; +DUSK_GAME_EXTERN u8 HeapSkipMargin; +DUSK_GAME_EXTERN int HeapAdjustMargin; } // namespace fopAcM struct fopAcM_prmBase_class { @@ -79,6 +77,10 @@ struct fopAcM_prm_class { /* 0x1C */ fpc_ProcID parent_id; /* 0x20 */ s8 argument; /* 0x21 */ s8 room_no; +#if TARGET_PC + u32 mItemGiveTag; + u8 mItemGiveOriginalNo; +#endif }; struct fopAcM_search4ev_prm { @@ -516,8 +518,9 @@ s32 fopAcM_SearchByName(s16 i_procName, fopAc_ac_c** i_outActor); fopAcM_prm_class* fopAcM_CreateAppend(); fopAcM_prm_class* createAppend(u16 i_setId, u32 i_parameters, const cXyz* i_pos, int i_roomNo, - const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, - fpc_ProcID i_parentId); + const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, + fpc_ProcID i_parentId IF_DUSK_ARG(u32 i_itemGiveTag = 0) + IF_DUSK_ARG(u8 i_itemOriginalNo = 0xFF)); void fopAcM_Log(fopAc_ac_c const* i_actor, char const* i_message); @@ -526,19 +529,22 @@ s32 fopAcM_delete(fopAc_ac_c* i_actor); s32 fopAcM_delete(fpc_ProcID i_actorID); fpc_ProcID fopAcM_create(s16 i_procName, u16 i_setId, u32 i_parameters, const cXyz* i_pos, - int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, - createFunc i_createFunc); + int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, + createFunc i_createFunc IF_DUSK_ARG(u32 i_itemGiveTag = 0) + IF_DUSK_ARG(u8 i_itemOriginalNo = 0xFF)); fpc_ProcID fopAcM_create(s16 i_procName, u32 i_parameters, const cXyz* i_pos, int i_roomNo, - const csXyz* i_angle, const cXyz* i_scale, s8 i_argument); + const csXyz* i_angle, const cXyz* i_scale, s8 i_argument IF_DUSK_ARG(u32 i_itemGiveTag = 0) + IF_DUSK_ARG(u8 i_itemOriginalNo = 0xFF)); inline fpc_ProcID fopAcM_Create(s16 i_procName, createFunc i_createFunc, void* params) { return fpcM_Create(i_procName, i_createFunc,params); } fopAc_ac_c* fopAcM_fastCreate(s16 i_procName, u32 i_parameters, const cXyz* i_pos, int i_roomNo, - const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, - createFunc i_createFunc, void* i_createFuncData); + const csXyz* i_angle, const cXyz* i_scale, s8 i_argument, createFunc i_createFunc, + void* i_createFuncData IF_DUSK_ARG(u32 i_itemGiveTag = 0) + IF_DUSK_ARG(u8 i_itemOriginalNo = 0xFF)); fopAc_ac_c* fopAcM_fastCreate(const char* i_actorname, u32 i_parameters, const cXyz* i_pos, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, @@ -623,11 +629,11 @@ fopAc_ac_c* fopAcM_getItemEventPartner(const fopAc_ac_c*); fopAc_ac_c* fopAcM_getEventPartner(const fopAc_ac_c*); fpc_ProcID fopAcM_createItemForPresentDemo(cXyz const* i_pos, int i_itemNo, u8 param_2, - int i_itemBitNo, int i_roomNo, csXyz const* i_angle, - cXyz const* i_scale); + int i_itemBitNo, int i_roomNo, csXyz const* i_angle, + cXyz const* i_scale IF_DUSK_ARG(u32 i_itemGiveTag = 0)); fpc_ProcID fopAcM_createItemForTrBoxDemo(cXyz const* i_pos, int i_itemNo, int i_itemBitNo, - int i_roomNo, csXyz const* i_angle, cXyz const* i_scale); + int i_roomNo, csXyz const* i_angle, cXyz const* i_scale IF_DUSK_ARG(u32 i_itemGiveTag = 0)); u8 fopAcM_getItemNoFromTableNo(u8 i_tableNo); @@ -641,11 +647,12 @@ fpc_ProcID fopAcM_createItemFromTable(cXyz const* i_pos, int i_tableNo, int i_it bool i_createDirect); fpc_ProcID fopAcM_createDemoItem(const cXyz* i_pos, int i_itemNo, int i_itemBitNo, - const csXyz* i_angle, int i_roomNo, const cXyz* scale, u8 param_7); + const csXyz* i_angle, int i_roomNo, const cXyz* scale, + u8 param_7 IF_DUSK_ARG(u32 i_itemGiveTag = 0)); fpc_ProcID fopAcM_createItemForBoss(const cXyz* i_pos, int i_itemNo, int i_roomNo, - const csXyz* i_angle, const cXyz* i_scale, f32 i_speedF, - f32 i_speedY, int param_8); + const csXyz* i_angle, const cXyz* i_scale, f32 i_speedF, f32 i_speedY, + int param_8 IF_DUSK_ARG(const char* i_itemCheckName = NULL)); fpc_ProcID fopAcM_createItemForMidBoss(const cXyz* i_pos, int i_itemNo, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, int param_6, @@ -826,8 +833,8 @@ BOOL fopAcM_getNameString(const fopAc_ac_c*, char*); inline void fopAcM_SetStatusMap(fopAc_ac_c*, u32) {} -extern cull_box l_cullSizeBox[fopAc_CULLBOX_MAX_e]; -extern cull_sphere l_cullSizeSphere[fopAc_CULLSPHERE_MAX_e]; +DUSK_GAME_EXTERN cull_box l_cullSizeBox[fopAc_CULLBOX_MAX_e]; +DUSK_GAME_EXTERN cull_sphere l_cullSizeSphere[fopAc_CULLSPHERE_MAX_e]; class fopAcM_lc_c { public: @@ -854,7 +861,7 @@ public: return cBgW_CheckBGround(poly.mNormal.y); } - static dBgS_ObjLinChk mLineCheck; + static DUSK_GAME_DATA dBgS_ObjLinChk mLineCheck; }; class dBgS_RoofChk; @@ -864,16 +871,16 @@ public: static f32 getRoofY() { return mRoofY; } static bool roofCheck(const cXyz*); - static dBgS_ObjRoofChk mRoofCheck; - static f32 mRoofY; + static DUSK_GAME_DATA dBgS_ObjRoofChk mRoofCheck; + static DUSK_GAME_DATA f32 mRoofY; }; class dBgS_GndChk; class fopAcM_gc_c { public: static bool gndCheck(const cXyz*); - static dBgS_ObjGndChk mGndCheck; - static f32 mGroundY; + static DUSK_GAME_DATA dBgS_ObjGndChk mGndCheck; + static DUSK_GAME_DATA f32 mGroundY; static bool getTriPla(cM3dGPla* i_plane) { return dComIfG_Bgsp().GetTriPla(mGndCheck, i_plane); @@ -900,8 +907,8 @@ public: static int getPolyAtt0() { return dComIfG_Bgsp().GetPolyAtt0(mWaterCheck); } static bool waterCheck(const cXyz*); - static dBgS_WtrChk mWaterCheck; - static f32 mWaterY; + static DUSK_GAME_DATA dBgS_WtrChk mWaterCheck; + static DUSK_GAME_DATA f32 mWaterY; }; #endif diff --git a/include/f_op/f_op_actor_tag.h b/include/f_op/f_op_actor_tag.h index a354178a8b..dfad5b5b83 100644 --- a/include/f_op/f_op_actor_tag.h +++ b/include/f_op/f_op_actor_tag.h @@ -7,6 +7,6 @@ void fopAcTg_ActorQTo(create_tag_class* i_createTag); int fopAcTg_Init(create_tag_class* i_createTag, void* i_data); int fopAcTg_ToActorQ(create_tag_class* i_createTag); -extern node_list_class g_fopAcTg_Queue; +DUSK_GAME_EXTERN node_list_class g_fopAcTg_Queue; #endif diff --git a/include/f_op/f_op_camera.h b/include/f_op/f_op_camera.h index 584bff29d4..30bcd3fe60 100644 --- a/include/f_op/f_op_camera.h +++ b/include/f_op/f_op_camera.h @@ -15,6 +15,6 @@ static s32 fopCam_Draw(camera_class* i_this); static int fopCam_Execute(camera_class* i_this); int fopCam_IsDelete(camera_class* i_this); -extern leafdraw_method_class g_fopCam_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopCam_Method; #endif diff --git a/include/f_op/f_op_draw_tag.h b/include/f_op/f_op_draw_tag.h index 317cad1baf..1071616988 100644 --- a/include/f_op/f_op_draw_tag.h +++ b/include/f_op/f_op_draw_tag.h @@ -5,7 +5,7 @@ typedef struct create_tag_class create_tag_class; -extern node_lists_tree_class g_fopDwTg_Queue; +DUSK_GAME_EXTERN node_lists_tree_class g_fopDwTg_Queue; void fopDwTg_DrawQTo(create_tag_class* i_createTag); void fopDwTg_CreateQueue(); diff --git a/include/f_op/f_op_kankyo.h b/include/f_op/f_op_kankyo.h index 7741d6c09d..75833fe5ad 100644 --- a/include/f_op/f_op_kankyo.h +++ b/include/f_op/f_op_kankyo.h @@ -21,6 +21,6 @@ struct kankyo_process_profile_definition { BOOL fopKy_IsKankyo(void* i_this); -extern leafdraw_method_class g_fopKy_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopKy_Method; #endif /* F_OP_F_OP_KANKYO_H */ diff --git a/include/f_op/f_op_msg.h b/include/f_op/f_op_msg.h index 72a57b594f..1338732a4b 100644 --- a/include/f_op/f_op_msg.h +++ b/include/f_op/f_op_msg.h @@ -30,13 +30,13 @@ struct msg_class { /* 0xDC */ fopAc_ac_c* talk_actor; /* 0xE0 */ cXyz pos; /* 0xEC */ u32 msg_idx; - /* 0xF0 */ u32 field_0xf0; + /* 0xF0 */ u32 select_msg_idx; // selection options message ID; 1000 = none /* 0xF4 */ u32 field_0xf4; /* 0xF8 */ u16 mode; /* 0xFA */ u8 select_idx; }; // Size: 0xFC -extern leafdraw_method_class g_fopMsg_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopMsg_Method; namespace fopMsg { extern u8 MemCheck; diff --git a/include/f_op/f_op_msg_mng.h b/include/f_op/f_op_msg_mng.h index 330347fc18..35d0e28ea7 100644 --- a/include/f_op/f_op_msg_mng.h +++ b/include/f_op/f_op_msg_mng.h @@ -19,7 +19,7 @@ struct fopMsg_prm_class { /* 0x00 */ fopAc_ac_c* talk_actor; /* 0x04 */ cXyz pos; /* 0x10 */ u32 msg_idx; - /* 0x14 */ u32 field_0x14; + /* 0x14 */ u32 select_msg_idx; // selection options message ID; 1000 = none /* 0x18 */ fpc_ProcID field_0x18; }; // Size: 0x1C @@ -46,8 +46,8 @@ void fopMsgM_setMessageID(fpc_ProcID msg_id); void fopMsgM_destroyExpHeap(JKRExpHeap* i_heap); f32 fopMsgM_valueIncrease(int param_0, int param_1, u8 i_type); s32 fopMsgM_setStageLayer(void* i_process); -fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_talkActor, u32 param_2); -fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, u32 param_1); +fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_talkActor, u32 i_selectMsgIdx); +fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, u32 i_selectMsgIdx); fpc_ProcID fopMsgM_messageSetDemo(u32 i_msgidx); msg_class* fopMsgM_SearchByID(fpc_ProcID i_id); TEXT_SPAN fopMsgM_messageGet(TEXT_SPAN i_stringBuf, u32 i_msgId); diff --git a/include/f_op/f_op_overlap.h b/include/f_op/f_op_overlap.h index c639ff38e0..275b86fc40 100644 --- a/include/f_op/f_op_overlap.h +++ b/include/f_op/f_op_overlap.h @@ -18,6 +18,6 @@ struct overlap_process_profile_definition { static s32 fopOvlp_Draw(void* param_1); -extern leafdraw_method_class g_fopOvlp_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopOvlp_Method; #endif diff --git a/include/f_op/f_op_scene.h b/include/f_op/f_op_scene.h index 0e736093f1..b7e182e890 100644 --- a/include/f_op/f_op_scene.h +++ b/include/f_op/f_op_scene.h @@ -24,6 +24,6 @@ public: /* 0x1B0 */ scene_tag_class scene_tag; }; -extern leafdraw_method_class g_fopScn_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopScn_Method; #endif diff --git a/include/f_op/f_op_scene_tag.h b/include/f_op/f_op_scene_tag.h index ad26ab3564..f4bb4ebad6 100644 --- a/include/f_op/f_op_scene_tag.h +++ b/include/f_op/f_op_scene_tag.h @@ -12,6 +12,6 @@ void fopScnTg_QueueTo(scene_tag_class* i_sceneTag); void fopScnTg_ToQueue(scene_tag_class* i_sceneTag); void fopScnTg_Init(scene_tag_class* i_sceneTag, void* i_data); -extern node_list_class g_fopScnTg_SceneList; +DUSK_GAME_EXTERN node_list_class g_fopScnTg_SceneList; #endif diff --git a/include/f_op/f_op_view.h b/include/f_op/f_op_view.h index a605923b2f..62c135fb68 100644 --- a/include/f_op/f_op_view.h +++ b/include/f_op/f_op_view.h @@ -56,6 +56,6 @@ struct view_class { /* 0x1E0 */ Mtx viewMtxNoTrans; }; -extern leafdraw_method_class g_fopVw_Method; +DUSK_GAME_EXTERN leafdraw_method_class g_fopVw_Method; #endif diff --git a/include/f_pc/f_pc_base.h b/include/f_pc/f_pc_base.h index 23c7893b91..63c629e624 100644 --- a/include/f_pc/f_pc_base.h +++ b/include/f_pc/f_pc_base.h @@ -57,6 +57,6 @@ int fpcBs_Delete(base_process_class* i_proc); base_process_class* fpcBs_Create(s16 i_profname, fpc_ProcID i_procID, void* i_append); int fpcBs_SubCreate(base_process_class* i_proc); -extern int g_fpcBs_type; +DUSK_GAME_EXTERN int g_fpcBs_type; #endif diff --git a/include/f_pc/f_pc_create_tag.h b/include/f_pc/f_pc_create_tag.h index 45b1f2ea8b..4706b3862a 100644 --- a/include/f_pc/f_pc_create_tag.h +++ b/include/f_pc/f_pc_create_tag.h @@ -13,6 +13,6 @@ void fpcCtTg_ToCreateQ(create_tag* i_createTag); void fpcCtTg_CreateQTo(create_tag* i_createTag); int fpcCtTg_Init(create_tag* i_createTag, void* i_data); -extern node_list_class g_fpcCtTg_Queue; +DUSK_GAME_EXTERN node_list_class g_fpcCtTg_Queue; #endif diff --git a/include/f_pc/f_pc_delete_tag.h b/include/f_pc/f_pc_delete_tag.h index 57b049c2f2..1dd0cd728a 100644 --- a/include/f_pc/f_pc_delete_tag.h +++ b/include/f_pc/f_pc_delete_tag.h @@ -25,6 +25,6 @@ void fpcDtTg_DeleteQTo(delete_tag_class* i_deleteTag); int fpcDtTg_Do(delete_tag_class* i_deleteTag, delete_tag_func i_func); int fpcDtTg_Init(delete_tag_class* i_deleteTag, void* i_data); -extern node_list_class g_fpcDtTg_Queue; +DUSK_GAME_EXTERN node_list_class g_fpcDtTg_Queue; #endif diff --git a/include/f_pc/f_pc_deletor.h b/include/f_pc/f_pc_deletor.h index c0b7da0fc2..1667303fc4 100644 --- a/include/f_pc/f_pc_deletor.h +++ b/include/f_pc/f_pc_deletor.h @@ -7,6 +7,7 @@ typedef struct base_process_class base_process_class; BOOL fpcDt_IsComplete(); +int fpcDt_deleteMethod(base_process_class* i_proc); int fpcDt_ToDeleteQ(base_process_class* i_proc); int fpcDt_ToQueue(base_process_class* i_proc); void fpcDt_Handler(); diff --git a/include/f_pc/f_pc_leaf.h b/include/f_pc/f_pc_leaf.h index 2234fa87a5..99b176e73c 100644 --- a/include/f_pc/f_pc_leaf.h +++ b/include/f_pc/f_pc_leaf.h @@ -43,7 +43,7 @@ int fpcLf_IsDelete(leafdraw_class* i_leaf); int fpcLf_Delete(leafdraw_class* i_leaf); int fpcLf_Create(leafdraw_class* i_leaf); -extern int g_fpcLf_type; -extern leafdraw_method_class DUSK_CONST g_fpcLf_Method; +DUSK_GAME_EXTERN int g_fpcLf_type; +DUSK_GAME_EXTERN leafdraw_method_class DUSK_CONST g_fpcLf_Method; #endif diff --git a/include/f_pc/f_pc_line.h b/include/f_pc/f_pc_line.h index 47a8018792..4527653a90 100644 --- a/include/f_pc/f_pc_line.h +++ b/include/f_pc/f_pc_line.h @@ -5,6 +5,6 @@ void fpcLn_Create(); -extern node_lists_tree_class g_fpcLn_Queue; +DUSK_GAME_EXTERN node_lists_tree_class g_fpcLn_Queue; #endif diff --git a/include/f_pc/f_pc_node.h b/include/f_pc/f_pc_node.h index 0d96fd2de5..a519393b1c 100644 --- a/include/f_pc/f_pc_node.h +++ b/include/f_pc/f_pc_node.h @@ -35,7 +35,7 @@ int fpcNd_IsDelete(process_node_class* pProcNode); int fpcNd_Delete(process_node_class* pProcNode); int fpcNd_Create(process_node_class* pProcNode); -extern int g_fpcNd_type; -extern nodedraw_method_class g_fpcNd_Method; +DUSK_GAME_EXTERN int g_fpcNd_type; +DUSK_GAME_EXTERN nodedraw_method_class g_fpcNd_Method; #endif diff --git a/include/f_pc/f_pc_profile.h b/include/f_pc/f_pc_profile.h index bccbfda215..f1ebfa144e 100644 --- a/include/f_pc/f_pc_profile.h +++ b/include/f_pc/f_pc_profile.h @@ -6,7 +6,7 @@ #include "global.h" // Putting const on these profiles make them have internal linkage. Make sure they're extern! -#define DUSK_PROFILE IF_DUSK(extern) +#define DUSK_PROFILE IF_DUSK(extern) DUSK_GAME_DATA typedef struct nodedraw_method_class nodedraw_method_class; typedef struct leafdraw_method_class leafdraw_method_class; @@ -27,6 +27,6 @@ typedef struct process_profile_definition { struct leaf_process_profile_definition; process_profile_definition DUSK_CONST* fpcPf_Get(s16 i_profname); -extern process_profile_definition DUSK_CONST* DUSK_CONST* DUSK_CONST g_fpcPf_ProfileList_p; +DUSK_GAME_EXTERN process_profile_definition DUSK_CONST* DUSK_CONST* DUSK_CONST g_fpcPf_ProfileList_p; #endif diff --git a/include/f_pc/f_pc_profile_lst.h b/include/f_pc/f_pc_profile_lst.h index e4e2e7c95f..b5d6e461b5 100644 --- a/include/f_pc/f_pc_profile_lst.h +++ b/include/f_pc/f_pc_profile_lst.h @@ -13,1594 +13,1594 @@ #endif #ifdef __MWERKS__ -extern process_profile_definition g_profile_ALINK; -extern process_profile_definition g_profile_NO_CHG_ROOM; -extern process_profile_definition g_profile_ITEM; -extern process_profile_definition g_profile_CAMERA; -extern process_profile_definition g_profile_CAMERA2; -extern process_profile_definition g_profile_ENVSE; -extern process_profile_definition g_profile_GAMEOVER; -extern process_profile_definition g_profile_KANKYO; -extern process_profile_definition g_profile_KYEFF; -extern process_profile_definition g_profile_KYEFF2; -extern process_profile_definition g_profile_KY_THUNDER; -extern process_profile_definition g_profile_MENUWINDOW; -extern process_profile_definition g_profile_METER2; -extern process_profile_definition g_profile_MSG_OBJECT; -extern process_profile_definition g_profile_OVERLAP0; -extern process_profile_definition g_profile_OVERLAP1; -extern process_profile_definition g_profile_OVERLAP6; -extern process_profile_definition g_profile_OVERLAP7; -extern process_profile_definition g_profile_OVERLAP8; -extern process_profile_definition g_profile_OVERLAP9; -extern process_profile_definition g_profile_OVERLAP10; -extern process_profile_definition g_profile_OVERLAP11; -extern process_profile_definition g_profile_OVERLAP2; -extern process_profile_definition g_profile_OVERLAP3; -extern process_profile_definition g_profile_LOGO_SCENE; -extern process_profile_definition g_profile_MENU_SCENE; -extern process_profile_definition g_profile_NAME_SCENE; -extern process_profile_definition g_profile_NAMEEX_SCENE; -extern process_profile_definition g_profile_PLAY_SCENE; -extern process_profile_definition g_profile_OPENING_SCENE; -extern process_profile_definition g_profile_ROOM_SCENE; -extern process_profile_definition g_profile_WARNING_SCENE; -extern process_profile_definition g_profile_WARNING2_SCENE; -extern process_profile_definition g_profile_TIMER; -extern process_profile_definition g_profile_WMARK; -extern process_profile_definition g_profile_WPILLAR; -extern process_profile_definition g_profile_ANDSW; -extern process_profile_definition g_profile_BG; -extern process_profile_definition g_profile_BG_OBJ; -extern process_profile_definition g_profile_DMIDNA; -extern process_profile_definition g_profile_DBDOOR; -extern process_profile_definition g_profile_KNOB20; -extern process_profile_definition g_profile_DOOR20; -extern process_profile_definition g_profile_SPIRAL_DOOR; -extern process_profile_definition g_profile_DSHUTTER; -extern process_profile_definition g_profile_EP; -extern process_profile_definition g_profile_HITOBJ; -extern process_profile_definition g_profile_KYTAG00; -extern process_profile_definition g_profile_KYTAG04; -extern process_profile_definition g_profile_KYTAG17; -extern process_profile_definition g_profile_OBJ_BEF; -extern process_profile_definition g_profile_Obj_BurnBox; -extern process_profile_definition g_profile_Obj_Carry; -extern process_profile_definition g_profile_OBJ_ITO; -extern process_profile_definition g_profile_Obj_Movebox; -extern process_profile_definition g_profile_Obj_Swpush; -extern process_profile_definition g_profile_Obj_Timer; -extern process_profile_definition g_profile_PATH_LINE; -extern process_profile_definition g_profile_SCENE_EXIT; -extern process_profile_definition g_profile_SET_BG_OBJ; -extern process_profile_definition g_profile_SWHIT0; -extern process_profile_definition g_profile_TAG_ALLMATO; -extern process_profile_definition g_profile_TAG_CAMERA; -extern process_profile_definition g_profile_TAG_CHKPOINT; -extern process_profile_definition g_profile_TAG_EVENT; -extern process_profile_definition g_profile_TAG_EVT; -extern process_profile_definition g_profile_TAG_EVTAREA; -extern process_profile_definition g_profile_TAG_EVTMSG; -extern process_profile_definition g_profile_TAG_HOWL; -extern process_profile_definition g_profile_TAG_KMSG; -extern process_profile_definition g_profile_TAG_LANTERN; -extern process_profile_definition g_profile_Tag_Mist; -extern process_profile_definition g_profile_TAG_MSG; -extern process_profile_definition g_profile_TAG_PUSH; -extern process_profile_definition g_profile_TAG_TELOP; -extern process_profile_definition g_profile_TBOX; -extern process_profile_definition g_profile_TBOX2; -extern process_profile_definition g_profile_VRBOX; -extern process_profile_definition g_profile_VRBOX2; -extern process_profile_definition g_profile_ARROW; -extern process_profile_definition g_profile_BOOMERANG; -extern process_profile_definition g_profile_CROD; -extern process_profile_definition g_profile_DEMO00; -extern process_profile_definition g_profile_DISAPPEAR; -extern process_profile_definition g_profile_MG_ROD; -extern process_profile_definition g_profile_MIDNA; -extern process_profile_definition g_profile_NBOMB; -extern process_profile_definition g_profile_Obj_LifeContainer; -extern process_profile_definition g_profile_Obj_Yousei; -extern process_profile_definition g_profile_SPINNER; -extern process_profile_definition g_profile_SUSPEND; -extern process_profile_definition g_profile_Tag_Attp; -extern process_profile_definition g_profile_ALLDIE; -extern process_profile_definition g_profile_ANDSW2; -extern process_profile_definition g_profile_BD; -extern process_profile_definition g_profile_CANOE; -extern process_profile_definition g_profile_CSTAF; -extern process_profile_definition g_profile_Demo_Item; -extern process_profile_definition g_profile_L1BOSS_DOOR; -extern process_profile_definition g_profile_E_DN; -extern process_profile_definition g_profile_E_FM; -extern process_profile_definition g_profile_E_GA; -extern process_profile_definition g_profile_E_HB; -extern process_profile_definition g_profile_E_NEST; -extern process_profile_definition g_profile_E_RD; -extern process_profile_definition g_profile_ECONT; -extern process_profile_definition g_profile_FR; -extern process_profile_definition g_profile_GRASS; -extern process_profile_definition g_profile_KYTAG05; -extern process_profile_definition g_profile_KYTAG10; -extern process_profile_definition g_profile_KYTAG11; -extern process_profile_definition g_profile_KYTAG14; -extern process_profile_definition g_profile_MG_FISH; -extern process_profile_definition g_profile_NPC_BESU; -extern process_profile_definition g_profile_NPC_FAIRY_SEIREI; -extern process_profile_definition g_profile_NPC_FISH; -extern process_profile_definition g_profile_NPC_HENNA; -extern process_profile_definition g_profile_NPC_KAKASHI; -extern process_profile_definition g_profile_NPC_KKRI; -extern process_profile_definition g_profile_NPC_KOLIN; -extern process_profile_definition g_profile_NPC_MARO; -extern process_profile_definition g_profile_NPC_TARO; -extern process_profile_definition g_profile_NPC_TKJ; -extern process_profile_definition g_profile_Obj_BHASHI; -extern process_profile_definition g_profile_Obj_BkDoor; -extern process_profile_definition g_profile_Obj_BossWarp; -extern process_profile_definition g_profile_Obj_Cboard; -extern process_profile_definition g_profile_Obj_Digpl; -extern process_profile_definition g_profile_Obj_Eff; -extern process_profile_definition g_profile_OBJ_FMOBJ; -extern process_profile_definition g_profile_Obj_GpTaru; -extern process_profile_definition g_profile_Obj_HHASHI; -extern process_profile_definition g_profile_OBJ_KANBAN2; -extern process_profile_definition g_profile_OBJ_KBACKET; -extern process_profile_definition g_profile_Obj_KkrGate; -extern process_profile_definition g_profile_Obj_KLift00; -extern process_profile_definition g_profile_Tag_KtOnFire; -extern process_profile_definition g_profile_Obj_Ladder; -extern process_profile_definition g_profile_Obj_Lv2Candle; -extern process_profile_definition g_profile_Obj_MagneArm; -extern process_profile_definition g_profile_Obj_MetalBox; -extern process_profile_definition g_profile_Obj_MGate; -extern process_profile_definition g_profile_Obj_NamePlate; -extern process_profile_definition g_profile_Obj_OnCloth; -extern process_profile_definition g_profile_Obj_RopeBridge; -extern process_profile_definition g_profile_Obj_SwallShutter; -extern process_profile_definition g_profile_OBJ_STICK; -extern process_profile_definition g_profile_Obj_StoneMark; -extern process_profile_definition g_profile_Obj_Swpropeller; -extern process_profile_definition g_profile_Obj_Swpush5; -extern process_profile_definition g_profile_Obj_Yobikusa; -extern process_profile_definition g_profile_SCENE_EXIT2; -extern process_profile_definition g_profile_ShopItem; -extern process_profile_definition g_profile_SQ; -extern process_profile_definition g_profile_SWC00; -extern process_profile_definition g_profile_Tag_CstaSw; -extern process_profile_definition g_profile_Tag_AJnot; -extern process_profile_definition g_profile_Tag_AttackItem; -extern process_profile_definition g_profile_Tag_Gstart; -extern process_profile_definition g_profile_Tag_Hinit; -extern process_profile_definition g_profile_Tag_Hjump; -extern process_profile_definition g_profile_Tag_Hstop; -extern process_profile_definition g_profile_Tag_Lv2PrChk; -extern process_profile_definition g_profile_Tag_Magne; -extern process_profile_definition g_profile_Tag_Mhint; -extern process_profile_definition g_profile_Tag_Mstop; -extern process_profile_definition g_profile_Tag_Spring; -extern process_profile_definition g_profile_Tag_Statue; -extern process_profile_definition g_profile_Ykgr; -extern process_profile_definition g_profile_DR; -extern process_profile_definition g_profile_L7lowDr; -extern process_profile_definition g_profile_L7ODR; -extern process_profile_definition g_profile_B_BH; -extern process_profile_definition g_profile_B_BQ; -extern process_profile_definition g_profile_B_DR; -extern process_profile_definition g_profile_B_DRE; -extern process_profile_definition g_profile_B_DS; -extern process_profile_definition g_profile_B_GG; -extern process_profile_definition g_profile_B_GM; -extern process_profile_definition g_profile_B_GND; -extern process_profile_definition g_profile_B_GO; -extern process_profile_definition g_profile_B_GOS; -extern process_profile_definition g_profile_B_MGN; -extern process_profile_definition g_profile_B_OB; -extern process_profile_definition g_profile_B_OH; -extern process_profile_definition g_profile_B_OH2; -extern process_profile_definition g_profile_B_TN; -extern process_profile_definition g_profile_B_YO; -extern process_profile_definition g_profile_B_YOI; -extern process_profile_definition g_profile_B_ZANT; -extern process_profile_definition g_profile_B_ZANTM; -extern process_profile_definition g_profile_B_ZANTZ; -extern process_profile_definition g_profile_B_ZANTS; -extern process_profile_definition g_profile_BALLOON2D; -extern process_profile_definition g_profile_BULLET; -extern process_profile_definition g_profile_COACH2D; -extern process_profile_definition g_profile_COACH_FIRE; -extern process_profile_definition g_profile_COW; -extern process_profile_definition g_profile_CSTATUE; -extern process_profile_definition g_profile_DO; -extern process_profile_definition g_profile_BOSS_DOOR; -extern process_profile_definition g_profile_L5BOSS_DOOR; -extern process_profile_definition g_profile_L1MBOSS_DOOR; -extern process_profile_definition g_profile_PushDoor; -extern process_profile_definition g_profile_E_AI; -extern process_profile_definition g_profile_E_ARROW; -extern process_profile_definition g_profile_E_BA; -extern process_profile_definition g_profile_E_BEE; -extern process_profile_definition g_profile_E_BG; -extern process_profile_definition g_profile_E_BI; -extern process_profile_definition g_profile_E_BI_LEAF; -extern process_profile_definition g_profile_E_BS; -extern process_profile_definition g_profile_E_BU; -extern process_profile_definition g_profile_E_BUG; -extern process_profile_definition g_profile_E_CR; -extern process_profile_definition g_profile_E_CR_EGG; -extern process_profile_definition g_profile_E_DB; -extern process_profile_definition g_profile_E_DB_LEAF; -extern process_profile_definition g_profile_E_DD; -extern process_profile_definition g_profile_E_DF; -extern process_profile_definition g_profile_E_DK; -extern process_profile_definition g_profile_E_DT; -extern process_profile_definition g_profile_E_FB; -extern process_profile_definition g_profile_E_FK; -extern process_profile_definition g_profile_E_FS; -extern process_profile_definition g_profile_E_FZ; -extern process_profile_definition g_profile_E_GB; -extern process_profile_definition g_profile_E_GE; -extern process_profile_definition g_profile_E_GI; -extern process_profile_definition g_profile_E_GM; -extern process_profile_definition g_profile_E_GOB; -extern process_profile_definition g_profile_E_GS; -extern process_profile_definition g_profile_E_HB_LEAF; -extern process_profile_definition g_profile_E_HM; -extern process_profile_definition g_profile_E_HP; -extern process_profile_definition g_profile_E_HZ; -extern process_profile_definition g_profile_E_HZELDA; -extern process_profile_definition g_profile_E_IS; -extern process_profile_definition g_profile_E_KG; -extern process_profile_definition g_profile_E_KK; -extern process_profile_definition g_profile_E_KR; -extern process_profile_definition g_profile_E_MB; -extern process_profile_definition g_profile_E_MD; -extern process_profile_definition g_profile_E_MF; -extern process_profile_definition g_profile_E_MK; -extern process_profile_definition g_profile_E_MK_BO; -extern process_profile_definition g_profile_E_MM; -extern process_profile_definition g_profile_E_MM_MT; -extern process_profile_definition g_profile_E_MS; -extern process_profile_definition g_profile_E_NZ; -extern process_profile_definition g_profile_E_OC; -extern process_profile_definition g_profile_E_OctBg; -extern process_profile_definition g_profile_E_OT; -extern process_profile_definition g_profile_E_PH; -extern process_profile_definition g_profile_E_PM; -extern process_profile_definition g_profile_E_PO; -extern process_profile_definition g_profile_E_PZ; -extern process_profile_definition g_profile_E_RB; -extern process_profile_definition g_profile_E_RDB; -extern process_profile_definition g_profile_E_RDY; -extern process_profile_definition g_profile_E_S1; -extern process_profile_definition g_profile_E_SB; -extern process_profile_definition g_profile_E_SF; -extern process_profile_definition g_profile_E_SG; -extern process_profile_definition g_profile_E_SH; -extern process_profile_definition g_profile_E_SM; -extern process_profile_definition g_profile_E_SM2; -extern process_profile_definition g_profile_E_ST; -extern process_profile_definition g_profile_E_ST_LINE; -extern process_profile_definition g_profile_E_SW; -extern process_profile_definition g_profile_E_TH; -extern process_profile_definition g_profile_E_TH_BALL; -extern process_profile_definition g_profile_E_TK; -extern process_profile_definition g_profile_E_TK2; -extern process_profile_definition g_profile_E_TK_BALL; -extern process_profile_definition g_profile_E_TT; -extern process_profile_definition g_profile_E_VT; -extern process_profile_definition g_profile_E_WAP; -extern process_profile_definition g_profile_E_WB; -extern process_profile_definition g_profile_E_WS; -extern process_profile_definition g_profile_E_WW; -extern process_profile_definition g_profile_E_YC; -extern process_profile_definition g_profile_E_YD; -extern process_profile_definition g_profile_E_YD_LEAF; -extern process_profile_definition g_profile_E_YG; -extern process_profile_definition g_profile_E_YH; -extern process_profile_definition g_profile_E_YK; -extern process_profile_definition g_profile_E_YM; -extern process_profile_definition g_profile_E_YM_TAG; -extern process_profile_definition g_profile_E_YMB; -extern process_profile_definition g_profile_E_YR; -extern process_profile_definition g_profile_E_ZH; -extern process_profile_definition g_profile_E_ZM; -extern process_profile_definition g_profile_E_ZS; -extern process_profile_definition g_profile_FORMATION_MNG; -extern process_profile_definition g_profile_GUARD_MNG; -extern process_profile_definition g_profile_HORSE; -extern process_profile_definition g_profile_HOZELDA; -extern process_profile_definition g_profile_Izumi_Gate; -extern process_profile_definition g_profile_KAGO; -extern process_profile_definition g_profile_KYTAG01; -extern process_profile_definition g_profile_KYTAG02; -extern process_profile_definition g_profile_KYTAG03; -extern process_profile_definition g_profile_KYTAG06; -extern process_profile_definition g_profile_KYTAG07; -extern process_profile_definition g_profile_KYTAG08; -extern process_profile_definition g_profile_KYTAG09; -extern process_profile_definition g_profile_KYTAG12; -extern process_profile_definition g_profile_KYTAG13; -extern process_profile_definition g_profile_KYTAG15; -extern process_profile_definition g_profile_KYTAG16; -extern process_profile_definition g_profile_MANT; -extern process_profile_definition g_profile_FSHOP; -extern process_profile_definition g_profile_MIRROR; -extern process_profile_definition g_profile_MOVIE_PLAYER; -extern process_profile_definition g_profile_MYNA; -extern process_profile_definition g_profile_NI; -extern process_profile_definition g_profile_NPC_ARU; -extern process_profile_definition g_profile_NPC_ASH; -extern process_profile_definition g_profile_NPC_ASHB; -extern process_profile_definition g_profile_NPC_BANS; -extern process_profile_definition g_profile_NPC_BLUENS; -extern process_profile_definition g_profile_NPC_BOU; -extern process_profile_definition g_profile_NPC_BOU_S; -extern process_profile_definition g_profile_NPC_CD3; -extern process_profile_definition g_profile_NPC_CHAT; -extern process_profile_definition g_profile_NPC_CHIN; -extern process_profile_definition g_profile_NPC_CLERKA; -extern process_profile_definition g_profile_NPC_CLERKB; -extern process_profile_definition g_profile_NPC_CLERKT; -extern process_profile_definition g_profile_NPC_COACH; -extern process_profile_definition g_profile_NPC_DF; -extern process_profile_definition g_profile_NPC_DOC; -extern process_profile_definition g_profile_NPC_DOORBOY; -extern process_profile_definition g_profile_NPC_DRSOL; -extern process_profile_definition g_profile_NPC_DU; -extern process_profile_definition g_profile_NPC_FAIRY; -extern process_profile_definition g_profile_NPC_FGUARD; -extern process_profile_definition g_profile_NPC_GND; -extern process_profile_definition g_profile_NPC_GRA; -extern process_profile_definition g_profile_NPC_GRC; -extern process_profile_definition g_profile_NPC_GRD; -extern process_profile_definition g_profile_NPC_GRM; -extern process_profile_definition g_profile_NPC_GRMC; -extern process_profile_definition g_profile_NPC_GRO; -extern process_profile_definition g_profile_NPC_GRR; -extern process_profile_definition g_profile_NPC_GRS; -extern process_profile_definition g_profile_NPC_GRZ; -extern process_profile_definition g_profile_NPC_GUARD; -extern process_profile_definition g_profile_NPC_GWOLF; -extern process_profile_definition g_profile_NPC_HANJO; -extern process_profile_definition g_profile_NPC_HENNA0; -extern process_profile_definition g_profile_NPC_HOZ; -extern process_profile_definition g_profile_NPC_IMPAL; -extern process_profile_definition g_profile_NPC_INKO; -extern process_profile_definition g_profile_NPC_INS; -extern process_profile_definition g_profile_NPC_JAGAR; -extern process_profile_definition g_profile_NPC_KASIHANA; -extern process_profile_definition g_profile_NPC_KASIKYU; -extern process_profile_definition g_profile_NPC_KASIMICH; -extern process_profile_definition g_profile_NPC_KDK; -extern process_profile_definition g_profile_NPC_KN; -extern process_profile_definition g_profile_NPC_KNJ; -extern process_profile_definition g_profile_NPC_KOLINB; -extern process_profile_definition g_profile_NPC_KS; -extern process_profile_definition g_profile_NPC_KYURY; -extern process_profile_definition g_profile_NPC_LEN; -extern process_profile_definition g_profile_NPC_LF; -extern process_profile_definition g_profile_NPC_LUD; -extern process_profile_definition g_profile_NPC_MIDP; -extern process_profile_definition g_profile_NPC_MK; -extern process_profile_definition g_profile_NPC_MOI; -extern process_profile_definition g_profile_NPC_MOIR; -extern process_profile_definition g_profile_MYNA2; -extern process_profile_definition g_profile_NPC_NE; -extern process_profile_definition g_profile_NPC_P2; -extern process_profile_definition g_profile_NPC_PACHI_BESU; -extern process_profile_definition g_profile_NPC_PACHI_MARO; -extern process_profile_definition g_profile_NPC_PACHI_TARO; -extern process_profile_definition g_profile_NPC_PASSER; -extern process_profile_definition g_profile_NPC_PASSER2; -extern process_profile_definition g_profile_NPC_POST; -extern process_profile_definition g_profile_NPC_POUYA; -extern process_profile_definition g_profile_NPC_PRAYER; -extern process_profile_definition g_profile_NPC_RACA; -extern process_profile_definition g_profile_NPC_RAFREL; -extern process_profile_definition g_profile_NPC_SARU; -extern process_profile_definition g_profile_NPC_SEIB; -extern process_profile_definition g_profile_NPC_SEIC; -extern process_profile_definition g_profile_NPC_SEID; -extern process_profile_definition g_profile_NPC_SEIRA; -extern process_profile_definition g_profile_NPC_SERA2; -extern process_profile_definition g_profile_NPC_SEIREI; -extern process_profile_definition g_profile_NPC_SHAD; -extern process_profile_definition g_profile_NPC_SHAMAN; -extern process_profile_definition g_profile_NPC_SHOE; -extern process_profile_definition g_profile_NPC_SHOP0; -extern process_profile_definition g_profile_NPC_SMARO; -extern process_profile_definition g_profile_NPC_SOLA; -extern process_profile_definition g_profile_NPC_SOLDIERa; -extern process_profile_definition g_profile_NPC_SOLDIERb; -extern process_profile_definition g_profile_NPC_SQ; -extern process_profile_definition g_profile_NPC_THE; -extern process_profile_definition g_profile_NPC_THEB; -extern process_profile_definition g_profile_NPC_TK; -extern process_profile_definition g_profile_NPC_TKC; -extern process_profile_definition g_profile_NPC_TKJ2; -extern process_profile_definition g_profile_NPC_TKS; -extern process_profile_definition g_profile_NPC_TOBY; -extern process_profile_definition g_profile_NPC_TR; -extern process_profile_definition g_profile_NPC_URI; -extern process_profile_definition g_profile_NPC_WORM; -extern process_profile_definition g_profile_NPC_WRESTLER; -extern process_profile_definition g_profile_NPC_YAMID; -extern process_profile_definition g_profile_NPC_YAMIS; -extern process_profile_definition g_profile_NPC_YAMIT; -extern process_profile_definition g_profile_NPC_YELIA; -extern process_profile_definition g_profile_NPC_YKM; -extern process_profile_definition g_profile_NPC_YKW; -extern process_profile_definition g_profile_NPC_ZANB; -extern process_profile_definition g_profile_NPC_ZANT; -extern process_profile_definition g_profile_NPC_ZELR; -extern process_profile_definition g_profile_NPC_ZELRO; -extern process_profile_definition g_profile_NPC_ZELDA; -extern process_profile_definition g_profile_NPC_ZRA; -extern process_profile_definition g_profile_NPC_ZRC; -extern process_profile_definition g_profile_NPC_ZRZ; -extern process_profile_definition g_profile_Obj_Lv5Key; -extern process_profile_definition g_profile_Obj_Turara; -extern process_profile_definition g_profile_Obj_TvCdlst; -extern process_profile_definition g_profile_Obj_Ytaihou; -extern process_profile_definition g_profile_Obj_AmiShutter; -extern process_profile_definition g_profile_Obj_Ari; -extern process_profile_definition g_profile_OBJ_AUTOMATA; -extern process_profile_definition g_profile_Obj_Avalanche; -extern process_profile_definition g_profile_OBJ_BALLOON; -extern process_profile_definition g_profile_Obj_BarDesk; -extern process_profile_definition g_profile_Obj_Batta; -extern process_profile_definition g_profile_Obj_BBox; -extern process_profile_definition g_profile_OBJ_BED; -extern process_profile_definition g_profile_Obj_Bemos; -extern process_profile_definition g_profile_Obj_Bhbridge; -extern process_profile_definition g_profile_Obj_BkLeaf; -extern process_profile_definition g_profile_BkyRock; -extern process_profile_definition g_profile_Obj_BmWindow; -extern process_profile_definition g_profile_Obj_BoomShutter; -extern process_profile_definition g_profile_Obj_Bombf; -extern process_profile_definition g_profile_OBJ_BOUMATO; -extern process_profile_definition g_profile_OBJ_BRG; -extern process_profile_definition g_profile_Obj_BsGate; -extern process_profile_definition g_profile_Obj_awaPlar; -extern process_profile_definition g_profile_Obj_CatDoor; -extern process_profile_definition g_profile_OBJ_CB; -extern process_profile_definition g_profile_Obj_ChainBlock; -extern process_profile_definition g_profile_Obj_Cdoor; -extern process_profile_definition g_profile_Obj_Chandelier; -extern process_profile_definition g_profile_Obj_Chest; -extern process_profile_definition g_profile_Obj_Cho; -extern process_profile_definition g_profile_Obj_Cowdoor; -extern process_profile_definition g_profile_Obj_Crope; -extern process_profile_definition g_profile_Obj_CRVFENCE; -extern process_profile_definition g_profile_Obj_CRVGATE; -extern process_profile_definition g_profile_Obj_CRVHAHEN; -extern process_profile_definition g_profile_Obj_CRVLH_DW; -extern process_profile_definition g_profile_Obj_CRVLH_UP; -extern process_profile_definition g_profile_Obj_CRVSTEEL; -extern process_profile_definition g_profile_Obj_Crystal; -extern process_profile_definition g_profile_Obj_ChainWall; -extern process_profile_definition g_profile_Obj_DamCps; -extern process_profile_definition g_profile_Obj_Dan; -extern process_profile_definition g_profile_Obj_Digholl; -extern process_profile_definition g_profile_Obj_DigSnow; -extern process_profile_definition g_profile_Obj_Elevator; -extern process_profile_definition g_profile_Obj_Drop; -extern process_profile_definition g_profile_Obj_DUST; -extern process_profile_definition g_profile_Obj_E_CREATE; -extern process_profile_definition g_profile_Obj_FallObj; -extern process_profile_definition g_profile_Obj_Fan; -extern process_profile_definition g_profile_Obj_Fchain; -extern process_profile_definition g_profile_Obj_FireWood; -extern process_profile_definition g_profile_Obj_FireWood2; -extern process_profile_definition g_profile_Obj_FirePillar; -extern process_profile_definition g_profile_Obj_FirePillar2; -extern process_profile_definition g_profile_Obj_Flag; -extern process_profile_definition g_profile_Obj_Flag2; -extern process_profile_definition g_profile_Obj_Flag3; -extern process_profile_definition g_profile_OBJ_FOOD; -extern process_profile_definition g_profile_OBJ_FW; -extern process_profile_definition g_profile_OBJ_GADGET; -extern process_profile_definition g_profile_Obj_GanonWall; -extern process_profile_definition g_profile_Obj_GanonWall2; -extern process_profile_definition g_profile_OBJ_GB; -extern process_profile_definition g_profile_Obj_Geyser; -extern process_profile_definition g_profile_Obj_glowSphere; -extern process_profile_definition g_profile_OBJ_GM; -extern process_profile_definition g_profile_Obj_GoGate; -extern process_profile_definition g_profile_Obj_GOMIKABE; -extern process_profile_definition g_profile_OBJ_GRA; -extern process_profile_definition g_profile_GRA_WALL; -extern process_profile_definition g_profile_Obj_GraRock; -extern process_profile_definition g_profile_Obj_GraveStone; -extern process_profile_definition g_profile_GRDWATER; -extern process_profile_definition g_profile_Obj_GrzRock; -extern process_profile_definition g_profile_Obj_H_Saku; -extern process_profile_definition g_profile_Obj_HBarrel; -extern process_profile_definition g_profile_Obj_HFtr; -extern process_profile_definition g_profile_Obj_MHasu; -extern process_profile_definition g_profile_Obj_Hata; -extern process_profile_definition g_profile_OBJ_HB; -extern process_profile_definition g_profile_Obj_HBombkoya; -extern process_profile_definition g_profile_Obj_HeavySw; -extern process_profile_definition g_profile_Obj_Hfuta; -extern process_profile_definition g_profile_Obj_HsTarget; -extern process_profile_definition g_profile_Obj_Ice_l; -extern process_profile_definition g_profile_Obj_Ice_s; -extern process_profile_definition g_profile_Obj_IceBlock; -extern process_profile_definition g_profile_Obj_IceLeaf; -extern process_profile_definition g_profile_OBJ_IHASI; -extern process_profile_definition g_profile_Obj_Ikada; -extern process_profile_definition g_profile_Obj_InoBone; -extern process_profile_definition g_profile_Obj_ITA; -extern process_profile_definition g_profile_OBJ_ITAMATO; -extern process_profile_definition g_profile_Obj_Kabuto; -extern process_profile_definition g_profile_Obj_Kag; -extern process_profile_definition g_profile_OBJ_KAGE; -extern process_profile_definition g_profile_OBJ_KAGO; -extern process_profile_definition g_profile_Obj_Kaisou; -extern process_profile_definition g_profile_Obj_Kam; -extern process_profile_definition g_profile_Obj_Kantera; -extern process_profile_definition g_profile_Obj_Kat; -extern process_profile_definition g_profile_Obj_KazeNeko; -extern process_profile_definition g_profile_OBJ_KBOX; -extern process_profile_definition g_profile_OBJ_KEY; -extern process_profile_definition g_profile_OBJ_KEYHOLE; -extern process_profile_definition g_profile_OBJ_KI; -extern process_profile_definition g_profile_Obj_KiPot; -extern process_profile_definition g_profile_OBJ_KITA; -extern process_profile_definition g_profile_Obj_KJgjs; -extern process_profile_definition g_profile_Obj_KKanban; -extern process_profile_definition g_profile_KN_BULLET; -extern process_profile_definition g_profile_Obj_Kshutter; -extern process_profile_definition g_profile_Obj_Kuw; -extern process_profile_definition g_profile_Obj_KWheel00; -extern process_profile_definition g_profile_Obj_KWheel01; -extern process_profile_definition g_profile_Obj_KznkArm; -extern process_profile_definition g_profile_Obj_Laundry; -extern process_profile_definition g_profile_Obj_LndRope; -extern process_profile_definition g_profile_OBJ_LBOX; -extern process_profile_definition g_profile_OBJ_LP; -extern process_profile_definition g_profile_Obj_Lv1Cdl00; -extern process_profile_definition g_profile_Obj_Lv1Cdl01; -extern process_profile_definition g_profile_Obj_Lv3Candle; -extern process_profile_definition g_profile_Obj_Lv3Water; -extern process_profile_definition g_profile_Obj_Lv3Water2; -extern process_profile_definition g_profile_OBJ_LV3WATERB; -extern process_profile_definition g_profile_Obj_Lv3R10Saka; -extern process_profile_definition g_profile_Obj_WaterEff; -extern process_profile_definition g_profile_Tag_Lv4CandleDm; -extern process_profile_definition g_profile_Tag_Lv4Candle; -extern process_profile_definition g_profile_Obj_Lv4EdShutter; -extern process_profile_definition g_profile_Obj_Lv4Gate; -extern process_profile_definition g_profile_Obj_Lv4HsTarget; -extern process_profile_definition g_profile_Obj_Lv4PoGate; -extern process_profile_definition g_profile_Obj_Lv4RailWall; -extern process_profile_definition g_profile_Obj_Lv4SlideWall; -extern process_profile_definition g_profile_Obj_Lv4Bridge; -extern process_profile_definition g_profile_Obj_Lv4Chan; -extern process_profile_definition g_profile_Obj_Lv4DigSand; -extern process_profile_definition g_profile_Obj_Lv4Floor; -extern process_profile_definition g_profile_Obj_Lv4Gear; -extern process_profile_definition g_profile_Obj_PRElvtr; -extern process_profile_definition g_profile_Obj_Lv4PRwall; -extern process_profile_definition g_profile_Obj_Lv4Sand; -extern process_profile_definition g_profile_Obj_Lv5FBoard; -extern process_profile_definition g_profile_Obj_IceWall; -extern process_profile_definition g_profile_Obj_Lv5SwIce; -extern process_profile_definition g_profile_Obj_Ychndlr; -extern process_profile_definition g_profile_Obj_YIblltray; -extern process_profile_definition g_profile_Obj_Lv6ChgGate; -extern process_profile_definition g_profile_Obj_Lv6FuriTrap; -extern process_profile_definition g_profile_Obj_Lv6Lblock; -extern process_profile_definition g_profile_Obj_Lv6SwGate; -extern process_profile_definition g_profile_Obj_Lv6SzGate; -extern process_profile_definition g_profile_Obj_Lv6Tenbin; -extern process_profile_definition g_profile_Obj_Lv6TogeRoll; -extern process_profile_definition g_profile_Obj_Lv6TogeTrap; -extern process_profile_definition g_profile_Obj_Lv6bemos; -extern process_profile_definition g_profile_Obj_Lv6bemos2; -extern process_profile_definition g_profile_Obj_Lv6EGate; -extern process_profile_definition g_profile_Obj_Lv6ElevtA; -extern process_profile_definition g_profile_Obj_Lv6SwTurn; -extern process_profile_definition g_profile_Obj_Lv7BsGate; -extern process_profile_definition g_profile_Obj_Lv7PropY; -extern process_profile_definition g_profile_Obj_Lv7Bridge; -extern process_profile_definition g_profile_Obj_Lv8KekkaiTrap; -extern process_profile_definition g_profile_Obj_Lv8Lift; -extern process_profile_definition g_profile_Obj_Lv8OptiLift; -extern process_profile_definition g_profile_Obj_Lv8UdFloor; -extern process_profile_definition g_profile_Obj_Lv9SwShutter; -extern process_profile_definition g_profile_Obj_MagLift; -extern process_profile_definition g_profile_Obj_MagLiftRot; -extern process_profile_definition g_profile_OBJ_MAKI; -extern process_profile_definition g_profile_Obj_MasterSword; -extern process_profile_definition g_profile_Obj_Mato; -extern process_profile_definition g_profile_Obj_MHole; -extern process_profile_definition g_profile_OBJ_MIE; -extern process_profile_definition g_profile_Obj_Mirror6Pole; -extern process_profile_definition g_profile_Obj_MirrorChain; -extern process_profile_definition g_profile_Obj_MirrorSand; -extern process_profile_definition g_profile_Obj_MirrorScrew; -extern process_profile_definition g_profile_Obj_MirrorTable; -extern process_profile_definition g_profile_OBJ_MSIMA; -extern process_profile_definition g_profile_Obj_MvStair; -extern process_profile_definition g_profile_OBJ_MYOGAN; -extern process_profile_definition g_profile_Obj_Nagaisu; -extern process_profile_definition g_profile_Obj_Nan; -extern process_profile_definition g_profile_OBJ_NDOOR; -extern process_profile_definition g_profile_OBJ_NOUGU; -extern process_profile_definition g_profile_OCTHASHI; -extern process_profile_definition g_profile_OBJ_OILTUBO; -extern process_profile_definition g_profile_Obj_Onsen; -extern process_profile_definition g_profile_OBJ_ONSEN_FIRE; -extern process_profile_definition g_profile_Obj_OnsenTaru; -extern process_profile_definition g_profile_Obj_PushDoor; -extern process_profile_definition g_profile_Obj_PDtile; -extern process_profile_definition g_profile_Obj_PDwall; -extern process_profile_definition g_profile_Obj_Picture; -extern process_profile_definition g_profile_Obj_Pillar; -extern process_profile_definition g_profile_OBJ_PLEAF; -extern process_profile_definition g_profile_Obj_poCandle; -extern process_profile_definition g_profile_Obj_poFire; -extern process_profile_definition g_profile_Obj_poTbox; -extern process_profile_definition g_profile_Obj_Prop; -extern process_profile_definition g_profile_OBJ_PUMPKIN; -extern process_profile_definition g_profile_Obj_RCircle; -extern process_profile_definition g_profile_Obj_RfHole; -extern process_profile_definition g_profile_Obj_RiderGate; -extern process_profile_definition g_profile_Obj_RIVERROCK; -extern process_profile_definition g_profile_OBJ_ROCK; -extern process_profile_definition g_profile_Obj_RotBridge; -extern process_profile_definition g_profile_Obj_RotTrap; -extern process_profile_definition g_profile_OBJ_ROTEN; -extern process_profile_definition g_profile_Obj_RotStair; -extern process_profile_definition g_profile_OBJ_RW; -extern process_profile_definition g_profile_Obj_Saidan; -extern process_profile_definition g_profile_Obj_Sakuita; -extern process_profile_definition g_profile_Obj_ItaRope; -extern process_profile_definition g_profile_Obj_SCannon; -extern process_profile_definition g_profile_Obj_SCannonCrs; -extern process_profile_definition g_profile_Obj_SCannonTen; -extern process_profile_definition g_profile_OBJ_SEKIDOOR; -extern process_profile_definition g_profile_OBJ_SEKIZO; -extern process_profile_definition g_profile_OBJ_SEKIZOA; -extern process_profile_definition g_profile_Obj_Shield; -extern process_profile_definition g_profile_Obj_SM_DOOR; -extern process_profile_definition g_profile_Obj_SmallKey; -extern process_profile_definition g_profile_Obj_SmgDoor; -extern process_profile_definition g_profile_Obj_Smoke; -extern process_profile_definition g_profile_OBJ_SMTILE; -extern process_profile_definition g_profile_Obj_SmWStone; -extern process_profile_definition g_profile_Tag_SnowEff; -extern process_profile_definition g_profile_Obj_SnowSoup; -extern process_profile_definition g_profile_OBJ_SO; -extern process_profile_definition g_profile_Obj_SpinLift; -extern process_profile_definition g_profile_OBJ_SSDRINK; -extern process_profile_definition g_profile_OBJ_SSITEM; -extern process_profile_definition g_profile_Obj_StairBlock; -extern process_profile_definition g_profile_Obj_Stone; -extern process_profile_definition g_profile_Obj_Stopper; -extern process_profile_definition g_profile_Obj_Stopper2; -extern process_profile_definition g_profile_OBJ_SUISYA; -extern process_profile_definition g_profile_OBJ_SW; -extern process_profile_definition g_profile_Obj_SwBallA; -extern process_profile_definition g_profile_Obj_SwBallB; -extern process_profile_definition g_profile_Obj_SwBallC; -extern process_profile_definition g_profile_Obj_SwLight; -extern process_profile_definition g_profile_Obj_SwChain; -extern process_profile_definition g_profile_Obj_SwHang; -extern process_profile_definition g_profile_Obj_Sword; -extern process_profile_definition g_profile_Obj_Swpush2; -extern process_profile_definition g_profile_Obj_SwSpinner; -extern process_profile_definition g_profile_Obj_SwTurn; -extern process_profile_definition g_profile_Obj_SyRock; -extern process_profile_definition g_profile_Obj_SZbridge; -extern process_profile_definition g_profile_Obj_TaFence; -extern process_profile_definition g_profile_Obj_Table; -extern process_profile_definition g_profile_Obj_TakaraDai; -extern process_profile_definition g_profile_OBJ_TATIGI; -extern process_profile_definition g_profile_Obj_Ten; -extern process_profile_definition g_profile_Obj_TestCube; -extern process_profile_definition g_profile_Obj_Gake; -extern process_profile_definition g_profile_Obj_THASHI; -extern process_profile_definition g_profile_Obj_TDoor; -extern process_profile_definition g_profile_Obj_TimeFire; -extern process_profile_definition g_profile_OBJ_TKS; -extern process_profile_definition g_profile_Obj_TMoon; -extern process_profile_definition g_profile_Obj_ToaruMaki; -extern process_profile_definition g_profile_OBJ_TOBY; -extern process_profile_definition g_profile_Obj_TobyHouse; -extern process_profile_definition g_profile_Obj_TogeTrap; -extern process_profile_definition g_profile_Obj_Tombo; -extern process_profile_definition g_profile_Obj_Tornado; -extern process_profile_definition g_profile_Obj_Tornado2; -extern process_profile_definition g_profile_OBJ_TP; -extern process_profile_definition g_profile_TREESH; -extern process_profile_definition g_profile_Obj_TwGate; -extern process_profile_definition g_profile_OBJ_UDOOR; -extern process_profile_definition g_profile_OBJ_USAKU; -extern process_profile_definition g_profile_Obj_VolcGnd; -extern process_profile_definition g_profile_Obj_VolcanicBall; -extern process_profile_definition g_profile_Obj_VolcanicBomb; -extern process_profile_definition g_profile_Obj_KakarikoBrg; -extern process_profile_definition g_profile_Obj_OrdinBrg; -extern process_profile_definition g_profile_Obj_WtGate; -extern process_profile_definition g_profile_Obj_WaterPillar; -extern process_profile_definition g_profile_Obj_WaterFall; -extern process_profile_definition g_profile_Obj_Wchain; -extern process_profile_definition g_profile_Obj_WdStick; -extern process_profile_definition g_profile_OBJ_WEB0; -extern process_profile_definition g_profile_OBJ_WEB1; -extern process_profile_definition g_profile_Obj_WellCover; -extern process_profile_definition g_profile_OBJ_WFLAG; -extern process_profile_definition g_profile_Obj_WindStone; -extern process_profile_definition g_profile_Obj_Window; -extern process_profile_definition g_profile_Obj_WoodPendulum; -extern process_profile_definition g_profile_Obj_WoodStatue; -extern process_profile_definition g_profile_Obj_WoodenSword; -extern process_profile_definition g_profile_OBJ_YBAG; -extern process_profile_definition g_profile_OBJ_YSTONE; -extern process_profile_definition g_profile_Obj_ZoraCloth; -extern process_profile_definition g_profile_Obj_ZDoor; -extern process_profile_definition g_profile_Obj_zrTurara; -extern process_profile_definition g_profile_Obj_zrTuraraRc; -extern process_profile_definition g_profile_ZRA_MARK; -extern process_profile_definition g_profile_OBJ_ZRAFREEZE; -extern process_profile_definition g_profile_Obj_ZraRock; -extern process_profile_definition g_profile_PASSER_MNG; -extern process_profile_definition g_profile_PERU; -extern process_profile_definition g_profile_PPolamp; -extern process_profile_definition g_profile_SKIP2D; -extern process_profile_definition g_profile_START_AND_GOAL; -extern process_profile_definition g_profile_SwBall; -extern process_profile_definition g_profile_SwLBall; -extern process_profile_definition g_profile_SwTime; -extern process_profile_definition g_profile_Tag_Lv6Gate; -extern process_profile_definition g_profile_Tag_Lv7Gate; -extern process_profile_definition g_profile_Tag_Lv8Gate; -extern process_profile_definition g_profile_Tag_TWGate; -extern process_profile_definition g_profile_Tag_Arena; -extern process_profile_definition g_profile_Tag_Assist; -extern process_profile_definition g_profile_TAG_BTLITM; -extern process_profile_definition g_profile_Tag_ChgRestart; -extern process_profile_definition g_profile_TAG_CSW; -extern process_profile_definition g_profile_Tag_Escape; -extern process_profile_definition g_profile_Tag_FWall; -extern process_profile_definition g_profile_TAG_GRA; -extern process_profile_definition g_profile_TAG_GUARD; -extern process_profile_definition g_profile_Tag_Instruction; -extern process_profile_definition g_profile_Tag_KagoFall; -extern process_profile_definition g_profile_Tag_LightBall; -extern process_profile_definition g_profile_TAG_LV5SOUP; -extern process_profile_definition g_profile_Tag_Lv6CstaSw; -extern process_profile_definition g_profile_Tag_Mmsg; -extern process_profile_definition g_profile_Tag_Mwait; -extern process_profile_definition g_profile_TAG_MYNA2; -extern process_profile_definition g_profile_TAG_MNLIGHT; -extern process_profile_definition g_profile_TAG_PATI; -extern process_profile_definition g_profile_Tag_poFire; -extern process_profile_definition g_profile_TAG_QS; -extern process_profile_definition g_profile_Tag_RetRoom; -extern process_profile_definition g_profile_Tag_RiverBack; -extern process_profile_definition g_profile_Tag_RmbitSw; -extern process_profile_definition g_profile_Tag_Schedule; -extern process_profile_definition g_profile_Tag_SetBall; -extern process_profile_definition g_profile_Tag_Restart; -extern process_profile_definition g_profile_TAG_SHOPCAM; -extern process_profile_definition g_profile_TAG_SHOPITM; -extern process_profile_definition g_profile_Tag_SmkEmt; -extern process_profile_definition g_profile_Tag_Spinner; -extern process_profile_definition g_profile_Tag_Sppath; -extern process_profile_definition g_profile_TAG_SSDRINK; -extern process_profile_definition g_profile_Tag_Stream; -extern process_profile_definition g_profile_Tag_TheBHint; -extern process_profile_definition g_profile_Tag_WaraHowl; -extern process_profile_definition g_profile_Tag_WatchGe; -extern process_profile_definition g_profile_Tag_WaterFall; -extern process_profile_definition g_profile_Tag_Wljump; -extern process_profile_definition g_profile_TAG_YAMI; -extern process_profile_definition g_profile_TALK; -extern process_profile_definition g_profile_TBOX_SW; -extern process_profile_definition g_profile_TITLE; -extern process_profile_definition g_profile_WarpBug; +DUSK_GAME_EXTERN process_profile_definition g_profile_ALINK; +DUSK_GAME_EXTERN process_profile_definition g_profile_NO_CHG_ROOM; +DUSK_GAME_EXTERN process_profile_definition g_profile_ITEM; +DUSK_GAME_EXTERN process_profile_definition g_profile_CAMERA; +DUSK_GAME_EXTERN process_profile_definition g_profile_CAMERA2; +DUSK_GAME_EXTERN process_profile_definition g_profile_ENVSE; +DUSK_GAME_EXTERN process_profile_definition g_profile_GAMEOVER; +DUSK_GAME_EXTERN process_profile_definition g_profile_KANKYO; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYEFF; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYEFF2; +DUSK_GAME_EXTERN process_profile_definition g_profile_KY_THUNDER; +DUSK_GAME_EXTERN process_profile_definition g_profile_MENUWINDOW; +DUSK_GAME_EXTERN process_profile_definition g_profile_METER2; +DUSK_GAME_EXTERN process_profile_definition g_profile_MSG_OBJECT; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP0; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP1; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP6; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP7; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP8; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP9; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP10; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP11; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OVERLAP3; +DUSK_GAME_EXTERN process_profile_definition g_profile_LOGO_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_MENU_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_NAME_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_NAMEEX_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_PLAY_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_OPENING_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_ROOM_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_WARNING_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_WARNING2_SCENE; +DUSK_GAME_EXTERN process_profile_definition g_profile_TIMER; +DUSK_GAME_EXTERN process_profile_definition g_profile_WMARK; +DUSK_GAME_EXTERN process_profile_definition g_profile_WPILLAR; +DUSK_GAME_EXTERN process_profile_definition g_profile_ANDSW; +DUSK_GAME_EXTERN process_profile_definition g_profile_BG; +DUSK_GAME_EXTERN process_profile_definition g_profile_BG_OBJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_DMIDNA; +DUSK_GAME_EXTERN process_profile_definition g_profile_DBDOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_KNOB20; +DUSK_GAME_EXTERN process_profile_definition g_profile_DOOR20; +DUSK_GAME_EXTERN process_profile_definition g_profile_SPIRAL_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_DSHUTTER; +DUSK_GAME_EXTERN process_profile_definition g_profile_EP; +DUSK_GAME_EXTERN process_profile_definition g_profile_HITOBJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG00; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG04; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG17; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_BEF; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BurnBox; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Carry; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ITO; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Movebox; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Swpush; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Timer; +DUSK_GAME_EXTERN process_profile_definition g_profile_PATH_LINE; +DUSK_GAME_EXTERN process_profile_definition g_profile_SCENE_EXIT; +DUSK_GAME_EXTERN process_profile_definition g_profile_SET_BG_OBJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_SWHIT0; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_ALLMATO; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_CAMERA; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_CHKPOINT; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_EVENT; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_EVT; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_EVTAREA; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_EVTMSG; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_HOWL; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_KMSG; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_LANTERN; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Mist; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_MSG; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_PUSH; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_TELOP; +DUSK_GAME_EXTERN process_profile_definition g_profile_TBOX; +DUSK_GAME_EXTERN process_profile_definition g_profile_TBOX2; +DUSK_GAME_EXTERN process_profile_definition g_profile_VRBOX; +DUSK_GAME_EXTERN process_profile_definition g_profile_VRBOX2; +DUSK_GAME_EXTERN process_profile_definition g_profile_ARROW; +DUSK_GAME_EXTERN process_profile_definition g_profile_BOOMERANG; +DUSK_GAME_EXTERN process_profile_definition g_profile_CROD; +DUSK_GAME_EXTERN process_profile_definition g_profile_DEMO00; +DUSK_GAME_EXTERN process_profile_definition g_profile_DISAPPEAR; +DUSK_GAME_EXTERN process_profile_definition g_profile_MG_ROD; +DUSK_GAME_EXTERN process_profile_definition g_profile_MIDNA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NBOMB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_LifeContainer; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Yousei; +DUSK_GAME_EXTERN process_profile_definition g_profile_SPINNER; +DUSK_GAME_EXTERN process_profile_definition g_profile_SUSPEND; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Attp; +DUSK_GAME_EXTERN process_profile_definition g_profile_ALLDIE; +DUSK_GAME_EXTERN process_profile_definition g_profile_ANDSW2; +DUSK_GAME_EXTERN process_profile_definition g_profile_BD; +DUSK_GAME_EXTERN process_profile_definition g_profile_CANOE; +DUSK_GAME_EXTERN process_profile_definition g_profile_CSTAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_Demo_Item; +DUSK_GAME_EXTERN process_profile_definition g_profile_L1BOSS_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DN; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_FM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GA; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_NEST; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_RD; +DUSK_GAME_EXTERN process_profile_definition g_profile_ECONT; +DUSK_GAME_EXTERN process_profile_definition g_profile_FR; +DUSK_GAME_EXTERN process_profile_definition g_profile_GRASS; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG05; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG10; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG11; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG14; +DUSK_GAME_EXTERN process_profile_definition g_profile_MG_FISH; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_BESU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_FAIRY_SEIREI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_FISH; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_HENNA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KAKASHI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KKRI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KOLIN; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_MARO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TARO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TKJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BHASHI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BkDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BossWarp; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Cboard; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Digpl; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Eff; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_FMOBJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GpTaru; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HHASHI; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KANBAN2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KBACKET; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KkrGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KLift00; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_KtOnFire; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ladder; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv2Candle; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MagneArm; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MetalBox; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_NamePlate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_OnCloth; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RopeBridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwallShutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_STICK; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_StoneMark; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Swpropeller; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Swpush5; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Yobikusa; +DUSK_GAME_EXTERN process_profile_definition g_profile_SCENE_EXIT2; +DUSK_GAME_EXTERN process_profile_definition g_profile_ShopItem; +DUSK_GAME_EXTERN process_profile_definition g_profile_SQ; +DUSK_GAME_EXTERN process_profile_definition g_profile_SWC00; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_CstaSw; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_AJnot; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_AttackItem; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Gstart; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Hinit; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Hjump; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Hstop; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv2PrChk; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Magne; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Mhint; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Mstop; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Spring; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Statue; +DUSK_GAME_EXTERN process_profile_definition g_profile_Ykgr; +DUSK_GAME_EXTERN process_profile_definition g_profile_DR; +DUSK_GAME_EXTERN process_profile_definition g_profile_L7lowDr; +DUSK_GAME_EXTERN process_profile_definition g_profile_L7ODR; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_BH; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_BQ; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_DR; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_DRE; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_DS; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_GG; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_GM; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_GND; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_GO; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_GOS; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_MGN; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_OB; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_OH; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_OH2; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_TN; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_YO; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_YOI; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_ZANT; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_ZANTM; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_ZANTZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_B_ZANTS; +DUSK_GAME_EXTERN process_profile_definition g_profile_BALLOON2D; +DUSK_GAME_EXTERN process_profile_definition g_profile_BULLET; +DUSK_GAME_EXTERN process_profile_definition g_profile_COACH2D; +DUSK_GAME_EXTERN process_profile_definition g_profile_COACH_FIRE; +DUSK_GAME_EXTERN process_profile_definition g_profile_COW; +DUSK_GAME_EXTERN process_profile_definition g_profile_CSTATUE; +DUSK_GAME_EXTERN process_profile_definition g_profile_DO; +DUSK_GAME_EXTERN process_profile_definition g_profile_BOSS_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_L5BOSS_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_L1MBOSS_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_PushDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_AI; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ARROW; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BA; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BEE; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BI; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BI_LEAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BU; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_BUG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_CR; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_CR_EGG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DB_LEAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DD; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_DT; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_FB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_FK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_FS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_FZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GE; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GI; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GOB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_GS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HB_LEAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HP; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_HZELDA; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_IS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_KG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_KK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_KR; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MD; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MK_BO; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MM_MT; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_MS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_NZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_OC; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_OctBg; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_OT; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_PH; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_PM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_PO; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_PZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_RB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_RDB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_RDY; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_S1; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SH; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SM2; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ST; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ST_LINE; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_SW; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TH; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TH_BALL; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TK2; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TK_BALL; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_TT; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_VT; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_WAP; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_WB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_WS; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_WW; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YC; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YD; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YD_LEAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YH; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YK; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YM_TAG; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YMB; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_YR; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ZH; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ZM; +DUSK_GAME_EXTERN process_profile_definition g_profile_E_ZS; +DUSK_GAME_EXTERN process_profile_definition g_profile_FORMATION_MNG; +DUSK_GAME_EXTERN process_profile_definition g_profile_GUARD_MNG; +DUSK_GAME_EXTERN process_profile_definition g_profile_HORSE; +DUSK_GAME_EXTERN process_profile_definition g_profile_HOZELDA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Izumi_Gate; +DUSK_GAME_EXTERN process_profile_definition g_profile_KAGO; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG01; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG02; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG03; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG06; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG07; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG08; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG09; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG12; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG13; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG15; +DUSK_GAME_EXTERN process_profile_definition g_profile_KYTAG16; +DUSK_GAME_EXTERN process_profile_definition g_profile_MANT; +DUSK_GAME_EXTERN process_profile_definition g_profile_FSHOP; +DUSK_GAME_EXTERN process_profile_definition g_profile_MIRROR; +DUSK_GAME_EXTERN process_profile_definition g_profile_MOVIE_PLAYER; +DUSK_GAME_EXTERN process_profile_definition g_profile_MYNA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ARU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ASH; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ASHB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_BANS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_BLUENS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_BOU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_BOU_S; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CD3; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CHAT; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CHIN; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CLERKA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CLERKB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_CLERKT; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_COACH; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_DF; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_DOC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_DOORBOY; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_DRSOL; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_DU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_FAIRY; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_FGUARD; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GND; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRD; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRM; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRMC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRR; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GRZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GUARD; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_GWOLF; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_HANJO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_HENNA0; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_HOZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_IMPAL; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_INKO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_INS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_JAGAR; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KASIHANA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KASIKYU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KASIMICH; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KDK; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KN; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KNJ; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KOLINB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_KYURY; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_LEN; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_LF; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_LUD; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_MIDP; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_MK; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_MOI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_MOIR; +DUSK_GAME_EXTERN process_profile_definition g_profile_MYNA2; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_NE; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_P2; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PACHI_BESU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PACHI_MARO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PACHI_TARO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PASSER; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PASSER2; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_POST; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_POUYA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_PRAYER; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_RACA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_RAFREL; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SARU; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SEIB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SEIC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SEID; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SEIRA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SERA2; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SEIREI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SHAD; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SHAMAN; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SHOE; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SHOP0; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SMARO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SOLA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SOLDIERa; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SOLDIERb; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_SQ; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_THE; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_THEB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TK; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TKC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TKJ2; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TKS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TOBY; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_TR; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_URI; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_WORM; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_WRESTLER; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YAMID; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YAMIS; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YAMIT; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YELIA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YKM; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_YKW; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZANB; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZANT; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZELR; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZELRO; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZELDA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZRA; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZRC; +DUSK_GAME_EXTERN process_profile_definition g_profile_NPC_ZRZ; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv5Key; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Turara; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TvCdlst; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ytaihou; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_AmiShutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ari; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_AUTOMATA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Avalanche; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_BALLOON; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BarDesk; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Batta; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BBox; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_BED; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Bemos; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Bhbridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BkLeaf; +DUSK_GAME_EXTERN process_profile_definition g_profile_BkyRock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BmWindow; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BoomShutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Bombf; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_BOUMATO; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_BRG; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_BsGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_awaPlar; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CatDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_CB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ChainBlock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Cdoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Chandelier; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Chest; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Cho; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Cowdoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Crope; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVFENCE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVGATE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVHAHEN; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVLH_DW; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVLH_UP; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_CRVSTEEL; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Crystal; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ChainWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_DamCps; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Dan; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Digholl; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_DigSnow; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Elevator; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Drop; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_DUST; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_E_CREATE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_FallObj; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Fan; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Fchain; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_FireWood; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_FireWood2; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_FirePillar; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_FirePillar2; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Flag; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Flag2; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Flag3; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_FOOD; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_FW; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_GADGET; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GanonWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GanonWall2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_GB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Geyser; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_glowSphere; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_GM; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GoGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GOMIKABE; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_GRA; +DUSK_GAME_EXTERN process_profile_definition g_profile_GRA_WALL; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GraRock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GraveStone; +DUSK_GAME_EXTERN process_profile_definition g_profile_GRDWATER; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_GrzRock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_H_Saku; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HBarrel; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HFtr; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MHasu; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Hata; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_HB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HBombkoya; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HeavySw; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Hfuta; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_HsTarget; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ice_l; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ice_s; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_IceBlock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_IceLeaf; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_IHASI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ikada; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_InoBone; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ITA; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ITAMATO; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kabuto; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kag; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KAGE; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KAGO; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kaisou; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kam; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kantera; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kat; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KazeNeko; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KBOX; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KEY; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KEYHOLE; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KiPot; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_KITA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KJgjs; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KKanban; +DUSK_GAME_EXTERN process_profile_definition g_profile_KN_BULLET; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kshutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Kuw; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KWheel00; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KWheel01; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KznkArm; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Laundry; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_LndRope; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_LBOX; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_LP; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv1Cdl00; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv1Cdl01; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv3Candle; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv3Water; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv3Water2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_LV3WATERB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv3R10Saka; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WaterEff; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv4CandleDm; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv4Candle; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4EdShutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Gate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4HsTarget; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4PoGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4RailWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4SlideWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Bridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Chan; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4DigSand; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Floor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Gear; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_PRElvtr; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4PRwall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv4Sand; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv5FBoard; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_IceWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv5SwIce; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ychndlr; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_YIblltray; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6ChgGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6FuriTrap; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6Lblock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6SwGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6SzGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6Tenbin; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6TogeRoll; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6TogeTrap; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6bemos; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6bemos2; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6EGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6ElevtA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv6SwTurn; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv7BsGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv7PropY; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv7Bridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv8KekkaiTrap; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv8Lift; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv8OptiLift; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv8UdFloor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Lv9SwShutter; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MagLift; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MagLiftRot; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_MAKI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MasterSword; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Mato; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MHole; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_MIE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Mirror6Pole; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MirrorChain; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MirrorSand; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MirrorScrew; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MirrorTable; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_MSIMA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_MvStair; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_MYOGAN; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Nagaisu; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Nan; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_NDOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_NOUGU; +DUSK_GAME_EXTERN process_profile_definition g_profile_OCTHASHI; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_OILTUBO; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Onsen; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ONSEN_FIRE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_OnsenTaru; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_PushDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_PDtile; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_PDwall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Picture; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Pillar; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_PLEAF; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_poCandle; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_poFire; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_poTbox; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Prop; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_PUMPKIN; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RCircle; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RfHole; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RiderGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RIVERROCK; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ROCK; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RotBridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RotTrap; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ROTEN; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_RotStair; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_RW; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Saidan; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Sakuita; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ItaRope; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SCannon; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SCannonCrs; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SCannonTen; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SEKIDOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SEKIZO; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SEKIZOA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Shield; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SM_DOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SmallKey; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SmgDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Smoke; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SMTILE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SmWStone; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_SnowEff; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SnowSoup; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SO; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SpinLift; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SSDRINK; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SSITEM; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_StairBlock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Stone; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Stopper; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Stopper2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SUISYA; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_SW; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwBallA; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwBallB; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwBallC; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwLight; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwChain; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwHang; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Sword; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Swpush2; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwSpinner; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SwTurn; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SyRock; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_SZbridge; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TaFence; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Table; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TakaraDai; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_TATIGI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Ten; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TestCube; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Gake; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_THASHI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TimeFire; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_TKS; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TMoon; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ToaruMaki; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_TOBY; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TobyHouse; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TogeTrap; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Tombo; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Tornado; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Tornado2; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_TP; +DUSK_GAME_EXTERN process_profile_definition g_profile_TREESH; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_TwGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_UDOOR; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_USAKU; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_VolcGnd; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_VolcanicBall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_VolcanicBomb; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_KakarikoBrg; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_OrdinBrg; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WtGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WaterPillar; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WaterFall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Wchain; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WdStick; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_WEB0; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_WEB1; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WellCover; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_WFLAG; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WindStone; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_Window; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WoodPendulum; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WoodStatue; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_WoodenSword; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_YBAG; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_YSTONE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ZoraCloth; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ZDoor; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_zrTurara; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_zrTuraraRc; +DUSK_GAME_EXTERN process_profile_definition g_profile_ZRA_MARK; +DUSK_GAME_EXTERN process_profile_definition g_profile_OBJ_ZRAFREEZE; +DUSK_GAME_EXTERN process_profile_definition g_profile_Obj_ZraRock; +DUSK_GAME_EXTERN process_profile_definition g_profile_PASSER_MNG; +DUSK_GAME_EXTERN process_profile_definition g_profile_PERU; +DUSK_GAME_EXTERN process_profile_definition g_profile_PPolamp; +DUSK_GAME_EXTERN process_profile_definition g_profile_SKIP2D; +DUSK_GAME_EXTERN process_profile_definition g_profile_START_AND_GOAL; +DUSK_GAME_EXTERN process_profile_definition g_profile_SwBall; +DUSK_GAME_EXTERN process_profile_definition g_profile_SwLBall; +DUSK_GAME_EXTERN process_profile_definition g_profile_SwTime; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv6Gate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv7Gate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv8Gate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_TWGate; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Arena; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Assist; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_BTLITM; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_ChgRestart; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_CSW; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Escape; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_FWall; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_GRA; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_GUARD; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Instruction; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_KagoFall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_LightBall; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_LV5SOUP; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Lv6CstaSw; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Mmsg; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Mwait; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_MYNA2; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_MNLIGHT; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_PATI; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_poFire; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_QS; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_RetRoom; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_RiverBack; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_RmbitSw; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Schedule; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_SetBall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Restart; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_SHOPCAM; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_SHOPITM; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_SmkEmt; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Spinner; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Sppath; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_SSDRINK; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Stream; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_TheBHint; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_WaraHowl; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_WatchGe; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_WaterFall; +DUSK_GAME_EXTERN process_profile_definition g_profile_Tag_Wljump; +DUSK_GAME_EXTERN process_profile_definition g_profile_TAG_YAMI; +DUSK_GAME_EXTERN process_profile_definition g_profile_TALK; +DUSK_GAME_EXTERN process_profile_definition g_profile_TBOX_SW; +DUSK_GAME_EXTERN process_profile_definition g_profile_TITLE; +DUSK_GAME_EXTERN process_profile_definition g_profile_WarpBug; #else -extern actor_process_profile_definition DUSK_CONST g_profile_ALINK; -extern actor_process_profile_definition DUSK_CONST g_profile_NO_CHG_ROOM; -extern actor_process_profile_definition DUSK_CONST g_profile_ITEM; -extern camera_process_profile_definition DUSK_CONST g_profile_CAMERA; -extern camera_process_profile_definition DUSK_CONST g_profile_CAMERA2; -extern kankyo_process_profile_definition DUSK_CONST g_profile_ENVSE; -extern msg_process_profile_definition DUSK_CONST g_profile_GAMEOVER; -extern kankyo_process_profile_definition DUSK_CONST g_profile_KANKYO; -extern kankyo_process_profile_definition DUSK_CONST g_profile_KYEFF; -extern kankyo_process_profile_definition DUSK_CONST g_profile_KYEFF2; -extern kankyo_process_profile_definition DUSK_CONST g_profile_KY_THUNDER; -extern msg_process_profile_definition DUSK_CONST g_profile_MENUWINDOW; -extern msg_process_profile_definition DUSK_CONST g_profile_METER2; -extern msg_process_profile_definition DUSK_CONST g_profile_MSG_OBJECT; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP0; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP1; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP6; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP7; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP8; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP9; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP10; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP11; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP2; -extern overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP3; -extern scene_process_profile_definition DUSK_CONST g_profile_LOGO_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_MENU_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_NAME_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_NAMEEX_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_PLAY_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_OPENING_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_ROOM_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_WARNING_SCENE; -extern scene_process_profile_definition DUSK_CONST g_profile_WARNING2_SCENE; -extern msg_process_profile_definition DUSK_CONST g_profile_TIMER; -extern kankyo_process_profile_definition DUSK_CONST g_profile_WMARK; -extern kankyo_process_profile_definition DUSK_CONST g_profile_WPILLAR; -extern actor_process_profile_definition DUSK_CONST g_profile_ANDSW; -extern actor_process_profile_definition2 DUSK_CONST g_profile_BG; -extern actor_process_profile_definition DUSK_CONST g_profile_BG_OBJ; -extern actor_process_profile_definition DUSK_CONST g_profile_DMIDNA; -extern actor_process_profile_definition DUSK_CONST g_profile_DBDOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_KNOB20; -extern actor_process_profile_definition DUSK_CONST g_profile_DOOR20; -extern actor_process_profile_definition DUSK_CONST g_profile_SPIRAL_DOOR; -extern actor_process_profile_definition2 DUSK_CONST g_profile_DSHUTTER; -extern actor_process_profile_definition DUSK_CONST g_profile_EP; -extern actor_process_profile_definition DUSK_CONST g_profile_HITOBJ; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG00; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG04; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG17; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_BEF; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BurnBox; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Carry; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ITO; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Movebox; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Timer; -extern actor_process_profile_definition2 DUSK_CONST g_profile_PATH_LINE; -extern actor_process_profile_definition2 DUSK_CONST g_profile_SCENE_EXIT; -extern actor_process_profile_definition DUSK_CONST g_profile_SET_BG_OBJ; -extern actor_process_profile_definition DUSK_CONST g_profile_SWHIT0; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_ALLMATO; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_CAMERA; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_CHKPOINT; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_EVENT; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_EVT; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_EVTAREA; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_EVTMSG; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_HOWL; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_KMSG; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_LANTERN; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Mist; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_MSG; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_PUSH; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_TELOP; -extern actor_process_profile_definition DUSK_CONST g_profile_TBOX; -extern actor_process_profile_definition DUSK_CONST g_profile_TBOX2; -extern actor_process_profile_definition DUSK_CONST g_profile_VRBOX; -extern actor_process_profile_definition DUSK_CONST g_profile_VRBOX2; -extern actor_process_profile_definition DUSK_CONST g_profile_ARROW; -extern actor_process_profile_definition DUSK_CONST g_profile_BOOMERANG; -extern actor_process_profile_definition DUSK_CONST g_profile_CROD; -extern actor_process_profile_definition DUSK_CONST g_profile_DEMO00; -extern actor_process_profile_definition DUSK_CONST g_profile_DISAPPEAR; -extern actor_process_profile_definition DUSK_CONST g_profile_MG_ROD; -extern actor_process_profile_definition DUSK_CONST g_profile_MIDNA; -extern actor_process_profile_definition DUSK_CONST g_profile_NBOMB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_LifeContainer; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Yousei; -extern actor_process_profile_definition DUSK_CONST g_profile_SPINNER; -extern actor_process_profile_definition DUSK_CONST g_profile_SUSPEND; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Attp; -extern actor_process_profile_definition DUSK_CONST g_profile_ALLDIE; -extern actor_process_profile_definition DUSK_CONST g_profile_ANDSW2; -extern actor_process_profile_definition DUSK_CONST g_profile_BD; -extern actor_process_profile_definition DUSK_CONST g_profile_CANOE; -extern actor_process_profile_definition DUSK_CONST g_profile_CSTAF; -extern actor_process_profile_definition DUSK_CONST g_profile_Demo_Item; -extern actor_process_profile_definition DUSK_CONST g_profile_L1BOSS_DOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DN; -extern actor_process_profile_definition DUSK_CONST g_profile_E_FM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GA; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_NEST; -extern actor_process_profile_definition DUSK_CONST g_profile_E_RD; -extern actor_process_profile_definition DUSK_CONST g_profile_ECONT; -extern actor_process_profile_definition DUSK_CONST g_profile_FR; -extern actor_process_profile_definition DUSK_CONST g_profile_GRASS; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG05; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG10; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG11; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG14; -extern actor_process_profile_definition DUSK_CONST g_profile_MG_FISH; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_BESU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_FAIRY_SEIREI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_FISH; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_HENNA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KAKASHI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KKRI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KOLIN; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_MARO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TARO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TKJ; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BHASHI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BkDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BossWarp; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Cboard; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Digpl; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Eff; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_FMOBJ; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GpTaru; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HHASHI; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KANBAN2; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KBACKET; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KkrGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KLift00; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_KtOnFire; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ladder; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv2Candle; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MagneArm; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MetalBox; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_NamePlate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_OnCloth; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RopeBridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwallShutter; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_STICK; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_StoneMark; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpropeller; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush5; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Yobikusa; -extern actor_process_profile_definition DUSK_CONST g_profile_SCENE_EXIT2; -extern actor_process_profile_definition DUSK_CONST g_profile_ShopItem; -extern actor_process_profile_definition DUSK_CONST g_profile_SQ; -extern actor_process_profile_definition DUSK_CONST g_profile_SWC00; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_CstaSw; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_AJnot; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_AttackItem; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Gstart; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Hinit; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Hjump; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Hstop; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv2PrChk; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Magne; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Mhint; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Mstop; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Spring; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Statue; -extern actor_process_profile_definition DUSK_CONST g_profile_Ykgr; -extern actor_process_profile_definition DUSK_CONST g_profile_DR; -extern actor_process_profile_definition DUSK_CONST g_profile_L7lowDr; -extern actor_process_profile_definition DUSK_CONST g_profile_L7ODR; -extern actor_process_profile_definition DUSK_CONST g_profile_B_BH; -extern actor_process_profile_definition DUSK_CONST g_profile_B_BQ; -extern actor_process_profile_definition DUSK_CONST g_profile_B_DR; -extern actor_process_profile_definition DUSK_CONST g_profile_B_DRE; -extern actor_process_profile_definition DUSK_CONST g_profile_B_DS; -extern actor_process_profile_definition DUSK_CONST g_profile_B_GG; -extern actor_process_profile_definition DUSK_CONST g_profile_B_GM; -extern actor_process_profile_definition DUSK_CONST g_profile_B_GND; -extern actor_process_profile_definition DUSK_CONST g_profile_B_GO; -extern actor_process_profile_definition DUSK_CONST g_profile_B_GOS; -extern actor_process_profile_definition DUSK_CONST g_profile_B_MGN; -extern actor_process_profile_definition DUSK_CONST g_profile_B_OB; -extern actor_process_profile_definition DUSK_CONST g_profile_B_OH; -extern actor_process_profile_definition DUSK_CONST g_profile_B_OH2; -extern actor_process_profile_definition DUSK_CONST g_profile_B_TN; -extern actor_process_profile_definition DUSK_CONST g_profile_B_YO; -extern actor_process_profile_definition DUSK_CONST g_profile_B_YOI; -extern actor_process_profile_definition DUSK_CONST g_profile_B_ZANT; -extern actor_process_profile_definition DUSK_CONST g_profile_B_ZANTM; -extern actor_process_profile_definition DUSK_CONST g_profile_B_ZANTZ; -extern actor_process_profile_definition DUSK_CONST g_profile_B_ZANTS; -extern actor_process_profile_definition DUSK_CONST g_profile_BALLOON2D; -extern actor_process_profile_definition DUSK_CONST g_profile_BULLET; -extern actor_process_profile_definition DUSK_CONST g_profile_COACH2D; -extern actor_process_profile_definition DUSK_CONST g_profile_COACH_FIRE; -extern actor_process_profile_definition DUSK_CONST g_profile_COW; -extern actor_process_profile_definition DUSK_CONST g_profile_CSTATUE; -extern actor_process_profile_definition DUSK_CONST g_profile_DO; -extern actor_process_profile_definition DUSK_CONST g_profile_BOSS_DOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_L5BOSS_DOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_L1MBOSS_DOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_PushDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_E_AI; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ARROW; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BA; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BEE; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BI; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BI_LEAF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BU; -extern actor_process_profile_definition DUSK_CONST g_profile_E_BUG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_CR; -extern actor_process_profile_definition DUSK_CONST g_profile_E_CR_EGG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DB_LEAF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DD; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_DT; -extern actor_process_profile_definition DUSK_CONST g_profile_E_FB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_FK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_FS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_FZ; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GE; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GI; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GOB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_GS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HB_LEAF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HP; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HZ; -extern actor_process_profile_definition DUSK_CONST g_profile_E_HZELDA; -extern actor_process_profile_definition DUSK_CONST g_profile_E_IS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_KG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_KK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_KR; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MD; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MK_BO; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MM_MT; -extern actor_process_profile_definition DUSK_CONST g_profile_E_MS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_NZ; -extern actor_process_profile_definition DUSK_CONST g_profile_E_OC; -extern actor_process_profile_definition DUSK_CONST g_profile_E_OctBg; -extern actor_process_profile_definition DUSK_CONST g_profile_E_OT; -extern actor_process_profile_definition DUSK_CONST g_profile_E_PH; -extern actor_process_profile_definition DUSK_CONST g_profile_E_PM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_PO; -extern actor_process_profile_definition DUSK_CONST g_profile_E_PZ; -extern actor_process_profile_definition DUSK_CONST g_profile_E_RB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_RDB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_RDY; -extern actor_process_profile_definition DUSK_CONST g_profile_E_S1; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SH; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SM2; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ST; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ST_LINE; -extern actor_process_profile_definition DUSK_CONST g_profile_E_SW; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TH; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TH_BALL; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TK2; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TK_BALL; -extern actor_process_profile_definition DUSK_CONST g_profile_E_TT; -extern actor_process_profile_definition DUSK_CONST g_profile_E_VT; -extern actor_process_profile_definition DUSK_CONST g_profile_E_WAP; -extern actor_process_profile_definition DUSK_CONST g_profile_E_WB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_WS; -extern actor_process_profile_definition DUSK_CONST g_profile_E_WW; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YC; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YD; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YD_LEAF; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YH; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YK; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YM_TAG; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YMB; -extern actor_process_profile_definition DUSK_CONST g_profile_E_YR; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ZH; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ZM; -extern actor_process_profile_definition DUSK_CONST g_profile_E_ZS; -extern actor_process_profile_definition DUSK_CONST g_profile_FORMATION_MNG; -extern actor_process_profile_definition DUSK_CONST g_profile_GUARD_MNG; -extern actor_process_profile_definition DUSK_CONST g_profile_HORSE; -extern actor_process_profile_definition DUSK_CONST g_profile_HOZELDA; -extern actor_process_profile_definition DUSK_CONST g_profile_Izumi_Gate; -extern actor_process_profile_definition DUSK_CONST g_profile_KAGO; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG01; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG02; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG03; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG06; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG07; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG08; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG09; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG12; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG13; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG15; -extern actor_process_profile_definition DUSK_CONST g_profile_KYTAG16; -extern actor_process_profile_definition DUSK_CONST g_profile_MANT; -extern actor_process_profile_definition DUSK_CONST g_profile_FSHOP; -extern actor_process_profile_definition DUSK_CONST g_profile_MIRROR; -extern actor_process_profile_definition DUSK_CONST g_profile_MOVIE_PLAYER; -extern actor_process_profile_definition DUSK_CONST g_profile_MYNA; -extern actor_process_profile_definition DUSK_CONST g_profile_NI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ARU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ASH; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ASHB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_BANS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_BLUENS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_BOU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_BOU_S; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CD3; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CHAT; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CHIN; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKT; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_COACH; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_DF; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_DOC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_DOORBOY; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_DRSOL; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_DU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_FAIRY; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_FGUARD; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GND; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRD; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRM; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRMC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRR; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GRZ; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GUARD; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_GWOLF; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_HANJO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_HENNA0; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_HOZ; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_IMPAL; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_INKO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_INS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_JAGAR; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIHANA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIKYU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIMICH; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KDK; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KN; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KNJ; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KOLINB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_KYURY; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_LEN; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_LF; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_LUD; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_MIDP; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_MK; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_MOI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_MOIR; -extern actor_process_profile_definition DUSK_CONST g_profile_MYNA2; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_NE; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_P2; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_BESU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_MARO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_TARO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PASSER; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PASSER2; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_POST; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_POUYA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_PRAYER; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_RACA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_RAFREL; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SARU; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SEID; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIRA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SERA2; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIREI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SHAD; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SHAMAN; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SHOE; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SHOP0; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SMARO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLDIERa; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLDIERb; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_SQ; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_THE; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_THEB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TK; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TKC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TKJ2; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TKS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TOBY; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_TR; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_URI; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_WORM; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_WRESTLER; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMID; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMIS; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMIT; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YELIA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YKM; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_YKW; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZANB; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZANT; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELR; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELRO; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELDA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRA; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRC; -extern actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRZ; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5Key; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Turara; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TvCdlst; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ytaihou; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_AmiShutter; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ari; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_AUTOMATA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Avalanche; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_BALLOON; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BarDesk; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Batta; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BBox; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_BED; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Bemos; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Bhbridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BkLeaf; -extern actor_process_profile_definition DUSK_CONST g_profile_BkyRock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BmWindow; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BoomShutter; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Bombf; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_BOUMATO; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_BRG; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_BsGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_awaPlar; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CatDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_CB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ChainBlock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Cdoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Chandelier; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Chest; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Cho; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Cowdoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Crope; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVFENCE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVGATE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVHAHEN; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVLH_DW; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVLH_UP; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVSTEEL; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Crystal; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ChainWall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_DamCps; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Dan; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Digholl; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_DigSnow; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Elevator; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Drop; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_DUST; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_E_CREATE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_FallObj; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Fan; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Fchain; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_FireWood; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_FireWood2; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_FirePillar; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_FirePillar2; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag2; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag3; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_FOOD; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_FW; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_GADGET; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GanonWall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GanonWall2; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_GB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Geyser; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_glowSphere; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_GM; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GoGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GOMIKABE; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_GRA; -extern actor_process_profile_definition DUSK_CONST g_profile_GRA_WALL; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GraRock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GraveStone; -extern actor_process_profile_definition DUSK_CONST g_profile_GRDWATER; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_GrzRock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_H_Saku; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HBarrel; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HFtr; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MHasu; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Hata; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_HB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HBombkoya; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HeavySw; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Hfuta; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_HsTarget; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ice_l; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ice_s; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_IceBlock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_IceLeaf; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_IHASI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ikada; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_InoBone; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ITA; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ITAMATO; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kabuto; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kag; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KAGE; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KAGO; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kaisou; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kam; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kantera; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kat; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KazeNeko; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KBOX; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KEY; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KEYHOLE; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KiPot; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_KITA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KJgjs; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KKanban; -extern actor_process_profile_definition DUSK_CONST g_profile_KN_BULLET; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kshutter; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Kuw; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KWheel00; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KWheel01; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KznkArm; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Laundry; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_LndRope; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_LBOX; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_LP; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv1Cdl00; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv1Cdl01; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Candle; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Water; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Water2; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_LV3WATERB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3R10Saka; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterEff; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv4CandleDm; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv4Candle; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4EdShutter; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Gate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4HsTarget; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4PoGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4RailWall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4SlideWall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Bridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Chan; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4DigSand; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Floor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Gear; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_PRElvtr; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4PRwall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Sand; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5FBoard; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_IceWall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5SwIce; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ychndlr; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_YIblltray; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6ChgGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6FuriTrap; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6Lblock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SwGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SzGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6Tenbin; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6TogeRoll; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6TogeTrap; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6bemos; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6bemos2; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6EGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6ElevtA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SwTurn; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7BsGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7PropY; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7Bridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8KekkaiTrap; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8Lift; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8OptiLift; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8UdFloor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv9SwShutter; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MagLift; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MagLiftRot; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_MAKI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MasterSword; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Mato; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MHole; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_MIE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Mirror6Pole; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorChain; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorSand; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorScrew; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorTable; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_MSIMA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_MvStair; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_MYOGAN; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Nagaisu; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Nan; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_NDOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_NOUGU; -extern actor_process_profile_definition DUSK_CONST g_profile_OCTHASHI; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_OILTUBO; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Onsen; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ONSEN_FIRE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_OnsenTaru; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_PushDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_PDtile; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_PDwall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Picture; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Pillar; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_PLEAF; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_poCandle; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_poFire; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_poTbox; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Prop; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_PUMPKIN; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RCircle; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RfHole; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RiderGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RIVERROCK; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ROCK; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RotBridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RotTrap; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ROTEN; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_RotStair; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_RW; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Saidan; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Sakuita; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ItaRope; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannon; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannonCrs; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannonTen; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIDOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIZO; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIZOA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Shield; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SM_DOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SmallKey; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SmgDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Smoke; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SMTILE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SmWStone; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_SnowEff; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SnowSoup; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SO; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SpinLift; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SSDRINK; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SSITEM; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_StairBlock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Stone; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Stopper; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Stopper2; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SUISYA; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_SW; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallA; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallB; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallC; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwLight; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwChain; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwHang; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Sword; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush2; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwSpinner; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SwTurn; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SyRock; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_SZbridge; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TaFence; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Table; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TakaraDai; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_TATIGI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Ten; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TestCube; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Gake; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ALINK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NO_CHG_ROOM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ITEM; +DUSK_GAME_EXTERN camera_process_profile_definition DUSK_CONST g_profile_CAMERA; +DUSK_GAME_EXTERN camera_process_profile_definition DUSK_CONST g_profile_CAMERA2; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_ENVSE; +DUSK_GAME_EXTERN msg_process_profile_definition DUSK_CONST g_profile_GAMEOVER; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_KANKYO; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_KYEFF; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_KYEFF2; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_KY_THUNDER; +DUSK_GAME_EXTERN msg_process_profile_definition DUSK_CONST g_profile_MENUWINDOW; +DUSK_GAME_EXTERN msg_process_profile_definition DUSK_CONST g_profile_METER2; +DUSK_GAME_EXTERN msg_process_profile_definition DUSK_CONST g_profile_MSG_OBJECT; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP0; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP1; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP6; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP7; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP8; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP9; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP10; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP11; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP2; +DUSK_GAME_EXTERN overlap_process_profile_definition DUSK_CONST g_profile_OVERLAP3; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_LOGO_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_MENU_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_NAME_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_NAMEEX_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_PLAY_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_OPENING_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_ROOM_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_WARNING_SCENE; +DUSK_GAME_EXTERN scene_process_profile_definition DUSK_CONST g_profile_WARNING2_SCENE; +DUSK_GAME_EXTERN msg_process_profile_definition DUSK_CONST g_profile_TIMER; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_WMARK; +DUSK_GAME_EXTERN kankyo_process_profile_definition DUSK_CONST g_profile_WPILLAR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ANDSW; +DUSK_GAME_EXTERN actor_process_profile_definition2 DUSK_CONST g_profile_BG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BG_OBJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DMIDNA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DBDOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KNOB20; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DOOR20; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SPIRAL_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition2 DUSK_CONST g_profile_DSHUTTER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_EP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_HITOBJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG04; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG17; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_BEF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BurnBox; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Carry; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ITO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Movebox; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Timer; +DUSK_GAME_EXTERN actor_process_profile_definition2 DUSK_CONST g_profile_PATH_LINE; +DUSK_GAME_EXTERN actor_process_profile_definition2 DUSK_CONST g_profile_SCENE_EXIT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SET_BG_OBJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SWHIT0; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_ALLMATO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_CAMERA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_CHKPOINT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_EVENT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_EVT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_EVTAREA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_EVTMSG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_HOWL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_KMSG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_LANTERN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Mist; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_MSG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_PUSH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_TELOP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TBOX; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TBOX2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_VRBOX; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_VRBOX2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ARROW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BOOMERANG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_CROD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DEMO00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DISAPPEAR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MG_ROD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MIDNA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NBOMB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_LifeContainer; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Yousei; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SPINNER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SUSPEND; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Attp; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ALLDIE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ANDSW2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_CANOE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_CSTAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Demo_Item; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_L1BOSS_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_FM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_NEST; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_RD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ECONT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_FR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_GRASS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG05; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG10; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG11; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG14; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MG_FISH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_BESU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_FAIRY_SEIREI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_FISH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_HENNA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KAKASHI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KKRI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KOLIN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_MARO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TARO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TKJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BHASHI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BkDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BossWarp; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Cboard; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Digpl; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Eff; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_FMOBJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GpTaru; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HHASHI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KANBAN2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KBACKET; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KkrGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KLift00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_KtOnFire; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ladder; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv2Candle; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MagneArm; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MetalBox; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_NamePlate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_OnCloth; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RopeBridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwallShutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_STICK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_StoneMark; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpropeller; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush5; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Yobikusa; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SCENE_EXIT2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ShopItem; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SQ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SWC00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_CstaSw; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_AJnot; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_AttackItem; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Gstart; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Hinit; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Hjump; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Hstop; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv2PrChk; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Magne; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Mhint; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Mstop; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Spring; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Statue; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Ykgr; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_L7lowDr; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_L7ODR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_BH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_BQ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_DR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_DRE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_DS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_GG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_GM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_GND; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_GO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_GOS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_MGN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_OB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_OH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_OH2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_TN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_YO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_YOI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_ZANT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_ZANTM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_ZANTZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_B_ZANTS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BALLOON2D; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BULLET; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_COACH2D; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_COACH_FIRE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_COW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_CSTATUE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_DO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BOSS_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_L5BOSS_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_L1MBOSS_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_PushDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_AI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ARROW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BEE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BI_LEAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_BUG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_CR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_CR_EGG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DB_LEAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_DT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_FB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_FK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_FS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_FZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GOB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_GS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HB_LEAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_HZELDA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_IS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_KG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_KK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_KR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MK_BO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MM_MT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_MS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_NZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_OC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_OctBg; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_OT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_PH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_PM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_PO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_PZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_RB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_RDB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_RDY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_S1; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SM2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ST; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ST_LINE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_SW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TH_BALL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TK2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TK_BALL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_TT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_VT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_WAP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_WB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_WS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_WW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YD_LEAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YM_TAG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YMB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_YR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ZH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ZM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_E_ZS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_FORMATION_MNG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_GUARD_MNG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_HORSE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_HOZELDA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Izumi_Gate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KAGO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG01; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG02; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG03; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG06; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG07; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG08; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG09; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG12; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG13; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG15; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KYTAG16; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MANT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_FSHOP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MIRROR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MOVIE_PLAYER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MYNA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ARU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ASH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ASHB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_BANS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_BLUENS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_BOU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_BOU_S; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CD3; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CHAT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CHIN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_CLERKT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_COACH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_DF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_DOC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_DOORBOY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_DRSOL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_DU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_FAIRY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_FGUARD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GND; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRMC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GRZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GUARD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_GWOLF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_HANJO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_HENNA0; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_HOZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_IMPAL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_INKO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_INS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_JAGAR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIHANA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIKYU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KASIMICH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KDK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KNJ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KOLINB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_KYURY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_LEN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_LF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_LUD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_MIDP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_MK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_MOI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_MOIR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_MYNA2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_NE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_P2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_BESU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_MARO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PACHI_TARO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PASSER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PASSER2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_POST; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_POUYA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_PRAYER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_RACA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_RAFREL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SARU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SEID; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIRA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SERA2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SEIREI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SHAD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SHAMAN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SHOE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SHOP0; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SMARO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLDIERa; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SOLDIERb; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_SQ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_THE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_THEB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TKC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TKJ2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TKS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TOBY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_TR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_URI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_WORM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_WRESTLER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMID; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMIS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YAMIT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YELIA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YKM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_YKW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZANB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZANT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELRO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZELDA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_NPC_ZRZ; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5Key; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Turara; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TvCdlst; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ytaihou; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_AmiShutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ari; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_AUTOMATA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Avalanche; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_BALLOON; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BarDesk; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Batta; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BBox; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_BED; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Bemos; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Bhbridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BkLeaf; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_BkyRock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BmWindow; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BoomShutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Bombf; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_BOUMATO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_BRG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_BsGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_awaPlar; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CatDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_CB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ChainBlock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Cdoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Chandelier; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Chest; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Cho; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Cowdoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Crope; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVFENCE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVGATE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVHAHEN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVLH_DW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVLH_UP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_CRVSTEEL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Crystal; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ChainWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_DamCps; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Dan; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Digholl; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_DigSnow; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Elevator; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Drop; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_DUST; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_E_CREATE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_FallObj; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Fan; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Fchain; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_FireWood; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_FireWood2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_FirePillar; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_FirePillar2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Flag3; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_FOOD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_FW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_GADGET; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GanonWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GanonWall2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_GB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Geyser; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_glowSphere; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_GM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GoGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GOMIKABE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_GRA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_GRA_WALL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GraRock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GraveStone; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_GRDWATER; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_GrzRock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_H_Saku; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HBarrel; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HFtr; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MHasu; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Hata; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_HB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HBombkoya; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HeavySw; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Hfuta; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_HsTarget; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ice_l; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ice_s; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_IceBlock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_IceLeaf; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_IHASI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ikada; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_InoBone; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ITA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ITAMATO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kabuto; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kag; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KAGE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KAGO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kaisou; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kam; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kantera; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kat; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KazeNeko; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KBOX; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KEY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KEYHOLE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KiPot; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_KITA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KJgjs; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KKanban; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_KN_BULLET; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kshutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Kuw; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KWheel00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KWheel01; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KznkArm; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Laundry; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_LndRope; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_LBOX; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_LP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv1Cdl00; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv1Cdl01; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Candle; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Water; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Water2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_LV3WATERB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3R10Saka; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterEff; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv4CandleDm; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv4Candle; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4EdShutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Gate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4HsTarget; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4PoGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4RailWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4SlideWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Bridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Chan; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4DigSand; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Floor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Gear; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_PRElvtr; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4PRwall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv4Sand; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5FBoard; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_IceWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv5SwIce; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ychndlr; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_YIblltray; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6ChgGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6FuriTrap; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6Lblock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SwGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SzGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6Tenbin; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6TogeRoll; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6TogeTrap; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6bemos; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6bemos2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6EGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6ElevtA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv6SwTurn; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7BsGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7PropY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv7Bridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8KekkaiTrap; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8Lift; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8OptiLift; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv8UdFloor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv9SwShutter; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MagLift; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MagLiftRot; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_MAKI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MasterSword; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Mato; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MHole; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_MIE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Mirror6Pole; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorChain; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorSand; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorScrew; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MirrorTable; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_MSIMA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_MvStair; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_MYOGAN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Nagaisu; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Nan; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_NDOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_NOUGU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OCTHASHI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_OILTUBO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Onsen; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ONSEN_FIRE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_OnsenTaru; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_PushDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_PDtile; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_PDwall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Picture; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Pillar; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_PLEAF; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_poCandle; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_poFire; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_poTbox; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Prop; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_PUMPKIN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RCircle; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RfHole; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RiderGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RIVERROCK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ROCK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RotBridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RotTrap; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ROTEN; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_RotStair; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_RW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Saidan; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Sakuita; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ItaRope; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannon; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannonCrs; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SCannonTen; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIDOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIZO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SEKIZOA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Shield; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SM_DOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SmallKey; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SmgDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Smoke; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SMTILE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SmWStone; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_SnowEff; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SnowSoup; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SO; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SpinLift; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SSDRINK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SSITEM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_StairBlock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Stone; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Stopper; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Stopper2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SUISYA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_SW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallB; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwBallC; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwLight; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwChain; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwHang; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Sword; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Swpush2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwSpinner; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SwTurn; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SyRock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_SZbridge; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TaFence; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Table; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TakaraDai; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_TATIGI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Ten; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TestCube; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Gake; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_THASHI; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TimeFire; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_TKS; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TMoon; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ToaruMaki; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_TOBY; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TobyHouse; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TogeTrap; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Tombo; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Tornado; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Tornado2; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_TP; -extern actor_process_profile_definition DUSK_CONST g_profile_TREESH; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_TwGate; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_UDOOR; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_USAKU; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcGnd; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcanicBall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcanicBomb; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_KakarikoBrg; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_OrdinBrg; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WtGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterPillar; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterFall; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Wchain; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WdStick; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_WEB0; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_WEB1; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WellCover; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_WFLAG; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WindStone; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_Window; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodPendulum; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodStatue; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodenSword; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_YBAG; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_YSTONE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ZoraCloth; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ZDoor; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_zrTurara; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_zrTuraraRc; -extern actor_process_profile_definition DUSK_CONST g_profile_ZRA_MARK; -extern actor_process_profile_definition DUSK_CONST g_profile_OBJ_ZRAFREEZE; -extern actor_process_profile_definition DUSK_CONST g_profile_Obj_ZraRock; -extern actor_process_profile_definition DUSK_CONST g_profile_PASSER_MNG; -extern actor_process_profile_definition DUSK_CONST g_profile_PERU; -extern actor_process_profile_definition DUSK_CONST g_profile_PPolamp; -extern actor_process_profile_definition DUSK_CONST g_profile_SKIP2D; -extern actor_process_profile_definition DUSK_CONST g_profile_START_AND_GOAL; -extern actor_process_profile_definition DUSK_CONST g_profile_SwBall; -extern actor_process_profile_definition DUSK_CONST g_profile_SwLBall; -extern actor_process_profile_definition DUSK_CONST g_profile_SwTime; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv6Gate; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv7Gate; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv8Gate; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_TWGate; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Arena; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Assist; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_BTLITM; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_ChgRestart; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_CSW; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Escape; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_FWall; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_GRA; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_GUARD; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Instruction; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_KagoFall; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_LightBall; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_LV5SOUP; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv6CstaSw; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Mmsg; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Mwait; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_MYNA2; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_MNLIGHT; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_PATI; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_poFire; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_QS; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_RetRoom; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_RiverBack; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_RmbitSw; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Schedule; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_SetBall; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Restart; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_SHOPCAM; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_SHOPITM; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_SmkEmt; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Spinner; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Sppath; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_SSDRINK; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Stream; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_TheBHint; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_WaraHowl; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_WatchGe; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_WaterFall; -extern actor_process_profile_definition DUSK_CONST g_profile_Tag_Wljump; -extern actor_process_profile_definition DUSK_CONST g_profile_TAG_YAMI; -extern actor_process_profile_definition DUSK_CONST g_profile_TALK; -extern actor_process_profile_definition DUSK_CONST g_profile_TBOX_SW; -extern actor_process_profile_definition DUSK_CONST g_profile_TITLE; -extern actor_process_profile_definition DUSK_CONST g_profile_WarpBug; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_THASHI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TimeFire; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_TKS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TMoon; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ToaruMaki; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_TOBY; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TobyHouse; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TogeTrap; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Tombo; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Tornado; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Tornado2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_TP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TREESH; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_TwGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_UDOOR; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_USAKU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcGnd; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcanicBall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_VolcanicBomb; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_KakarikoBrg; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_OrdinBrg; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WtGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterPillar; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WaterFall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Wchain; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WdStick; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_WEB0; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_WEB1; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WellCover; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_WFLAG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WindStone; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_Window; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodPendulum; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodStatue; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_WoodenSword; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_YBAG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_YSTONE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ZoraCloth; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ZDoor; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_zrTurara; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_zrTuraraRc; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_ZRA_MARK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_OBJ_ZRAFREEZE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Obj_ZraRock; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_PASSER_MNG; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_PERU; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_PPolamp; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SKIP2D; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_START_AND_GOAL; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SwBall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SwLBall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_SwTime; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv6Gate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv7Gate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv8Gate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_TWGate; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Arena; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Assist; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_BTLITM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_ChgRestart; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_CSW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Escape; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_FWall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_GRA; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_GUARD; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Instruction; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_KagoFall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_LightBall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_LV5SOUP; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Lv6CstaSw; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Mmsg; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Mwait; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_MYNA2; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_MNLIGHT; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_PATI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_poFire; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_QS; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_RetRoom; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_RiverBack; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_RmbitSw; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Schedule; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_SetBall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Restart; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_SHOPCAM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_SHOPITM; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_SmkEmt; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Spinner; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Sppath; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_SSDRINK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Stream; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_TheBHint; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_WaraHowl; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_WatchGe; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_WaterFall; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_Tag_Wljump; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TAG_YAMI; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TALK; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TBOX_SW; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_TITLE; +DUSK_GAME_EXTERN actor_process_profile_definition DUSK_CONST g_profile_WarpBug; #endif -extern process_profile_definition DUSK_CONST* DUSK_CONST g_fpcPfLst_ProfileList[]; +DUSK_GAME_EXTERN process_profile_definition DUSK_CONST* DUSK_CONST g_fpcPfLst_ProfileList[]; #endif /* F_PC_PROFILE_LST_H_ */ diff --git a/include/global.h b/include/global.h index 5add912748..c559435fa5 100644 --- a/include/global.h +++ b/include/global.h @@ -83,11 +83,15 @@ extern void __dcbf(void*, int); extern void __dcbz(void*, int); extern void __sync(); extern int __abs(int); +#if defined(_MSVC_LANG) && !defined(__clang__) +#define __memcpy memcpy +#else #if defined(__has_builtin) && __has_builtin(__builtin_memcpy) #define __memcpy __builtin_memcpy #else #define __memcpy memcpy #endif +#endif #ifdef __cplusplus } #endif @@ -114,18 +118,22 @@ inline int __builtin_clz(unsigned int v) { #endif -// Data symbols exported from the main exe need dllimport on the mod side. -// DUSK_BUILDING_GAME is defined for the game build so the same headers work in both. +// Data symbols exported from the main exe need dllimport on the mod side. The game itself +// exports them through its generated .def, so the annotation is otherwise intentionally empty. #if defined(TARGET_PC) && defined(_WIN32) && !defined(DUSK_BUILDING_GAME) -#define DUSK_GAME_EXTERN extern __declspec(dllimport) #define DUSK_GAME_DATA __declspec(dllimport) -#elif defined(TARGET_PC) && defined(_WIN32) && defined(DUSK_BUILDING_GAME) -#define DUSK_GAME_EXTERN extern __declspec(dllexport) -#define DUSK_GAME_DATA __declspec(dllexport) #else -#define DUSK_GAME_EXTERN extern #define DUSK_GAME_DATA #endif +#define DUSK_GAME_EXTERN extern DUSK_GAME_DATA + +#if defined(_MSC_VER) +#define DUSK_NOINLINE __declspec(noinline) +#elif defined(__GNUC__) +#define DUSK_NOINLINE __attribute__((noinline)) +#else +#define DUSK_NOINLINE +#endif #define FAST_DIV(x, n) (x >> (n / 2)) @@ -260,4 +268,23 @@ using std::isnan; #define DUSK_CONST IF_DUSK(const) #define DUSK_CONSTEXPR IF_DUSK(constexpr) +#if TARGET_PC && defined(DUSK_BUILDING_GAME) +#include "dusk/mods/item.hpp" +#define DUSK_ITEM_CHECK(name, item_no, giver) \ + (item_no) = ::dusk::mods::item_check_commit(name, (item_no), giver).itemNo +#define DUSK_ITEM_CHECK_EXPR(name, item_no, giver) \ + (::dusk::mods::item_check_commit(name, (item_no), giver).itemNo) +#define DUSK_ITEM_CHECK_PREVIEW(name, item_no, giver) \ + (item_no) = ::dusk::mods::item_check(name, (item_no), giver) +#define DUSK_ITEM_CHECK_PREVIEW_EXPR(name, item_no, giver) \ + (::dusk::mods::item_check(name, (item_no), giver)) +#define DUSK_GIVE_TAG(name) IF_DUSK_ARG(::dusk::mods::item_give_tag(name)) +#else +#define DUSK_ITEM_CHECK(name, item_no, giver) +#define DUSK_ITEM_CHECK_EXPR(name, item_no, giver) (item_no) +#define DUSK_ITEM_CHECK_PREVIEW(name, item_no, giver) +#define DUSK_ITEM_CHECK_PREVIEW_EXPR(name, item_no, giver) (item_no) +#define DUSK_GIVE_TAG(name) +#endif + #endif diff --git a/include/helpers/README.md b/include/helpers/README.md new file mode 100644 index 0000000000..d14f1e1b36 --- /dev/null +++ b/include/helpers/README.md @@ -0,0 +1,12 @@ +# Public game helpers + +Headers in this directory provide port-specific types and utilities used by ordinary game +headers. Their corresponding implementations live in `src/helpers/`. + +These helpers **must not** depend on internal `src/dusk/` declarations in their public interface. +Unlike the internal `dusk::` namespace, they are exposed to mods that use the `game` feature +and therefore must remain ABI stable within `GameService` major versions. + +APIs _specifically_ for mod use do not belong here; instead they belong in mod services, +which are individually versioned, can provide backwards compatibility, and are designed to +keep track of per-mod runtime state. diff --git a/src/dusk/batch.hpp b/include/helpers/batch.hpp similarity index 90% rename from src/dusk/batch.hpp rename to include/helpers/batch.hpp index 2569f27761..0eaeb17a2c 100644 --- a/src/dusk/batch.hpp +++ b/include/helpers/batch.hpp @@ -2,7 +2,7 @@ #include -namespace dusk::batch { +namespace batch { struct LeafTemplate { static constexpr u32 kMaxVtx = 192; @@ -22,4 +22,4 @@ struct LeafTemplate { void decode_leaf_template(const u8* dl, u32 size, LeafTemplate& out); -} // namespace dusk +} // namespace batch diff --git a/include/helpers/bits.hpp b/include/helpers/bits.hpp new file mode 100644 index 0000000000..73442d337b --- /dev/null +++ b/include/helpers/bits.hpp @@ -0,0 +1,178 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace dusk { +namespace detail { + +template +struct uint_of_size; + +template <> +struct uint_of_size<1> { + using type = uint8_t; +}; + +template <> +struct uint_of_size<2> { + using type = uint16_t; +}; + +template <> +struct uint_of_size<4> { + using type = uint32_t; +}; + +template <> +struct uint_of_size<8> { + using type = uint64_t; +}; + +template +using uint_of_size_t = uint_of_size::type; + +template + requires(std::is_trivially_copyable_v) +T unaligned_load(const void* source) noexcept { + T value; + std::memcpy(&value, source, sizeof(value)); + return value; +} + +template + requires(std::is_trivially_copyable_v) +void unaligned_store(void* destination, T value) noexcept { + std::memcpy(destination, &value, sizeof(value)); +} + +} // namespace detail + +template + requires(std::is_unsigned_v) +constexpr T bswap(T value) noexcept { + if constexpr (sizeof(T) == 1) { + return value; + } else if constexpr (sizeof(T) == 2) { + return static_cast((value << 8) | (value >> 8)); + } else if constexpr (sizeof(T) == 4) { + return static_cast(((value & 0x000000ffU) << 24) | ((value & 0x0000ff00U) << 8) | + ((value & 0x00ff0000U) >> 8) | ((value & 0xff000000U) >> 24)); + } else { + static_assert(sizeof(T) == 8); + return static_cast( + ((value & 0x00000000000000ffULL) << 56) | ((value & 0x000000000000ff00ULL) << 40) | + ((value & 0x0000000000ff0000ULL) << 24) | ((value & 0x00000000ff000000ULL) << 8) | + ((value & 0x000000ff00000000ULL) >> 8) | ((value & 0x0000ff0000000000ULL) >> 24) | + ((value & 0x00ff000000000000ULL) >> 40) | ((value & 0xff00000000000000ULL) >> 56)); + } +} + +/// Reads an unaligned integral value in the specified byte order. +template + requires(std::is_integral_v && !std::is_same_v) +T read_bits(const void* source, std::endian endian = std::endian::big) noexcept { + using Bits = std::make_unsigned_t; + Bits value = detail::unaligned_load(source); + if constexpr (sizeof(Bits) > 1) { + if (endian != std::endian::native) { + value = bswap(value); + } + } + return std::bit_cast(value); +} + +template + requires(std::is_integral_v && !std::is_same_v) +constexpr T read_bits(const uint8_t* source, std::endian endian = std::endian::big) noexcept { + if (!std::is_constant_evaluated()) { + return read_bits(static_cast(source), endian); + } + using Bits = std::make_unsigned_t; + Bits value{}; + if (endian == std::endian::big) { + for (size_t i = 0; i < sizeof(Bits); ++i) { + value = static_cast((value << 8) | source[i]); + } + } else { + for (size_t i = 0; i < sizeof(Bits); ++i) { + value |= static_cast(source[i]) << (i * 8); + } + } + return std::bit_cast(value); +} + +/// Reads an unaligned floating-point value in the specified byte order. +template + requires( + std::is_floating_point_v && requires { typename detail::uint_of_size_t; }) +T read_bits(const void* source, std::endian endian = std::endian::big) noexcept { + using Bits = detail::uint_of_size_t; + return std::bit_cast(read_bits(source, endian)); +} + +template + requires( + std::is_floating_point_v && requires { typename detail::uint_of_size_t; }) +constexpr T read_bits(const uint8_t* source, std::endian endian = std::endian::big) noexcept { + using Bits = detail::uint_of_size_t; + return std::bit_cast(read_bits(source, endian)); +} + +/// Writes an unaligned integral value in the specified byte order. +template + requires(std::is_integral_v && !std::is_same_v) +void write_bits(void* destination, T value, std::endian endian = std::endian::big) noexcept { + using Bits = std::make_unsigned_t; + Bits bits = std::bit_cast(value); + if constexpr (sizeof(Bits) > 1) { + if (endian != std::endian::native) { + bits = bswap(bits); + } + } + detail::unaligned_store(destination, bits); +} + +template + requires(std::is_integral_v && !std::is_same_v) +constexpr void write_bits( + uint8_t* destination, T value, std::endian endian = std::endian::big) noexcept { + if (!std::is_constant_evaluated()) { + write_bits(static_cast(destination), value, endian); + return; + } + using Bits = std::make_unsigned_t; + const Bits bits = std::bit_cast(value); + if (endian == std::endian::big) { + for (size_t i = 0; i < sizeof(Bits); ++i) { + destination[sizeof(Bits) - i - 1] = static_cast(bits >> (i * 8)); + } + } else { + for (size_t i = 0; i < sizeof(Bits); ++i) { + destination[i] = static_cast(bits >> (i * 8)); + } + } +} + +/// Writes an unaligned floating-point value in the specified byte order. +template + requires( + std::is_floating_point_v && requires { typename detail::uint_of_size_t; }) +void write_bits(void* destination, T value, std::endian endian = std::endian::big) noexcept { + using Bits = detail::uint_of_size_t; + write_bits(destination, std::bit_cast(value), endian); +} + +template + requires( + std::is_floating_point_v && requires { typename detail::uint_of_size_t; }) +constexpr void write_bits( + uint8_t* destination, T value, std::endian endian = std::endian::big) noexcept { + using Bits = detail::uint_of_size_t; + write_bits(destination, std::bit_cast(value), endian); +} + +} // namespace dusk diff --git a/include/dusk/endian.h b/include/helpers/endian.h similarity index 98% rename from include/dusk/endian.h rename to include/helpers/endian.h index d16d0aa80c..689f9f0dab 100644 --- a/include/dusk/endian.h +++ b/include/helpers/endian.h @@ -1,5 +1,4 @@ -#ifndef DOLPHIN_ENDIAN_H -#define DOLPHIN_ENDIAN_H +#pragma once #include @@ -292,6 +291,3 @@ inline void be_swap(Mtx& val) { #define BE(T) T #define BE_HOST(T) (T) #endif - - -#endif // DOLPHIN_ENDIAN_H diff --git a/include/dusk/endian_gx.hpp b/include/helpers/endian_gx.hpp similarity index 100% rename from include/dusk/endian_gx.hpp rename to include/helpers/endian_gx.hpp diff --git a/include/dusk/endian_ssystem.h b/include/helpers/endian_ssystem.h similarity index 93% rename from include/dusk/endian_ssystem.h rename to include/helpers/endian_ssystem.h index fe9248ffa4..b383ef6e43 100644 --- a/include/dusk/endian_ssystem.h +++ b/include/helpers/endian_ssystem.h @@ -1,5 +1,4 @@ -#ifndef _DUSK_ENDIAN_SSYSTEM_H_ -#define _DUSK_ENDIAN_SSYSTEM_H_ +#pragma once #include "SSystem/SComponent/c_sxyz.h" #include "endian.h" @@ -61,5 +60,3 @@ struct BE { }; } }; - -#endif \ No newline at end of file diff --git a/include/dusk/gx_helper.h b/include/helpers/gx_helper.h similarity index 94% rename from include/dusk/gx_helper.h rename to include/helpers/gx_helper.h index 02a36fc6db..32cf340ed5 100644 --- a/include/dusk/gx_helper.h +++ b/include/helpers/gx_helper.h @@ -1,12 +1,17 @@ -#ifndef DUSK_GX_HELPER_H -#define DUSK_GX_HELPER_H +#pragma once #include #include #include -#include "profiling.hpp" +#if defined(DUSK_BUILDING_GAME) +#include +#else +#ifndef ZoneScopedN +#define ZoneScopedN(name) +#endif +#endif #if DUSK_GFX_DEBUG_GROUPS #define GX_DEBUG_GROUP(name, ...) \ @@ -79,5 +84,3 @@ struct GXScopedDebugGroup { }; #define GX_AND_TRACY_SCOPED(name) GXScopedDebugGroup scope(name); ZoneScopedN(name); - -#endif // DUSK_GX_HELPER_H diff --git a/include/dusk/math.h b/include/helpers/math.h similarity index 84% rename from include/dusk/math.h rename to include/helpers/math.h index 04f1087670..c1e966951a 100644 --- a/include/dusk/math.h +++ b/include/helpers/math.h @@ -1,5 +1,4 @@ -#ifndef _SRC_DUSK_MATH_H_ -#define _SRC_DUSK_MATH_H_ +#pragma once #include @@ -17,5 +16,3 @@ inline float i_tanf(float x) { return tan(x); } inline float i_acosf(float x) { return acos(x); } #include - -#endif // _SRC_DUSK_MATH_H_ diff --git a/include/dusk/offset_ptr.h b/include/helpers/offset_ptr.h similarity index 89% rename from include/dusk/offset_ptr.h rename to include/helpers/offset_ptr.h index 3a940804c2..924b840659 100644 --- a/include/dusk/offset_ptr.h +++ b/include/helpers/offset_ptr.h @@ -1,5 +1,4 @@ -#ifndef DUSK_OFFSET_PTR_H -#define DUSK_OFFSET_PTR_H +#pragma once #if TARGET_PC @@ -47,21 +46,17 @@ struct OffsetPtrT { } operator T*() const { - return (T*) value; - } + return (T*)value; } - template + template explicit operator TOther*() const { - return (TOther*) value; + return (TOther*)value; } }; - #define OFFSET_PTR(T) OffsetPtrT #define OFFSET_PTR_RAW OffsetPtr #else #define OFFSET_PTR(T) T* #define OFFSET_PTR_RAW u32 #endif - -#endif // DUSK_OFFSET_PTR_H diff --git a/include/dusk/string.hpp b/include/helpers/string.hpp similarity index 89% rename from include/dusk/string.hpp rename to include/helpers/string.hpp index af91ff8fe9..b7ba0ef3b7 100644 --- a/include/dusk/string.hpp +++ b/include/helpers/string.hpp @@ -1,8 +1,7 @@ -#ifndef DUSK_STRING_HPP -#define DUSK_STRING_HPP -#include +#pragma once -namespace dusk { +#include +#include struct TextSpan { char* buffer; @@ -44,7 +43,7 @@ private: }; #if TARGET_PC -#define TEXT_SPAN dusk::TextSpan +#define TEXT_SPAN TextSpan #else #define TEXT_SPAN char* #endif @@ -111,11 +110,11 @@ int SafeStringPrintf(char (&buffer)[BufSize], const char* format, ...) { } #if TARGET_PC -#define SAFE_STRCPY dusk::SafeStringCopy -#define SAFE_STRCAT dusk::SafeStringCat -#define SAFE_SPRINTF dusk::SafeStringPrintf -#define SAFE_STRCPY_BOUNDED dusk::SafeStringCopy -#define SAFE_STRCAT_BOUNDED dusk::SafeStringCat +#define SAFE_STRCPY SafeStringCopy +#define SAFE_STRCAT SafeStringCat +#define SAFE_SPRINTF SafeStringPrintf +#define SAFE_STRCPY_BOUNDED SafeStringCopy +#define SAFE_STRCAT_BOUNDED SafeStringCat #else #define SAFE_STRCPY strcpy #define SAFE_STRCAT strcat @@ -123,6 +122,3 @@ int SafeStringPrintf(char (&buffer)[BufSize], const char* format, ...) { #define SAFE_STRCPY_BOUNDED strcpy #define SAFE_STRCPY_BOUNDED strcat #endif -} - -#endif // DUSK_STRING_HPP diff --git a/include/m_Do/m_Do_MemCard.h b/include/m_Do/m_Do_MemCard.h index f369bf2f2f..84fc246e09 100644 --- a/include/m_Do/m_Do_MemCard.h +++ b/include/m_Do/m_Do_MemCard.h @@ -112,6 +112,11 @@ public: mSerialNo = serial_no; } +#ifdef TARGET_PC + void setFileName(const std::string& fileName); + const char* getFileName(); +#endif + /* 0x0000 */ u8 mData[SAVEFILE_SIZE]; /* 0x1FBC */ u8 mChannel; /* 0x1FBD */ u8 mCopyToPos; @@ -124,13 +129,18 @@ public: /* 0x1FEC */ s32 mNandState; /* 0x1FF0 */ u64 mSerialNo; /* 0x1FF8 */ u32 mDataVersion; +#ifdef TARGET_PC + bool mInitialized; + std::string mFileName; +#endif + }; // Size: 0x2000 STATIC_ASSERT(sizeof(mDoMemCd_Ctrl_c) == 8192); static int mDoMemCd_main(void*); -extern mDoMemCd_Ctrl_c g_mDoMemCd_control; +DUSK_GAME_EXTERN mDoMemCd_Ctrl_c g_mDoMemCd_control; inline bool mDoMemCd_isCardCommNone() { return g_mDoMemCd_control.isCardCommNone(); @@ -230,4 +240,14 @@ inline s32 mDoMemCd_checkNANDFile() { } #endif +#ifdef TARGET_PC +inline void mDoMemCd_SetFileName(const std::string& fileName) { + g_mDoMemCd_control.setFileName(fileName); +} + +inline const char* mDoMemCd_GetFileName() { + return g_mDoMemCd_control.getFileName(); +} +#endif + #endif /* M_DO_M_DO_MEMCARD_H */ diff --git a/include/m_Do/m_Do_Reset.h b/include/m_Do/m_Do_Reset.h index a426460ba9..85a986263a 100644 --- a/include/m_Do/m_Do_Reset.h +++ b/include/m_Do/m_Do_Reset.h @@ -54,9 +54,9 @@ public: static mDoRstData* getResetData() { return mResetData; } static void setResetData(mDoRstData* rstData) { mResetData = rstData; } - static mDoRstData* mResetData; + static DUSK_GAME_DATA mDoRstData* mResetData; }; -extern bool mDoDvdErr_initialized; +DUSK_GAME_EXTERN bool mDoDvdErr_initialized; #endif /* M_DO_M_DO_RESET_H */ diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index e1e15c1ef1..43d0b81766 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -4,8 +4,12 @@ #include "Z2AudioLib/Z2AudioMgr.h" #include "Z2AudioLib/Z2EnvSeMgr.h" #include "Z2AudioLib/Z2LinkMgr.h" +#if defined(DUSK_BUILDING_GAME) #include "dusk/audio.h" #include "dusk/settings.h" +#else +#define DUSK_AUDIO_SKIP(...) +#endif class mDoAud_zelAudio_c : public Z2AudioMgr { public: @@ -33,12 +37,12 @@ public: static void onBgmSet() { mBgmSet = true; } static void offBgmSet() { mBgmSet = false; } - static u8 mInitFlag; - static u8 mResetFlag; - static u8 mBgmSet; + static DUSK_GAME_DATA u8 mInitFlag; + static DUSK_GAME_DATA u8 mResetFlag; + static DUSK_GAME_DATA u8 mBgmSet; }; -extern JKRSolidHeap* g_mDoAud_audioHeap; +DUSK_GAME_EXTERN JKRSolidHeap* g_mDoAud_audioHeap; void mDoAud_Execute(); void mDoAud_resetProcess(); @@ -134,15 +138,7 @@ inline void mDoAud_seStart(u32 i_sfxID, const Vec* i_sePos, u32 param_2, s8 i_re } #if TARGET_PC -inline void mDoAud_seStartMenu(u32 i_sfxID) { - if (!mDoAud_zelAudio_c::isInitFlag()) { - return; - } - if (!dusk::getSettings().audio.menuSounds.getValue()) { - return; - } - mDoAud_seStart(i_sfxID, nullptr, 0, 0); -} +void mDoAud_seStartMenu(u32 i_sfxID); #endif inline void mDoAud_seStartLevel(u32 i_sfxID, const Vec* i_sePos, u32 param_2, s8 i_reverb) { diff --git a/include/m_Do/m_Do_controller_pad.h b/include/m_Do/m_Do_controller_pad.h index e187efd17d..f63c1c8d1c 100644 --- a/include/m_Do/m_Do_controller_pad.h +++ b/include/m_Do/m_Do_controller_pad.h @@ -3,7 +3,10 @@ #include "JSystem/JUtility/JUTGamePad.h" #include "SSystem/SComponent/c_API_controller_pad.h" + +#if defined(DUSK_BUILDING_GAME) #include "dusk/settings.h" +#endif // Controller Ports 1 - 4 enum { PAD_1, PAD_2, PAD_3, PAD_4 }; @@ -54,29 +57,21 @@ public: static f32 getStickValue(u32 pad) { return getCpadInfo(pad).mMainStickValue; } static s16 getStickAngle(u32 pad) { return getCpadInfo(pad).mMainStickAngle; } +#if TARGET_PC + static s16 getStickAngle3D(u32 pad); +#else static s16 getStickAngle3D(u32 pad) { - #if TARGET_PC - if (dusk::getSettings().game.enableMirrorMode) { - return -getCpadInfo(pad).mMainStickAngle; - } else { - return getCpadInfo(pad).mMainStickAngle; - } - #else return getCpadInfo(pad).mMainStickAngle; - #endif } +#endif +#if TARGET_PC + static f32 getSubStickX3D(u32 pad); +#else static f32 getSubStickX3D(u32 pad) { - #if TARGET_PC - if (dusk::getSettings().game.enableMirrorMode) { - return -getCpadInfo(pad).mCStickPosX; - } else { - return getCpadInfo(pad).mCStickPosX; - } - #else return getCpadInfo(pad).mCStickPosX; - #endif } +#endif static f32 getSubStickX(u32 pad) { return getCpadInfo(pad).mCStickPosX; } static f32 getSubStickY(u32 pad) { return getCpadInfo(pad).mCStickPosY; } @@ -93,9 +88,9 @@ public: static void stopMotorHard(u32 pad) { return m_gamePad[pad]->stopMotorHard(); } static void stopMotorWaveHard(u32 pad) { return m_gamePad[pad]->stopMotorWaveHard(); } - static JUTGamePad* m_gamePad[4]; - static interface_of_controller_pad m_cpadInfo[4]; - static interface_of_controller_pad m_debugCpadInfo[4]; + static DUSK_GAME_DATA JUTGamePad* m_gamePad[4]; + static DUSK_GAME_DATA interface_of_controller_pad m_cpadInfo[4]; + static DUSK_GAME_DATA interface_of_controller_pad m_debugCpadInfo[4]; }; inline void mDoCPd_ANALOG_CONV(u8 analog, f32& param_1) { diff --git a/include/m_Do/m_Do_dvd_thread.h b/include/m_Do/m_Do_dvd_thread.h index 8af8c520b5..dcb3f2fc65 100644 --- a/include/m_Do/m_Do_dvd_thread.h +++ b/include/m_Do/m_Do_dvd_thread.h @@ -130,21 +130,21 @@ private: }; // Size = 0x28 struct mDoDvdThdStack { - u8 stack[4096]; -} ATTRIBUTE_ALIGN(16); + ATTRIBUTE_ALIGN(16) u8 stack[4096]; +}; struct mDoDvdThd { static s32 main(void*); static void create(s32); static void suspend(); - static OSThread l_thread; - static mDoDvdThdStack l_threadStack; - static mDoDvdThd_param_c l_param; + static DUSK_GAME_DATA OSThread l_thread; + static DUSK_GAME_DATA mDoDvdThdStack l_threadStack; + static DUSK_GAME_DATA mDoDvdThd_param_c l_param; static u8 verbose; - static u8 DVDLogoMode; - static bool SyncWidthSound; + static DUSK_GAME_DATA u8 DVDLogoMode; + static DUSK_GAME_DATA bool SyncWidthSound; static u8 Report_DVDRead; }; diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index 77d046f0de..4c1ceeb997 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -19,9 +19,9 @@ class Z2Creature; struct cXy; namespace mDoExt { - extern u8 CurrentHeapAdjustVerbose; - extern u8 HeapAdjustVerbose; - extern u8 HeapAdjustQuiet; + DUSK_GAME_EXTERN u8 CurrentHeapAdjustVerbose; + DUSK_GAME_EXTERN u8 HeapAdjustVerbose; + DUSK_GAME_EXTERN u8 HeapAdjustQuiet; }; class mDoExt_baseAnm { @@ -542,10 +542,18 @@ public: virtual void setMaterial() = 0; virtual void draw() = 0; #if TARGET_PC - virtual void refreshGeometryForPresentationEye(const cXyz& eye) {} + virtual void captureInterpPoints() {} + virtual void refreshGeometryForPresentation() {} #endif /* 0x4 */ mDoExt_3DlineMat_c* field_0x4; + +#if TARGET_PC +protected: + u8 mInterpKind; + f32 mInterpWidth; + u16 mInterpTaper; +#endif }; class mDoExt_3DlineMat0_c : public mDoExt_3DlineMat_c { @@ -567,6 +575,10 @@ public: virtual int getMaterialID() { return 0; } virtual void setMaterial(); virtual void draw(); +#if TARGET_PC + void captureInterpPoints() override; + void refreshGeometryForPresentation() override; +#endif cXyz* getPos(int param_0) { return field_0x18[param_0].field_0x0; } f32* getSize(int param_0) { return field_0x18[param_0].field_0x4; } @@ -585,18 +597,14 @@ class dKy_tevstr_c; class mDoExt_3DlineMat1_c : public mDoExt_3DlineMat_c { public: int init(u16, u16, ResTIMG*, int); -#if TARGET_PC - void update(int, GXColor&, dKy_tevstr_c*, const cXyz* presentationEye = nullptr); - void update(int, f32, GXColor&, u16, dKy_tevstr_c*, const cXyz* presentationEye = nullptr); -#else void update(int, GXColor&, dKy_tevstr_c*); void update(int, f32, GXColor&, u16, dKy_tevstr_c*); -#endif int getMaterialID() { return 1; } void setMaterial(); void draw(); #if TARGET_PC - void refreshGeometryForPresentationEye(const cXyz& eye) override; + void captureInterpPoints() override; + void refreshGeometryForPresentation() override; #endif cXyz* getPos(int i_idx) { return mpLines[i_idx].field_0x0; } @@ -611,11 +619,6 @@ private: /* 0x34 */ u16 field_0x34; /* 0x36 */ u8 mIsDrawn; /* 0x38 */ mDoExt_3Dline_c* mpLines; -#if TARGET_PC - u8 mInterpLineKind; - f32 mInterpLineF; - u16 mInterpLineU16; -#endif }; class mDoExt_3DlineMat2_c : public mDoExt_3DlineMat1_c { @@ -840,7 +843,7 @@ void mDoExt_modelUpdateDL(J3DModel* i_model); J3DModel* mDoExt_J3DModel__create(J3DModelData* i_modelData, u32 i_modelFlag, u32 i_differedDlistFlag); -extern u32 aram_cache_size; +DUSK_GAME_EXTERN u32 aram_cache_size; u32 mDoExt_getAraCacheSize(); void mDoExt_setAraCacheSize(u32 size); @@ -889,10 +892,10 @@ int DummyCheckHeap_isVirgin(); void DummyCheckHeap_check(); -extern JKRExpHeap* zeldaHeap; -extern JKRExpHeap* gameHeap; -extern JKRExpHeap* archiveHeap; -extern JKRExpHeap* commandHeap; -extern DummyCheckHeap* dch; +DUSK_GAME_EXTERN JKRExpHeap* zeldaHeap; +DUSK_GAME_EXTERN JKRExpHeap* gameHeap; +DUSK_GAME_EXTERN JKRExpHeap* archiveHeap; +DUSK_GAME_EXTERN JKRExpHeap* commandHeap; +DUSK_GAME_EXTERN DummyCheckHeap* dch; #endif /* M_DO_M_DO_EXT_H */ diff --git a/include/m_Do/m_Do_graphic.h b/include/m_Do/m_Do_graphic.h index 5d29049520..dbda35d9c2 100644 --- a/include/m_Do/m_Do_graphic.h +++ b/include/m_Do/m_Do_graphic.h @@ -123,8 +123,8 @@ public: static void waitBlanking(int wait) { JFWDisplay::getManager()->waitBlanking(wait); } #if TARGET_PC - static f32 hudAspectScaleDown; - static f32 hudAspectScaleUp; + static DUSK_GAME_DATA f32 hudAspectScaleDown; + static DUSK_GAME_DATA f32 hudAspectScaleUp; static void updateSafeAreaBounds(); static f32 getSafeMinXF() { return m_safeMinXF; } static f32 getSafeMinYF() { return m_safeMinYF; } @@ -302,23 +302,23 @@ public: static void updateRenderSize(); #endif - static TGXTexObj mFrameBufferTexObj; - static TGXTexObj mZbufferTexObj; - static bloom_c m_bloom; - static Mtx mBlureMtx; - static GXColor mBackColor; - static GXColor mFadeColor; - static JUTFader* mFader; - static ResTIMG* mFrameBufferTimg; - static void* mFrameBufferTex; - static ResTIMG* mZbufferTimg; - static void* mZbufferTex; - static f32 mFadeRate; - static f32 mFadeSpeed; - static u8 mBlureFlag; - static u8 mBlureRate; - static u8 mFade; - static bool mAutoForcus; + static DUSK_GAME_DATA TGXTexObj mFrameBufferTexObj; + static DUSK_GAME_DATA TGXTexObj mZbufferTexObj; + static DUSK_GAME_DATA bloom_c m_bloom; + static DUSK_GAME_DATA Mtx mBlureMtx; + static DUSK_GAME_DATA GXColor mBackColor; + static DUSK_GAME_DATA GXColor mFadeColor; + static DUSK_GAME_DATA JUTFader* mFader; + static DUSK_GAME_DATA ResTIMG* mFrameBufferTimg; + static DUSK_GAME_DATA void* mFrameBufferTex; + static DUSK_GAME_DATA ResTIMG* mZbufferTimg; + static DUSK_GAME_DATA void* mZbufferTex; + static DUSK_GAME_DATA f32 mFadeRate; + static DUSK_GAME_DATA f32 mFadeSpeed; + static DUSK_GAME_DATA u8 mBlureFlag; + static DUSK_GAME_DATA u8 mBlureRate; + static DUSK_GAME_DATA u8 mFade; + static DUSK_GAME_DATA bool mAutoForcus; #if PLATFORM_SHIELD static JKRHeap* getHeap() { @@ -333,9 +333,9 @@ public: #endif #if PLATFORM_WII || PLATFORM_SHIELD || TARGET_PC - static ResTIMG* m_fullFrameBufferTimg; - static void* m_fullFrameBufferTex; - static TGXTexObj m_fullFrameBufferTexObj; + static DUSK_GAME_DATA ResTIMG* m_fullFrameBufferTimg; + static DUSK_GAME_DATA void* m_fullFrameBufferTex; + static DUSK_GAME_DATA TGXTexObj m_fullFrameBufferTexObj; #endif #if PLATFORM_WII || PLATFORM_SHIELD @@ -350,35 +350,35 @@ public: #endif #if WIDESCREEN_SUPPORT - static u8 mWide; - static u8 mWideZoom; + static DUSK_GAME_DATA u8 mWide; + static DUSK_GAME_DATA u8 mWideZoom; - static f32 m_aspect; - static f32 m_scale; - static f32 m_invScale; + static DUSK_GAME_DATA f32 m_aspect; + static DUSK_GAME_DATA f32 m_scale; + static DUSK_GAME_DATA f32 m_invScale; - static f32 m_minXF; - static f32 m_minYF; - static int m_minX; - static int m_minY; + static DUSK_GAME_DATA f32 m_minXF; + static DUSK_GAME_DATA f32 m_minYF; + static DUSK_GAME_DATA int m_minX; + static DUSK_GAME_DATA int m_minY; - static f32 m_maxXF; - static f32 m_maxYF; - static int m_maxX; - static int m_maxY; + static DUSK_GAME_DATA f32 m_maxXF; + static DUSK_GAME_DATA f32 m_maxYF; + static DUSK_GAME_DATA int m_maxX; + static DUSK_GAME_DATA int m_maxY; - static int m_width; - static int m_height; - static f32 m_heightF; - static f32 m_widthF; + static DUSK_GAME_DATA int m_width; + static DUSK_GAME_DATA int m_height; + static DUSK_GAME_DATA f32 m_heightF; + static DUSK_GAME_DATA f32 m_widthF; #if TARGET_PC - static f32 m_safeMinXF; - static f32 m_safeMinYF; - static f32 m_safeMaxXF; - static f32 m_safeMaxYF; - static f32 m_safeWidthF; - static f32 m_safeHeightF; + static DUSK_GAME_DATA f32 m_safeMinXF; + static DUSK_GAME_DATA f32 m_safeMinYF; + static DUSK_GAME_DATA f32 m_safeMaxXF; + static DUSK_GAME_DATA f32 m_safeMaxYF; + static DUSK_GAME_DATA f32 m_safeWidthF; + static DUSK_GAME_DATA f32 m_safeHeightF; #endif #endif }; diff --git a/include/m_Do/m_Do_lib.h b/include/m_Do/m_Do_lib.h index f194a4591b..9ceaa9c137 100644 --- a/include/m_Do/m_Do_lib.h +++ b/include/m_Do/m_Do_lib.h @@ -2,14 +2,11 @@ #define M_DO_M_DO_LIB_H #include "JSystem/J3DU/J3DUClipper.h" -#include #if TARGET_PC -#include "JSystem/JGeometry.h" +#include "helpers/gx_helper.h" #endif -#include "dusk/gx_helper.h" - typedef struct Vec Vec; struct ResTIMG; @@ -37,9 +34,9 @@ struct mDoLib_clipper { mClipper.calcViewFrustum(); } - static J3DUClipper mClipper; - static f32 mSystemFar; - static f32 mFovyRate; + static DUSK_GAME_DATA J3DUClipper mClipper; + static DUSK_GAME_DATA f32 mSystemFar; + static DUSK_GAME_DATA f32 mFovyRate; }; void mDoLib_project(Vec* src, Vec* dst); diff --git a/include/m_Do/m_Do_machine.h b/include/m_Do/m_Do_machine.h index eeea7e77ce..5469a29b5b 100644 --- a/include/m_Do/m_Do_machine.h +++ b/include/m_Do/m_Do_machine.h @@ -19,7 +19,7 @@ int mDoMch_Create(); void mDoMch_Destroy(); #endif -extern GXRenderModeObj g_ntscZeldaProg; +DUSK_GAME_EXTERN GXRenderModeObj g_ntscZeldaProg; class mDoMch_render_c { public: @@ -30,11 +30,11 @@ public: static GXRenderModeObj* getRenderModeObj() { return mRenderModeObj; } - static GXRenderModeObj* mRenderModeObj; + static DUSK_GAME_DATA GXRenderModeObj* mRenderModeObj; }; namespace mDoMch { - extern u8 mDebugFill; + DUSK_GAME_EXTERN u8 mDebugFill; extern u8 mDebugFillNotUse; extern u8 mDebugFillNew; extern u8 mDebugFillDelete; diff --git a/include/m_Do/m_Do_main.h b/include/m_Do/m_Do_main.h index 9bedc21a39..e3b8f1acf7 100644 --- a/include/m_Do/m_Do_main.h +++ b/include/m_Do/m_Do_main.h @@ -6,12 +6,12 @@ class JKRExpHeap; -extern OSThread mainThread; +DUSK_GAME_EXTERN OSThread mainThread; void version_check(); s32 LOAD_COPYDATE(void*); -extern OSThread mainThread; +DUSK_GAME_EXTERN OSThread mainThread; const int HeapCheckTableNum = 8; class HeapCheck { @@ -70,11 +70,11 @@ struct mDoMain { static u32 archiveHeapSize; static u32 gameHeapSize; - static char COPYDATE_STRING[18]; - static u32 memMargin; - static OSTime sPowerOnTime; - static OSTime sHungUpTime; - static s8 developmentMode; + static DUSK_GAME_DATA char COPYDATE_STRING[18]; + static DUSK_GAME_DATA u32 memMargin; + static DUSK_GAME_DATA OSTime sPowerOnTime; + static DUSK_GAME_DATA OSTime sHungUpTime; + static DUSK_GAME_DATA s8 developmentMode; }; #endif /* M_DO_M_DO_MAIN_H */ diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 23db8b6d94..fdf5b66fed 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -5,11 +5,14 @@ #include "SSystem/SComponent/c_xyz.h" #include +#if TARGET_PC +#include "helpers/endian.h" + #include "JSystem/JMath/JMath.h" -#include "dusk/endian.h" +#endif extern u8 g_printCurrentHeapDebug; -extern u8 g_printOtherHeapDebug; +DUSK_GAME_EXTERN u8 g_printOtherHeapDebug; void mDoMtx_XYZrotS(Mtx, s16, s16, s16); void mDoMtx_XYZrotM(Mtx, s16, s16, s16); @@ -373,13 +376,13 @@ public: PSMTXIdentity(now); } - static Mtx now; - static Mtx buffer[16]; - static Mtx* next; - static Mtx* end; + static DUSK_GAME_DATA Mtx now; + static DUSK_GAME_DATA Mtx buffer[16]; + static DUSK_GAME_DATA Mtx* next; + static DUSK_GAME_DATA Mtx* end; }; -extern Mtx g_mDoMtx_identity; +DUSK_GAME_EXTERN Mtx g_mDoMtx_identity; inline MtxP mDoMtx_getIdentity() { return g_mDoMtx_identity; diff --git a/include/m_Do/m_Do_printf.h b/include/m_Do/m_Do_printf.h index 527be3d58a..dc30b1c720 100644 --- a/include/m_Do/m_Do_printf.h +++ b/include/m_Do/m_Do_printf.h @@ -2,7 +2,6 @@ #define M_DO_M_DO_PRINTF_H #include -#include "dusk/endian.h" void my_PutString(const char*); void mDoPrintf_vprintf_Interrupt(char const*, va_list); diff --git a/include/mods/api.h b/include/mods/api.h deleted file mode 100644 index 85e2f76545..0000000000 --- a/include/mods/api.h +++ /dev/null @@ -1,152 +0,0 @@ -#pragma once - -#ifdef __cplusplus -#include -#include -extern "C" { -#else -#include -#include -#include -#include -#endif - -#if defined(_WIN32) -#define MOD_EXPORT __declspec(dllexport) -#else -#define MOD_EXPORT __attribute__((visibility("default"))) -#endif - -#ifdef __cplusplus -#define MOD_EXTERN_C extern "C" -#else -#define MOD_EXTERN_C -#endif - -#define MOD_ABI_VERSION 5u -#define MOD_ERROR_MESSAGE_SIZE 512u - -typedef struct ModContext ModContext; - -typedef enum ModResult { - MOD_OK = 0, - MOD_ERROR = 1, - MOD_UNAVAILABLE = 2, - MOD_UNSUPPORTED = 3, - MOD_CONFLICT = 4, - MOD_INVALID_ARGUMENT = 5, -} ModResult; - -static_assert(sizeof(ModResult) == 4, "mod SDK enums must be int-sized; do not build mods with -fshort-enums"); - -typedef struct ModError { - uint32_t struct_size; - ModResult code; - char message[MOD_ERROR_MESSAGE_SIZE]; -} ModError; - -#define MOD_ERROR_INIT {sizeof(ModError), MOD_OK, {0}} - -/* - * Opaque per-mod context, populated by the host before mod_initialize is called. - * Pass it as the first argument to every service call; it identifies the calling - * mod for attribution (logging, resource lookup, hook ownership, etc.). - */ -MOD_EXPORT extern ModContext* mod_ctx; - -/* - * Service versioning contract: - * - * A service is a struct of function pointers, beginning with a ServiceHeader. - * Compatibility is tracked with a major/minor version pair: - * - * - A major version bump is a breaking change. Different majors are distinct - * services; the registry never matches an import against a different major. - * - A minor version bump may only append fields to the end of the struct. - * Existing fields must keep their offsets and semantics. - * - * Providers: exporting minor N means every function pointer introduced at or - * below N is populated (non-NULL). struct_size reflects the compiled struct. - * - * Importers: importing with min_minor_version N guarantees (enforced at load - * time) that the resolved service is at least minor N, so any field introduced - * at or below N may be used unconditionally, with no availability checks. - * Fields newer than the declared min_minor_version must be gated behind - * SERVICE_HAS plus a NULL check on the pointer itself. - * - * Load ordering: a manifest import of another mod's service (required or - * optional) guarantees that the provider's mod_initialize completed before the - * importer's runs, and deferred services published during the provider's - * initialization resolve into import slots just like static exports. If a - * provider fails to load, mods that required its services fail in turn. Mods - * whose required imports form a cycle all fail to load; a cycle involving an - * optional import is broken by dropping the ordering guarantee (not the - * resolution) of that optional import. Dynamic lookups via - * HostService::get_service carry no ordering guarantee: they see whatever has - * been published at call time. - */ -typedef struct ServiceHeader { - uint32_t struct_size; - uint16_t major_version; - uint16_t minor_version; -} ServiceHeader; - -#define SERVICE_HEADER(service_type, major, minor) {sizeof(service_type), (major), (minor)} - -#define SERVICE_HAS(service, service_type, field) \ - ((service) != NULL && \ - (service)->header.struct_size >= \ - (uint32_t)(offsetof(service_type, field) + sizeof(((service_type*)0)->field))) - -typedef enum ServiceImportFlags { - SERVICE_IMPORT_REQUIRED = 0u, - SERVICE_IMPORT_OPTIONAL = 1u << 0u, -} ServiceImportFlags; - -typedef enum ServiceExportFlags { - SERVICE_EXPORT_STATIC = 0u, - SERVICE_EXPORT_DEFERRED = 1u << 0u, -} ServiceExportFlags; - -typedef struct ServiceImport { - uint32_t struct_size; - const char* service_id; - uint16_t major_version; - uint16_t min_minor_version; - uint32_t flags; - void* slot; -} ServiceImport; - -typedef struct ServiceExport { - uint32_t struct_size; - const char* service_id; - uint16_t major_version; - uint16_t minor_version; - uint32_t flags; - const void* service; -} ServiceExport; - -typedef struct ModManifest { - uint32_t struct_size; - uint32_t abi_version; - const ServiceImport* imports; - size_t import_count; - const ServiceExport* exports; - size_t export_count; -} ModManifest; - -typedef const ModManifest* (*ModGetManifestFn)(void); - -typedef ModResult (*ModInitializeFn)(ModError* out_error); -typedef ModResult (*ModUpdateFn)(ModError* out_error); -typedef ModResult (*ModShutdownFn)(ModError* out_error); - -MOD_EXPORT const ModManifest* mod_get_manifest(void); - -MOD_EXPORT ModResult mod_initialize(ModError* out_error); -MOD_EXPORT ModResult mod_update(ModError* out_error); -MOD_EXPORT ModResult mod_shutdown(ModError* out_error); - -#ifdef __cplusplus -} -#endif diff --git a/include/mods/hook.hpp b/include/mods/hook.hpp deleted file mode 100644 index c58bd719c9..0000000000 --- a/include/mods/hook.hpp +++ /dev/null @@ -1,464 +0,0 @@ -#pragma once - -#include "mods/svc/hook.h" - -#include -#include -#include -#include -#include -#include - -namespace dusk::mods { - -template -T arg(void* argsRaw, int n) noexcept { - void** args = static_cast(argsRaw); - return *static_cast > >(args[n]); -} - -template -std::remove_reference_t& arg_ref(void* argsRaw, int n) noexcept { - void** args = static_cast(argsRaw); - return *static_cast > >(args[n]); -} - -template -void* mfp_addr(F fn) noexcept { - void* p = nullptr; - static_assert(sizeof(fn) >= sizeof(void*), "unexpected function pointer size"); - std::memcpy(&p, &fn, sizeof(void*)); - return p; -} - -/* A string usable as a template argument: carries the hook target's symbol name and - * makes each NamedHook instantiation's static state unique. */ -template -struct FixedString { - char chars[N]{}; - constexpr FixedString(const char (&s)[N]) noexcept { - for (size_t i = 0; i < N; ++i) { - chars[i] = s[i]; - } - } -}; - -namespace detail { - -template -constexpr std::string_view class_name() { -#if defined(__clang__) || defined(__GNUC__) - // "... class_name() [T = daAlink_c]" / "... [with T = daAlink_c; ...]" - constexpr std::string_view fn = __PRETTY_FUNCTION__; - constexpr size_t start = fn.find("T = ") + 4; - return fn.substr(start, fn.find_first_of(";]", start) - start); -#elif defined(_MSC_VER) - // "... class_name(void)" - constexpr std::string_view fn = __FUNCSIG__; - constexpr size_t start = fn.find("class_name<") + 11; - constexpr std::string_view name = fn.substr(start, fn.rfind(">(") - start); - if constexpr (name.starts_with("class ")) { - return name.substr(6); - } else if constexpr (name.starts_with("struct ")) { - return name.substr(7); - } else { - return name; - } -#else -#error "unsupported compiler" -#endif -} - -/* The manifest name of C's vtable. Only unscoped, non-template class names are - * supported (an empty result fails resolution and the install reports it). */ -template -constexpr auto vtable_symbol() { - constexpr std::string_view name = class_name(); - constexpr bool simple = name.find_first_of(":<> ") == std::string_view::npos; - // "_ZTV" + decimal length + name / "??_7" + name + "@@6B@", NUL-terminated - std::array out{}; - if constexpr (!simple) { - return out; - } - size_t n = 0; -#if defined(_WIN32) - for (char c : {'?', '?', '_', '7'}) { - out[n++] = c; - } - for (char c : name) { - out[n++] = c; - } - for (char c : {'@', '@', '6', 'B', '@'}) { - out[n++] = c; - } -#else - for (char c : {'_', 'Z', 'T', 'V'}) { - out[n++] = c; - } - size_t len = name.size(); - char digits[8]{}; - size_t d = 0; - while (len != 0) { - digits[d++] = static_cast('0' + len % 10); - len /= 10; - } - while (d != 0) { - out[n++] = digits[--d]; - } - for (char c : name) { - out[n++] = c; - } -#endif - return out; -} - -#if defined(_WIN32) -/* Follow jump stubs, then match the MSVC vcall thunk a virtual mfp points at. - * Returns the vtable slot's byte offset, or npos when fn is not a vcall thunk. */ -inline size_t vcall_slot_offset(const void*& fn) noexcept { - constexpr size_t npos = static_cast(-1); -#if defined(_M_X64) || defined(__x86_64__) - const auto* p = static_cast(fn); - for (int i = 0; i < 8 && p[0] == 0xE9; ++i) { // incremental-link stubs - int32_t rel; - std::memcpy(&rel, p + 1, 4); - p += 5 + rel; - } - fn = p; - // The vptr load. Unoptimized clang-cl thunks spill/reload rcx first - // (push rax; mov [rsp], rcx; mov rcx, [rsp]), so scan a short window. - const uint8_t* q = nullptr; - for (int i = 0; i <= 12; ++i) { - if (p[i] == 0x48 && p[i + 1] == 0x8B && p[i + 2] == 0x01) { // mov rax, [rcx] - q = p + i + 3; - break; - } - } - if (q == nullptr) { - return npos; - } - if (q[0] == 0xFF && q[1] == 0x20) { // jmp [rax] (MSVC) - return 0; - } - if (q[0] == 0xFF && q[1] == 0x60) { // jmp [rax + imm8] - return static_cast(q[2]); - } - if (q[0] == 0xFF && q[1] == 0xA0) { // jmp [rax + imm32] - int32_t off; - std::memcpy(&off, q + 2, 4); - return off; - } - // clang-cl: mov rax, [rax + off]; (pop r10;) jmp rax. Requiring the jmp rax - // distinguishes the thunk from an ordinary getter that begins the same way. - if (q[0] == 0x48 && q[1] == 0x8B && (q[2] == 0x00 || q[2] == 0x40 || q[2] == 0x80)) { - size_t off = 0; - const uint8_t* r = q + 3; - if (q[2] == 0x40) { - off = static_cast(q[3]); - r = q + 4; - } else if (q[2] == 0x80) { - int32_t off32; - std::memcpy(&off32, q + 3, 4); - off = off32; - r = q + 7; - } - for (int i = 0; i <= 8; ++i) { - if (r[i] == 0xFF && r[i + 1] == 0xE0) { // jmp rax (48 REX optional) - return off; - } - } - } - return npos; -#elif defined(_M_ARM64) || defined(__aarch64__) - const auto* p = static_cast(fn); - uint32_t insn[3]; - for (int i = 0; i < 8; ++i) { // incremental-link `b` stubs - std::memcpy(insn, p, 4); - if ((insn[0] & 0xFC000000u) != 0x14000000u) { - break; - } - const auto imm26 = static_cast(insn[0] << 6) >> 6; - p += static_cast(imm26) * 4; - } - fn = p; - std::memcpy(insn, p, 12); - // ldr Xt, [x0]; ldr Xs, [Xt, #imm12*8]; br Xs - if ((insn[0] & 0xFFFFFFE0u) != 0xF9400000u) { - return npos; - } - const uint32_t t = insn[0] & 0x1Fu; - if ((insn[1] & 0xFFC003E0u) != (0xF9400000u | (t << 5))) { - return npos; - } - const uint32_t s = insn[1] & 0x1Fu; - if (insn[2] != (0xD61F0000u | (s << 5))) { - return npos; - } - return ((insn[1] >> 10) & 0xFFFu) * 8; -#else - (void)fn; - return npos; -#endif -} -#endif - -/* Code address of the member function a mfp designates. Virtual mfps don't carry - * one; recover it from the class's vtable (resolved from the symbol manifest), so - * Hook works uniformly on virtual and non-virtual members. */ -template -ModResult member_target(const HookService* hooks, F mfp, void** out) { - *out = nullptr; - uintptr_t words[sizeof(F) > sizeof(uintptr_t) ? 2 : 1] = {}; - std::memcpy(words, &mfp, sizeof(words) < sizeof(F) ? sizeof(words) : sizeof(F)); - -#if defined(_WIN32) - const void* fn = reinterpret_cast(words[0]); - const size_t slot = vcall_slot_offset(fn); - if (slot == static_cast(-1)) { // not a vcall thunk: direct address - *out = const_cast(fn); - return MOD_OK; - } - void* vtable = nullptr; - const ModResult resolved = hooks->resolve(mod_ctx, vtable_symbol().data(), &vtable, nullptr); - if (resolved != MOD_OK) { - return resolved; - } - // ??_7 points at the first slot. - *out = *reinterpret_cast(static_cast(vtable) + slot); -#else -#if defined(__aarch64__) || defined(__arm__) - // AAPCS C++ ABI: the virtual flag is bit 0 of the adjustment word (function - // addresses can't spare their low bit), and ptr holds the slot offset directly. - const bool isVirtual = (words[1] & 1) != 0; - const uintptr_t thisAdjust = words[1] >> 1; - const uintptr_t slotOffset = words[0]; -#else - // Itanium C++ ABI: virtual mfps set bit 0 of ptr; the slot offset is ptr - 1. - const bool isVirtual = (words[0] & 1) != 0; - const uintptr_t thisAdjust = words[1]; - const uintptr_t slotOffset = words[0] - 1; -#endif - if (!isVirtual) { // non-virtual: the address itself - *out = reinterpret_cast(words[0]); - return MOD_OK; - } - if (thisAdjust != 0) { - // this-adjusting mfp (member of a secondary base): the slot offset is - // relative to a vtable we can't locate. Hook the overrider by name instead. - return MOD_UNSUPPORTED; - } - void* vtable = nullptr; - const ModResult resolved = hooks->resolve(mod_ctx, vtable_symbol().data(), &vtable, nullptr); - if (resolved != MOD_OK) { - return resolved; - } - // _ZTV points at the offset-to-top slot; the address point mfps index from is - // two pointers in (past offset-to-top and the typeinfo pointer). - *out = *reinterpret_cast(static_cast(vtable) + 2 * sizeof(void*) + slotOffset); -#endif - return *out != nullptr ? MOD_OK : MOD_UNAVAILABLE; -} - -} // namespace detail - -/* Trampoline generator + per-target state shared by Hook and NamedHook. Tag makes - * each hooked target's statics distinct; the target address is filled in at install. */ -template -struct HookImpl { - static inline R (*g_orig)(A...) = nullptr; - static inline const HookService* hooks = nullptr; - static inline void* target = nullptr; - - static bool dispatch_pre(void* args, void* retval) { - if (hooks == nullptr) { - return false; - } - - int skipOriginal = 0; - const ModResult result = hooks->dispatch_pre(mod_ctx, target, args, retval, &skipOriginal); - return result == MOD_OK && skipOriginal != 0; - } - - static void dispatch_post(void* args, void* retval) { - if (hooks != nullptr) { - hooks->dispatch_post(mod_ctx, target, args, retval); - } - } - - static R trampoline(A... args) { - if constexpr (sizeof...(A) == 0) { - if constexpr (std::is_void_v) { - const bool skipOriginal = dispatch_pre(nullptr, nullptr); - if (!skipOriginal) { - g_orig(args...); - } - dispatch_post(nullptr, nullptr); - } else { - R result{}; - const bool skipOriginal = - dispatch_pre(nullptr, static_cast(std::addressof(result))); - if (!skipOriginal) { - result = g_orig(args...); - } - dispatch_post(nullptr, static_cast(std::addressof(result))); - return result; - } - } else { - void* ptrs[] = {static_cast(std::addressof(args))...}; - if constexpr (std::is_void_v) { - const bool skipOriginal = dispatch_pre(static_cast(ptrs), nullptr); - if (!skipOriginal) { - g_orig(args...); - } - dispatch_post(static_cast(ptrs), nullptr); - } else { - R result{}; - const bool skipOriginal = dispatch_pre( - static_cast(ptrs), static_cast(std::addressof(result))); - if (!skipOriginal) { - result = g_orig(args...); - } - dispatch_post(static_cast(ptrs), static_cast(std::addressof(result))); - return result; - } - } - } -}; - -namespace detail { -template -using TargetTag = std::integral_constant; -template -struct NameTag {}; -} // namespace detail - -/* - * Typed hook on a function named at compile time (&daAlink_c::execute, &free_fn). - * Member functions may be virtual: the install decodes the member function pointer and hooks the - * class's own overrider. - */ -template -struct Hook; - -template -struct Hook : HookImpl, R, C*, A...> { - static ModResult resolve_target(const HookService* hooks, void** out) { - return detail::member_target(hooks, Target, out); - } -}; - -template -struct Hook : HookImpl, R, const C*, A...> { - static ModResult resolve_target(const HookService* hooks, void** out) { - return detail::member_target(hooks, Target, out); - } -}; - -template -struct Hook : HookImpl, R, A...> { - static ModResult resolve_target(const HookService*, void** out) { - *out = mfp_addr(Target); - return MOD_OK; - } -}; - -/* - * Typed hook on a function by its symbol name, for targets you can't name in C++: file-local - * statics, private members, or symbols without a header. The signature is written free-style with - * the receiver first and is *not* compiler-checked. - * - * using HookshotHit = dusk::mods::NamedHook< - * "daAlink_hookshotAtHitCallBack", - * void(fopAc_ac_c*, dCcD_GObjInf*, fopAc_ac_c*, dCcD_GObjInf*)>; - * dusk::mods::hook_add_pre(svc_hook, on_hookshot_hit); - */ -template -struct NamedHook; - -template -struct NamedHook : HookImpl, R, A...> { - static ModResult resolve_target(const HookService* hooks, void** out) { - HookSymbolFlags flags{}; - const ModResult resolved = hooks->resolve(mod_ctx, Name.chars, out, &flags); - if (resolved == MOD_OK && (flags & HOOK_SYMBOL_CODE) == 0) { - *out = nullptr; - return MOD_INVALID_ARGUMENT; - } - return resolved; - } -}; - -template -ModResult hook_install(const HookService* hooks) { - if (hooks == nullptr) { - return MOD_UNAVAILABLE; - } - - Entry::hooks = hooks; - if (Entry::target == nullptr) { - const ModResult resolved = Entry::resolve_target(hooks, &Entry::target); - if (resolved != MOD_OK) { - return resolved; - } - } - return hooks->install(mod_ctx, Entry::target, reinterpret_cast(Entry::trampoline), - reinterpret_cast(&Entry::g_orig)); -} - -template -ModResult hook_install(const HookService* hooks) { - return hook_install >(hooks); -} - -template -ModResult hook_add_pre( - const HookService* hooks, HookPreFn callback, const HookOptions* options = nullptr) { - const ModResult installed = hook_install(hooks); - if (installed != MOD_OK) { - return installed; - } - - return hooks->add_pre(mod_ctx, Entry::target, callback, options); -} - -template -ModResult hook_add_pre( - const HookService* hooks, HookPreFn callback, const HookOptions* options = nullptr) { - return hook_add_pre >(hooks, callback, options); -} - -template -ModResult hook_add_post( - const HookService* hooks, HookPostFn callback, const HookOptions* options = nullptr) { - const ModResult installed = hook_install(hooks); - if (installed != MOD_OK) { - return installed; - } - - return hooks->add_post(mod_ctx, Entry::target, callback, options); -} - -template -ModResult hook_add_post( - const HookService* hooks, HookPostFn callback, const HookOptions* options = nullptr) { - return hook_add_post >(hooks, callback, options); -} - -template -ModResult hook_replace( - const HookService* hooks, HookReplaceFn callback, const HookOptions* options = nullptr) { - const ModResult installed = hook_install(hooks); - if (installed != MOD_OK) { - return installed; - } - - return hooks->replace(mod_ctx, Entry::target, callback, options); -} - -template -ModResult hook_replace( - const HookService* hooks, HookReplaceFn callback, const HookOptions* options = nullptr) { - return hook_replace >(hooks, callback, options); -} - -} // namespace dusk::mods diff --git a/include/mods/service.hpp b/include/mods/service.hpp deleted file mode 100644 index d79b53f24d..0000000000 --- a/include/mods/service.hpp +++ /dev/null @@ -1,138 +0,0 @@ -#pragma once - -#include "mods/api.h" - -#include -#include -#include -#include - -namespace dusk::mods { - -template -struct ServiceTraits; - -namespace detail { - -inline std::vector& imports() { - static std::vector entries; - return entries; -} - -inline std::vector& exports() { - static std::vector entries; - return entries; -} - -inline int register_import(ServiceImport entry) { - imports().push_back(entry); - return 0; -} - -inline int register_export(ServiceExport entry) { - exports().push_back(entry); - return 0; -} - -inline const ModManifest* manifest() { - static ModManifest manifest{ - sizeof(ModManifest), - MOD_ABI_VERSION, - nullptr, - 0, - nullptr, - 0, - }; - - auto& importEntries = imports(); - auto& exportEntries = exports(); - manifest.imports = importEntries.data(); - manifest.import_count = importEntries.size(); - manifest.exports = exportEntries.data(); - manifest.export_count = exportEntries.size(); - return &manifest; -} - -} // namespace detail - -inline ModResult set_error(ModError* outError, ModResult code, const char* message) { - if (outError != nullptr && outError->struct_size >= sizeof(ModError)) { - outError->code = code; - outError->message[0] = '\0'; - if (message != nullptr) { - std::snprintf(outError->message, sizeof(outError->message), "%s", message); - } - } - return code; -} - -} // namespace dusk::mods - -#define DEFINE_MOD() \ - extern "C" { \ - MOD_EXPORT ModContext* mod_ctx = nullptr; \ - MOD_EXPORT const ModManifest* mod_get_manifest(void) { \ - return ::dusk::mods::detail::manifest(); \ - } \ - } - -// Declares `static const service_type* variable`, filled in by the host before mod_initialize. -// Required imports are guaranteed non-null (the mod fails to load otherwise); optional imports -// must be checked against nullptr before use. -#define IMPORT_SERVICE_EX( \ - service_type, variable, service_id_value, major_value, min_minor_value, flags_value) \ - static const service_type* variable = nullptr; \ - [[maybe_unused]] static const int mod_import_registration_##variable = \ - ::dusk::mods::detail::register_import(ServiceImport{ \ - sizeof(ServiceImport), \ - (service_id_value), \ - static_cast(major_value), \ - static_cast(min_minor_value), \ - static_cast(flags_value), \ - &(variable), \ - }) - -#define IMPORT_SERVICE_VERSION(service_type, variable, min_minor_value) \ - IMPORT_SERVICE_EX(service_type, variable, ::dusk::mods::ServiceTraits::id, \ - ::dusk::mods::ServiceTraits::major_version, min_minor_value, \ - SERVICE_IMPORT_REQUIRED) - -#define IMPORT_SERVICE(service_type, variable) IMPORT_SERVICE_VERSION(service_type, variable, 0) - -#define IMPORT_OPTIONAL_SERVICE_VERSION(service_type, variable, min_minor_value) \ - IMPORT_SERVICE_EX(service_type, variable, ::dusk::mods::ServiceTraits::id, \ - ::dusk::mods::ServiceTraits::major_version, min_minor_value, \ - SERVICE_IMPORT_OPTIONAL) - -#define IMPORT_OPTIONAL_SERVICE(service_type, variable) \ - IMPORT_OPTIONAL_SERVICE_VERSION(service_type, variable, 0) - -#define EXPORT_SERVICE_AS(instance, service_id_value) \ - namespace { \ - const int mod_export_registration_##instance = \ - ::dusk::mods::detail::register_export(ServiceExport{ \ - sizeof(ServiceExport), \ - (service_id_value), \ - (instance).header.major_version, \ - (instance).header.minor_version, \ - SERVICE_EXPORT_STATIC, \ - &(instance), \ - }); \ - } - -#define EXPORT_SERVICE(instance) \ - EXPORT_SERVICE_AS( \ - instance, ::dusk::mods::ServiceTraits >::id) - -#define EXPORT_DEFERRED_SERVICE(token, service_id_value, major_value, minor_value) \ - namespace { \ - const int mod_deferred_export_registration_##token = \ - ::dusk::mods::detail::register_export(ServiceExport{ \ - sizeof(ServiceExport), \ - (service_id_value), \ - static_cast(major_value), \ - static_cast(minor_value), \ - SERVICE_EXPORT_DEFERRED, \ - nullptr, \ - }); \ - } diff --git a/include/os_report.h b/include/os_report.h index 78177a199d..0831e45396 100644 --- a/include/os_report.h +++ b/include/os_report.h @@ -25,16 +25,10 @@ DECL_WEAK void OSReportForceEnableOn(void); #define OS_PANIC(...) #endif -extern u8 __OSReport_disable; +DUSK_GAME_EXTERN u8 __OSReport_disable; extern u8 __OSReport_Error_disable; extern u8 __OSReport_Warning_disable; extern u8 __OSReport_System_disable; extern u8 __OSReport_enable; -#if TARGET_PC -namespace dusk { - extern bool OSReportReallyForceEnable; -} -#endif - #endif // _OS_REPORT_H diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h b/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h index 27218d0d0d..3eb1967e2c 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h @@ -3,6 +3,10 @@ #include +#if TARGET_PC + #include "helpers/endian.h" +#endif + class JSUInputStream; /** diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DMatBlock.h b/libs/JSystem/include/JSystem/J2DGraph/J2DMatBlock.h index 7a5a3e594a..340f4014ed 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DMatBlock.h @@ -892,7 +892,7 @@ struct J2DBlendInfo { /* 0x3 */ u8 mOp; }; -extern const J2DBlendInfo j2dDefaultBlendInfo; +DUSK_GAME_EXTERN const J2DBlendInfo j2dDefaultBlendInfo; /** * @ingroup jsystem-j2d diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h b/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h index f82788d57c..1eddcb943a 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DManage.h" #include "JSystem/J2DGraph/J2DMatBlock.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j2d diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h b/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h index 60f382f064..a588b4e7f7 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h @@ -5,7 +5,7 @@ #include "JSystem/JSupport/JSUList.h" #include #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DAnmBase; class J2DAnmColor; @@ -201,7 +201,7 @@ public: static s16 J2DCast_F32_to_S16(f32 value, u8 arg2); - static JGeometry::TBox2 static_mBounds; + static DUSK_GAME_DATA JGeometry::TBox2 static_mBounds; public: /* 0x04 */ u16 field_0x4; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h b/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h index f738a96dd4..f311e191fa 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DPane.h" #include "JSystem/JUtility/JUTTexture.h" #include "JSystem/JUtility/TColor.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DMaterial; class JUTPalette; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DPrint.h b/libs/JSystem/include/JSystem/J2DGraph/J2DPrint.h index aa0ffbdcf1..64e1b25139 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DPrint.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DPrint.h @@ -67,8 +67,8 @@ public: mFontSizeY = y; } - static char* mStrBuff; - static size_t mStrBuffSize; + static DUSK_GAME_DATA char* mStrBuff; + static DUSK_GAME_DATA size_t mStrBuffSize; private: void private_initiate(JUTFont*, f32, f32, JUtility::TColor, JUtility::TColor, diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h b/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h index ef83eee36e..ffc7568846 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DManage.h" #include "JSystem/J2DGraph/J2DPane.h" #include "JSystem/JUtility/TColor.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DMaterial; class JUTNameTab; @@ -90,7 +90,7 @@ public: static J2DDataManage* getDataManage() { return mDataManage; } - static J2DDataManage* mDataManage; + static DUSK_GAME_DATA J2DDataManage* mDataManage; /* 0x100 */ bool mScissor; /* 0x102 */ u16 mMaterialNum; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h b/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h index ea81bc869f..e515321188 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h @@ -4,7 +4,7 @@ #include #include #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j2d @@ -46,7 +46,7 @@ struct J2DTexMtxInfo { }; // Size: 0x24 -extern J2DTexMtxInfo const j2dDefaultTexMtxInfo; +DUSK_GAME_EXTERN J2DTexMtxInfo const j2dDefaultTexMtxInfo; /** * @ingroup jsystem-j2d @@ -86,7 +86,7 @@ struct J2DIndTexOrderInfo { GXTexMapID getTexMapID() const { return (GXTexMapID)mTexMapID; } }; -extern const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull; +DUSK_GAME_EXTERN const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull; /** * @ingroup jsystem-j2d @@ -130,7 +130,7 @@ struct J2DIndTexMtxInfo { } }; -extern J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo; +DUSK_GAME_EXTERN J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo; /** * @ingroup jsystem-j2d @@ -175,7 +175,7 @@ struct J2DIndTexCoordScaleInfo { GXIndTexScale getScaleT() const { return (GXIndTexScale)mScaleT; } }; -extern const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo; +DUSK_GAME_EXTERN const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo; /** * @ingroup jsystem-j2d @@ -239,7 +239,7 @@ inline u32 J2DCalcIndTevStage(J2DIndTevStageInfo info) { (info.mBiasSel << 4) | (info.mIndFormat << 2) | (info.mIndStage); } -extern const J2DIndTevStageInfo j2dDefaultIndTevStageInfo; +DUSK_GAME_EXTERN const J2DIndTevStageInfo j2dDefaultIndTevStageInfo; /** * @ingroup jsystem-j2d @@ -289,7 +289,7 @@ struct J2DTexCoordInfo { } }; -extern J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; +DUSK_GAME_EXTERN J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; /** * @ingroup jsystem-j2d @@ -332,7 +332,7 @@ struct J2DTevOrderInfo { } }; -extern const J2DTevOrderInfo j2dDefaultTevOrderInfoNull; +DUSK_GAME_EXTERN const J2DTevOrderInfo j2dDefaultTevOrderInfoNull; /** * @ingroup jsystem-j2d @@ -383,7 +383,7 @@ struct J2DTevStageInfo { /* 0x13 */ u8 field_0x13; }; -extern J2DTevStageInfo const j2dDefaultTevStageInfo; +DUSK_GAME_EXTERN J2DTevStageInfo const j2dDefaultTevStageInfo; /** * @ingroup jsystem-j2d @@ -396,7 +396,7 @@ struct J2DTevSwapModeInfo { /* 0x3 */ u8 field_0x3; }; -extern const J2DTevSwapModeInfo j2dDefaultTevSwapMode; +DUSK_GAME_EXTERN const J2DTevSwapModeInfo j2dDefaultTevSwapMode; /** * @ingroup jsystem-j2d @@ -565,8 +565,8 @@ inline u8 J2DCalcTevSwapTable(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { return (param_0 << 6) + (param_1 << 4) + (param_2 << 2) + param_3; } -extern const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable; -extern const u8 j2dDefaultTevSwapTableID; +DUSK_GAME_EXTERN const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable; +DUSK_GAME_EXTERN const u8 j2dDefaultTevSwapTableID; /** * @ingroup jsystem-j2d @@ -615,7 +615,7 @@ struct J2DColorChanInfo { }; inline u16 J2DCalcColorChanID(u8 param_0) { return param_0; } -extern const J2DColorChanInfo j2dDefaultColorChanInfo; +DUSK_GAME_EXTERN const J2DColorChanInfo j2dDefaultColorChanInfo; /** * @ingroup jsystem-j2d @@ -644,12 +644,12 @@ private: /* 0x0 */ u16 mColorChan; }; -extern const GXColor j2dDefaultColInfo; -extern const GXColorS10 j2dDefaultTevColor; -extern const GXColor j2dDefaultTevKColor; -extern const J2DTevOrderInfo j2dDefaultTevOrderInfoNull; -extern const u8 j2dDefaultPEBlockDither; -extern const u8 j2dDefaultTevSwapTableID; -extern const u16 j2dDefaultAlphaCmp; +DUSK_GAME_EXTERN const GXColor j2dDefaultColInfo; +DUSK_GAME_EXTERN const GXColorS10 j2dDefaultTevColor; +DUSK_GAME_EXTERN const GXColor j2dDefaultTevKColor; +DUSK_GAME_EXTERN const J2DTevOrderInfo j2dDefaultTevOrderInfoNull; +DUSK_GAME_EXTERN const u8 j2dDefaultPEBlockDither; +DUSK_GAME_EXTERN const u8 j2dDefaultTevSwapTableID; +DUSK_GAME_EXTERN const u16 j2dDefaultAlphaCmp; #endif /* J2DTEVS_H */ diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h b/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h index 0d875ad652..96a53c5a16 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h @@ -3,8 +3,8 @@ #include "JSystem/J2DGraph/J2DMaterial.h" #include "JSystem/J2DGraph/J2DPane.h" -#include "dusk/endian.h" -#include "dusk/string.hpp" +#include "helpers/endian.h" +#include "helpers/string.hpp" class J2DMaterial; class JUTFont; @@ -100,7 +100,7 @@ public: J2DTextBoxVBinding); void private_readStream(J2DPane*, JSURandomInputStream*, JKRArchive*); TEXT_SPAN getStringPtr() const; - dusk::TextSpan getSpan() const; + TextSpan getSpan() const; s32 setString(s16, char const*, ...); s32 setString(char const*, ...); diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h index 3c5133e880..f006183d07 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -6,7 +6,7 @@ #include #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC #define OFFSET_PTR_V0 BE(u32) diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h index 2a71ada3dd..4704fe1ee1 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -3,7 +3,7 @@ #include "JSystem/J3DAssert.h" #include "JSystem/J3DGraphLoader/J3DClusterLoader.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DDeformer; class J3DClusterKey; diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJoint.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJoint.h index 0a10f035be..7f57ed877b 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJoint.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJoint.h @@ -53,8 +53,8 @@ public: } static void setJoint(J3DJoint* joint) { mJoint = joint; } - static J3DMtxBuffer* mMtxBuffer; - static J3DJoint* mJoint; + static DUSK_GAME_DATA J3DMtxBuffer* mMtxBuffer; + static DUSK_GAME_DATA J3DJoint* mJoint; }; // Size: 0x4 typedef int (*J3DJointCallBack)(J3DJoint*, int); @@ -100,7 +100,7 @@ public: void setMtxType(u8 type) { mKind = (mKind & ~0xf0) | (type << 4); } f32 getRadius() const { return mBoundingSphereRadius; } - static J3DMtxCalc* mCurrentMtxCalc; + static DUSK_GAME_DATA J3DMtxCalc* mCurrentMtxCalc; u8 getKind() const { return mKind & 15; } diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h index 92b252fb7a..e4018f1ea2 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -3,7 +3,7 @@ #include "JSystem/J3DAssert.h" #include "JSystem/J3DGraphBase/J3DTransform.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DJoint; class J3DMtxBuffer; diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h index 2e5b3bd38d..a7edb19b70 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -3,7 +3,6 @@ #include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" #include "JSystem/J3DGraphBase/J3DPacket.h" -#include "dusk/frame_interpolation.h" #include enum J3DMdlFlag { @@ -80,7 +79,9 @@ public: virtual ~J3DModel() {} #if TARGET_PC - static void interp_callback(bool isSimFrame, void* pUserWork); + static void interp_callback(void* pUserWork); + void calc_presentation_base_mtx(); + void prepare_presentation_view(); #endif J3DModelData* getModelData() { return mModelData; } @@ -106,12 +107,13 @@ public: void setUserArea(uintptr_t area) { mUserArea = area; } uintptr_t getUserArea() const { return mUserArea; } Vec* getBaseScale() { return &mBaseScale; } +#if TARGET_PC + void setAnmMtx(int jointNo, Mtx m); +#else void setAnmMtx(int jointNo, Mtx m) { mMtxBuffer->setAnmMtx(jointNo, m); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); -#endif } +#endif MtxP getAnmMtx(int jointNo) { return mMtxBuffer->getAnmMtx(jointNo); } MtxP getWeightAnmMtx(int i) { return mMtxBuffer->getWeightAnmMtx(i); } J3DSkinDeform* getSkinDeform() { return mSkinDeform; } @@ -133,6 +135,9 @@ public: /* 0xD0 */ J3DVtxColorCalc* mVtxColorCalc; /* 0xD4 */ J3DUnkCalc1* mUnkCalc1; /* 0xD8 */ J3DUnkCalc2* mUnkCalc2; +#if TARGET_PC + Mtx mPresentationBase; +#endif }; #endif /* J3DMODEL_H */ diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h index e61bbbe231..3a9538a58d 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h @@ -62,10 +62,10 @@ public: mpNrmMtxArr[1][mCurrentViewNo] = tmp; } - static Mtx sNoUseDrawMtx; - static Mtx33 sNoUseNrmMtx; - static Mtx* sNoUseDrawMtxPtr; - static Mtx33* sNoUseNrmMtxPtr; + static DUSK_GAME_DATA Mtx sNoUseDrawMtx; + static DUSK_GAME_DATA Mtx33 sNoUseNrmMtx; + static DUSK_GAME_DATA Mtx* sNoUseDrawMtxPtr; + static DUSK_GAME_DATA Mtx33* sNoUseNrmMtxPtr; /* 0x00 */ J3DJointTree* mJointTree; /* 0x04 */ u8* mpScaleFlagArr; diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h index e68b3ab02c..3799687f93 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -59,9 +59,9 @@ public: virtual void deform(J3DVertexBuffer*, J3DMtxBuffer*); virtual ~J3DSkinDeform(); - static BE(u16)* sWorkArea_WEvlpMixMtx[1024]; - static BE(f32)* sWorkArea_WEvlpMixWeight[1024]; - static u16 sWorkArea_MtxReg[1024]; + static DUSK_GAME_DATA BE(u16)* sWorkArea_WEvlpMixMtx[1024]; + static DUSK_GAME_DATA BE(f32)* sWorkArea_WEvlpMixWeight[1024]; + static DUSK_GAME_DATA u16 sWorkArea_MtxReg[1024]; private: /* 0x04 */ u16* mPosData; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DDrawBuffer.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DDrawBuffer.h index 68be132081..a55f9ebcf1 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DDrawBuffer.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DDrawBuffer.h @@ -99,9 +99,9 @@ public: /* 0x1C */ MtxP mpZMtx; /* 0x20 */ J3DPacket* mpCallBackPacket; - static sortFunc sortFuncTable[6]; - static drawFunc drawFuncTable[2]; - static int entryNum; + static DUSK_GAME_DATA sortFunc sortFuncTable[6]; + static DUSK_GAME_DATA drawFunc drawFuncTable[2]; + static DUSK_GAME_DATA int entryNum; }; #endif /* J3DDRAWBUFFER_H */ diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h index 859bd6943e..dbb3877dc3 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -1437,7 +1437,7 @@ inline u16 calcZModeID(u8 param_0, u8 param_1, u8 param_2) { return param_1 * 2 + param_0 * 0x10 + param_2; } -extern u8 j3dZModeTable[96]; +DUSK_GAME_EXTERN u8 j3dZModeTable[96]; /** * @ingroup jsystem-j3d diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h index 4be9fe1f17..992d96b255 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h @@ -125,8 +125,8 @@ public: u8* getDisplayList(int idx) { return (u8*)mpDisplayList[idx]; } u32 getDisplayListSize() { return mSize; } - static GDLObj sGDLObj; - static s32 sInterruptFlag; + static DUSK_GAME_DATA GDLObj sGDLObj; + static DUSK_GAME_DATA s32 sInterruptFlag; /* 0x0 */ void* mpDisplayList[2]; /* 0x8 */ u32 mSize; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h index 5477868596..4ba3cc8023 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h @@ -4,8 +4,10 @@ #include "JSystem/J3DGraphBase/J3DShapeDraw.h" #include "JSystem/J3DAssert.h" #include "JSystem/J3DGraphBase/J3DFifo.h" +#include "JSystem/JMath/JMath.h" +#include "global.h" #include -#include "dusk/endian_gx.hpp" +#include "helpers/endian_gx.hpp" class J3DShapeMtx; @@ -78,13 +80,13 @@ public: virtual void load() const; virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); - static J3DShapeMtx_LoadFunc sMtxLoadPipeline[4]; - static u16 sMtxLoadCache[10]; - static u32 sCurrentPipeline; - static u8* sCurrentScaleFlag; - static bool sNBTFlag; - static bool sLODFlag; - static u32 sTexMtxLoadType; + static DUSK_GAME_DATA J3DShapeMtx_LoadFunc sMtxLoadPipeline[4]; + static DUSK_GAME_DATA u16 sMtxLoadCache[10]; + static DUSK_GAME_DATA u32 sCurrentPipeline; + static DUSK_GAME_DATA u8* sCurrentScaleFlag; + static DUSK_GAME_DATA bool sNBTFlag; + static DUSK_GAME_DATA bool sLODFlag; + static DUSK_GAME_DATA u32 sTexMtxLoadType; static void setCurrentPipeline(u32 pipeline) { J3D_ASSERT_RANGE(91, pipeline < 4); @@ -202,8 +204,8 @@ public: static void resetVcdVatCache() { sOldVcdVatCmd = NULL; } - static void* sOldVcdVatCmd; - static bool sEnvelopeFlag; + static DUSK_GAME_DATA void* sOldVcdVatCmd; + static DUSK_GAME_DATA bool sEnvelopeFlag; private: friend struct J3DShapeFactory; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h index 313fa1ef30..2b7ad8ad35 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphBase/J3DShape.h" #include "JSystem/J3DAssert.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DTexMtx; class J3DTexGenBlock; @@ -22,8 +22,8 @@ public: loadExecute(m); } - static J3DTexGenBlock* sTexGenBlock; - static J3DTexMtxObj* sTexMtxObj; + static DUSK_GAME_DATA J3DTexGenBlock* sTexGenBlock; + static DUSK_GAME_DATA J3DTexMtxObj* sTexMtxObj; }; class J3DShapeMtxConcatView; @@ -75,9 +75,9 @@ public: void loadMtxConcatView_PNCPU(int, u16) const; void loadMtxConcatView_PNGP_LOD(int, u16) const; - static J3DShapeMtxConcatView_LoadFunc sMtxLoadPipeline[4]; - static J3DShapeMtxConcatView_LoadFunc sMtxLoadLODPipeline[4]; - static MtxP sMtxPtrTbl[2]; + static DUSK_GAME_DATA J3DShapeMtxConcatView_LoadFunc sMtxLoadPipeline[4]; + static DUSK_GAME_DATA J3DShapeMtxConcatView_LoadFunc sMtxLoadLODPipeline[4]; + static DUSK_GAME_DATA MtxP sMtxPtrTbl[2]; }; /** diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h index 05663fd84e..0de93bcaf5 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h @@ -7,7 +7,7 @@ #include "global.h" #include "JSystem/JMath/JMath.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j3d diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h index 8c4bbd06e3..a4750e5d29 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h @@ -6,8 +6,8 @@ #include "JSystem/J3DAssert.h" #include "JSystem/JMath/JMath.h" -#include "dusk/frame_interpolation.h" -#include "dusk/endian.h" +#include "helpers/endian.h" +#include "global.h" enum J3DSysDrawBuf { /* 0x0 */ J3DSysDrawBuf_Opa, @@ -189,25 +189,23 @@ struct J3DSys { Mtx& getModelDrawMtx(u16 no) { return mModelDrawMtx[no]; } J3DShapePacket* getShapePacket() { return mShapePacket; } +#if TARGET_PC + void setViewMtx(const Mtx m); +#else void setViewMtx(const Mtx m) { -#ifdef TARGET_PC - Mtx patched; - if (dusk::frame_interp::lookup_replacement(m, patched)) { - m = patched; - } -#endif MTXCopy(m, mViewMtx); } +#endif J3DModel* getModel() { return mModel; } - static Mtx mCurrentMtx; - static Vec mCurrentS; - static Vec mParentS; - static J3DTexCoordScaleInfo sTexCoordScaleTable[8]; + static DUSK_GAME_DATA Mtx mCurrentMtx; + static DUSK_GAME_DATA Vec mCurrentS; + static DUSK_GAME_DATA Vec mParentS; + static DUSK_GAME_DATA J3DTexCoordScaleInfo sTexCoordScaleTable[8]; }; -extern u32 j3dDefaultViewNo; -extern J3DSys j3dSys; +DUSK_GAME_EXTERN u32 j3dDefaultViewNo; +DUSK_GAME_EXTERN J3DSys j3dSys; #endif /* J3DSYS_H */ diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTevs.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTevs.h index b0e2abfaae..c3d8dde2a4 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTevs.h @@ -6,32 +6,32 @@ #include "JSystem/J3DGraphBase/J3DGD.h" #include "JSystem/J3DGraphBase/J3DStruct.h" -extern u8 j3dTevSwapTableTable[1024]; +DUSK_GAME_EXTERN u8 j3dTevSwapTableTable[1024]; -extern const J3DLightInfo j3dDefaultLightInfo; -extern const J3DTexCoordInfo j3dDefaultTexCoordInfo[8]; -extern const J3DTexMtxInfo j3dDefaultTexMtxInfo; -extern const J3DIndTexMtxInfo j3dDefaultIndTexMtxInfo; -extern const J3DTevStageInfo j3dDefaultTevStageInfo; -extern const J3DIndTevStageInfo j3dDefaultIndTevStageInfo; -extern const J3DFogInfo j3dDefaultFogInfo; -extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; +DUSK_GAME_EXTERN const J3DLightInfo j3dDefaultLightInfo; +DUSK_GAME_EXTERN const J3DTexCoordInfo j3dDefaultTexCoordInfo[8]; +DUSK_GAME_EXTERN const J3DTexMtxInfo j3dDefaultTexMtxInfo; +DUSK_GAME_EXTERN const J3DIndTexMtxInfo j3dDefaultIndTexMtxInfo; +DUSK_GAME_EXTERN const J3DTevStageInfo j3dDefaultTevStageInfo; +DUSK_GAME_EXTERN const J3DIndTevStageInfo j3dDefaultIndTevStageInfo; +DUSK_GAME_EXTERN const J3DFogInfo j3dDefaultFogInfo; +DUSK_GAME_EXTERN const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; -extern const GXColor j3dDefaultColInfo; -extern const GXColor j3dDefaultAmbInfo; +DUSK_GAME_EXTERN const GXColor j3dDefaultColInfo; +DUSK_GAME_EXTERN const GXColor j3dDefaultAmbInfo; extern const u8 j3dDefaultColorChanNum; -extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; -extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; -extern const GXColorS10 j3dDefaultTevColor; -extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; -extern const GXColor j3dDefaultTevKColor; -extern const J3DTevSwapModeInfo j3dDefaultTevSwapMode; -extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable; -extern const J3DBlendInfo j3dDefaultBlendInfo; -extern const J3DColorChanInfo j3dDefaultColorChanInfo; -extern const u8 j3dDefaultTevSwapTableID; -extern const u16 j3dDefaultAlphaCmpID; -extern const u16 j3dDefaultZModeID; +DUSK_GAME_EXTERN const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; +DUSK_GAME_EXTERN const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; +DUSK_GAME_EXTERN const GXColorS10 j3dDefaultTevColor; +DUSK_GAME_EXTERN const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; +DUSK_GAME_EXTERN const GXColor j3dDefaultTevKColor; +DUSK_GAME_EXTERN const J3DTevSwapModeInfo j3dDefaultTevSwapMode; +DUSK_GAME_EXTERN const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable; +DUSK_GAME_EXTERN const J3DBlendInfo j3dDefaultBlendInfo; +DUSK_GAME_EXTERN const J3DColorChanInfo j3dDefaultColorChanInfo; +DUSK_GAME_EXTERN const u8 j3dDefaultTevSwapTableID; +DUSK_GAME_EXTERN const u16 j3dDefaultAlphaCmpID; +DUSK_GAME_EXTERN const u16 j3dDefaultZModeID; /** * @ingroup jsystem-j3d @@ -191,7 +191,7 @@ struct J3DIndTevStage { /* 0x0 */ u32 mInfo; }; -extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; +DUSK_GAME_EXTERN const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; /** * @ingroup jsystem-j3d @@ -209,8 +209,8 @@ struct J3DTevOrder : public J3DTevOrderInfo { u8 getTexMap() const { return mTexMap; } }; -extern u8 j3dTevSwapTableTable[1024]; -extern u8 const j3dDefaultTevSwapTableID; +DUSK_GAME_EXTERN u8 j3dTevSwapTableTable[1024]; +DUSK_GAME_EXTERN u8 const j3dDefaultTevSwapTableID; inline u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { return 0x40 * (u8)param_0 + 0x10 * (u8)param_1 + 4 * (u8)param_2 + param_3; @@ -263,7 +263,7 @@ public: /* 0x34 */ GXLightObj mLightObj; }; // Size = 0x74 -extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; +DUSK_GAME_EXTERN const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; /** * @ingroup jsystem-j3d @@ -287,12 +287,12 @@ struct J3DNBTScale : public J3DNBTScaleInfo { BE(Vec)* getScale() { return &mScale; } }; -extern const GXColor j3dDefaultColInfo; -extern const GXColor j3dDefaultAmbInfo; -extern const GXColorS10 j3dDefaultTevColor; -extern const GXColor j3dDefaultTevKColor; -extern u8 j3dAlphaCmpTable[768]; -extern const u8 j3dDefaultNumChans; +DUSK_GAME_EXTERN const GXColor j3dDefaultColInfo; +DUSK_GAME_EXTERN const GXColor j3dDefaultAmbInfo; +DUSK_GAME_EXTERN const GXColorS10 j3dDefaultTevColor; +DUSK_GAME_EXTERN const GXColor j3dDefaultTevKColor; +DUSK_GAME_EXTERN u8 j3dAlphaCmpTable[768]; +DUSK_GAME_EXTERN const u8 j3dDefaultNumChans; struct J3DNBTScale; struct J3DTexCoord; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h index e407db84b4..516ddac887 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h @@ -7,7 +7,7 @@ #include "global.h" #include -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" /** * @ingroup jsystem-j3d @@ -20,7 +20,7 @@ private: /* 0x4 */ ResTIMG* mpRes; #if TARGET_PC - GXTlutObj* mpTlutObj; + TGXTlutObj* mpTlutObj; TGXTexObj* mpTexObj; u8** mpImgDataPtr; u8** mpTlutDataPtr; @@ -31,20 +31,22 @@ public: J3D_ASSERT_NULLPTR(52, res != NULL || num == 0); #if TARGET_PC mpTexObj = new TGXTexObj[num]; - mpTlutObj = new GXTlutObj[num]; + mpTlutObj = new TGXTlutObj[num]; mpImgDataPtr = new u8*[num]; mpTlutDataPtr = new u8*[num]; for (u16 i = 0; i < num; i++) { mpImgDataPtr[i] = (u8*)(&mpRes[i]) + mpRes[i].imageOffset; mpTlutDataPtr[i] = (u8*)(&mpRes[i]) + mpRes[i].paletteOffset; - loadGXTexObj(i); + initGXTexObj(i); } #endif } void loadGX(u16, GXTexMapID) const; #if TARGET_PC - void loadGXTexObj(u16); + void initGXTexObj(u16); + TGXTexObj* getTexObj(u16 i) const { return &mpTexObj[i]; } + TGXTlutObj* getTlutObj(u16 i) const { return &mpTlutObj[i]; } #endif void entryNum(u16); void addResTIMG(u16, ResTIMG const*); @@ -77,7 +79,7 @@ public: #if TARGET_PC mpImgDataPtr[index] = ((u8*)&timg) + timg.imageOffset; mpTlutDataPtr[index] = ((u8*)&timg) + timg.paletteOffset; - loadGXTexObj(index); + initGXTexObj(index); #else mpRes[index].imageOffset = ((mpRes[index].imageOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index))); mpRes[index].paletteOffset = ((mpRes[index].paletteOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index))); @@ -85,7 +87,7 @@ public: } }; -extern J3DTexMtxInfo const j3dDefaultTexMtxInfo; +DUSK_GAME_EXTERN J3DTexMtxInfo const j3dDefaultTexMtxInfo; /** * @ingroup jsystem-j3d @@ -117,7 +119,7 @@ private: /* 0x64 */ Mtx mMtx; }; // Size: 0x94 -extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8]; +DUSK_GAME_EXTERN J3DTexCoordInfo const j3dDefaultTexCoordInfo[8]; /** * @ingroup jsystem-j3d diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTransform.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTransform.h index f8f27b26d9..dfe439fbfb 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTransform.h @@ -45,10 +45,10 @@ struct J3DTransformInfo { #endif }; // Size: 0x20 -extern J3DTransformInfo const j3dDefaultTransformInfo; -extern Vec const j3dDefaultScale; -extern Mtx const j3dDefaultMtx; -extern f32 const PSMulUnit01[]; +DUSK_GAME_EXTERN J3DTransformInfo const j3dDefaultTransformInfo; +DUSK_GAME_EXTERN Vec const j3dDefaultScale; +DUSK_GAME_EXTERN Mtx const j3dDefaultMtx; +DUSK_GAME_EXTERN f32 const PSMulUnit01[]; void J3DGQRSetup7(u32 param_0, u32 param_1, u32 param_2, u32 param_3); void J3DCalcBBoardMtx(f32 (*)[4]); diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h index 1638e316e9..f7ad92afb8 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h @@ -3,7 +3,7 @@ #include #include -#include "dusk/endian_gx.hpp" +#include "helpers/endian_gx.hpp" class J3DModel; class J3DAnmVtxColor; diff --git a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h index 2899065150..75ba644be8 100644 --- a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h +++ b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphAnimator/J3DAnimation.h" #include "JSystem/J3DGraphAnimator/J3DAnimation.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC #define OFFSET_PTR_V0 BE(u32) diff --git a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h index 6c856f1a3d..a0711fd796 100644 --- a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h +++ b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -4,11 +4,12 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DModelData; class J3DMaterialTable; struct J3DModelHierarchy; +class J3DVertexData; #if TARGET_PC #define OFFSET_PTR_V0 BE(u32) diff --git a/libs/JSystem/include/JSystem/JAHostIO/JAHUpdate.h b/libs/JSystem/include/JSystem/JAHostIO/JAHUpdate.h index 84efd7e539..8ef1c84577 100644 --- a/libs/JSystem/include/JSystem/JAHostIO/JAHUpdate.h +++ b/libs/JSystem/include/JSystem/JAHostIO/JAHUpdate.h @@ -8,8 +8,8 @@ namespace JAHUpdate { -extern JAHioNode* spNode; -extern JORMContext* spMc; +DUSK_GAME_EXTERN JAHioNode* spNode; +DUSK_GAME_EXTERN JORMContext* spMc; inline void startUpdateNode(JAHioNode* param_1) { spMc = attachJORMContext(8); diff --git a/libs/JSystem/include/JSystem/JAHostIO/JAHVirtualNode.h b/libs/JSystem/include/JSystem/JAHostIO/JAHVirtualNode.h index eee0ed94c0..535c01f881 100644 --- a/libs/JSystem/include/JSystem/JAHostIO/JAHVirtualNode.h +++ b/libs/JSystem/include/JSystem/JAHostIO/JAHVirtualNode.h @@ -29,7 +29,7 @@ public: JSUTree* getVirTree() { return &mTree; } static u32 getVirNodeNum() { return smVirNodeNum; } - static u32 smVirNodeNum; + static DUSK_GAME_DATA u32 smVirNodeNum; /* 0x04 */ JSUTree mTree; /* 0x20 */ char mName[32]; diff --git a/libs/JSystem/include/JSystem/JAHostIO/JAHioMessage.h b/libs/JSystem/include/JSystem/JAHostIO/JAHioMessage.h index 5a323dacd0..1b27be95b4 100644 --- a/libs/JSystem/include/JSystem/JAHostIO/JAHioMessage.h +++ b/libs/JSystem/include/JSystem/JAHostIO/JAHioMessage.h @@ -38,17 +38,17 @@ public: static u32 getIntervalX() { return smIntX; } static u32 getNameWidth() { return smNameWidth; } - static u16 smButtonWidth[]; - static u16 smCommentWidth[]; - static u16 smComboWidth[]; - static u16 smYTop; - static u16 smXLeft; - static u16 smIndentSize; - static u16 smLineHeight; - static u16 smContWidth; - static u16 smIntX; - static u16 smIntY; - static u16 smNameWidth; + static DUSK_GAME_DATA u16 smButtonWidth[]; + static DUSK_GAME_DATA u16 smCommentWidth[]; + static DUSK_GAME_DATA u16 smComboWidth[]; + static DUSK_GAME_DATA u16 smYTop; + static DUSK_GAME_DATA u16 smXLeft; + static DUSK_GAME_DATA u16 smIndentSize; + static DUSK_GAME_DATA u16 smLineHeight; + static DUSK_GAME_DATA u16 smContWidth; + static DUSK_GAME_DATA u16 smIntX; + static DUSK_GAME_DATA u16 smIntY; + static DUSK_GAME_DATA u16 smNameWidth; u16 getX() { return mX; } u16 getY() { return mY; } diff --git a/libs/JSystem/include/JSystem/JAHostIO/JAHioNode.h b/libs/JSystem/include/JSystem/JAHostIO/JAHioNode.h index 70fb1d07b5..d0e294a959 100644 --- a/libs/JSystem/include/JSystem/JAHostIO/JAHioNode.h +++ b/libs/JSystem/include/JSystem/JAHostIO/JAHioNode.h @@ -41,7 +41,7 @@ public: static JAHioNode* getCurrentNode() { return smCurrentNode; } - static JAHioNode* smCurrentNode; + static DUSK_GAME_DATA JAHioNode* smCurrentNode; JSUTree* getTree() { return &mTree; } char* getNodeName() { return mName; } diff --git a/libs/JSystem/include/JSystem/JAHostIO/JAHioUtil.h b/libs/JSystem/include/JSystem/JAHostIO/JAHioUtil.h index 08522c8ba1..2342f030ec 100644 --- a/libs/JSystem/include/JSystem/JAHostIO/JAHioUtil.h +++ b/libs/JSystem/include/JSystem/JAHostIO/JAHioUtil.h @@ -4,7 +4,7 @@ namespace JAHioUtil { char* getString(const char* msg, ...); - extern char mStringBuffer[]; + DUSK_GAME_EXTERN char mStringBuffer[]; } #endif /* JAHIOUTIL_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JAISound.h b/libs/JSystem/include/JSystem/JAudio2/JAISound.h index e96053fc9f..fa262a7426 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAISound.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAISound.h @@ -5,7 +5,7 @@ #include "JSystem/JAudio2/JAIAudible.h" #include "JSystem/JUtility/JUTAssert.h" #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #include class JAISound; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASAiCtrl.h b/libs/JSystem/include/JSystem/JAudio2/JASAiCtrl.h index 5bba1b94ee..2ae0f82c0a 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASAiCtrl.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASAiCtrl.h @@ -41,21 +41,21 @@ namespace JASDriver { void subframeCallback(); void DSPSyncCallback(); - extern const MixFunc sMixFuncs[4]; - extern s16* sDmaDacBuffer[3]; - extern JASMixMode sMixMode; - extern f32 sDacRate; - extern u32 sSubFrames; - extern s16** sDspDacBuffer; - extern s32 sDspDacWriteBuffer; - extern s32 sDspDacReadBuffer; - extern s32 sDspStatus; - extern DSPBufCallback sDspDacCallback; - extern s16* lastRspMadep; - extern void (*dacCallbackFunc)(s16*, u32); - extern MixCallback extMixCallback; - extern u32 sOutputRate; - extern u32 sSubFrameCounter; + DUSK_GAME_EXTERN const MixFunc sMixFuncs[4]; + DUSK_GAME_EXTERN s16* sDmaDacBuffer[3]; + DUSK_GAME_EXTERN JASMixMode sMixMode; + DUSK_GAME_EXTERN f32 sDacRate; + DUSK_GAME_EXTERN u32 sSubFrames; + DUSK_GAME_EXTERN s16** sDspDacBuffer; + DUSK_GAME_EXTERN s32 sDspDacWriteBuffer; + DUSK_GAME_EXTERN s32 sDspDacReadBuffer; + DUSK_GAME_EXTERN s32 sDspStatus; + DUSK_GAME_EXTERN DSPBufCallback sDspDacCallback; + DUSK_GAME_EXTERN s16* lastRspMadep; + DUSK_GAME_EXTERN void (*dacCallbackFunc)(s16*, u32); + DUSK_GAME_EXTERN MixCallback extMixCallback; + DUSK_GAME_EXTERN u32 sOutputRate; + DUSK_GAME_EXTERN u32 sSubFrameCounter; }; #endif /* JASAICTRL_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h b/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h index dcfcebd30a..46a30d2616 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h @@ -4,7 +4,7 @@ #include "JSystem/JAudio2/JASTaskThread.h" #include "JSystem/JUtility/JUTAssert.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class JASChannel; @@ -256,24 +256,24 @@ public: * Thread that will be sent DVD load commands. * This is the JASDvd thread in practice. */ - static JASTaskThread* sLoadThread; + static DUSK_GAME_DATA JASTaskThread* sLoadThread; /** * Buffer used to read DVD data. Can store the size of an entire streamed audio block. */ - static u8* sReadBuffer; + static DUSK_GAME_DATA u8* sReadBuffer; /** * Block size used by all streamed music in the game. * This is 0x2760 for TP. */ - static u32 sBlockSize; + static DUSK_GAME_DATA u32 sBlockSize; /** * Maximum amount of output channels for all streamed music in the game. * This is 2 for TP (stereo). */ - static u32 sChannelMax; + static DUSK_GAME_DATA u32 sChannelMax; }; #endif /* JASARAMSTREAM_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASAudioThread.h b/libs/JSystem/include/JSystem/JAudio2/JASAudioThread.h index dd9fed2183..f633d58708 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASAudioThread.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASAudioThread.h @@ -30,7 +30,7 @@ struct JASAudioThread : public JKRThread, public JASGlobalInstance +#include #include /** @@ -10,16 +11,31 @@ */ struct JASCalc { static void imixcopy(const s16*, const s16*, s16*, u32); - static void bcopyfast(const void* src, void* dest, u32 size); +#if TARGET_PC + static void bcopyfast(const void* src, void* dest, u32 size) { + std::memcpy(dest, src, size); + } #if TARGET_ANDROID - static void _bcopy(const void* src, void* dest, u32 size); + static void _bcopy(const void* src, void* dest, u32 size) { #else - static void bcopy(const void* src, void* dest, u32 size); + static void bcopy(const void* src, void* dest, u32 size) { #endif - static void bzerofast(void* dest, u32 size); + std::memcpy(dest, src, size); + } + static void bzerofast(void* dest, u32 size) { + std::memset(dest, 0, size); + } #if TARGET_ANDROID - static void _bzero(void* dest, u32 size); + static void _bzero(void* dest, u32 size) { #else + static void bzero(void* dest, u32 size) { +#endif + std::memset(dest, 0, size); + } +#else + static void bcopyfast(const void* src, void* dest, u32 size); + static void bcopy(const void* src, void* dest, u32 size); + static void bzerofast(void* dest, u32 size); static void bzero(void* dest, u32 size); #endif static f32 pow2(f32); @@ -42,7 +58,7 @@ struct JASCalc { f32 fake3(); #if AVOID_UB - static const s16 CUTOFF_TO_IIR_TABLE[129][4]; + static DUSK_GAME_DATA const s16 CUTOFF_TO_IIR_TABLE[129][4]; #else static const s16 CUTOFF_TO_IIR_TABLE[128][4]; #endif diff --git a/libs/JSystem/include/JSystem/JAudio2/JASChannel.h b/libs/JSystem/include/JSystem/JAudio2/JASChannel.h index ce9b0b20de..af922638da 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASChannel.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASChannel.h @@ -166,10 +166,10 @@ public: u32 field_0x104; }; - static OSMessageQueue sBankDisposeMsgQ; - static OSMessage sBankDisposeMsg[16]; - static OSMessage sBankDisposeList[16]; - static int sBankDisposeListSize; + static DUSK_GAME_DATA OSMessageQueue sBankDisposeMsgQ; + static DUSK_GAME_DATA OSMessage sBankDisposeMsg[16]; + static DUSK_GAME_DATA OSMessage sBankDisposeList[16]; + static DUSK_GAME_DATA int sBankDisposeListSize; }; #endif /* JASCHANNEL_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASCmdStack.h b/libs/JSystem/include/JSystem/JAudio2/JASCmdStack.h index 2ad327362b..7765b6aee0 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASCmdStack.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASCmdStack.h @@ -52,8 +52,8 @@ struct JASPortCmd : JSULink { Command mFunc; JASPortArgs* mArgs; - static TPortHead sCommandListOnce; - static TPortHead sCommandListStay; + static DUSK_GAME_DATA TPortHead sCommandListOnce; + static DUSK_GAME_DATA TPortHead sCommandListStay; }; #endif /* JASCMDSTACK_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASDSPChannel.h b/libs/JSystem/include/JSystem/JAudio2/JASDSPChannel.h index 8204ab0838..f2ee2c3e49 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASDSPChannel.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASDSPChannel.h @@ -63,7 +63,7 @@ struct JASDSPChannel { static u32 getNumFree(); static u32 getNumBreak(); - static JASDSPChannel* sDspChannels; + static DUSK_GAME_DATA JASDSPChannel* sDspChannels; /* 0x00 */ s32 mStatus; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASDSPInterface.h b/libs/JSystem/include/JSystem/JAudio2/JASDSPInterface.h index a9a9b2d11e..b413052da7 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASDSPInterface.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASDSPInterface.h @@ -196,15 +196,15 @@ namespace JASDsp { int setFXLine(u8, s16*, JASDsp::FxlineConfig_*); BOOL changeFXLineParam(u8, u8, uintptr_t); - extern u8 const DSPADPCM_FILTER[64]; - extern u32 const DSPRES_FILTER[320]; - extern u16 SEND_TABLE[]; - extern TChannel* CH_BUF; - extern FxBuf* FX_BUF; - extern f32 sDSPVolume; + DUSK_GAME_EXTERN u8 const DSPADPCM_FILTER[64]; + DUSK_GAME_EXTERN u32 const DSPRES_FILTER[320]; + DUSK_GAME_EXTERN u16 SEND_TABLE[]; + DUSK_GAME_EXTERN TChannel* CH_BUF; + DUSK_GAME_EXTERN FxBuf* FX_BUF; + DUSK_GAME_EXTERN f32 sDSPVolume; #if DEBUG - extern s32 dspMutex; + DUSK_GAME_EXTERN s32 dspMutex; #endif }; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASDriverIF.h b/libs/JSystem/include/JSystem/JAudio2/JASDriverIF.h index 5cddc38596..6401c0783a 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASDriverIF.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASDriverIF.h @@ -24,11 +24,11 @@ namespace JASDriver { void DSPSyncCallback(); void updateDacCallback(); - extern JASCallbackMgr sDspSyncCallback; - extern JASCallbackMgr sSubFrameCallback; - extern JASCallbackMgr sUpdateDacCallback; - extern u16 MAX_MIXERLEVEL; - extern u32 JAS_SYSTEM_OUTPUT_MODE; + DUSK_GAME_EXTERN JASCallbackMgr sDspSyncCallback; + DUSK_GAME_EXTERN JASCallbackMgr sSubFrameCallback; + DUSK_GAME_EXTERN JASCallbackMgr sUpdateDacCallback; + DUSK_GAME_EXTERN u16 MAX_MIXERLEVEL; + DUSK_GAME_EXTERN u32 JAS_SYSTEM_OUTPUT_MODE; }; inline void JAISetOutputMode(u32 mode) { diff --git a/libs/JSystem/include/JSystem/JAudio2/JASDvdThread.h b/libs/JSystem/include/JSystem/JAudio2/JASDvdThread.h index 553dffb7ca..c238413f8d 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASDvdThread.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASDvdThread.h @@ -14,7 +14,7 @@ public: static JASTaskThread* getThreadPointer(); static bool createThread(s32 priority, int msgCount, u32 stackSize); - static JASTaskThread* sThread; + static DUSK_GAME_DATA JASTaskThread* sThread; }; #endif /* JASDVDTHREAD_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h b/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h index 996fef6fef..353e0c4315 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASHeapCtrl.h @@ -273,10 +273,10 @@ namespace JASKernel { u32 getAramFreeSize(); u32 getAramSize(); - extern JASHeap audioAramHeap; - extern uintptr_t sAramBase; - extern JKRHeap* sSystemHeap; - extern JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* sCommandHeap; + DUSK_GAME_EXTERN JASHeap audioAramHeap; + DUSK_GAME_EXTERN uintptr_t sAramBase; + DUSK_GAME_EXTERN JKRHeap* sSystemHeap; + DUSK_GAME_EXTERN JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* sCommandHeap; }; /** @@ -452,6 +452,6 @@ private: template JASMemPool_MultiThreaded JASPoolAllocObject_MultiThreaded::memPool_; #endif -extern JKRSolidHeap* JASDram; +DUSK_GAME_EXTERN JKRSolidHeap* JASDram; #endif /* JASHEAPCTRL_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASLfo.h b/libs/JSystem/include/JSystem/JAudio2/JASLfo.h index adc27a8325..5177a40f97 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASLfo.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASLfo.h @@ -19,7 +19,7 @@ struct JASLfo { static void updateFreeRun(f32 param_0) { sFreeRunLfo.incCounter(param_0); } - static JASLfo sFreeRunLfo; + static DUSK_GAME_DATA JASLfo sFreeRunLfo; /* 0x00 */ u32 field_0x0; /* 0x04 */ u32 field_0x4; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h b/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h index e811e890ab..8ac20ce1ca 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h @@ -2,7 +2,7 @@ #define JASOSCILLATOR_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio @@ -92,10 +92,10 @@ struct JASOscillator { /* 0x1A */ u16 _1A; /* 0x1C */ int _1C; - static const f32 sCurveTableLinear[17]; - static const f32 sCurveTableSampleCell[17]; - static const f32 sCurveTableSqRoot[17]; - static const f32 sCurveTableSquare[17]; + static DUSK_GAME_DATA const f32 sCurveTableLinear[17]; + static DUSK_GAME_DATA const f32 sCurveTableSampleCell[17]; + static DUSK_GAME_DATA const f32 sCurveTableSqRoot[17]; + static DUSK_GAME_DATA const f32 sCurveTableSquare[17]; }; #endif /* JASOSCILLATOR_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASProbe.h b/libs/JSystem/include/JSystem/JAudio2/JASProbe.h index 03337adce7..1aacf96b4a 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASProbe.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASProbe.h @@ -13,7 +13,7 @@ struct JASProbe { void stop(); static void stop(s32); - static JASProbe* sProbeTable[16]; + static DUSK_GAME_DATA JASProbe* sProbeTable[16]; /* 0x000 */ char const* mName; /* 0x004 */ s32 mStartTime; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASSeqCtrl.h b/libs/JSystem/include/JSystem/JAudio2/JASSeqCtrl.h index d481192d6f..ce184e400d 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASSeqCtrl.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASSeqCtrl.h @@ -73,7 +73,7 @@ public: /* 0x52 */ u16 field_0x52; /* 0x54 */ u32 field_0x54; /* 0x58 */ u32 field_0x58; - static JASSeqParser sDefaultParser; + static DUSK_GAME_DATA JASSeqParser sDefaultParser; }; #endif /* JASSEQCTRL_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASSeqParser.h b/libs/JSystem/include/JSystem/JAudio2/JASSeqParser.h index 51db04ba26..8040e07228 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASSeqParser.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASSeqParser.h @@ -92,9 +92,9 @@ public: static void registerSeqCallback(u16 (*param_0)(JASTrack*, u16)) { sCallBackFunc = param_0; } - static CmdInfo sCmdInfo[96]; - static CmdInfo sExtCmdInfo[255]; - static u16 (*sCallBackFunc)(JASTrack*, u16); + static DUSK_GAME_DATA CmdInfo sCmdInfo[96]; + static DUSK_GAME_DATA CmdInfo sExtCmdInfo[255]; + static DUSK_GAME_DATA u16 (*sCallBackFunc)(JASTrack*, u16); }; #endif /* JASSEQPARSER_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASTrack.h b/libs/JSystem/include/JSystem/JAudio2/JASTrack.h index b54a98aa77..eb8010be52 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASTrack.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASTrack.h @@ -14,7 +14,7 @@ struct JASSoundParams; namespace JASDsp { struct TChannel; - extern const u32 FILTER_MODE_IIR; + DUSK_GAME_EXTERN const u32 FILTER_MODE_IIR; }; #if !BIT_64 @@ -136,12 +136,12 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded { static void channelUpdateCallback(u32, JASChannel*, JASDsp::TChannel*, void*); - static JASOscillator::Point const sAdsTable[4]; - static JASOscillator::Data const sEnvOsc; - static JASOscillator::Data const sPitchEnvOsc; + static DUSK_GAME_DATA JASOscillator::Point const sAdsTable[4]; + static DUSK_GAME_DATA JASOscillator::Data const sEnvOsc; + static DUSK_GAME_DATA JASOscillator::Data const sPitchEnvOsc; - static JASDefaultBankTable sDefaultBankTable; - static TList sTrackList; + static DUSK_GAME_DATA JASDefaultBankTable sDefaultBankTable; + static DUSK_GAME_DATA TList sTrackList; static const int MAX_CHILDREN = 16; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASVoiceBank.h b/libs/JSystem/include/JSystem/JAudio2/JASVoiceBank.h index f54273e962..ee40ea1074 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASVoiceBank.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASVoiceBank.h @@ -14,8 +14,8 @@ public: virtual ~JASVoiceBank(); virtual u32 getType() const; - static const JASOscillator::Data sOscData; - static JASOscillator::Data* sOscTable; + static DUSK_GAME_DATA const JASOscillator::Data sOscData; + static DUSK_GAME_DATA JASOscillator::Data* sOscTable; }; #endif /* JASVOICEBANK_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASWSParser.h b/libs/JSystem/include/JSystem/JAudio2/JASWSParser.h index 68d91006ba..9fe201308c 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASWSParser.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASWSParser.h @@ -89,7 +89,7 @@ public: static JASBasicWaveBank* createBasicWaveBank(void const*, JKRHeap*); static JASSimpleWaveBank* createSimpleWaveBank(void const*, JKRHeap*); - static u32 sUsedHeapSize; + static DUSK_GAME_DATA u32 sUsedHeapSize; }; #endif /* JASWSPARSER_H */ diff --git a/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h b/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h index eea3eddac3..0ad4e044c8 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASWaveArcLoader.h @@ -28,8 +28,8 @@ struct JASWaveArcLoader { static void setCurrentDir(char const*); static char* getCurrentDir(); - static char sCurrentDir[DIR_MAX]; - static JASHeap* sAramHeap; + static DUSK_GAME_DATA char sCurrentDir[DIR_MAX]; + static DUSK_GAME_DATA JASHeap* sAramHeap; }; /** diff --git a/libs/JSystem/include/JSystem/JAudio2/JASWaveInfo.h b/libs/JSystem/include/JSystem/JAudio2/JASWaveInfo.h index cac518836e..04bd541204 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASWaveInfo.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASWaveInfo.h @@ -33,7 +33,7 @@ struct JASWaveInfo { /* 0x1E */ s16 mpPenult; /* 0x20 */ const u32* field_0x20; - static u32 one; + static DUSK_GAME_DATA u32 one; }; /** diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h b/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h index 44d4137d9b..cc5653fe25 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h @@ -2,7 +2,7 @@ #define JAUAUDIBLEPARAM_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h b/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h index c36ad44b22..33a31adb9f 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h @@ -2,7 +2,7 @@ #define JAUAUDIOARCINTERPRETER_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h b/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h index e81cd70ee4..f590815af5 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h @@ -2,7 +2,7 @@ #define JAUSOUNDANIMATOR_H #include "JSystem/JAudio2/JAISound.h" -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" class JAUSoundAnimation; diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h index 4cc48f2a0b..fbd3427649 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h @@ -3,7 +3,7 @@ #include "JSystem/JAudio2/JAISound.h" #include "JSystem/JAudio2/JASGadget.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JFramework/JFWDisplay.h b/libs/JSystem/include/JSystem/JFramework/JFWDisplay.h index 28967cc0a2..c9fc602b29 100644 --- a/libs/JSystem/include/JSystem/JFramework/JFWDisplay.h +++ b/libs/JSystem/include/JSystem/JFramework/JFWDisplay.h @@ -27,7 +27,7 @@ public: OSThread* getThread() const { return mThread; } void setThread(OSThread* thread) { mThread = thread; } - static JSUList sList; + static DUSK_GAME_DATA JSUList sList; public: /* 0x28 */ OSThread* mThread; @@ -108,7 +108,7 @@ public: int getEfbHeight() const { return JUTVideo::getManager()->getEfbHeight(); } JUTXfb* getXfbManager() const { return mXfbManager; } - static JFWDisplay* sManager; + static DUSK_GAME_DATA JFWDisplay* sManager; private: /* 0x04 */ JUTFader* mFader; diff --git a/libs/JSystem/include/JSystem/JFramework/JFWSystem.h b/libs/JSystem/include/JSystem/JFramework/JFWSystem.h index 288b5f03d8..c8d3940331 100644 --- a/libs/JSystem/include/JSystem/JFramework/JFWSystem.h +++ b/libs/JSystem/include/JSystem/JFramework/JFWSystem.h @@ -18,17 +18,17 @@ struct ResFONT; */ struct JFWSystem { struct CSetUpParam { - static s32 maxStdHeaps; - static u32 sysHeapSize; - static u32 fifoBufSize; - static u32 aramAudioBufSize; - static u32 aramGraphBufSize; - static s32 streamPriority; - static s32 decompPriority; - static s32 aPiecePriority; - static ResFONT* systemFontRes; - static const GXRenderModeObj* renderMode; - static u32 exConsoleBufferSize; + static DUSK_GAME_DATA s32 maxStdHeaps; + static DUSK_GAME_DATA u32 sysHeapSize; + static DUSK_GAME_DATA u32 fifoBufSize; + static DUSK_GAME_DATA u32 aramAudioBufSize; + static DUSK_GAME_DATA u32 aramGraphBufSize; + static DUSK_GAME_DATA s32 streamPriority; + static DUSK_GAME_DATA s32 decompPriority; + static DUSK_GAME_DATA s32 aPiecePriority; + static DUSK_GAME_DATA ResFONT* systemFontRes; + static DUSK_GAME_DATA const GXRenderModeObj* renderMode; + static DUSK_GAME_DATA u32 exConsoleBufferSize; }; static void firstInit(); @@ -67,14 +67,14 @@ struct JFWSystem { CSetUpParam::renderMode = p_modeObj; } - static JKRExpHeap* rootHeap; - static JKRExpHeap* systemHeap; - static JKRThread* mainThread; - static JUTDbPrint* debugPrint; - static JUTResFont* systemFont; - static JUTConsoleManager* systemConsoleManager; - static JUTConsole* systemConsole; - static bool sInitCalled; + static DUSK_GAME_DATA JKRExpHeap* rootHeap; + static DUSK_GAME_DATA JKRExpHeap* systemHeap; + static DUSK_GAME_DATA JKRThread* mainThread; + static DUSK_GAME_DATA JUTDbPrint* debugPrint; + static DUSK_GAME_DATA JUTResFont* systemFont; + static DUSK_GAME_DATA JUTConsoleManager* systemConsoleManager; + static DUSK_GAME_DATA JUTConsole* systemConsole; + static DUSK_GAME_DATA bool sInitCalled; }; #endif /* JFWSYSTEM_H */ diff --git a/libs/JSystem/include/JSystem/JGadget/binary.h b/libs/JSystem/include/JSystem/JGadget/binary.h index f93e548f88..eb0ddfb1d0 100644 --- a/libs/JSystem/include/JSystem/JGadget/binary.h +++ b/libs/JSystem/include/JSystem/JGadget/binary.h @@ -3,7 +3,7 @@ #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JGadget/search.h" -#include "dusk/endian.h" +#include "helpers/endian.h" namespace JGadget { namespace binary { diff --git a/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h b/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h index 3d8c452c72..e5a3e11553 100644 --- a/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h +++ b/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h @@ -2,7 +2,7 @@ #define JHICOMMONMEM_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" inline u32 JHIhtonl(u32 v) { return BSWAP32(v); diff --git a/libs/JSystem/include/JSystem/JHostIO/JHIMccBuf.h b/libs/JSystem/include/JSystem/JHostIO/JHIMccBuf.h index 7343b88376..a7b4544980 100644 --- a/libs/JSystem/include/JSystem/JHostIO/JHIMccBuf.h +++ b/libs/JSystem/include/JSystem/JHostIO/JHIMccBuf.h @@ -27,8 +27,8 @@ public: virtual void disablePort() { mPortEnabled = false; } virtual bool isPort() { return mPortEnabled; } - static u8* mTempBuf; - static u16 mRefCount; + static DUSK_GAME_DATA u8* mTempBuf; + static DUSK_GAME_DATA u16 mRefCount; /* 0x04 */ u32 mTag; /* 0x08 */ u16 field_0x8; diff --git a/libs/JSystem/include/JSystem/JHostIO/JORServer.h b/libs/JSystem/include/JSystem/JHostIO/JORServer.h index 53f3283f6c..ecb6225650 100644 --- a/libs/JSystem/include/JSystem/JHostIO/JORServer.h +++ b/libs/JSystem/include/JSystem/JHostIO/JORServer.h @@ -120,7 +120,7 @@ public: CallbackLinkList* referEventCallbackList() { return &m_eventCallbackList; } static JORServer* getInstance() { return instance; } - static JORServer* instance; + static DUSK_GAME_DATA JORServer* instance; /* 0x0000C */ JORMContext m_context; /* 0x10020 */ JORReflexible* mp_rootObj; diff --git a/libs/JSystem/include/JSystem/JKernel/JKRAram.h b/libs/JSystem/include/JSystem/JKernel/JKRAram.h index dd3bf54f9c..c934820b13 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRAram.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRAram.h @@ -65,13 +65,13 @@ public: static u32 getSZSBufferSize() { return sSZSBufferSize; } static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; } - static OSMessageQueue sMessageQueue; + static DUSK_GAME_DATA OSMessageQueue sMessageQueue; private: - static JKRAram* sAramObject; - static u32 sSZSBufferSize; - static OSMessage sMessageBuffer[4]; - static JSUList sAramCommandList; + static DUSK_GAME_DATA JKRAram* sAramObject; + static DUSK_GAME_DATA u32 sSZSBufferSize; + static DUSK_GAME_DATA OSMessage sMessageBuffer[4]; + static DUSK_GAME_DATA JSUList sAramCommandList; }; inline JKRAramBlock* JKRAllocFromAram(u32 size, JKRAramHeap::EAllocMode allocMode) { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRAramHeap.h b/libs/JSystem/include/JSystem/JKernel/JKRAramHeap.h index 0d7734f6f4..b502e21aa7 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRAramHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRAramHeap.h @@ -19,7 +19,7 @@ public: }; public: - static JSUList sAramList; + static DUSK_GAME_DATA JSUList sAramList; JKRAramHeap(u32, u32); virtual ~JKRAramHeap(); diff --git a/libs/JSystem/include/JSystem/JKernel/JKRAramPiece.h b/libs/JSystem/include/JSystem/JKernel/JKRAramPiece.h index 51eeef27e9..f701afd08f 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRAramPiece.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRAramPiece.h @@ -62,9 +62,9 @@ struct JKRAramCommand { */ class JKRAramPiece { public: - static OSMutex mMutex; + static DUSK_GAME_DATA OSMutex mMutex; // TODO: fix type - static JSUList sAramPieceCommandList; + static DUSK_GAME_DATA JSUList sAramPieceCommandList; public: static JKRAMCommand* prepareCommand(int, uintptr_t, uintptr_t, u32, JKRAramBlock*, diff --git a/libs/JSystem/include/JSystem/JKernel/JKRAramStream.h b/libs/JSystem/include/JSystem/JKernel/JKRAramStream.h index 47d9257229..9ea3fb4eb6 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRAramStream.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRAramStream.h @@ -60,13 +60,13 @@ public: static void setTransBuffer(u8*, u32, JKRHeap*); private: - static JKRAramStream* sAramStreamObject; - static OSMessage sMessageBuffer[4]; - static OSMessageQueue sMessageQueue; + static DUSK_GAME_DATA JKRAramStream* sAramStreamObject; + static DUSK_GAME_DATA OSMessage sMessageBuffer[4]; + static DUSK_GAME_DATA OSMessageQueue sMessageQueue; - static u8* transBuffer; - static u32 transSize; - static JKRHeap* transHeap; + static DUSK_GAME_DATA u8* transBuffer; + static DUSK_GAME_DATA u32 transSize; + static DUSK_GAME_DATA JKRHeap* transHeap; }; inline JKRAramStream* JKRCreateAramStreamManager(s32 priority) { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRArchive.h b/libs/JSystem/include/JSystem/JKernel/JKRArchive.h index 89f3835364..bcedc7834e 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRArchive.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRArchive.h @@ -4,13 +4,19 @@ #include "JSystem/JKernel/JKRCompression.h" #include "JSystem/JKernel/JKRFileLoader.h" #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" + +#if TARGET_PC +#include +#include +#include +#endif class JKRHeap; /** * @ingroup jsystem-jkernel - * + * */ struct SArcHeader { /* 0x00 */ BE(u32) signature; @@ -25,7 +31,7 @@ struct SArcHeader { /** * @ingroup jsystem-jkernel - * + * */ struct SArcDataInfo { /* 0x00 */ BE(u32) num_nodes; @@ -59,7 +65,7 @@ extern u32 sCurrentDirID__10JKRArchive; // JKRArchive::sCurrentDirID /** * @ingroup jsystem-jkernel - * + * */ class JKRArchive : public JKRFileLoader { public: @@ -192,9 +198,7 @@ public: u32 countFile() const { return mArcInfoBlock->num_file_entries; } s32 countDirectory() const { return mArcInfoBlock->num_nodes; } u8 getMountMode() const { return mMountMode; } - bool isFileEntry(u32 param_0) const { - return getFileAttribute(param_0) & 1; - } + bool isFileEntry(u32 param_0) const { return getFileAttribute(param_0) & 1; } public: /* 0x00 */ // vtable @@ -210,7 +214,36 @@ public: /* 0x54 */ const char* mStringTable; #if TARGET_PC + u32 getFileSize(SDIFileEntry* entry) const; + void* getOverlayData(SDIFileEntry* entry, u32* outSize); + bool getOverlayFileSize(SDIFileEntry* entry, u32* outSize) const; + static void notifyOverlayFilesChanged(); + +protected: void** mFileData; + + struct ArcOverlayResource { + u32 entryIndex; + u32 size; + u64 generation; + }; + + // Resource pointers remain valid until removed through the JKR resource APIs. + // That way, any pointers to old overlay data remain valid even when the overlay changed. + std::unordered_map mArcOverlayResources; + mutable std::unordered_map mActiveArcOverlayResources; + mutable std::string mArcOverlaysPath; + mutable std::unordered_map mIdxToPathMap; + mutable bool mArcOverlaysPathResolved = false; + + bool buildArcOverlaysPath() const; + void buildIndexToPathMap(u32 dirIndex, const std::string& currentPath) const; + bool getOverlayPath(SDIFileEntry* entry, std::string& path) const; + void* getActiveOverlayData(SDIFileEntry* entry, u32* outSize) const; + bool copyOverlayData(void* buffer, u32 bufferSize, SDIFileEntry* entry, u32* outSize); + bool getOverlayResourceSize(const void* data, u32* outSize) const; + bool removeOverlayResource(void* resource, bool freeResource); + void removeAllOverlayResources(); #endif protected: @@ -234,7 +267,7 @@ public: } else if (attr & JKRARCHIVE_ATTR_YAZ0) { return COMPRESSION_YAZ0; } else { - return COMPRESSION_YAY0; + return COMPRESSION_YAY0; } } @@ -242,7 +275,10 @@ public: static void setCurrentDirID(u32 dirID) { sCurrentDirID = dirID; } protected: - static u32 sCurrentDirID; + static DUSK_GAME_DATA u32 sCurrentDirID; +#if TARGET_PC + static std::atomic sArcOverlayGeneration; +#endif }; inline JKRCompression JKRConvertAttrToCompressionType(int attr) { @@ -261,8 +297,8 @@ inline bool JKRRemoveResource(void* resource, JKRFileLoader* fileLoader) { return JKRFileLoader::removeResource(resource, fileLoader); } -inline JKRArchive* JKRMountArchive(void* ptr, JKRHeap* heap, - JKRArchive::EMountDirection mountDirection) { +inline JKRArchive* JKRMountArchive( + void* ptr, JKRHeap* heap, JKRArchive::EMountDirection mountDirection) { return JKRArchive::mount(ptr, heap, mountDirection); } diff --git a/libs/JSystem/include/JSystem/JKernel/JKRDecomp.h b/libs/JSystem/include/JSystem/JKernel/JKRDecomp.h index 2e7ce0ef1c..f7b4581993 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRDecomp.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRDecomp.h @@ -61,9 +61,9 @@ public: static void decodeSZS(u8*, u8*, u32, u32); static JKRCompression checkCompressed(u8*); - static JKRDecomp* sDecompObject; - static OSMessage sMessageBuffer[8]; - static OSMessageQueue sMessageQueue; + static DUSK_GAME_DATA JKRDecomp* sDecompObject; + static DUSK_GAME_DATA OSMessage sMessageBuffer[8]; + static DUSK_GAME_DATA OSMessageQueue sMessageQueue; }; inline void JKRDecompress(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 dstLength) { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRDvdAramRipper.h b/libs/JSystem/include/JSystem/JKernel/JKRDvdAramRipper.h index 110827dc0b..20e8001e50 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRDvdAramRipper.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRDvdAramRipper.h @@ -55,9 +55,9 @@ public: static bool isErrorRetry() { return errorRetry; } // TODO: fix type - static JSUList sDvdAramAsyncList; - static u32 sSZSBufferSize; - static bool errorRetry; + static DUSK_GAME_DATA JSUList sDvdAramAsyncList; + static DUSK_GAME_DATA u32 sSZSBufferSize; + static DUSK_GAME_DATA bool errorRetry; }; inline JKRAramBlock *JKRDvdToAram(s32 entrynum, u32 p2, JKRExpandSwitch expSwitch, u32 p4, u32 p5, u32 *p6) { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRDvdFile.h b/libs/JSystem/include/JSystem/JKernel/JKRDvdFile.h index f32c8c6778..d5d439d363 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRDvdFile.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRDvdFile.h @@ -62,7 +62,7 @@ public: static JSUList& getDvdList() { return sDvdList; } private: - static JSUList sDvdList; + static DUSK_GAME_DATA JSUList sDvdList; }; #endif /* JKRDVDFILE_H */ diff --git a/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h b/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h index 0720605efb..aafecf063b 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRDvdRipper.h @@ -33,11 +33,11 @@ class JKRDvdFile; */ class JKRDvdRipper { public: - static JSUList sDvdAsyncList; - static u32 sSZSBufferSize; - static bool errorRetry; + static DUSK_GAME_DATA JSUList sDvdAsyncList; + static DUSK_GAME_DATA u32 sSZSBufferSize; + static DUSK_GAME_DATA bool errorRetry; #if TARGET_PC - static JKRHeap* sHeap; + static DUSK_GAME_DATA JKRHeap* sHeap; #endif enum EAllocDirection { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRFileLoader.h b/libs/JSystem/include/JSystem/JKernel/JKRFileLoader.h index 7e3e4cd1c5..cd1483ed1f 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRFileLoader.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRFileLoader.h @@ -53,8 +53,8 @@ public: static void setCurrentVolume(JKRFileLoader* fileLoader) { sCurrentVolume = fileLoader; } static JSUList& getVolumeList() { return sVolumeList; } - static JKRFileLoader* sCurrentVolume; - static JSUList sVolumeList; + static DUSK_GAME_DATA JKRFileLoader* sCurrentVolume; + static DUSK_GAME_DATA JSUList sVolumeList; }; inline bool JKRDetachResource(void* resource, JKRFileLoader* fileLoader) { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h index d1b27a0fd0..e23dca3c02 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h @@ -7,16 +7,17 @@ #include #include #include +#include class JKRHeap; typedef void (*JKRErrorHandler)(void*, u32, int); -extern u8 JKRValue_DEBUGFILL_NOTUSE; -extern u8 JKRValue_DEBUGFILL_NEW; -extern u8 JKRValue_DEBUGFILL_DELETE; +DUSK_GAME_EXTERN u8 JKRValue_DEBUGFILL_NOTUSE; +DUSK_GAME_EXTERN u8 JKRValue_DEBUGFILL_NEW; +DUSK_GAME_EXTERN u8 JKRValue_DEBUGFILL_DELETE; -extern s32 fillcheck_dispcount; -extern bool data_8074A8D0_debug; +DUSK_GAME_EXTERN s32 fillcheck_dispcount; +DUSK_GAME_EXTERN bool data_8074A8D0_debug; #if BIT_64 #define MEM_BLOCK_SIZE 0x20 @@ -194,26 +195,26 @@ public: } static void* getState_buf_(TState* state) { return &state->mBuf; } - static void* mCodeStart; - static void* mCodeEnd; - static void* mUserRamStart; - static void* mUserRamEnd; - static u32 mMemorySize; - static JKRAllocCallback sAllocCallback; - static JKRFreeCallback sFreeCallback; + static DUSK_GAME_DATA void* mCodeStart; + static DUSK_GAME_DATA void* mCodeEnd; + static DUSK_GAME_DATA void* mUserRamStart; + static DUSK_GAME_DATA void* mUserRamEnd; + static DUSK_GAME_DATA u32 mMemorySize; + static DUSK_GAME_DATA JKRAllocCallback sAllocCallback; + static DUSK_GAME_DATA JKRFreeCallback sFreeCallback; - static bool sDefaultFillFlag; + static DUSK_GAME_DATA bool sDefaultFillFlag; - static JKRHeap* sRootHeap; + static DUSK_GAME_DATA JKRHeap* sRootHeap; - static JKRHeap* sRootHeap2; + static DUSK_GAME_DATA JKRHeap* sRootHeap2; - static JKRHeap* sSystemHeap; + static DUSK_GAME_DATA JKRHeap* sSystemHeap; #if !TARGET_PC // Hide sCurrentHeap, we need to make it thread local. static JKRHeap* sCurrentHeap; #endif - static JKRErrorHandler mErrorHandler; + static DUSK_GAME_DATA JKRErrorHandler mErrorHandler; #if TARGET_PC void setName(const char* name); diff --git a/libs/JSystem/include/JSystem/JKernel/JKRThread.h b/libs/JSystem/include/JSystem/JKernel/JKRThread.h index 79217f3675..b77b40c74e 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRThread.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRThread.h @@ -141,7 +141,7 @@ public: static JKRThread* searchThread(OSThread* thread); static JSUList& getList() { return (JSUList&)sThreadList; } - static JSUList sThreadList; + static DUSK_GAME_DATA JSUList sThreadList; // static u8 sThreadList[12]; #if TARGET_PC @@ -155,7 +155,7 @@ public: virtual ~JKRIdleThread() { sThread = NULL; } virtual void* run() { while (true); } - static void* sThread; + static DUSK_GAME_DATA void* sThread; }; typedef void (*JKRThreadSwitch_PreCallback)(OSThread* current, OSThread* next); @@ -181,11 +181,11 @@ public: static u32 getTotalCount() { return sTotalCount; } private: - static JKRThreadSwitch* sManager; - static u32 sTotalCount; - static u64 sTotalStart; - static JKRThreadSwitch_PreCallback mUserPreCallback; - static JKRThreadSwitch_PostCallback mUserPostCallback; + static DUSK_GAME_DATA JKRThreadSwitch* sManager; + static DUSK_GAME_DATA u32 sTotalCount; + static DUSK_GAME_DATA u64 sTotalStart; + static DUSK_GAME_DATA JKRThreadSwitch_PreCallback mUserPreCallback; + static DUSK_GAME_DATA JKRThreadSwitch_PostCallback mUserPostCallback; private: /* 0x00 */ // vtable @@ -207,8 +207,8 @@ public: int check(); - static JSUList sTaskList; - static u8 sEndMesgQueue[32]; + static DUSK_GAME_DATA JSUList sTaskList; + static DUSK_GAME_DATA u8 sEndMesgQueue[32]; /* 0x7C */ JSULink mTaskLink; /* 0x8C */ u8 field_0x8c[0x94 - 0x8C]; diff --git a/libs/JSystem/include/JSystem/JMath/JMATrigonometric.h b/libs/JSystem/include/JSystem/JMath/JMATrigonometric.h index e51296ba3b..520f18810d 100644 --- a/libs/JSystem/include/JSystem/JMath/JMATrigonometric.h +++ b/libs/JSystem/include/JSystem/JMath/JMATrigonometric.h @@ -141,9 +141,9 @@ struct TAsinAcosTable { } }; -extern TSinCosTable<13, f32> sincosTable_; -extern TAtanTable<1024, f32> atanTable_; -extern TAsinAcosTable<1024, f32> asinAcosTable_; +DUSK_GAME_EXTERN TSinCosTable<13, f32> sincosTable_; +DUSK_GAME_EXTERN TAtanTable<1024, f32> atanTable_; +DUSK_GAME_EXTERN TAsinAcosTable<1024, f32> asinAcosTable_; inline f32 acosDegree(f32 x) { return asinAcosTable_.acosDegree(x); diff --git a/libs/JSystem/include/JSystem/JMath/JMath.h b/libs/JSystem/include/JSystem/JMath/JMath.h index 5d0263d669..8a7efc3f32 100644 --- a/libs/JSystem/include/JSystem/JMath/JMath.h +++ b/libs/JSystem/include/JSystem/JMath/JMath.h @@ -4,7 +4,7 @@ #include #include -#include "dusk/math.h" +#include "helpers/math.h" typedef f32 Mtx33[3][3]; typedef f32 Mtx23[2][3]; diff --git a/libs/JSystem/include/JSystem/JMessage/JMessage.h b/libs/JSystem/include/JSystem/JMessage/JMessage.h index 0b3d1c64c8..7218c7f4a9 100644 --- a/libs/JSystem/include/JSystem/JMessage/JMessage.h +++ b/libs/JSystem/include/JSystem/JMessage/JMessage.h @@ -6,7 +6,7 @@ #else #include #endif -#include "dusk/endian.h" +#include "helpers/endian.h" // Struct definitions might be wrong typedef struct bmg_header_t { diff --git a/libs/JSystem/include/JSystem/JMessage/data.h b/libs/JSystem/include/JSystem/JMessage/data.h index 0f7e4fda95..bfb3303056 100644 --- a/libs/JSystem/include/JSystem/JMessage/data.h +++ b/libs/JSystem/include/JSystem/JMessage/data.h @@ -81,8 +81,8 @@ struct data { static unsigned int getTagCode(u32 tag) { return tag & 0xFFFF; } static u8 getTagGroup(u32 tag) { return tag >> 0x10; } - static const BE(u32) ga4cSignature; - static const BE(u32) ga4cSignature_color; + static DUSK_GAME_DATA const BE(u32) ga4cSignature; + static DUSK_GAME_DATA const BE(u32) ga4cSignature_color; static const int gcTagBegin = '\x1A'; // All text Control Tags will begin with this character diff --git a/libs/JSystem/include/JSystem/JMessage/processor.h b/libs/JSystem/include/JSystem/JMessage/processor.h index cfb20c2c46..efd4c3629e 100644 --- a/libs/JSystem/include/JSystem/JMessage/processor.h +++ b/libs/JSystem/include/JSystem/JMessage/processor.h @@ -174,10 +174,14 @@ struct TProcessor { } void on_character(int iCharacter) { do_character(iCharacter); } +#if TARGET_PC + const char* on_message_limited(u16 u16Index) const; +#else const char* on_message_limited(u16 u16Index) const { JUT_ASSERT(482, pResourceCache_!=NULL); return pResourceCache_->getMessageText_messageIndex(u16Index); } +#endif bool on_setBegin_isReady_() const { return do_setBegin_isReady_(); } @@ -195,6 +199,10 @@ struct TProcessor { return 1; } +#if TARGET_PC + void* getMessageEntry_messageCode(u16 u16Code, u16 u16Index) const; + const char* getMessageText_messageCode(u16 u16Code, u16 u16Index) const; +#else void* getMessageEntry_messageCode(u16 u16Code, u16 u16Index) const { const TResource* pResource = getResource_groupID(u16Code); @@ -214,6 +222,7 @@ struct TProcessor { return pResourceCache_->getMessageText_messageEntry(pEntry); } +#endif void stack_pushCurrent_(const char* pszText) { oStack_.push(getCurrent()); diff --git a/libs/JSystem/include/JSystem/JMessage/resource.h b/libs/JSystem/include/JSystem/JMessage/resource.h index 6e4acdd6a7..cecfe9dbbb 100644 --- a/libs/JSystem/include/JSystem/JMessage/resource.h +++ b/libs/JSystem/include/JSystem/JMessage/resource.h @@ -144,7 +144,7 @@ struct TResourceContainer { destroyResource_color(); } - static JMessage::locale::parseCharacter_function sapfnParseCharacter_[5]; + static DUSK_GAME_DATA JMessage::locale::parseCharacter_function sapfnParseCharacter_[5]; /* 0x00 */ u8 encodingType_; /* 0x04 */ JMessage::locale::parseCharacter_function pfnParseCharacter_; diff --git a/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h b/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h index ec15c0430a..84fc657387 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h +++ b/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h @@ -63,13 +63,13 @@ public: JPABaseShape(u8 const*, JKRHeap*); void setGX(JPAEmitterWorkData*) const; - static GXBlendMode st_bm[3]; - static GXBlendFactor st_bf[10]; - static GXLogicOp st_lo[16]; - static GXCompare st_c[8]; - static GXAlphaOp st_ao[4]; - static GXTevColorArg st_ca[6][4]; - static GXTevAlphaArg st_aa[2][4]; + static DUSK_GAME_DATA GXBlendMode st_bm[3]; + static DUSK_GAME_DATA GXBlendFactor st_bf[10]; + static DUSK_GAME_DATA GXLogicOp st_lo[16]; + static DUSK_GAME_DATA GXCompare st_c[8]; + static DUSK_GAME_DATA GXAlphaOp st_ao[4]; + static DUSK_GAME_DATA GXTevColorArg st_ca[6][4]; + static DUSK_GAME_DATA GXTevAlphaArg st_aa[2][4]; GXBlendMode getBlendMode() const { return st_bm[pBsd->mBlendModeCfg & 0x03]; } GXBlendFactor getBlendSrc() const { return st_bf[(pBsd->mBlendModeCfg >> 2) & 0x0F]; } diff --git a/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h b/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h index c69ddc07cb..eb08e4ff9f 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h +++ b/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h @@ -4,7 +4,7 @@ #include "JSystem/JGeometry.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" struct JPAEmitterWorkData; diff --git a/libs/JSystem/include/JSystem/JParticle/JPAResource.h b/libs/JSystem/include/JSystem/JParticle/JPAResource.h index 07563fa73d..ba52564b95 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPAResource.h +++ b/libs/JSystem/include/JSystem/JParticle/JPAResource.h @@ -2,7 +2,7 @@ #define JPARESOURCE_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" class JKRHeap; struct JPAEmitterWorkData; diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/ctb.h b/libs/JSystem/include/JSystem/JStudio/JStudio/ctb.h index da03389c25..f01a170bde 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/ctb.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/ctb.h @@ -109,7 +109,7 @@ struct data { } }; - static const u32 ga4cSignature; + static DUSK_GAME_DATA const u32 ga4cSignature; }; struct TObject_TxyzRy : public TObject { diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/fvb-data.h b/libs/JSystem/include/JSystem/JStudio/JStudio/fvb-data.h index 8e82a0c031..e0a337a51a 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/fvb-data.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/fvb-data.h @@ -10,7 +10,7 @@ namespace JStudio { namespace fvb { namespace data { -extern const char ga4cSignature[4]; +DUSK_GAME_EXTERN const char ga4cSignature[4]; const int PARAGRAPH_DATA = 1; diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-data.h b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-data.h index 9dc95fae97..4956d1c150 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-data.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-data.h @@ -4,7 +4,7 @@ namespace JStudio { namespace data { - extern const char ga8cSignature[8]; + DUSK_GAME_EXTERN const char ga8cSignature[8]; } // namespace data } // namespace JStudio diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h index a23eed44e9..826e0948c1 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h @@ -6,7 +6,7 @@ #define m_PI_D 3.141592653589793 #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif namespace JStudio { diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-object.h b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-object.h index 2fe984853f..914ce66397 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-object.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-object.h @@ -91,7 +91,7 @@ struct TVariableValue { pOutput_ = (param_1 != NULL) ? param_1 : &soOutput_none_; } - static TOutput_none_ soOutput_none_; + static DUSK_GAME_DATA TOutput_none_ soOutput_none_; /* 0x00 */ f32 mValue; /* 0x04 */ u32 field_0x4; @@ -249,9 +249,9 @@ struct TAdaptor_actor : public TAdaptor { /* 0x10 */ TVariableValue mValue[14]; - static u32 const sauVariableValue_3_TRANSLATION_XYZ[3]; - static u32 const sauVariableValue_3_ROTATION_XYZ[3]; - static u32 const sauVariableValue_3_SCALING_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_TRANSLATION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_ROTATION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_SCALING_XYZ[3]; }; // Size: 0x128 struct TObject_actor : public TObject { @@ -267,8 +267,8 @@ struct TAdaptor_ambientLight : public TAdaptor { /* 0x10 */ TVariableValue mValue[4]; - static u32 const sauVariableValue_3_COLOR_RGB[3]; - static u32 const sauVariableValue_4_COLOR_RGBA[4]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_COLOR_RGB[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_4_COLOR_RGBA[4]; }; struct TObject_ambientLight : public TObject { @@ -299,9 +299,9 @@ struct TAdaptor_camera : public TAdaptor { /* 0x10 */ TVariableValue mValue[12]; - static u32 const sauVariableValue_3_POSITION_XYZ[3]; - static u32 const sauVariableValue_3_TARGET_POSITION_XYZ[3]; - static u32 const sauVariableValue_2_DISTANCE_NEAR_FAR[2]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_POSITION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_TARGET_POSITION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_2_DISTANCE_NEAR_FAR[2]; }; struct TObject_camera : public TObject { @@ -322,9 +322,9 @@ struct TAdaptor_fog : public TAdaptor { /* 0x10 */ TVariableValue mValue[6]; - static u32 const sauVariableValue_3_COLOR_RGB[3]; - static u32 const sauVariableValue_4_COLOR_RGBA[4]; - static u32 const sauVariableValue_2_RANGE_BEGIN_END[2]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_COLOR_RGB[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_4_COLOR_RGBA[4]; + static DUSK_GAME_DATA u32 const sauVariableValue_2_RANGE_BEGIN_END[2]; }; struct TObject_fog : public TObject { @@ -351,11 +351,11 @@ struct TAdaptor_light : public TAdaptor { /* 0x10 */ TVariableValue mValue[13]; - static u32 const sauVariableValue_3_COLOR_RGB[3]; - static u32 const sauVariableValue_4_COLOR_RGBA[4]; - static u32 const sauVariableValue_3_POSITION_XYZ[3]; - static u32 const sauVariableValue_3_TARGET_POSITION_XYZ[3]; - static u32 const sauVariableValue_2_DIRECTION_THETA_PHI[2]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_COLOR_RGB[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_4_COLOR_RGBA[4]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_POSITION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_TARGET_POSITION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_2_DIRECTION_THETA_PHI[2]; }; struct TObject_light : public TObject { @@ -396,13 +396,13 @@ struct TAdaptor_particle : public TAdaptor { /* 0x10 */ TVariableValue mValue[20]; - static u32 const sauVariableValue_3_TRANSLATION_XYZ[3]; - static u32 const sauVariableValue_3_ROTATION_XYZ[3]; - static u32 const sauVariableValue_3_SCALING_XYZ[3]; - static u32 const sauVariableValue_3_COLOR_RGB[3]; - static u32 const sauVariableValue_4_COLOR_RGBA[4]; - static u32 const sauVariableValue_3_COLOR1_RGB[3]; - static u32 const sauVariableValue_4_COLOR1_RGBA[4]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_TRANSLATION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_ROTATION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_SCALING_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_COLOR_RGB[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_4_COLOR_RGBA[4]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_COLOR1_RGB[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_4_COLOR1_RGBA[4]; }; struct TObject_particle : public TObject { @@ -440,7 +440,7 @@ struct TAdaptor_sound : public TAdaptor { /* 0x10 */ TVariableValue mValue[13]; - static u32 const sauVariableValue_3_POSITION_XYZ[3]; + static DUSK_GAME_DATA u32 const sauVariableValue_3_POSITION_XYZ[3]; }; // Size: 0x114 struct TObject_sound : public TObject { diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/stb-data.h b/libs/JSystem/include/JSystem/JStudio/JStudio/stb-data.h index b7e3cd0f7b..5da61e1575 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/stb-data.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/stb-data.h @@ -21,8 +21,8 @@ const int BLOCK_NONE = -1; // Used to expand a signed 24 int to a signed 32 int const u32 gu32Mask_TSequence_value_signExpansion = 0xFF000000; -extern const BE(u32) ga4cSignature; // 'STB/0' -extern const s32 gauDataSize_TEParagraph_data[8]; +DUSK_GAME_EXTERN const BE(u32) ga4cSignature; // 'STB/0' +DUSK_GAME_EXTERN const s32 gauDataSize_TEParagraph_data[8]; inline void toString_block(char* a5c, u32 arg1) { // from debug, todo diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio_JAudio2/control.h b/libs/JSystem/include/JSystem/JStudio/JStudio_JAudio2/control.h index effefaef18..884aeb9da5 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio_JAudio2/control.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio_JAudio2/control.h @@ -94,7 +94,7 @@ struct TAdaptor_sound : public JStudio::TAdaptor_sound { void set_bPermit_onExit_notEnd_(bool param_1) { field_0x11c = param_1; } - static TVVOSetValue_ saoVVOSetValue_[6]; + static DUSK_GAME_DATA TVVOSetValue_ saoVVOSetValue_[6]; /* 0x114 */ TCreateObject* pCreateObject_; /* 0x118 */ JAISoundHandle opJAISoundHandle_; diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio_JStage/control.h b/libs/JSystem/include/JSystem/JStudio/JStudio_JStage/control.h index 1e8331206b..050088722e 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio_JStage/control.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio_JStage/control.h @@ -131,8 +131,8 @@ struct TAdaptor_actor : public JStudio::TAdaptor_actor, public JStudio_JStage::T JStage::TActor* get_pJSG_() { return (JStage::TActor*) pJSGObject_; } - static const TVVOutputObject saoVVOutput_[]; - static const TVVOutput_ANIMATION_FRAME_ saoVVOutput_ANIMATION_FRAME_[]; + static DUSK_GAME_DATA const TVVOutputObject saoVVOutput_[]; + static DUSK_GAME_DATA const TVVOutput_ANIMATION_FRAME_ saoVVOutput_ANIMATION_FRAME_[]; /* 0x130 */ u32 field_0x130; /* 0x134 */ u32 field_0x134; @@ -187,7 +187,7 @@ struct TAdaptor_camera : public JStudio::TAdaptor_camera, public TAdaptor_object JStage::TCamera* get_pJSG_() { return (JStage::TCamera*)pJSGObject_; } - static TVVOutput saoVVOutput_[]; + static DUSK_GAME_DATA TVVOutput saoVVOutput_[]; /* 0x108 */ int field_0x108; /* 0x10C */ JStage::TObject* field_0x10c; @@ -211,7 +211,7 @@ struct TAdaptor_fog : public JStudio::TAdaptor_fog, public TAdaptor_object_ { JStage::TFog* get_pJSG_() { return (JStage::TFog*)pJSGObject_; } - static TVariableValueOutput_object_ saoVVOutput_[]; + static DUSK_GAME_DATA TVariableValueOutput_object_ saoVVOutput_[]; }; template @@ -285,7 +285,7 @@ struct TAdaptor_light : public JStudio::TAdaptor_light, public TAdaptor_object_ int field_0x11c; - static TVVOutput_direction_ saoVVOutput_direction_[6]; + static DUSK_GAME_DATA TVVOutput_direction_ saoVVOutput_direction_[6]; }; bool diff --git a/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h b/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h index 77c27d0530..07d5a29b69 100644 --- a/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h +++ b/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h @@ -2,7 +2,7 @@ #define JSUINPUTSTREAM_H #include "JSystem/JSupport/JSUIosBase.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jsupport diff --git a/libs/JSystem/include/JSystem/JUtility/JUTCacheFont.h b/libs/JSystem/include/JSystem/JUtility/JUTCacheFont.h index 2e089b7cc4..dabb561aa1 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTCacheFont.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTCacheFont.h @@ -55,12 +55,16 @@ public: void prepend(JUTCacheFont::TGlyphCacheInfo*); virtual ~JUTCacheFont(); +#if TARGET_PC + virtual void loadImage(int, GXTexMapID FONT_DRAW_CTX); +#else virtual void loadImage(int, GXTexMapID); +#endif virtual void setBlock(); void setPagingType(EPagingType type) { mPagingType = type; } - static u32 calcCacheSize(u32 param_0, int param_1) { return (ALIGN_NEXT(param_0, 0x20) + 0x40) * param_1; } + static u32 calcCacheSize(u32 param_0, int param_1) { return (ALIGN_NEXT(param_0, 0x20) + sizeof(TCachePage)) * param_1; } TGXTexObj* getTexObj(void* buffer) const { return &((TCachePage*)buffer)->mTexObj; } void delete_and_initialize() { deleteMemBlocks_CacheFont(); initialize_state(); } diff --git a/libs/JSystem/include/JSystem/JUtility/JUTConsole.h b/libs/JSystem/include/JSystem/JUtility/JUTConsole.h index 0f95feb2a1..1bc56f0d6d 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTConsole.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTConsole.h @@ -152,7 +152,7 @@ public: static JUTConsoleManager* const getManager() { return sManager; } - static JUTConsoleManager* sManager; + static DUSK_GAME_DATA JUTConsoleManager* sManager; #ifdef __MWERKS__ typedef JGadget::TLinkList ConsoleList; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTDbPrint.h b/libs/JSystem/include/JSystem/JUtility/JUTDbPrint.h index 14714df16e..67c7f8e89c 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTDbPrint.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTDbPrint.h @@ -40,7 +40,7 @@ public: void setCharColor(JUtility::TColor color) { mColor = color; }; - static JUTDbPrint* sDebugPrint; + static DUSK_GAME_DATA JUTDbPrint* sDebugPrint; private: /* 0x00 */ unk_print* mFirst; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTDirectPrint.h b/libs/JSystem/include/JSystem/JUtility/JUTDirectPrint.h index 14ed2c28b8..a1dd45efe2 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTDirectPrint.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTDirectPrint.h @@ -33,10 +33,10 @@ public: static JUTDirectPrint* getManager() { return sDirectPrint; } private: - static u8 sAsciiTable[128]; - static u32 sFontData[64]; - static u32 sFontData2[77]; - static JUTDirectPrint* sDirectPrint; + static DUSK_GAME_DATA u8 sAsciiTable[128]; + static DUSK_GAME_DATA u32 sFontData[64]; + static DUSK_GAME_DATA u32 sFontData2[77]; + static DUSK_GAME_DATA JUTDirectPrint* sDirectPrint; static u8 sDirectPrint_padding[4 /* padding */]; private: diff --git a/libs/JSystem/include/JSystem/JUtility/JUTException.h b/libs/JSystem/include/JSystem/JUtility/JUTException.h index 698a02ed44..b4504e68c0 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTException.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTException.h @@ -117,18 +117,18 @@ public: } private: - static OSMessageQueue sMessageQueue; - static const char* sCpuExpName[17]; - static JSUList sMapFileList; - static OSMessage sMessageBuffer[1]; - static JUTException* sErrorManager; - static JUTExceptionUserCallback sPreUserCallback; - static JUTExceptionUserCallback sPostUserCallback; - static void* sConsoleBuffer; - static u32 sConsoleBufferSize; - static JUTConsole* sConsole; - static u32 msr; - static u32 fpscr; + static DUSK_GAME_DATA OSMessageQueue sMessageQueue; + static DUSK_GAME_DATA const char* sCpuExpName[17]; + static DUSK_GAME_DATA JSUList sMapFileList; + static DUSK_GAME_DATA OSMessage sMessageBuffer[1]; + static DUSK_GAME_DATA JUTException* sErrorManager; + static DUSK_GAME_DATA JUTExceptionUserCallback sPreUserCallback; + static DUSK_GAME_DATA JUTExceptionUserCallback sPostUserCallback; + static DUSK_GAME_DATA void* sConsoleBuffer; + static DUSK_GAME_DATA u32 sConsoleBufferSize; + static DUSK_GAME_DATA JUTConsole* sConsole; + static DUSK_GAME_DATA u32 msr; + static DUSK_GAME_DATA u32 fpscr; private: /* 0x7C */ JUTExternalFB* mFrameMemory; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTFont.h b/libs/JSystem/include/JSystem/JUtility/JUTFont.h index 3c1cd0bf1f..0b262c0ac4 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTFont.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTFont.h @@ -3,7 +3,7 @@ #include "JSystem/JUtility/TColor.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC struct FontDrawContext { diff --git a/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h b/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h index 45e7227fe3..76e0780d9b 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTGamePad.h @@ -151,21 +151,21 @@ public: struct C3ButtonReset { C3ButtonReset() { mReset = false; } - static u32 sResetPattern; - static u32 sResetMaskPattern; - static callbackFn sCallback; - static void* sCallbackArg; - static OSTime sThreshold; - static s32 sResetOccurredPort; - static bool sResetOccurred; - static bool sResetSwitchPushing; + static DUSK_GAME_DATA u32 sResetPattern; + static DUSK_GAME_DATA u32 sResetMaskPattern; + static DUSK_GAME_DATA callbackFn sCallback; + static DUSK_GAME_DATA void* sCallbackArg; + static DUSK_GAME_DATA OSTime sThreshold; + static DUSK_GAME_DATA s32 sResetOccurredPort; + static DUSK_GAME_DATA bool sResetOccurred; + static DUSK_GAME_DATA bool sResetSwitchPushing; /* 0x0 */ bool mReset; }; // Size: 0x4 struct CStick { - static f32 sPressPoint; - static f32 sReleasePoint; + static DUSK_GAME_DATA f32 sPressPoint; + static DUSK_GAME_DATA f32 sReleasePoint; CStick() { clear(); } void clear(); @@ -187,9 +187,9 @@ public: struct CRumble { CRumble(JUTGamePad* pad) { clear(pad); } - static u32 sChannelMask[4]; - static u8 mStatus[4]; - static u32 mEnabled; + static DUSK_GAME_DATA u32 sChannelMask[4]; + static DUSK_GAME_DATA u8 mStatus[4]; + static DUSK_GAME_DATA u32 mEnabled; enum ERumble { VAL_0 = 0, @@ -237,18 +237,18 @@ public: mRumble.startPatternedRumble(data, rumble, length); } - static JSUList mPadList; - static bool mListInitialized; - static PADStatus mPadStatus[4]; - static CButton mPadButton[4]; - static CStick mPadMStick[4]; - static CStick mPadSStick[4]; - static EStickMode sStickMode; - static int sClampMode; - static u8 mPadAssign[4]; - static u32 sSuppressPadReset; - static s32 sAnalogMode; - static u32 sRumbleSupported; + static DUSK_GAME_DATA JSUList mPadList; + static DUSK_GAME_DATA bool mListInitialized; + static DUSK_GAME_DATA PADStatus mPadStatus[4]; + static DUSK_GAME_DATA CButton mPadButton[4]; + static DUSK_GAME_DATA CStick mPadMStick[4]; + static DUSK_GAME_DATA CStick mPadSStick[4]; + static DUSK_GAME_DATA EStickMode sStickMode; + static DUSK_GAME_DATA int sClampMode; + static DUSK_GAME_DATA u8 mPadAssign[4]; + static DUSK_GAME_DATA u32 sSuppressPadReset; + static DUSK_GAME_DATA s32 sAnalogMode; + static DUSK_GAME_DATA u32 sRumbleSupported; /* 0x18 */ CButton mButton; /* 0x48 */ CStick mMainStick; @@ -273,7 +273,7 @@ public: * */ struct JUTGamePadLongPress { - static JSUList sPatternList; + static DUSK_GAME_DATA JSUList sPatternList; void checkCallback(int port, u32 hold_time); u32 getMaskPattern() const { return mMaskPattern; } diff --git a/libs/JSystem/include/JSystem/JUtility/JUTGraphFifo.h b/libs/JSystem/include/JSystem/JUtility/JUTGraphFifo.h index 3ea6d2ec97..ababb1b83d 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTGraphFifo.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTGraphFifo.h @@ -32,8 +32,8 @@ public: #endif } - static JUTGraphFifo* sCurrentFifo; - static bool mGpStatus[5]; + static DUSK_GAME_DATA JUTGraphFifo* sCurrentFifo; + static DUSK_GAME_DATA bool mGpStatus[5]; private: /* 0x04 */ GXFifoObj* mFifo; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h b/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h index 6affae8ecb..6d4994d3f3 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h @@ -2,7 +2,7 @@ #define JUTNAMETAB_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jutility diff --git a/libs/JSystem/include/JSystem/JUtility/JUTPalette.h b/libs/JSystem/include/JSystem/JUtility/JUTPalette.h index 5d29005a92..8987c28f13 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTPalette.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTPalette.h @@ -3,7 +3,7 @@ #include -#include "dusk/endian.h" +#include "helpers/endian.h" enum JUTTransparency { UNK0, UNK1 }; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTProcBar.h b/libs/JSystem/include/JSystem/JUtility/JUTProcBar.h index c491641218..13f249213a 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTProcBar.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTProcBar.h @@ -102,7 +102,7 @@ public: static JUTProcBar* getManager() { return sManager; } - static JUTProcBar* sManager; + static DUSK_GAME_DATA JUTProcBar* sManager; private: /* 0x000 */ CTime mIdle; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTResFont.h b/libs/JSystem/include/JSystem/JUtility/JUTResFont.h index 29d8a77b92..5e1cfa0011 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTResFont.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTResFont.h @@ -2,7 +2,7 @@ #define JUTRESFONT_H #include "JSystem/JUtility/JUTFont.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" class JKRHeap; @@ -64,7 +64,7 @@ public: } static const int suAboutEncoding_ = 3; - static IsLeadByte_func const saoAboutEncoding_[suAboutEncoding_]; + static DUSK_GAME_DATA IsLeadByte_func const saoAboutEncoding_[suAboutEncoding_]; // some types uncertain, may need to be fixed /* 0x1C */ int mWidth; @@ -95,7 +95,7 @@ public: #endif }; -extern u8 const JUTResFONT_Ascfont_fix12[]; +DUSK_GAME_EXTERN u8 const JUTResFONT_Ascfont_fix12[]; extern u8 const JUTResFONT_Ascfont_fix16[]; #endif /* JUTRESFONT_H */ diff --git a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h index 6a7a8f9a0e..c4356b0bf9 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h @@ -3,8 +3,8 @@ #include #include -#include "dusk/endian.h" -#include "dusk/gx_helper.h" +#include "helpers/endian.h" +#include "helpers/gx_helper.h" class JUTPalette; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTVideo.h b/libs/JSystem/include/JSystem/JUtility/JUTVideo.h index dfc6fd0b6c..6e6edecd19 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTVideo.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTVideo.h @@ -59,9 +59,9 @@ public: #endif private: - static JUTVideo* sManager; - static OSTick sVideoLastTick; - static OSTick sVideoInterval; + static DUSK_GAME_DATA JUTVideo* sManager; + static DUSK_GAME_DATA OSTick sVideoLastTick; + static DUSK_GAME_DATA OSTick sVideoInterval; private: /* 0x04 */ GXRenderModeObj* mRenderObj; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTXfb.h b/libs/JSystem/include/JSystem/JUtility/JUTXfb.h index acc48739fc..358f559b73 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTXfb.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTXfb.h @@ -71,7 +71,7 @@ public: static JUTXfb* getManager() { return sManager; } private: - static JUTXfb* sManager; + static DUSK_GAME_DATA JUTXfb* sManager; private: /* 0x00 */ u8* mBuffer[3]; diff --git a/libs/JSystem/include/JSystem/JUtility/TColor.h b/libs/JSystem/include/JSystem/JUtility/TColor.h index d4a615b5b4..5ec7afa42a 100644 --- a/libs/JSystem/include/JSystem/JUtility/TColor.h +++ b/libs/JSystem/include/JSystem/JUtility/TColor.h @@ -2,7 +2,7 @@ #define TCOLOR_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" namespace JUtility { diff --git a/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp b/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp index 2cede2c49a..34e33bc03d 100644 --- a/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp +++ b/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp @@ -8,7 +8,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) { mMaterialNum = param_0.field_0x8; diff --git a/libs/JSystem/src/J2DGraph/J2DPane.cpp b/libs/JSystem/src/J2DGraph/J2DPane.cpp index 3ba9b6e85c..01ab0e5444 100644 --- a/libs/JSystem/src/J2DGraph/J2DPane.cpp +++ b/libs/JSystem/src/J2DGraph/J2DPane.cpp @@ -8,7 +8,7 @@ #include "JSystem/JSupport/JSURandomInputStream.h" #include "JSystem/JUtility/JUTResource.h" #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) { @@ -424,7 +424,7 @@ void J2DPane::resize(f32 x, f32 y) { place(box); } -JGeometry::TBox2 J2DPane::static_mBounds(0, 0, 0, 0); +DUSK_GAME_DATA JGeometry::TBox2 J2DPane::static_mBounds(0, 0, 0, 0); JGeometry::TBox2& J2DPane::getBounds() { static_mBounds = mBounds; diff --git a/libs/JSystem/src/J2DGraph/J2DPrint.cpp b/libs/JSystem/src/J2DGraph/J2DPrint.cpp index 69d71aa6c5..ac6bfb7099 100644 --- a/libs/JSystem/src/J2DGraph/J2DPrint.cpp +++ b/libs/JSystem/src/J2DGraph/J2DPrint.cpp @@ -7,11 +7,11 @@ #include #include -char* J2DPrint::mStrBuff; +DUSK_GAME_DATA char* J2DPrint::mStrBuff; static bool sStrBufInitialized; -size_t J2DPrint::mStrBuffSize; +DUSK_GAME_DATA size_t J2DPrint::mStrBuffSize; static u8 data_8045158C[4]; diff --git a/libs/JSystem/src/J2DGraph/J2DScreen.cpp b/libs/JSystem/src/J2DGraph/J2DScreen.cpp index c44859046d..603ab512f7 100644 --- a/libs/JSystem/src/J2DGraph/J2DScreen.cpp +++ b/libs/JSystem/src/J2DGraph/J2DScreen.cpp @@ -408,7 +408,7 @@ bool J2DScreen::isUsed(ResFONT const* p_font) { return J2DPane::isUsed(p_font); } -J2DDataManage* J2DScreen::mDataManage; +DUSK_GAME_DATA J2DDataManage* J2DScreen::mDataManage; void* J2DScreen::getNameResource(char const* resName) { void* res = JKRGetNameResource(resName, NULL); diff --git a/libs/JSystem/src/J2DGraph/J2DTevs.cpp b/libs/JSystem/src/J2DGraph/J2DTevs.cpp index 33a65dd273..bda5576cee 100644 --- a/libs/JSystem/src/J2DGraph/J2DTevs.cpp +++ b/libs/JSystem/src/J2DGraph/J2DTevs.cpp @@ -9,7 +9,7 @@ #ifdef __MWERKS__ #include #else -#include +#include #endif #include @@ -117,60 +117,60 @@ static void dummyVirtual(J2DMaterial* material) { block->getTevSwapModeTable(0); } -J2DTexCoordInfo const j2dDefaultTexCoordInfo[8] = { +DUSK_GAME_DATA J2DTexCoordInfo const j2dDefaultTexCoordInfo[8] = { {GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX2, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX3, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX4, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX5, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX6, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX7, GX_IDENTITY, 0}, }; -J2DTexMtxInfo const j2dDefaultTexMtxInfo = {1, 1, 255, 255, {0.5f, 0.5f, +DUSK_GAME_DATA J2DTexMtxInfo const j2dDefaultTexMtxInfo = {1, 1, 255, 255, {0.5f, 0.5f, 0.0f}, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f}; -J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo = {{0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f}, 1}; +DUSK_GAME_DATA J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo = {{0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f}, 1}; -J2DTevStageInfo const j2dDefaultTevStageInfo = { +DUSK_GAME_DATA J2DTevStageInfo const j2dDefaultTevStageInfo = { 4, GX_CC_RASC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV, GX_CA_RASA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV}; -const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = { +DUSK_GAME_DATA const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = { GX_INDTEXSTAGE0, GX_ITB_NONE, GX_ITB_NONE, GX_ITM_OFF, GX_ITW_OFF, GX_ITW_OFF, 0, 0, GX_ITBA_OFF, }; -const GXColor j2dDefaultColInfo = {255, 255, 255, 255}; +DUSK_GAME_DATA const GXColor j2dDefaultColInfo = {255, 255, 255, 255}; -const J2DTevOrderInfo j2dDefaultTevOrderInfoNull = { +DUSK_GAME_DATA const J2DTevOrderInfo j2dDefaultTevOrderInfoNull = { GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL, 0}; -const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = { +DUSK_GAME_DATA const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = { GX_TEXCOORD_NULL, GX_TEXMAP_NULL, }; -const GXColorS10 j2dDefaultTevColor = {255, 255, 255, 255}; +DUSK_GAME_DATA const GXColorS10 j2dDefaultTevColor = {255, 255, 255, 255}; -const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = { +DUSK_GAME_DATA const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = { GX_ITS_1, GX_ITS_1, }; -const GXColor j2dDefaultTevKColor = {255, 255, 255, 255}; +DUSK_GAME_DATA const GXColor j2dDefaultTevKColor = {255, 255, 255, 255}; -const J2DTevSwapModeInfo j2dDefaultTevSwapMode = {GX_TEV_SWAP0, GX_TEV_SWAP0, 0, 0}; +DUSK_GAME_DATA const J2DTevSwapModeInfo j2dDefaultTevSwapMode = {GX_TEV_SWAP0, GX_TEV_SWAP0, 0, 0}; -const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = { +DUSK_GAME_DATA const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = { GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA}; -const J2DBlendInfo j2dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, +DUSK_GAME_DATA const J2DBlendInfo j2dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP}; -const u8 j2dDefaultPEBlockDither = 0; +DUSK_GAME_DATA const u8 j2dDefaultPEBlockDither = 0; -const J2DColorChanInfo j2dDefaultColorChanInfo = {0, 3, 0, 0}; +DUSK_GAME_DATA const J2DColorChanInfo j2dDefaultColorChanInfo = {0, 3, 0, 0}; -const u8 j2dDefaultTevSwapTableID = 0x1B; +DUSK_GAME_DATA const u8 j2dDefaultTevSwapTableID = 0x1B; -const u16 j2dDefaultAlphaCmp = 0x00E7; +DUSK_GAME_DATA const u16 j2dDefaultAlphaCmp = 0x00E7; diff --git a/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp b/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp index fe4c5df9e6..284d7ea220 100644 --- a/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp +++ b/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp @@ -3,7 +3,7 @@ #include "JSystem/J2DGraph/J2DWindowEx.h" #include "JSystem/JUtility/JUTTexture.h" #include "JSystem/JSupport/JSURandomInputStream.h" -#include "dusk/endian.h" +#include "helpers/endian.h" struct J2DWindowExDef { BE(u32) field_0x0[4]; diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DJoint.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DJoint.cpp index 4091a3b7a1..a943940d84 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DJoint.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DJoint.cpp @@ -22,9 +22,9 @@ void J3DMtxCalcJ3DSysInitMaya::init(Vec const& scale, Mtx const& mtx) { JMAMTXApplyScale(mtx, J3DSys::mCurrentMtx, scale.x, scale.y, scale.z); } -J3DMtxBuffer* J3DMtxCalc::mMtxBuffer; +DUSK_GAME_DATA J3DMtxBuffer* J3DMtxCalc::mMtxBuffer; -J3DJoint* J3DMtxCalc::mJoint; +DUSK_GAME_DATA J3DJoint* J3DMtxCalc::mJoint; void J3DMtxCalcCalcTransformBasic::calcTransform(J3DTransformInfo const& transInfo) { J3DJoint* joint = J3DMtxCalc::getJoint(); @@ -189,7 +189,7 @@ void J3DJoint::entryIn() { } } -J3DMtxCalc* J3DJoint::mCurrentMtxCalc; +DUSK_GAME_DATA J3DMtxCalc* J3DJoint::mCurrentMtxCalc; void J3DJoint::recursiveCalc() { J3DMtxCalc* prevMtxCalc = NULL; diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp index 8e111428cc..dfb9050cbd 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp @@ -8,7 +8,10 @@ #include "JSystem/J3DGraphBase/J3DShapeMtx.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/JKernel/JKRHeap.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif #define J3D_ASSERTMSG(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) #define J3D_WARN1(LINE, MSG, ARG1) JUT_WARN(LINE, MSG, ARG1) @@ -26,6 +29,7 @@ void J3DModel::initialize() { MTXIdentity(mBaseTransformMtx); MTXIdentity(mInternalView); + IF_DUSK(MTXIdentity(mPresentationBase)); mMtxBuffer = NULL; mMatPacket = NULL; @@ -98,12 +102,32 @@ s32 J3DModel::entryModelData(J3DModelData* pModelData, u32 mdlFlags, u32 mtxNum) } #if TARGET_PC -void J3DModel::interp_callback(bool isSimFrame, void* pUserWork) { +void J3DModel::interp_callback(void* pUserWork) { J3DModel* i_this = static_cast(pUserWork); - if (!isSimFrame) { - i_this->calcMaterial(); - i_this->diff(); + i_this->calcMaterial(); + i_this->diff(); +} + +void J3DModel::setAnmMtx(int jointNo, Mtx m) { + mMtxBuffer->setAnmMtx(jointNo, m); + dusk::interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); +} + +void J3DModel::calc_presentation_base_mtx() { + Mtx identity; + MTXIdentity(identity); + J3DCalcViewBaseMtx(identity, mBaseScale, mBaseTransformMtx, mPresentationBase); + dusk::interp::record_final_mtx(mPresentationBase); + prepare_presentation_view(); +} + +void J3DModel::prepare_presentation_view() { + Mtx replacement; + MtxP presentationBase = mPresentationBase; + if (dusk::interp::lookup_replacement(mPresentationBase, replacement)) { + presentationBase = replacement; } + MTXConcat(j3dSys.getViewMtx(), presentationBase, mInternalView); } #endif @@ -462,11 +486,11 @@ void J3DModel::calc() { #ifdef TARGET_PC for (u16 i = 0; i < mModelData->getJointNum(); ++i) { - dusk::frame_interp::record_final_mtx(getAnmMtx(i)); + dusk::interp::record_final_mtx(getAnmMtx(i)); } for (u16 i = 0; i < mModelData->getWEvlpMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(getWeightAnmMtx(i)); + dusk::interp::record_final_mtx(getWeightAnmMtx(i)); } #endif } @@ -497,8 +521,9 @@ void J3DModel::entry() { } #if TARGET_PC - if (mModelData->needsInterpCallBack()) - dusk::frame_interp::add_interpolation_callback(&J3DModel::interp_callback, this); + if (mModelData->needsInterpCallBack()) { + dusk::interp::add_interpolation_callback(&J3DModel::interp_callback, this); + } #endif } @@ -508,18 +533,20 @@ void J3DModel::viewCalc() { if (getModelData()->checkFlag(0x10)) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (isCpuSkinningOn()) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (checkFlag(J3DMdlFlag_SkinPosCpu)) { @@ -541,15 +568,6 @@ void J3DModel::viewCalc() { DCStoreRange(getNrmMtxPtr(), mModelData->getDrawMtxNum() * sizeof(Mtx33)); } -#ifdef TARGET_PC - Mtx* drawMtx = getDrawMtxPtr(); - if (drawMtx != J3DMtxBuffer::sNoUseDrawMtxPtr) { - for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(drawMtx[i]); - } - } -#endif - prepareShapePackets(); } diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DMtxBuffer.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DMtxBuffer.cpp index a1765acce4..a2c0a7f2d6 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DMtxBuffer.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DMtxBuffer.cpp @@ -6,13 +6,13 @@ #include "JSystem/J3DGraphLoader/J3DModelLoader.h" #include "JSystem/JKernel/JKRHeap.h" -Mtx J3DMtxBuffer::sNoUseDrawMtx; +DUSK_GAME_DATA Mtx J3DMtxBuffer::sNoUseDrawMtx; -Mtx33 J3DMtxBuffer::sNoUseNrmMtx; +DUSK_GAME_DATA Mtx33 J3DMtxBuffer::sNoUseNrmMtx; -Mtx* J3DMtxBuffer::sNoUseDrawMtxPtr = &J3DMtxBuffer::sNoUseDrawMtx; +DUSK_GAME_DATA Mtx* J3DMtxBuffer::sNoUseDrawMtxPtr = &J3DMtxBuffer::sNoUseDrawMtx; -Mtx33* J3DMtxBuffer::sNoUseNrmMtxPtr = &J3DMtxBuffer::sNoUseNrmMtx; +DUSK_GAME_DATA Mtx33* J3DMtxBuffer::sNoUseNrmMtxPtr = &J3DMtxBuffer::sNoUseNrmMtx; // force .sdata2 order static f32 dummy1() { diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DSkinDeform.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DSkinDeform.cpp index 76002c0a38..e262797a25 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DSkinDeform.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DSkinDeform.cpp @@ -79,9 +79,9 @@ J3DSkinDeform::J3DSkinDeform() { mSkinNList = NULL; } -BE(u16)* J3DSkinDeform::sWorkArea_WEvlpMixMtx[1024]; +DUSK_GAME_DATA BE(u16)* J3DSkinDeform::sWorkArea_WEvlpMixMtx[1024]; -BE(f32)* J3DSkinDeform::sWorkArea_WEvlpMixWeight[1024]; +DUSK_GAME_DATA BE(f32)* J3DSkinDeform::sWorkArea_WEvlpMixWeight[1024]; void J3DSkinDeform::initSkinInfo(J3DModelData* pModelData) { J3D_ASSERT_NULLPTR(322, pModelData != NULL); @@ -194,7 +194,7 @@ void J3DSkinDeform::initSkinInfo(J3DModelData* pModelData) { } } -u16 J3DSkinDeform::sWorkArea_MtxReg[1024]; +DUSK_GAME_DATA u16 J3DSkinDeform::sWorkArea_MtxReg[1024]; int J3DSkinDeform::initMtxIndexArray(J3DModelData* pModelData) { J3D_ASSERT_NULLPTR(507, pModelData != NULL); diff --git a/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp b/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp index c533face96..2d175ff871 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp @@ -8,7 +8,10 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" #include "JSystem/JKernel/JKRHeap.h" -#include "tracy/Tracy.hpp" + +#if TARGET_PC +#include +#endif void J3DDrawBuffer::calcZRatio() { mZRatio = (mZFar - mZNear) / (f32)mEntryTableSize; @@ -205,17 +208,17 @@ int J3DDrawBuffer::entryImm(J3DPacket* pPacket, u16 index) { return 1; } -J3DDrawBuffer::sortFunc J3DDrawBuffer::sortFuncTable[6] = { +DUSK_GAME_DATA J3DDrawBuffer::sortFunc J3DDrawBuffer::sortFuncTable[6] = { &J3DDrawBuffer::entryMatSort, &J3DDrawBuffer::entryMatAnmSort, &J3DDrawBuffer::entryZSort, &J3DDrawBuffer::entryModelSort, &J3DDrawBuffer::entryInvalidSort, &J3DDrawBuffer::entryNonSort, }; -J3DDrawBuffer::drawFunc J3DDrawBuffer::drawFuncTable[2] = { +DUSK_GAME_DATA J3DDrawBuffer::drawFunc J3DDrawBuffer::drawFuncTable[2] = { &J3DDrawBuffer::drawHead, &J3DDrawBuffer::drawTail, }; -int J3DDrawBuffer::entryNum; +DUSK_GAME_DATA int J3DDrawBuffer::entryNum; void J3DDrawBuffer::draw() const { J3D_ASSERT_RANGE(411, mDrawMode < J3DDrawBufDrawMode_MAX); diff --git a/libs/JSystem/src/J3DGraphBase/J3DGD.cpp b/libs/JSystem/src/J3DGraphBase/J3DGD.cpp index eb89fc3b81..74e5c2c759 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DGD.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DGD.cpp @@ -6,7 +6,10 @@ #include "JSystem/J3DGraphBase/J3DGD.h" #include "JSystem/J3DGraphBase/J3DFifo.h" -#include + +#if TARGET_PC +#include "dusk/logging.h" +#endif void J3DGDSetGenMode(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm) { diff --git a/libs/JSystem/src/J3DGraphBase/J3DMatBlock.cpp b/libs/JSystem/src/J3DGraphBase/J3DMatBlock.cpp index f401f16c43..dada6a19e8 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DMatBlock.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DMatBlock.cpp @@ -246,22 +246,37 @@ s32 J3DTexGenBlockBasic::countDLSize() { } s32 J3DTevBlockPatched::countDLSize() { +#if TARGET_PC + return 2048; +#endif return 560; } s32 J3DTevBlock1::countDLSize() { +#if TARGET_PC + return 256; +#endif return 105; } s32 J3DTevBlock2::countDLSize() { +#if TARGET_PC + return 512; +#endif return 335; } s32 J3DTevBlock4::countDLSize() { +#if TARGET_PC + return 1024; +#endif return 580; } s32 J3DTevBlock16::countDLSize() { +#if TARGET_PC + return 2048; +#endif return 1000; } diff --git a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp index 48d4731ed9..27043184ee 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp @@ -218,9 +218,6 @@ void J3DMaterial::makeSharedDisplayList() { void J3DMaterial::load() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (!j3dSys.checkFlag(2)) { loadNBTScale(*mTexGenBlock->getNBTScale()); } @@ -228,9 +225,6 @@ void J3DMaterial::load() { void J3DMaterial::loadSharedDL() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (!j3dSys.checkFlag(2)) { mSharedDLObj->callDL(); loadNBTScale(*mTexGenBlock->getNBTScale()); @@ -405,9 +399,6 @@ void J3DPatchedMaterial::makeSharedDisplayList() {} void J3DPatchedMaterial::load() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (j3dSys.checkFlag(2)) { return; } @@ -415,9 +406,6 @@ void J3DPatchedMaterial::load() { void J3DPatchedMaterial::loadSharedDL() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (!j3dSys.checkFlag(0x02)) mSharedDLObj->callDL(); } @@ -436,9 +424,6 @@ void J3DLockedMaterial::makeSharedDisplayList() {} void J3DLockedMaterial::load() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (j3dSys.checkFlag(2)) { return; } @@ -446,9 +431,6 @@ void J3DLockedMaterial::load() { void J3DLockedMaterial::loadSharedDL() { j3dSys.setMaterialMode(mMaterialMode); -#if TARGET_PC - mTevBlock->loadTexture(); -#endif if (!j3dSys.checkFlag(0x02)) mSharedDLObj->callDL(); } diff --git a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp index 9e28a7f7cb..354dee4130 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp @@ -1,15 +1,18 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include -#include +#include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphAnimator/J3DModel.h" #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" -#include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DShapeMtx.h" #include "JSystem/JKernel/JKRHeap.h" +#include +#include #include "global.h" -#include "tracy/Tracy.hpp" + +#if TARGET_PC +#include +#endif J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) { mMaxSize = ALIGN_NEXT(maxSize, 0x20); @@ -68,9 +71,9 @@ void J3DDisplayListObj::callDL() const { GXCallDisplayList(mpDisplayList[0], mSize); } -GDLObj J3DDisplayListObj::sGDLObj; +DUSK_GAME_DATA GDLObj J3DDisplayListObj::sGDLObj; -s32 J3DDisplayListObj::sInterruptFlag; +DUSK_GAME_DATA s32 J3DDisplayListObj::sInterruptFlag; void J3DDisplayListObj::beginDL() { swapBuffer(); @@ -209,9 +212,6 @@ bool J3DMatPacket::isSame(J3DMatPacket* pOther) const { void J3DMatPacket::draw() { ZoneScoped; -#if TARGET_PC - j3dSys.setTexture(mpTexture); -#endif mpMaterial->load(); #if DEBUG && TARGET_PC @@ -225,9 +225,6 @@ void J3DMatPacket::draw() { callDL(); J3DShapePacket* packet = getShapePacket(); -#if TARGET_PC - packet->mpModel->getVertexBuffer()->setArray(); -#endif packet->getShape()->loadPreDrawSetting(); while (packet != NULL) { @@ -339,6 +336,11 @@ int J3DShapePacket::newDifferedDisplayList(u32 diffFlags) { void J3DShapePacket::prepareDraw() const { mpModel->getVertexBuffer()->setArray(); j3dSys.setModel(mpModel); +#if TARGET_PC + if (mpModel->getMtxCalcMode() == 2) { + mpModel->prepare_presentation_view(); + } +#endif j3dSys.setShapePacket((J3DShapePacket*)this); J3DShapeMtx::setLODFlag(mpModel->checkFlag(J3DMdlFlag_EnableLOD) != 0); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp index 4b407d1e05..07ed23ed4a 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp @@ -1,15 +1,17 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/J3DGraphBase/J3DShape.h" - -#include -#include -#include -#include "JSystem/J3DGraphBase/J3DFifo.h" #include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DVertex.h" +#include "JSystem/J3DGraphBase/J3DFifo.h" +#include + +#if TARGET_PC #include "JSystem/JKernel/JKRHeap.h" -#include "tracy/Tracy.hpp" + +#include +#include +#endif void J3DGDSetVtxAttrFmtv(GXVtxFmt, GXVtxAttrFmtList const*, bool); void J3DFifoLoadPosMtxImm(Mtx, u32); @@ -289,7 +291,7 @@ void J3DShape::makeVcdVatCmd() { OSRestoreInterrupts(sInterruptFlag); } -void* J3DShape::sOldVcdVatCmd; +DUSK_GAME_DATA void* J3DShape::sOldVcdVatCmd; void J3DShape::loadCurrentMtx() const { mCurrentMtx.load(); @@ -304,7 +306,7 @@ void J3DShape::loadPreDrawSetting() const { mCurrentMtx.load(); } -bool J3DShape::sEnvelopeFlag; +DUSK_GAME_DATA bool J3DShape::sEnvelopeFlag; void J3DShape::setArrayAndBindPipeline() const { J3DShapeMtx::setCurrentPipeline((mFlags & 0x1C) >> 2); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp index d9af135999..ae9021f76c 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp @@ -6,13 +6,16 @@ #include "JSystem/J3DGraphBase/J3DMatBlock.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "dusk/frame_interpolation.h" -u16 J3DShapeMtx::sMtxLoadCache[10]; +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif -#ifdef TARGET_PC +DUSK_GAME_DATA u16 J3DShapeMtx::sMtxLoadCache[10]; + +#if TARGET_PC static void J3DFrameInterpConcat(MtxP lhs, MtxP rhs, Mtx out) { - if (!dusk::frame_interp::lookup_concat_replacement(lhs, rhs, out)) { + if (!dusk::interp::lookup_concat_replacement(lhs, rhs, out)) { MTXConcat(lhs, rhs, out); } } @@ -54,42 +57,42 @@ void J3DShapeMtx::loadMtxIndx_PNCPU(int slot, u16 indx) const { J3DFifoLoadNrmMtxImm(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3); } -J3DShapeMtx_LoadFunc J3DShapeMtx::sMtxLoadPipeline[4] = { +DUSK_GAME_DATA J3DShapeMtx_LoadFunc J3DShapeMtx::sMtxLoadPipeline[4] = { &J3DShapeMtx::loadMtxIndx_PNGP, &J3DShapeMtx::loadMtxIndx_PCPU, &J3DShapeMtx::loadMtxIndx_NCPU, &J3DShapeMtx::loadMtxIndx_PNCPU, }; -J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadPipeline[4] = { +DUSK_GAME_DATA J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadPipeline[4] = { &J3DShapeMtxConcatView::loadMtxConcatView_PNGP, &J3DShapeMtxConcatView::loadMtxConcatView_PCPU, &J3DShapeMtxConcatView::loadMtxConcatView_NCPU, &J3DShapeMtxConcatView::loadMtxConcatView_PNCPU, }; -J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadLODPipeline[4] = { +DUSK_GAME_DATA J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadLODPipeline[4] = { &J3DShapeMtxConcatView::loadMtxConcatView_PNGP_LOD, &J3DShapeMtxConcatView::loadMtxConcatView_PCPU, &J3DShapeMtxConcatView::loadMtxConcatView_NCPU, &J3DShapeMtxConcatView::loadMtxConcatView_PNCPU, }; -u32 J3DShapeMtx::sCurrentPipeline; +DUSK_GAME_DATA u32 J3DShapeMtx::sCurrentPipeline; -u8* J3DShapeMtx::sCurrentScaleFlag; +DUSK_GAME_DATA u8* J3DShapeMtx::sCurrentScaleFlag; -bool J3DShapeMtx::sNBTFlag; +DUSK_GAME_DATA bool J3DShapeMtx::sNBTFlag; -bool J3DShapeMtx::sLODFlag; +DUSK_GAME_DATA bool J3DShapeMtx::sLODFlag; -u32 J3DShapeMtx::sTexMtxLoadType; +DUSK_GAME_DATA u32 J3DShapeMtx::sTexMtxLoadType; -MtxP J3DShapeMtxConcatView::sMtxPtrTbl[2]; +DUSK_GAME_DATA MtxP J3DShapeMtxConcatView::sMtxPtrTbl[2]; -J3DTexGenBlock* J3DDifferedTexMtx::sTexGenBlock; +DUSK_GAME_DATA J3DTexGenBlock* J3DDifferedTexMtx::sTexGenBlock; -J3DTexMtxObj* J3DDifferedTexMtx::sTexMtxObj; +DUSK_GAME_DATA J3DTexMtxObj* J3DDifferedTexMtx::sTexMtxObj; void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) { static Mtx qMtx = { diff --git a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp index b4598bfa7a..0f5beb9db5 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp @@ -1,27 +1,32 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include "JSystem/J3DGraphBase/J3DFifo.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "dusk/gx_helper.h" +#include "JSystem/J3DGraphBase/J3DFifo.h" #include "global.h" -#include "tracy/Tracy.hpp" -J3DSys j3dSys; +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "helpers/gx_helper.h" -Mtx J3DSys::mCurrentMtx; +#include +#endif -Vec J3DSys::mCurrentS; +DUSK_GAME_DATA J3DSys j3dSys; -Vec J3DSys::mParentS; +DUSK_GAME_DATA Mtx J3DSys::mCurrentMtx; -J3DTexCoordScaleInfo J3DSys::sTexCoordScaleTable[8]; +DUSK_GAME_DATA Vec J3DSys::mCurrentS; + +DUSK_GAME_DATA Vec J3DSys::mParentS; + +DUSK_GAME_DATA J3DTexCoordScaleInfo J3DSys::sTexCoordScaleTable[8]; #if TARGET_PC // Original game bug, array is too small. -static u8 NullTexData[0x20] ATTRIBUTE_ALIGN(32) = {0}; +ATTRIBUTE_ALIGN(32) static u8 NullTexData[0x20] = {0}; #else -static u8 NullTexData[0x10] ATTRIBUTE_ALIGN(32) = {0}; +ATTRIBUTE_ALIGN(32) static u8 NullTexData[0x10] = {0}; #endif static Mtx j3dIdentityMtx = { @@ -35,7 +40,7 @@ static Mtx23 IndMtx = { 0.0f, 0.5f, 0.0f, }; -u32 j3dDefaultViewNo; +DUSK_GAME_DATA u32 j3dDefaultViewNo; static GXColor ColorBlack = {0x00, 0x00, 0x00, 0x00}; @@ -370,3 +375,13 @@ void J3DSys::reinitPixelProc() { GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GXSetZCompLoc(GX_TRUE); } + +#if TARGET_PC +void J3DSys::setViewMtx(const Mtx m) { + Mtx patched; + if (dusk::interp::lookup_replacement(m, patched)) { + m = patched; + } + MTXCopy(m, mViewMtx); +} +#endif diff --git a/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp b/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp index 719976770b..b43663731d 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp @@ -11,6 +11,10 @@ #include "JSystem/J3DGraphBase/J3DTransform.h" #include "global.h" +#if TARGET_PC +#include "aurora/lib/gfx/texture.hpp" +#endif + static void J3DGDLoadTexMtxImm(f32 (*)[4], u32, GXTexMtxType); static void J3DGDLoadPostTexMtxImm(f32 (*)[4], u32); @@ -280,6 +284,46 @@ u16 getTexNoReg(void* pDL) { return var_r31 & 0xFFFFFF; } +#if TARGET_PC +inline void J3DGDWrite_u64(u64 data) { + __GDWrite((u8)((data >> 56) & 0xFF)); + __GDWrite((u8)((data >> 48) & 0xFF)); + __GDWrite((u8)((data >> 40) & 0xFF)); + __GDWrite((u8)((data >> 32) & 0xFF)); + __GDWrite((u8)((data >> 24) & 0xFF)); + __GDWrite((u8)((data >> 16) & 0xFF)); + __GDWrite((u8)((data >> 8) & 0xFF)); + __GDWrite((u8)((data >> 0) & 0xFF)); +} + +void J3D_emit_loaded_texobj_metadata(const GXTexObj_& obj, GXTexMapID id) { + GDOverflowCheck(38); + J3DGDWrite_u8(GX_AURORA); + J3DGDWrite_u16(GX_AURORA_LOAD_TEXOBJ); + J3DGDWrite_u8(static_cast(id)); + J3DGDWrite_u64(reinterpret_cast(obj.data)); + J3DGDWrite_u32(obj.width()); + J3DGDWrite_u32(obj.height()); + J3DGDWrite_u32(obj.format()); + J3DGDWrite_u32(static_cast(obj.tlut)); + J3DGDWrite_u8(static_cast(obj.has_mips())); + J3DGDWrite_u32(obj.texObjId); + J3DGDWrite_u32(obj.texDataVersion); +} + +void J3D_emit_loaded_tlut_metadata(const GXTlutObj_& obj, u32 idx) { + GDOverflowCheck(22); + J3DGDWrite_u8(GX_AURORA); + J3DGDWrite_u16(GX_AURORA_LOAD_TLUT); + J3DGDWrite_u8(static_cast(idx)); + J3DGDWrite_u64(reinterpret_cast(obj.data)); + J3DGDWrite_u32(static_cast(obj.format)); + J3DGDWrite_u16(obj.numEntries); + J3DGDWrite_u32(obj.tlutObjId); + J3DGDWrite_u32(obj.tlutDataVersion); +} +#endif + void loadTexNo(u32 param_0, const u16& texNo) { ResTIMG* resTIMG = j3dSys.getTexture()->getResTIMG(texNo); J3D_ASSERT_NULLPTR(462, resTIMG != NULL); @@ -287,6 +331,15 @@ void loadTexNo(u32 param_0, const u16& texNo) { J3DSys::sTexCoordScaleTable[param_0].field_0x00 = (u16)resTIMG->width; J3DSys::sTexCoordScaleTable[param_0].field_0x02 = (u16)resTIMG->height; +#if TARGET_PC + J3D_emit_loaded_texobj_metadata( + *reinterpret_cast(j3dSys.getTexture()->getTexObj(texNo)), GXTexMapID(param_0)); + if (resTIMG->indexTexture) { + J3D_emit_loaded_tlut_metadata( + *reinterpret_cast(j3dSys.getTexture()->getTlutObj(texNo)), param_0); + } +#endif + GDOverflowCheck(0x14); J3DGDSetTexImgPtr(GXTexMapID(param_0), (u8*)resTIMG + resTIMG->imageOffset); J3DGDSetTexImgAttr(GXTexMapID(param_0), resTIMG->width, resTIMG->height, GXTexFmt(resTIMG->format & 0x0f)); @@ -315,7 +368,7 @@ void loadNBTScale(J3DNBTScale& NBTScale) { } } -const J3DLightInfo j3dDefaultLightInfo = { +DUSK_GAME_DATA const J3DLightInfo j3dDefaultLightInfo = { 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0xff, 0xff, 0xff, 0xff, @@ -323,14 +376,14 @@ const J3DLightInfo j3dDefaultLightInfo = { 1.0f, 0.0f, 0.0f, }; -J3DTexCoordInfo const j3dDefaultTexCoordInfo[8] = { +DUSK_GAME_DATA J3DTexCoordInfo const j3dDefaultTexCoordInfo[8] = { {GX_MTX2x4, GX_TG_TEX0, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX1, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX2, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX3, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX4, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX5, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX6, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX7, GX_IDENTITY, 0}, }; -J3DTexMtxInfo const j3dDefaultTexMtxInfo = { +DUSK_GAME_DATA J3DTexMtxInfo const j3dDefaultTexMtxInfo = { 0x01, 0x00, 0xFF, @@ -341,27 +394,27 @@ J3DTexMtxInfo const j3dDefaultTexMtxInfo = { 1.0f}, }; -J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo = { +DUSK_GAME_DATA J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo = { 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 1 }; -J3DTevStageInfo const j3dDefaultTevStageInfo = { +DUSK_GAME_DATA J3DTevStageInfo const j3dDefaultTevStageInfo = { 0x04, 0x0A, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, }; -J3DIndTevStageInfo const j3dDefaultIndTevStageInfo = { +DUSK_GAME_DATA J3DIndTevStageInfo const j3dDefaultIndTevStageInfo = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -J3DFogInfo const j3dDefaultFogInfo = { +DUSK_GAME_DATA J3DFogInfo const j3dDefaultFogInfo = { 0x00, 0x00, 0x0140, 0.0f, 0.0f, 0.1f, 10000.0f, 0xFF, 0xFF, 0xFF, 0x00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; -J3DNBTScaleInfo const j3dDefaultNBTScaleInfo = { +DUSK_GAME_DATA J3DNBTScaleInfo const j3dDefaultNBTScaleInfo = { #if TARGET_PC 0x00, {1.0f, 1.0f, 1.0f}, #else @@ -399,9 +452,9 @@ void makeTexCoordTable() { } } -u8 j3dTevSwapTableTable[1024]; +DUSK_GAME_DATA u8 j3dTevSwapTableTable[1024]; -u8 j3dAlphaCmpTable[768]; +DUSK_GAME_DATA u8 j3dAlphaCmpTable[768]; void makeAlphaCmpTable() { u8* table = j3dAlphaCmpTable; @@ -417,7 +470,7 @@ void makeAlphaCmpTable() { } } -u8 j3dZModeTable[96]; +DUSK_GAME_DATA u8 j3dZModeTable[96]; void makeZModeTable() { u8* table = j3dZModeTable; @@ -495,44 +548,44 @@ static void J3DGDLoadPostTexMtxImm(f32 (*param_1)[4], u32 param_2) { J3DGDWrite_f32(param_1[2][3]); } -const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF}; +DUSK_GAME_DATA const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF}; -const GXColor j3dDefaultAmbInfo = {0x32, 0x32, 0x32, 0x32}; +DUSK_GAME_DATA const GXColor j3dDefaultAmbInfo = {0x32, 0x32, 0x32, 0x32}; -const u8 j3dDefaultNumChans = 1; +DUSK_GAME_DATA const u8 j3dDefaultNumChans = 1; -const J3DTevOrderInfo j3dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00}; +DUSK_GAME_DATA const J3DTevOrderInfo j3dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00}; -const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull = {0xFF, 0xFF, 0x00, 0x00}; +DUSK_GAME_DATA const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull = {0xFF, 0xFF, 0x00, 0x00}; -const GXColorS10 j3dDefaultTevColor = {0xFF, 0xFF, 0xFF, 0xFF}; +DUSK_GAME_DATA const GXColorS10 j3dDefaultTevColor = {0xFF, 0xFF, 0xFF, 0xFF}; -const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo = { +DUSK_GAME_DATA const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo = { 0x00, 0x00, 0x00, 0x00, }; -const GXColor j3dDefaultTevKColor = {0xFF, 0xFF, 0xFF, 0xFF}; +DUSK_GAME_DATA const GXColor j3dDefaultTevKColor = {0xFF, 0xFF, 0xFF, 0xFF}; -J3DTevSwapModeInfo const j3dDefaultTevSwapMode = { +DUSK_GAME_DATA J3DTevSwapModeInfo const j3dDefaultTevSwapMode = { 0x00, 0x00, 0x00, 0x00, }; -const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable = {0x00, 0x01, 0x02, 0x03}; +DUSK_GAME_DATA const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable = {0x00, 0x01, 0x02, 0x03}; -const J3DBlendInfo j3dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP}; +DUSK_GAME_DATA const J3DBlendInfo j3dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP}; -const J3DColorChanInfo j3dDefaultColorChanInfo = { +DUSK_GAME_DATA const J3DColorChanInfo j3dDefaultColorChanInfo = { 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0xFF, 0xFF, }; -const u8 j3dDefaultTevSwapTableID = 0x1B; +DUSK_GAME_DATA const u8 j3dDefaultTevSwapTableID = 0x1B; -const u16 j3dDefaultAlphaCmpID = 0x00E7; +DUSK_GAME_DATA const u16 j3dDefaultAlphaCmpID = 0x00E7; -const u16 j3dDefaultZModeID = 0x0017; +DUSK_GAME_DATA const u16 j3dDefaultZModeID = 0x0017; diff --git a/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp b/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp index a01e605abb..971d5d08dd 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp @@ -49,7 +49,7 @@ void J3DTexture::loadGX(u16 idx, GXTexMapID texMapID) const { } #if TARGET_PC -void J3DTexture::loadGXTexObj(u16 idx) { +void J3DTexture::initGXTexObj(u16 idx) { J3D_ASSERT_RANGE(29, idx < mNum); ResTIMG* timg = getResTIMG(idx); @@ -89,7 +89,7 @@ void J3DTexture::entryNum(u16 num) { delete[] mpImgDataPtr; delete[] mpTlutDataPtr; mpTexObj = new TGXTexObj[num](); - mpTlutObj = new GXTlutObj[num](); + mpTlutObj = new TGXTlutObj[num](); mpImgDataPtr = new u8*[num](); mpTlutDataPtr = new u8*[num](); diff --git a/libs/JSystem/src/J3DGraphBase/J3DTransform.cpp b/libs/JSystem/src/J3DGraphBase/J3DTransform.cpp index 44e0711337..5a7099e6dc 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DTransform.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DTransform.cpp @@ -74,12 +74,12 @@ void J3DCalcBBoardMtx(__REGISTER Mtx mtx) { mtx[2][2] = z; } -J3DTransformInfo const j3dDefaultTransformInfo = { +DUSK_GAME_DATA J3DTransformInfo const j3dDefaultTransformInfo = { {1.0f, 1.0f, 1.0f}, {0, 0, 0}, {0.0f, 0.0f, 0.0f}}; -Vec const j3dDefaultScale = {1.0f, 1.0f, 1.0f}; +DUSK_GAME_DATA Vec const j3dDefaultScale = {1.0f, 1.0f, 1.0f}; -Mtx const j3dDefaultMtx = { +DUSK_GAME_DATA Mtx const j3dDefaultMtx = { {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}}; void J3DCalcYBBoardMtx(Mtx mtx) { @@ -610,7 +610,7 @@ void J3DPSMtxArrayConcat(Mtx mA, Mtx mB, Mtx mAB, u32 count) { } #endif // clang-format on -f32 const PSMulUnit01[] = { +DUSK_GAME_DATA f32 const PSMulUnit01[] = { 0.0f, -1.0f, }; diff --git a/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp b/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp index 71068a3591..1459a705cd 100644 --- a/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp +++ b/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp @@ -2,9 +2,9 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" -u32 JAHVirtualNode::smVirNodeNum; +DUSK_GAME_DATA u32 JAHVirtualNode::smVirNodeNum; void JAHVirtualNode::virtualMessage(JAHControl& control) { message(control); diff --git a/libs/JSystem/src/JAHostIO/JAHioMessage.cpp b/libs/JSystem/src/JAHostIO/JAHioMessage.cpp index bc0e26e211..a32c20962e 100644 --- a/libs/JSystem/src/JAHostIO/JAHioMessage.cpp +++ b/libs/JSystem/src/JAHostIO/JAHioMessage.cpp @@ -5,17 +5,17 @@ #include "JSystem/JAHostIO/JAHioUtil.h" #include "JSystem/JHostIO/JORMContext.h" -u16 JAHControl::smButtonWidth[] = {20, 50, 100, 150, 300, 600}; -u16 JAHControl::smCommentWidth[] = {20, 50, 100, 200, 400, 800}; -u16 JAHControl::smComboWidth[] = {50, 100, 150, 200, 300, 600}; -u16 JAHControl::smYTop = 5; -u16 JAHControl::smXLeft = 5; -u16 JAHControl::smIndentSize = 30; -u16 JAHControl::smLineHeight = 23; -u16 JAHControl::smContWidth = 450; -u16 JAHControl::smIntX = 2; -u16 JAHControl::smIntY = 5; -u16 JAHControl::smNameWidth = 150; +DUSK_GAME_DATA u16 JAHControl::smButtonWidth[] = {20, 50, 100, 150, 300, 600}; +DUSK_GAME_DATA u16 JAHControl::smCommentWidth[] = {20, 50, 100, 200, 400, 800}; +DUSK_GAME_DATA u16 JAHControl::smComboWidth[] = {50, 100, 150, 200, 300, 600}; +DUSK_GAME_DATA u16 JAHControl::smYTop = 5; +DUSK_GAME_DATA u16 JAHControl::smXLeft = 5; +DUSK_GAME_DATA u16 JAHControl::smIndentSize = 30; +DUSK_GAME_DATA u16 JAHControl::smLineHeight = 23; +DUSK_GAME_DATA u16 JAHControl::smContWidth = 450; +DUSK_GAME_DATA u16 JAHControl::smIntX = 2; +DUSK_GAME_DATA u16 JAHControl::smIntY = 5; +DUSK_GAME_DATA u16 JAHControl::smNameWidth = 150; void JAHControl::returnY(u16 param_1) { mY += u16(smIntY + smLineHeight * param_1); diff --git a/libs/JSystem/src/JAHostIO/JAHioMgr.cpp b/libs/JSystem/src/JAHostIO/JAHioMgr.cpp index 91b0a030e6..9b404b6bef 100644 --- a/libs/JSystem/src/JAHostIO/JAHioMgr.cpp +++ b/libs/JSystem/src/JAHostIO/JAHioMgr.cpp @@ -5,7 +5,7 @@ #include "JSystem/JHostIO/JORServer.h" template <> -JAHioMgr* JAHSingletonBase::sInstance = NULL; +DUSK_GAME_DATA JAHioMgr* JAHSingletonBase::sInstance = NULL; JAHioMgr::JAHioMgr() : field_0x4(0), field_0x8(0) {} diff --git a/libs/JSystem/src/JAHostIO/JAHioNode.cpp b/libs/JSystem/src/JAHostIO/JAHioNode.cpp index e6c342eeeb..6e6ea2a320 100644 --- a/libs/JSystem/src/JAHostIO/JAHioNode.cpp +++ b/libs/JSystem/src/JAHostIO/JAHioNode.cpp @@ -6,9 +6,9 @@ #include "JSystem/JAHostIO/JAHioNode.h" #include "JSystem/JHostIO/JORServer.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" -JAHioNode* JAHioNode::smCurrentNode; +DUSK_GAME_DATA JAHioNode* JAHioNode::smCurrentNode; JAHioNode::JAHioNode(const char* name) : mTree(this) { mLastChild = NULL; diff --git a/libs/JSystem/src/JAHostIO/JAHioUtil.cpp b/libs/JSystem/src/JAHostIO/JAHioUtil.cpp index 9a0fdf027a..6f1935744d 100644 --- a/libs/JSystem/src/JAHostIO/JAHioUtil.cpp +++ b/libs/JSystem/src/JAHostIO/JAHioUtil.cpp @@ -6,10 +6,10 @@ #include "JSystem/JAHostIO/JAHioUtil.h" #include "JSystem/JHostIO/JORFile.h" -char JAHioUtil::mStringBuffer[256]; +DUSK_GAME_DATA char JAHioUtil::mStringBuffer[256]; -JAHioNode* JAHUpdate::spNode; -JORMContext* JAHUpdate::spMc; +DUSK_GAME_DATA JAHioNode* JAHUpdate::spNode; +DUSK_GAME_DATA JORMContext* JAHUpdate::spMc; static char* dummy(JORDir* dir) { return std::strrchr(dir->getFilename(), '\n'); diff --git a/libs/JSystem/src/JAudio2/JASAiCtrl.cpp b/libs/JSystem/src/JAudio2/JASAiCtrl.cpp index 3764700149..e59c9d45fe 100644 --- a/libs/JSystem/src/JAudio2/JASAiCtrl.cpp +++ b/libs/JSystem/src/JAudio2/JASAiCtrl.cpp @@ -18,35 +18,37 @@ #include #include -#include "tracy/Tracy.hpp" +#if TARGET_PC +#include +#endif -s16* JASDriver::sDmaDacBuffer[3]; +DUSK_GAME_DATA s16* JASDriver::sDmaDacBuffer[3]; static u8 data_804507A8 = 3; -s16** JASDriver::sDspDacBuffer; +DUSK_GAME_DATA s16** JASDriver::sDspDacBuffer; -s32 JASDriver::sDspDacWriteBuffer; +DUSK_GAME_DATA s32 JASDriver::sDspDacWriteBuffer; -s32 JASDriver::sDspDacReadBuffer; +DUSK_GAME_DATA s32 JASDriver::sDspDacReadBuffer; -s32 JASDriver::sDspStatus; +DUSK_GAME_DATA s32 JASDriver::sDspStatus; -JASDriver::DSPBufCallback JASDriver::sDspDacCallback; +DUSK_GAME_DATA JASDriver::DSPBufCallback JASDriver::sDspDacCallback; -s16* JASDriver::lastRspMadep; +DUSK_GAME_DATA s16* JASDriver::lastRspMadep; -void (*JASDriver::dacCallbackFunc)(s16*, u32); +DUSK_GAME_DATA void (*JASDriver::dacCallbackFunc)(s16*, u32); -JASDriver::MixCallback JASDriver::extMixCallback; +DUSK_GAME_DATA JASDriver::MixCallback JASDriver::extMixCallback; -u32 JASDriver::sOutputRate; +DUSK_GAME_DATA u32 JASDriver::sOutputRate; -JASMixMode JASDriver::sMixMode = MIX_MODE_EXTRA; +DUSK_GAME_DATA JASMixMode JASDriver::sMixMode = MIX_MODE_EXTRA; -f32 JASDriver::sDacRate = 32028.5f; +DUSK_GAME_DATA f32 JASDriver::sDacRate = 32028.5f; -u32 JASDriver::sSubFrames = 0x00000007; +DUSK_GAME_DATA u32 JASDriver::sSubFrames = 0x00000007; void JASDriver::initAI(void (*param_0)(void)) { setOutputRate(OUTPUT_RATE_0); @@ -114,14 +116,14 @@ void JASDriver::setOutputRate(JASOutputRate param_0) { #endif } -const JASDriver::MixFunc JASDriver::sMixFuncs[4] = { +DUSK_GAME_DATA const JASDriver::MixFunc JASDriver::sMixFuncs[4] = { mixMonoTrack, mixMonoTrackWide, mixExtraTrack, mixInterleaveTrack, }; -u32 JASDriver::sSubFrameCounter; +DUSK_GAME_DATA u32 JASDriver::sSubFrameCounter; void JASDriver::updateDac() { static u32 dacp = 0; @@ -227,7 +229,7 @@ void JASDriver::readDspBuffer(s16* param_0, u32 param_1) { JASCalc::imixcopy(endDacBuffer, dacBuffer, param_0, param_1); } -u32 sDspUpCount; +DUSK_GAME_DATA u32 sDspUpCount; void JASDriver::finishDSPFrame() { static u32 waitcount; diff --git a/libs/JSystem/src/JAudio2/JASAramStream.cpp b/libs/JSystem/src/JAudio2/JASAramStream.cpp index 64ddfc467e..6a15869a7c 100644 --- a/libs/JSystem/src/JAudio2/JASAramStream.cpp +++ b/libs/JSystem/src/JAudio2/JASAramStream.cpp @@ -12,16 +12,16 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include "JSystem/JSupport/JSupport.h" -JASTaskThread* JASAramStream::sLoadThread; +DUSK_GAME_DATA JASTaskThread* JASAramStream::sLoadThread; -u8* JASAramStream::sReadBuffer; +DUSK_GAME_DATA u8* JASAramStream::sReadBuffer; -u32 JASAramStream::sBlockSize; +DUSK_GAME_DATA u32 JASAramStream::sBlockSize; -u32 JASAramStream::sChannelMax; +DUSK_GAME_DATA u32 JASAramStream::sChannelMax; -bool dvdHasErrored; -bool hasErrored; +DUSK_GAME_DATA bool dvdHasErrored; +DUSK_GAME_DATA bool hasErrored; #define PAUSE_REQUESTED 1 #define PAUSE_DVD_ERROR 2 diff --git a/libs/JSystem/src/JAudio2/JASAudioThread.cpp b/libs/JSystem/src/JAudio2/JASAudioThread.cpp index fa476d1cb4..bd95337c44 100644 --- a/libs/JSystem/src/JAudio2/JASAudioThread.cpp +++ b/libs/JSystem/src/JAudio2/JASAudioThread.cpp @@ -41,7 +41,7 @@ void JASAudioThread::stop() { jamMessageBlock((void*)2); } -volatile int JASAudioThread::snIntCount; +DUSK_GAME_DATA volatile int JASAudioThread::snIntCount; class Lock { public: diff --git a/libs/JSystem/src/JAudio2/JASBNKParser.cpp b/libs/JSystem/src/JAudio2/JASBNKParser.cpp index 7898eedd48..ad8aa1ee46 100644 --- a/libs/JSystem/src/JAudio2/JASBNKParser.cpp +++ b/libs/JSystem/src/JAudio2/JASBNKParser.cpp @@ -13,7 +13,7 @@ JASBank* JASBNKParser::createBank(void const* stream, JKRHeap* heap) { return createBasicBank(stream, heap); } -u32 JASBNKParser::sUsedHeapSize; +DUSK_GAME_DATA u32 JASBNKParser::sUsedHeapSize; JASBasicBank* JASBNKParser::createBasicBank(void const* stream, JKRHeap* heap) { if (heap == NULL) { diff --git a/libs/JSystem/src/JAudio2/JASBasicWaveBank.cpp b/libs/JSystem/src/JAudio2/JASBasicWaveBank.cpp index 9170e59ed1..ac11742e6b 100644 --- a/libs/JSystem/src/JAudio2/JASBasicWaveBank.cpp +++ b/libs/JSystem/src/JAudio2/JASBasicWaveBank.cpp @@ -55,7 +55,7 @@ void JASBasicWaveBank::incWaveTable(JASBasicWaveBank::TWaveGroup const* param_0) } } -u32 JASBasicWaveBank::mNoLoad; +DUSK_GAME_DATA u32 JASBasicWaveBank::mNoLoad; void JASBasicWaveBank::decWaveTable(JASBasicWaveBank::TWaveGroup const* param_0) { JASMutexLock lock(&field_0x4); diff --git a/libs/JSystem/src/JAudio2/JASCalc.cpp b/libs/JSystem/src/JAudio2/JASCalc.cpp index 69369192fe..de0cf02295 100644 --- a/libs/JSystem/src/JAudio2/JASCalc.cpp +++ b/libs/JSystem/src/JAudio2/JASCalc.cpp @@ -11,6 +11,7 @@ void JASCalc::imixcopy(const s16* s1, const s16* s2, s16* dst, u32 n) { } } +#if !TARGET_PC void JASCalc::bcopyfast(const void* src, void* dest, u32 size) { JUT_ASSERT(226, (reinterpret_cast(src) & 0x03) == 0); JUT_ASSERT(227, (reinterpret_cast(dest) & 0x03) == 0); @@ -33,11 +34,7 @@ void JASCalc::bcopyfast(const void* src, void* dest, u32 size) { } } -#if TARGET_ANDROID -void JASCalc::_bcopy(const void* src, void* dest, u32 size) { -#else void JASCalc::bcopy(const void* src, void* dest, u32 size) { -#endif u32* usrc; u32* udest; @@ -94,11 +91,7 @@ void JASCalc::bzerofast(void* dest, u32 size) { } } -#if TARGET_ANDROID -void JASCalc::_bzero(void* dest, u32 size) { -#else void JASCalc::bzero(void* dest, u32 size) { -#endif u32* udest; u8* bdest = (u8*)dest; if ((size & 0x1f) == 0 && (reinterpret_cast(dest) & 0x1f) == 0) { @@ -139,9 +132,10 @@ void JASCalc::bzero(void* dest, u32 size) { } } } +#endif #if AVOID_UB -s16 const JASCalc::CUTOFF_TO_IIR_TABLE[129][4] = { +DUSK_GAME_DATA s16 const JASCalc::CUTOFF_TO_IIR_TABLE[129][4] = { #else s16 const JASCalc::CUTOFF_TO_IIR_TABLE[128][4] = { #endif diff --git a/libs/JSystem/src/JAudio2/JASChannel.cpp b/libs/JSystem/src/JAudio2/JASChannel.cpp index 758167cc5c..a709edc3f9 100644 --- a/libs/JSystem/src/JAudio2/JASChannel.cpp +++ b/libs/JSystem/src/JAudio2/JASChannel.cpp @@ -12,13 +12,13 @@ #include "JSystem/JMath/JMATrigonometric.h" #include "JSystem/JGeometry.h" -OSMessageQueue JASChannel::sBankDisposeMsgQ; +DUSK_GAME_DATA OSMessageQueue JASChannel::sBankDisposeMsgQ; -OSMessage JASChannel::sBankDisposeMsg[16]; +DUSK_GAME_DATA OSMessage JASChannel::sBankDisposeMsg[16]; -OSMessage JASChannel::sBankDisposeList[16]; +DUSK_GAME_DATA OSMessage JASChannel::sBankDisposeList[16]; -int JASChannel::sBankDisposeListSize; +DUSK_GAME_DATA int JASChannel::sBankDisposeListSize; JASChannel::JASChannel(Callback i_callback, void* i_callbackData) : mStatus(STATUS_STOP), @@ -173,11 +173,7 @@ void JASChannel::updateEffectorParam(JASDsp::TChannel* i_channel, u16* i_mixerVo f32 pan = 0.5f; f32 dolby = 0.0f; -#if TARGET_PC - u32 effectiveOutputMode = dusk::audio::EnableHrtf ? JAS_OUTPUT_SURROUND : JASDriver::getOutputMode(); -#else u32 effectiveOutputMode = JASDriver::getOutputMode(); -#endif switch (effectiveOutputMode) { case JAS_OUTPUT_MONO: break; diff --git a/libs/JSystem/src/JAudio2/JASCmdStack.cpp b/libs/JSystem/src/JAudio2/JASCmdStack.cpp index beaeee492e..90c56150ce 100644 --- a/libs/JSystem/src/JAudio2/JASCmdStack.cpp +++ b/libs/JSystem/src/JAudio2/JASCmdStack.cpp @@ -8,9 +8,9 @@ #include "JSystem/JAudio2/JASCriticalSection.h" #include -JASPortCmd::TPortHead JASPortCmd::sCommandListOnce; +DUSK_GAME_DATA JASPortCmd::TPortHead JASPortCmd::sCommandListOnce; -JASPortCmd::TPortHead JASPortCmd::sCommandListStay; +DUSK_GAME_DATA JASPortCmd::TPortHead JASPortCmd::sCommandListStay; bool JASPortCmd::addPortCmdOnce() { JASCriticalSection cs; diff --git a/libs/JSystem/src/JAudio2/JASDSPChannel.cpp b/libs/JSystem/src/JAudio2/JASDSPChannel.cpp index 62c983248c..7c35ce8e94 100644 --- a/libs/JSystem/src/JAudio2/JASDSPChannel.cpp +++ b/libs/JSystem/src/JAudio2/JASDSPChannel.cpp @@ -4,7 +4,7 @@ #include "JSystem/JAudio2/JASHeapCtrl.h" #include "JSystem/JKernel/JKRSolidHeap.h" -JASDSPChannel* JASDSPChannel::sDspChannels; +DUSK_GAME_DATA JASDSPChannel* JASDSPChannel::sDspChannels; JASDSPChannel::JASDSPChannel() : mStatus(STATUS_INACTIVE), diff --git a/libs/JSystem/src/JAudio2/JASDSPInterface.cpp b/libs/JSystem/src/JAudio2/JASDSPInterface.cpp index 14a723e27d..7a9b5cda3e 100644 --- a/libs/JSystem/src/JAudio2/JASDSPInterface.cpp +++ b/libs/JSystem/src/JAudio2/JASDSPInterface.cpp @@ -11,13 +11,13 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include -JASDsp::TChannel* JASDsp::CH_BUF; +DUSK_GAME_DATA JASDsp::TChannel* JASDsp::CH_BUF; -JASDsp::FxBuf* JASDsp::FX_BUF; +DUSK_GAME_DATA JASDsp::FxBuf* JASDsp::FX_BUF; -f32 JASDsp::sDSPVolume; +DUSK_GAME_DATA f32 JASDsp::sDSPVolume; -u16 JASDsp::SEND_TABLE[] = { +DUSK_GAME_DATA u16 JASDsp::SEND_TABLE[] = { 0x0D00, 0x0D60, 0x0DC8, @@ -32,10 +32,10 @@ u16 JASDsp::SEND_TABLE[] = { 0x0000, }; -u32 JASWaveInfo::one = 1; +DUSK_GAME_DATA u32 JASWaveInfo::one = 1; #if DEBUG -s32 JASDsp::dspMutex = 1; +DUSK_GAME_DATA s32 JASDsp::dspMutex = 1; #endif void JASDsp::boot(void (*param_0)(void*)) { @@ -99,14 +99,14 @@ void JASDsp::invalChannelAll() { DCInvalidateRange(CH_BUF, sizeof(TChannel) * DSP_CHANNELS); } -u8 const ATTRIBUTE_ALIGN(32) JASDsp::DSPADPCM_FILTER[64] = { +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA u8 const JASDsp::DSPADPCM_FILTER[64] = { 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10, 0x00, 0xF8, 0x00, 0x0E, 0x00, 0xFA, 0x00, 0x0C, 0x00, 0xFC, 0x00, 0x12, 0x00, 0xF6, 0x00, 0x10, 0x68, 0xF7, 0x38, 0x12, 0xC0, 0xF7, 0x04, 0x14, 0x00, 0xF4, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x04, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x04, 0x00, 0xFC, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, }; -u32 const ATTRIBUTE_ALIGN(32) JASDsp::DSPRES_FILTER[320] = { +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA u32 const JASDsp::DSPRES_FILTER[320] = { 0x0C3966AD, 0x0D46FFDF, 0x0B396696, diff --git a/libs/JSystem/src/JAudio2/JASDriverIF.cpp b/libs/JSystem/src/JAudio2/JASDriverIF.cpp index 7d602a8856..a08e3339ea 100644 --- a/libs/JSystem/src/JAudio2/JASDriverIF.cpp +++ b/libs/JSystem/src/JAudio2/JASDriverIF.cpp @@ -3,13 +3,14 @@ #include "JSystem/JAudio2/JASDriverIF.h" #include "JSystem/JAudio2/JASAiCtrl.h" #include "JSystem/JAudio2/JASDSPInterface.h" +#include "dusk/settings.h" #include void JASDriver::setDSPLevel(f32 param_0) { JASDsp::setDSPMixerLevel(param_0); } -u16 JASDriver::MAX_MIXERLEVEL = 0x2EE0; +DUSK_GAME_DATA u16 JASDriver::MAX_MIXERLEVEL = 0x2EE0; u16 JASDriver::getChannelLevel_dsp() { return JASDriver::MAX_MIXERLEVEL; @@ -23,14 +24,25 @@ f32 JASDriver::getDSPLevel() { return JASDsp::getDSPMixerLevel(); } -u32 JASDriver::JAS_SYSTEM_OUTPUT_MODE = JAS_OUTPUT_STEREO; +DUSK_GAME_DATA u32 JASDriver::JAS_SYSTEM_OUTPUT_MODE = JAS_OUTPUT_STEREO; void JASDriver::setOutputMode(u32 mode) { JAS_SYSTEM_OUTPUT_MODE = mode; } u32 JASDriver::getOutputMode() { +#ifdef TARGET_PC + switch (dusk::getSettings().audio.outputMode) { + case dusk::AudioOutputMode::StereoSpeakers: + return JAS_OUTPUT_STEREO; + case dusk::AudioOutputMode::StereoHeadphones: + case dusk::AudioOutputMode::Surround6ch: + case dusk::AudioOutputMode::Surround8ch: + return JAS_OUTPUT_SURROUND; + } +#else return JASDriver::JAS_SYSTEM_OUTPUT_MODE; +#endif } void JASDriver::waitSubFrame() { @@ -40,11 +52,11 @@ void JASDriver::waitSubFrame() { } while (r31 == getSubFrameCounter()); } -JASCallbackMgr JASDriver::sDspSyncCallback; +DUSK_GAME_DATA JASCallbackMgr JASDriver::sDspSyncCallback; -JASCallbackMgr JASDriver::sSubFrameCallback; +DUSK_GAME_DATA JASCallbackMgr JASDriver::sSubFrameCallback; -JASCallbackMgr JASDriver::sUpdateDacCallback; +DUSK_GAME_DATA JASCallbackMgr JASDriver::sUpdateDacCallback; int JASDriver::rejectCallback(DriverCallback callback, void* param_1) { int r31 = sDspSyncCallback.reject(callback, param_1); diff --git a/libs/JSystem/src/JAudio2/JASDvdThread.cpp b/libs/JSystem/src/JAudio2/JASDvdThread.cpp index 31a313a8b1..dfa85d3166 100644 --- a/libs/JSystem/src/JAudio2/JASDvdThread.cpp +++ b/libs/JSystem/src/JAudio2/JASDvdThread.cpp @@ -4,7 +4,7 @@ #include "JSystem/JAudio2/JASTaskThread.h" #include "JSystem/JKernel/JKRSolidHeap.h" -JASTaskThread* JASDvd::sThread; +DUSK_GAME_DATA JASTaskThread* JASDvd::sThread; JASTaskThread* JASDvd::getThreadPointer() { return JASDvd::sThread; diff --git a/libs/JSystem/src/JAudio2/JASHeapCtrl.cpp b/libs/JSystem/src/JAudio2/JASHeapCtrl.cpp index e3722e3726..ef2d26256a 100644 --- a/libs/JSystem/src/JAudio2/JASHeapCtrl.cpp +++ b/libs/JSystem/src/JAudio2/JASHeapCtrl.cpp @@ -247,7 +247,7 @@ JASGenericMemPool::~JASGenericMemPool() { } } -JKRSolidHeap* JASDram; +DUSK_GAME_DATA JKRSolidHeap* JASDram; // TODO: What is this and Where does it go? struct TNextOnFreeList { @@ -290,11 +290,11 @@ void JASGenericMemPool::free(void* ptr, u32 param_1) { freeMemCount++; } -uintptr_t JASKernel::sAramBase; +DUSK_GAME_DATA uintptr_t JASKernel::sAramBase; -JKRHeap* JASKernel::sSystemHeap; +DUSK_GAME_DATA JKRHeap* JASKernel::sSystemHeap; -JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* JASKernel::sCommandHeap; +DUSK_GAME_DATA JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* JASKernel::sCommandHeap; void JASKernel::setupRootHeap(JKRSolidHeap* heap, u32 size) { JUT_ASSERT(784, heap); @@ -314,7 +314,7 @@ JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* JASKernel::getCom return JASKernel::sCommandHeap; } -JASHeap JASKernel::audioAramHeap; +DUSK_GAME_DATA JASHeap JASKernel::audioAramHeap; void JASKernel::setupAramHeap(uintptr_t param_0, u32 param_1) { #if !PLATFORM_GCN diff --git a/libs/JSystem/src/JAudio2/JASLfo.cpp b/libs/JSystem/src/JAudio2/JASLfo.cpp index d369072a15..4a9af0c3c9 100644 --- a/libs/JSystem/src/JAudio2/JASLfo.cpp +++ b/libs/JSystem/src/JAudio2/JASLfo.cpp @@ -40,7 +40,7 @@ void JASLfo::incCounter(f32 param_0) { } } -JASLfo JASLfo::sFreeRunLfo; +DUSK_GAME_DATA JASLfo JASLfo::sFreeRunLfo; void JASLfo::resetCounter() { field_0x16 = mDelay; diff --git a/libs/JSystem/src/JAudio2/JASOscillator.cpp b/libs/JSystem/src/JAudio2/JASOscillator.cpp index f4bf2ade6f..666b2dd439 100644 --- a/libs/JSystem/src/JAudio2/JASOscillator.cpp +++ b/libs/JSystem/src/JAudio2/JASOscillator.cpp @@ -131,25 +131,25 @@ void JASOscillator::update() { updateCurrentValue(psVar1[mCurPoint].mTime); } -f32 const JASOscillator::sCurveTableLinear[17] = { +DUSK_GAME_DATA f32 const JASOscillator::sCurveTableLinear[17] = { 1.0, 0.9375, 0.875, 0.8125, 0.75, 0.6875, 0.625, 0.5625, 0.5, 0.4375, 0.375, 0.3125, 0.25, 0.1875, 0.125, 0.0625, 0.0, }; -f32 const JASOscillator::sCurveTableSampleCell[17] = { +DUSK_GAME_DATA f32 const JASOscillator::sCurveTableSampleCell[17] = { 1.0, 0.9704890251159668, 0.7812740206718445, 0.5462809801101685, 0.39979198575019836, 0.28931498527526855, 0.21210399270057678, 0.15747599303722382, 0.1126129999756813, 0.08178959786891937, 0.057985201478004456, 0.04364150017499924, 0.03082370012998581, 0.023712899535894394, 0.015259300358593464, 0.00915555004030466, 0.0 }; -f32 const JASOscillator::sCurveTableSqRoot[17] = { +DUSK_GAME_DATA f32 const JASOscillator::sCurveTableSqRoot[17] = { 1.0, 0.8789060115814209, 0.765625, 0.6601560115814209, 0.5625, 0.4726560115814209, 0.390625, 0.3164060115814209, 0.25, 0.1914059966802597, 0.140625, 0.09765619784593582, 0.0625, 0.03515620157122612, 0.015625, 0.00390625, 0.0 }; -f32 const JASOscillator::sCurveTableSquare[17] = { +DUSK_GAME_DATA f32 const JASOscillator::sCurveTableSquare[17] = { 1.0, 0.9682459831237793, 0.9354140162467957, 0.9013879895210266, 0.8660249710083008, 0.8291559815406799, 0.790569007396698, 0.75, 0.7071070075035095, 0.66143798828125, 0.6123719811439514, 0.55901700258255, 0.5, 0.433012992143631, 0.35355299711227417, 0.25, 0.0, diff --git a/libs/JSystem/src/JAudio2/JASProbe.cpp b/libs/JSystem/src/JAudio2/JASProbe.cpp index 55a63e67c8..70e930c2bb 100644 --- a/libs/JSystem/src/JAudio2/JASProbe.cpp +++ b/libs/JSystem/src/JAudio2/JASProbe.cpp @@ -26,7 +26,7 @@ void JASProbe::stop() { _1A8++; } -JASProbe* JASProbe::sProbeTable[16]; +DUSK_GAME_DATA JASProbe* JASProbe::sProbeTable[16]; void JASProbe::start(s32 index, char const* name) { JASProbe* probe; diff --git a/libs/JSystem/src/JAudio2/JASResArcLoader.cpp b/libs/JSystem/src/JAudio2/JASResArcLoader.cpp index a55c73469c..57e6742c51 100644 --- a/libs/JSystem/src/JAudio2/JASResArcLoader.cpp +++ b/libs/JSystem/src/JAudio2/JASResArcLoader.cpp @@ -17,7 +17,7 @@ size_t JASResArcLoader::getResSize(JKRArchive const* i_archiveP, u16 i_resourceI return 0; } - return file->data_size; + return DUSK_IF_ELSE(i_archiveP->getFileSize(file), file->data_size); } size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) { @@ -27,9 +27,16 @@ size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) { for (index = 0; index < fileEntries; index++) { JKRArchive::SDIFileEntry* file = i_archiveP->findIdxResource(index); if (file) { +#if TARGET_PC + const u32 fileSize = i_archiveP->getFileSize(file); + if (maxSize < fileSize) { + maxSize = fileSize; + } +#else if (maxSize < file->data_size) { maxSize = file->data_size; } +#endif } } diff --git a/libs/JSystem/src/JAudio2/JASSeqCtrl.cpp b/libs/JSystem/src/JAudio2/JASSeqCtrl.cpp index a4e4a4b441..d9fe9d6698 100644 --- a/libs/JSystem/src/JAudio2/JASSeqCtrl.cpp +++ b/libs/JSystem/src/JAudio2/JASSeqCtrl.cpp @@ -4,7 +4,7 @@ #include "JSystem/JAudio2/JASSeqParser.h" #include "JSystem/JAudio2/JASTrack.h" -JASSeqParser JASSeqCtrl::sDefaultParser; +DUSK_GAME_DATA JASSeqParser JASSeqCtrl::sDefaultParser; JASSeqCtrl::JASSeqCtrl() { field_0x3c = &sDefaultParser; diff --git a/libs/JSystem/src/JAudio2/JASSeqParser.cpp b/libs/JSystem/src/JAudio2/JASSeqParser.cpp index b2077ce499..92288cbc4e 100644 --- a/libs/JSystem/src/JAudio2/JASSeqParser.cpp +++ b/libs/JSystem/src/JAudio2/JASSeqParser.cpp @@ -9,7 +9,7 @@ #include "JSystem/JUtility/JUTAssert.h" -JASSeqParser::CmdInfo JASSeqParser::sCmdInfo[96] = { +DUSK_GAME_DATA JASSeqParser::CmdInfo JASSeqParser::sCmdInfo[96] = { NULL, 0x0000, 0x0000, NULL, 0x0000, 0x0000, NULL, 0x0000, 0x0000, @@ -108,7 +108,7 @@ JASSeqParser::CmdInfo JASSeqParser::sCmdInfo[96] = { &JASSeqParser::cmdFinish, 0x0000, 0x0000, }; -JASSeqParser::CmdInfo JASSeqParser::sExtCmdInfo[255] = { +DUSK_GAME_DATA JASSeqParser::CmdInfo JASSeqParser::sExtCmdInfo[255] = { NULL, 0x0000, 0x0000, &JASSeqParser::cmdDump, 0x0000, 0x0000, NULL, 0x0000, 0x0000, @@ -589,7 +589,7 @@ s32 JASSeqParser::cmdIntTimer(JASTrack* param_0, u32* param_1) { return 0; } -u16 (*JASSeqParser::sCallBackFunc)(JASTrack*, u16); +DUSK_GAME_DATA u16 (*JASSeqParser::sCallBackFunc)(JASTrack*, u16); s32 JASSeqParser::cmdSyncCPU(JASTrack* param_0, u32* param_1) { u16 r31 = 0xffff; diff --git a/libs/JSystem/src/JAudio2/JASTrack.cpp b/libs/JSystem/src/JAudio2/JASTrack.cpp index 68fbee63e5..4b1a7ba7aa 100644 --- a/libs/JSystem/src/JAudio2/JASTrack.cpp +++ b/libs/JSystem/src/JAudio2/JASTrack.cpp @@ -15,9 +15,9 @@ JASTrack::JASTrack() : mDefaultChannelMgr(this), mChannelMgrCount(1), mStatus(0) init(); } -JASDefaultBankTable JASTrack::sDefaultBankTable; +DUSK_GAME_DATA JASDefaultBankTable JASTrack::sDefaultBankTable; -JASTrack::TList JASTrack::sTrackList; +DUSK_GAME_DATA JASTrack::TList JASTrack::sTrackList; // NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations JASTrack::~JASTrack() { @@ -50,16 +50,16 @@ void JASTrack::setChannelMgrCount(u32 count) { } } -JASOscillator::Point const JASTrack::sAdsTable[4] = { +DUSK_GAME_DATA JASOscillator::Point const JASTrack::sAdsTable[4] = { {0, 0, 0x7fff}, {0, 0, 0x7fff}, {0, 0, 0}, {0xe, 0, 0}, }; -JASOscillator::Data const JASTrack::sEnvOsc = {0, 1.0f, NULL, NULL, 1.0f, 0.0f}; +DUSK_GAME_DATA JASOscillator::Data const JASTrack::sEnvOsc = {0, 1.0f, NULL, NULL, 1.0f, 0.0f}; -JASOscillator::Data const JASTrack::sPitchEnvOsc = {1, 1.0f, NULL, NULL, 1.0f, 0.0f}; +DUSK_GAME_DATA JASOscillator::Data const JASTrack::sPitchEnvOsc = {1, 1.0f, NULL, NULL, 1.0f, 0.0f}; // NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations void JASTrack::init() { @@ -552,7 +552,7 @@ void JASTrack::setOscAdsr(s16 param_0, s16 param_1, s16 param_2, s16 param_3, u1 mDirectRelease = i_directRelease; } -const u32 JASDsp::FILTER_MODE_IIR = 0x00000020; +DUSK_GAME_DATA const u32 JASDsp::FILTER_MODE_IIR = 0x00000020; void JASTrack::setFIR(s16 const* i_FIR) { for (int i = 0; i < 8; i++) { diff --git a/libs/JSystem/src/JAudio2/JASVoiceBank.cpp b/libs/JSystem/src/JAudio2/JASVoiceBank.cpp index f69616a3af..0d3cd3adb2 100644 --- a/libs/JSystem/src/JAudio2/JASVoiceBank.cpp +++ b/libs/JSystem/src/JAudio2/JASVoiceBank.cpp @@ -3,11 +3,11 @@ #include "JSystem/JAudio2/JASVoiceBank.h" #include "JSystem/JAudio2/JASBasicInst.h" -const JASOscillator::Data JASVoiceBank::sOscData = { +DUSK_GAME_DATA const JASOscillator::Data JASVoiceBank::sOscData = { 0, 1.0f, NULL, NULL, 1.0f, 0.0f, }; -JASOscillator::Data* JASVoiceBank::sOscTable; +DUSK_GAME_DATA JASOscillator::Data* JASVoiceBank::sOscTable; bool JASVoiceBank::getInstParam(int param_0, int param_1, int param_2, JASInstParam* param_3) const { diff --git a/libs/JSystem/src/JAudio2/JASWSParser.cpp b/libs/JSystem/src/JAudio2/JASWSParser.cpp index 4288377548..519eaa3307 100644 --- a/libs/JSystem/src/JAudio2/JASWSParser.cpp +++ b/libs/JSystem/src/JAudio2/JASWSParser.cpp @@ -21,7 +21,7 @@ JASWaveBank* JASWSParser::createWaveBank(void const* stream, JKRHeap* heap) { } } -u32 JASWSParser::sUsedHeapSize; +DUSK_GAME_DATA u32 JASWSParser::sUsedHeapSize; JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap* heap) { if (heap == NULL) { diff --git a/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp b/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp index 41ad35380d..02730f46b4 100644 --- a/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp +++ b/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp @@ -9,9 +9,9 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" -JASHeap* JASWaveArcLoader::sAramHeap; +DUSK_GAME_DATA JASHeap* JASWaveArcLoader::sAramHeap; JASHeap* JASWaveArcLoader::getRootHeap() { if (JASWaveArcLoader::sAramHeap) { @@ -20,7 +20,7 @@ JASHeap* JASWaveArcLoader::getRootHeap() { return JASKernel::getAramHeap(); } -char JASWaveArcLoader::sCurrentDir[DIR_MAX] = "/AudioRes/Waves/"; +DUSK_GAME_DATA char JASWaveArcLoader::sCurrentDir[DIR_MAX] = "/AudioRes/Waves/"; void JASWaveArcLoader::setCurrentDir(char const* dir) { JUT_ASSERT(40, std::strlen(dir) < DIR_MAX - 1); diff --git a/libs/JSystem/src/JAudio2/dsptask.cpp b/libs/JSystem/src/JAudio2/dsptask.cpp index 7d2e8dd2ad..ce91ae2e78 100644 --- a/libs/JSystem/src/JAudio2/dsptask.cpp +++ b/libs/JSystem/src/JAudio2/dsptask.cpp @@ -25,7 +25,7 @@ void DspHandShake(void*) { Dsp_Running_Start(); } -static u8 jdsp[7936] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u8 jdsp[7936] = { 0x02, 0x9F, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x02, 0x9F, 0x06, 0xA5, 0x02, 0x9F, 0x00, 0x4E, 0x12, 0x05, 0x02, 0xBF, 0x00, 0x57, 0x81, 0x00, 0x00, 0x9F, 0x10, 0x00, @@ -524,9 +524,9 @@ static u8 jdsp[7936] ATTRIBUTE_ALIGN(32) = { 0x80, 0x01, 0x02, 0xBF, 0x00, 0xF4, 0x02, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static DSPTaskInfo audio_task ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static DSPTaskInfo audio_task; -static u8 AUDIO_YIELD_BUFFER[8192] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u8 AUDIO_YIELD_BUFFER[8192]; void DspBoot(void (*requestCallback)(void*)) { DspInitWork(); diff --git a/libs/JSystem/src/JAudio2/osdsp_task.cpp b/libs/JSystem/src/JAudio2/osdsp_task.cpp index 7ec8f3f855..c7d24eaca8 100644 --- a/libs/JSystem/src/JAudio2/osdsp_task.cpp +++ b/libs/JSystem/src/JAudio2/osdsp_task.cpp @@ -5,8 +5,8 @@ #include #include -extern DSPTaskInfo* __DSP_first_task; -extern DSPTaskInfo* __DSP_curr_task; +DUSK_GAME_EXTERN DSPTaskInfo* __DSP_first_task; +DUSK_GAME_EXTERN DSPTaskInfo* __DSP_curr_task; extern "C" void __DSP_exec_task(DSPTaskInfo*, DSPTaskInfo*); extern "C" void __DSP_remove_task(DSPTaskInfo* task); diff --git a/libs/JSystem/src/JFramework/JFWDisplay.cpp b/libs/JSystem/src/JFramework/JFWDisplay.cpp index 2d4c9c7126..0524cb86f7 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -12,16 +12,18 @@ #include "global.h" #include -#ifdef TARGET_PC +#if TARGET_PC #include "dusk/dusk.h" -#include "dusk/gx_helper.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" #include "dusk/time.h" +#include "helpers/gx_helper.h" + #include "f_op/f_op_overlap_mng.h" -#include "SDL3/SDL_timer.h" -#include "tracy/Tracy.hpp" +#include +#include #include #endif @@ -37,7 +39,7 @@ void JFWDisplay::ctor_subroutine(bool enableAlpha) { mTickRate = 0; mCombinationRatio = 0.0f; field_0x30 = 0; - field_0x2c = OSGetTick(); + field_0x2c = DUSK_IF_ELSE(static_cast(OSGetNativeTime()), OSGetTick()); field_0x34 = 0; field_0x48 = 0; field_0x4a = 0; @@ -65,7 +67,7 @@ JFWDisplay::~JFWDisplay() { mXfbManager = NULL; } -JFWDisplay* JFWDisplay::sManager; +DUSK_GAME_DATA JFWDisplay* JFWDisplay::sManager; JFWDisplay* JFWDisplay::createManager(GXRenderModeObj const* p_rObj, JKRHeap* p_heap, JUTXfb::EXfbNumber xfb_num, bool enableAlpha) { @@ -216,8 +218,8 @@ void JFWDisplay::endGX() { if (mFader != NULL) { ortho.setPort(); -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { +#if TARGET_PC + if (dusk::interp::get_ui_tick_pending()) { mFader->advance(); } if (mFader->getStatus() != JUTFader::Wait) { @@ -257,7 +259,7 @@ void JFWDisplay::beginRender() { waitForTick(mTickRate, mFrameRate); JUTVideo::getManager()->waitRetraceIfNeed(); - OSTick tick = OSGetTick(); + OSTick tick = DUSK_IF_ELSE(static_cast(OSGetNativeTime()), OSGetTick()); field_0x30 = tick - field_0x2c; field_0x2c = tick; field_0x34 = field_0x2c - JUTVideo::getVideoLastTick(); @@ -370,7 +372,7 @@ constexpr auto FRAME_PERIOD = std::chrono::duration_cast(sleepTime) / static_cast(targetNs)); } @@ -380,15 +382,12 @@ static void waitForTick(u32 p1, u16 p2) { #if TARGET_PC static Limiter limiter; - if (dusk::frame_interp::is_enabled() && !dusk::getTransientSettings().skipFrameRateLimit) { - dusk::frameUsagePct = 0.f; - return; + if (dusk::interp::is_enabled() || dusk::getTransientSettings().turboMode) { + limiter.Reset(); + dusk::frameUsagePct = 0.f; + return; } - if (dusk::getTransientSettings().skipFrameRateLimit) { - p1 = OS_TIMER_CLOCK / 120; - } - if (fopOvlpM_IsPeek() && dusk::getTransientSettings().stateShareLoadActive) { return; } @@ -398,7 +397,6 @@ static void waitForTick(u32 p1, u16 p2) { if (p1 != 0) { #if TARGET_PC - static Limiter limiter; waitPrecise(limiter, static_cast(OSTicksToMicroseconds(p1)) * 1000ULL); #else static OSTime nextTick = OSGetTime(); @@ -412,7 +410,6 @@ static void waitForTick(u32 p1, u16 p2) { } else { u32 uVar1 = (p2 == 0) ? 1 : p2; #if TARGET_PC - static Limiter limiter; waitPrecise(limiter, static_cast((RETRACE_PERIOD * uVar1).count())); #else static u32 nextCount = VIGetRetraceCount(); @@ -428,7 +425,7 @@ static void waitForTick(u32 p1, u16 p2) { } } -JSUList JFWAlarm::sList(false); +DUSK_GAME_DATA JSUList JFWAlarm::sList(false); static void JFWThreadAlarmHandler(OSAlarm* p_alarm, OSContext* p_ctx) { JFWAlarm* alarm = static_cast(p_alarm); alarm->removeLink(); @@ -451,13 +448,13 @@ static void dummy() { JUTXfb::getManager()->setDisplayingXfbIndex(0); } -static Mtx e_mtx ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static Mtx e_mtx = { {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, }; -static u8 clear_z_TX[64] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u8 clear_z_TX[64] = { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, diff --git a/libs/JSystem/src/JFramework/JFWSystem.cpp b/libs/JSystem/src/JFramework/JFWSystem.cpp index d6322f34c9..e0f9f58ef6 100644 --- a/libs/JSystem/src/JFramework/JFWSystem.cpp +++ b/libs/JSystem/src/JFramework/JFWSystem.cpp @@ -13,32 +13,32 @@ #include "JSystem/JUtility/JUTResFont.h" #include "JSystem/JUtility/JUTDbPrint.h" -s32 JFWSystem::CSetUpParam::maxStdHeaps = 2; +DUSK_GAME_DATA s32 JFWSystem::CSetUpParam::maxStdHeaps = 2; -u32 JFWSystem::CSetUpParam::sysHeapSize = 0x400000; +DUSK_GAME_DATA u32 JFWSystem::CSetUpParam::sysHeapSize = 0x400000; -JKRExpHeap* JFWSystem::rootHeap; +DUSK_GAME_DATA JKRExpHeap* JFWSystem::rootHeap; -JKRExpHeap* JFWSystem::systemHeap; +DUSK_GAME_DATA JKRExpHeap* JFWSystem::systemHeap; -u32 JFWSystem::CSetUpParam::fifoBufSize = 0x40000; +DUSK_GAME_DATA u32 JFWSystem::CSetUpParam::fifoBufSize = 0x40000; -u32 JFWSystem::CSetUpParam::aramAudioBufSize = 0x800000; +DUSK_GAME_DATA u32 JFWSystem::CSetUpParam::aramAudioBufSize = 0x800000; -u32 JFWSystem::CSetUpParam::aramGraphBufSize = 0x600000; +DUSK_GAME_DATA u32 JFWSystem::CSetUpParam::aramGraphBufSize = 0x600000; -s32 JFWSystem::CSetUpParam::streamPriority = 8; +DUSK_GAME_DATA s32 JFWSystem::CSetUpParam::streamPriority = 8; -s32 JFWSystem::CSetUpParam::decompPriority = 7; +DUSK_GAME_DATA s32 JFWSystem::CSetUpParam::decompPriority = 7; -s32 JFWSystem::CSetUpParam::aPiecePriority = 6; +DUSK_GAME_DATA s32 JFWSystem::CSetUpParam::aPiecePriority = 6; -ResFONT* JFWSystem::CSetUpParam::systemFontRes = (ResFONT*)&JUTResFONT_Ascfont_fix12; +DUSK_GAME_DATA ResFONT* JFWSystem::CSetUpParam::systemFontRes = (ResFONT*)&JUTResFONT_Ascfont_fix12; -const GXRenderModeObj* JFWSystem::CSetUpParam::renderMode = &GXNtsc480IntDf; +DUSK_GAME_DATA const GXRenderModeObj* JFWSystem::CSetUpParam::renderMode = &GXNtsc480IntDf; -u32 JFWSystem::CSetUpParam::exConsoleBufferSize = 0x24FC; +DUSK_GAME_DATA u32 JFWSystem::CSetUpParam::exConsoleBufferSize = 0x24FC; void JFWSystem::firstInit() { JUT_ASSERT(80, rootHeap == NULL); @@ -49,17 +49,17 @@ void JFWSystem::firstInit() { JKRHEAP_NAME(systemHeap, "System"); } -JKRThread* JFWSystem::mainThread; +DUSK_GAME_DATA JKRThread* JFWSystem::mainThread; -JUTDbPrint* JFWSystem::debugPrint; +DUSK_GAME_DATA JUTDbPrint* JFWSystem::debugPrint; -JUTResFont* JFWSystem::systemFont; +DUSK_GAME_DATA JUTResFont* JFWSystem::systemFont; -JUTConsoleManager* JFWSystem::systemConsoleManager; +DUSK_GAME_DATA JUTConsoleManager* JFWSystem::systemConsoleManager; -JUTConsole* JFWSystem::systemConsole; +DUSK_GAME_DATA JUTConsole* JFWSystem::systemConsole; -bool JFWSystem::sInitCalled = false; +DUSK_GAME_DATA bool JFWSystem::sInitCalled = false; void JFWSystem::init() { JUT_ASSERT(101, sInitCalled == false); diff --git a/libs/JSystem/src/JHostIO/JHIMccBuf.cpp b/libs/JSystem/src/JHostIO/JHIMccBuf.cpp index 363eb23dd8..1f9df6be7b 100644 --- a/libs/JSystem/src/JHostIO/JHIMccBuf.cpp +++ b/libs/JSystem/src/JHostIO/JHIMccBuf.cpp @@ -14,8 +14,8 @@ void JHIReport(const char* fmt, ...) {} void JHIHalt(const char* fmt, ...) {} -u8* JHIMccBuf::mTempBuf; -u16 JHIMccBuf::mRefCount; +DUSK_GAME_DATA u8* JHIMccBuf::mTempBuf; +DUSK_GAME_DATA u16 JHIMccBuf::mRefCount; JHIMccBuf::JHIMccBuf(u16 channel, u16 param_1, u32 param_2) { initInstance(channel, param_1, param_2); diff --git a/libs/JSystem/src/JHostIO/JHIRMcc.cpp b/libs/JSystem/src/JHostIO/JHIRMcc.cpp index fc1b295181..f3892f6520 100644 --- a/libs/JSystem/src/JHostIO/JHIRMcc.cpp +++ b/libs/JSystem/src/JHostIO/JHIRMcc.cpp @@ -7,14 +7,14 @@ #include #endif -HIO2DeviceType gExiDevice = HIO2_DEVICE_INVALID; -u8 data_8074bd04 = 1; +DUSK_GAME_DATA HIO2DeviceType gExiDevice = HIO2_DEVICE_INVALID; +DUSK_GAME_DATA u8 data_8074bd04 = 1; -s32 ghHIO2; -JHIMccContext tContext_old; -JHIMccContext tContext_new; -bool data_8074d138; -u8 data_8074d139; +DUSK_GAME_DATA s32 ghHIO2; +DUSK_GAME_DATA JHIMccContext tContext_old; +DUSK_GAME_DATA JHIMccContext tContext_new; +DUSK_GAME_DATA bool data_8074d138; +DUSK_GAME_DATA u8 data_8074d139; BOOL JHIhio2CallbackEnum(HIO2DeviceType type) { gExiDevice = type; diff --git a/libs/JSystem/src/JHostIO/JHIhioASync.cpp b/libs/JSystem/src/JHostIO/JHIhioASync.cpp index b423c366fe..a25e5bd136 100644 --- a/libs/JSystem/src/JHostIO/JHIhioASync.cpp +++ b/libs/JSystem/src/JHostIO/JHIhioASync.cpp @@ -9,16 +9,16 @@ #endif #include "global.h" -u32 gsEnableHostio; -u32 gsEnableInterface; -u32 gsDataToRead; +DUSK_GAME_DATA u32 gsEnableHostio; +DUSK_GAME_DATA u32 gsEnableInterface; +DUSK_GAME_DATA u32 gsDataToRead; -u8* gsReadBuf; -u8* gsWriteBuf; -JHICommBufReader* gsJHIrecvBuf; -JHICommBufWriter* gsJHIsendBuf; +DUSK_GAME_DATA u8* gsReadBuf; +DUSK_GAME_DATA u8* gsWriteBuf; +DUSK_GAME_DATA JHICommBufReader* gsJHIrecvBuf; +DUSK_GAME_DATA JHICommBufWriter* gsJHIsendBuf; -JHIMccContext gMccContext; +DUSK_GAME_DATA JHIMccContext gMccContext; BOOL JHIInit(u32 enabled) { gsEnableHostio = enabled; diff --git a/libs/JSystem/src/JHostIO/JORServer.cpp b/libs/JSystem/src/JHostIO/JORServer.cpp index 62086b259c..cabcf10bb3 100644 --- a/libs/JSystem/src/JHostIO/JORServer.cpp +++ b/libs/JSystem/src/JHostIO/JORServer.cpp @@ -113,7 +113,7 @@ void JORReflexible::listenPropertyEvent(const JORPropertyEvent* pEvent) { } #endif -JORServer* JORServer::instance; +DUSK_GAME_DATA JORServer* JORServer::instance; JORServer* JORServer::create() { if (instance == NULL) { diff --git a/libs/JSystem/src/JKernel/JKRAram.cpp b/libs/JSystem/src/JKernel/JKRAram.cpp index 2770328afa..98829765bc 100644 --- a/libs/JSystem/src/JKernel/JKRAram.cpp +++ b/libs/JSystem/src/JKernel/JKRAram.cpp @@ -27,7 +27,7 @@ static int JKRDecompressFromAramToMainRam(u32 src, void* dst, u32 srcLength, u32 u32 offset, u32* resourceSize); int decompSZS_subroutine(u8* src, u8* dest); -JKRAram* JKRAram::sAramObject; +DUSK_GAME_DATA JKRAram* JKRAram::sAramObject; JKRAram* JKRAram::create(u32 aram_audio_buffer_size, u32 aram_audio_graph_size, s32 stream_priority, s32 decomp_priority, s32 piece_priority) { @@ -48,14 +48,14 @@ void JKRAram::destroy() { } #endif -OSMessage JKRAram::sMessageBuffer[4] = { +DUSK_GAME_DATA OSMessage JKRAram::sMessageBuffer[4] = { NULL, NULL, NULL, NULL, }; -OSMessageQueue JKRAram::sMessageQueue = {0}; +DUSK_GAME_DATA OSMessageQueue JKRAram::sMessageQueue = {0}; JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, s32 priority) : JKRThread(stack_size, 0x10, priority) { @@ -279,11 +279,11 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS } } -JSUList JKRAram::sAramCommandList; +DUSK_GAME_DATA JSUList JKRAram::sAramCommandList; static OSMutex decompMutex; -u32 JKRAram::sSZSBufferSize = 0x00000400; +DUSK_GAME_DATA u32 JKRAram::sSZSBufferSize = 0x00000400; static u8* szpBuf; diff --git a/libs/JSystem/src/JKernel/JKRAramArchive.cpp b/libs/JSystem/src/JKernel/JKRAramArchive.cpp index d6923ee06b..fcb54271e4 100644 --- a/libs/JSystem/src/JKernel/JKRAramArchive.cpp +++ b/libs/JSystem/src/JKernel/JKRAramArchive.cpp @@ -196,6 +196,13 @@ cleanup: void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) { JUT_ASSERT(442, isMounted()); + +#if TARGET_PC + if (void* data = getOverlayData(pEntry, pOutSize); data != nullptr) { + return data; + } +#endif + u32 outSize; u8* outBuf; if (pOutSize == NULL) { @@ -231,6 +238,13 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) { void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* pEntry, u32* resourceSize) { JUT_ASSERT(515, isMounted()); + +#if TARGET_PC + if (copyOverlayData(buffer, bufferSize, pEntry, resourceSize)) { + return buffer; + } +#endif + u32 size = pEntry->data_size; if (size > bufferSize) { size = bufferSize; @@ -337,6 +351,12 @@ u32 JKRAramArchive::getExpandedResSize(const void* ptr) const { return this->getResSize(ptr); } +#if TARGET_PC + if (u32 size; getOverlayResourceSize(ptr, &size)) { + return size; + } +#endif + JKRArchive::SDIFileEntry* entry = this->findPtrResource(ptr); if (entry == NULL) { return 0xFFFFFFFF; diff --git a/libs/JSystem/src/JKernel/JKRAramHeap.cpp b/libs/JSystem/src/JKernel/JKRAramHeap.cpp index 83e5cc9ac7..7b3406383b 100644 --- a/libs/JSystem/src/JKernel/JKRAramHeap.cpp +++ b/libs/JSystem/src/JKernel/JKRAramHeap.cpp @@ -6,7 +6,7 @@ #include #include "os_report.h" -JSUList JKRAramHeap::sAramList; +DUSK_GAME_DATA JSUList JKRAramHeap::sAramList; JKRAramHeap::JKRAramHeap(u32 startAddress, u32 size) { OSInitMutex(&mMutex); diff --git a/libs/JSystem/src/JKernel/JKRAramPiece.cpp b/libs/JSystem/src/JKernel/JKRAramPiece.cpp index 0946275b83..bfbabfd478 100644 --- a/libs/JSystem/src/JKernel/JKRAramPiece.cpp +++ b/libs/JSystem/src/JKernel/JKRAramPiece.cpp @@ -23,12 +23,12 @@ void JKRAramPiece::sendCommand(JKRAMCommand* command) { startDMA(command); } -JSUList JKRAramPiece::sAramPieceCommandList; +DUSK_GAME_DATA JSUList JKRAramPiece::sAramPieceCommandList; -OSMutex JKRAramPiece::mMutex; +DUSK_GAME_DATA OSMutex JKRAramPiece::mMutex; #if DEBUG && TARGET_PC -volatile u8 forceRead; +DUSK_GAME_DATA volatile u8 forceRead; #endif JKRAMCommand* JKRAramPiece::orderAsync(int direction, uintptr_t source, uintptr_t destination, u32 length, diff --git a/libs/JSystem/src/JKernel/JKRAramStream.cpp b/libs/JSystem/src/JKernel/JKRAramStream.cpp index a30f23dfaa..548a044571 100644 --- a/libs/JSystem/src/JKernel/JKRAramStream.cpp +++ b/libs/JSystem/src/JKernel/JKRAramStream.cpp @@ -12,7 +12,7 @@ const u32 stack_size = 0xc00; const u32 stack_size = 0x4000; #endif -JKRAramStream* JKRAramStream::sAramStreamObject; +DUSK_GAME_DATA JKRAramStream* JKRAramStream::sAramStreamObject; JKRAramStream* JKRAramStream::create(s32 priority) { if (!sAramStreamObject) { @@ -23,14 +23,14 @@ JKRAramStream* JKRAramStream::create(s32 priority) { return sAramStreamObject; } -void* JKRAramStream::sMessageBuffer[4] = { +DUSK_GAME_DATA void* JKRAramStream::sMessageBuffer[4] = { NULL, NULL, NULL, NULL, }; -OSMessageQueue JKRAramStream::sMessageQueue = {0}; +DUSK_GAME_DATA OSMessageQueue JKRAramStream::sMessageQueue = {0}; JKRAramStream::JKRAramStream(s32 priority) : JKRThread(stack_size, 0x10, priority) { resume(); @@ -141,11 +141,11 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) { return writtenLength; } -u8* JKRAramStream::transBuffer; +DUSK_GAME_DATA u8* JKRAramStream::transBuffer; -u32 JKRAramStream::transSize; +DUSK_GAME_DATA u32 JKRAramStream::transSize; -JKRHeap* JKRAramStream::transHeap; +DUSK_GAME_DATA JKRHeap* JKRAramStream::transHeap; JKRAramStreamCommand* JKRAramStream::write_StreamToAram_Async(JSUFileInputStream* stream, u32 addr, u32 size, u32 offset, diff --git a/libs/JSystem/src/JKernel/JKRArchivePri.cpp b/libs/JSystem/src/JKernel/JKRArchivePri.cpp index 9da4c2d1aa..f81082cc2f 100644 --- a/libs/JSystem/src/JKernel/JKRArchivePri.cpp +++ b/libs/JSystem/src/JKernel/JKRArchivePri.cpp @@ -7,9 +7,43 @@ #if TARGET_PC #include +#include +#include +#include +#include +#include +#include +#include "JSystem/JKernel/JKRDvdRipper.h" +#if _WIN32 +#include #endif -u32 JKRArchive::sCurrentDirID; +std::atomic JKRArchive::sArcOverlayGeneration{0}; + +namespace { + +inline constexpr borealis::Log Log{"JKRArchivePri"}; + +void* alloc_overlay_buffer(u32 size) { +#if _WIN32 + return _aligned_malloc(size, alignof(std::max_align_t)); +#else + return std::malloc(size); +#endif +} + +void free_overlay_buffer(void* data) { +#if _WIN32 + _aligned_free(data); +#else + std::free(data); +#endif +} + +} // namespace +#endif + +DUSK_GAME_DATA u32 JKRArchive::sCurrentDirID; JKRArchive::JKRArchive() { mIsMounted = false; @@ -42,6 +76,7 @@ JKRArchive::JKRArchive(s32 entryNumber, JKRArchive::EMountMode mountMode) { JKRArchive::~JKRArchive() { #if TARGET_PC + removeAllOverlayResources(); if (mFileData != nullptr) { JKRHeap::getSystemHeap()->free(mFileData); mFileData = nullptr; @@ -270,4 +305,246 @@ void JKRArchive::initFileDataPointers() { mFiles[i].index = i; } } + +void JKRArchive::notifyOverlayFilesChanged() { + sArcOverlayGeneration.fetch_add(1, std::memory_order_release); +} + +bool JKRArchive::buildArcOverlaysPath() const { + if (mArcOverlaysPathResolved) { + return !mArcOverlaysPath.empty(); + } + mArcOverlaysPathResolved = true; + + if (mEntryNum < 0) { + return false; + } + + char pathBuffer[1024]; + if (!DVDConvertEntrynumToPath(mEntryNum, pathBuffer, sizeof(pathBuffer))) { + return false; + } + + std::string path{pathBuffer}; + constexpr std::string_view extension{".arc"}; + if (path.size() < extension.size() || + path.compare(path.size() - extension.size(), extension.size(), extension) != 0) + { + return false; + } + path.resize(path.size() - extension.size()); + path.push_back('/'); + + mArcOverlaysPath = std::move(path); + return true; +} + +void JKRArchive::buildIndexToPathMap(u32 dirIndex, const std::string& currentPath) const { + const SDIDirEntry& dir = mNodes[dirIndex]; + for (int i = 0; i < dir.num_entries; i++) { + const SDIFileEntry& entry = mFiles[dir.first_file_index + i]; + std::string entryName{&mStringTable[entry.getNameOffset()]}; + if (entryName == "." || entryName == "..") { + continue; + } + if (entry.isDirectory()) { + buildIndexToPathMap(entry.data_offset, currentPath + entryName + "/"); + } else { + mIdxToPathMap[entry.index] = currentPath + entryName; + } + } +} + +bool JKRArchive::getOverlayPath(SDIFileEntry* entry, std::string& path) const { + if (entry == nullptr || !buildArcOverlaysPath()) { + return false; + } + + if (mIdxToPathMap.empty()) { + buildIndexToPathMap(0, std::string{&mStringTable[mNodes[0].name_offset]} + "/"); + } + + const auto pathIt = mIdxToPathMap.find(entry->index); + if (pathIt == mIdxToPathMap.end()) { + return false; + } + + path = mArcOverlaysPath + pathIt->second; + return true; +} + +void* JKRArchive::getActiveOverlayData(SDIFileEntry* entry, u32* outSize) const { + const auto activeIt = mActiveArcOverlayResources.find(entry->index); + if (activeIt == mActiveArcOverlayResources.end()) { + return nullptr; + } + + const auto resourceIt = mArcOverlayResources.find(activeIt->second); + const u64 generation = sArcOverlayGeneration.load(std::memory_order_acquire); + if (resourceIt == mArcOverlayResources.end() || resourceIt->second.generation != generation) { + // Keep the allocation owned so raw pointers returned by earlier fetches remain valid. + mActiveArcOverlayResources.erase(activeIt); + return nullptr; + } + + if (outSize != nullptr) { + *outSize = resourceIt->second.size; + } + return resourceIt->first; +} + +void* JKRArchive::getOverlayData(SDIFileEntry* entry, u32* outSize) { + if (entry == nullptr) { + return nullptr; + } + + if (void* data = getActiveOverlayData(entry, outSize)) { + return data; + } + + std::string path; + if (!getOverlayPath(entry, path)) { + return nullptr; + } + + constexpr u32 alignmentMask = 0x1f; + const u64 generation = sArcOverlayGeneration.load(std::memory_order_acquire); + DVDFileInfo fileInfo{}; + if (!DVDOpen(path.c_str(), &fileInfo)) { + return nullptr; + } + + const u32 logicalSize = fileInfo.length; + if (logicalSize > static_cast(std::numeric_limits::max()) - alignmentMask) { + DVDClose(&fileInfo); + return nullptr; + } + + const u32 readSize = ALIGN_NEXT(logicalSize, 0x20); + const u32 allocationSize = readSize == 0 ? 1 : readSize; + void* data = alloc_overlay_buffer(allocationSize); + if (data == nullptr) { + DVDClose(&fileInfo); + return nullptr; + } + + const s32 status = DVDReadPrio(&fileInfo, data, readSize, 0, 2); + DVDClose(&fileInfo); + if (status < DVD_RESULT_GOOD || static_cast(status) != logicalSize) { + free_overlay_buffer(data); + return nullptr; + } + + mArcOverlayResources.emplace(data, ArcOverlayResource{ + .entryIndex = entry->index, + .size = logicalSize, + .generation = generation, + }); + mActiveArcOverlayResources[entry->index] = data; + + if (outSize != nullptr) { + *outSize = logicalSize; + } + return data; +} + +bool JKRArchive::copyOverlayData(void* buffer, u32 bufferSize, SDIFileEntry* entry, u32* outSize) { + u32 overlaySize; + const void* overlayData = getOverlayData(entry, &overlaySize); + if (overlayData == nullptr) { + return false; + } + + if (overlaySize > bufferSize) { + std::string path; + getOverlayPath(entry, path); + Log.error("Overlay %s is %u bytes but the game reserved %u\n", path.c_str(), overlaySize, + bufferSize); + return false; + } + if (overlaySize != 0) { + memcpy(buffer, overlayData, overlaySize); + } + if (outSize != nullptr) { + *outSize = overlaySize; + } + return true; +} + +bool JKRArchive::getOverlayResourceSize(const void* data, u32* outSize) const { + const auto resourceIt = mArcOverlayResources.find(const_cast(data)); + if (resourceIt == mArcOverlayResources.end()) { + return false; + } + + if (outSize != nullptr) { + *outSize = resourceIt->second.size; + } + return true; +} + +bool JKRArchive::getOverlayFileSize(SDIFileEntry* entry, u32* outSize) const { + if (entry == nullptr) { + return false; + } + + u32 activeSize; + if (getActiveOverlayData(entry, &activeSize) != nullptr) { + if (outSize != nullptr) { + *outSize = activeSize; + } + return true; + } + + std::string path; + if (!getOverlayPath(entry, path)) { + return false; + } + + DVDFileInfo fileInfo{}; + if (!DVDOpen(path.c_str(), &fileInfo)) { + return false; + } + + if (outSize != nullptr) { + *outSize = fileInfo.length; + } + DVDClose(&fileInfo); + return true; +} + +u32 JKRArchive::getFileSize(SDIFileEntry* entry) const { + u32 size; + if (getOverlayFileSize(entry, &size)) { + return size; + } + return entry != nullptr ? entry->getSize() : 0; +} + +bool JKRArchive::removeOverlayResource(void* resource, bool freeResource) { + const auto resourceIt = mArcOverlayResources.find(resource); + if (resourceIt == mArcOverlayResources.end()) { + return false; + } + + const auto activeIt = mActiveArcOverlayResources.find(resourceIt->second.entryIndex); + if (activeIt != mActiveArcOverlayResources.end() && activeIt->second == resource) { + mActiveArcOverlayResources.erase(activeIt); + } + + if (freeResource) { + free_overlay_buffer(resource); + } + mArcOverlayResources.erase(resourceIt); + return true; +} + +void JKRArchive::removeAllOverlayResources() { + mActiveArcOverlayResources.clear(); + for (const auto& key : mArcOverlayResources | std::views::keys) { + free_overlay_buffer(key); + } + mArcOverlayResources.clear(); +} + #endif diff --git a/libs/JSystem/src/JKernel/JKRArchivePub.cpp b/libs/JSystem/src/JKernel/JKRArchivePub.cpp index 731a049457..97306c9033 100644 --- a/libs/JSystem/src/JKernel/JKRArchivePub.cpp +++ b/libs/JSystem/src/JKernel/JKRArchivePub.cpp @@ -246,6 +246,7 @@ u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u16 id) { void JKRArchive::removeResourceAll() { if (mArcInfoBlock && mMountMode != MOUNT_MEM) { + IF_DUSK(removeAllOverlayResources();) SDIFileEntry* fileEntry = mFiles; for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) { if (JKAR_DATA(fileEntry)) { @@ -259,6 +260,13 @@ void JKRArchive::removeResourceAll() { bool JKRArchive::removeResource(void* resource) { JUT_ASSERT(678, resource != NULL); + +#if TARGET_PC + if (removeOverlayResource(resource, true)) { + return true; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (fileEntry == NULL) return false; @@ -270,6 +278,13 @@ bool JKRArchive::removeResource(void* resource) { bool JKRArchive::detachResource(void* resource) { JUT_ASSERT(707, resource != NULL); + +#if TARGET_PC + if (removeOverlayResource(resource, false)) { + return true; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (fileEntry == NULL) return false; @@ -280,6 +295,13 @@ bool JKRArchive::detachResource(void* resource) { u32 JKRArchive::getResSize(const void* resource) const { JUT_ASSERT(732, resource != NULL); + +#if TARGET_PC + if (u32 size; getOverlayResourceSize(resource, &size)) { + return size; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (fileEntry == NULL) return -1; diff --git a/libs/JSystem/src/JKernel/JKRCompArchive.cpp b/libs/JSystem/src/JKernel/JKRCompArchive.cpp index 716aaa2838..acac590ec0 100644 --- a/libs/JSystem/src/JKernel/JKRCompArchive.cpp +++ b/libs/JSystem/src/JKernel/JKRCompArchive.cpp @@ -226,6 +226,13 @@ bool JKRCompArchive::open(s32 entryNum) { void* JKRCompArchive::fetchResource(SDIFileEntry *fileEntry, u32 *pSize) { JUT_ASSERT(597, isMounted()); + +#if TARGET_PC + if (void* data = getOverlayData(fileEntry, pSize); data != nullptr) { + return data; + } +#endif + u32 ptrSize; u32 size = fileEntry->data_size; int compression = JKRConvertAttrToCompressionType(u8(fileEntry->type_flags_and_name_offset >> 0x18)); @@ -274,6 +281,13 @@ void *JKRCompArchive::fetchResource(void *data, u32 compressedSize, SDIFileEntry { u32 size = 0; JUT_ASSERT(708, isMounted()); + +#if TARGET_PC + if (copyOverlayData(data, compressedSize, fileEntry, pSize)) { + return data; + } +#endif + u32 fileSize = fileEntry->data_size; u32 alignedSize = ALIGN_NEXT(fileSize, 32); u32 fileFlag = fileEntry->type_flags_and_name_offset >> 0x18; @@ -319,6 +333,7 @@ void *JKRCompArchive::fetchResource(void *data, u32 compressedSize, SDIFileEntry void JKRCompArchive::removeResourceAll() { if (mArcInfoBlock != NULL && mMountMode != MOUNT_MEM) { + IF_DUSK(removeAllOverlayResources();) SDIFileEntry* fileEntry = mFiles; for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) { int tmp = fileEntry->type_flags_and_name_offset >> 0x18; @@ -336,6 +351,12 @@ void JKRCompArchive::removeResourceAll() { } bool JKRCompArchive::removeResource(void* resource) { +#if TARGET_PC + if (removeOverlayResource(resource, true)) { + return true; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (!fileEntry) return false; @@ -356,6 +377,12 @@ u32 JKRCompArchive::getExpandedResSize(const void *resource) const return getResSize(resource); } +#if TARGET_PC + if (u32 size; getOverlayResourceSize(resource, &size)) { + return size; + } +#endif + SDIFileEntry *fileEntry = findPtrResource(resource); if(!fileEntry) { return 0xffffffff; diff --git a/libs/JSystem/src/JKernel/JKRDecomp.cpp b/libs/JSystem/src/JKernel/JKRDecomp.cpp index a97edea0a3..2f8b9a68d7 100644 --- a/libs/JSystem/src/JKernel/JKRDecomp.cpp +++ b/libs/JSystem/src/JKernel/JKRDecomp.cpp @@ -10,7 +10,7 @@ const u32 stack_size = 0x800; const u32 stack_size = 0x4000; #endif -JKRDecomp* JKRDecomp::sDecompObject; +DUSK_GAME_DATA JKRDecomp* JKRDecomp::sDecompObject; JKRDecomp* JKRDecomp::create(s32 priority) { if (!sDecompObject) { @@ -29,9 +29,9 @@ void JKRDecomp::destroy() { } #endif -OSMessage JKRDecomp::sMessageBuffer[8] = {0}; +DUSK_GAME_DATA OSMessage JKRDecomp::sMessageBuffer[8] = {0}; -OSMessageQueue JKRDecomp::sMessageQueue = {0}; +DUSK_GAME_DATA OSMessageQueue JKRDecomp::sMessageQueue = {0}; JKRDecomp::JKRDecomp(s32 priority) : JKRThread(stack_size, 0x10, priority) { resume(); diff --git a/libs/JSystem/src/JKernel/JKRDvdAramRipper.cpp b/libs/JSystem/src/JKernel/JKRDvdAramRipper.cpp index 9472539e24..22f040b360 100644 --- a/libs/JSystem/src/JKernel/JKRDvdAramRipper.cpp +++ b/libs/JSystem/src/JKernel/JKRDvdAramRipper.cpp @@ -75,9 +75,9 @@ JKRADCommand* JKRDvdAramRipper::loadToAram_Async(JKRDvdFile* dvdFile, u32 addres return command; } -JSUList JKRDvdAramRipper::sDvdAramAsyncList; +DUSK_GAME_DATA JSUList JKRDvdAramRipper::sDvdAramAsyncList; -bool JKRDvdAramRipper::errorRetry = true; +DUSK_GAME_DATA bool JKRDvdAramRipper::errorRetry = true; JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) { s32 compression; @@ -228,7 +228,7 @@ JKRADCommand::~JKRADCommand() { static OSMutex decompMutex; -u32 JKRDvdAramRipper::sSZSBufferSize = 0x00000400; +DUSK_GAME_DATA u32 JKRDvdAramRipper::sSZSBufferSize = 0x00000400; static u8* szpBuf; diff --git a/libs/JSystem/src/JKernel/JKRDvdArchive.cpp b/libs/JSystem/src/JKernel/JKRDvdArchive.cpp index b82302c900..d599879f8f 100644 --- a/libs/JSystem/src/JKernel/JKRDvdArchive.cpp +++ b/libs/JSystem/src/JKernel/JKRDvdArchive.cpp @@ -147,6 +147,13 @@ cleanup: void* JKRDvdArchive::fetchResource(SDIFileEntry* fileEntry, u32* returnSize) { JUT_ASSERT(428, isMounted()); + +#if TARGET_PC + if (void* data = getOverlayData(fileEntry, returnSize); data != nullptr) { + return data; + } +#endif + u32 tempReturnSize; if (returnSize == NULL) { returnSize = &tempReturnSize; @@ -181,6 +188,13 @@ void* JKRDvdArchive::fetchResource(SDIFileEntry* fileEntry, u32* returnSize) { void* JKRDvdArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* fileEntry, u32* returnSize) { JUT_ASSERT(504, isMounted()); + +#if TARGET_PC + if (copyOverlayData(buffer, bufferSize, fileEntry, returnSize)) { + return buffer; + } +#endif + u32 size = fileEntry->data_size; JKRCompression fileCompression = JKRConvertAttrToCompressionType(u8(fileEntry->type_flags_and_name_offset >> 24)); @@ -344,6 +358,12 @@ u32 JKRDvdArchive::getExpandedResSize(const void* resource) const { return getResSize(resource); } +#if TARGET_PC + if (u32 size; getOverlayResourceSize(resource, &size)) { + return size; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (!fileEntry) { return -1; diff --git a/libs/JSystem/src/JKernel/JKRDvdFile.cpp b/libs/JSystem/src/JKernel/JKRDvdFile.cpp index face6c824b..83f7d4d333 100644 --- a/libs/JSystem/src/JKernel/JKRDvdFile.cpp +++ b/libs/JSystem/src/JKernel/JKRDvdFile.cpp @@ -5,7 +5,7 @@ #include "JSystem/JUtility/JUTException.h" #include -JSUList JKRDvdFile::sDvdList; +DUSK_GAME_DATA JSUList JKRDvdFile::sDvdList; JKRDvdFile::JKRDvdFile() : mDvdLink(this) { initiate(); diff --git a/libs/JSystem/src/JKernel/JKRDvdRipper.cpp b/libs/JSystem/src/JKernel/JKRDvdRipper.cpp index ae65f42ba3..2c2d521b3a 100644 --- a/libs/JSystem/src/JKernel/JKRDvdRipper.cpp +++ b/libs/JSystem/src/JKernel/JKRDvdRipper.cpp @@ -44,7 +44,7 @@ void* JKRDvdRipper::loadToMainRAM(s32 entryNumber, u8* dst, JKRExpandSwitch expa pCompression, param_8); } -bool JKRDvdRipper::errorRetry = true; +DUSK_GAME_DATA bool JKRDvdRipper::errorRetry = true; void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength, JKRHeap* heap, @@ -236,13 +236,13 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch static u8 lit_491[12]; -JSUList JKRDvdRipper::sDvdAsyncList; +DUSK_GAME_DATA JSUList JKRDvdRipper::sDvdAsyncList; static OSMutex decompMutex; -u32 JKRDvdRipper::sSZSBufferSize = 0x00000400; +DUSK_GAME_DATA u32 JKRDvdRipper::sSZSBufferSize = 0x00000400; -JKRHeap* JKRDvdRipper::sHeap = NULL; +DUSK_GAME_DATA JKRHeap* JKRDvdRipper::sHeap = NULL; static u8* szpBuf; diff --git a/libs/JSystem/src/JKernel/JKRFileCache.cpp b/libs/JSystem/src/JKernel/JKRFileCache.cpp index 1a97ddefa3..a4795602c0 100644 --- a/libs/JSystem/src/JKernel/JKRFileCache.cpp +++ b/libs/JSystem/src/JKernel/JKRFileCache.cpp @@ -8,7 +8,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" JKRFileCache* JKRFileCache::mount(const char* path, JKRHeap* heap, const char* param_3) { diff --git a/libs/JSystem/src/JKernel/JKRFileLoader.cpp b/libs/JSystem/src/JKernel/JKRFileLoader.cpp index 4a7fa00d10..0ff00f5f84 100644 --- a/libs/JSystem/src/JKernel/JKRFileLoader.cpp +++ b/libs/JSystem/src/JKernel/JKRFileLoader.cpp @@ -8,11 +8,11 @@ #include #include #include "JSystem/JKernel/JKRHeap.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" -JKRFileLoader* JKRFileLoader::sCurrentVolume; -JSUList JKRFileLoader::sVolumeList; +DUSK_GAME_DATA JKRFileLoader* JKRFileLoader::sCurrentVolume; +DUSK_GAME_DATA JSUList JKRFileLoader::sVolumeList; JKRFileLoader::JKRFileLoader(void) : mFileLoaderLink(this), mVolumeName(NULL), mVolumeType(0), mMountCount(0) {} diff --git a/libs/JSystem/src/JKernel/JKRHeap.cpp b/libs/JSystem/src/JKernel/JKRHeap.cpp index c4849437ac..3c329e0a43 100644 --- a/libs/JSystem/src/JKernel/JKRHeap.cpp +++ b/libs/JSystem/src/JKernel/JKRHeap.cpp @@ -15,7 +15,7 @@ #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JUtility/JUTException.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #ifdef __MWERKS__ #include #else @@ -28,14 +28,14 @@ #include "os_report.h" #if DEBUG -u8 JKRValue_DEBUGFILL_NOTUSE = 0xFD; -u8 JKRValue_DEBUGFILL_NEW = 0xCD; -u8 JKRValue_DEBUGFILL_DELETE = 0xDD; +DUSK_GAME_DATA u8 JKRValue_DEBUGFILL_NOTUSE = 0xFD; +DUSK_GAME_DATA u8 JKRValue_DEBUGFILL_NEW = 0xCD; +DUSK_GAME_DATA u8 JKRValue_DEBUGFILL_DELETE = 0xDD; #endif -bool JKRHeap::sDefaultFillFlag = true; +DUSK_GAME_DATA bool JKRHeap::sDefaultFillFlag = true; -JKRHeap* JKRHeap::sSystemHeap; +DUSK_GAME_DATA JKRHeap* JKRHeap::sSystemHeap; #if TARGET_PC // JSystem normally has a thread switch callback to track the correct heap. @@ -52,13 +52,13 @@ static thread_local TLS_GLOBAL_DYNAMIC JKRHeap* sCurrentHeap; JKRHeap* JKRHeap::sCurrentHeap; #endif -JKRHeap* JKRHeap::sRootHeap; +DUSK_GAME_DATA JKRHeap* JKRHeap::sRootHeap; #if PLATFORM_WII || PLATFORM_SHIELD JKRHeap* JKRHeap::sRootHeap2; #endif -JKRErrorHandler JKRHeap::mErrorHandler; +DUSK_GAME_DATA JKRErrorHandler JKRHeap::mErrorHandler; static bool data_80451380; @@ -111,19 +111,19 @@ JKRHeap::~JKRHeap() { } } -void* JKRHeap::mCodeStart; +DUSK_GAME_DATA void* JKRHeap::mCodeStart; -void* JKRHeap::mCodeEnd; +DUSK_GAME_DATA void* JKRHeap::mCodeEnd; -void* JKRHeap::mUserRamStart; +DUSK_GAME_DATA void* JKRHeap::mUserRamStart; -void* JKRHeap::mUserRamEnd; +DUSK_GAME_DATA void* JKRHeap::mUserRamEnd; -u32 JKRHeap::mMemorySize; +DUSK_GAME_DATA u32 JKRHeap::mMemorySize; -JKRHeap::JKRAllocCallback JKRHeap::sAllocCallback; +DUSK_GAME_DATA JKRHeap::JKRAllocCallback JKRHeap::sAllocCallback; -JKRHeap::JKRFreeCallback JKRHeap::sFreeCallback; +DUSK_GAME_DATA JKRHeap::JKRFreeCallback JKRHeap::sFreeCallback; bool JKRHeap::initArena(char** memory, u32* size, int maxHeaps) { void* arenaLo = OSGetArenaLo(); @@ -661,8 +661,8 @@ void operator delete[](void* ptr JKR_HEAP_TOKEN_PARAM) IF_DUSK(noexcept) { } #endif -s32 fillcheck_dispcount = 100; -bool data_8074A8D0_debug = true; +DUSK_GAME_DATA s32 fillcheck_dispcount = 100; +DUSK_GAME_DATA bool data_8074A8D0_debug = true; void JKRHeap::state_register(JKRHeap::TState* p, u32 id) const { JUT_ASSERT(1213, p != NULL); @@ -680,7 +680,7 @@ void JKRHeap::state_dump(const JKRHeap::TState& p) const { JUT_LOG(1248, "used size : %u", p.getUsedSize()); } -void* ARALT_AramStartAdr = (void*)0x90000000; +DUSK_GAME_DATA void* ARALT_AramStartAdr = (void*)0x90000000; void* JKRHeap::getAltAramStartAdr() { return ARALT_AramStartAdr; } @@ -702,7 +702,7 @@ JKRHeap* JKRHeap::getCurrentHeap() { } void JKRHeap::setName(const char* name) { - dusk::SafeStringCopyTruncate(mName, name); + SafeStringCopyTruncate(mName, name); } void JKRHeap::setNamef(const char* fmt, ...) { diff --git a/libs/JSystem/src/JKernel/JKRMemArchive.cpp b/libs/JSystem/src/JKernel/JKRMemArchive.cpp index d3b17d8a63..f0feabe3be 100644 --- a/libs/JSystem/src/JKernel/JKRMemArchive.cpp +++ b/libs/JSystem/src/JKernel/JKRMemArchive.cpp @@ -135,6 +135,13 @@ bool JKRMemArchive::open(void* buffer, u32 bufferSize, JKRMemBreakFlag flag) { void* JKRMemArchive::fetchResource(SDIFileEntry* fileEntry, u32* resourceSize) { JUT_ASSERT(555, isMounted()); + +#if TARGET_PC + if (void* data = getOverlayData(fileEntry, resourceSize); data != nullptr) { + return data; + } +#endif + if (!JKAR_DATA(fileEntry)) { JKAR_DATA(fileEntry) = mArchiveData + fileEntry->data_offset; } @@ -149,6 +156,13 @@ void* JKRMemArchive::fetchResource(SDIFileEntry* fileEntry, u32* resourceSize) { void* JKRMemArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* fileEntry, u32* resourceSize) { JUT_ASSERT(595, isMounted()); + +#if TARGET_PC + if (copyOverlayData(buffer, bufferSize, fileEntry, resourceSize)) { + return buffer; + } +#endif + u32 srcLength = fileEntry->data_size; if (srcLength > bufferSize) { srcLength = bufferSize; @@ -173,6 +187,8 @@ void* JKRMemArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* f void JKRMemArchive::removeResourceAll(void) { JUT_ASSERT(642, isMounted()); + IF_DUSK(removeAllOverlayResources();) + if (mArcInfoBlock == NULL) return; if (mMountMode == MOUNT_MEM) @@ -192,6 +208,12 @@ void JKRMemArchive::removeResourceAll(void) { bool JKRMemArchive::removeResource(void* resource) { JUT_ASSERT(673, isMounted()); +#if TARGET_PC + if (removeOverlayResource(resource, true)) { + return true; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (!fileEntry) return false; @@ -231,6 +253,12 @@ u32 JKRMemArchive::fetchResource_subroutine(u8* src, u32 srcLength, u8* dst, u32 } u32 JKRMemArchive::getExpandedResSize(const void* resource) const { +#if TARGET_PC + if (u32 overlaySize; getOverlayResourceSize(resource, &overlaySize)) { + return overlaySize; + } +#endif + SDIFileEntry* fileEntry = findPtrResource(resource); if (fileEntry == NULL) return -1; diff --git a/libs/JSystem/src/JKernel/JKRThread.cpp b/libs/JSystem/src/JKernel/JKRThread.cpp index 8c945aba32..73135381eb 100644 --- a/libs/JSystem/src/JKernel/JKRThread.cpp +++ b/libs/JSystem/src/JKernel/JKRThread.cpp @@ -7,25 +7,25 @@ #include "global.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if TARGET_PC #include "dusk/os.h" #endif -JSUList JKRThread::sThreadList(0); +DUSK_GAME_DATA JSUList JKRThread::sThreadList(0); -void* JKRIdleThread::sThread; +DUSK_GAME_DATA void* JKRIdleThread::sThread; -JKRThreadSwitch* JKRThreadSwitch::sManager; +DUSK_GAME_DATA JKRThreadSwitch* JKRThreadSwitch::sManager; -u32 JKRThreadSwitch::sTotalCount; +DUSK_GAME_DATA u32 JKRThreadSwitch::sTotalCount; -u64 JKRThreadSwitch::sTotalStart; +DUSK_GAME_DATA u64 JKRThreadSwitch::sTotalStart; -JKRThreadSwitch_PreCallback JKRThreadSwitch::mUserPreCallback; +DUSK_GAME_DATA JKRThreadSwitch_PreCallback JKRThreadSwitch::mUserPreCallback; -JKRThreadSwitch_PostCallback JKRThreadSwitch::mUserPostCallback; +DUSK_GAME_DATA JKRThreadSwitch_PostCallback JKRThreadSwitch::mUserPostCallback; JKRThread::JKRThread(u32 stack_size, int message_count, int param_3) : mThreadListLink(this) { JKRHeap* heap = JKRHeap::findFromRoot(this); @@ -358,10 +358,10 @@ static void dummy(JKRIdleThread* thread) { #pragma push #pragma force_active on -JSUList JKRTask::sTaskList; +DUSK_GAME_DATA JSUList JKRTask::sTaskList; #pragma pop #pragma push #pragma force_active on -u8 JKRTask::sEndMesgQueue[32]; +DUSK_GAME_DATA u8 JKRTask::sEndMesgQueue[32]; #pragma pop diff --git a/libs/JSystem/src/JMath/JMATrigonometric.cpp b/libs/JSystem/src/JMath/JMATrigonometric.cpp index 5d394ac9c2..cc8ce129e6 100644 --- a/libs/JSystem/src/JMath/JMATrigonometric.cpp +++ b/libs/JSystem/src/JMath/JMATrigonometric.cpp @@ -16,10 +16,10 @@ inline f64 getConst2() { return 9.765625E-4; } -TSinCosTable<13, f32> sincosTable_ ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA TSinCosTable<13, f32> sincosTable_; -TAtanTable<1024, f32> atanTable_ ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA TAtanTable<1024, f32> atanTable_; -TAsinAcosTable<1024, f32> asinAcosTable_ ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA TAsinAcosTable<1024, f32> asinAcosTable_; } // namespace JMath diff --git a/libs/JSystem/src/JMessage/control.cpp b/libs/JSystem/src/JMessage/control.cpp index acd5387f77..e739d2f672 100644 --- a/libs/JSystem/src/JMessage/control.cpp +++ b/libs/JSystem/src/JMessage/control.cpp @@ -7,6 +7,10 @@ #include "JSystem/JMessage/control.h" +#if TARGET_PC +#include "dusk/mods/svc/flow.hpp" +#endif + JMessage::TControl::TControl() : pSequenceProcessor_(NULL), pRenderingProcessor_(NULL), @@ -19,9 +23,16 @@ JMessage::TControl::TControl() pMessageText_current_(NULL) {} -JMessage::TControl::~TControl() {} +JMessage::TControl::~TControl() { +#if TARGET_PC + dusk::flow::release_message_control(this); +#endif +} void JMessage::TControl::reset() { +#if TARGET_PC + dusk::flow::release_message_control(this); +#endif pEntry_ = NULL; pMessageText_begin_ = NULL; pszText_update_current_ = NULL; @@ -78,18 +89,57 @@ int JMessage::TControl::setMessageID(u32 uMsgID, u32 param_1, bool* pbValid) { } bool JMessage::TControl::setMessageCode_inSequence_(JMessage::TProcessor const* pProcessor, u16 u16GroupID, u16 u16Index) { +#if TARGET_PC + const TResource* resource = NULL; + const void* resolvedEntry = NULL; + const char* resolvedText = NULL; + if (u16Index >= dusk::flow::kCustomMessageMin) { + if (!dusk::flow::custom_message_for_processor( + this, pProcessor, u16Index, resource, resolvedEntry, resolvedText)) + { + return false; + } + const_cast(pProcessor)->setResourceCache(const_cast(resource)); + } else { + resource = pProcessor->getResource_groupID(u16GroupID); + if (resource == NULL) { + return false; + } + const void* nativeEntry = resource->getMessageEntry_messageIndex(u16Index); + const char* nativeText = + nativeEntry != NULL ? resource->getMessageText_messageEntry(nativeEntry) : NULL; + resolvedEntry = nativeEntry; + resolvedText = nativeText; + dusk::flow::resolve_message_for_control(this, resource->oParse_THeader_.getRaw(), u16Index, + nativeEntry, nativeText, resolvedEntry, resolvedText); + } + pEntry_ = const_cast(resolvedEntry); + if (pEntry_ == NULL || resolvedText == NULL) { + return false; + } +#else pEntry_ = pProcessor->getMessageEntry_messageCode(u16GroupID, u16Index); if (pEntry_ == NULL) { return false; } +#endif +#if TARGET_PC + uMessageGroupID_ = resource->getGroupID(); + pResourceCache_ = resource; +#else uMessageGroupID_ = u16GroupID; - uMessageID_ = u16Index; - pResourceCache_ = pProcessor->getResourceCache(); +#endif + uMessageID_ = u16Index; + JUT_ASSERT(155, pResourceCache_!=NULL); +#if TARGET_PC + pMessageText_begin_ = resolvedText; +#else pMessageText_begin_ = pResourceCache_->getMessageText_messageEntry(pEntry_); +#endif pMessageText_current_ = pMessageText_begin_; oStack_renderingProcessor_.clear(); return true; diff --git a/libs/JSystem/src/JMessage/data.cpp b/libs/JSystem/src/JMessage/data.cpp index 29c96c18c7..4ff9919594 100644 --- a/libs/JSystem/src/JMessage/data.cpp +++ b/libs/JSystem/src/JMessage/data.cpp @@ -2,6 +2,6 @@ #include "JSystem/JMessage/data.h" -const BE(u32) JMessage::data::ga4cSignature = 'MESG'; +DUSK_GAME_DATA const BE(u32) JMessage::data::ga4cSignature = 'MESG'; -const BE(u32) JMessage::data::ga4cSignature_color = 'MGCL'; +DUSK_GAME_DATA const BE(u32) JMessage::data::ga4cSignature_color = 'MGCL'; diff --git a/libs/JSystem/src/JMessage/processor.cpp b/libs/JSystem/src/JMessage/processor.cpp index eef50e7516..08b0af0b7a 100644 --- a/libs/JSystem/src/JMessage/processor.cpp +++ b/libs/JSystem/src/JMessage/processor.cpp @@ -5,15 +5,26 @@ #include "JSystem/JUtility/JUTAssert.h" #include +#if TARGET_PC +#include "dusk/mods/svc/flow.hpp" +#endif + JMessage::TReference::~TReference() {} const char* JMessage::TReference::do_word(u32 param_0) const { return NULL; } -JMessage::TProcessor::~TProcessor() {} +JMessage::TProcessor::~TProcessor() { +#if TARGET_PC + dusk::flow::release_message_processor(this); +#endif +} void JMessage::TProcessor::reset() { +#if TARGET_PC + dusk::flow::release_message_processor(this); +#endif on_resetStatus_(NULL); do_reset(); } @@ -44,6 +55,15 @@ const JMessage::TResource* JMessage::TProcessor::getResource_groupID(u16 u16Grou } u32 JMessage::TProcessor::toMessageCode_messageID(u32 uMsgID, u32 param_1, bool* pbValid) const { +#if TARGET_PC + u32 customCode = 0; + if (dusk::flow::message_code_for_id(this, uMsgID, customCode)) { + if (pbValid != NULL) { + *pbValid = true; + } + return customCode; + } +#endif const TResource* pResourceCache = (const TResource*)getResourceCache(); if (pResourceCache != NULL) { u16 u16Index = pResourceCache->toMessageIndex_messageID(uMsgID, param_1, pbValid); @@ -73,6 +93,74 @@ u32 JMessage::TProcessor::toMessageCode_messageID(u32 uMsgID, u32 param_1, bool* return 0xFFFFFFFF; } +#if TARGET_PC +void* JMessage::TProcessor::getMessageEntry_messageCode(u16 groupId, u16 index) const { + if (index >= dusk::flow::kCustomMessageMin) { + const TResource* customResource = NULL; + const void* customEntry = NULL; + const char* customText = NULL; + if (!dusk::flow::custom_message_for_processor( + NULL, this, index, customResource, customEntry, customText)) + { + return NULL; + } + const_cast(this)->setResourceCache(const_cast(customResource)); + return const_cast(customEntry); + } + const TResource* resource = getResource_groupID(groupId); + if (resource == NULL) { + return NULL; + } + void* nativeEntry = resource->getMessageEntry_messageIndex(index); + const char* nativeText = + nativeEntry != NULL ? resource->getMessageText_messageEntry(nativeEntry) : NULL; + const void* resolvedEntry = nativeEntry; + const char* resolvedText = nativeText; + dusk::flow::resolve_message(this, resource->oParse_THeader_.getRaw(), index, nativeEntry, + nativeText, resolvedEntry, resolvedText); + return const_cast(resolvedEntry); +} + +const char* JMessage::TProcessor::getMessageText_messageCode(u16 groupId, u16 index) const { + if (index >= dusk::flow::kCustomMessageMin) { + const TResource* customResource = NULL; + const void* customEntry = NULL; + const char* customText = NULL; + if (!dusk::flow::custom_message_for_processor( + NULL, this, index, customResource, customEntry, customText)) + { + return NULL; + } + const_cast(this)->setResourceCache(const_cast(customResource)); + return customText; + } + const TResource* resource = getResource_groupID(groupId); + if (resource == NULL) { + return NULL; + } + const void* nativeEntry = resource->getMessageEntry_messageIndex(index); + const char* nativeText = + nativeEntry != NULL ? resource->getMessageText_messageEntry(nativeEntry) : NULL; + const void* resolvedEntry = nativeEntry; + const char* resolvedText = nativeText; + dusk::flow::resolve_message(this, resource->oParse_THeader_.getRaw(), index, nativeEntry, + nativeText, resolvedEntry, resolvedText); + return resolvedText; +} + +const char* JMessage::TProcessor::on_message_limited(u16 index) const { + JUT_ASSERT(482, pResourceCache_!=NULL); + const void* nativeEntry = pResourceCache_->getMessageEntry_messageIndex(index); + const char* nativeText = + nativeEntry != NULL ? pResourceCache_->getMessageText_messageEntry(nativeEntry) : NULL; + const void* resolvedEntry = nativeEntry; + const char* resolvedText = nativeText; + dusk::flow::resolve_message(this, pResourceCache_->oParse_THeader_.getRaw(), index, + nativeEntry, nativeText, resolvedEntry, resolvedText); + return resolvedText; +} +#endif + void JMessage::TProcessor::on_select_begin(char const* (*pfn)(JMessage::TProcessor*), void const* pOffset, char const* pcBase, u32 uNumber) { JUT_ASSERT(191, uNumber>0); diff --git a/libs/JSystem/src/JMessage/resource.cpp b/libs/JSystem/src/JMessage/resource.cpp index 4e48701c11..fc8d011af7 100644 --- a/libs/JSystem/src/JMessage/resource.cpp +++ b/libs/JSystem/src/JMessage/resource.cpp @@ -89,7 +89,7 @@ u16 JMessage::TResource::toMessageIndex_messageID(u32 uMsgID, u32 upperHalf, boo return nIndex; } -JMessage::locale::parseCharacter_function JMessage::TResourceContainer::sapfnParseCharacter_[5] = { +DUSK_GAME_DATA JMessage::locale::parseCharacter_function JMessage::TResourceContainer::sapfnParseCharacter_[5] = { NULL, JMessage::locale::parseCharacter_1Byte, JMessage::locale::parseCharacter_2Byte, diff --git a/libs/JSystem/src/JParticle/JPABaseShape.cpp b/libs/JSystem/src/JParticle/JPABaseShape.cpp index a569d96842..bebf947fec 100644 --- a/libs/JSystem/src/JParticle/JPABaseShape.cpp +++ b/libs/JSystem/src/JParticle/JPABaseShape.cpp @@ -10,9 +10,10 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" + +#include #endif -#include "tracy/Tracy.hpp" #if TARGET_PC #define JPA_DRAW_CTX_PARAM , ParticleDrawCtx* ctx @@ -551,7 +552,7 @@ static void submit_particle_quad( void JPAInterpBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -563,7 +564,7 @@ void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { ptclPosMtx[0][1] = -sinRot; ptclPosMtx[1][0] = sinRot; ptclPosMtx[1][1] = cosRot; - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } #endif @@ -576,7 +577,7 @@ void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C JGeometry::TVec3 pos; #if TARGET_PC Mtx ptclPosMtx; - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); MTXMultVec(work->mPosCamMtx, &pos, &pos); } else @@ -616,7 +617,7 @@ void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA #if TARGET_PC Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); sinRot = ptclPosMtx[1][0]; cosRot = ptclPosMtx[0][0]; @@ -993,7 +994,7 @@ void JPAInterpDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][2] = axisZ.z; posMtx[2][3] = ptcl->mPosition.z; p_plane[work->mPlaneType](posMtx, scaleX, scaleY); - dusk::frame_interp::record_final_mtx(posMtx, ptcl); + dusk::interp::record_final_mtx(posMtx, ptcl); } void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -1036,7 +1037,7 @@ void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { mtx2[2][2] = axisZ.z; mtx2[2][3] = ptcl->mPosition.z; MTXConcat(mtx2, mtx1, mtx1); - dusk::frame_interp::record_final_mtx(mtx1, ptcl); + dusk::interp::record_final_mtx(mtx1, ptcl); } #endif @@ -1049,7 +1050,7 @@ void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C Mtx posMtx; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, posMtx) && + if (!dusk::interp::lookup_replacement(ptcl, posMtx) && !make_direction_mtx(work, ptcl, posMtx)) { return; @@ -1112,7 +1113,7 @@ void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA Mtx mtx1; Mtx mtx2; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, mtx1) && + if (!dusk::interp::lookup_replacement(ptcl, mtx1) && !make_rot_direction_mtx(work, ptcl, mtx1)) { return; @@ -1580,36 +1581,36 @@ static void makeColorTable(GXColor** o_color_table, JPAClrAnmKeyData const* i_da *o_color_table = p_clr_tbl; } -GXBlendMode JPABaseShape::st_bm[3] = { +DUSK_GAME_DATA GXBlendMode JPABaseShape::st_bm[3] = { GX_BM_NONE, GX_BM_BLEND, GX_BM_LOGIC, }; -GXBlendFactor JPABaseShape::st_bf[10] = { +DUSK_GAME_DATA GXBlendFactor JPABaseShape::st_bf[10] = { GX_BL_ZERO, GX_BL_ONE, GX_BL_SRCCLR, GX_BL_INVSRCCLR, GX_BL_DSTCLR, GX_BL_INVDSTCLR, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_BL_DSTALPHA, GX_BL_INVDSTALPHA, }; -GXLogicOp JPABaseShape::st_lo[16] = { +DUSK_GAME_DATA GXLogicOp JPABaseShape::st_lo[16] = { GX_LO_CLEAR, GX_LO_SET, GX_LO_COPY, GX_LO_INVCOPY, GX_LO_NOOP, GX_LO_INV, GX_LO_AND, GX_LO_NAND, GX_LO_OR, GX_LO_NOR, GX_LO_XOR, GX_LO_EQUIV, GX_LO_REVAND, GX_LO_INVAND, GX_LO_REVOR, GX_LO_INVOR, }; -GXCompare JPABaseShape::st_c[8] = { +DUSK_GAME_DATA GXCompare JPABaseShape::st_c[8] = { GX_NEVER, GX_LESS, GX_LEQUAL, GX_EQUAL, GX_NEQUAL, GX_GEQUAL, GX_GREATER, GX_ALWAYS, }; -GXAlphaOp JPABaseShape::st_ao[4] = { +DUSK_GAME_DATA GXAlphaOp JPABaseShape::st_ao[4] = { GX_AOP_AND, GX_AOP_OR, GX_AOP_XOR, GX_AOP_XNOR, }; -GXTevColorArg JPABaseShape::st_ca[6][4] = { +DUSK_GAME_DATA GXTevColorArg JPABaseShape::st_ca[6][4] = { { GX_CC_ZERO, GX_CC_TEXC, @@ -1648,7 +1649,7 @@ GXTevColorArg JPABaseShape::st_ca[6][4] = { }, }; -GXTevAlphaArg JPABaseShape::st_aa[2][4] = { +DUSK_GAME_DATA GXTevAlphaArg JPABaseShape::st_aa[2][4] = { { GX_CA_ZERO, GX_CA_TEXA, diff --git a/libs/JSystem/src/JParticle/JPAEmitterManager.cpp b/libs/JSystem/src/JParticle/JPAEmitterManager.cpp index 3a793000ed..0dcaa3b8b5 100644 --- a/libs/JSystem/src/JParticle/JPAEmitterManager.cpp +++ b/libs/JSystem/src/JParticle/JPAEmitterManager.cpp @@ -8,7 +8,9 @@ #include "JSystem/JUtility/JUTAssert.h" #include +#if TARGET_PC #include "tracy/Tracy.hpp" +#endif JPAEmitterManager::JPAEmitterManager(u32 i_ptclNum, u32 i_emtrNum, JKRHeap* pHeap, u8 i_gidMax, u8 i_ridMax) { diff --git a/libs/JSystem/src/JParticle/JPAParticle.cpp b/libs/JSystem/src/JParticle/JPAParticle.cpp index eb2395e346..0bb03d607a 100644 --- a/libs/JSystem/src/JParticle/JPAParticle.cpp +++ b/libs/JSystem/src/JParticle/JPAParticle.cpp @@ -7,6 +7,10 @@ #include "JSystem/JParticle/JPAEmitterManager.h" #include "JSystem/JParticle/JPAExtraShape.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + JPAParticleCallBack::~JPAParticleCallBack() { /* empty function */ } @@ -206,7 +210,7 @@ void JPABaseParticle::init_c(JPAEmitterWorkData* work, JPABaseParticle* parent) #if TARGET_PC void JPABaseParticle::interp(JPAEmitterWorkData* work, void const* drawFunc) { - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) return; // don't interpolate the first frame diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index 2d5d872bac..8a4d931e16 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -1,10 +1,6 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/JParticle/JPAResource.h" - -#include - -#include #include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JParticle/JPABaseShape.h" #include "JSystem/JParticle/JPAChildShape.h" @@ -15,10 +11,14 @@ #include "JSystem/JParticle/JPAKeyBlock.h" #include "JSystem/JParticle/JPAParticle.h" #include "JSystem/JParticle/JPAResourceManager.h" +#include #include "global.h" -#include "tracy/Tracy.hpp" #if TARGET_PC +#include "dusk/interp/frame_interpolation.h" + +#include + #define JPA_DRAW_CTX_ARG , &ctx #else #define JPA_DRAW_CTX_ARG @@ -44,7 +44,7 @@ JPAResource::JPAResource() { mUsrIdx = fldNum = keyNum = texNum = mpCalcEmitterFuncListNum = mpDrawEmitterFuncListNum = mpDrawEmitterChildFuncListNum = mpCalcParticleFuncListNum = mpDrawParticleFuncListNum = mpCalcParticleChildFuncListNum = mpDrawParticleChildFuncListNum = 0; } -static u8 jpa_pos[324] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u8 jpa_pos[324] = { 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x32, 0xCE, 0x00, 0x00, 0xCE, 0x00, 0xE7, 0x00, 0x00, 0x19, 0x00, 0x00, 0x19, 0xCE, 0x00, 0xE7, 0xCE, 0x00, 0xCE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0x00, 0xCE, 0xCE, 0x00, 0x00, 0x19, 0x00, 0x32, 0x19, 0x00, 0x32, 0xE7, 0x00, 0x00, 0xE7, 0x00, @@ -68,7 +68,7 @@ static u8 jpa_pos[324] ATTRIBUTE_ALIGN(32) = { 0x00, 0x00, 0x00, 0xCE, }; -static u8 jpa_crd[32] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u8 jpa_crd[32] = { 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, }; @@ -839,7 +839,7 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) { #ifdef TARGET_PC if (((pBsp && pBsp->getDirType() == 3) || (pCsp && pCsp->getDirType() == 3)) && - dusk::frame_interp::is_enabled()) + dusk::interp::is_enabled()) { // ensure mGlobalEmtrDir is valid calcWorkData_d(work); diff --git a/libs/JSystem/src/JStudio/JStudio/ctb-data.cpp b/libs/JSystem/src/JStudio/JStudio/ctb-data.cpp index 629d542457..8f7fa348ba 100644 --- a/libs/JSystem/src/JStudio/JStudio/ctb-data.cpp +++ b/libs/JSystem/src/JStudio/JStudio/ctb-data.cpp @@ -2,4 +2,4 @@ #include "JSystem/JStudio/JStudio/ctb.h" -const u32 JStudio::ctb::data::ga4cSignature = BSWAP32('CTB\0'); +DUSK_GAME_DATA const u32 JStudio::ctb::data::ga4cSignature = BSWAP32('CTB\0'); diff --git a/libs/JSystem/src/JStudio/JStudio/fvb-data.cpp b/libs/JSystem/src/JStudio/JStudio/fvb-data.cpp index deee81198e..ef9f785165 100644 --- a/libs/JSystem/src/JStudio/JStudio/fvb-data.cpp +++ b/libs/JSystem/src/JStudio/JStudio/fvb-data.cpp @@ -2,4 +2,4 @@ #include "JSystem/JStudio/JStudio/fvb-data.h" -const char JStudio::fvb::data::ga4cSignature[4] = "FVB"; +DUSK_GAME_DATA const char JStudio::fvb::data::ga4cSignature[4] = "FVB"; diff --git a/libs/JSystem/src/JStudio/JStudio/jstudio-data.cpp b/libs/JSystem/src/JStudio/JStudio/jstudio-data.cpp index c6f90bc45f..2d361f5acd 100644 --- a/libs/JSystem/src/JStudio/JStudio/jstudio-data.cpp +++ b/libs/JSystem/src/JStudio/JStudio/jstudio-data.cpp @@ -2,4 +2,4 @@ #include "JSystem/JStudio/JStudio/jstudio-data.h" -const char JStudio::data::ga8cSignature[8] = "jstudio"; +DUSK_GAME_DATA const char JStudio::data::ga8cSignature[8] = "jstudio"; diff --git a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp index 864dec39fc..b6f41098e5 100644 --- a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp +++ b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp @@ -4,7 +4,7 @@ #if TARGET_PC #include "dusk/audio.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #endif @@ -326,19 +326,19 @@ JStudio::TObject_actor::TObject_actor(JStudio::stb::data::TParse_TBlock_object c } -u32 const JStudio::TAdaptor_actor::sauVariableValue_3_TRANSLATION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_actor::sauVariableValue_3_TRANSLATION_XYZ[3] = { 3, 4, 5, }; - u32 const JStudio::TAdaptor_actor::sauVariableValue_3_ROTATION_XYZ[3] = { + DUSK_GAME_DATA u32 const JStudio::TAdaptor_actor::sauVariableValue_3_ROTATION_XYZ[3] = { 6, 7, 8, }; -u32 const JStudio::TAdaptor_actor::sauVariableValue_3_SCALING_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_actor::sauVariableValue_3_SCALING_XYZ[3] = { 9, 10, 11, }; - JStudio::TVariableValue::TOutput_none_ JStudio::TVariableValue::soOutput_none_; + DUSK_GAME_DATA JStudio::TVariableValue::TOutput_none_ JStudio::TVariableValue::soOutput_none_; void JStudio::TObject_actor::do_paragraph(u32 param_1, void const* param_2, u32 param_3) { TAdaptor* adaptor = getAdaptor(); @@ -479,11 +479,11 @@ JStudio::TObject_ambientLight::TObject_ambientLight( JStudio::TAdaptor_ambientLight* param_1) : TObject(param_0, param_1) { } -u32 const JStudio::TAdaptor_ambientLight::sauVariableValue_3_COLOR_RGB[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_ambientLight::sauVariableValue_3_COLOR_RGB[3] = { 0, 1, 2, }; -u32 const JStudio::TAdaptor_ambientLight::sauVariableValue_4_COLOR_RGBA[4] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_ambientLight::sauVariableValue_4_COLOR_RGBA[4] = { 0, 1, 2, 3, }; @@ -540,15 +540,15 @@ JStudio::TObject_camera::TObject_camera(JStudio::stb::data::TParse_TBlock_object JStudio::TAdaptor_camera* param_1) : TObject(param_0, param_1) {} -u32 const JStudio::TAdaptor_camera::sauVariableValue_3_POSITION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_camera::sauVariableValue_3_POSITION_XYZ[3] = { 0, 1, 2, }; -u32 const JStudio::TAdaptor_camera::sauVariableValue_3_TARGET_POSITION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_camera::sauVariableValue_3_TARGET_POSITION_XYZ[3] = { 3, 4, 5, }; -u32 const JStudio::TAdaptor_camera::sauVariableValue_2_DISTANCE_NEAR_FAR[2] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_camera::sauVariableValue_2_DISTANCE_NEAR_FAR[2] = { 8, 9, }; @@ -655,10 +655,10 @@ value_or_fun: value: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && u <= 5 && + if (dusk::interp::is_enabled() && u <= 5 && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue(control, u, operation, param_2, param_3); @@ -666,11 +666,11 @@ value: value_n: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && + if (dusk::interp::is_enabled() && (pN == TAdaptor_camera::sauVariableValue_3_POSITION_XYZ || pN == TAdaptor_camera::sauVariableValue_3_TARGET_POSITION_XYZ) && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue_n(control, pN, u, operation, param_2, param_3); @@ -686,15 +686,15 @@ JStudio::TAdaptor_fog::~TAdaptor_fog() {} JStudio::TObject_fog::TObject_fog(JStudio::stb::data::TParse_TBlock_object const& param_0, JStudio::TAdaptor_fog* param_1) : TObject(param_0, param_1) {} -u32 const JStudio::TAdaptor_fog::sauVariableValue_3_COLOR_RGB[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_fog::sauVariableValue_3_COLOR_RGB[3] = { 0, 1, 2, }; -u32 const JStudio::TAdaptor_fog::sauVariableValue_4_COLOR_RGBA[4] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_fog::sauVariableValue_4_COLOR_RGBA[4] = { 0, 1, 2, 3, }; -u32 const JStudio::TAdaptor_fog::sauVariableValue_2_RANGE_BEGIN_END[2] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_fog::sauVariableValue_2_RANGE_BEGIN_END[2] = { 4, 5, }; @@ -759,23 +759,23 @@ JStudio::TAdaptor_light::~TAdaptor_light() {} JStudio::TObject_light::TObject_light(JStudio::stb::data::TParse_TBlock_object const& param_0, JStudio::TAdaptor_light* param_1) : TObject(param_0, param_1) {} -u32 const JStudio::TAdaptor_light::sauVariableValue_2_DIRECTION_THETA_PHI[2] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_light::sauVariableValue_2_DIRECTION_THETA_PHI[2] = { 10, 11, }; - u32 const JStudio::TAdaptor_light::sauVariableValue_3_COLOR_RGB[3] = { + DUSK_GAME_DATA u32 const JStudio::TAdaptor_light::sauVariableValue_3_COLOR_RGB[3] = { 0, 1, 2, }; -u32 const JStudio::TAdaptor_light::sauVariableValue_4_COLOR_RGBA[4] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_light::sauVariableValue_4_COLOR_RGBA[4] = { 0, 1, 2, 3, }; -u32 const JStudio::TAdaptor_light::sauVariableValue_3_POSITION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_light::sauVariableValue_3_POSITION_XYZ[3] = { 4, 5, 6, }; -u32 const JStudio::TAdaptor_light::sauVariableValue_3_TARGET_POSITION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_light::sauVariableValue_3_TARGET_POSITION_XYZ[3] = { 7, 8, 9, }; @@ -921,31 +921,31 @@ JStudio::TAdaptor_particle::~TAdaptor_particle() {} JStudio::TObject_particle::TObject_particle( JStudio::stb::data::TParse_TBlock_object const& param_0, JStudio::TAdaptor_particle* param_1) : TObject(param_0, param_1) {} - u32 const JStudio::TAdaptor_particle::sauVariableValue_3_TRANSLATION_XYZ[3] = { + DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_3_TRANSLATION_XYZ[3] = { 0, 1, 2, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_3_ROTATION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_3_ROTATION_XYZ[3] = { 3, 4, 5, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_3_SCALING_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_3_SCALING_XYZ[3] = { 6, 7, 8, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_3_COLOR_RGB[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_3_COLOR_RGB[3] = { 9, 10, 11, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_4_COLOR_RGBA[4] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_4_COLOR_RGBA[4] = { 9, 10, 11, 12, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_3_COLOR1_RGB[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_3_COLOR1_RGB[3] = { 9, 10, 11, }; -u32 const JStudio::TAdaptor_particle::sauVariableValue_4_COLOR1_RGBA[4] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_particle::sauVariableValue_4_COLOR1_RGBA[4] = { 9, 10, 11, 12, }; @@ -1119,7 +1119,7 @@ JStudio::TAdaptor_sound::~TAdaptor_sound() {} JStudio::TObject_sound::TObject_sound(JStudio::stb::data::TParse_TBlock_object const& param_0, JStudio::TAdaptor_sound* param_1) : TObject(param_0, param_1) {} -u32 const JStudio::TAdaptor_sound::sauVariableValue_3_POSITION_XYZ[3] = { +DUSK_GAME_DATA u32 const JStudio::TAdaptor_sound::sauVariableValue_3_POSITION_XYZ[3] = { 0, 1, 2, }; diff --git a/libs/JSystem/src/JStudio/JStudio/stb-data.cpp b/libs/JSystem/src/JStudio/JStudio/stb-data.cpp index 79df1744d9..5de2b8f7bf 100644 --- a/libs/JSystem/src/JStudio/JStudio/stb-data.cpp +++ b/libs/JSystem/src/JStudio/JStudio/stb-data.cpp @@ -1,6 +1,6 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include "dusk/endian.h" +#include "helpers/endian.h" #include "JSystem/JStudio/JStudio/stb-data.h" -const s32 JStudio::stb::data::gauDataSize_TEParagraph_data[8] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40}; -const BE(u32) JStudio::stb::data::ga4cSignature = 'STB\0'; +DUSK_GAME_DATA const s32 JStudio::stb::data::gauDataSize_TEParagraph_data[8] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40}; +DUSK_GAME_DATA const BE(u32) JStudio::stb::data::ga4cSignature = 'STB\0'; diff --git a/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp b/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp index 9bdde8b5cc..14eb3a74a4 100644 --- a/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JAudio2/object-sound.cpp @@ -80,7 +80,7 @@ void JStudio_JAudio2::TAdaptor_sound::adaptor_do_prepare() { } } -JStudio_JAudio2::TAdaptor_sound::TVVOSetValue_ JStudio_JAudio2::TAdaptor_sound::saoVVOSetValue_[6] = { +DUSK_GAME_DATA JStudio_JAudio2::TAdaptor_sound::TVVOSetValue_ JStudio_JAudio2::TAdaptor_sound::saoVVOSetValue_[6] = { JStudio_JAudio2::TAdaptor_sound::TVVOSetValue_( JStudio_JAudio2::TAdaptor_sound::UNK_7, setValue_VOLUME_ ), diff --git a/libs/JSystem/src/JStudio/JStudio_JStage/object-actor.cpp b/libs/JSystem/src/JStudio/JStudio_JStage/object-actor.cpp index 0ee7d53fb7..603cf30319 100644 --- a/libs/JSystem/src/JStudio/JStudio_JStage/object-actor.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JStage/object-actor.cpp @@ -348,12 +348,12 @@ JStudio_JStage::TAdaptor_actor::TVVOutput_ANIMATION_FRAME_::~TVVOutput_ANIMATION namespace JStudio_JStage { -const TAdaptor_actor::TVVOutputObject TAdaptor_actor::saoVVOutput_[] = { +DUSK_GAME_DATA const TAdaptor_actor::TVVOutputObject TAdaptor_actor::saoVVOutput_[] = { TVVOutputObject(TAdaptor_actor::TEACTOR_1, &JStage::TActor::JSGSetAnimationTransition, &JStage::TActor::JSGGetAnimationTransition), TVVOutputObject() }; -const TAdaptor_actor::TVVOutput_ANIMATION_FRAME_ TAdaptor_actor::saoVVOutput_ANIMATION_FRAME_[] = { +DUSK_GAME_DATA const TAdaptor_actor::TVVOutput_ANIMATION_FRAME_ TAdaptor_actor::saoVVOutput_ANIMATION_FRAME_[] = { TVVOutput_ANIMATION_FRAME_(0, 305, &JStage::TActor::JSGSetAnimationFrame, &JStage::TActor::JSGGetAnimationFrame, &JStage::TActor::JSGGetAnimationFrameMax), TVVOutput_ANIMATION_FRAME_(2, 309, &JStage::TActor::JSGSetTextureAnimationFrame, &JStage::TActor::JSGGetTextureAnimationFrame, &JStage::TActor::JSGGetTextureAnimationFrameMax), TVVOutput_ANIMATION_FRAME_() diff --git a/libs/JSystem/src/JStudio/JStudio_JStage/object-camera.cpp b/libs/JSystem/src/JStudio/JStudio_JStage/object-camera.cpp index afa1fb8ab4..c29aea47fa 100644 --- a/libs/JSystem/src/JStudio/JStudio_JStage/object-camera.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JStage/object-camera.cpp @@ -22,7 +22,7 @@ JStudio_JStage::TAdaptor_camera::~TAdaptor_camera() { adaptor_do_end(); } -JStudio_JStage::TAdaptor_camera::TVVOutput JStudio_JStage::TAdaptor_camera::saoVVOutput_[5] = { +DUSK_GAME_DATA JStudio_JStage::TAdaptor_camera::TVVOutput JStudio_JStage::TAdaptor_camera::saoVVOutput_[5] = { TVVOutput(JStudio_JStage::TAdaptor_camera::TECAMERA_7, &JStage::TCamera::JSGSetViewRoll, &JStage::TCamera::JSGGetViewRoll), TVVOutput(JStudio_JStage::TAdaptor_camera::TECAMERA_6, &JStage::TCamera::JSGSetProjectionFovy, diff --git a/libs/JSystem/src/JStudio/JStudio_JStage/object-fog.cpp b/libs/JSystem/src/JStudio/JStudio_JStage/object-fog.cpp index ba1f2391e3..43cd94229a 100644 --- a/libs/JSystem/src/JStudio/JStudio_JStage/object-fog.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JStage/object-fog.cpp @@ -13,7 +13,7 @@ JStudio_JStage::TAdaptor_fog::~TAdaptor_fog() { adaptor_do_end(); } -JStudio_JStage::TVariableValueOutput_object_ JStudio_JStage::TAdaptor_fog::saoVVOutput_[3] = { +DUSK_GAME_DATA JStudio_JStage::TVariableValueOutput_object_ JStudio_JStage::TAdaptor_fog::saoVVOutput_[3] = { JStudio_JStage::TVariableValueOutput_object_(JStudio_JStage::TAdaptor_fog::TEFOG_4, &JStage::TFog::JSGSetStartZ, &JStage::TFog::JSGGetStartZ), JStudio_JStage::TVariableValueOutput_object_(JStudio_JStage::TAdaptor_fog::TEFOG_5, &JStage::TFog::JSGSetEndZ, &JStage::TFog::JSGGetEndZ), JStudio_JStage::TVariableValueOutput_object_(), diff --git a/libs/JSystem/src/JStudio/JStudio_JStage/object-light.cpp b/libs/JSystem/src/JStudio/JStudio_JStage/object-light.cpp index 19a02f09df..9b3b2e608d 100644 --- a/libs/JSystem/src/JStudio/JStudio_JStage/object-light.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JStage/object-light.cpp @@ -12,7 +12,7 @@ JStudio_JStage::TAdaptor_light::~TAdaptor_light() { adaptor_do_end(); } -JStudio_JStage::TAdaptor_light::TVVOutput_direction_ +DUSK_GAME_DATA JStudio_JStage::TAdaptor_light::TVVOutput_direction_ JStudio_JStage::TAdaptor_light::saoVVOutput_direction_[6] = { JStudio_JStage::TAdaptor_light::TVVOutput_direction_( JStudio_JStage::TAdaptor_light::TE_VALUE_10, diff --git a/libs/JSystem/src/JUtility/JUTCacheFont.cpp b/libs/JSystem/src/JUtility/JUTCacheFont.cpp index 81b9f252f1..3fd02a1232 100644 --- a/libs/JSystem/src/JUtility/JUTCacheFont.cpp +++ b/libs/JSystem/src/JUtility/JUTCacheFont.cpp @@ -56,6 +56,10 @@ void JUTCacheFont::initialize_state() { mCacheBuffer = NULL; field_0x9c = NULL; field_0xa0 = NULL; + +#if TARGET_PC + mJoinedTextureHeight = 0; +#endif } int JUTCacheFont::getMemorySize(ResFONT const* p_font, u16* o_widCount, u32* o_widSize, @@ -203,7 +207,7 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) { } } - field_0x94 = mMaxSheetSize + 0x40; + field_0x94 = mMaxSheetSize + sizeof(TCachePage); mCachePage = param_1 / field_0x94; u32 v1 = field_0x94 * mCachePage; if (mCachePage == 0) { @@ -346,7 +350,23 @@ void JUTCacheFont::getGlyphFromAram(JUTCacheFont::TGlyphCacheInfo* param_0, JUTCacheFont::TCachePage* pCachePage, int* param_2, int* param_3) { TGlyphCacheInfo* pGylphCacheInfo = pCachePage; int* r30 = param_2; +#if TARGET_PC + // TODO: proper fix to account for 64bit ptr sizes + ResFONT::GLY1* glyph = (ResFONT::GLY1*)param_0; + pGylphCacheInfo->field_0x8 = glyph->startCode; + pGylphCacheInfo->field_0xa = glyph->endCode; + pGylphCacheInfo->field_0xc = glyph->cellWidth; + pGylphCacheInfo->field_0xe = glyph->cellHeight; + pGylphCacheInfo->field_0x10 = glyph->textureSize; + pGylphCacheInfo->mTexFormat = glyph->textureFormat; + pGylphCacheInfo->field_0x16 = glyph->numRows; + pGylphCacheInfo->field_0x18 = glyph->numColumns; + pGylphCacheInfo->mWidth = glyph->textureWidth; + pGylphCacheInfo->mHeight = glyph->textureHeight; + pGylphCacheInfo->field_0x1e = 0; +#else memcpy(pGylphCacheInfo, param_0, sizeof(TGlyphCacheInfo)); +#endif prepend(pGylphCacheInfo); int iVar3 = pGylphCacheInfo->field_0x16 * pGylphCacheInfo->field_0x18; int iVar2 = *r30 / iVar3; @@ -364,7 +384,11 @@ void JUTCacheFont::getGlyphFromAram(JUTCacheFont::TGlyphCacheInfo* param_0, GX_ANISO_1); } +#if TARGET_PC +void JUTCacheFont::loadImage(int param_0, GXTexMapID texMapId FONT_DRAW_CTX) { +#else void JUTCacheFont::loadImage(int param_0, GXTexMapID texMapId) { +#endif TCachePage* cachePage = loadCache_char_subroutine(¶m_0, false); if (cachePage != NULL) { mWidth = cachePage->field_0xc * (param_0 % (int)cachePage->field_0x16); @@ -421,6 +445,16 @@ JUTCacheFont::TCachePage* JUTCacheFont::loadCache_char_subroutine(int* param_0, } void JUTCacheFont::invalidiateAllCache() { +#if TARGET_PC + u8* cacheBuffer = (u8*)mCacheBuffer; + for (int i = 0; i < mCachePage; i++) { + TGlyphCacheInfo* current = (TGlyphCacheInfo*)cacheBuffer; + current->mPrev = i == 0 ? NULL : (TGlyphCacheInfo*)(cacheBuffer - field_0x94); + current->mNext = i == mCachePage - 1 ? NULL : (TGlyphCacheInfo*)(cacheBuffer + field_0x94); + cacheBuffer = cacheBuffer + field_0x94; + } + field_0xa8 = (intptr_t)cacheBuffer - field_0x94; +#else int* cacheBuffer = (int*)mCacheBuffer; for (int i = 0; i < mCachePage; i++) { *cacheBuffer = i == 0 ? 0 : (intptr_t)cacheBuffer - field_0x94; @@ -428,6 +462,7 @@ void JUTCacheFont::invalidiateAllCache() { cacheBuffer = (int*)((intptr_t)cacheBuffer + field_0x94); } field_0xa8 = (intptr_t)cacheBuffer - field_0x94; +#endif field_0xa4 = (TGlyphCacheInfo*)mCacheBuffer; field_0x9c = NULL; field_0xa0 = NULL; diff --git a/libs/JSystem/src/JUtility/JUTConsole.cpp b/libs/JSystem/src/JUtility/JUTConsole.cpp index c2c023a2d8..75150cb498 100644 --- a/libs/JSystem/src/JUtility/JUTConsole.cpp +++ b/libs/JSystem/src/JUtility/JUTConsole.cpp @@ -8,10 +8,10 @@ #include "JSystem/JUtility/JUTConsole.h" #include "JSystem/JUtility/JUTDirectPrint.h" #include "JSystem/JUtility/JUTVideo.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" -JUTConsoleManager* JUTConsoleManager::sManager; +DUSK_GAME_DATA JUTConsoleManager* JUTConsoleManager::sManager; JUTConsole* JUTConsole::create(unsigned int param_0, unsigned int maxLines, JKRHeap* pHeap) { JUTConsoleManager* pManager = JUTConsoleManager::getManager(); diff --git a/libs/JSystem/src/JUtility/JUTDbPrint.cpp b/libs/JSystem/src/JUtility/JUTDbPrint.cpp index cdf4c08d29..03535f2d15 100644 --- a/libs/JSystem/src/JUtility/JUTDbPrint.cpp +++ b/libs/JSystem/src/JUtility/JUTDbPrint.cpp @@ -16,7 +16,7 @@ JUTDbPrint::JUTDbPrint(JUTFont* pFont, JKRHeap* pHeap) { mVisible = true; } -JUTDbPrint* JUTDbPrint::sDebugPrint; +DUSK_GAME_DATA JUTDbPrint* JUTDbPrint::sDebugPrint; JUTDbPrint* JUTDbPrint::start(JUTFont* pFont, JKRHeap* pHeap) { if (sDebugPrint == NULL) { diff --git a/libs/JSystem/src/JUtility/JUTDirectPrint.cpp b/libs/JSystem/src/JUtility/JUTDirectPrint.cpp index 1b5993c5bd..745862dfbc 100644 --- a/libs/JSystem/src/JUtility/JUTDirectPrint.cpp +++ b/libs/JSystem/src/JUtility/JUTDirectPrint.cpp @@ -7,7 +7,7 @@ #include "global.h" #include "angle_utils.h" -JUTDirectPrint* JUTDirectPrint::sDirectPrint; +DUSK_GAME_DATA JUTDirectPrint* JUTDirectPrint::sDirectPrint; JUTDirectPrint::JUTDirectPrint() { changeFrameBuffer(NULL, 0, 0); @@ -48,7 +48,7 @@ void JUTDirectPrint::erase(int x, int y, int width, int height) { } } -u8 JUTDirectPrint::sAsciiTable[128] = { +DUSK_GAME_DATA u8 JUTDirectPrint::sAsciiTable[128] = { 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0xFD, 0xFE, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x64, 0x65, 0x66, 0x2B, 0x67, 0x68, 0x25, 0x26, 0x69, 0x2A, 0x6A, 0x27, 0x2C, 0x6B, @@ -59,7 +59,7 @@ u8 JUTDirectPrint::sAsciiTable[128] = { 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x76, 0x77, 0x78, 0x79, 0x7A, }; -u32 JUTDirectPrint::sFontData[64] = { +DUSK_GAME_DATA u32 JUTDirectPrint::sFontData[64] = { 0x70871C30, 0x8988A250, 0x88808290, 0x88830C90, 0x888402F8, 0x88882210, 0x71CF9C10, 0xF9CF9C70, 0x8208A288, 0xF200A288, 0x0BC11C78, 0x0A222208, 0x8A222208, 0x71C21C70, 0x23C738F8, 0x5228A480, 0x8A282280, 0x8BC822F0, 0xFA282280, 0x8A28A480, 0x8BC738F8, 0xF9C89C08, 0x82288808, 0x82088808, @@ -70,7 +70,7 @@ u32 JUTDirectPrint::sFontData[64] = { 0x70800000, 0x88822200, 0x08820400, 0x108F8800, 0x20821000, 0x00022200, 0x20800020, 0x00000000, }; -u32 JUTDirectPrint::sFontData2[77] = { +DUSK_GAME_DATA u32 JUTDirectPrint::sFontData2[77] = { 0x51421820, 0x53E7A420, 0x014A2C40, 0x01471000, 0x0142AA00, 0x03EAA400, 0x01471A78, 0x00000000, 0x50008010, 0x20010820, 0xF8020040, 0x20420820, 0x50441010, 0x00880000, 0x00070E00, 0x01088840, 0x78898820, 0x004A8810, 0x788A8810, 0x01098808, 0x00040E04, 0x70800620, 0x11400820, 0x12200820, diff --git a/libs/JSystem/src/JUtility/JUTException.cpp b/libs/JSystem/src/JUtility/JUTException.cpp index 54b234118c..9e00bce739 100644 --- a/libs/JSystem/src/JUtility/JUTException.cpp +++ b/libs/JSystem/src/JUtility/JUTException.cpp @@ -10,7 +10,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #ifdef __REVOLUTION_SDK__ #include #else @@ -27,16 +27,16 @@ struct CallbackObject { /* 0x10 */ int param_4; }; -OSMessageQueue JUTException::sMessageQueue = {0}; +DUSK_GAME_DATA OSMessageQueue JUTException::sMessageQueue = {0}; STATIC_ASSERT(sizeof(CallbackObject) == 0x14); static CallbackObject exCallbackObject; -JSUList JUTException::sMapFileList(false); +DUSK_GAME_DATA JSUList JUTException::sMapFileList(false); static OSTime c3bcnt[4] = {0, 0, 0, 0}; -const char* JUTException::sCpuExpName[17] = { +DUSK_GAME_DATA const char* JUTException::sCpuExpName[17] = { "SYSTEM RESET", "MACHINE CHECK", "DSI", @@ -56,11 +56,11 @@ const char* JUTException::sCpuExpName[17] = { "FLOATING POINT", }; -JUTException* JUTException::sErrorManager; +DUSK_GAME_DATA JUTException* JUTException::sErrorManager; -JUTExceptionUserCallback JUTException::sPreUserCallback; +DUSK_GAME_DATA JUTExceptionUserCallback JUTException::sPreUserCallback; -JUTExceptionUserCallback JUTException::sPostUserCallback; +DUSK_GAME_DATA JUTExceptionUserCallback JUTException::sPostUserCallback; #if PLATFORM_GCN const int stack_size = 0x1C00; @@ -100,7 +100,7 @@ JUTException* JUTException::create(JUTDirectPrint* directPrint) { return sErrorManager; } -OSMessage JUTException::sMessageBuffer[1] = {0}; +DUSK_GAME_DATA OSMessage JUTException::sMessageBuffer[1] = {0}; void* JUTException::run() { #ifdef TARGET_PC @@ -140,15 +140,15 @@ void* JUTException::run() { #endif } -void* JUTException::sConsoleBuffer; +DUSK_GAME_DATA void* JUTException::sConsoleBuffer; -u32 JUTException::sConsoleBufferSize; +DUSK_GAME_DATA u32 JUTException::sConsoleBufferSize; -JUTConsole* JUTException::sConsole; +DUSK_GAME_DATA JUTConsole* JUTException::sConsole; -u32 JUTException::msr; +DUSK_GAME_DATA u32 JUTException::msr; -u32 JUTException::fpscr; +DUSK_GAME_DATA u32 JUTException::fpscr; void JUTException::errorHandler(OSError error, OSContext* context, u32 param_3, u32 param_4) { #ifndef TARGET_PC diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index e7d33454b7..2e937b176e 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -9,6 +9,8 @@ #include "JSystem/J2DGraph/J2DOrthoGraph.h" #ifdef TARGET_PC +#include "dusk/interp/frame_interpolation.h" + #include #endif @@ -73,8 +75,8 @@ void JUTFader::control() { void JUTFader::draw() { if (mColor.a != 0) { #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled() && mDuration != 0) { - const auto step = dusk::frame_interp::get_interpolation_step(); + if (dusk::interp::is_enabled() && mDuration != 0) { + const auto step = dusk::interp::get_interpolation_step(); const auto progress = static_cast(mTimer) / static_cast(mDuration); const auto timer = mTimer - 1 + step + progress; auto alpha = timer / mDuration; diff --git a/libs/JSystem/src/JUtility/JUTFontData_Ascfont_fix12.cpp b/libs/JSystem/src/JUtility/JUTFontData_Ascfont_fix12.cpp index 35979ebc9f..0e500e377c 100644 --- a/libs/JSystem/src/JUtility/JUTFontData_Ascfont_fix12.cpp +++ b/libs/JSystem/src/JUtility/JUTFontData_Ascfont_fix12.cpp @@ -8,7 +8,7 @@ #endif #include "global.h" -u8 const JUTResFONT_Ascfont_fix12[] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) DUSK_GAME_DATA u8 const JUTResFONT_Ascfont_fix12[] = { 0x46, 0x4F, 0x4E, 0x54, 0x62, 0x66, 0x6E, 0x31, 0x00, 0x00, 0x41, 0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x46, 0x31, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0C, diff --git a/libs/JSystem/src/JUtility/JUTGamePad.cpp b/libs/JSystem/src/JUtility/JUTGamePad.cpp index 48ed5f130e..c7e078b893 100644 --- a/libs/JSystem/src/JUtility/JUTGamePad.cpp +++ b/libs/JSystem/src/JUtility/JUTGamePad.cpp @@ -8,7 +8,7 @@ #include "dusk/action_bindings.h" #endif -u32 JUTGamePad::CRumble::sChannelMask[4] = { +DUSK_GAME_DATA u32 JUTGamePad::CRumble::sChannelMask[4] = { PAD_CHAN0_BIT, PAD_CHAN1_BIT, PAD_CHAN2_BIT, @@ -17,11 +17,11 @@ u32 JUTGamePad::CRumble::sChannelMask[4] = { static u32 channel_mask[4] = {PAD_CHAN0_BIT, PAD_CHAN1_BIT, PAD_CHAN2_BIT, PAD_CHAN3_BIT}; -JSUList JUTGamePad::mPadList(false); +DUSK_GAME_DATA JSUList JUTGamePad::mPadList(false); -bool JUTGamePad::mListInitialized; +DUSK_GAME_DATA bool JUTGamePad::mListInitialized; -u8 JUTGamePad::mPadAssign[4]; +DUSK_GAME_DATA u8 JUTGamePad::mPadAssign[4]; JUTGamePad::JUTGamePad(EPadPort port) : mRumble(this), mLink(this) { mPortNum = port; @@ -53,11 +53,11 @@ void JUTGamePad::initList() { } } -u32 JUTGamePad::sSuppressPadReset; +DUSK_GAME_DATA u32 JUTGamePad::sSuppressPadReset; -u8 data_8074CFA4_debug; +DUSK_GAME_DATA u8 data_8074CFA4_debug; -s32 JUTGamePad::sAnalogMode; +DUSK_GAME_DATA s32 JUTGamePad::sAnalogMode; BOOL JUTGamePad::init() { PADSetSpec(PAD_SPEC_5); @@ -73,19 +73,19 @@ void JUTGamePad::clear() { #endif } -PADStatus JUTGamePad::mPadStatus[4]; +DUSK_GAME_DATA PADStatus JUTGamePad::mPadStatus[4]; -JUTGamePad::CButton JUTGamePad::mPadButton[4]; +DUSK_GAME_DATA JUTGamePad::CButton JUTGamePad::mPadButton[4]; -JUTGamePad::CStick JUTGamePad::mPadMStick[4]; +DUSK_GAME_DATA JUTGamePad::CStick JUTGamePad::mPadMStick[4]; -JUTGamePad::CStick JUTGamePad::mPadSStick[4]; +DUSK_GAME_DATA JUTGamePad::CStick JUTGamePad::mPadSStick[4]; -JUTGamePad::EStickMode JUTGamePad::sStickMode = EStickMode1; +DUSK_GAME_DATA JUTGamePad::EStickMode JUTGamePad::sStickMode = EStickMode1; -int JUTGamePad::sClampMode = EClampStick; +DUSK_GAME_DATA int JUTGamePad::sClampMode = EClampStick; -u32 JUTGamePad::sRumbleSupported; +DUSK_GAME_DATA u32 JUTGamePad::sRumbleSupported; u32 JUTGamePad::read() { sRumbleSupported = PADRead(mPadStatus); @@ -181,21 +181,21 @@ void JUTGamePad::assign() { } } -u8 JUTGamePad::CRumble::mStatus[4]; +DUSK_GAME_DATA u8 JUTGamePad::CRumble::mStatus[4]; -u32 JUTGamePad::CRumble::mEnabled; +DUSK_GAME_DATA u32 JUTGamePad::CRumble::mEnabled; -callbackFn JUTGamePad::C3ButtonReset::sCallback; +DUSK_GAME_DATA callbackFn JUTGamePad::C3ButtonReset::sCallback; -void* JUTGamePad::C3ButtonReset::sCallbackArg; +DUSK_GAME_DATA void* JUTGamePad::C3ButtonReset::sCallbackArg; -OSTime JUTGamePad::C3ButtonReset::sThreshold = (OSTime)(OS_TIMER_CLOCK / 60) * 30; +DUSK_GAME_DATA OSTime JUTGamePad::C3ButtonReset::sThreshold = (OSTime)(OS_TIMER_CLOCK / 60) * 30; -bool JUTGamePad::C3ButtonReset::sResetSwitchPushing; +DUSK_GAME_DATA bool JUTGamePad::C3ButtonReset::sResetSwitchPushing; -bool JUTGamePad::C3ButtonReset::sResetOccurred; +DUSK_GAME_DATA bool JUTGamePad::C3ButtonReset::sResetOccurred; -s32 JUTGamePad::C3ButtonReset::sResetOccurredPort; +DUSK_GAME_DATA s32 JUTGamePad::C3ButtonReset::sResetOccurredPort; void JUTGamePad::checkResetCallback(OSTime holdTime) { if (holdTime >= JUTGamePad::C3ButtonReset::sThreshold) { @@ -208,13 +208,13 @@ void JUTGamePad::checkResetCallback(OSTime holdTime) { } } -f32 JUTGamePad::CStick::sPressPoint = 0.5f; +DUSK_GAME_DATA f32 JUTGamePad::CStick::sPressPoint = 0.5f; -f32 JUTGamePad::CStick::sReleasePoint = 0.25f; +DUSK_GAME_DATA f32 JUTGamePad::CStick::sReleasePoint = 0.25f; -u32 JUTGamePad::C3ButtonReset::sResetPattern = PAD_BUTTON_START | PAD_BUTTON_X | PAD_BUTTON_B; +DUSK_GAME_DATA u32 JUTGamePad::C3ButtonReset::sResetPattern = PAD_BUTTON_START | PAD_BUTTON_X | PAD_BUTTON_B; -u32 JUTGamePad::C3ButtonReset::sResetMaskPattern = 0x0000FFFF; +DUSK_GAME_DATA u32 JUTGamePad::C3ButtonReset::sResetMaskPattern = 0x0000FFFF; void JUTGamePad::update() { if (mPortNum != EPortInvalid) { @@ -269,7 +269,7 @@ void JUTGamePad::update() { } } -JSUList JUTGamePadLongPress::sPatternList(false); +DUSK_GAME_DATA JSUList JUTGamePadLongPress::sPatternList(false); void JUTGamePad::checkResetSwitch() { if (!JUTGamePad::C3ButtonReset::sResetOccurred) { diff --git a/libs/JSystem/src/JUtility/JUTGraphFifo.cpp b/libs/JSystem/src/JUtility/JUTGraphFifo.cpp index 1ffc0da27d..99bbfe7156 100644 --- a/libs/JSystem/src/JUtility/JUTGraphFifo.cpp +++ b/libs/JSystem/src/JUtility/JUTGraphFifo.cpp @@ -6,7 +6,7 @@ static bool data_804514B8; -JUTGraphFifo* JUTGraphFifo::sCurrentFifo; +DUSK_GAME_DATA JUTGraphFifo* JUTGraphFifo::sCurrentFifo; JUTGraphFifo::JUTGraphFifo(u32 size) { mSize = ROUND(size, 0x20); @@ -26,7 +26,7 @@ JUTGraphFifo::JUTGraphFifo(u32 size) { } } -bool JUTGraphFifo::mGpStatus[5]; +DUSK_GAME_DATA bool JUTGraphFifo::mGpStatus[5]; JUTGraphFifo::~JUTGraphFifo() { sCurrentFifo->save(); diff --git a/libs/JSystem/src/JUtility/JUTProcBar.cpp b/libs/JSystem/src/JUtility/JUTProcBar.cpp index 81d55ed3f1..cfcf58fb5c 100644 --- a/libs/JSystem/src/JUtility/JUTProcBar.cpp +++ b/libs/JSystem/src/JUtility/JUTProcBar.cpp @@ -27,7 +27,7 @@ JUTProcBar::JUTProcBar() { mWatchHeap = NULL; } -JUTProcBar* JUTProcBar::sManager; +DUSK_GAME_DATA JUTProcBar* JUTProcBar::sManager; JUTProcBar::~JUTProcBar() { sManager = NULL; diff --git a/libs/JSystem/src/JUtility/JUTResFont.cpp b/libs/JSystem/src/JUtility/JUTResFont.cpp index 63afbc29aa..3f31961d1f 100644 --- a/libs/JSystem/src/JUtility/JUTResFont.cpp +++ b/libs/JSystem/src/JUtility/JUTResFont.cpp @@ -7,6 +7,8 @@ #include "JSystem/JUtility/JUTConsole.h" #include +#include "dusk/version.hpp" + JUTResFont::JUTResFont() { initialize_state(); JUTFont::initialize_state(); @@ -68,8 +70,16 @@ void JUTResFont::initJoinedTexture() { int pageCount = 0; u32 pageNumCells = block.numRows * block.numColumns; - for (u32 code = block.startCode; code < block.endCode; code += pageNumCells) { - pageCount += 1; + + if (dusk::version::isRegionJpn()) { + pageCount = 1; + if (pageNumCells > 0 && block.endCode > block.startCode) { + pageCount = (block.endCode - block.startCode + pageNumCells - 1) / pageNumCells; + } + } else { + for (u32 code = block.startCode; code < block.endCode; code += pageNumCells) { + pageCount += 1; + } } mJoinedTextureHeight = block.textureHeight * pageCount; @@ -143,7 +153,7 @@ void JUTResFont::countBlock() { } } -IsLeadByte_func const JUTResFont::saoAboutEncoding_[3] = { +DUSK_GAME_DATA IsLeadByte_func const JUTResFont::saoAboutEncoding_[3] = { JUTFont::isLeadByte_1Byte, JUTFont::isLeadByte_2Byte, JUTFont::isLeadByte_ShiftJIS, @@ -273,12 +283,19 @@ f32 JUTResFont::drawChar_scale(f32 pos_x, f32 pos_y, f32 scale_x, f32 scale_y, i u16 texW = mpGlyphBlocks[field_0x66]->textureWidth; #if TARGET_PC - u16 texH = mJoinedTextureHeight; + // JUTCacheFont does not set mJoinedTextureHeight (it uses per-page textures via loadImage override). + // Fall back to the individual glyph block's textureHeight in that case. + u16 texH = mJoinedTextureHeight > 0 ? (u16)mJoinedTextureHeight : (u16)mpGlyphBlocks[field_0x66]->textureHeight; #else u16 texH = mpGlyphBlocks[field_0x66]->textureHeight; #endif - u16 cellW = mpGlyphBlocks[field_0x66]->cellWidth; +#if AVOID_UB + if (texW == 0) texW = 1; + if (texH == 0) texH = 1; +#endif + + u16 cellW = mpGlyphBlocks[field_0x66]->cellWidth; u16 cellH = mpGlyphBlocks[field_0x66]->cellHeight; s32 u1 = (mWidth * 0x8000) / texW; s32 v1 = (mHeight * 0x8000) / texH; diff --git a/libs/JSystem/src/JUtility/JUTVideo.cpp b/libs/JSystem/src/JUtility/JUTVideo.cpp index 5586342f0e..663c357e17 100644 --- a/libs/JSystem/src/JUtility/JUTVideo.cpp +++ b/libs/JSystem/src/JUtility/JUTVideo.cpp @@ -8,11 +8,11 @@ #include "JSystem/JKernel/JKRHeap.h" -JUTVideo* JUTVideo::sManager; +DUSK_GAME_DATA JUTVideo* JUTVideo::sManager; -OSTick JUTVideo::sVideoLastTick; +DUSK_GAME_DATA OSTick JUTVideo::sVideoLastTick; -OSTick JUTVideo::sVideoInterval; +DUSK_GAME_DATA OSTick JUTVideo::sVideoInterval; static bool data_80451544; @@ -42,7 +42,7 @@ JUTVideo::JUTVideo(GXRenderModeObj const* param_0) { mRetraceCount = VIGetRetraceCount(); field_0x10 = 1; field_0x18 = 0; - sVideoLastTick = OSGetTick(); + sVideoLastTick = DUSK_IF_ELSE(static_cast(OSGetNativeTime()), OSGetTick()); sVideoInterval = 670000; mPreRetraceCallback = VISetPreRetraceCallback(preRetraceProc); mPostRetraceCallback = VISetPostRetraceCallback(postRetraceProc); @@ -68,8 +68,13 @@ void JUTVideo::preRetraceProc(u32 retrace_count) { (*sManager->mPreCallback)(retrace_count); } - OSTick tick = OSGetTick(); + OSTick tick = DUSK_IF_ELSE(static_cast(OSGetNativeTime()), OSGetTick()); sVideoInterval = tick - sVideoLastTick; +#if TARGET_PC + if (sVideoInterval <= 0) { + sVideoInterval = 1; + } +#endif sVideoLastTick = tick; JUTXfb* xfb = JUTXfb::getManager(); diff --git a/libs/JSystem/src/JUtility/JUTXfb.cpp b/libs/JSystem/src/JUtility/JUTXfb.cpp index f04a5e93fc..ac66621243 100644 --- a/libs/JSystem/src/JUtility/JUTXfb.cpp +++ b/libs/JSystem/src/JUtility/JUTXfb.cpp @@ -33,7 +33,7 @@ JUTXfb::JUTXfb(GXRenderModeObj const* pObj, JKRHeap* pHeap, JUTXfb::EXfbNumber x } } -JUTXfb* JUTXfb::sManager; +DUSK_GAME_DATA JUTXfb* JUTXfb::sManager; JUTXfb::~JUTXfb() { for (int i = 0; i < 3; i++) { diff --git a/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk.c b/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk.c index 13a30383ba..2564e1298c 100644 --- a/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk.c +++ b/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk.c @@ -136,7 +136,7 @@ void TRK__read_aram(__REGISTER int c, __REGISTER u32 p2, void* p3) { } void TRK__write_aram(__REGISTER int c, __REGISTER u32 p2, void* p3) { - u8 buff[32] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 buff[32]; u32 err; __REGISTER int count = c; __REGISTER u32 bf; diff --git a/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Portable/msghndlr.c b/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Portable/msghndlr.c index 36a33d75fa..f3b5901d5b 100644 --- a/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Portable/msghndlr.c +++ b/libs/TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Portable/msghndlr.c @@ -85,7 +85,7 @@ DSError TRKDoSupportMask(TRKBuffer*) { } DSError TRKDoReadMemory(TRKBuffer* buffer) { - u8 buf[0x820] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 buf[0x820]; size_t tempLength; int result; int replyErr; @@ -158,7 +158,7 @@ DSError TRKDoReadMemory(TRKBuffer* buffer) { } DSError TRKDoWriteMemory(TRKBuffer* b) { - u8 buf[0x820] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 buf[0x820]; size_t tempLength; int options; int result; diff --git a/libs/dolphin/src/ax/AXAux.c b/libs/dolphin/src/ax/AXAux.c index 7d392d8f1c..cf469197ee 100644 --- a/libs/dolphin/src/ax/AXAux.c +++ b/libs/dolphin/src/ax/AXAux.c @@ -3,8 +3,8 @@ #include "__ax.h" -static s32 __AXBufferAuxA[3][480] ATTRIBUTE_ALIGN(32); -static s32 __AXBufferAuxB[3][480] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static s32 __AXBufferAuxA[3][480]; +ATTRIBUTE_ALIGN(32) static s32 __AXBufferAuxB[3][480]; static void (* __AXCallbackAuxA)(void*, void*); static void (* __AXCallbackAuxB)(void*, void*); diff --git a/libs/dolphin/src/ax/AXSPB.c b/libs/dolphin/src/ax/AXSPB.c index 3729589b62..6fad9bae4b 100644 --- a/libs/dolphin/src/ax/AXSPB.c +++ b/libs/dolphin/src/ax/AXSPB.c @@ -3,7 +3,7 @@ #include "__ax.h" -static AXSPB __AXStudio ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static AXSPB __AXStudio; static s32 __AXSpbAL; static s32 __AXSpbAR; diff --git a/libs/dolphin/src/ax/AXVPB.c b/libs/dolphin/src/ax/AXVPB.c index e8cf663470..02b9db2c63 100644 --- a/libs/dolphin/src/ax/AXVPB.c +++ b/libs/dolphin/src/ax/AXVPB.c @@ -35,9 +35,9 @@ static u32 __AXAuxMixCycles[32] = { 0x000009E2, 0x00000E97 }; -static AXPB __AXPB[AX_MAX_VOICES] ATTRIBUTE_ALIGN(32); -static AXPBITDBUFFER __AXITD[AX_MAX_VOICES] ATTRIBUTE_ALIGN(32); -static AXPBU __AXUpdates[AX_MAX_VOICES] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static AXPB __AXPB[AX_MAX_VOICES]; +ATTRIBUTE_ALIGN(32) static AXPBITDBUFFER __AXITD[AX_MAX_VOICES]; +ATTRIBUTE_ALIGN(32) static AXPBU __AXUpdates[AX_MAX_VOICES]; static AXVPB __AXVPB[AX_MAX_VOICES]; static u32 __AXMaxDspCycles; diff --git a/libs/dolphin/src/ax/DSPCode.c b/libs/dolphin/src/ax/DSPCode.c index 7ca0d067ba..a2f77e2805 100644 --- a/libs/dolphin/src/ax/DSPCode.c +++ b/libs/dolphin/src/ax/DSPCode.c @@ -3,7 +3,7 @@ u16 axDspSlaveLength = (AX_DSP_SLAVE_LENGTH * 2); -u16 axDspSlave[AX_DSP_SLAVE_LENGTH] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) u16 axDspSlave[AX_DSP_SLAVE_LENGTH] = { 0x0000, 0x0000, 0x029F, 0x0E88, 0x029F, 0x0E97, 0x029F, 0x0EB3, 0x029F, 0x0ED3, 0x029F, 0x0ED9, 0x029F, 0x0F0B, 0x029F, 0x0F11, 0x1302, 0x1303, diff --git a/libs/dolphin/src/card/CARDUnlock.c b/libs/dolphin/src/card/CARDUnlock.c index 48f64e500a..31138c2995 100644 --- a/libs/dolphin/src/card/CARDUnlock.c +++ b/libs/dolphin/src/card/CARDUnlock.c @@ -4,7 +4,7 @@ #include "__card.h" -static u8 CardData[352] ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) = { +ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) static u8 CardData[352] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x02, 0xFF, 0x00, 0x21, 0x13, 0x06, 0x12, 0x03, 0x12, 0x04, 0x13, 0x05, 0x00, 0x92, 0x00, 0xFF, 0x00, 0x88, 0xFF, 0xFF, 0x00, 0x89, 0xFF, 0xFF, 0x00, 0x8A, 0xFF, 0xFF, 0x00, diff --git a/libs/dolphin/src/demo/DEMOAVX.c b/libs/dolphin/src/demo/DEMOAVX.c index 39f5d8f554..6de1cfd01d 100644 --- a/libs/dolphin/src/demo/DEMOAVX.c +++ b/libs/dolphin/src/demo/DEMOAVX.c @@ -3,7 +3,7 @@ #include #include "sdk_math.h" -static s16 __AVX_internal_buffer[3200] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static s16 __AVX_internal_buffer[3200]; static void (*__AVX_save_isr)(void); diff --git a/libs/dolphin/src/demo/DEMOFont.c b/libs/dolphin/src/demo/DEMOFont.c index 48299131d9..3ea63d291e 100644 --- a/libs/dolphin/src/demo/DEMOFont.c +++ b/libs/dolphin/src/demo/DEMOFont.c @@ -1,7 +1,7 @@ #include #include -u32 DEMOFontBitmap[768] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) u32 DEMOFontBitmap[768] = { 0x00000000, 0x00000000, 0x00000000, diff --git a/libs/dolphin/src/gx/GXInit.c b/libs/dolphin/src/gx/GXInit.c index c22f5acbd8..639c990d72 100644 --- a/libs/dolphin/src/gx/GXInit.c +++ b/libs/dolphin/src/gx/GXInit.c @@ -43,7 +43,7 @@ void* __piReg; GXBool __GXinBegin; #endif -static u16 DefaultTexData[] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u16 DefaultTexData[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, }; diff --git a/libs/dolphin/src/mcc/mcc.c b/libs/dolphin/src/mcc/mcc.c index fa75efe415..1d05d947a6 100644 --- a/libs/dolphin/src/mcc/mcc.c +++ b/libs/dolphin/src/mcc/mcc.c @@ -7,11 +7,11 @@ const char* __MCCVersion = "<< Dolphin SDK - MCC\tdebug build: Apr 5 2004 03:57 const char* __MCCVersion = "<< Dolphin SDK - MCC\trelease build: Apr 5 2004 04:15:49 (0x2301) >>"; #endif -static MCC_ChannelInfo gChannelInfo[16] ATTRIBUTE_ALIGN(32); -static char gStreamWork[32] ATTRIBUTE_ALIGN(32); -static char m_szAdapterMode[32] ATTRIBUTE_ALIGN(32); -static char m_szInitCode[32] ATTRIBUTE_ALIGN(32); -static MCC_Info channelInfo[16] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static MCC_ChannelInfo gChannelInfo[16]; +ATTRIBUTE_ALIGN(32) static char gStreamWork[32]; +ATTRIBUTE_ALIGN(32) static char m_szAdapterMode[32]; +ATTRIBUTE_ALIGN(32) static char m_szInitCode[32]; +ATTRIBUTE_ALIGN(32) static MCC_Info channelInfo[16]; volatile static BOOL gIsChannelinfoDirty = TRUE; diff --git a/libs/dolphin/src/os/OSRtc.c b/libs/dolphin/src/os/OSRtc.c index ee55fcc0e4..c4f9cb7233 100644 --- a/libs/dolphin/src/os/OSRtc.c +++ b/libs/dolphin/src/os/OSRtc.c @@ -3,7 +3,7 @@ #include "__os.h" -static SramControl Scb ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT); +ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) static SramControl Scb; // prototypes static int GetRTC(u32* rtc); diff --git a/libs/freeverb/CMakeLists.txt b/libs/freeverb/CMakeLists.txt index c0c12da293..d0275f62ac 100644 --- a/libs/freeverb/CMakeLists.txt +++ b/libs/freeverb/CMakeLists.txt @@ -7,3 +7,5 @@ add_library(freeverb allpass.cpp revmodel.cpp ) +target_include_directories(freeverb PRIVATE include/freeverb) +target_include_directories(freeverb INTERFACE include) diff --git a/libs/freeverb/allpass.hpp b/libs/freeverb/include/freeverb/allpass.hpp similarity index 100% rename from libs/freeverb/allpass.hpp rename to libs/freeverb/include/freeverb/allpass.hpp diff --git a/libs/freeverb/comb.hpp b/libs/freeverb/include/freeverb/comb.hpp similarity index 100% rename from libs/freeverb/comb.hpp rename to libs/freeverb/include/freeverb/comb.hpp diff --git a/libs/freeverb/denormals.h b/libs/freeverb/include/freeverb/denormals.h similarity index 100% rename from libs/freeverb/denormals.h rename to libs/freeverb/include/freeverb/denormals.h diff --git a/libs/freeverb/revmodel.hpp b/libs/freeverb/include/freeverb/revmodel.hpp similarity index 100% rename from libs/freeverb/revmodel.hpp rename to libs/freeverb/include/freeverb/revmodel.hpp diff --git a/libs/freeverb/tuning.h b/libs/freeverb/include/freeverb/tuning.h similarity index 100% rename from libs/freeverb/tuning.h rename to libs/freeverb/include/freeverb/tuning.h diff --git a/libs/revolution/src/card/CARDUnlock.c b/libs/revolution/src/card/CARDUnlock.c index 93298297c8..1fad65efe4 100644 --- a/libs/revolution/src/card/CARDUnlock.c +++ b/libs/revolution/src/card/CARDUnlock.c @@ -3,7 +3,7 @@ #include "__card.h" -static u8 CardData[352] ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) = { +ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) static u8 CardData[352] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x02, 0xFF, 0x00, 0x21, 0x13, 0x06, 0x12, 0x03, 0x12, 0x04, 0x13, 0x05, 0x00, 0x92, 0x00, 0xFF, 0x00, 0x88, 0xFF, 0xFF, 0x00, 0x89, 0xFF, 0xFF, 0x00, 0x8A, 0xFF, 0xFF, 0x00, diff --git a/libs/revolution/src/dvd/dvd.c b/libs/revolution/src/dvd/dvd.c index 0e5dbd0945..9e91f6e3f3 100644 --- a/libs/revolution/src/dvd/dvd.c +++ b/libs/revolution/src/dvd/dvd.c @@ -44,7 +44,7 @@ static u32 LastError; static BOOL ResetRequired; static u32 MotorState; static volatile OSTime LastResetEnd; -static u32 __DVDNumTmdBytes ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u32 __DVDNumTmdBytes; static DVDGameTOC* GameToc; static DVDPartitionInfo* PartInfo; static DVDPartitionInfo* BootGameInfo; @@ -80,10 +80,10 @@ static DVDCommandBlock DummyCommandBlock; static OSAlarm ResetAlarm; static OSAlarm CoverAlarm; -static u8 __DVDGameTocBuffer[OSRoundUp32B(sizeof(DVDGameTOC) * 4)] ATTRIBUTE_ALIGN(32); -static u8 __DVDPartInfoBuffer[OSRoundUp32B(sizeof(DVDPartitionInfo) * 4)] ATTRIBUTE_ALIGN(32); -static u8 __DVDTmdBuffer[OSRoundUp32B(sizeof(ESTitleMeta))] ATTRIBUTE_ALIGN(32); -static u8 __DVDTicketViewBuffer[OSRoundUp32B(sizeof(ESTicketView))] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u8 __DVDGameTocBuffer[OSRoundUp32B(sizeof(DVDGameTOC) * 4)]; +ATTRIBUTE_ALIGN(32) static u8 __DVDPartInfoBuffer[OSRoundUp32B(sizeof(DVDPartitionInfo) * 4)]; +ATTRIBUTE_ALIGN(32) static u8 __DVDTmdBuffer[OSRoundUp32B(sizeof(ESTitleMeta))]; +ATTRIBUTE_ALIGN(32) static u8 __DVDTicketViewBuffer[OSRoundUp32B(sizeof(ESTicketView))]; static OSAlarm FatalAlarm; DVDCommandBlock __DVDStopMotorCommandBlock; diff --git a/libs/revolution/src/dvd/dvdDeviceError.c b/libs/revolution/src/dvd/dvdDeviceError.c index 316346461f..6fa74234ee 100644 --- a/libs/revolution/src/dvd/dvdDeviceError.c +++ b/libs/revolution/src/dvd/dvdDeviceError.c @@ -5,7 +5,7 @@ #include "__os.h" #include "__dvd.h" -static u8 CheckBuffer[32] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u8 CheckBuffer[32]; static volatile BOOL lowDone = TRUE; static volatile u32 lowIntType = 0; diff --git a/libs/revolution/src/dvd/dvd_broadway.c b/libs/revolution/src/dvd/dvd_broadway.c index ab4840791f..c2e8aef89d 100644 --- a/libs/revolution/src/dvd/dvd_broadway.c +++ b/libs/revolution/src/dvd/dvd_broadway.c @@ -8,15 +8,15 @@ static volatile u8 requestInProgress = FALSE; static u8 breakRequested; static u8 callbackInProgress; -static u32 registerBuf[8] ATTRIBUTE_ALIGN(32); -static u32 statusRegister[8] ATTRIBUTE_ALIGN(32); -static u32 controlRegister[8] ATTRIBUTE_ALIGN(32); -static s32 lastTicketError[8] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u32 registerBuf[8]; +ATTRIBUTE_ALIGN(32) static u32 statusRegister[8]; +ATTRIBUTE_ALIGN(32) static u32 controlRegister[8]; +ATTRIBUTE_ALIGN(32) static s32 lastTicketError[8]; static u32 readLength; static u32 spinUpValue; -static diRegVals_t diRegValCache ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static diRegVals_t diRegValCache; static u8 DVDLowInitCalled = FALSE; @@ -42,8 +42,8 @@ typedef struct dvdContext { static int freeDvdContext = 0; static u8 dvdContextsInited = FALSE; -static dvdContext_t dvdContexts[4] ATTRIBUTE_ALIGN(32); -static IOSIoVector ioVec[10] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static dvdContext_t dvdContexts[4]; +ATTRIBUTE_ALIGN(32) static IOSIoVector ioVec[10]; static void* ddrAllocAligned32(const int size) { void* low, *high; diff --git a/libs/revolution/src/dvd/dvderror.c b/libs/revolution/src/dvd/dvderror.c index 7f1e8e52ad..8b12465825 100644 --- a/libs/revolution/src/dvd/dvderror.c +++ b/libs/revolution/src/dvd/dvderror.c @@ -11,8 +11,8 @@ static NANDCommandBlock NandCb; static NANDFileInfo NandInfo; static DVDCBCallback Callback; static u32 NextOffset; -DVDErrorInfo __ErrorInfo ATTRIBUTE_ALIGN(32); -DVDErrorInfo __FirstErrorInfo ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) DVDErrorInfo __ErrorInfo; +ATTRIBUTE_ALIGN(32) DVDErrorInfo __FirstErrorInfo; void cbForNandClose(s32 result, NANDCommandBlock* block) { if (Callback) { diff --git a/libs/revolution/src/esp/esp.c b/libs/revolution/src/esp/esp.c index 68899e2598..aec3e862b1 100644 --- a/libs/revolution/src/esp/esp.c +++ b/libs/revolution/src/esp/esp.c @@ -33,7 +33,7 @@ s32 ESP_CloseLib(void) { s32 ESP_LaunchTitle(u64 titleID, ESTicketView* pTicketView) { s32 ret = 0; - u8 buf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 buf[256]; IOSIoVector* vec = (IOSIoVector*)(buf + 208); u64* id = (u64*)buf; @@ -63,7 +63,7 @@ out: s32 ESP_GetTicketViews(ESTitleId titleId, ESTicketView* ticketViewList, u32* ticketViewCnt) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); ESTitleId* p1 = (ESTitleId*)__esBuf; u32* p2 = (u32*)(__esBuf + 32); @@ -111,7 +111,7 @@ out: s32 ESP_DiGetTicketView(const void* ticket, ESTicketView* ticketView) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); if (__esFd < 0 || ticketView == NULL) { @@ -142,7 +142,7 @@ out: s32 ESP_DiGetTmd(ESTitleMeta* tmd, u32* tmdSize) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); u32* p1 = (u32*)__esBuf; @@ -184,7 +184,7 @@ out: s32 ESP_GetTmdView(ESTitleId titleId, ESTmdView* tmdView, u32* size) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); ESTitleId* p1 = (ESTitleId*)__esBuf; u32* p2 = (u32*)(__esBuf + 32); @@ -233,7 +233,7 @@ out: s32 ESP_GetDataDir(ESTitleId titleId, char* dataDir) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); ESTitleId* p1 = (ESTitleId*)__esBuf; @@ -260,7 +260,7 @@ out: s32 ESP_GetTitleId(ESTitleId* titleId) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); if (__esFd < 0 || titleId == NULL) { @@ -283,7 +283,7 @@ out: s32 ESP_GetConsumption(ESTicketId ticketId, ESLpEntry* entries, u32* nEntries) { s32 rv = 0; - u8 __esBuf[256] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 __esBuf[256]; IOSIoVector* v = (IOSIoVector*)(__esBuf + 256 - 6 * sizeof(IOSIoVector)); ESTicketId* p1 = (ESTicketId*)__esBuf; u32* p2 = (u32*)(__esBuf + 32); diff --git a/libs/revolution/src/fs/fs.c b/libs/revolution/src/fs/fs.c index 1e5f601198..34397254c1 100644 --- a/libs/revolution/src/fs/fs.c +++ b/libs/revolution/src/fs/fs.c @@ -25,7 +25,7 @@ typedef struct isfs_GetUsage { } isfs_GetUsage; typedef struct __isfsCtxt { - u8 ioBuf[ROUNDUP(256)] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 ioBuf[ROUNDUP(256)]; ISFSCallback cb; void* ctxt; u32 func; diff --git a/libs/revolution/src/gx/GXInit.c b/libs/revolution/src/gx/GXInit.c index 0504827170..0ae463d84d 100644 --- a/libs/revolution/src/gx/GXInit.c +++ b/libs/revolution/src/gx/GXInit.c @@ -49,7 +49,7 @@ volatile void* __piReg; GXBool __GXinBegin; #endif -static u16 DefaultTexData[] ATTRIBUTE_ALIGN(32) = { +ATTRIBUTE_ALIGN(32) static u16 DefaultTexData[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, }; diff --git a/libs/revolution/src/homebuttonLib/nw4hbm/lyt/picture.h b/libs/revolution/src/homebuttonLib/nw4hbm/lyt/picture.h index 4a77129ea7..c34a092a61 100644 --- a/libs/revolution/src/homebuttonLib/nw4hbm/lyt/picture.h +++ b/libs/revolution/src/homebuttonLib/nw4hbm/lyt/picture.h @@ -34,7 +34,7 @@ namespace nw4hbm { private: /* 0x00 (base) */ - /* 0xD4 */ ut::Color mVtxColors[VERTEXCOLOR_MAX] ATTRIBUTE_ALIGN(4); + /* 0xD4 */ ATTRIBUTE_ALIGN(4) ut::Color mVtxColors[VERTEXCOLOR_MAX]; /* 0xE4 */ detail::TexCoordAry mTexCoordAry; }; diff --git a/libs/revolution/src/homebuttonLib/nw4hbm/snd/StrmPlayer.h b/libs/revolution/src/homebuttonLib/nw4hbm/snd/StrmPlayer.h index eae08ba82d..45f682b4b9 100644 --- a/libs/revolution/src/homebuttonLib/nw4hbm/snd/StrmPlayer.h +++ b/libs/revolution/src/homebuttonLib/nw4hbm/snd/StrmPlayer.h @@ -58,7 +58,7 @@ namespace nw4hbm { public: /* 0x14 */ ut::LinkListNode mLinkNode; - static u8 mMramBuf[LOAD_BUFFER_SIZE] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) static u8 mMramBuf[LOAD_BUFFER_SIZE]; }; typedef ut::LinkList LoadCommandList; diff --git a/libs/revolution/src/ipc/ipcclt.c b/libs/revolution/src/ipc/ipcclt.c index 6976775218..449e94ecd0 100644 --- a/libs/revolution/src/ipc/ipcclt.c +++ b/libs/revolution/src/ipc/ipcclt.c @@ -24,7 +24,7 @@ static u32 __relnchFl = 0; typedef struct IOSRpcRequest { IOSResourceRequest request; - IOSIpcCb cb ATTRIBUTE_ALIGN(32); // I am assuming this is aligned due to where cbArg is stored, and I see nothing between cb and callback_arg? + ATTRIBUTE_ALIGN(32) IOSIpcCb cb; // I am assuming this is aligned due to where cbArg is stored, and I see nothing between cb and callback_arg? void* callback_arg; u32 relaunch_flag; OSThreadQueue thread_queue; @@ -37,7 +37,7 @@ static IOSRpcRequest* __relnchRpcSave = 0; #define ROUNDUP(sz) (((u32)(sz) + (IPC_BUF_CNT / 2 - 1)) & ~(u32)(IPC_BUF_CNT / 2 - 1)) -static u8 __rpcBuf[ROUNDUP(sizeof(IOSRpcRequest))] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u8 __rpcBuf[ROUNDUP(sizeof(IOSRpcRequest))]; static struct { u32 rcount; diff --git a/libs/revolution/src/nand/NANDCore.c b/libs/revolution/src/nand/NANDCore.c index c93ec26c9c..8a9818197f 100644 --- a/libs/revolution/src/nand/NANDCore.c +++ b/libs/revolution/src/nand/NANDCore.c @@ -33,8 +33,8 @@ enum LibState { }; static enum LibState s_libState = STATE_NOT_INITIALIZED; -static char s_currentDir[64] ATTRIBUTE_ALIGN(32) = "/"; -static char s_homeDir[64] ATTRIBUTE_ALIGN(32) = ""; +ATTRIBUTE_ALIGN(32) static char s_currentDir[64] = "/"; +ATTRIBUTE_ALIGN(32) static char s_homeDir[64] = ""; static BOOL nandOnShutdown(BOOL final, u32 event); void nandConvertPath(char* abspath, const char* wd, const char* relpath); @@ -262,7 +262,7 @@ s32 nandConvertErrorCode(const ISFSError err) { for (; i < sizeof(ERRMAP) / 4; i = i + 2) { if (ERRMAP[i] == err) { if (err == ISFS_ERROR_ECC_CRIT || err == ISFS_ERROR_HMAC || err == ISFS_ERROR_UNKNOWN || err == IOS_ERROR_UNKNOWN || err == IOS_ERROR_ECC_CRIT) { - char buf[128] ATTRIBUTE_ALIGN(64); + ATTRIBUTE_ALIGN(64) char buf[128]; sprintf(buf, "ISFS error code: %d", err); NANDLoggingAddMessageAsync(nandLoggingCallback, err, buf); } @@ -279,7 +279,7 @@ s32 nandConvertErrorCode(const ISFSError err) { OSReport("CAUTION! Unexpected error code [%d] was found.\n", err); { - char buf[128] ATTRIBUTE_ALIGN(64); + ATTRIBUTE_ALIGN(64) char buf[128]; sprintf(buf, "ISFS unexpected error code: %d", err); NANDLoggingAddMessageAsync(nandLoggingCallback, err, buf); } diff --git a/libs/revolution/src/nand/NANDLogging.c b/libs/revolution/src/nand/NANDLogging.c index 8e620895d5..409fbad527 100644 --- a/libs/revolution/src/nand/NANDLogging.c +++ b/libs/revolution/src/nand/NANDLogging.c @@ -7,7 +7,7 @@ static IOSFd s_fd = -255; static IOSError s_err = ISFS_ERROR_UNKNOWN; static int s_stage; -static char s_message[256] ATTRIBUTE_ALIGN(64); +ATTRIBUTE_ALIGN(64) static char s_message[256]; static NANDLoggingCallback s_callback = 0; static void asyncRoutine(ISFSError, void*); @@ -70,8 +70,8 @@ static void callbackRoutine(BOOL result) { static void asyncRoutine(ISFSError result, void *ctxt) { ISFSError ret = ISFS_ERROR_UNKNOWN; - static char s_rBuf[256] ATTRIBUTE_ALIGN(64); - static char s_wBuf[256] ATTRIBUTE_ALIGN(64); + ATTRIBUTE_ALIGN(64) static char s_rBuf[256]; + ATTRIBUTE_ALIGN(64) static char s_wBuf[256]; ++s_stage; if (s_stage == 2) { diff --git a/libs/revolution/src/nand/nand.c b/libs/revolution/src/nand/nand.c index 6155789690..1fd2640660 100644 --- a/libs/revolution/src/nand/nand.c +++ b/libs/revolution/src/nand/nand.c @@ -293,7 +293,7 @@ s32 NANDMove(const char* path, const char* destDir) { } static ISFSError nandGetFileStatus(IOSFd fd, u32* length, u32* pos) { - ISFSFileStats fstat ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) ISFSFileStats fstat; ISFSError result = ISFS_GetFileStats(fd, &fstat); if (result == ISFS_ERROR_OK) { if (length) { diff --git a/libs/revolution/src/os/OSLaunch.c b/libs/revolution/src/os/OSLaunch.c index 2c57906e95..f82f2ef19f 100644 --- a/libs/revolution/src/os/OSLaunch.c +++ b/libs/revolution/src/os/OSLaunch.c @@ -8,7 +8,7 @@ void __OSRelaunchTitle(u32 resetCode) { s32 rc = 0; u32 ticketCnt = 1; ESTicketView* tik = NULL; - ESTitleId titleId ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) ESTitleId titleId; __OSPlayTimeType type = OSPLAYTIME_PERMANENT; u32 remain = 0; u8* bi2 = NULL; diff --git a/libs/revolution/src/os/OSNet.c b/libs/revolution/src/os/OSNet.c index e68c789734..b749532494 100644 --- a/libs/revolution/src/os/OSNet.c +++ b/libs/revolution/src/os/OSNet.c @@ -85,7 +85,7 @@ NWC24Err NWC24iSynchronizeRtcCounter(BOOL param_0) { } NWC24Err NWC24SuspendScheduler(void) { - static u8 susResult[0x20] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) static u8 susResult[0x20]; NWC24Err rt = NWC24_OK; NWC24Err closeRt = NWC24_OK; IOSFd fd; diff --git a/libs/revolution/src/os/OSPlayRecord.c b/libs/revolution/src/os/OSPlayRecord.c index a1499e71b7..b9743d9946 100644 --- a/libs/revolution/src/os/OSPlayRecord.c +++ b/libs/revolution/src/os/OSPlayRecord.c @@ -2,7 +2,7 @@ #include static BOOL PlayRecordGet = FALSE; -static OSPlayRecord PlayRecord ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static OSPlayRecord PlayRecord; static NANDFileInfo FileInfo; static NANDCommandBlock Block; static s32 PlayRecordState = 9; diff --git a/libs/revolution/src/os/OSPlayTime.c b/libs/revolution/src/os/OSPlayTime.c index 653afad7db..675d88d020 100644 --- a/libs/revolution/src/os/OSPlayTime.c +++ b/libs/revolution/src/os/OSPlayTime.c @@ -7,7 +7,7 @@ #include "__os.h" -OSAlarm __OSExpireAlarm ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) OSAlarm __OSExpireAlarm; OSTime __OSExpireTime; OSPlayTimeCallbackFunc __OSExpireCallback; BOOL __OSExpireSetExpiredFlag; @@ -103,7 +103,7 @@ BOOL __OSWriteExpiredFlag(void) { s32 rv = 0; NANDFileInfo nInfo; BOOL openNInfo = FALSE; - u8 titleId[32] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) u8 titleId[32]; rv = NANDPrivateCreate("/shared2/expired", 63, 0); @@ -162,7 +162,7 @@ BOOL __OSWriteExpiredFlagIfSet(void) { void* __OSPlayTimeRebootThread(void* args) { BOOL enabled; u32 frames, fadeShift = 1; - __OSExpireAIFadeStruct aiFade ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) __OSExpireAIFadeStruct aiFade; __OSExpireAIFade = &aiFade; memset(__OSExpireAIFade, 0, sizeof(__OSExpireAIFadeStruct)); @@ -227,9 +227,9 @@ out: s32 __OSGetPlayTime(ESTicketView* ticket, __OSPlayTimeType* type, u32* playTime) { s32 rv; u32 i; - ESLpEntry lpEntry[8] ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) ESLpEntry lpEntry[8]; u32 numCc = 0, seenOther = 0; - ESTicketView ticketAligned ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) ESTicketView ticketAligned; ASSERTLINE(601, ticket && type && playTime); @@ -288,7 +288,7 @@ out: s32 __OSGetPlayTimeCurrent(__OSPlayTimeType* type, u32* playTime) { s32 rv; - ESTicketView ticket ATTRIBUTE_ALIGN(32); + ATTRIBUTE_ALIGN(32) ESTicketView ticket; ASSERTLINE(676, type && playTime); diff --git a/libs/revolution/src/os/OSRtc.c b/libs/revolution/src/os/OSRtc.c index 11fa04e05d..d5fa89ee54 100644 --- a/libs/revolution/src/os/OSRtc.c +++ b/libs/revolution/src/os/OSRtc.c @@ -3,7 +3,7 @@ #include "__os.h" -static SramControl Scb ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT); +ATTRIBUTE_ALIGN(DOLPHIN_ALIGNMENT) static SramControl Scb; // prototypes static int GetRTC(u32* rtc); diff --git a/libs/revolution/src/os/OSStateFlags.c b/libs/revolution/src/os/OSStateFlags.c index 723069d5a6..9283c57499 100644 --- a/libs/revolution/src/os/OSStateFlags.c +++ b/libs/revolution/src/os/OSStateFlags.c @@ -2,7 +2,7 @@ #include #include -static OSStateFlags StateFlags ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static OSStateFlags StateFlags; static u32 CheckSum(OSStateFlags* flags) { u32* ptr, i, sum; diff --git a/libs/revolution/src/os/OSStateTM.c b/libs/revolution/src/os/OSStateTM.c index a81de612cf..d08bf5e6f6 100644 --- a/libs/revolution/src/os/OSStateTM.c +++ b/libs/revolution/src/os/OSStateTM.c @@ -5,14 +5,14 @@ #include -static u32 StmImInBuf[8] ATTRIBUTE_ALIGN(32); -static u32 StmImOutBuf[8] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u32 StmImInBuf[8]; +ATTRIBUTE_ALIGN(32) static u32 StmImOutBuf[8]; -static u32 StmVdInBuf[8] ATTRIBUTE_ALIGN(32); -static u32 StmVdOutBuf[8] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u32 StmVdInBuf[8]; +ATTRIBUTE_ALIGN(32) static u32 StmVdOutBuf[8]; -static u32 StmEhInBuf[8] ATTRIBUTE_ALIGN(32); -static u32 StmEhOutBuf[8] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u32 StmEhInBuf[8]; +ATTRIBUTE_ALIGN(32) static u32 StmEhOutBuf[8]; static OSResetCallback ResetCallback; static OSPowerCallback PowerCallback; diff --git a/libs/revolution/src/os/OSThread.c b/libs/revolution/src/os/OSThread.c index dbe745d17a..447709a17d 100644 --- a/libs/revolution/src/os/OSThread.c +++ b/libs/revolution/src/os/OSThread.c @@ -873,4 +873,4 @@ void* OSGetThreadSpecific(s32 index) { #include "global.h" extern u8 Debug_BBA_804516D0; -u8 Debug_BBA_804516D0 ATTRIBUTE_ALIGN(8); +ATTRIBUTE_ALIGN(8) u8 Debug_BBA_804516D0; diff --git a/libs/revolution/src/sc/scsystem.c b/libs/revolution/src/sc/scsystem.c index 74d78e6bfc..a03fe7b3b7 100644 --- a/libs/revolution/src/sc/scsystem.c +++ b/libs/revolution/src/sc/scsystem.c @@ -75,8 +75,8 @@ static const char ConfDirName[] = "/shared2/sys"; static const char ConfFileName[] = "/shared2/sys/SYSCONF"; static const char ProductInfoFileName[] = "/title/00000001/00000002/data/setting.txt"; -static u8 ConfBuf[0x4000] ATTRIBUTE_ALIGN(32); -static u8 ConfBufForFlush[0x4000] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) static u8 ConfBuf[0x4000]; +ATTRIBUTE_ALIGN(32) static u8 ConfBufForFlush[0x4000]; static u8 Initialized; static u8 DirtyFlag; diff --git a/libs/revolution/src/wpad/WPAD.c b/libs/revolution/src/wpad/WPAD.c index 20e7509da3..3a0591f396 100644 --- a/libs/revolution/src/wpad/WPAD.c +++ b/libs/revolution/src/wpad/WPAD.c @@ -262,7 +262,7 @@ void WPADiManageHandler(OSAlarm*, OSContext*) { BTA_HhGetAclQueueInfo(); } -u8 __WPADiManageHandlerStack[4096] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) u8 __WPADiManageHandlerStack[4096]; void WPADiManageHandler0(OSAlarm* alarm, OSContext* context) { OSSwitchFiberEx((u32)alarm, (u32)context, 0, 0, (u32)WPADiManageHandler, (u32)(__WPADiManageHandlerStack + sizeof(__WPADiManageHandlerStack))); diff --git a/libs/revolution/src/wud/WUD.c b/libs/revolution/src/wud/WUD.c index 72a2c9b60b..deef3b2624 100644 --- a/libs/revolution/src/wud/WUD.c +++ b/libs/revolution/src/wud/WUD.c @@ -41,7 +41,7 @@ WUDControlBlock _wcb; WUDDevInfo _work; static WUDDiscResp _discResp; SCBtDeviceInfoArray _scArray; -u8 __WUDHandlerStack[0x1000] ATTRIBUTE_ALIGN(32); +ATTRIBUTE_ALIGN(32) u8 __WUDHandlerStack[0x1000]; extern u8 _scFlush; diff --git a/mods/ao_mod/CMakeLists.txt b/mods/ao_mod/CMakeLists.txt new file mode 100644 index 0000000000..7304654d0c --- /dev/null +++ b/mods/ao_mod/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.25) +project(ao_mod CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(ao_mod + FEATURES webgpu + SOURCES src/mod.cpp + MOD_JSON mod.json + RES_DIR res +) diff --git a/mods/ao_mod/mod.json b/mods/ao_mod/mod.json new file mode 100644 index 0000000000..9019cf335d --- /dev/null +++ b/mods/ao_mod/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.ao_mod", + "name": "[Demo] Ambient Occlusion", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "Ground-truth ambient occlusion (GTAO) computed from the scene depth buffer and composited over the game. Ported from Bevy Engine's SSAO and Intel XeGTAO." +} diff --git a/mods/ao_mod/res/composite.wgsl b/mods/ao_mod/res/composite.wgsl new file mode 100644 index 0000000000..fa3a0101b8 --- /dev/null +++ b/mods/ao_mod/res/composite.wgsl @@ -0,0 +1,161 @@ +// Fullscreen composite: multiplies the denoised ambient-occlusion visibility over the scene. +// +// Debug views: +// 1 = raw AO visibility as grayscale +// 2 = view-space normals reconstructed from depth (keep in sync with gtao.wgsl) +// 3 = the preprocessed depth input +// 4 = depth staircase detector + +struct Uniforms { + projection: mat4x4f, + inverse_projection: mat4x4f, + size: vec2f, // AO texture size in pixels (may be half the render size) + inv_size: vec2f, + depth_scale: vec2f, + effect_radius: f32, + intensity: f32, + slice_count: f32, + samples_per_slice_side: f32, + debug_view: u32, + _pad: f32, +} + +@group(0) @binding(0) var ambient_occlusion: texture_2d; +@group(0) @binding(1) var preprocessed_depth: texture_2d; +@group(0) @binding(2) var scene_depth_raw: texture_2d; +@group(0) @binding(3) var uniforms: Uniforms; + +struct VertexOutput { + @builtin(position) position: vec4f, + @location(0) uv: vec2f, +} + +@vertex +fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput { + // Fullscreen triangle + var out: VertexOutput; + let uv = vec2f(f32((index << 1u) & 2u), f32(index & 2u)); + out.position = vec4f(uv * vec2f(2.0, -2.0) + vec2f(-1.0, 1.0), 0.0, 1.0); + out.uv = uv; + return out; +} + +// Manual bilinear sample (r32float is unfilterable without optional device features) +fn sample_visibility(uv: vec2f) -> f32 { + let coordinates = uv * uniforms.size - 0.5; + let base = floor(coordinates); + let fraction = coordinates - base; + let max_coordinates = vec2i(uniforms.size) - 1i; + let p00 = clamp(vec2i(base), vec2i(0i), max_coordinates); + let p11 = clamp(vec2i(base) + 1i, vec2i(0i), max_coordinates); + let v00 = textureLoad(ambient_occlusion, vec2i(p00.x, p00.y), 0i).r; + let v10 = textureLoad(ambient_occlusion, vec2i(p11.x, p00.y), 0i).r; + let v01 = textureLoad(ambient_occlusion, vec2i(p00.x, p11.y), 0i).r; + let v11 = textureLoad(ambient_occlusion, vec2i(p11.x, p11.y), 0i).r; + let top = mix(v00, v10, fraction.x); + let bottom = mix(v01, v11, fraction.x); + return mix(top, bottom, fraction.y); +} + +fn load_depth(pixel_coordinates: vec2) -> f32 { + let coordinates = clamp(pixel_coordinates, vec2(0i), vec2(uniforms.size) - 1i); + return textureLoad(preprocessed_depth, coordinates, 0i).r; +} + +fn reconstruct_view_space_position(depth: f32, uv: vec2f) -> vec3f { + let clip_xy = vec2f(uv.x * 2.0 - 1.0, 1.0 - 2.0 * uv.y); + let t = uniforms.inverse_projection * vec4f(clip_xy, depth, 1.0); + return t.xyz / t.w; +} + +fn view_position_at(pixel_coordinates: vec2) -> vec3f { + let depth = load_depth(pixel_coordinates); + let uv = (vec2f(pixel_coordinates) + 0.5) * uniforms.inv_size; + return reconstruct_view_space_position(depth, uv); +} + +fn reconstruct_normal(pixel_coordinates: vec2, pixel_position: vec3f, depth_center: f32) -> vec3f { + let depth_left1 = load_depth(pixel_coordinates + vec2(-1i, 0i)); + let depth_left2 = load_depth(pixel_coordinates + vec2(-2i, 0i)); + let depth_right1 = load_depth(pixel_coordinates + vec2(1i, 0i)); + let depth_right2 = load_depth(pixel_coordinates + vec2(2i, 0i)); + let depth_top1 = load_depth(pixel_coordinates + vec2(0i, -1i)); + let depth_top2 = load_depth(pixel_coordinates + vec2(0i, -2i)); + let depth_bottom1 = load_depth(pixel_coordinates + vec2(0i, 1i)); + let depth_bottom2 = load_depth(pixel_coordinates + vec2(0i, 2i)); + + let use_left = abs(2.0 * depth_left1 - depth_left2 - depth_center) < + abs(2.0 * depth_right1 - depth_right2 - depth_center); + let use_top = abs(2.0 * depth_top1 - depth_top2 - depth_center) < + abs(2.0 * depth_bottom1 - depth_bottom2 - depth_center); + + var ddx: vec3f; + if use_left { + ddx = pixel_position - view_position_at(pixel_coordinates + vec2(-1i, 0i)); + } else { + ddx = view_position_at(pixel_coordinates + vec2(1i, 0i)) - pixel_position; + } + var ddy: vec3f; + if use_top { + ddy = pixel_position - view_position_at(pixel_coordinates + vec2(0i, -1i)); + } else { + ddy = view_position_at(pixel_coordinates + vec2(0i, 1i)) - pixel_position; + } + + var normal = normalize(cross(ddy, ddx)); + if dot(normal, pixel_position) > 0.0 { + normal = -normal; + } + return normal; +} + +// Raw-snapshot variant of load_depth for the staircase view +fn load_raw_depth(pixel_coordinates: vec2) -> f32 { + let size = vec2(textureDimensions(scene_depth_raw)); + let coordinates = clamp(pixel_coordinates, vec2(0i), size - 1i); + return textureLoad(scene_depth_raw, coordinates, 0i).r; +} + +@fragment +fn fs_main(in: VertexOutput) -> @location(0) vec4f { + if uniforms.debug_view == 2u { + // Reconstructed view-space normals, [-1,1] -> RGB + let pixel = vec2(in.uv * uniforms.size); + let depth = load_depth(pixel); + let uv = (vec2f(pixel) + 0.5) * uniforms.inv_size; + let position = reconstruct_view_space_position(depth, uv); + let normal = reconstruct_normal(pixel, position, depth); + return vec4f(normal * 0.5 + 0.5, 1.0); + } + if uniforms.debug_view == 3u { + // Preprocessed depth as an exponential distance gradient (white = near, black = far) + let pixel = vec2(in.uv * uniforms.size); + let position = view_position_at(pixel); + let value = exp(-max(-position.z, 0.0) * 0.0003); + return vec4f(value, value, value, 1.0); + } + if uniforms.debug_view == 4u { + // Staircase detector on the raw snapshot depth + let size = vec2f(textureDimensions(scene_depth_raw)); + let pixel = vec2(in.uv * size); + let d_center = load_raw_depth(pixel); + let d_left = load_raw_depth(pixel + vec2(-1i, 0i)); + let d_right = load_raw_depth(pixel + vec2(1i, 0i)); + let d_top = load_raw_depth(pixel + vec2(0i, -1i)); + let d_bottom = load_raw_depth(pixel + vec2(0i, 1i)); + let gradient_x = abs(d_right - d_left) * 0.5; + let curvature_x = abs(d_right - 2.0 * d_center + d_left); + let gradient_y = abs(d_bottom - d_top) * 0.5; + let curvature_y = abs(d_bottom - 2.0 * d_center + d_top); + let ratio_x = curvature_x / max(gradient_x, 1e-12); + let ratio_y = curvature_y / max(gradient_y, 1e-12); + return vec4f(saturate(ratio_x), saturate(ratio_y), 0.0, 1.0); + } + + let visibility = sample_visibility(in.uv); + if uniforms.debug_view == 1u { + return vec4f(visibility, visibility, visibility, 1.0); + } + let value = mix(1.0, visibility, uniforms.intensity); + return vec4f(value, value, value, 1.0); +} diff --git a/mods/ao_mod/res/denoise.wgsl b/mods/ao_mod/res/denoise.wgsl new file mode 100644 index 0000000000..b947b1bd04 --- /dev/null +++ b/mods/ao_mod/res/denoise.wgsl @@ -0,0 +1,108 @@ +// 3x3 bilaterial filter (edge-preserving blur) +// https://people.csail.mit.edu/sparis/bf_course/course_notes.pdf +// +// Note: Does not use the Gaussian kernel part of a typical bilateral blur +// From the paper: "use the information gathered on a neighborhood of 4 x 4 using a bilateral filter for +// reconstruction, using _uniform_ convolution weights" +// +// Note: The paper does a 4x4 (not quite centered) filter, offset by +/- 1 pixel every other frame +// XeGTAO does a 3x3 filter, on two pixels at a time per compute thread, applied twice +// We do a 3x3 filter, on 1 pixel per compute thread, applied once +// +// Ported from Bevy Engine, crates/bevy_pbr/src/ssao/spatial_denoise.wgsl (v0.13.2), licensed +// MIT OR Apache-2.0 (see res/licenses/), itself derived from Intel XeGTAO (MIT). +// +// PORT: the textureGather calls are rewritten as explicit per-neighbor textureLoads (r32float +// and r32uint are unfilterable); Bevy view uniforms -> the mod's uniform block; r16float -> r32float. + +struct Uniforms { + projection: mat4x4f, + inverse_projection: mat4x4f, + size: vec2f, + inv_size: vec2f, + depth_scale: vec2f, + effect_radius: f32, + intensity: f32, + slice_count: f32, + samples_per_slice_side: f32, + debug_view: u32, + _pad: f32, +} + +@group(0) @binding(0) var ambient_occlusion_noisy: texture_2d; +@group(0) @binding(1) var depth_differences: texture_2d; +@group(0) @binding(2) var ambient_occlusion: texture_storage_2d; +@group(0) @binding(3) var uniforms: Uniforms; + +fn clamp_coordinates(pixel_coordinates: vec2) -> vec2 { + return clamp(pixel_coordinates, vec2(0i), vec2(uniforms.size) - 1i); +} + +// Each pixel's packed edge info is (left, right, top, bottom) weights, packed by the GTAO pass. +fn load_edges(pixel_coordinates: vec2) -> vec4 { + return unpack4x8unorm(textureLoad(depth_differences, clamp_coordinates(pixel_coordinates), 0i).r); +} + +fn load_visibility(pixel_coordinates: vec2) -> f32 { + return textureLoad(ambient_occlusion_noisy, clamp_coordinates(pixel_coordinates), 0i).r; +} + +@compute +@workgroup_size(8, 8, 1) +fn spatial_denoise(@builtin(global_invocation_id) global_id: vec3) { + let pixel_coordinates = vec2(global_id.xy); + + let left_edges = load_edges(pixel_coordinates + vec2(-1i, 0i)); + let right_edges = load_edges(pixel_coordinates + vec2(1i, 0i)); + let top_edges = load_edges(pixel_coordinates + vec2(0i, -1i)); + let bottom_edges = load_edges(pixel_coordinates + vec2(0i, 1i)); + var center_edges = load_edges(pixel_coordinates); + // Cross-check each edge against the neighbor's opposing edge weight. + center_edges *= vec4(left_edges.y, right_edges.x, top_edges.w, bottom_edges.z); + + let center_weight = 1.2; + let left_weight = center_edges.x; + let right_weight = center_edges.y; + let top_weight = center_edges.z; + let bottom_weight = center_edges.w; + let top_left_weight = 0.425 * (top_weight * top_edges.x + left_weight * left_edges.z); + let top_right_weight = 0.425 * (top_weight * top_edges.y + right_weight * right_edges.z); + let bottom_left_weight = 0.425 * (bottom_weight * bottom_edges.x + left_weight * left_edges.w); + let bottom_right_weight = 0.425 * (bottom_weight * bottom_edges.y + right_weight * right_edges.w); + + let center_visibility = load_visibility(pixel_coordinates); + let left_visibility = load_visibility(pixel_coordinates + vec2(-1i, 0i)); + let right_visibility = load_visibility(pixel_coordinates + vec2(1i, 0i)); + let top_visibility = load_visibility(pixel_coordinates + vec2(0i, -1i)); + let bottom_visibility = load_visibility(pixel_coordinates + vec2(0i, 1i)); + let top_left_visibility = load_visibility(pixel_coordinates + vec2(-1i, -1i)); + let top_right_visibility = load_visibility(pixel_coordinates + vec2(1i, -1i)); + let bottom_left_visibility = load_visibility(pixel_coordinates + vec2(-1i, 1i)); + let bottom_right_visibility = load_visibility(pixel_coordinates + vec2(1i, 1i)); + + // PORT: Bevy sums the center sample unweighted while still counting center_weight in the + // denominator; XeGTAO's original weights the value too, which is what we do here. + var sum = center_visibility * center_weight; + sum += left_visibility * left_weight; + sum += right_visibility * right_weight; + sum += top_visibility * top_weight; + sum += bottom_visibility * bottom_weight; + sum += top_left_visibility * top_left_weight; + sum += top_right_visibility * top_right_weight; + sum += bottom_left_visibility * bottom_left_weight; + sum += bottom_right_visibility * bottom_right_weight; + + var sum_weight = center_weight; + sum_weight += left_weight; + sum_weight += right_weight; + sum_weight += top_weight; + sum_weight += bottom_weight; + sum_weight += top_left_weight; + sum_weight += top_right_weight; + sum_weight += bottom_left_weight; + sum_weight += bottom_right_weight; + + let denoised_visibility = sum / sum_weight; + + textureStore(ambient_occlusion, pixel_coordinates, vec4(denoised_visibility, 0.0, 0.0, 0.0)); +} diff --git a/mods/ao_mod/res/gtao.wgsl b/mods/ao_mod/res/gtao.wgsl new file mode 100644 index 0000000000..ee23774681 --- /dev/null +++ b/mods/ao_mod/res/gtao.wgsl @@ -0,0 +1,247 @@ +// Ground Truth-based Ambient Occlusion (GTAO) +// Paper: https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf +// Presentation: https://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf +// +// Ported from Bevy Engine, crates/bevy_pbr/src/ssao/gtao.wgsl (v0.13.2), licensed +// MIT OR Apache-2.0 (see res/licenses/), itself heavily based on XeGTAO v1.30 from Intel (MIT): +// https://github.com/GameTechDev/XeGTAO/blob/0d177ce06bfa642f64d8af4de1197ad1bcb862d4/Source/Rendering/Shaders/XeGTAO.hlsli +// +// PORT: +// - Bevy view/globals bindings -> the mod's own uniform block (matrices from Dusklight's +// CameraService, WebGPU clip convention, reversed-Z - the same convention Bevy uses). +// - Prepass normals -> normals reconstructed from depth (atyuwen's accurate 5-tap method, +// https://atyuwen.github.io/posts/normal-reconstruction/). +// - Sampler-based reads -> textureLoad (r32float is unfilterable without optional features); +// the mip level for the XeGTAO bandwidth optimization is selected explicitly per load. +// - effect_radius and slice/sample counts come from uniforms instead of constants/shader defs +// (game world units are ~100x larger than Bevy's meters, and quality is a live setting). +// - No TEMPORAL_JITTER: the noise index is pinned (no TAA; the spatial denoiser is the only +// filter, a configuration XeGTAO supports). +// - Storage format r16float -> r32float (core WebGPU storage format). + +struct Uniforms { + projection: mat4x4f, + inverse_projection: mat4x4f, + size: vec2f, + inv_size: vec2f, + depth_scale: vec2f, + effect_radius: f32, + intensity: f32, + slice_count: f32, + samples_per_slice_side: f32, + debug_view: u32, + _pad: f32, +} + +@group(0) @binding(0) var preprocessed_depth: texture_2d; +@group(0) @binding(1) var hilbert_index_lut: texture_2d; +@group(0) @binding(2) var ambient_occlusion: texture_storage_2d; +@group(0) @binding(3) var depth_differences: texture_storage_2d; +@group(0) @binding(4) var uniforms: Uniforms; + +const PI: f32 = 3.141592653589793; +const HALF_PI: f32 = 1.5707963267948966; + +fn fast_sqrt(x: f32) -> f32 { + return bitcast(0x1fbd1df5 + (bitcast(x) >> 1u)); +} + +fn fast_acos(in_x: f32) -> f32 { + let x = abs(in_x); + var res = -0.156583 * x + HALF_PI; + res *= fast_sqrt(1.0 - x); + return select(PI - res, res, in_x >= 0.0); +} + +fn load_noise(pixel_coordinates: vec2) -> vec2 { + let index = textureLoad(hilbert_index_lut, pixel_coordinates % 64, 0).r; + // R2 sequence - http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences + return fract(0.5 + f32(index) * vec2(0.75487766624669276005, 0.5698402909980532659114)); +} + +fn load_depth(pixel_coordinates: vec2, mip_level: i32) -> f32 { + let mip_size = max(vec2(uniforms.size) >> vec2(u32(mip_level)), vec2(1i)); + let coordinates = clamp(pixel_coordinates, vec2(0i), mip_size - 1i); + return textureLoad(preprocessed_depth, coordinates, mip_level).r; +} + +// Calculate differences in depth between neighbor pixels (later used by the spatial denoiser pass to preserve object edges) +fn calculate_neighboring_depth_differences(pixel_coordinates: vec2) -> f32 { + // Sample the pixel's depth and 4 depths around it + // PORT: explicit loads instead of two textureGathers. + let depth_center = load_depth(pixel_coordinates, 0i); + let depth_left = load_depth(pixel_coordinates + vec2(-1i, 0i), 0i); + let depth_top = load_depth(pixel_coordinates + vec2(0i, -1i), 0i); + let depth_bottom = load_depth(pixel_coordinates + vec2(0i, 1i), 0i); + let depth_right = load_depth(pixel_coordinates + vec2(1i, 0i), 0i); + + // Calculate the depth differences (large differences represent object edges) + var edge_info = vec4(depth_left, depth_right, depth_top, depth_bottom) - depth_center; + let slope_left_right = (edge_info.y - edge_info.x) * 0.5; + let slope_top_bottom = (edge_info.w - edge_info.z) * 0.5; + let edge_info_slope_adjusted = edge_info + vec4(slope_left_right, -slope_left_right, slope_top_bottom, -slope_top_bottom); + edge_info = min(abs(edge_info), abs(edge_info_slope_adjusted)); + let bias = 0.25; // Using the bias and then saturating nudges the values a bit + let scale = depth_center * 0.011; // Weight the edges by their distance from the camera + edge_info = saturate((1.0 + bias) - edge_info / scale); // Apply the bias and scale, and invert edge_info so that small values become large, and vice versa + + // Pack the edge info into the texture + let edge_info_packed = vec4(pack4x8unorm(edge_info), 0u, 0u, 0u); + textureStore(depth_differences, pixel_coordinates, edge_info_packed); + + return depth_center; +} + +fn reconstruct_view_space_position(depth: f32, uv: vec2) -> vec3 { + let clip_xy = vec2(uv.x * 2.0 - 1.0, 1.0 - 2.0 * uv.y); + let t = uniforms.inverse_projection * vec4(clip_xy, depth, 1.0); + let view_xyz = t.xyz / t.w; + return view_xyz; +} + +fn view_position_at(pixel_coordinates: vec2) -> vec3 { + let depth = load_depth(pixel_coordinates, 0i); + let uv = (vec2(pixel_coordinates) + 0.5) * uniforms.inv_size; + return reconstruct_view_space_position(depth, uv); +} + +// PORT: replaces Bevy's load_normal_view_space (which reads a prepass normal texture we do +// not have). Accurate view-space normal reconstruction from depth, atyuwen's 5-tap method: +// for each axis, extrapolate the center depth from the two taps on each side and derive the +// tangent from whichever side predicts it better. This keeps normals stable across depth +// discontinuities where naive derivatives smear. +fn reconstruct_normal(pixel_coordinates: vec2, pixel_position: vec3, depth_center: f32) -> vec3 { + let depth_left1 = load_depth(pixel_coordinates + vec2(-1i, 0i), 0i); + let depth_left2 = load_depth(pixel_coordinates + vec2(-2i, 0i), 0i); + let depth_right1 = load_depth(pixel_coordinates + vec2(1i, 0i), 0i); + let depth_right2 = load_depth(pixel_coordinates + vec2(2i, 0i), 0i); + let depth_top1 = load_depth(pixel_coordinates + vec2(0i, -1i), 0i); + let depth_top2 = load_depth(pixel_coordinates + vec2(0i, -2i), 0i); + let depth_bottom1 = load_depth(pixel_coordinates + vec2(0i, 1i), 0i); + let depth_bottom2 = load_depth(pixel_coordinates + vec2(0i, 2i), 0i); + + let use_left = abs(2.0 * depth_left1 - depth_left2 - depth_center) < + abs(2.0 * depth_right1 - depth_right2 - depth_center); + let use_top = abs(2.0 * depth_top1 - depth_top2 - depth_center) < + abs(2.0 * depth_bottom1 - depth_bottom2 - depth_center); + + var ddx: vec3; + if use_left { + ddx = pixel_position - view_position_at(pixel_coordinates + vec2(-1i, 0i)); + } else { + ddx = view_position_at(pixel_coordinates + vec2(1i, 0i)) - pixel_position; + } + var ddy: vec3; + if use_top { + ddy = pixel_position - view_position_at(pixel_coordinates + vec2(0i, -1i)); + } else { + ddy = view_position_at(pixel_coordinates + vec2(0i, 1i)) - pixel_position; + } + + var normal = normalize(cross(ddy, ddx)); + // Guard the orientation: the normal must face the camera. + if dot(normal, pixel_position) > 0.0 { + normal = -normal; + } + return normal; +} + +fn load_and_reconstruct_view_space_position(uv: vec2, sample_mip_level: f32) -> vec3 { + // PORT: point-sample the selected mip explicitly instead of textureSampleLevel. + let mip_level = i32(sample_mip_level + 0.5); + let mip_size = max(vec2(uniforms.size) >> vec2(u32(mip_level)), vec2(1i)); + let depth = load_depth(vec2(uv * vec2(mip_size)), mip_level); + return reconstruct_view_space_position(depth, uv); +} + +@compute +@workgroup_size(8, 8, 1) +fn gtao(@builtin(global_invocation_id) global_id: vec3) { + let slice_count = uniforms.slice_count; + let samples_per_slice_side = uniforms.samples_per_slice_side; + let effect_radius = uniforms.effect_radius; + let falloff_range = 0.615 * effect_radius; + let falloff_from = effect_radius * (1.0 - 0.615); + let falloff_mul = -1.0 / falloff_range; + let falloff_add = falloff_from / falloff_range + 1.0; + + let pixel_coordinates = vec2(global_id.xy); + let uv = (vec2(pixel_coordinates) + 0.5) * uniforms.inv_size; + + var pixel_depth = calculate_neighboring_depth_differences(pixel_coordinates); + let raw_depth = pixel_depth; + pixel_depth += 0.00001; // Avoid depth precision issues + + let pixel_position = reconstruct_view_space_position(pixel_depth, uv); + // PORT: the reconstruction differences the center position against neighbor positions + // built from unbiased depths, so its center must use the raw depth too: at this game's + // depth scale (far plane 200000 -> depth ~5e-3) Bevy's +0.00001 bias is comparable to a + // one-pixel depth step, and a biased center corrupts both tangents. + let pixel_normal = reconstruct_normal( + pixel_coordinates, reconstruct_view_space_position(raw_depth, uv), raw_depth); + let view_vec = normalize(-pixel_position); + + let noise = load_noise(pixel_coordinates); + let sample_scale = (-0.5 * effect_radius * uniforms.projection[0][0]) / pixel_position.z; + + var visibility = 0.0; + for (var slice_t = 0.0; slice_t < slice_count; slice_t += 1.0) { + let slice = slice_t + noise.x; + let phi = (PI / slice_count) * slice; + let omega = vec2(cos(phi), sin(phi)); + + let direction = vec3(omega.xy, 0.0); + let orthographic_direction = direction - (dot(direction, view_vec) * view_vec); + let axis = cross(direction, view_vec); + let projected_normal = pixel_normal - axis * dot(pixel_normal, axis); + let projected_normal_length = length(projected_normal); + + let sign_norm = sign(dot(orthographic_direction, projected_normal)); + let cos_norm = saturate(dot(projected_normal, view_vec) / projected_normal_length); + let n = sign_norm * fast_acos(cos_norm); + + let min_cos_horizon_1 = cos(n + HALF_PI); + let min_cos_horizon_2 = cos(n - HALF_PI); + var cos_horizon_1 = min_cos_horizon_1; + var cos_horizon_2 = min_cos_horizon_2; + let sample_mul = vec2(omega.x, -omega.y) * sample_scale; + for (var sample_t = 0.0; sample_t < samples_per_slice_side; sample_t += 1.0) { + var sample_noise = (slice_t + sample_t * samples_per_slice_side) * 0.6180339887498948482; + sample_noise = fract(noise.y + sample_noise); + + var s = (sample_t + sample_noise) / samples_per_slice_side; + s *= s; // https://github.com/GameTechDev/XeGTAO#sample-distribution + let sample = s * sample_mul; + + // * uniforms.size gets us from [0, 1] to [0, viewport_size], which is needed for this to get the correct mip levels + let sample_mip_level = clamp(log2(length(sample * uniforms.size)) - 3.3, 0.0, 4.0); // https://github.com/GameTechDev/XeGTAO#memory-bandwidth-bottleneck + let sample_position_1 = load_and_reconstruct_view_space_position(uv + sample, sample_mip_level); + let sample_position_2 = load_and_reconstruct_view_space_position(uv - sample, sample_mip_level); + + let sample_difference_1 = sample_position_1 - pixel_position; + let sample_difference_2 = sample_position_2 - pixel_position; + let sample_distance_1 = length(sample_difference_1); + let sample_distance_2 = length(sample_difference_2); + var sample_cos_horizon_1 = dot(sample_difference_1 / sample_distance_1, view_vec); + var sample_cos_horizon_2 = dot(sample_difference_2 / sample_distance_2, view_vec); + + let weight_1 = saturate(sample_distance_1 * falloff_mul + falloff_add); + let weight_2 = saturate(sample_distance_2 * falloff_mul + falloff_add); + sample_cos_horizon_1 = mix(min_cos_horizon_1, sample_cos_horizon_1, weight_1); + sample_cos_horizon_2 = mix(min_cos_horizon_2, sample_cos_horizon_2, weight_2); + + cos_horizon_1 = max(cos_horizon_1, sample_cos_horizon_1); + cos_horizon_2 = max(cos_horizon_2, sample_cos_horizon_2); + } + + let horizon_1 = fast_acos(cos_horizon_1); + let horizon_2 = -fast_acos(cos_horizon_2); + let v1 = (cos_norm + 2.0 * horizon_1 * sin(n) - cos(2.0 * horizon_1 - n)) / 4.0; + let v2 = (cos_norm + 2.0 * horizon_2 * sin(n) - cos(2.0 * horizon_2 - n)) / 4.0; + visibility += projected_normal_length * (v1 + v2); + } + visibility /= slice_count; + visibility = clamp(visibility, 0.03, 1.0); + + textureStore(ambient_occlusion, pixel_coordinates, vec4(visibility, 0.0, 0.0, 0.0)); +} diff --git a/mods/ao_mod/res/licenses/BEVY-APACHE-2.0.txt b/mods/ao_mod/res/licenses/BEVY-APACHE-2.0.txt new file mode 100644 index 0000000000..d9a10c0d8e --- /dev/null +++ b/mods/ao_mod/res/licenses/BEVY-APACHE-2.0.txt @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/mods/ao_mod/res/licenses/BEVY-MIT.txt b/mods/ao_mod/res/licenses/BEVY-MIT.txt new file mode 100644 index 0000000000..9cf106272a --- /dev/null +++ b/mods/ao_mod/res/licenses/BEVY-MIT.txt @@ -0,0 +1,19 @@ +MIT License + +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/mods/ao_mod/res/licenses/XEGTAO-MIT.txt b/mods/ao_mod/res/licenses/XEGTAO-MIT.txt new file mode 100644 index 0000000000..2b1bd1561b --- /dev/null +++ b/mods/ao_mod/res/licenses/XEGTAO-MIT.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (C) 2016-2021, Intel Corporation + +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/mods/ao_mod/res/preprocess_depth.wgsl b/mods/ao_mod/res/preprocess_depth.wgsl new file mode 100644 index 0000000000..98fe1d5400 --- /dev/null +++ b/mods/ao_mod/res/preprocess_depth.wgsl @@ -0,0 +1,138 @@ +// Inputs a depth texture and outputs a MIP-chain of depths. +// +// Because SSAO's performance is bound by texture reads, this increases +// performance over using the full resolution depth for every sample. +// +// Reference: https://research.nvidia.com/sites/default/files/pubs/2012-06_Scalable-Ambient-Obscurance/McGuire12SAO.pdf, section 2.2 +// +// Ported from Bevy Engine, crates/bevy_pbr/src/ssao/preprocess_depth.wgsl (v0.13.2), +// licensed MIT OR Apache-2.0 (see res/licenses/), itself derived from Intel XeGTAO (MIT). +// +// PORT: sampler-based gathers replaced with textureLoad (r32float is not filterable without +// optional device features), Bevy view uniforms replaced with the mod's own uniform block, +// storage format r16float -> r32float (core WebGPU storage format). MIP 4 moved into its own +// entry point (core WebGPU limit is 4 storage textures per stage). + +struct Uniforms { + projection: mat4x4f, + inverse_projection: mat4x4f, + size: vec2f, // AO chain size in pixels (MIP 0 of the preprocessed depth) + inv_size: vec2f, + depth_scale: vec2f, // input depth snapshot pixels per chain pixel (1 or 2) + effect_radius: f32, // view-space units + intensity: f32, + slice_count: f32, + samples_per_slice_side: f32, + debug_view: u32, + _pad: f32, +} + +@group(0) @binding(0) var input_depth: texture_2d; +@group(0) @binding(1) var preprocessed_depth_mip0: texture_storage_2d; +@group(0) @binding(2) var preprocessed_depth_mip1: texture_storage_2d; +@group(0) @binding(3) var preprocessed_depth_mip2: texture_storage_2d; +@group(0) @binding(4) var preprocessed_depth_mip3: texture_storage_2d; +@group(0) @binding(5) var uniforms: Uniforms; +// downsample_mip4 entry point only (disjoint subresources of the same texture). +@group(0) @binding(6) var preprocessed_depth_mip3_in: texture_2d; +@group(0) @binding(7) var preprocessed_depth_mip4: texture_storage_2d; + +// PORT: replaces the textureGather of the input depth with explicit loads (also handles the +// half-resolution case, where one chain texel covers depth_scale snapshot texels). +fn load_input_depth(pixel_coordinates: vec2) -> f32 { + let input_size = vec2(uniforms.size * uniforms.depth_scale); + let coordinates = clamp(vec2(vec2(pixel_coordinates) * uniforms.depth_scale), + vec2(0i), input_size - 1i); + return textureLoad(input_depth, coordinates, 0i).r; +} + +// Using 4 depths from the previous MIP, compute a weighted average for the depth of the current MIP +fn weighted_average(depth0: f32, depth1: f32, depth2: f32, depth3: f32) -> f32 { + let depth_range_scale_factor = 0.75; + let effect_radius = depth_range_scale_factor * 0.5 * 1.457; + let falloff_range = 0.615 * effect_radius; + let falloff_from = effect_radius * (1.0 - 0.615); + let falloff_mul = -1.0 / falloff_range; + let falloff_add = falloff_from / falloff_range + 1.0; + + let min_depth = min(min(depth0, depth1), min(depth2, depth3)); + let weight0 = saturate((depth0 - min_depth) * falloff_mul + falloff_add); + let weight1 = saturate((depth1 - min_depth) * falloff_mul + falloff_add); + let weight2 = saturate((depth2 - min_depth) * falloff_mul + falloff_add); + let weight3 = saturate((depth3 - min_depth) * falloff_mul + falloff_add); + let weight_total = weight0 + weight1 + weight2 + weight3; + + return ((weight0 * depth0) + (weight1 * depth1) + (weight2 * depth2) + (weight3 * depth3)) / weight_total; +} + +// Used to share the depths from the previous MIP level between all invocations in a workgroup +var previous_mip_depth: array, 8>; + +@compute +@workgroup_size(8, 8, 1) +fn preprocess_depth(@builtin(global_invocation_id) global_id: vec3, @builtin(local_invocation_id) local_id: vec3) { + let base_coordinates = vec2(global_id.xy); + + // MIP 0 - Copy 4 texels from the input depth (per invocation, 8x8 invocations per workgroup) + let pixel_coordinates0 = base_coordinates * 2i; + let pixel_coordinates1 = pixel_coordinates0 + vec2(1i, 0i); + let pixel_coordinates2 = pixel_coordinates0 + vec2(0i, 1i); + let pixel_coordinates3 = pixel_coordinates0 + vec2(1i, 1i); + let depth0 = load_input_depth(pixel_coordinates0); + let depth1 = load_input_depth(pixel_coordinates1); + let depth2 = load_input_depth(pixel_coordinates2); + let depth3 = load_input_depth(pixel_coordinates3); + textureStore(preprocessed_depth_mip0, pixel_coordinates0, vec4(depth0, 0.0, 0.0, 0.0)); + textureStore(preprocessed_depth_mip0, pixel_coordinates1, vec4(depth1, 0.0, 0.0, 0.0)); + textureStore(preprocessed_depth_mip0, pixel_coordinates2, vec4(depth2, 0.0, 0.0, 0.0)); + textureStore(preprocessed_depth_mip0, pixel_coordinates3, vec4(depth3, 0.0, 0.0, 0.0)); + + // MIP 1 - Weighted average of MIP 0's depth values (per invocation, 8x8 invocations per workgroup) + let depth_mip1 = weighted_average(depth0, depth1, depth2, depth3); + textureStore(preprocessed_depth_mip1, base_coordinates, vec4(depth_mip1, 0.0, 0.0, 0.0)); + previous_mip_depth[local_id.x][local_id.y] = depth_mip1; + + workgroupBarrier(); + + // MIP 2 - Weighted average of MIP 1's depth values (per invocation, 4x4 invocations per workgroup) + if all(local_id.xy % vec2(2u) == vec2(0u)) { + let mip2_depth0 = previous_mip_depth[local_id.x + 0u][local_id.y + 0u]; + let mip2_depth1 = previous_mip_depth[local_id.x + 1u][local_id.y + 0u]; + let mip2_depth2 = previous_mip_depth[local_id.x + 0u][local_id.y + 1u]; + let mip2_depth3 = previous_mip_depth[local_id.x + 1u][local_id.y + 1u]; + let depth_mip2 = weighted_average(mip2_depth0, mip2_depth1, mip2_depth2, mip2_depth3); + textureStore(preprocessed_depth_mip2, base_coordinates / 2i, vec4(depth_mip2, 0.0, 0.0, 0.0)); + previous_mip_depth[local_id.x][local_id.y] = depth_mip2; + } + + workgroupBarrier(); + + // MIP 3 - Weighted average of MIP 2's depth values (per invocation, 2x2 invocations per workgroup) + if all(local_id.xy % vec2(4u) == vec2(0u)) { + let mip3_depth0 = previous_mip_depth[local_id.x + 0u][local_id.y + 0u]; + let mip3_depth1 = previous_mip_depth[local_id.x + 2u][local_id.y + 0u]; + let mip3_depth2 = previous_mip_depth[local_id.x + 0u][local_id.y + 2u]; + let mip3_depth3 = previous_mip_depth[local_id.x + 2u][local_id.y + 2u]; + let depth_mip3 = weighted_average(mip3_depth0, mip3_depth1, mip3_depth2, mip3_depth3); + textureStore(preprocessed_depth_mip3, base_coordinates / 4i, vec4(depth_mip3, 0.0, 0.0, 0.0)); + previous_mip_depth[local_id.x][local_id.y] = depth_mip3; + } +} + +// MIP 4: weighted average of MIP 3's depth values, as a second (tiny) dispatch. +@compute +@workgroup_size(8, 8, 1) +fn downsample_mip4(@builtin(global_invocation_id) global_id: vec3) { + let base_coordinates = vec2(global_id.xy); + let mip3_size = max(vec2(textureDimensions(preprocessed_depth_mip3_in)), vec2(1i)); + let coordinates0 = clamp(base_coordinates * 2i, vec2(0i), mip3_size - 1i); + let coordinates1 = clamp(base_coordinates * 2i + vec2(1i, 0i), vec2(0i), mip3_size - 1i); + let coordinates2 = clamp(base_coordinates * 2i + vec2(0i, 1i), vec2(0i), mip3_size - 1i); + let coordinates3 = clamp(base_coordinates * 2i + vec2(1i, 1i), vec2(0i), mip3_size - 1i); + let depth0 = textureLoad(preprocessed_depth_mip3_in, coordinates0, 0i).r; + let depth1 = textureLoad(preprocessed_depth_mip3_in, coordinates1, 0i).r; + let depth2 = textureLoad(preprocessed_depth_mip3_in, coordinates2, 0i).r; + let depth3 = textureLoad(preprocessed_depth_mip3_in, coordinates3, 0i).r; + let depth_mip4 = weighted_average(depth0, depth1, depth2, depth3); + textureStore(preprocessed_depth_mip4, base_coordinates, vec4(depth_mip4, 0.0, 0.0, 0.0)); +} diff --git a/mods/ao_mod/src/mod.cpp b/mods/ao_mod/src/mod.cpp new file mode 100644 index 0000000000..8a96ae3c95 --- /dev/null +++ b/mods/ao_mod/src/mod.cpp @@ -0,0 +1,933 @@ +// Ambient occlusion (GTAO) example mod. +// +// Showcases the gfx service's compute tasks and the camera service: after opaque scene draws, +// before translucent/fog overlays, the scene depth is resolved and a three-dispatch compute +// chain (depth MIP prefilter, GTAO, spatial denoise) produces a visibility texture that a +// fullscreen draw multiplies over the world. +// +// The WGSL in res/ is ported from Bevy Engine's SSAO implementation (MIT OR Apache-2.0), +// itself based on Intel XeGTAO (MIT); see res/licenses/ and the `PORT:` notes in the shaders. + +#include "mods/service.hpp" +#include "mods/svc/camera.h" +#include "mods/svc/config.h" +#include "mods/svc/gfx.h" +#include "mods/svc/log.h" +#include "mods/svc/resource.h" +#include "mods/svc/ui.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(ConfigService, svc_config); +IMPORT_SERVICE(ResourceService, svc_resource); +IMPORT_SERVICE(UiService, svc_ui); +IMPORT_SERVICE(GfxService, svc_gfx); +IMPORT_SERVICE(CameraService, svc_camera); + +namespace { + +ConfigVarHandle g_cvarEnabled = 0; +ConfigVarHandle g_cvarQuality = 0; +ConfigVarHandle g_cvarRadius = 0; +ConfigVarHandle g_cvarIntensity = 0; +ConfigVarHandle g_cvarHalfRes = 0; +ConfigVarHandle g_cvarDebugView = 0; + +GfxComputeTypeHandle g_computeType = 0; +GfxDrawTypeHandle g_drawType = 0; +GfxStageHookHandle g_afterOpaqueHook = 0; +UiWindowHandle g_controlsWindow = 0; + +ResourceBuffer g_preprocessSource = RESOURCE_BUFFER_INIT; +ResourceBuffer g_gtaoSource = RESOURCE_BUFFER_INIT; +ResourceBuffer g_denoiseSource = RESOURCE_BUFFER_INIT; +ResourceBuffer g_compositeSource = RESOURCE_BUFFER_INIT; + +GfxDeviceInfo g_deviceInfo = GFX_DEVICE_INFO_INIT; +GfxRenderTargetLayout g_sceneTargetLayout = GFX_RENDER_TARGET_LAYOUT_INIT; +WGPUComputePipeline g_preprocessPipeline = nullptr; +WGPUComputePipeline g_mip4Pipeline = nullptr; +WGPUComputePipeline g_gtaoPipeline = nullptr; +WGPUComputePipeline g_denoisePipeline = nullptr; +WGPUBindGroupLayout g_preprocessLayout = nullptr; +WGPUBindGroupLayout g_mip4Layout = nullptr; +WGPUBindGroupLayout g_gtaoLayout = nullptr; +WGPUBindGroupLayout g_denoiseLayout = nullptr; +WGPURenderPipeline g_compositePipeline = nullptr; +WGPURenderPipeline g_compositeDebugPipeline = nullptr; +WGPUBindGroupLayout g_compositeLayout = nullptr; +WGPUBindGroupLayout g_compositeDebugLayout = nullptr; +WGPUTexture g_hilbertLut = nullptr; +WGPUTextureView g_hilbertLutView = nullptr; + +// AO chain targets, recreated when the render size (or halfRes) changes. Old sets are retired +// for a few frames instead of released immediately: payloads embedding their views may still +// be in flight on the render worker. +struct AoTargets { + uint32_t width = 0; + uint32_t height = 0; + WGPUTexture preprocessedDepth = nullptr; + WGPUTextureView preprocessedDepthMips[5] = {}; + WGPUTextureView preprocessedDepthAll = nullptr; + WGPUTexture aoNoisy = nullptr; + WGPUTextureView aoNoisyView = nullptr; + WGPUTexture depthDifferences = nullptr; + WGPUTextureView depthDifferencesView = nullptr; + WGPUTexture aoFinal = nullptr; + WGPUTextureView aoFinalView = nullptr; +}; +AoTargets g_targets; +struct RetiredTargets { + AoTargets targets; + int framesLeft = 0; +}; +std::vector g_retiredTargets; + +bool g_warnedNoDepth = false; +bool g_loggedChain = false; +std::atomic g_chainExecuted{false}; + +// Mirror of the WGSL Uniforms struct (keep in sync with res/*.wgsl). +struct AoUniforms { + float projection[16]; + float inverse_projection[16]; + float size[2]; + float inv_size[2]; + float depth_scale[2]; + float effect_radius; + float intensity; + float slice_count; + float samples_per_slice_side; + uint32_t debug_view; + float _pad; +}; +static_assert(sizeof(AoUniforms) % 16 == 0); + +struct ComputePayload { + WGPUTextureView depth; // frame-pooled scene depth snapshot + WGPUTextureView preprocessedDepthMips[5]; + WGPUTextureView preprocessedDepthAll; + WGPUTextureView aoNoisy; + WGPUTextureView depthDifferences; + WGPUTextureView aoFinal; + uint32_t uniform_offset; + uint32_t uniform_size; + uint32_t width; + uint32_t height; +}; +static_assert(sizeof(ComputePayload) <= GFX_INLINE_DRAW_PAYLOAD_SIZE); +static_assert(std::is_trivially_copyable_v); + +struct CompositePayload { + WGPUTextureView aoFinal; + WGPUTextureView preprocessedDepth; // debug views reconstruct normals/depth from it + WGPUTextureView sceneDepth; // raw snapshot, for the bypass debug views + uint32_t uniform_offset; + uint32_t uniform_size; + uint32_t debug_view; +}; +static_assert(sizeof(CompositePayload) <= GFX_INLINE_DRAW_PAYLOAD_SIZE); +static_assert(std::is_trivially_copyable_v); + +int64_t get_int_option(ConfigVarHandle handle, int64_t fallback) { + int64_t value = fallback; + if (handle == 0 || svc_config->get_int(mod_ctx, handle, &value) != MOD_OK) { + return fallback; + } + return value; +} + +bool get_bool_option(ConfigVarHandle handle, bool fallback) { + bool value = fallback; + if (handle == 0 || svc_config->get_bool(mod_ctx, handle, &value) != MOD_OK) { + return fallback; + } + return value; +} + +// XeGTAO/Bevy quality presets: slices x (samples per slice side * 2). +void quality_counts(int64_t quality, float& sliceCount, float& samplesPerSliceSide) { + switch (std::clamp(quality, 0, 3)) { + case 0: + sliceCount = 1.0f; + samplesPerSliceSide = 2.0f; + break; + case 1: + sliceCount = 2.0f; + samplesPerSliceSide = 2.0f; + break; + default: + case 2: + sliceCount = 3.0f; + samplesPerSliceSide = 3.0f; + break; + case 3: + sliceCount = 9.0f; + samplesPerSliceSide = 3.0f; + break; + } +} + +WGPUShaderModule create_shader_module(const char* label, const ResourceBuffer& source) { + WGPUShaderSourceWGSL wgsl = WGPU_SHADER_SOURCE_WGSL_INIT; + wgsl.code = {static_cast(source.data), source.size}; + WGPUShaderModuleDescriptor moduleDesc = WGPU_SHADER_MODULE_DESCRIPTOR_INIT; + moduleDesc.nextInChain = &wgsl.chain; + moduleDesc.label = {label, WGPU_STRLEN}; + return wgpuDeviceCreateShaderModule(g_deviceInfo.device, &moduleDesc); +} + +bool build_compute_pipeline(const char* label, const ResourceBuffer& source, const char* entry, + WGPUComputePipeline& outPipeline, WGPUBindGroupLayout& outLayout) { + WGPUShaderModule module = create_shader_module(label, source); + if (module == nullptr) { + return false; + } + WGPUComputePipelineDescriptor pipelineDesc = WGPU_COMPUTE_PIPELINE_DESCRIPTOR_INIT; + pipelineDesc.label = {label, WGPU_STRLEN}; + pipelineDesc.compute.module = module; + pipelineDesc.compute.entryPoint = {entry, WGPU_STRLEN}; + outPipeline = wgpuDeviceCreateComputePipeline(g_deviceInfo.device, &pipelineDesc); + wgpuShaderModuleRelease(module); + if (outPipeline == nullptr) { + return false; + } + outLayout = wgpuComputePipelineGetBindGroupLayout(outPipeline, 0); + return outLayout != nullptr; +} + +bool build_composite_pipeline( + bool blend, WGPURenderPipeline& outPipeline, WGPUBindGroupLayout& outLayout) { + WGPUShaderModule module = create_shader_module("AO composite", g_compositeSource); + if (module == nullptr) { + return false; + } + + // Multiply blend + WGPUBlendState blendState{ + .color = + { + .operation = WGPUBlendOperation_Add, + .srcFactor = WGPUBlendFactor_Dst, + .dstFactor = WGPUBlendFactor_Zero, + }, + .alpha = + { + .operation = WGPUBlendOperation_Add, + .srcFactor = WGPUBlendFactor_Zero, + .dstFactor = WGPUBlendFactor_One, + }, + }; + WGPUColorTargetState colorTargets[GFX_MAX_COLOR_ATTACHMENTS]; + const uint32_t colorTargetCount = gfx_init_color_target_states( + &g_sceneTargetLayout, colorTargets, blend ? &blendState : nullptr, WGPUColorWriteMask_All); + WGPUFragmentState fragment = WGPU_FRAGMENT_STATE_INIT; + fragment.module = module; + fragment.entryPoint = {"fs_main", WGPU_STRLEN}; + fragment.targetCount = colorTargetCount; + fragment.targets = colorTargets; + // Depth state must match the EFB pass despite never touching depth. + WGPUDepthStencilState depthStencil = WGPU_DEPTH_STENCIL_STATE_INIT; + depthStencil.format = g_sceneTargetLayout.depth_stencil_format; + depthStencil.depthWriteEnabled = WGPUOptionalBool_False; + depthStencil.depthCompare = WGPUCompareFunction_Always; + + WGPURenderPipelineDescriptor pipelineDesc = WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT; + pipelineDesc.label = {blend ? "AO composite" : "AO composite (debug)", WGPU_STRLEN}; + pipelineDesc.vertex.module = module; + pipelineDesc.vertex.entryPoint = {"vs_main", WGPU_STRLEN}; + pipelineDesc.primitive.topology = WGPUPrimitiveTopology_TriangleList; + pipelineDesc.depthStencil = &depthStencil; + pipelineDesc.multisample.count = g_sceneTargetLayout.sample_count; + pipelineDesc.fragment = &fragment; + outPipeline = wgpuDeviceCreateRenderPipeline(g_deviceInfo.device, &pipelineDesc); + wgpuShaderModuleRelease(module); + if (outPipeline == nullptr) { + return false; + } + outLayout = wgpuRenderPipelineGetBindGroupLayout(outPipeline, 0); + return outLayout != nullptr; +} + +// Hilbert curve index LUT for the R2 noise sequence, generated once at init. +// Ported from Bevy's generate_hilbert_index_lut (https://www.shadertoy.com/view/3tB3z3). +uint16_t hilbert_index(uint16_t x, uint16_t y) { + uint16_t index = 0; + for (uint16_t level = 32; level > 0; level /= 2) { + const uint16_t regionX = (x & level) > 0 ? 1 : 0; + const uint16_t regionY = (y & level) > 0 ? 1 : 0; + index += level * level * ((3 * regionX) ^ regionY); + if (regionY == 0) { + if (regionX == 1) { + x = 63 - x; + y = 63 - y; + } + std::swap(x, y); + } + } + return index; +} + +bool build_hilbert_lut() { + WGPUTextureDescriptor texDesc = WGPU_TEXTURE_DESCRIPTOR_INIT; + texDesc.label = {"AO hilbert LUT", WGPU_STRLEN}; + texDesc.usage = WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst; + texDesc.size = {64, 64, 1}; + texDesc.format = WGPUTextureFormat_R16Uint; + g_hilbertLut = wgpuDeviceCreateTexture(g_deviceInfo.device, &texDesc); + if (g_hilbertLut == nullptr) { + return false; + } + g_hilbertLutView = wgpuTextureCreateView(g_hilbertLut, nullptr); + if (g_hilbertLutView == nullptr) { + return false; + } + + uint16_t lut[64 * 64]; + for (uint16_t y = 0; y < 64; ++y) { + for (uint16_t x = 0; x < 64; ++x) { + lut[y * 64 + x] = hilbert_index(x, y); + } + } + WGPUTexelCopyTextureInfo dst = WGPU_TEXEL_COPY_TEXTURE_INFO_INIT; + dst.texture = g_hilbertLut; + WGPUTexelCopyBufferLayout layout{.offset = 0, .bytesPerRow = 64 * 2, .rowsPerImage = 64}; + WGPUExtent3D extent{64, 64, 1}; + wgpuQueueWriteTexture(g_deviceInfo.queue, &dst, lut, sizeof(lut), &layout, &extent); + return true; +} + +void release_targets(AoTargets& targets) { + for (auto*& view : targets.preprocessedDepthMips) { + if (view != nullptr) { + wgpuTextureViewRelease(view); + view = nullptr; + } + } + const auto releaseView = [](WGPUTextureView& view) { + if (view != nullptr) { + wgpuTextureViewRelease(view); + view = nullptr; + } + }; + const auto releaseTexture = [](WGPUTexture& texture) { + if (texture != nullptr) { + wgpuTextureRelease(texture); + texture = nullptr; + } + }; + releaseView(targets.preprocessedDepthAll); + releaseView(targets.aoNoisyView); + releaseView(targets.depthDifferencesView); + releaseView(targets.aoFinalView); + releaseTexture(targets.preprocessedDepth); + releaseTexture(targets.aoNoisy); + releaseTexture(targets.depthDifferences); + releaseTexture(targets.aoFinal); + targets.width = targets.height = 0; +} + +void tick_retired_targets() { + for (auto it = g_retiredTargets.begin(); it != g_retiredTargets.end();) { + if (--it->framesLeft <= 0) { + release_targets(it->targets); + it = g_retiredTargets.erase(it); + } else { + ++it; + } + } +} + +bool ensure_targets(uint32_t width, uint32_t height) { + if (g_targets.width == width && g_targets.height == height) { + return true; + } + if (g_targets.width != 0) { + g_retiredTargets.push_back(RetiredTargets{std::exchange(g_targets, AoTargets{}), 4}); + } + + const auto createStorageTexture = [&](const char* label, WGPUTextureFormat format, + uint32_t mipCount, WGPUTexture& outTexture) { + WGPUTextureDescriptor texDesc = WGPU_TEXTURE_DESCRIPTOR_INIT; + texDesc.label = {label, WGPU_STRLEN}; + texDesc.usage = WGPUTextureUsage_StorageBinding | WGPUTextureUsage_TextureBinding; + texDesc.size = {width, height, 1}; + texDesc.format = format; + texDesc.mipLevelCount = mipCount; + outTexture = wgpuDeviceCreateTexture(g_deviceInfo.device, &texDesc); + return outTexture != nullptr; + }; + + bool ok = createStorageTexture("AO preprocessed depth", WGPUTextureFormat_R32Float, 5, + g_targets.preprocessedDepth) && + createStorageTexture("AO noisy", WGPUTextureFormat_R32Float, 1, g_targets.aoNoisy) && + createStorageTexture("AO depth differences", WGPUTextureFormat_R32Uint, 1, + g_targets.depthDifferences) && + createStorageTexture("AO final", WGPUTextureFormat_R32Float, 1, g_targets.aoFinal); + if (ok) { + for (uint32_t mip = 0; mip < 5 && ok; ++mip) { + WGPUTextureViewDescriptor viewDesc = WGPU_TEXTURE_VIEW_DESCRIPTOR_INIT; + viewDesc.baseMipLevel = mip; + viewDesc.mipLevelCount = 1; + g_targets.preprocessedDepthMips[mip] = + wgpuTextureCreateView(g_targets.preprocessedDepth, &viewDesc); + ok = g_targets.preprocessedDepthMips[mip] != nullptr; + } + } + if (ok) { + g_targets.preprocessedDepthAll = + wgpuTextureCreateView(g_targets.preprocessedDepth, nullptr); + g_targets.aoNoisyView = wgpuTextureCreateView(g_targets.aoNoisy, nullptr); + g_targets.depthDifferencesView = wgpuTextureCreateView(g_targets.depthDifferences, nullptr); + g_targets.aoFinalView = wgpuTextureCreateView(g_targets.aoFinal, nullptr); + ok = g_targets.preprocessedDepthAll != nullptr && g_targets.aoNoisyView != nullptr && + g_targets.depthDifferencesView != nullptr && g_targets.aoFinalView != nullptr; + } + if (!ok) { + release_targets(g_targets); + return false; + } + g_targets.width = width; + g_targets.height = height; + return true; +} + +constexpr uint32_t div_ceil(uint32_t numerator, uint32_t denominator) { + return (numerator + denominator - 1) / denominator; +} + +// Render worker thread: the AO chain as one compute pass with three dispatches. +void on_compute( + ModContext*, const GfxComputeContext* ctx, const void* payload, size_t payloadSize, void*) { + if (payloadSize != sizeof(ComputePayload)) { + return; + } + ComputePayload data; + std::memcpy(&data, payload, sizeof(data)); + if (data.depth == nullptr || g_preprocessPipeline == nullptr) { + return; + } + + const auto makeBindGroup = [&](WGPUBindGroupLayout layout, + std::initializer_list entries) { + WGPUBindGroupDescriptor bindGroupDesc = WGPU_BIND_GROUP_DESCRIPTOR_INIT; + bindGroupDesc.layout = layout; + bindGroupDesc.entryCount = entries.size(); + bindGroupDesc.entries = entries.begin(); + return wgpuDeviceCreateBindGroup(ctx->device, &bindGroupDesc); + }; + const auto textureEntry = [](uint32_t binding, WGPUTextureView view) { + WGPUBindGroupEntry entry = WGPU_BIND_GROUP_ENTRY_INIT; + entry.binding = binding; + entry.textureView = view; + return entry; + }; + const auto uniformEntry = [&](uint32_t binding) { + WGPUBindGroupEntry entry = WGPU_BIND_GROUP_ENTRY_INIT; + entry.binding = binding; + entry.buffer = ctx->uniform_buffer; + entry.offset = data.uniform_offset; + entry.size = data.uniform_size; + return entry; + }; + + WGPUBindGroup preprocessGroup = makeBindGroup(g_preprocessLayout, + {textureEntry(0, data.depth), textureEntry(1, data.preprocessedDepthMips[0]), + textureEntry(2, data.preprocessedDepthMips[1]), + textureEntry(3, data.preprocessedDepthMips[2]), + textureEntry(4, data.preprocessedDepthMips[3]), uniformEntry(5)}); + WGPUBindGroup mip4Group = + makeBindGroup(g_mip4Layout, {textureEntry(6, data.preprocessedDepthMips[3]), + textureEntry(7, data.preprocessedDepthMips[4])}); + WGPUBindGroup gtaoGroup = makeBindGroup( + g_gtaoLayout, {textureEntry(0, data.preprocessedDepthAll), + textureEntry(1, g_hilbertLutView), textureEntry(2, data.aoNoisy), + textureEntry(3, data.depthDifferences), uniformEntry(4)}); + WGPUBindGroup denoiseGroup = makeBindGroup( + g_denoiseLayout, {textureEntry(0, data.aoNoisy), textureEntry(1, data.depthDifferences), + textureEntry(2, data.aoFinal), uniformEntry(3)}); + if (preprocessGroup == nullptr || mip4Group == nullptr || gtaoGroup == nullptr || + denoiseGroup == nullptr) + { + const auto release = [](WGPUBindGroup group) { + if (group != nullptr) { + wgpuBindGroupRelease(group); + } + }; + release(preprocessGroup); + release(mip4Group); + release(gtaoGroup); + release(denoiseGroup); + return; + } + + WGPUComputePassDescriptor passDesc = WGPU_COMPUTE_PASS_DESCRIPTOR_INIT; + passDesc.label = {"AO chain", WGPU_STRLEN}; + WGPUComputePassEncoder pass = wgpuCommandEncoderBeginComputePass(ctx->encoder, &passDesc); + // Each preprocess workgroup covers 16x16 MIP-0 texels (8x8 invocations, 2x2 texels each). + wgpuComputePassEncoderSetPipeline(pass, g_preprocessPipeline); + wgpuComputePassEncoderSetBindGroup(pass, 0, preprocessGroup, 0, nullptr); + wgpuComputePassEncoderDispatchWorkgroups( + pass, div_ceil(data.width, 16), div_ceil(data.height, 16), 1); + wgpuComputePassEncoderSetPipeline(pass, g_mip4Pipeline); + wgpuComputePassEncoderSetBindGroup(pass, 0, mip4Group, 0, nullptr); + wgpuComputePassEncoderDispatchWorkgroups(pass, div_ceil(std::max(data.width >> 4, 1u), 8), + div_ceil(std::max(data.height >> 4, 1u), 8), 1); + wgpuComputePassEncoderSetPipeline(pass, g_gtaoPipeline); + wgpuComputePassEncoderSetBindGroup(pass, 0, gtaoGroup, 0, nullptr); + wgpuComputePassEncoderDispatchWorkgroups( + pass, div_ceil(data.width, 8), div_ceil(data.height, 8), 1); + wgpuComputePassEncoderSetPipeline(pass, g_denoisePipeline); + wgpuComputePassEncoderSetBindGroup(pass, 0, denoiseGroup, 0, nullptr); + wgpuComputePassEncoderDispatchWorkgroups( + pass, div_ceil(data.width, 8), div_ceil(data.height, 8), 1); + wgpuComputePassEncoderEnd(pass); + wgpuComputePassEncoderRelease(pass); + + wgpuBindGroupRelease(preprocessGroup); + wgpuBindGroupRelease(mip4Group); + wgpuBindGroupRelease(gtaoGroup); + wgpuBindGroupRelease(denoiseGroup); + g_chainExecuted.store(true, std::memory_order_release); +} + +// Render worker thread: composite the AO over the scene (or show it, in debug view). +void on_draw( + ModContext*, const GfxDrawContext* ctx, const void* payload, size_t payloadSize, void*) { + if (payloadSize != sizeof(CompositePayload) || ctx->layout.key != g_sceneTargetLayout.key) { + return; + } + CompositePayload data; + std::memcpy(&data, payload, sizeof(data)); + WGPURenderPipeline pipeline = + data.debug_view != 0 ? g_compositeDebugPipeline : g_compositePipeline; + WGPUBindGroupLayout layout = data.debug_view != 0 ? g_compositeDebugLayout : g_compositeLayout; + if (data.aoFinal == nullptr || data.preprocessedDepth == nullptr || + data.sceneDepth == nullptr || pipeline == nullptr) + { + return; + } + + WGPUBindGroupEntry entries[4] = {WGPU_BIND_GROUP_ENTRY_INIT, WGPU_BIND_GROUP_ENTRY_INIT, + WGPU_BIND_GROUP_ENTRY_INIT, WGPU_BIND_GROUP_ENTRY_INIT}; + entries[0].binding = 0; + entries[0].textureView = data.aoFinal; + entries[1].binding = 1; + entries[1].textureView = data.preprocessedDepth; + entries[2].binding = 2; + entries[2].textureView = data.sceneDepth; + entries[3].binding = 3; + entries[3].buffer = ctx->uniform_buffer; + entries[3].offset = data.uniform_offset; + entries[3].size = data.uniform_size; + WGPUBindGroupDescriptor bindGroupDesc = WGPU_BIND_GROUP_DESCRIPTOR_INIT; + bindGroupDesc.layout = layout; + bindGroupDesc.entryCount = 4; + bindGroupDesc.entries = entries; + WGPUBindGroup bindGroup = wgpuDeviceCreateBindGroup(ctx->device, &bindGroupDesc); + if (bindGroup == nullptr) { + return; + } + + wgpuRenderPassEncoderSetPipeline(ctx->pass, pipeline); + wgpuRenderPassEncoderSetBindGroup(ctx->pass, 0, bindGroup, 0, nullptr); + wgpuRenderPassEncoderDraw(ctx->pass, 3, 1, 0, 0); + wgpuBindGroupRelease(bindGroup); +} + +// Game thread, after opaque scene draws and before translucent/fog overlay lists. +void on_scene_after_opaque(ModContext*, const GfxStageContext* stageCtx, void*) { + tick_retired_targets(); + if (!get_bool_option(g_cvarEnabled, true)) { + return; + } + if (stageCtx == nullptr || stageCtx->struct_size < sizeof(GfxStageContext) || + stageCtx->game_view == nullptr) + { + return; + } + + CameraInfo camera = CAMERA_INFO_INIT; + if (svc_camera->get_camera(mod_ctx, stageCtx->game_view, &camera) != MOD_OK) { + return; + } + + GfxResolveDesc resolveDesc = GFX_RESOLVE_DESC_INIT; + resolveDesc.color = false; + resolveDesc.depth = true; + GfxResolvedTargets resolved = GFX_RESOLVED_TARGETS_INIT; + if (svc_gfx->resolve_pass(mod_ctx, &resolveDesc, &resolved) != MOD_OK || + resolved.depth == nullptr) + { + if (!g_warnedNoDepth) { + g_warnedNoDepth = true; + svc_log->warn(mod_ctx, "depth snapshots unavailable; AO disabled"); + } + return; + } + + const bool halfRes = get_bool_option(g_cvarHalfRes, false); + const uint32_t divisor = halfRes ? 2 : 1; + const uint32_t width = resolved.width / divisor; + const uint32_t height = resolved.height / divisor; + if (width < 32 || height < 32 || !ensure_targets(width, height)) { + return; + } + + AoUniforms uniforms{}; + std::memcpy(uniforms.projection, camera.proj_from_view, sizeof(uniforms.projection)); + std::memcpy( + uniforms.inverse_projection, camera.view_from_proj, sizeof(uniforms.inverse_projection)); + uniforms.size[0] = static_cast(width); + uniforms.size[1] = static_cast(height); + uniforms.inv_size[0] = 1.0f / uniforms.size[0]; + uniforms.inv_size[1] = 1.0f / uniforms.size[1]; + uniforms.depth_scale[0] = static_cast(resolved.width) / uniforms.size[0]; + uniforms.depth_scale[1] = static_cast(resolved.height) / uniforms.size[1]; + uniforms.effect_radius = + static_cast(std::clamp(get_int_option(g_cvarRadius, 70), 10, 500)); + uniforms.intensity = + static_cast(std::clamp(get_int_option(g_cvarIntensity, 100), 0, 100)) / + 100.0f; + quality_counts( + get_int_option(g_cvarQuality, 2), uniforms.slice_count, uniforms.samples_per_slice_side); + const uint32_t debugMode = + static_cast(std::clamp(get_int_option(g_cvarDebugView, 0), 0, 4)); + uniforms.debug_view = debugMode; + + GfxRange uniformRange{0, 0}; + if (svc_gfx->push_uniform(mod_ctx, &uniforms, sizeof(uniforms), &uniformRange) != MOD_OK) { + return; + } + + ComputePayload computePayload{}; + computePayload.depth = resolved.depth; + for (int mip = 0; mip < 5; ++mip) { + computePayload.preprocessedDepthMips[mip] = g_targets.preprocessedDepthMips[mip]; + } + computePayload.preprocessedDepthAll = g_targets.preprocessedDepthAll; + computePayload.aoNoisy = g_targets.aoNoisyView; + computePayload.depthDifferences = g_targets.depthDifferencesView; + computePayload.aoFinal = g_targets.aoFinalView; + computePayload.uniform_offset = uniformRange.offset; + computePayload.uniform_size = uniformRange.size; + computePayload.width = width; + computePayload.height = height; + if (svc_gfx->push_compute(mod_ctx, g_computeType, &computePayload, sizeof(computePayload)) != + MOD_OK) + { + return; + } + + const CompositePayload drawPayload{g_targets.aoFinalView, g_targets.preprocessedDepthAll, + resolved.depth, uniformRange.offset, uniformRange.size, debugMode}; + svc_gfx->push_draw(mod_ctx, g_drawType, &drawPayload, sizeof(drawPayload)); +} + +void add_control(UiElementHandle pane, const UiControlDesc& desc) { + svc_ui->pane_add_control(mod_ctx, pane, &desc, nullptr); +} + +void add_toggle(UiElementHandle pane, const char* label, ConfigVarHandle cvar, const char* help) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_TOGGLE; + control.label = label; + control.help_rml = help; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = cvar; + add_control(pane, control); +} + +ModResult build_controls_tab( + ModContext*, UiWindowHandle, UiElementHandle left, UiElementHandle right, void*, ModError*) { + (void)right; + + svc_ui->pane_add_section(mod_ctx, left, "Ambient Occlusion"); + add_toggle(left, "Enabled", g_cvarEnabled, "Enables the GTAO pass."); + + static const char* kQualityOptions[] = {"Low", "Medium", "High", "Ultra"}; + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_SELECT; + control.label = "Quality"; + control.help_rml = "Horizon slices and samples per pixel (XeGTAO presets: 4/8/18/54 spp)."; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarQuality; + control.options = kQualityOptions; + control.option_count = 4; + add_control(left, control); + + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_NUMBER; + control.label = "Radius"; + control.help_rml = "Occlusion sampling radius in world units."; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarRadius; + control.min = 10; + control.max = 500; + control.step = 10; + add_control(left, control); + + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_NUMBER; + control.label = "Intensity"; + control.help_rml = "How strongly occlusion darkens the scene."; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarIntensity; + control.min = 0; + control.max = 100; + control.step = 5; + control.suffix = "%"; + add_control(left, control); + + add_toggle(left, "Half Resolution", g_cvarHalfRes, + "Computes AO at half resolution and upscales; faster, slightly softer."); + + static const char* kDebugOptions[] = {"Off", "AO", "Normals", "Depth", "Staircase"}; + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_SELECT; + control.label = "Debug View"; + control.help_rml = "AO: raw visibility as grayscale.
Normals: the view-space " + "normals the GTAO pass consumes.
Depth: the preprocessed depth " + "as a distance gradient.
Staircase: detects quantized depth - smooth " + "depth is near-black with thin triangle edges, quantized depth lights " + "up across surfaces."; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarDebugView; + control.options = kDebugOptions; + control.option_count = 5; + add_control(left, control); + return MOD_OK; +} + +void on_controls_window_closed(ModContext*, UiWindowHandle, void*) { + g_controlsWindow = 0; +} + +void on_open_controls(ModContext*, void*) { + if (g_controlsWindow != 0) { + return; + } + UiTabDesc tabs[1] = {UI_TAB_DESC_INIT}; + tabs[0].title = "Controls"; + tabs[0].build = build_controls_tab; + UiWindowDesc desc = UI_WINDOW_DESC_INIT; + desc.tabs = tabs; + desc.tab_count = 1; + desc.on_closed = on_controls_window_closed; + if (svc_ui->window_push(mod_ctx, &desc, &g_controlsWindow) != MOD_OK) { + svc_log->error(mod_ctx, "failed to open AO controls window"); + } +} + +ModResult build_panel(ModContext*, UiElementHandle panel, void*, ModError*) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_TOGGLE; + control.label = "Enabled"; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarEnabled; + add_control(panel, control); + + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_BUTTON; + control.label = "Open Controls"; + control.on_pressed = on_open_controls; + add_control(panel, control); + return MOD_OK; +} + +ModResult register_bool_option( + const char* name, bool defaultValue, ConfigVarHandle& outHandle, ModError* error) { + ConfigVarDesc cvarDesc = CONFIG_VAR_DESC_INIT; + cvarDesc.name = name; + cvarDesc.type = CONFIG_VAR_BOOL; + cvarDesc.default_bool = defaultValue; + if (svc_config->register_var(mod_ctx, &cvarDesc, &outHandle) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register AO option"); + } + return MOD_OK; +} + +ModResult register_int_option( + const char* name, int64_t defaultValue, ConfigVarHandle& outHandle, ModError* error) { + ConfigVarDesc cvarDesc = CONFIG_VAR_DESC_INIT; + cvarDesc.name = name; + cvarDesc.type = CONFIG_VAR_INT; + cvarDesc.default_int = defaultValue; + if (svc_config->register_var(mod_ctx, &cvarDesc, &outHandle) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register AO option"); + } + return MOD_OK; +} + +} // namespace + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError* error) { + ModResult result = svc_resource->load(mod_ctx, "preprocess_depth.wgsl", &g_preprocessSource); + if (result == MOD_OK) { + result = svc_resource->load(mod_ctx, "gtao.wgsl", &g_gtaoSource); + } + if (result == MOD_OK) { + result = svc_resource->load(mod_ctx, "denoise.wgsl", &g_denoiseSource); + } + if (result == MOD_OK) { + result = svc_resource->load(mod_ctx, "composite.wgsl", &g_compositeSource); + } + if (result != MOD_OK) { + return mods::set_error(error, result, "failed to load AO shaders"); + } + + result = register_bool_option("effectEnabled", false, g_cvarEnabled, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("quality", 2, g_cvarQuality, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("radius", 70, g_cvarRadius, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("intensity", 100, g_cvarIntensity, error); + if (result != MOD_OK) { + return result; + } + result = register_bool_option("halfRes", false, g_cvarHalfRes, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("debugMode", 0, g_cvarDebugView, error); + if (result != MOD_OK) { + return result; + } + + if (svc_gfx->get_device_info(mod_ctx, &g_deviceInfo) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to query device info"); + } + if (svc_gfx->get_scene_target_layout(mod_ctx, &g_sceneTargetLayout) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to query scene target layout"); + } + if (!build_compute_pipeline("AO preprocess depth", g_preprocessSource, "preprocess_depth", + g_preprocessPipeline, g_preprocessLayout) || + !build_compute_pipeline("AO downsample mip4", g_preprocessSource, "downsample_mip4", + g_mip4Pipeline, g_mip4Layout) || + !build_compute_pipeline("AO gtao", g_gtaoSource, "gtao", g_gtaoPipeline, g_gtaoLayout) || + !build_compute_pipeline( + "AO denoise", g_denoiseSource, "spatial_denoise", g_denoisePipeline, g_denoiseLayout)) + { + return mods::set_error(error, MOD_ERROR, "failed to create AO compute pipelines"); + } + if (!build_composite_pipeline(true, g_compositePipeline, g_compositeLayout) || + !build_composite_pipeline(false, g_compositeDebugPipeline, g_compositeDebugLayout)) + { + return mods::set_error(error, MOD_ERROR, "failed to create AO composite pipeline"); + } + if (!build_hilbert_lut()) { + return mods::set_error(error, MOD_ERROR, "failed to create AO noise LUT"); + } + + GfxComputeTypeDesc computeDesc = GFX_COMPUTE_TYPE_DESC_INIT; + computeDesc.label = "AO chain"; + computeDesc.callback = on_compute; + if (svc_gfx->register_compute_type(mod_ctx, &computeDesc, &g_computeType) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register compute type"); + } + GfxDrawTypeDesc drawDesc = GFX_DRAW_TYPE_DESC_INIT; + drawDesc.label = "AO composite"; + drawDesc.draw = on_draw; + if (svc_gfx->register_draw_type(mod_ctx, &drawDesc, &g_drawType) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register draw type"); + } + GfxStageHookDesc stageDesc = GFX_STAGE_HOOK_DESC_INIT; + stageDesc.callback = on_scene_after_opaque; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_SCENE_AFTER_OPAQUE, &stageDesc, &g_afterOpaqueHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register stage hook"); + } + + UiModsPanelDesc panelDesc = UI_MODS_PANEL_DESC_INIT; + panelDesc.build = build_panel; + svc_ui->register_mods_panel(mod_ctx, &panelDesc); + + svc_log->info(mod_ctx, "ao_mod ready"); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + if (!g_loggedChain && g_chainExecuted.load(std::memory_order_acquire)) { + g_loggedChain = true; + svc_log->info(mod_ctx, "AO chain executed OK"); + } + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + svc_resource->free(mod_ctx, &g_preprocessSource); + svc_resource->free(mod_ctx, &g_gtaoSource); + svc_resource->free(mod_ctx, &g_denoiseSource); + svc_resource->free(mod_ctx, &g_compositeSource); + + release_targets(g_targets); + for (auto& retired : g_retiredTargets) { + release_targets(retired.targets); + } + g_retiredTargets.clear(); + + const auto releasePipeline = [](WGPUComputePipeline& pipeline) { + if (pipeline != nullptr) { + wgpuComputePipelineRelease(pipeline); + pipeline = nullptr; + } + }; + const auto releaseLayout = [](WGPUBindGroupLayout& layout) { + if (layout != nullptr) { + wgpuBindGroupLayoutRelease(layout); + layout = nullptr; + } + }; + releasePipeline(g_preprocessPipeline); + releasePipeline(g_mip4Pipeline); + releasePipeline(g_gtaoPipeline); + releasePipeline(g_denoisePipeline); + releaseLayout(g_preprocessLayout); + releaseLayout(g_mip4Layout); + releaseLayout(g_gtaoLayout); + releaseLayout(g_denoiseLayout); + if (g_compositePipeline != nullptr) { + wgpuRenderPipelineRelease(g_compositePipeline); + g_compositePipeline = nullptr; + } + if (g_compositeDebugPipeline != nullptr) { + wgpuRenderPipelineRelease(g_compositeDebugPipeline); + g_compositeDebugPipeline = nullptr; + } + releaseLayout(g_compositeLayout); + releaseLayout(g_compositeDebugLayout); + if (g_hilbertLutView != nullptr) { + wgpuTextureViewRelease(g_hilbertLutView); + g_hilbertLutView = nullptr; + } + if (g_hilbertLut != nullptr) { + wgpuTextureRelease(g_hilbertLut); + g_hilbertLut = nullptr; + } + g_cvarEnabled = g_cvarQuality = g_cvarRadius = g_cvarIntensity = 0; + g_cvarHalfRes = g_cvarDebugView = 0; + g_computeType = g_drawType = 0; + g_afterOpaqueHook = 0; + g_controlsWindow = 0; + return MOD_OK; +} +} diff --git a/mods/cosmetics b/mods/cosmetics new file mode 160000 index 0000000000..93971c38aa --- /dev/null +++ b/mods/cosmetics @@ -0,0 +1 @@ +Subproject commit 93971c38aa7286c59be7c3874a95e12d1a37036a diff --git a/mods/custom_actor_demo/CMakeLists.txt b/mods/custom_actor_demo/CMakeLists.txt new file mode 100644 index 0000000000..d7e55536d4 --- /dev/null +++ b/mods/custom_actor_demo/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.25) +project(custom_actor_demo CXX) +set(CMAKE_CXX_STANDARD 20) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(custom_actor_demo + FEATURES game fmt + SOURCES src/mod.cpp src/m_a_obj_wrock.cpp src/m_a_mine.cpp + MOD_JSON mod.json + RES_DIR res +) diff --git a/mods/custom_actor_demo/mod.json b/mods/custom_actor_demo/mod.json new file mode 100644 index 0000000000..55f57c264d --- /dev/null +++ b/mods/custom_actor_demo/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.custom_actor_demo", + "name": "[Demo] Custom Actor", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "A mod to demonstrate how to create and use custom actors. Spawns a \"wrock\" in South Faron Woods." +} diff --git a/tools/mod_template/res/.gitkeep b/mods/custom_actor_demo/res/.gitkeep similarity index 100% rename from tools/mod_template/res/.gitkeep rename to mods/custom_actor_demo/res/.gitkeep diff --git a/mods/custom_actor_demo/src/m_a_mine.cpp b/mods/custom_actor_demo/src/m_a_mine.cpp new file mode 100644 index 0000000000..fd7fa77b65 --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_mine.cpp @@ -0,0 +1,227 @@ +#include "m_a_mine.hpp" +#include "d/d_com_inf_game.h" +#include "res/Object/O_mD_jira.h" + +// The name of the archive in /res/Object/ +static const char* l_resName = "O_mD_jira"; + +// The actor's heap (for resources) should be enough to hold the data for the model and collision +static constexpr u32 heap_size = ALIGN_NEXT(16832, 0x20); + +ma_Mine_c::~ma_Mine_c() { + // Called every time the actor is deleted + + // Delete the sound object + mSound.deleteObject(); + + // Request to unload the archive (the data acts as a shared pointer, and only gets deleted when + // the reference counter goes to zero) + dComIfG_resDelete(&mPhase, l_resName); +} + +cPhs_Step ma_Mine_c::create() { + // Because of how the actor system works, an actor's constructor doesn't get called when an + // actor is created. We need to manually do it here with the following ma: + fopAcM_ct(this, ma_Mine_c); + + // The create function gets called until we return cPhs_COMPLEATE_e while an actor is loading. + // We request to load the archive here, and wait until the dvd completes loading it + cPhs_Step step = dComIfG_resLoad(&mPhase, l_resName); + if (step == cPhs_COMPLEATE_e) { + // Initialize the solid heap for the actor's resources, if needed + if (!fopAcM_entrySolidHeap(this, createHeapCallBack, heap_size)) { + return cPhs_ERROR_e; + } + + // Setup our collision sphere and register it to the world + // Set a circle "wall" of 30 units around the actor + mAcchCir.SetWall(30.0f, 30.0f); + mAcch.Set(this, 1, &mAcchCir); + mAcch.ClrWaterNone(); + mAcch.SetRoofCrrHeight(60.0f); + mAcch.SetWaterCheckOffset(10000.0f); + mAcch.SetWtrChkMode(2); + mAcch.OnLineCheck(); + + mCcStts.Init(30, 0xFF, this); + + // Collision Sphere for the actor (copied from Bomb Actor) + static const dCcD_SrcSph + l_sphSrc = {.mObjInf = + { + .mObj = {.mFlags = 0x0, + .mSrcObjHitInf = {.mObjAt = {.mType = AT_TYPE_BOMB, + .mAtp = 0x4, + .mBase = {.mSPrm = 0x1e}}, + .mObjTg = {.mType = 0xd8fbffef, .mBase = {.mSPrm = 0x11}}, + .mObjCo = {.mBase = {.mSPrm = 0x79}}}}, + .mGObjAt{.mSe = dCcD_SE_NONE, + .mHitMark = 0x0, + .mSpl = 0x1, + .mMtrl = 0x0, + .mBase = {.mGFlag = 0x0}}, + .mGObjTg{.mSe = dCcD_SE_NONE, + .mHitMark = 0x0, + .mSpl = 0x0, + .mMtrl = 0x0, + .mBase = {.mGFlag = 0x4}}, + .mGObjCo{.mBase = {.mGFlag = 0x0}}, + }, + .mSphAttr = {.mSph = {.mCenter = {0.0f, 0.0f, 0.0f}, .mRadius = 80.0f}}}; + + mCollisionSphere.Set(l_sphSrc); + mCollisionSphere.SetStts(&mCcStts); + + // We register a callback anytime the actor is hit (both attacks and is hit) + mCollisionSphere.SetAtHitCallback(atHitCallback); + mCollisionSphere.SetTgHitCallback(atHitCallback); + mCollisionSphere.OffTgSetBit(); + mCollisionSphere.OffCoSetBit(); + mCollisionSphere.OnAtSetBit(); // Enable the attack sphere + + // Set the initial matrix and cull box for the actor + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_SetMin(this, -36.0f, 0.0f, -36.0f); + fopAcM_SetMax(this, 36.0f, 66.0f, 36.0f); + + // Call execute so the actor's information in the world can be updated + Execute(); + } + return step; +} + +// Initializes the heap that all instances of this actor will use for resources +// Gets called from the callback in fopAcM_entrySolidHeap +int ma_Mine_c::CreateHeap() { + // Get the bmd data from the archive and initialize it + J3DModelData* model_data = + (J3DModelData*)dComIfG_getObjectRes(l_resName, dRes_INDEX_O_MD_JIRA_BMD_O_MD_JIRAI_e); + if (model_data == NULL) { + return 0; + } + mpModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084); + if (mpModel == NULL) { + return 0; + } + + // Create the sound object the actor will use + mSound.init(¤t.pos, 1); + + return 1; +} + +int ma_Mine_c::createHeapCallBack(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); +} + +int ma_Mine_c::Delete() { + // Call the destructor anytime we delete the actor + this->~ma_Mine_c(); + return 1; +} + +int ma_Mine_c::Execute() { + // Update collision with the world + mAcch.CrrPos(dComIfG_Bgsp()); + mCollisionSphere.SetC(attention_info.position); + dComIfG_Ccsp()->Set(&mCollisionSphere); + + // Get the collision below the actor + cBgS_GndChk groundChunk = mAcch.m_gnd; + f32 groundH = mAcch.GetGroundH(); + if (groundH != -G_CM3D_F_INF) { + // Set the actor's environment colors to match the room's current ones + int roomNo = dComIfG_Bgsp().GetRoomId(groundChunk); + tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(groundChunk); + tevStr.room_no = roomNo; + + // Set the actor's room to be where it is sitting + mCcStts.SetRoomId(roomNo); + fopAcM_SetRoomNo(this, roomNo); + + // Get the reverb info here that the actor can use when exploding + mReverb = dComIfGp_getReverb(roomNo); + } + + // Update the model's transformation matrix to match the actor's transform + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mDoMtx_stack_c::scaleM(scale); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + + // Set any attention flags (if needed) + eyePos = attention_info.position = current.pos; + attention_info.flags = 0; + return 1; +} + +int ma_Mine_c::Draw() { + // Update the model's lighting with the scene + g_env_light.settingTevStruct(0x20, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); + + // Set the bmd model to be drawn when the display list is executed + mDoExt_modelUpdateDL(mpModel); + + return 1; +} + +void ma_Mine_c::atHit(dCcD_GObjInf* i_atObjInf) { + // Create particles with these IDs at the actor's position + static const u16 normalNameID[] = { + 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167, 0x168, 0x1EC}; + for (int i = 0; i < ARRAY_SIZE(normalNameID); i++) { + dComIfGp_particle_setColor(normalNameID[i], ¤t.pos, &tevStr, NULL, NULL, 0.0f, 0xFF, + &shape_angle, &scale, NULL, -1, NULL); + } + + // Create an explosion sound + mSound.startSound(Z2SE_OBJ_BOMB_EXPLODE, 0, mReverb); + + // Vibrate the controller + dComIfGp_getVibration().StartShock(4, 31, cXyz(0.0f, 1.0f, 0.0f)); + + // Request to delete the actor so it disappears + fopAcM_delete(this); +} + +void ma_Mine_c::atHitCallback(fopAc_ac_c* i_tgActor, dCcD_GObjInf* i_tgObjInf, + fopAc_ac_c* i_atActor, dCcD_GObjInf* i_atObjInf) { + // This callback gets triggered anytime an intersection happens with the object's collision sphere + ((ma_Mine_c*)i_tgActor)->atHit(i_atObjInf); +} + +static cPhs_Step ma_Mine_create(void* i_this) { + return static_cast(i_this)->create(); +} + +static int maMine_Delete(void* i_this) { + return static_cast(i_this)->Delete(); +} + +static int maMine_Execute(void* i_this) { + return static_cast(i_this)->Execute(); +} + +static int maMine_Draw(void* i_this) { + return static_cast(i_this)->Draw(); +} + +static int maMine_IsDelete(void*) { + return 1; +} + +s16 ma_Mine_c::sProcName = -1; +ActorHandle ma_Mine_c::sActorHandle = -1; +const ActorProfileDesc ma_Mine_c::sProfile = {.name = MA_MINE_NAME, + .priority_group = 7, + .process_size = sizeof(ma_Mine_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // An unused draw priority + .status = fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e, + .group = fopAc_ACTOR_e, + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = ma_Mine_create, + .delete_function = maMine_Delete, + .execute_function = maMine_Execute, + .is_delete_function = maMine_IsDelete, + .draw_function = maMine_Draw}; diff --git a/mods/custom_actor_demo/src/m_a_mine.hpp b/mods/custom_actor_demo/src/m_a_mine.hpp new file mode 100644 index 0000000000..147938473f --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_mine.hpp @@ -0,0 +1,43 @@ +#pragma once +#include "mods/svc/actor.h" + +// Base actor class definitions +#include "f_op/f_op_actor.h" + +// Definitions for request_of_phase_process_class and cPhs_Step +#include "SSystem/SComponent/c_phase.h" + +// Definitions for collision +#include "d/d_bg_s_acch.h" +#include "d/d_bg_w.h" +#include "d/d_cc_d.h" + +#define MA_MINE_NAME "m_mine" + +class ma_Mine_c : public fopAc_ac_c { +public: + request_of_phase_process_class mPhase; + J3DModel* mpModel; + dBgS_ObjAcch mAcch; + dBgS_AcchCir mAcchCir; + Mtx mColliderMtx; + dCcD_Stts mCcStts; + dCcD_Sph mCollisionSphere; + Z2SoundObjSimple mSound; + s8 mReverb; + + virtual ~ma_Mine_c(); + cPhs_Step create(); + int CreateHeap(); + int Delete(); + int Execute(); + int Draw(); + void atHit(dCcD_GObjInf* i_atObjInf); + static int createHeapCallBack(fopAc_ac_c*); + static void atHitCallback(fopAc_ac_c* i_tgActor, dCcD_GObjInf* i_tgObjInf, + fopAc_ac_c* i_atActor, dCcD_GObjInf* i_atObjInf); + + static s16 sProcName; + static ActorHandle sActorHandle; + static const ActorProfileDesc sProfile; +}; diff --git a/mods/custom_actor_demo/src/m_a_obj_wrock.cpp b/mods/custom_actor_demo/src/m_a_obj_wrock.cpp new file mode 100644 index 0000000000..bb40d10cf3 --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_obj_wrock.cpp @@ -0,0 +1,195 @@ +/* + * m_a_obj_wrock.cpp + * An example actor for a rock that can be placed in the world. + */ + +#include "m_a_obj_wrock.hpp" +#include "d/d_com_inf_game.h" +#include "res/Object/WRock.h" + +// The name of the archive in /res/Object/ +static const char* l_resName = "Wrock"; + +// The actor's heap (for resources) should be enough to hold the data for the model and collision +static constexpr u32 heap_size = ALIGN_NEXT(13952, 0x20) + ALIGN_NEXT(1920, 0x20); + +maObj_Wrock_c::~maObj_Wrock_c() { + // Called every time the actor is deleted + + // Remove the collider from the world's collision + if (mpCollider != NULL) { + dComIfG_Bgsp().Release(mpCollider); + } + + // Request to unload the archive (the data acts as a shared pointer, and only gets deleted when + // the reference counter goes to zero) + dComIfG_resDelete(&mPhase, l_resName); +} + +cPhs_Step maObj_Wrock_c::create() { + // Because of how the actor system works, an actor's constructor doesn't get called when an + // actor is created. We need to manually do it here with the following macro: + fopAcM_ct(this, maObj_Wrock_c); + + // The create function gets called until we return cPhs_COMPLEATE_e while an actor is loading. + // We request to load the archive here, and wait until the dvd completes loading it + cPhs_Step step = dComIfG_resLoad(&mPhase, l_resName); + if (step == cPhs_COMPLEATE_e) { + // Initialize the solid heap for the actor's resources, if needed + if (!fopAcM_entrySolidHeap(this, createHeapCallBack, heap_size)) { + return cPhs_ERROR_e; + } + + // Register the actor's collider to the current world's collision + if (mpCollider != NULL) { + if (dComIfG_Bgsp().Regist(mpCollider, this) == true) { + return cPhs_ERROR_e; + } + } + + // Set the initial matrix and cull box for the actor + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -400.0f, -400.0f, -400.0f, 400.0f, 400.0f, 400.0f); + + // Setup collision info (will be used in execute) + mAcch.Set(¤t.pos, &old.pos, this, 1, &mAcchCir, &speed, ¤t.angle, &shape_angle); + + // Call execute so the actor's information in the world can be updated + Execute(); + } + return step; +} + +// Initializes the heap that all instances of this actor will use for resources +// Gets called from the callback in fopAcM_entrySolidHeap +int maObj_Wrock_c::CreateHeap() { + // Get the bmd data from the archive and initialize it + J3DModelData* model_data = + (J3DModelData*)dComIfG_getObjectRes(l_resName, dRes_INDEX_WROCK_BMD_WROCK_e); + if (model_data == NULL) { + return 0; + } + mpModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084); + if (mpModel == NULL) { + return 0; + } + + // Get the dzb collision data from the archive and initialize it + mpCollider = JKR_NEW dBgW(); + if (mpCollider == NULL) { + return 0; + } + cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes(l_resName, dRes_INDEX_WROCK_DZB_WROCK_e); + if (mpCollider->Set(dzb, 1, &mColliderMtx) == true) { + return 0; + } + mpCollider->SetCrrFunc(dBgS_MoveBGProc_Typical); + return 1; +} + +int maObj_Wrock_c::createHeapCallBack(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); +} + +int maObj_Wrock_c::Delete() { + // Call the destructor anytime we delete the actor + this->~maObj_Wrock_c(); + return 1; +} + +int maObj_Wrock_c::Execute() { + // Update collision with the world + mAcch.CrrPos(dComIfG_Bgsp()); + + // Get the collision below the actor + mGndChk = mAcch.m_gnd; + mGroundH = mAcch.GetGroundH(); + if (mGroundH != -G_CM3D_F_INF) { + // Set the actor's environment colors to match the room's current ones + tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(mGndChk); + tevStr.room_no = dComIfG_Bgsp().GetRoomId(mGndChk); + + // Set the actor's room to be where it is sitting + fopAcM_SetRoomNo(this, dComIfG_Bgsp().GetRoomId(mGndChk)); + } + + // Update the model's transformation matrix to match the actor's transform + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mDoMtx_stack_c::scaleM(scale); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + + // Copy the model's transformation matrix to the collider's transformation matrix and update the + // collider + if (mpCollider != NULL) { + PSMTXCopy(mpModel->getBaseTRMtx(), mColliderMtx); + mpCollider->Move(); + } + + // Set any attention flags (if needed) + eyePos = attention_info.position = current.pos; + attention_info.flags = 0; + return 1; +} + +int maObj_Wrock_c::Draw() { + // Update the model's lighting with the scene + g_env_light.settingTevStruct(0x20, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); + + // Set the current dlist to BG Which means that shadows can be cast on it + // Because of the messy collider, the shadows don't look great, but this is here as an example + dComIfGd_setListBG(); + + // Set the bmd model to be drawn when the display list is executed + mDoExt_modelUpdateDL(mpModel); + + // Cast a shadow for the actor onto the ground. + // We can only do this if we are drawing to the normal dlist, not the BG dlist + // if (mGroundH != -G_CM3D_F_INF) { + // mShadow = dComIfGd_setShadow(mShadow, 1, mpModel, ¤t.pos, + // 2000.0f, 0.0f, + // current.pos.y, mGroundH, mGndChk, &tevStr, 0, + // 1.0f, &dDlst_shadowControl_c::mSimpleTexObj); + // } + + // Reset the active dlist + dComIfGd_setList(); + + return 1; +} + +static cPhs_Step maObj_Wrock_Create(void* i_this) { + return static_cast(i_this)->create(); +} + +static int maObj_Wrock_Delete(void* i_this) { + return static_cast(i_this)->Delete(); +} + +static int maObj_Wrock_Execute(void* i_this) { + return static_cast(i_this)->Execute(); +} + +static int maObj_Wrock_Draw(void* i_this) { + return static_cast(i_this)->Draw(); +} + +static int maObj_Wrock_IsDelete(void*) { + return 1; +} + +s16 maObj_Wrock_c::sProcName = -1; +ActorHandle maObj_Wrock_c::sActorHandle = -1; +const ActorProfileDesc maObj_Wrock_c::sProfile = {.name = MAOBJ_WROCK_NAME, + .priority_group = 7, + .process_size = sizeof(maObj_Wrock_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // An unused draw priority + .status = fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e, + .group = fopAc_ACTOR_e, + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = maObj_Wrock_Create, + .delete_function = maObj_Wrock_Delete, + .execute_function = maObj_Wrock_Execute, + .is_delete_function = maObj_Wrock_IsDelete, + .draw_function = maObj_Wrock_Draw}; diff --git a/mods/custom_actor_demo/src/m_a_obj_wrock.hpp b/mods/custom_actor_demo/src/m_a_obj_wrock.hpp new file mode 100644 index 0000000000..1e18d36f5f --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_obj_wrock.hpp @@ -0,0 +1,39 @@ +#pragma once +#include "mods/svc/actor.h" + +// Base actor class definitions +#include "f_op/f_op_actor.h" + +// Definitions for request_of_phase_process_class and cPhs_Step +#include "SSystem/SComponent/c_phase.h" + +// Definitions for collision +#include "d/d_bg_s_acch.h" +#include "d/d_bg_w.h" + +#define MAOBJ_WROCK_NAME "wrock" + +class maObj_Wrock_c : public fopAc_ac_c { +public: + request_of_phase_process_class mPhase; + J3DModel* mpModel; + dBgS_ObjAcch mAcch; + cBgS_GndChk mGndChk; + dBgS_AcchCir mAcchCir; + Mtx mColliderMtx; + dBgW* mpCollider; + f32 mGroundH; + int mShadow; + + virtual ~maObj_Wrock_c(); + cPhs_Step create(); + int CreateHeap(); + int Delete(); + int Execute(); + int Draw(); + static int createHeapCallBack(fopAc_ac_c*); + + static s16 sProcName; + static ActorHandle sActorHandle; + static const ActorProfileDesc sProfile; +}; diff --git a/mods/custom_actor_demo/src/mod.cpp b/mods/custom_actor_demo/src/mod.cpp new file mode 100644 index 0000000000..971ad6e4f0 --- /dev/null +++ b/mods/custom_actor_demo/src/mod.cpp @@ -0,0 +1,85 @@ +#include "mods/service.hpp" +#include "mods/svc/actor.h" +#include "mods/svc/log.hpp" +#include "mods/svc/stage.h" + +#include "d/d_com_inf_game.h" + +#include "m_a_mine.hpp" +#include "m_a_obj_wrock.hpp" + +#include + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(ActorService, svc_actor); +IMPORT_SERVICE(StageService, svc_stage); + +extern "C" { +MOD_EXPORT ModResult mod_initialize(ModError*) { + if (svc_actor->register_actor(mod_ctx, &maObj_Wrock_c::sProfile, &maObj_Wrock_c::sProcName, + &maObj_Wrock_c::sActorHandle) != MOD_OK) + { + mods::log::error("Failed to register actor wrock!"); + return MOD_ERROR; + } + + const stage_actor_data_class wrockParams{ + .name = MAOBJ_WROCK_NAME, + .base = + { + .parameters = 0, + .position = {-14324.0f, 0.0f, 341.0f}, + .angle = {0, -16595, 0}, + .setID = 0xFFFF, + }, + }; + if (svc_stage->add_actor( + mod_ctx, "F_SP108", 0, -1, &wrockParams, sizeof(wrockParams), nullptr) != MOD_OK) + { + mods::log::error("Adding wrock to F_SP108 Failed!"); + return MOD_ERROR; + } + + if (svc_actor->register_actor(mod_ctx, &ma_Mine_c::sProfile, &ma_Mine_c::sProcName, + &ma_Mine_c::sActorHandle) != MOD_OK) + { + mods::log::error("Failed to register actor " MA_MINE_NAME); + return MOD_ERROR; + } + + static const std::array minePositions = { + {{-14445.0f, 11.0f, 1304.0f}, {-14557.0f, 7.0f, 990.0f}, {-14790.0f, 7.0f, 634.0f}, + {-14829.0f, 0.0f, 144.0f}, {-14615.0f, 0.0f, -170.0f}, {-14283.0f, 10.0f, -420.0f}}}; + for (const auto& pos : minePositions) { + const stage_actor_data_class mineParams{ + .name = MA_MINE_NAME, + .base = + { + .parameters = 0, + .position = {pos.x, pos.y, pos.z}, + .angle = {0x2000, (s16)(pos.x*100000), 0}, // Adjusted and seemingly random angle + .setID = 0xFFFF, + }, + }; + if (svc_stage->add_actor( + mod_ctx, "F_SP108", 0, -1, &mineParams, sizeof(mineParams), nullptr) != MOD_OK) + { + mods::log::error("Adding mine to F_SP108 Failed!"); + return MOD_ERROR; + } + } + + mods::log::info("custom_actor_demo initialized"); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + mods::log::info("custom_actor_demo shutdown"); + return MOD_OK; +} +} diff --git a/mods/flow_demo/CMakeLists.txt b/mods/flow_demo/CMakeLists.txt new file mode 100644 index 0000000000..8487073dae --- /dev/null +++ b/mods/flow_demo/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.25) +project(flow_demo CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(flow_demo + FEATURES fmt + SOURCES src/mod.cpp + MOD_JSON mod.json +) diff --git a/mods/flow_demo/mod.json b/mods/flow_demo/mod.json new file mode 100644 index 0000000000..90d395bdcc --- /dev/null +++ b/mods/flow_demo/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.flow_demo", + "name": "[Demo] Flow & Messages", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "Adds a FlowService demonstration submenu to Midna's menu." +} diff --git a/mods/flow_demo/src/mod.cpp b/mods/flow_demo/src/mod.cpp new file mode 100644 index 0000000000..a05150458b --- /dev/null +++ b/mods/flow_demo/src/mod.cpp @@ -0,0 +1,302 @@ +#include "mods/service.hpp" +#include "mods/svc/flow.hpp" +#include "mods/svc/log.hpp" + +#include +#include +#include +#include +#include +#include + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(FlowService, svc_flow); +IMPORT_SERVICE(MessageService, svc_message); + +namespace { + +// The Midna flow lives in BMG group 0. +constexpr uint16_t kMessageGroup = 0; +// Midna's "speaker" value for messages. +constexpr uint16_t kMidnaSpeaker = 21; + +// Vanilla flow node/branch/edge IDs that we reference or override. +constexpr uint16_t kMidnaPromptHumanNode = 0x018c; +constexpr uint16_t kMidnaPromptWolfNode = 0x018d; +constexpr uint16_t kMidnaHumanBranch = 0x0190; +constexpr uint16_t kMidnaWolfBranch = 0x0193; +constexpr uint16_t kMidnaTalkNode = 0x018f; +constexpr uint16_t kMidnaHumanTalkEdge = 0x0113; +constexpr uint16_t kMidnaWolfTalkEdge = 0x0119; + +// For vanilla messages, we need both the entry index and the message ID. +// For registered custom messages, they're the same. +constexpr uint16_t kMidnaMenuPromptEntry = 3003; // message index used in flow message data +constexpr uint16_t kMidnaMenuPromptId = 2042; // message ID used to override + +constexpr std::array kAllLanguages{ + MESSAGE_LANGUAGE_ENGLISH, + MESSAGE_LANGUAGE_GERMAN, + MESSAGE_LANGUAGE_FRENCH, + MESSAGE_LANGUAGE_SPANISH, + MESSAGE_LANGUAGE_ITALIAN, + MESSAGE_LANGUAGE_JAPANESE, +}; + +constexpr mods::flow::MessageStyle kResponseStyle = + mods::flow::MessageStyle{}.speaker(kMidnaSpeaker).box_kind(MESSAGE_BOX_MIDNA); +constexpr mods::flow::MessageStyle kPromptStyle = + kResponseStyle.draw_type(MESSAGE_DRAW_INSTANT).talk_anim(31).face_anim(31); + +mods::flow::Query g_demoQuery; +mods::flow::Event g_demoEvent; +mods::flow::Graph g_graph; +std::vector g_messages; +std::vector g_overrides; +std::vector g_visitedPromptText; +uint32_t g_queryExecutions = 0; +uint32_t g_eventExecutions = 0; + +mods::flow::MessageBuilder build_prompt(std::string_view suffix) { + return mods::flow::MessageBuilder{kPromptStyle} + .text("What is it, ") + .text_color(MESSAGE_COLOR_RED) + .player_name() + .text_color(MESSAGE_COLOR_DEFAULT) + .text("?\n") + .text_scale(85) + .text(suffix) + .text_scale(100) + .await_choice(); +} + +// Registers a single message for all languages. +mods::flow::RegisteredMessage register_message(const mods::flow::MessageBuilder& builder) { + std::vector variants; + variants.reserve(kAllLanguages.size()); + for (const MessageLanguage language : kAllLanguages) { + variants.push_back(builder.build(language)); + } + return mods::flow::register_message(kMessageGroup, variants); +} + +ModResult add_message(const mods::flow::MessageBuilder& builder, MessageId& outId) { + auto message = register_message(builder); + if (!message) { + return message.result(); + } + outId = message.id(); + g_messages.push_back(std::move(message)); + return MOD_OK; +} + +ModResult add_fixed_override( + uint16_t messageId, const std::vector& text, bool addCallback) { + for (const MessageLanguage language : kAllLanguages) { + auto fixed = + mods::flow::override_message(kMessageGroup, messageId, language, std::span{text}); + if (!fixed) { + return fixed.result(); + } + g_overrides.push_back(std::move(fixed)); + if (!addCallback) { + continue; + } + auto callback = mods::flow::override_message_fn(kMessageGroup, messageId, language, + [](ModContext*, const MessageOverrideContext*, MessageTextData* outText, + void*) -> bool { + if (g_eventExecutions == 0 || outText == nullptr) { + return false; + } + outText->text = g_visitedPromptText.data(); + outText->text_size = g_visitedPromptText.size(); + return true; + }); + if (!callback) { + return callback.result(); + } + g_overrides.push_back(std::move(callback)); + } + return MOD_OK; +} + +uint16_t demo_query(ModContext*, const FlowQueryContext* query, void*) { + if (query == nullptr || query->parameter != 1234 || query->result_count < 3) { + return 0; + } + const auto result = static_cast(g_queryExecutions % 3); + if (query->phase == FLOW_QUERY_PHASE_EXECUTE) { + ++g_queryExecutions; + mods::log::info("Flow demo query selected result {}", result); + } + return result; +} + +void demo_event(ModContext*, const FlowEventContext* event, void*) { + ++g_eventExecutions; + const uint8_t path = event != nullptr ? event->parameters[3] : 0; + mods::log::info("Flow demo event {} executed (activation {})", path, g_eventExecutions); +} + +} // namespace + +extern "C" { +MOD_EXPORT ModResult mod_initialize(ModError* outError) { + g_queryExecutions = 0; + g_eventExecutions = 0; + + MessageId humanSelectionId = 0; + MessageId wolfSelectionId = 0; + MessageId labPromptId = 0; + MessageId labSelectionId = 0; + MessageId formattedId = 0; + MessageId evenId = 0; + MessageId oddId = 0; + MessageId timeoutId = 0; + + auto result = add_message(mods::flow::MessageBuilder{} + .speaker(kMidnaSpeaker) + .options("Transform into human", "Warp", "Flow demo"), + humanSelectionId); + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{} + .speaker(kMidnaSpeaker) + .options("Transform into wolf", "Warp", "Flow demo"), + wolfSelectionId); + } + if (result == MOD_OK) { + result = add_message(build_prompt("Choose a FlowService test."), labPromptId); + } + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{} + .speaker(kMidnaSpeaker) + .options("Formatted message", "Callback branch", "Talk to Midna"), + labSelectionId); + } + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{kResponseStyle} + .text_color(MESSAGE_COLOR_DEFAULT) + .text("Custom ") + .text_color(0xFF0000FF) + .text("colors") + .text_color(MESSAGE_COLOR_DEFAULT) + .text(" and even ") + .text_color(0x00FF00FF, 0x00FFFFFF) + .text("gradients") + .text_color(MESSAGE_COLOR_DEFAULT) + .text("!\n") + .character_delay(3) + .text("This text is slow. ") + .character_delay(0) + .pause(12) + .text_scale(150) + .text("Big") + .text_scale(100) + .text(" text too.") + .input_after_delay(15), + formattedId); + } + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{kResponseStyle} + .text("Query returned ") + .text_color(MESSAGE_COLOR_GREEN) + .text("zero") + .text_color(MESSAGE_COLOR_DEFAULT) + .text(".") + .auto_advance(75), + evenId); + } + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{kResponseStyle} + .box_kind(MESSAGE_BOX_LIGHT_SPIRIT) + .text("Query returned ") + .text_color(MESSAGE_COLOR_RED) + .text("one") + .text_color(MESSAGE_COLOR_DEFAULT) + .text(".") + .auto_advance(75), + oddId); + } + if (result == MOD_OK) { + result = add_message(mods::flow::MessageBuilder{kResponseStyle} + .text("Query returned ") + .text_color(MESSAGE_COLOR_YELLOW) + .text("three") + .text_color(MESSAGE_COLOR_DEFAULT) + .text(".\nThis will timeout after three seconds.") + .input_or_timeout(90), + timeoutId); + } + if (result != MOD_OK) { + return mods::set_error(outError, result, "failed to register custom demo messages"); + } + + g_visitedPromptText = + build_prompt("A custom event has run.").build(MESSAGE_LANGUAGE_ENGLISH).text(); + result = add_fixed_override(kMidnaMenuPromptId, + build_prompt("Flow demo is installed.").build(MESSAGE_LANGUAGE_ENGLISH).text(), true); + if (result != MOD_OK) { + return mods::set_error(outError, result, "failed to register demo message overrides"); + } + + g_demoQuery = mods::flow::register_query("flow_demo cycling branch", demo_query); + g_demoEvent = mods::flow::register_event("flow_demo activation", demo_event); + if (!g_demoQuery || !g_demoEvent) { + const auto callbackResult = !g_demoQuery ? g_demoQuery.result() : g_demoEvent.result(); + return mods::set_error(outError, callbackResult, "failed to register flow callbacks"); + } + + // Set up our demo graph + mods::flow::GraphBuilder graph{kMessageGroup}; + const auto demoSetup = graph.add_event(FLOW_EVENT_SELECT_VERTICAL, {0, 0, 0, 4}); + const auto formattedMessage = graph.add_message(formattedId).next(demoSetup); + const auto formattedEvent = + graph.add_event(g_demoEvent.id(), {0, 0, 0, 1}).next(formattedMessage); + const auto evenMessage = graph.add_message(evenId).next(demoSetup); + const auto evenEvent = graph.add_event(g_demoEvent.id(), {0, 0, 0, 2}).next(evenMessage); + const auto oddMessage = graph.add_message(oddId).next(demoSetup); + const auto oddEvent = graph.add_event(g_demoEvent.id(), {0, 0, 0, 3}).next(oddMessage); + const auto timeoutMessage = graph.add_message(timeoutId).next(demoSetup); + const auto timeoutEvent = graph.add_event(g_demoEvent.id(), {0, 0, 0, 4}).next(timeoutMessage); + const auto callbackBranch = + graph.add_branch(g_demoQuery.id(), 1234).results({evenEvent, oddEvent, timeoutEvent}); + const auto choiceBranch = + graph.add_branch(FLOW_QUERY_SELECT_3_CANCEL, 0) + .results({formattedEvent, callbackBranch, kMidnaTalkNode, mods::flow::kEnd}); + const auto demoSelection = graph.add_message(labSelectionId).next(choiceBranch); + const auto demoPrompt = graph.add_message(labPromptId).next(demoSelection); + demoSetup.next(demoPrompt); + + // Patch original nodes and edges so they flow into our custom graph + const auto humanSelection = graph.add_message(humanSelectionId).next(kMidnaHumanBranch); + const auto wolfSelection = graph.add_message(wolfSelectionId).next(kMidnaWolfBranch); + graph.patch_node( + kMidnaPromptHumanNode, mods::flow::message(0, kMidnaMenuPromptEntry, humanSelection)); + graph.patch_node( + kMidnaPromptWolfNode, mods::flow::message(0, kMidnaMenuPromptEntry, wolfSelection)); + graph.patch_edge(kMidnaHumanTalkEdge, demoSetup); + graph.patch_edge(kMidnaWolfTalkEdge, demoSetup); + + g_graph = graph.commit(); + if (!g_graph) { + return mods::set_error(outError, g_graph.result(), "failed to commit the flow demo graph"); + } + + mods::log::info("Flow demo ready: {} custom messages", g_messages.size()); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + mods::log::info("Flow demo unloaded after {} events", g_eventExecutions); + g_graph.reset(); + g_overrides.clear(); + g_messages.clear(); + g_visitedPromptText.clear(); + return MOD_OK; +} +} diff --git a/mods/luau_runtime/CMakeLists.txt b/mods/luau_runtime/CMakeLists.txt new file mode 100644 index 0000000000..fa38b64b8a --- /dev/null +++ b/mods/luau_runtime/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.25) +project(luau_runtime CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +include(FetchContent) + +set(LUAU_BUILD_CLI OFF CACHE BOOL "" FORCE) +set(LUAU_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set(LUAU_BUILD_WEB OFF CACHE BOOL "" FORCE) +set(LUAU_WERROR OFF CACHE BOOL "" FORCE) +FetchContent_Declare(luau + URL https://github.com/luau-lang/luau/archive/refs/tags/0.734.tar.gz + URL_HASH SHA256=cb55a891226d8c70284e22eb9281cc2b4496c709a4050f52aaa18a355fe7b1a3 + DOWNLOAD_EXTRACT_TIMESTAMP FALSE + EXCLUDE_FROM_ALL +) +FetchContent_MakeAvailable(luau) + +add_mod(luau_runtime + SOURCES + src/bindings.cpp + src/config.cpp + src/runtime.cpp + src/ui.cpp + MOD_JSON mod.json + RES_DIR res + BUNDLE +) + +target_link_libraries(luau_runtime PRIVATE Luau.VM Luau.Compiler) diff --git a/mods/luau_runtime/mod.json b/mods/luau_runtime/mod.json new file mode 100644 index 0000000000..788a57f554 --- /dev/null +++ b/mods/luau_runtime/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.luau", + "name": "Luau Support", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "Luau script runtime for mods" +} diff --git a/mods/luau_runtime/res/licenses/LUAU-MIT.txt b/mods/luau_runtime/res/licenses/LUAU-MIT.txt new file mode 100644 index 0000000000..2f2aa17066 --- /dev/null +++ b/mods/luau_runtime/res/licenses/LUAU-MIT.txt @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2019-2025 Roblox Corporation +Copyright (c) 1994-2019 Lua.org, PUC-Rio. + +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/mods/luau_runtime/src/bindings.cpp b/mods/luau_runtime/src/bindings.cpp new file mode 100644 index 0000000000..27f4218a83 --- /dev/null +++ b/mods/luau_runtime/src/bindings.cpp @@ -0,0 +1,340 @@ +#include "runtime.hpp" + +#include +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kOverlayMetatable[] = "dusklight.overlay_handle"; +constexpr char kTextureMetatable[] = "dusklight.texture_handle"; + +uint64_t get_hash_field(lua_State* state, int table, const char* field, bool required) { + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + if (required) { + luaL_error(state, "field '%s' is required", field); + } + return 0; + } + if (!lua_isinteger64(state, -1)) { + luaL_error(state, "field '%s' must be an integer", field); + } + const uint64_t value = static_cast(lua_tointeger64(state, -1, nullptr)); + lua_pop(state, 1); + return value; +} + +int log_write(lua_State* state, LogLevel level, int messageIndex) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + size_t length = 0; + const char* message = luaL_checklstring(state, messageIndex, &length); + const std::string copy{message, length}; + svc_log->write(vm.subject, level, copy.c_str()); + return 0; +} + +int log_trace(lua_State* state) { + return log_write(state, LOG_LEVEL_TRACE, 1); +} + +int log_debug(lua_State* state) { + return log_write(state, LOG_LEVEL_DEBUG, 1); +} + +int log_info(lua_State* state) { + return log_write(state, LOG_LEVEL_INFO, 1); +} + +int log_warn(lua_State* state) { + return log_write(state, LOG_LEVEL_WARN, 1); +} + +int log_error(lua_State* state) { + return log_write(state, LOG_LEVEL_ERROR, 1); +} + +int log_write_level(lua_State* state) { + static constexpr const char* kLevels[] = {"trace", "debug", "info", "warn", "error", nullptr}; + const int level = luaL_checkoption(state, 1, nullptr, kLevels); + return log_write(state, static_cast(level), 2); +} + +int host_mod_id(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_id(vm.subject)); + return 1; +} + +int host_mod_name(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_name(vm.subject)); + return 1; +} + +int host_mod_version(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_version(vm.subject)); + return 1; +} + +int host_mod_dir(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_dir(vm.subject)); + return 1; +} + +int host_data_dir(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr || !SERVICE_HAS(svc_host, HostService, data_dir) || + svc_host->data_dir == nullptr) + { + service_unavailable(state, "HostService::data_dir"); + } + const char* path = nullptr; + check_result(state, svc_host->data_dir(vm.subject, &path), "host.data_dir"); + lua_pushstring(state, path != nullptr ? path : ""); + return 1; +} + +int host_fail(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + const char* message = luaL_checkstring(state, 1); + svc_host->fail(vm.subject, MOD_ERROR, message); + luaL_error(state, "%s", message); +} + +int register_host_callback(lua_State* state, std::vector& callbacks) { + luaL_checktype(state, 1, LUA_TFUNCTION); + lua_pushvalue(state, 1); + callbacks.push_back(lua_ref(state, -1)); + lua_pop(state, 1); + return 0; +} + +int host_on_update(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + return register_host_callback(state, vm.updateRefs); +} + +int host_on_shutdown(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + return register_host_callback(state, vm.shutdownRefs); +} + +int resource_load(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_resource == nullptr) { + service_unavailable(state, "ResourceService"); + } + const char* path = luaL_checkstring(state, 1); + ResourceBuffer buffer = RESOURCE_BUFFER_INIT; + check_result(state, svc_resource->load(vm.subject, path, &buffer), "resource.load"); + const auto* data = buffer.data != nullptr ? static_cast(buffer.data) : ""; + const std::string copy{data, buffer.size}; + svc_resource->free(vm.subject, &buffer); + lua_pushlstring(state, copy.data(), copy.size()); + return 1; +} + +int overlay_remove(lua_State* state) { + auto& handle = check_handle(state, 1, kOverlayMetatable, HandleKind::Overlay); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + check_result(state, svc_overlay->remove(handle.vm->subject, handle.value), "overlay.remove"); + handle.value = 0; + return 0; +} + +int overlay_add_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + const char* discPath = luaL_checkstring(state, 1); + const char* bundlePath = luaL_checkstring(state, 2); + OverlayHandle handle = 0; + check_result(state, svc_overlay->add_file(vm.subject, discPath, bundlePath, &handle), + "overlay.add_file"); + push_handle(state, vm, handle, HandleKind::Overlay, kOverlayMetatable); + return 1; +} + +int overlay_add_buffer(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + const char* discPath = luaL_checkstring(state, 1); + size_t size = 0; + const char* data = luaL_checklstring(state, 2, &size); + OverlayHandle handle = 0; + check_result(state, svc_overlay->add_buffer(vm.subject, discPath, data, size, &handle), + "overlay.add_buffer"); + push_handle(state, vm, handle, HandleKind::Overlay, kOverlayMetatable); + return 1; +} + +int texture_unregister(lua_State* state) { + auto& handle = check_handle(state, 1, kTextureMetatable, HandleKind::Texture); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + check_result( + state, svc_texture->unregister(handle.vm->subject, handle.value), "texture.unregister"); + handle.value = 0; + return 0; +} + +int texture_register_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + const char* path = luaL_checkstring(state, 1); + TextureReplacementHandle handle = 0; + check_result( + state, svc_texture->register_file(vm.subject, path, &handle), "texture.register_file"); + push_handle(state, vm, handle, HandleKind::Texture, kTextureMetatable); + return 1; +} + +int texture_register_data(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + luaL_checktype(state, 1, LUA_TTABLE); + luaL_checktype(state, 2, LUA_TTABLE); + + TextureKey key = TEXTURE_KEY_INIT; + key.kind = TEXTURE_KEY_SOURCE; + key.texture_hash = get_hash_field(state, 1, "texture_hash", true); + key.tlut_hash = get_hash_field(state, 1, "tlut_hash", false); + key.width = static_cast(get_optional_int(state, 1, "width", 0)); + key.height = static_cast(get_optional_int(state, 1, "height", 0)); + key.gx_format = static_cast(get_optional_int(state, 1, "gx_format", 0)); + key.has_tlut = get_optional_bool(state, 1, "has_tlut", false); + + lua_getfield(state, 2, "data"); + size_t size = 0; + const char* bytes = luaL_checklstring(state, -1, &size); + TextureData data = TEXTURE_DATA_INIT; + data.data = bytes; + data.size = size; + data.width = static_cast(get_optional_int(state, 2, "width", key.width)); + data.height = static_cast(get_optional_int(state, 2, "height", key.height)); + data.mip_count = static_cast(get_optional_int(state, 2, "mip_count", 1)); + data.gx_format = static_cast(get_optional_int(state, 2, "gx_format", key.gx_format)); + + TextureReplacementHandle handle = 0; + const ModResult result = svc_texture->register_data(vm.subject, &key, &data, &handle); + lua_pop(state, 1); + check_result(state, result, "texture.register_data"); + push_handle(state, vm, handle, HandleKind::Texture, kTextureMetatable); + return 1; +} + +} // namespace + +int open_log(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + lua_newtable(state); + set_function(state, vm, "write", log_write_level); + set_function(state, vm, "trace", log_trace); + set_function(state, vm, "debug", log_debug); + set_function(state, vm, "info", log_info); + set_function(state, vm, "warn", log_warn); + set_function(state, vm, "error", log_error); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_host(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_newtable(state); + lua_pushstring(state, svc_host->version != nullptr ? svc_host->version : ""); + lua_setfield(state, -2, "version"); + set_function(state, vm, "mod_id", host_mod_id); + set_function(state, vm, "mod_name", host_mod_name); + set_function(state, vm, "mod_version", host_mod_version); + set_function(state, vm, "mod_dir", host_mod_dir); + set_function(state, vm, "data_dir", host_data_dir); + set_function(state, vm, "on_update", host_on_update); + set_function(state, vm, "on_shutdown", host_on_shutdown); + set_function(state, vm, "fail", host_fail); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_resource(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_resource == nullptr) { + service_unavailable(state, "ResourceService"); + } + lua_newtable(state); + set_function(state, vm, "load", resource_load); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_overlay(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + static const luaL_Reg kMethods[] = {{"remove", overlay_remove}, {nullptr, nullptr}}; + create_handle_metatable(state, kOverlayMetatable, kMethods, "OverlayHandle"); + lua_newtable(state); + set_function(state, vm, "add_file", overlay_add_file); + set_function(state, vm, "add_buffer", overlay_add_buffer); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_texture(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + static const luaL_Reg kMethods[] = {{"unregister", texture_unregister}, {nullptr, nullptr}}; + create_handle_metatable(state, kTextureMetatable, kMethods, "TextureHandle"); + lua_newtable(state); + set_function(state, vm, "register_file", texture_register_file); + set_function(state, vm, "register_data", texture_register_data); + lua_pushinteger64(state, static_cast(TEXTURE_HASH_WILDCARD)); + lua_setfield(state, -2, "hash_wildcard"); + lua_pushinteger64(state, static_cast(TEXTURE_TLUT_WILDCARD)); + lua_setfield(state, -2, "tlut_wildcard"); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/config.cpp b/mods/luau_runtime/src/config.cpp new file mode 100644 index 0000000000..b198bdb6e7 --- /dev/null +++ b/mods/luau_runtime/src/config.cpp @@ -0,0 +1,243 @@ +#include "runtime.hpp" + +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kConfigVarMetatable[] = "dusklight.config_var"; +constexpr char kConfigSubscriptionMetatable[] = "dusklight.config_subscription"; + +void config_changed(ModContext*, ConfigVarHandle, const ConfigVarValue* value, + const ConfigVarValue* previous, void* userData) { + auto& callback = *static_cast(userData); + if (value == nullptr || previous == nullptr) { + return; + } + push_config_value(callback.vm->state, *value); + push_config_value(callback.vm->state, *previous); + std::string error; + if (!call_ref(*callback.vm, callback.refs[0], 2, 0, kCallbackBudget, error)) { + fail_callback(*callback.vm, "config change callback", error); + } +} + +int config_get(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + switch (handle.configType) { + case CONFIG_VAR_BOOL: { + bool value = false; + check_result( + state, svc_config->get_bool(handle.vm->subject, handle.value, &value), "config get"); + lua_pushboolean(state, value); + break; + } + case CONFIG_VAR_INT: { + int64_t value = 0; + check_result( + state, svc_config->get_int(handle.vm->subject, handle.value, &value), "config get"); + lua_pushinteger64(state, value); + break; + } + case CONFIG_VAR_FLOAT: { + double value = 0; + check_result( + state, svc_config->get_float(handle.vm->subject, handle.value, &value), "config get"); + lua_pushnumber(state, value); + break; + } + case CONFIG_VAR_STRING: { + size_t size = 0; + check_result(state, + svc_config->get_string(handle.vm->subject, handle.value, nullptr, 0, &size), + "config get"); + std::vector value(size + 1); + check_result(state, + svc_config->get_string( + handle.vm->subject, handle.value, value.data(), value.size(), nullptr), + "config get"); + lua_pushlstring(state, value.data(), size); + break; + } + default: + luaL_error(state, "unknown config value type"); + } + return 1; +} + +int config_set(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + ModResult result = MOD_INVALID_ARGUMENT; + switch (handle.configType) { + case CONFIG_VAR_BOOL: + result = svc_config->set_bool( + handle.vm->subject, handle.value, luaL_checkboolean(state, 2) != 0); + break; + case CONFIG_VAR_INT: + result = svc_config->set_int(handle.vm->subject, handle.value, check_int64(state, 2)); + break; + case CONFIG_VAR_FLOAT: + result = + svc_config->set_float(handle.vm->subject, handle.value, luaL_checknumber(state, 2)); + break; + case CONFIG_VAR_STRING: + result = + svc_config->set_string(handle.vm->subject, handle.value, luaL_checkstring(state, 2)); + break; + default: + break; + } + check_result(state, result, "config set"); + return 0; +} + +int config_unregister(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + check_result( + state, svc_config->unregister_var(handle.vm->subject, handle.value), "config unregister"); + handle.value = 0; + return 0; +} + +int config_unsubscribe(lua_State* state) { + auto& handle = + check_handle(state, 1, kConfigSubscriptionMetatable, HandleKind::ConfigSubscription); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + check_result( + state, svc_config->unsubscribe(handle.vm->subject, handle.value), "config unsubscribe"); + handle.value = 0; + return 0; +} + +int subscribe(lua_State* state, ScriptHandle& variable, int functionIndex) { + luaL_checktype(state, functionIndex, LUA_TFUNCTION); + Callback& callback = retain_callback(*variable.vm); + callback.refs[0] = lua_ref(state, functionIndex); + + ConfigSubscriptionHandle subscription = 0; + check_result(state, + svc_config->subscribe( + variable.vm->subject, variable.value, config_changed, &callback, &subscription), + "config.subscribe"); + push_handle(state, *variable.vm, subscription, HandleKind::ConfigSubscription, + kConfigSubscriptionMetatable); + return 1; +} + +int config_subscribe(lua_State* state) { + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + auto& variable = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + return subscribe(state, variable, 2); +} + +int config_var_subscribe(lua_State* state) { + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + auto& variable = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + return subscribe(state, variable, 2); +} + +int config_register(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + luaL_checktype(state, 1, LUA_TTABLE); + + const std::string name = get_optional_string(state, 1, "name"); + const std::string type = get_optional_string(state, 1, "type"); + ConfigVarDesc desc = CONFIG_VAR_DESC_INIT; + desc.name = name.c_str(); + if (type == "bool") { + desc.type = CONFIG_VAR_BOOL; + desc.default_bool = get_optional_bool(state, 1, "default", false); + } else if (type == "int") { + desc.type = CONFIG_VAR_INT; + desc.default_int = get_optional_int(state, 1, "default", 0); + } else if (type == "float") { + desc.type = CONFIG_VAR_FLOAT; + desc.default_float = get_optional_number(state, 1, "default", 0); + } else if (type == "string") { + desc.type = CONFIG_VAR_STRING; + } else { + luaL_error(state, "config type must be 'bool', 'int', 'float', or 'string'"); + } + + std::string defaultString; + if (desc.type == CONFIG_VAR_STRING) { + defaultString = get_optional_string(state, 1, "default"); + desc.default_string = defaultString.c_str(); + } + + ConfigVarHandle handle = 0; + check_result(state, svc_config->register_var(vm.subject, &desc, &handle), "config.register"); + push_handle(state, vm, handle, HandleKind::ConfigVar, kConfigVarMetatable, desc.type); + return 1; +} + +} // namespace + +void push_config_value(lua_State* state, const ConfigVarValue& value) { + switch (value.type) { + case CONFIG_VAR_BOOL: + lua_pushboolean(state, value.bool_value); + break; + case CONFIG_VAR_INT: + lua_pushinteger64(state, value.int_value); + break; + case CONFIG_VAR_FLOAT: + lua_pushnumber(state, value.float_value); + break; + case CONFIG_VAR_STRING: + lua_pushlstring(state, value.string_value != nullptr ? value.string_value : "", + value.string_value != nullptr ? value.string_length : 0); + break; + default: + lua_pushnil(state); + break; + } +} + +int open_config(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + static const luaL_Reg kVarMethods[] = { + {"get", config_get}, + {"set", config_set}, + {"subscribe", config_var_subscribe}, + {"unregister", config_unregister}, + {nullptr, nullptr}, + }; + static const luaL_Reg kSubscriptionMethods[] = { + {"unsubscribe", config_unsubscribe}, + {nullptr, nullptr}, + }; + create_handle_metatable(state, kConfigVarMetatable, kVarMethods, "ConfigVar"); + create_handle_metatable( + state, kConfigSubscriptionMetatable, kSubscriptionMethods, "ConfigSubscription"); + + lua_newtable(state); + set_function(state, vm, "register", config_register); + set_function(state, vm, "subscribe", config_subscribe); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/runtime.cpp b/mods/luau_runtime/src/runtime.cpp new file mode 100644 index 0000000000..87676395d4 --- /dev/null +++ b/mods/luau_runtime/src/runtime.cpp @@ -0,0 +1,645 @@ +#include "runtime.hpp" + +#include "Luau/Common.h" +#include "luacode.h" +#include "mods/runtime.h" +#include "mods/service.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +LUAU_FASTFLAG(LuauIntegerLibrary) +LUAU_FASTFLAG(LuauIntegerType2) + +DEFINE_MOD(); +IMPORT_OPTIONAL_SERVICE(LogService, svc_log); +IMPORT_OPTIONAL_SERVICE(HostService, svc_host); +IMPORT_OPTIONAL_SERVICE(ConfigService, svc_config); +IMPORT_OPTIONAL_SERVICE(ResourceService, svc_resource); +IMPORT_OPTIONAL_SERVICE(OverlayService, svc_overlay); +IMPORT_OPTIONAL_SERVICE(TextureService, svc_texture); +IMPORT_OPTIONAL_SERVICE(UiService, svc_ui); + +namespace luau_runtime { +namespace { + +std::unordered_map> s_vms; + +void* limited_realloc(void* userData, void* pointer, size_t oldSize, size_t newSize) { + auto& budget = *static_cast(userData); + if (newSize == 0) { + std::free(pointer); + budget.used -= std::min(budget.used, oldSize); + return nullptr; + } + + const size_t growth = newSize > oldSize ? newSize - oldSize : 0; + if (growth > budget.limit - std::min(budget.used, budget.limit)) { + return nullptr; + } + void* result = std::realloc(pointer, newSize); + if (result != nullptr) { + budget.used -= std::min(budget.used, oldSize); + budget.used += newSize; + } + return result; +} + +int traceback_handler(lua_State* state) { + const char* message = lua_tostring(state, 1); + luaL_traceback(state, state, message != nullptr ? message : "Luau error", 1); + return 1; +} + +class DeadlineScope { +public: + DeadlineScope(Vm& vm, std::chrono::steady_clock::duration budget) + : m_vm{vm}, m_previousDeadline{vm.deadline}, m_previousActive{vm.deadlineActive} { + const auto requested = std::chrono::steady_clock::now() + budget; + if (!vm.deadlineActive || requested < vm.deadline) { + vm.deadline = requested; + } + vm.deadlineActive = true; + ++vm.callDepth; + } + + ~DeadlineScope() { + --m_vm.callDepth; + m_vm.deadline = m_previousDeadline; + m_vm.deadlineActive = m_previousActive; + } + +private: + Vm& m_vm; + std::chrono::steady_clock::time_point m_previousDeadline; + bool m_previousActive; +}; + +bool protected_call(lua_State* state, Vm& vm, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError) { + const int functionIndex = lua_gettop(state) - argumentCount; + lua_pushcfunction(state, traceback_handler, "dusklight traceback"); + lua_insert(state, functionIndex); + + DeadlineScope deadline{vm, budget}; + const int status = lua_pcall(state, argumentCount, resultCount, functionIndex); + if (status != LUA_OK) { + const char* message = lua_tostring(state, -1); + outError = message != nullptr ? message : "unknown Luau error"; + lua_pop(state, 1); + lua_remove(state, functionIndex); + return false; + } + lua_remove(state, functionIndex); + return true; +} + +std::optional normalize_module_path( + std::string_view currentPath, std::string_view requested) { + if ((!requested.starts_with("./") && !requested.starts_with("../")) || + requested.find('\\') != std::string_view::npos) + { + return std::nullopt; + } + + std::vector parts; + const auto parentEnd = currentPath.rfind('/'); + std::string combined; + if (parentEnd != std::string_view::npos) { + combined.assign(currentPath.substr(0, parentEnd + 1)); + } + combined.append(requested); + + size_t begin = 0; + while (begin <= combined.size()) { + const size_t end = combined.find('/', begin); + const auto part = std::string_view{combined}.substr( + begin, end == std::string::npos ? combined.size() - begin : end - begin); + if (part.empty() || part == ".") { + } else if (part == "..") { + if (parts.empty()) { + return std::nullopt; + } + parts.pop_back(); + } else { + parts.push_back(part); + } + if (end == std::string::npos) { + break; + } + begin = end + 1; + } + if (parts.empty()) { + return std::nullopt; + } + + std::string normalized; + for (const auto part : parts) { + if (!normalized.empty()) { + normalized.push_back('/'); + } + normalized.append(part); + } + if (!normalized.ends_with(".luau")) { + normalized += ".luau"; + } + return normalized; +} + +ModuleOpenFn module_factory(std::string_view name) { + if (name == "dusklight.log") { + return open_log; + } + if (name == "dusklight.host") { + return open_host; + } + if (name == "dusklight.resource") { + return open_resource; + } + if (name == "dusklight.overlay") { + return open_overlay; + } + if (name == "dusklight.texture") { + return open_texture; + } + if (name == "dusklight.config") { + return open_config; + } + if (name == "dusklight.ui") { + return open_ui; + } + return nullptr; +} + +int module_require(lua_State* state); +int print(lua_State* state); + +void install_module_require(lua_State* state, Vm& vm, std::string_view currentPath) { + lua_pushlightuserdata(state, &vm); + lua_pushlstring(state, currentPath.data(), currentPath.size()); + lua_pushcclosure(state, module_require, "require", 2); + lua_setglobal(state, "require"); +} + +void install_globals(Vm& vm) { + push_vm_closure(vm.state, vm, print, "print"); + lua_setglobal(vm.state, "print"); +} + +bool load_source_module( + lua_State* caller, Vm& vm, const std::string& path, bool keepResult, std::string& outError) { + if (svc_resource == nullptr) { + outError = "ResourceService is not available in this Dusklight build"; + return false; + } + + ResourceBuffer buffer = RESOURCE_BUFFER_INIT; + const ModResult loadResult = svc_resource->load(vm.subject, path.c_str(), &buffer); + if (loadResult != MOD_OK) { + outError = loadResult == MOD_UNAVAILABLE ? "module not found: res/" + path : + "failed to load module: res/" + path; + return false; + } + std::string source; + if (buffer.data != nullptr) { + source.assign(static_cast(buffer.data), buffer.size); + } + svc_resource->free(vm.subject, &buffer); + + size_t bytecodeSize = 0; + lua_CompileOptions options{}; + options.optimizationLevel = 1; + options.debugLevel = 1; + char* bytecode = luau_compile(source.data(), source.size(), &options, &bytecodeSize); + if (bytecode == nullptr) { + outError = "Luau compiler ran out of memory"; + return false; + } + + lua_State* moduleState = lua_newthread(caller); + if (moduleState == nullptr) { + std::free(bytecode); + outError = "Luau VM ran out of memory"; + return false; + } + luaL_sandboxthread(moduleState); + install_module_require(moduleState, vm, path); + + const std::string chunkName = "@res/" + path; + const int loadStatus = luau_load(moduleState, chunkName.c_str(), bytecode, bytecodeSize, 0); + std::free(bytecode); + if (loadStatus != LUA_OK) { + const char* message = lua_tostring(moduleState, -1); + outError = message != nullptr ? message : "failed to load Luau bytecode"; + lua_pop(caller, 1); + return false; + } + if (!protected_call(moduleState, vm, 0, keepResult ? 1 : 0, kLifecycleBudget, outError)) { + lua_pop(caller, 1); + return false; + } + if (!keepResult) { + lua_pop(caller, 1); + return true; + } + if (lua_isnil(moduleState, -1)) { + outError = "module res/" + path + " must return a value"; + lua_pop(caller, 1); + return false; + } + + lua_xmove(moduleState, caller, 1); + lua_remove(caller, -2); + return true; +} + +int module_require(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const std::string requested = luaL_checkstring(state, 1); + + std::string moduleName; + ModuleOpenFn factory = nullptr; + if (requested.starts_with("dusklight.")) { + moduleName = requested; + factory = module_factory(moduleName); + if (factory == nullptr) { + luaL_error(state, "unknown module '%s'", moduleName.c_str()); + } + } else { + const char* currentPath = lua_tostring(state, lua_upvalueindex(2)); + const auto normalized = + normalize_module_path(currentPath != nullptr ? currentPath : "main.luau", requested); + if (!normalized.has_value()) { + luaL_error( + state, "module paths must be relative and remain inside the mod's res directory"); + } + moduleName = *normalized; + } + + if (const auto found = vm.moduleRefs.find(moduleName); found != vm.moduleRefs.end()) { + lua_getref(state, found->second); + return 1; + } + if (!vm.loadingModules.insert(moduleName).second) { + luaL_error(state, "cyclic require of '%s'", moduleName.c_str()); + } + + std::string error; + if (factory != nullptr) { + factory(state); + } else if (!load_source_module(state, vm, moduleName, true, error)) { + vm.loadingModules.erase(moduleName); + luaL_error(state, "%s", error.c_str()); + } + vm.loadingModules.erase(moduleName); + + const int ref = lua_ref(state, -1); + vm.moduleRefs.emplace(moduleName, ref); + return 1; +} + +int print(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + + std::string value; + int const numArgs = lua_gettop(state); + for (int i = 0; i < numArgs; i += 1) { + if (i != 0) { + value.push_back('\t'); + } + + size_t length; + char const* str = luaL_tolstring(state, i + 1, &length); + value.append(str, length); + lua_pop(state, 1); + } + + svc_log->info(vm.subject, value.data()); + return 0; +} + +ModResult runtime_activate(ModContext*, ModContext* subject, ModError* outError) { + if (subject == nullptr) { + return set_error(outError, MOD_INVALID_ARGUMENT, "Delegated mod context is null"); + } + if (s_vms.contains(subject)) { + return set_error(outError, MOD_CONFLICT, "Delegated mod is already active"); + } + + auto vm = std::make_unique(); + vm->subject = subject; + vm->state = lua_newstate(limited_realloc, &vm->memory); + if (vm->state == nullptr) { + return set_error(outError, MOD_ERROR, "Failed to create Luau VM"); + } + lua_callbacks(vm->state)->userdata = vm.get(); +#if NDEBUG // Annoying for debuggers + lua_callbacks(vm->state)->interrupt = [](lua_State* state, int gc) { + auto* current = static_cast(lua_callbacks(state)->userdata); + if (gc < 0 && current != nullptr && current->deadlineActive && + std::chrono::steady_clock::now() > current->deadline) + { + luaL_error(state, "script execution exceeded its time budget"); + } + }; +#endif + luaL_openlibs(vm->state); + install_globals(*vm); + luaL_sandbox(vm->state); + + std::string error; + vm->loadingModules.insert("main.luau"); + const bool loadedMain = load_source_module(vm->state, *vm, "main.luau", false, error); + vm->loadingModules.erase("main.luau"); + if (!loadedMain) { + return set_error(outError, MOD_ERROR, error); + } + + s_vms.emplace(subject, std::move(vm)); + return MOD_OK; +} + +ModResult runtime_update(ModContext*, ModContext* subject, ModError* outError) { + const auto found = s_vms.find(subject); + if (found == s_vms.end()) { + return set_error(outError, MOD_INVALID_ARGUMENT, "Delegated mod is not active"); + } + Vm& vm = *found->second; + const size_t callbackCount = vm.updateRefs.size(); + if (callbackCount == 0) { + return MOD_OK; + } + + DeadlineScope deadline{vm, kUpdateBudget}; + std::string error; + for (size_t i = 0; i < callbackCount; ++i) { + const int ref = vm.updateRefs[i]; + if (!call_ref(vm, ref, 0, 0, kUpdateBudget, error)) { + return set_error(outError, MOD_ERROR, error); + } + } + return MOD_OK; +} + +ModResult runtime_deactivate(ModContext*, ModContext* subject, ModError*) { + const auto found = s_vms.find(subject); + if (found == s_vms.end()) { + return MOD_OK; + } + + { + Vm& vm = *found->second; + DeadlineScope deadline{vm, kLifecycleBudget}; + const size_t callbackCount = vm.shutdownRefs.size(); + for (size_t i = callbackCount; i > 0; --i) { + std::string error; + const int ref = vm.shutdownRefs[i - 1]; + if (!call_ref(vm, ref, 0, 0, kLifecycleBudget, error) && svc_log != nullptr) { + svc_log->write(subject, LOG_LEVEL_ERROR, error.c_str()); + } + } + } + s_vms.erase(found); + return MOD_OK; +} + +constexpr ModRuntimeService s_runtimeService{ + .header = SERVICE_HEADER(ModRuntimeService, 1, 0), + .activate = runtime_activate, + .update = runtime_update, + .deactivate = runtime_deactivate, +}; +EXPORT_SERVICE_AS(s_runtimeService, "dev.twilitrealm.luau"); + +} // namespace + +Vm::~Vm() { + if (state != nullptr) { + lua_close(state); + } +} + +Vm& vm_from_upvalue(lua_State* state) { + auto* vm = static_cast(lua_tolightuserdata(state, lua_upvalueindex(1))); + if (vm == nullptr) { + luaL_error(state, "missing Luau runtime context"); + } + return *vm; +} + +void push_vm_closure(lua_State* state, Vm& vm, lua_CFunction function, const char* name) { + lua_pushlightuserdata(state, &vm); + lua_pushcclosure(state, function, name, 1); +} + +void set_function(lua_State* state, Vm& vm, const char* name, lua_CFunction function) { + push_vm_closure(state, vm, function, name); + lua_setfield(state, -2, name); +} + +[[noreturn]] void service_unavailable(lua_State* state, const char* name) { + luaL_error(state, "%s is not available in this Dusklight build", name); +} + +void check_result(lua_State* state, ModResult result, const char* operation) { + if (result == MOD_OK) { + return; + } + const char* resultName = "error"; + switch (result) { + case MOD_UNAVAILABLE: + resultName = "unavailable"; + break; + case MOD_UNSUPPORTED: + resultName = "unsupported"; + break; + case MOD_CONFLICT: + resultName = "conflict"; + break; + case MOD_INVALID_ARGUMENT: + resultName = "invalid argument"; + break; + default: + break; + } + luaL_error(state, "%s failed: %s", operation, resultName); +} + +bool get_optional_bool(lua_State* state, int table, const char* field, bool fallback) { + lua_getfield(state, table, field); + const bool value = lua_isnil(state, -1) ? fallback : luaL_checkboolean(state, -1) != 0; + lua_pop(state, 1); + return value; +} + +bool to_int64(lua_State* state, int index, int64_t& outValue) { + if (lua_isinteger64(state, index)) { + outValue = lua_tointeger64(state, index, nullptr); + return true; + } + if (!lua_isnumber(state, index)) { + return false; + } + const double value = lua_tonumber(state, index); + constexpr double kMaxSafeInteger = 9007199254740991.0; + if (!std::isfinite(value) || value < -kMaxSafeInteger || value > kMaxSafeInteger || + std::trunc(value) != value) + { + return false; + } + outValue = static_cast(value); + return true; +} + +int64_t check_int64(lua_State* state, int index) { + int64_t value = 0; + if (!to_int64(state, index, value)) { + luaL_argerror(state, index, "integer value expected"); + } + return value; +} + +int64_t get_optional_int(lua_State* state, int table, const char* field, int64_t fallback) { + lua_getfield(state, table, field); + const int64_t value = lua_isnil(state, -1) ? fallback : check_int64(state, -1); + lua_pop(state, 1); + return value; +} + +double get_optional_number(lua_State* state, int table, const char* field, double fallback) { + lua_getfield(state, table, field); + const double value = lua_isnil(state, -1) ? fallback : luaL_checknumber(state, -1); + lua_pop(state, 1); + return value; +} + +std::string get_optional_string( + lua_State* state, int table, const char* field, std::string fallback) { + lua_getfield(state, table, field); + if (!lua_isnil(state, -1)) { + size_t length = 0; + const char* value = luaL_checklstring(state, -1, &length); + fallback.assign(value, length); + } + lua_pop(state, 1); + return fallback; +} + +int ref_optional_function(lua_State* state, int table, const char* field) { + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + return LUA_NOREF; + } + luaL_argexpected(state, lua_isfunction(state, -1), table, "function field"); + const int ref = lua_ref(state, -1); + lua_pop(state, 1); + return ref; +} + +int ref_required_function(lua_State* state, int table, const char* field) { + const int ref = ref_optional_function(state, table, field); + if (ref == LUA_NOREF) { + luaL_error(state, "field '%s' is required", field); + } + return ref; +} + +Callback& retain_callback(Vm& vm) { + auto callback = std::make_unique(); + callback->vm = &vm; + callback->refs.fill(LUA_NOREF); + vm.callbacks.push_back(std::move(callback)); + return *vm.callbacks.back(); +} + +bool call_ref(Vm& vm, int ref, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError) { + lua_State* state = vm.state; + lua_getref(state, ref); + if (!lua_isfunction(state, -1)) { + lua_pop(state, 1); + outError = "callback is no longer a function"; + return false; + } + if (argumentCount != 0) { + lua_insert(state, -argumentCount - 1); + } + return protected_call(state, vm, argumentCount, resultCount, budget, outError); +} + +void fail_callback(Vm& vm, std::string_view callbackName, std::string_view error) { + const std::string message = std::string{callbackName} + ": " + std::string{error}; + if (svc_host != nullptr) { + svc_host->fail(vm.subject, MOD_ERROR, message.c_str()); + } else if (svc_log != nullptr) { + svc_log->write(vm.subject, LOG_LEVEL_ERROR, message.c_str()); + } +} + +ModResult set_error(ModError* outError, ModResult result, std::string_view message) { + if (outError != nullptr && outError->struct_size >= sizeof(ModError)) { + outError->code = result; + const size_t size = std::min(message.size(), sizeof(outError->message) - 1); + std::memcpy(outError->message, message.data(), size); + outError->message[size] = '\0'; + } + return result; +} + +void create_handle_metatable( + lua_State* state, const char* name, const luaL_Reg* methods, const char* typeName) { + luaL_newmetatable(state, name); + luaL_register(state, nullptr, methods); + lua_pushvalue(state, -1); + lua_setfield(state, -2, "__index"); + lua_pushstring(state, typeName); + lua_setfield(state, -2, "__type"); + lua_setreadonly(state, -1, true); + lua_pop(state, 1); +} + +ScriptHandle& check_handle(lua_State* state, int index, const char* metatable, HandleKind kind) { + auto* handle = static_cast(luaL_checkudata(state, index, metatable)); + if (handle == nullptr || handle->kind != kind || handle->vm == nullptr || handle->value == 0) { + luaL_argerror(state, index, "stale handle"); + } + return *handle; +} + +void push_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind, const char* metatable, + ConfigVarType configType) { + auto* handle = static_cast(lua_newuserdata(state, sizeof(ScriptHandle))); + *handle = ScriptHandle{.vm = &vm, .value = value, .kind = kind, .configType = configType}; + luaL_getmetatable(state, metatable); + lua_setmetatable(state, -2); +} + +} // namespace luau_runtime + +extern "C" { +MOD_EXPORT ModResult mod_initialize(ModError*) { + FFlag::LuauIntegerType2.value = true; + FFlag::LuauIntegerLibrary.value = true; + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + luau_runtime::s_vms.clear(); + return MOD_OK; +} +} diff --git a/mods/luau_runtime/src/runtime.hpp b/mods/luau_runtime/src/runtime.hpp new file mode 100644 index 0000000000..2916a817e5 --- /dev/null +++ b/mods/luau_runtime/src/runtime.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "lua.h" +#include "lualib.h" + +#include "mods/api.h" +#include "mods/svc/config.h" +#include "mods/svc/host.h" +#include "mods/svc/log.h" +#include "mods/svc/overlay.h" +#include "mods/svc/resource.h" +#include "mods/svc/texture.h" +#include "mods/svc/ui.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace luau_runtime { + +constexpr size_t kMemoryLimit = 64u * 1024u * 1024u; +constexpr auto kUpdateBudget = std::chrono::milliseconds{250}; +constexpr auto kLifecycleBudget = std::chrono::seconds{5}; +constexpr auto kCallbackBudget = std::chrono::milliseconds{250}; + +struct MemoryBudget { + size_t used = 0; + size_t limit = kMemoryLimit; +}; + +struct Vm; + +struct Callback { + Vm* vm = nullptr; + std::array refs{}; + std::string returnedString; + int tag = 0; +}; + +struct Vm { + MemoryBudget memory; + lua_State* state = nullptr; + ModContext* subject = nullptr; + std::vector updateRefs; + std::vector shutdownRefs; + std::unordered_map moduleRefs; + std::unordered_set loadingModules; + std::vector> callbacks; + std::chrono::steady_clock::time_point deadline{}; + unsigned callDepth = 0; + bool deadlineActive = false; + + ~Vm(); +}; + +enum class HandleKind : uint8_t { + ConfigVar, + ConfigSubscription, + Overlay, + Texture, + UiWindow, + UiDialog, + UiElement, + UiStyle, + UiMenuTab, + UiList, +}; + +struct ScriptHandle { + Vm* vm = nullptr; + uint64_t value = 0; + HandleKind kind = HandleKind::ConfigVar; + ConfigVarType configType = CONFIG_VAR_BOOL; +}; + +using ModuleOpenFn = int (*)(lua_State* state); + +Vm& vm_from_upvalue(lua_State* state); +void push_vm_closure(lua_State* state, Vm& vm, lua_CFunction function, const char* name); +void set_function(lua_State* state, Vm& vm, const char* name, lua_CFunction function); + +[[noreturn]] void service_unavailable(lua_State* state, const char* name); +void check_result(lua_State* state, ModResult result, const char* operation); + +bool get_optional_bool(lua_State* state, int table, const char* field, bool fallback); +bool to_int64(lua_State* state, int index, int64_t& outValue); +int64_t check_int64(lua_State* state, int index); +int64_t get_optional_int(lua_State* state, int table, const char* field, int64_t fallback); +double get_optional_number(lua_State* state, int table, const char* field, double fallback); +std::string get_optional_string( + lua_State* state, int table, const char* field, std::string fallback = {}); +int ref_optional_function(lua_State* state, int table, const char* field); +int ref_required_function(lua_State* state, int table, const char* field); + +Callback& retain_callback(Vm& vm); +bool call_ref(Vm& vm, int ref, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError); +void fail_callback(Vm& vm, std::string_view callbackName, std::string_view error); +ModResult set_error(ModError* outError, ModResult result, std::string_view message); + +void create_handle_metatable( + lua_State* state, const char* name, const luaL_Reg* methods, const char* typeName); +ScriptHandle& check_handle(lua_State* state, int index, const char* metatable, HandleKind kind); +void push_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind, const char* metatable, + ConfigVarType configType = CONFIG_VAR_BOOL); + +void push_config_value(lua_State* state, const ConfigVarValue& value); +void push_ui_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind); + +int open_log(lua_State* state); +int open_host(lua_State* state); +int open_resource(lua_State* state); +int open_overlay(lua_State* state); +int open_texture(lua_State* state); +int open_config(lua_State* state); +int open_ui(lua_State* state); + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/ui.cpp b/mods/luau_runtime/src/ui.cpp new file mode 100644 index 0000000000..7c3acc1296 --- /dev/null +++ b/mods/luau_runtime/src/ui.cpp @@ -0,0 +1,856 @@ +#include "runtime.hpp" + +#include +#include +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kUiWindowMetatable[] = "dusklight.ui_window"; +constexpr char kUiDialogMetatable[] = "dusklight.ui_dialog"; +constexpr char kUiElementMetatable[] = "dusklight.ui_element"; +constexpr char kUiStyleMetatable[] = "dusklight.ui_style"; +constexpr char kUiMenuTabMetatable[] = "dusklight.ui_menu_tab"; +constexpr char kUiListMetatable[] = "dusklight.ui_list"; + +const char* ui_metatable(HandleKind kind) { + switch (kind) { + case HandleKind::UiWindow: + return kUiWindowMetatable; + case HandleKind::UiDialog: + return kUiDialogMetatable; + case HandleKind::UiStyle: + return kUiStyleMetatable; + case HandleKind::UiMenuTab: + return kUiMenuTabMetatable; + case HandleKind::UiList: + return kUiListMetatable; + default: + return kUiElementMetatable; + } +} + +ScriptHandle& check_ui_handle(lua_State* state, int index, HandleKind kind) { + return check_handle(state, index, ui_metatable(kind), kind); +} + +ScriptHandle& check_config_var(lua_State* state, int index) { + luaL_checktype(state, index, LUA_TUSERDATA); + auto* handle = static_cast(lua_touserdata(state, index)); + if (handle == nullptr || handle->kind != HandleKind::ConfigVar || handle->value == 0 || + handle->vm == nullptr) + { + luaL_argerror(state, index, "expected a live ConfigVar"); + } + return *handle; +} + +bool call_callback(Callback& callback, int ref, int argumentCount, int resultCount, + const char* name, std::string* outError = nullptr) { + std::string error; + if (call_ref(*callback.vm, ref, argumentCount, resultCount, kCallbackBudget, error)) { + return true; + } + if (outError != nullptr) { + *outError = std::move(error); + } else { + fail_callback(*callback.vm, name, error); + } + return false; +} + +ModResult call_build( + Callback& callback, int ref, int argumentCount, const char* name, ModError* outError) { + std::string error; + if (call_callback(callback, ref, argumentCount, 0, name, &error)) { + return MOD_OK; + } + return set_error(outError, MOD_ERROR, error); +} + +bool call_predicate(Callback& callback, int ref, int argumentCount, const char* name) { + if (!call_callback(callback, ref, argumentCount, 1, name)) { + return false; + } + lua_State* state = callback.vm->state; + const bool result = lua_toboolean(state, -1) != 0; + lua_pop(state, 1); + return result; +} + +void control_get(ModContext*, void* userData, UiControlValue* outValue) { + auto& callback = *static_cast(userData); + if (outValue == nullptr || !call_callback(callback, callback.refs[0], 0, 1, "control get")) { + return; + } + lua_State* state = callback.vm->state; + switch (static_cast(callback.tag)) { + case UI_CONTROL_TOGGLE: + outValue->bool_value = lua_toboolean(state, -1) != 0; + break; + case UI_CONTROL_NUMBER: + case UI_CONTROL_SELECT: { + int64_t value = 0; + if (!to_int64(state, -1, value)) { + fail_callback(*callback.vm, "control get", "callback must return an integer"); + } else { + outValue->int_value = value; + } + break; + } + case UI_CONTROL_STRING: + case UI_CONTROL_COLOR: + case UI_CONTROL_FILE_PICKER: { + size_t length = 0; + const char* value = lua_tolstring(state, -1, &length); + if (value == nullptr) { + fail_callback(*callback.vm, "control get", "callback must return a string"); + } else { + callback.returnedString.assign(value, length); + outValue->string_value = callback.returnedString.c_str(); + } + break; + } + default: + break; + } + lua_pop(state, 1); +} + +void control_set(ModContext*, void* userData, const UiControlValue* value) { + auto& callback = *static_cast(userData); + if (value == nullptr) { + return; + } + lua_State* state = callback.vm->state; + switch (static_cast(callback.tag)) { + case UI_CONTROL_TOGGLE: + lua_pushboolean(state, value->bool_value); + break; + case UI_CONTROL_NUMBER: + case UI_CONTROL_SELECT: + lua_pushinteger64(state, value->int_value); + break; + case UI_CONTROL_STRING: + case UI_CONTROL_COLOR: + case UI_CONTROL_FILE_PICKER: + lua_pushstring(state, value->string_value != nullptr ? value->string_value : ""); + break; + default: + return; + } + call_callback(callback, callback.refs[1], 1, 0, "control set"); +} + +bool control_disabled(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[3], 0, "control is_disabled"); +} + +bool control_modified(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[4], 0, "control is_modified"); +} + +bool control_selected(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[5], 0, "control is_selected"); +} + +void control_pressed(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + call_callback(callback, callback.refs[2], 0, 0, "control on_pressed"); +} + +ModResult panel_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 1, "panel build", outError); +} + +ModResult panel_update(ModContext*, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + return call_build(callback, callback.refs[1], 0, "panel update", outError); +} + +ModResult group_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 1, "group build", outError); +} + +ModResult tab_build(ModContext*, UiWindowHandle window, UiElementHandle left, UiElementHandle right, + void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, window, HandleKind::UiWindow); + push_ui_handle(callback.vm->state, *callback.vm, left, HandleKind::UiElement); + push_ui_handle(callback.vm->state, *callback.vm, right, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 3, "window tab build", outError); +} + +void window_closed(ModContext*, UiWindowHandle window, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, window, HandleKind::UiWindow); + call_callback(callback, callback.refs[0], 1, 0, "window on_closed"); +} + +void dialog_action(ModContext*, UiDialogHandle dialog, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, dialog, HandleKind::UiDialog); + call_callback(callback, callback.refs[0], 1, 0, "dialog action"); +} + +bool dialog_action_disabled(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[1], 0, "dialog action is_disabled"); +} + +void dialog_dismissed(ModContext*, UiDialogHandle dialog, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, dialog, HandleKind::UiDialog); + call_callback(callback, callback.refs[0], 1, 0, "dialog on_dismiss"); +} + +ModResult dialog_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[1], 1, "dialog build", outError); +} + +void menu_selected(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + call_callback(callback, callback.refs[0], 0, 0, "menu tab on_selected"); +} + +void list_pressed(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + call_callback(callback, callback.refs[0], 2, 0, "list on_pressed"); +} + +bool list_selected(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + return call_predicate(callback, callback.refs[1], 2, "list is_selected"); +} + +bool list_disabled(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + return call_predicate(callback, callback.refs[2], 2, "list is_disabled"); +} + +std::vector string_array(lua_State* state, int table, const char* field) { + std::vector result; + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + return result; + } + luaL_checktype(state, -1, LUA_TTABLE); + const int count = lua_objlen(state, -1); + result.reserve(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, -1, i); + result.emplace_back(luaL_checkstring(state, -1)); + lua_pop(state, 1); + } + lua_pop(state, 1); + return result; +} + +std::vector list_items(lua_State* state, int table, std::vector& labels) { + luaL_checktype(state, table, LUA_TTABLE); + const int count = lua_objlen(state, table); + labels.reserve(count); + std::vector items; + items.reserve(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, table, i); + luaL_checktype(state, -1, LUA_TTABLE); + labels.push_back(get_optional_string(state, -1, "label")); + UiListItem item = UI_LIST_ITEM_INIT; + item.key = static_cast(get_optional_int(state, -1, "key", 0)); + items.push_back(item); + lua_pop(state, 1); + } + for (size_t i = 0; i < items.size(); ++i) { + items[i].label = labels[i].c_str(); + } + return items; +} + +UiControlKind control_kind(lua_State* state, const std::string& kind) { + if (kind == "button") + return UI_CONTROL_BUTTON; + if (kind == "toggle") + return UI_CONTROL_TOGGLE; + if (kind == "number") + return UI_CONTROL_NUMBER; + if (kind == "string") + return UI_CONTROL_STRING; + if (kind == "select") + return UI_CONTROL_SELECT; + if (kind == "color") + return UI_CONTROL_COLOR; + if (kind == "group") + return UI_CONTROL_GROUP; + if (kind == "file_picker") + return UI_CONTROL_FILE_PICKER; + luaL_error(state, "unknown UI control kind '%s'", kind.c_str()); +} + +UiStyleScope style_scope(lua_State* state, const std::string& scope) { + if (scope == "prelaunch") + return UI_SCOPE_PRELAUNCH; + if (scope == "window") + return UI_SCOPE_WINDOW; + if (scope == "menu_bar") + return UI_SCOPE_MENU_BAR; + if (scope == "overlay") + return UI_SCOPE_OVERLAY; + if (scope == "touch_controls") + return UI_SCOPE_TOUCH_CONTROLS; + if (scope == "graphics_tuner") + return UI_SCOPE_GRAPHICS_TUNER; + luaL_error(state, "unknown UI style scope '%s'", scope.c_str()); +} + +int pane_add_section(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->pane_add_section(pane.vm->subject, pane.value, luaL_checkstring(state, 2)), + "ui pane_add_section"); + return 0; +} + +int pane_add_text(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_text(pane.vm->subject, pane.value, luaL_checkstring(state, 2), &element), + "ui pane_add_text"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_rml(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_rml(pane.vm->subject, pane.value, luaL_checkstring(state, 2), &element), + "ui pane_add_rml"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_progress(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_progress( + pane.vm->subject, pane.value, static_cast(luaL_checknumber(state, 2)), &element), + "ui pane_add_progress"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_control(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + luaL_checktype(state, 2, LUA_TTABLE); + + UiControlDesc desc = UI_CONTROL_DESC_INIT; + const std::string kind = get_optional_string(state, 2, "kind"); + const std::string label = get_optional_string(state, 2, "label"); + const std::string help = get_optional_string(state, 2, "help_rml"); + const std::string prefix = get_optional_string(state, 2, "prefix"); + const std::string suffix = get_optional_string(state, 2, "suffix"); + desc.kind = control_kind(state, kind); + desc.label = label.c_str(); + desc.help_rml = help.empty() ? nullptr : help.c_str(); + desc.min = get_optional_int(state, 2, "min", 0); + desc.max = get_optional_int(state, 2, "max", 0); + desc.step = get_optional_int(state, 2, "step", 1); + desc.prefix = prefix.empty() ? nullptr : prefix.c_str(); + desc.suffix = suffix.empty() ? nullptr : suffix.c_str(); + desc.max_length = static_cast(get_optional_int(state, 2, "max_length", 0)); + desc.color_alpha = get_optional_bool(state, 2, "color_alpha", false); + desc.directory_mode = get_optional_bool(state, 2, "directory_mode", false); + desc.string_set_mode = get_optional_string(state, 2, "string_set_mode") == "change" ? + UI_STRING_SET_ON_CHANGE : + UI_STRING_SET_ON_COMMIT; + + std::vector options = string_array(state, 2, "options"); + std::vector optionPointers; + optionPointers.reserve(options.size()); + for (const auto& option : options) + optionPointers.push_back(option.c_str()); + desc.options = optionPointers.data(); + desc.option_count = optionPointers.size(); + + std::vector presets = string_array(state, 2, "color_presets"); + std::vector presetPointers; + presetPointers.reserve(presets.size()); + for (const auto& preset : presets) + presetPointers.push_back(preset.c_str()); + desc.color_presets = presetPointers.data(); + desc.color_preset_count = presetPointers.size(); + + std::vector filterNames; + std::vector filterPatterns; + std::vector filters; + lua_getfield(state, 2, "file_filters"); + if (!lua_isnil(state, -1)) { + luaL_checktype(state, -1, LUA_TTABLE); + const int count = lua_objlen(state, -1); + filterNames.reserve(count); + filterPatterns.reserve(count); + filters.resize(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, -1, i); + filterNames.push_back(get_optional_string(state, -1, "name")); + filterPatterns.push_back(get_optional_string(state, -1, "pattern")); + lua_pop(state, 1); + } + for (int i = 0; i < count; ++i) { + filters[i] = {filterNames[i].c_str(), filterPatterns[i].c_str()}; + } + } + lua_pop(state, 1); + desc.file_filters = filters.data(); + desc.file_filter_count = filters.size(); + + Callback& callback = retain_callback(*pane.vm); + callback.tag = desc.kind; + callback.refs[2] = ref_optional_function(state, 2, "on_pressed"); + callback.refs[3] = ref_optional_function(state, 2, "is_disabled"); + callback.refs[4] = ref_optional_function(state, 2, "is_modified"); + callback.refs[5] = ref_optional_function(state, 2, "is_selected"); + desc.user_data = &callback; + desc.on_pressed = callback.refs[2] != LUA_NOREF ? control_pressed : nullptr; + desc.is_disabled = callback.refs[3] != LUA_NOREF ? control_disabled : nullptr; + desc.is_modified = callback.refs[4] != LUA_NOREF ? control_modified : nullptr; + desc.is_selected = callback.refs[5] != LUA_NOREF ? control_selected : nullptr; + + lua_getfield(state, 2, "config_var"); + if (!lua_isnil(state, -1)) { + auto& variable = check_config_var(state, -1); + desc.binding = UI_BINDING_CONFIG_VAR; + desc.config_var = variable.value; + } else if (desc.kind != UI_CONTROL_BUTTON && desc.kind != UI_CONTROL_GROUP) { + desc.binding = UI_BINDING_CALLBACKS; + callback.refs[0] = ref_required_function(state, 2, "get"); + callback.refs[1] = ref_required_function(state, 2, "set"); + desc.get = control_get; + desc.set = control_set; + } + lua_pop(state, 1); + + UiElementHandle element = 0; + check_result(state, svc_ui->pane_add_control(pane.vm->subject, pane.value, &desc, &element), + "ui pane_add_control"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_group(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + auto& target = check_ui_handle(state, 2, HandleKind::UiElement); + luaL_checktype(state, 3, LUA_TTABLE); + const std::string label = get_optional_string(state, 3, "label"); + Callback& callback = retain_callback(*pane.vm); + callback.refs[0] = ref_required_function(state, 3, "build"); + UiGroupDesc desc = UI_GROUP_DESC_INIT; + desc.label = label.c_str(); + desc.build = group_build; + desc.user_data = &callback; + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_group(pane.vm->subject, pane.value, target.value, &desc, &element), + "ui pane_add_group"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_list(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + luaL_checktype(state, 2, LUA_TTABLE); + Callback& callback = retain_callback(*pane.vm); + callback.refs[0] = ref_required_function(state, 2, "on_pressed"); + callback.refs[1] = ref_optional_function(state, 2, "is_selected"); + callback.refs[2] = ref_optional_function(state, 2, "is_disabled"); + + std::vector labels; + std::vector items; + lua_getfield(state, 2, "items"); + if (!lua_isnil(state, -1)) + items = list_items(state, -1, labels); + lua_pop(state, 1); + + UiListDesc desc = UI_LIST_DESC_INIT; + desc.items = items.data(); + desc.item_count = items.size(); + desc.on_pressed = list_pressed; + desc.is_selected = callback.refs[1] != LUA_NOREF ? list_selected : nullptr; + desc.is_disabled = callback.refs[2] != LUA_NOREF ? list_disabled : nullptr; + desc.user_data = &callback; + UiListHandle list = 0; + check_result(state, svc_ui->pane_add_list(pane.vm->subject, pane.value, &desc, &list), + "ui pane_add_list"); + push_ui_handle(state, *pane.vm, list, HandleKind::UiList); + return 1; +} + +int element_set_text(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_text(element.vm->subject, element.value, luaL_checkstring(state, 2)), + "ui elem_set_text"); + return 0; +} + +int element_set_rml(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_rml(element.vm->subject, element.value, luaL_checkstring(state, 2)), + "ui elem_set_rml"); + return 0; +} + +int element_set_progress(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_progress( + element.vm->subject, element.value, static_cast(luaL_checknumber(state, 2))), + "ui elem_set_progress"); + return 0; +} + +int element_set_class(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_class(element.vm->subject, element.value, luaL_checkstring(state, 2), + luaL_checkboolean(state, 3) != 0), + "ui elem_set_class"); + return 0; +} + +int list_set_items(lua_State* state) { + auto& list = check_ui_handle(state, 1, HandleKind::UiList); + std::vector labels; + auto items = list_items(state, 2, labels); + check_result(state, + svc_ui->list_set_items(list.vm->subject, list.value, items.data(), items.size()), + "ui list_set_items"); + return 0; +} + +int window_close(lua_State* state) { + auto& window = check_ui_handle(state, 1, HandleKind::UiWindow); + check_result(state, svc_ui->window_close(window.vm->subject, window.value), "ui window_close"); + window.value = 0; + return 0; +} + +int dialog_close(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, svc_ui->dialog_close(dialog.vm->subject, dialog.value), "ui dialog_close"); + dialog.value = 0; + return 0; +} + +int dialog_set_body(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, + svc_ui->dialog_set_body(dialog.vm->subject, dialog.value, luaL_checkstring(state, 2)), + "ui dialog_set_body"); + return 0; +} + +int dialog_set_icon(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, + svc_ui->dialog_set_icon(dialog.vm->subject, dialog.value, luaL_checkstring(state, 2)), + "ui dialog_set_icon"); + return 0; +} + +int style_unregister(lua_State* state) { + auto& style = check_ui_handle(state, 1, HandleKind::UiStyle); + check_result( + state, svc_ui->unregister_styles(style.vm->subject, style.value), "ui unregister_styles"); + style.value = 0; + return 0; +} + +int menu_tab_unregister(lua_State* state) { + auto& tab = check_ui_handle(state, 1, HandleKind::UiMenuTab); + check_result( + state, svc_ui->unregister_menu_tab(tab.vm->subject, tab.value), "ui unregister_menu_tab"); + tab.value = 0; + return 0; +} + +int register_mods_panel(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, 1, "build"); + callback.refs[1] = ref_optional_function(state, 1, "update"); + UiModsPanelDesc desc = UI_MODS_PANEL_DESC_INIT; + desc.build = panel_build; + desc.update = callback.refs[1] != LUA_NOREF ? panel_update : nullptr; + desc.user_data = &callback; + check_result(state, svc_ui->register_mods_panel(vm.subject, &desc), "ui register_mods_panel"); + return 0; +} + +int window_push(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + std::vector tabs; + std::vector titles; + lua_getfield(state, 1, "tabs"); + luaL_checktype(state, -1, LUA_TTABLE); + const int tabCount = lua_objlen(state, -1); + tabs.reserve(tabCount); + titles.reserve(tabCount); + for (int i = 1; i <= tabCount; ++i) { + lua_rawgeti(state, -1, i); + titles.push_back(get_optional_string(state, -1, "title")); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, -1, "build"); + callback.refs[1] = ref_optional_function(state, -1, "update"); + UiTabDesc tab = UI_TAB_DESC_INIT; + tab.build = tab_build; + tab.update = callback.refs[1] != LUA_NOREF ? panel_update : nullptr; + tab.user_data = &callback; + tabs.push_back(tab); + lua_pop(state, 1); + } + lua_pop(state, 1); + for (size_t i = 0; i < tabs.size(); ++i) + tabs[i].title = titles[i].c_str(); + + const std::string rcss = get_optional_string(state, 1, "rcss"); + Callback& closed = retain_callback(vm); + closed.refs[0] = ref_optional_function(state, 1, "on_closed"); + UiWindowDesc desc = UI_WINDOW_DESC_INIT; + desc.tabs = tabs.data(); + desc.tab_count = tabs.size(); + desc.rcss = rcss.empty() ? nullptr : rcss.c_str(); + desc.on_closed = closed.refs[0] != LUA_NOREF ? window_closed : nullptr; + desc.user_data = &closed; + UiWindowHandle window = 0; + check_result(state, svc_ui->window_push(vm.subject, &desc, &window), "ui window_push"); + push_ui_handle(state, vm, window, HandleKind::UiWindow); + return 1; +} + +UiDialogVariant dialog_variant(lua_State* state, const std::string& variant) { + if (variant.empty() || variant == "normal") + return UI_DIALOG_NORMAL; + if (variant == "warning") + return UI_DIALOG_WARNING; + if (variant == "danger") + return UI_DIALOG_DANGER; + luaL_error(state, "unknown dialog variant '%s'", variant.c_str()); +} + +int dialog_push(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string title = get_optional_string(state, 1, "title"); + const std::string body = get_optional_string(state, 1, "body_rml"); + const std::string icon = get_optional_string(state, 1, "icon"); + const std::string variant = get_optional_string(state, 1, "variant"); + + std::vector actions; + std::vector labels; + lua_getfield(state, 1, "actions"); + luaL_checktype(state, -1, LUA_TTABLE); + const int actionCount = lua_objlen(state, -1); + actions.reserve(actionCount); + labels.reserve(actionCount); + for (int i = 1; i <= actionCount; ++i) { + lua_rawgeti(state, -1, i); + labels.push_back(get_optional_string(state, -1, "label")); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_optional_function(state, -1, "on_pressed"); + callback.refs[1] = ref_optional_function(state, -1, "is_disabled"); + UiDialogAction action = UI_DIALOG_ACTION_INIT; + action.on_pressed = callback.refs[0] != LUA_NOREF ? dialog_action : nullptr; + action.is_disabled = callback.refs[1] != LUA_NOREF ? dialog_action_disabled : nullptr; + action.user_data = &callback; + action.keep_open = get_optional_bool(state, -1, "keep_open", false); + actions.push_back(action); + lua_pop(state, 1); + } + lua_pop(state, 1); + for (size_t i = 0; i < actions.size(); ++i) + actions[i].label = labels[i].c_str(); + + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_optional_function(state, 1, "on_dismiss"); + callback.refs[1] = ref_optional_function(state, 1, "build"); + UiDialogDesc desc = UI_DIALOG_DESC_INIT; + desc.title = title.c_str(); + desc.body_rml = body.c_str(); + desc.icon = icon.empty() ? nullptr : icon.c_str(); + desc.variant = dialog_variant(state, variant); + desc.actions = actions.data(); + desc.action_count = actions.size(); + desc.on_dismiss = callback.refs[0] != LUA_NOREF ? dialog_dismissed : nullptr; + desc.build = callback.refs[1] != LUA_NOREF ? dialog_build : nullptr; + desc.user_data = &callback; + UiDialogHandle dialog = 0; + check_result(state, svc_ui->dialog_push(vm.subject, &desc, &dialog), "ui dialog_push"); + push_ui_handle(state, vm, dialog, HandleKind::UiDialog); + return 1; +} + +int is_any_document_visible(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + bool visible = false; + check_result( + state, svc_ui->is_any_document_visible(vm.subject, &visible), "ui is_any_document_visible"); + lua_pushboolean(state, visible); + return 1; +} + +int register_styles(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const auto scope = style_scope(state, luaL_checkstring(state, 1)); + UiStyleHandle style = 0; + check_result(state, + svc_ui->register_styles(vm.subject, scope, luaL_checkstring(state, 2), &style), + "ui register_styles"); + push_ui_handle(state, vm, style, HandleKind::UiStyle); + return 1; +} + +int register_styles_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const auto scope = style_scope(state, luaL_checkstring(state, 1)); + UiStyleHandle style = 0; + check_result(state, + svc_ui->register_styles_file(vm.subject, scope, luaL_checkstring(state, 2), &style), + "ui register_styles_file"); + push_ui_handle(state, vm, style, HandleKind::UiStyle); + return 1; +} + +int register_menu_tab(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string label = get_optional_string(state, 1, "label"); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, 1, "on_selected"); + UiMenuTabDesc desc = UI_MENU_TAB_DESC_INIT; + desc.label = label.c_str(); + desc.on_selected = menu_selected; + desc.user_data = &callback; + UiMenuTabHandle tab = 0; + check_result(state, svc_ui->register_menu_tab(vm.subject, &desc, &tab), "ui register_menu_tab"); + push_ui_handle(state, vm, tab, HandleKind::UiMenuTab); + return 1; +} + +int push_toast(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string type = get_optional_string(state, 1, "type"); + const std::string title = get_optional_string(state, 1, "title_rml"); + const std::string body = get_optional_string(state, 1, "body_rml"); + UiToastDesc desc = UI_TOAST_DESC_INIT; + desc.type = type.empty() ? nullptr : type.c_str(); + desc.title_rml = title.empty() ? nullptr : title.c_str(); + desc.body_rml = body.empty() ? nullptr : body.c_str(); + desc.duration_ms = static_cast(get_optional_int(state, 1, "duration_ms", 0)); + check_result(state, svc_ui->push_toast(vm.subject, &desc), "ui push_toast"); + return 0; +} + +int get_clipboard_text(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + size_t size = 0; + check_result( + state, svc_ui->get_clipboard_text(vm.subject, nullptr, 0, &size), "ui get_clipboard_text"); + std::vector text(size + 1); + check_result(state, svc_ui->get_clipboard_text(vm.subject, text.data(), text.size(), nullptr), + "ui get_clipboard_text"); + lua_pushlstring(state, text.data(), size); + return 1; +} + +int set_clipboard_text(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + check_result(state, svc_ui->set_clipboard_text(vm.subject, luaL_checkstring(state, 1)), + "ui set_clipboard_text"); + return 0; +} + +} // namespace + +void push_ui_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind) { + push_handle(state, vm, value, kind, ui_metatable(kind)); +} + +int open_ui(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_ui == nullptr) { + service_unavailable(state, "UiService"); + } + static const luaL_Reg kElementMethods[] = { + {"add_section", pane_add_section}, + {"add_text", pane_add_text}, + {"add_rml", pane_add_rml}, + {"add_progress", pane_add_progress}, + {"add_control", pane_add_control}, + {"add_group", pane_add_group}, + {"add_list", pane_add_list}, + {"set_text", element_set_text}, + {"set_rml", element_set_rml}, + {"set_progress", element_set_progress}, + {"set_class", element_set_class}, + {nullptr, nullptr}, + }; + static const luaL_Reg kWindowMethods[] = {{"close", window_close}, {nullptr, nullptr}}; + static const luaL_Reg kDialogMethods[] = { + {"close", dialog_close}, + {"set_body", dialog_set_body}, + {"set_icon", dialog_set_icon}, + {nullptr, nullptr}, + }; + static const luaL_Reg kStyleMethods[] = {{"unregister", style_unregister}, {nullptr, nullptr}}; + static const luaL_Reg kMenuMethods[] = { + {"unregister", menu_tab_unregister}, {nullptr, nullptr}}; + static const luaL_Reg kListMethods[] = {{"set_items", list_set_items}, {nullptr, nullptr}}; + create_handle_metatable(state, kUiElementMetatable, kElementMethods, "UiElement"); + create_handle_metatable(state, kUiWindowMetatable, kWindowMethods, "UiWindow"); + create_handle_metatable(state, kUiDialogMetatable, kDialogMethods, "UiDialog"); + create_handle_metatable(state, kUiStyleMetatable, kStyleMethods, "UiStyle"); + create_handle_metatable(state, kUiMenuTabMetatable, kMenuMethods, "UiMenuTab"); + create_handle_metatable(state, kUiListMetatable, kListMethods, "UiList"); + + lua_newtable(state); + set_function(state, vm, "register_mods_panel", register_mods_panel); + set_function(state, vm, "window_push", window_push); + set_function(state, vm, "dialog_push", dialog_push); + set_function(state, vm, "is_any_document_visible", is_any_document_visible); + set_function(state, vm, "register_styles", register_styles); + set_function(state, vm, "register_styles_file", register_styles_file); + set_function(state, vm, "register_menu_tab", register_menu_tab); + set_function(state, vm, "push_toast", push_toast); + set_function(state, vm, "get_clipboard_text", get_clipboard_text); + set_function(state, vm, "set_clipboard_text", set_clipboard_text); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/randomizer b/mods/randomizer new file mode 160000 index 0000000000..641c9c9e0b --- /dev/null +++ b/mods/randomizer @@ -0,0 +1 @@ +Subproject commit 641c9c9e0bd04d51f9cb32e08daf7d134c65dcb1 diff --git a/mods/shadow_mod/CMakeLists.txt b/mods/shadow_mod/CMakeLists.txt new file mode 100644 index 0000000000..3f2e6b9412 --- /dev/null +++ b/mods/shadow_mod/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.25) +project(shadow_mod CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(shadow_mod + FEATURES game webgpu + SOURCES src/mod.cpp + MOD_JSON mod.json + RES_DIR res +) diff --git a/mods/shadow_mod/mod.json b/mods/shadow_mod/mod.json new file mode 100644 index 0000000000..dadc790f29 --- /dev/null +++ b/mods/shadow_mod/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.shadow_mod", + "name": "[Demo] Dynamic Shadows", + "version": "1.0.1", + "author": "encounter", + "description": "Demo showcasing dynamic shadow maps: re-renders geometry from the sun (or moon) point of view and composites real-time shadows over the world, with screen-space contact shadows for fine detail." +} diff --git a/mods/shadow_mod/res/shadow.wgsl b/mods/shadow_mod/res/shadow.wgsl new file mode 100644 index 0000000000..fe69b5bc3a --- /dev/null +++ b/mods/shadow_mod/res/shadow.wgsl @@ -0,0 +1,273 @@ +// Deferred shadow composite: reconstructs the world position of every scene pixel from the +// depth snapshot (CameraService matrices), transforms it into the light's clip space, and +// PCF-compares against the shadow map rendered earlier this frame. Drawn as a fullscreen +// triangle with multiply blending (srcFactor = Dst, dstFactor = Zero) before the HUD. +// +// Depth conventions (both reversed-Z): the scene snapshot has 1.0 at the camera near plane; +// the shadow map, rendered through the game's GX pipeline with a GC-convention light matrix, +// stores clip.z, i.e. 1.0 nearest to the light and 0.0 at the light frustum far plane. +// +// The optional contact-shadow raymarch follows Panos Karabelas' screen-space shadows +// (https://panoskarabelas.com/blog/posts/screen_space_shadows/, MIT via Spartan Engine): +// march from the pixel toward the light in view space and mark occlusion when the ray dips +// behind the depth buffer within a thickness threshold. + +struct Uniforms { + world_from_proj: mat4x4f, // scene depth unproject (camera) + view_from_proj: mat4x4f, // scene depth -> view space (contact shadows) + proj_from_view: mat4x4f, // view -> clip (contact shadows re-projection) + light_vp: mat4x4f, // world -> light receiver projection (UV/depth basis) + light_dir_view: vec3f, // direction *toward* the light, view space, normalized + bias: f32, // shadow-map depth bias (reversed-depth units) + size: vec2f, // shadow map size in texels + inv_size: vec2f, + edge_fade_width: f32, + strength: f32, // final darkening amount, horizon fade baked in + pcf_taps: f32, // 0 = single tap, 1 = 3x3, 2 = 5x5 + contact_enabled: f32, + contact_thickness: f32, // view-space thickness threshold + contact_length: f32, // view-space march distance + debug_mode: u32, // 0 = composite; nonzero modes are diagnostic views + _pad0: f32, +} + +@group(0) @binding(0) var scene_depth: texture_2d; +@group(0) @binding(1) var shadow_map: texture_2d; +@group(0) @binding(2) var uniforms: Uniforms; +@group(0) @binding(3) var light_color: texture_2d; + +struct VertexOutput { + @builtin(position) position: vec4f, + @location(0) uv: vec2f, +} + +@vertex +fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput { + var out: VertexOutput; + let uv = vec2f(f32((index << 1u) & 2u), f32(index & 2u)); + out.position = vec4f(uv * vec2f(2.0, -2.0) + vec2f(-1.0, 1.0), 0.0, 1.0); + out.uv = uv; + return out; +} + +fn load_shadow(texel: vec2) -> f32 { + let clamped = clamp(texel, vec2(0i), vec2(uniforms.size) - 1i); + return textureLoad(shadow_map, clamped, 0i).r; +} + +// Returns 1.0 when the pixel at light-space depth `receiver` is shadowed by the map texel. +fn shadow_test(texel: vec2, receiver: f32) -> f32 { + // Reversed depth: a larger stored value is closer to the light, i.e. an occluder. + return select(0.0, 1.0, load_shadow(texel) > receiver + uniforms.bias); +} + +// Bilinearly weighted comparison (what a hardware comparison sampler would do): filter the +// four *comparison results*, never the depths themselves. This is what turns per-texel +// staircases into smooth penumbra edges. +fn shadow_compare_bilinear(light_uv: vec2f, receiver: f32) -> f32 { + let coordinates = light_uv * uniforms.size - 0.5; + let base = floor(coordinates); + let fraction = coordinates - base; + let texel = vec2(base); + let s00 = shadow_test(texel, receiver); + let s10 = shadow_test(texel + vec2(1i, 0i), receiver); + let s01 = shadow_test(texel + vec2(0i, 1i), receiver); + let s11 = shadow_test(texel + vec2(1i, 1i), receiver); + let top = mix(s00, s10, fraction.x); + let bottom = mix(s01, s11, fraction.x); + return mix(top, bottom, fraction.y); +} + +fn sample_shadow_pcf(light_uv: vec2f, receiver: f32) -> f32 { + let radius = i32(uniforms.pcf_taps); + var sum = 0.0; + var count = 0.0; + for (var y = -radius; y <= radius; y += 1i) { + for (var x = -radius; x <= radius; x += 1i) { + let offset = vec2f(f32(x), f32(y)) * uniforms.inv_size; + sum += shadow_compare_bilinear(light_uv + offset, receiver); + count += 1.0; + } + } + return sum / count; +} + +// Softly fades shadows out over a small band near the shadow-map edge so receivers do not +// disappear abruptly when they leave the light's coverage area. +fn shadow_edge_fade(light_uv: vec2f) -> f32 { + let edge_texels = uniforms.edge_fade_width; + let edge_uv = edge_texels * max(uniforms.inv_size.x, uniforms.inv_size.y); + let distance_to_edge = min(min(light_uv.x, 1.0 - light_uv.x), min(light_uv.y, 1.0 - light_uv.y)); + // Avoid division by zero when the fade width is zero (no fade). + return select(1.0, saturate(distance_to_edge / edge_uv), edge_uv > 0.0); +} + +fn scene_depth_at(uv: vec2f) -> f32 { + let size = vec2(textureDimensions(scene_depth)); + let texel = clamp(vec2(uv * vec2f(size)), vec2(0i), size - 1i); + return textureLoad(scene_depth, texel, 0i).r; +} + +fn light_color_at(uv: vec2f) -> vec4f { + let size = vec2(textureDimensions(light_color)); + let texel = clamp(vec2(uv * vec2f(size)), vec2(0i), size - 1i); + return textureLoad(light_color, texel, 0i); +} + +fn light_depth_debug_at(uv: vec2f) -> vec3f { + let texel = vec2(uv * uniforms.size); + let depth = load_shadow(texel); + if depth <= 0.0 { + return vec3f(0.0); + } + + let dx = abs(depth - load_shadow(texel + vec2(1i, 0i))); + let dy = abs(depth - load_shadow(texel + vec2(0i, 1i))); + let edge = saturate((dx + dy) * 500.0); + let shade = saturate(depth * 1.5); + let bands = 0.08 * (0.5 + 0.5 * cos(depth * 96.0)); + return vec3f(saturate(shade + bands + edge)); +} + +fn view_position(uv: vec2f, depth: f32) -> vec3f { + let ndc = vec4f(uv.x * 2.0 - 1.0, 1.0 - 2.0 * uv.y, depth, 1.0); + let position = uniforms.view_from_proj * ndc; + return position.xyz / position.w; +} + +// Interleaved gradient noise (Jimenez); fixed per-pixel dither, no temporal rotation. +fn ign(pixel: vec2f) -> f32 { + return fract(52.9829189 * fract(dot(pixel, vec2f(0.06711056, 0.00583715)))); +} + +// Screen-space contact shadows: march toward the light in view space; occluded when the ray +// passes behind the depth buffer by less than the thickness threshold. Faded out with view +// distance: position reconstruction error grows with distance while the thickness threshold +// is fixed, so far surfaces (and anything translucent composited over them - clouds, fog) +// would otherwise pick up dithered false occlusion. Contact shadows are a near-field effect. +fn contact_shadow_fade(view_distance: f32) -> f32 { + return saturate(1.0 - (view_distance - 3000.0) / 5000.0); +} + +fn contact_shadow(origin: vec3f, pixel: vec2f) -> f32 { + let steps = 24; + let step_vec = uniforms.light_dir_view * (uniforms.contact_length / f32(steps)); + var ray = origin + step_vec * ign(pixel); + for (var i = 0; i < steps; i += 1) { + ray += step_vec; + // Project the ray position back to screen space. + let clip = uniforms.proj_from_view * vec4f(ray, 1.0); + if clip.w <= 0.0 { + break; + } + let ray_ndc = clip.xyz / clip.w; + let ray_uv = vec2f(0.5 + 0.5 * ray_ndc.x, 0.5 - 0.5 * ray_ndc.y); + if any(ray_uv < vec2f(0.0)) || any(ray_uv > vec2f(1.0)) { + break; + } + let scene = scene_depth_at(ray_uv); + if scene <= 0.0 { + continue; + } + // Compare in view space: positive delta = the ray is behind the scene surface. + let scene_z = view_position(ray_uv, scene).z; + let delta = scene_z - ray.z; // view space looks down -z; larger z = closer + if delta > 0.0 && delta < uniforms.contact_thickness { + return 1.0; + } + } + return 0.0; +} + +@fragment +fn fs_main(in: VertexOutput) -> @location(0) vec4f { + let depth = scene_depth_at(in.uv); + if uniforms.debug_mode == 1u { + let value = load_shadow(vec2(in.uv * uniforms.size)); + return vec4f(value, value, value, 1.0); + } + if uniforms.debug_mode == 9u || uniforms.debug_mode == 10u { + let color = light_color_at(in.uv); + let color_luma = max(color.r, max(color.g, color.b)); + let depth_color = light_depth_debug_at(in.uv); + let rgb = select(depth_color, color.rgb, color_luma > (1.0 / 255.0)); + return vec4f(rgb, 1.0); + } + + if depth <= 0.0 { + // Sky / cleared pixels receive no shadow. + if uniforms.debug_mode >= 3u { + return vec4f(0.0, 0.0, 0.0, 1.0); + } + return vec4f(1.0); + } + + let ndc = vec4f(in.uv.x * 2.0 - 1.0, 1.0 - 2.0 * in.uv.y, depth, 1.0); + let world4 = uniforms.world_from_proj * ndc; + let world = world4.xyz / world4.w; + + let light_clip = uniforms.light_vp * vec4f(world, 1.0); + let light_ndc = light_clip.xyz / light_clip.w; + let receiver = light_ndc.z; // reversed light depth, 1 = nearest to the light + let light_uv = vec2f(0.5 + 0.5 * light_ndc.x, 0.5 - 0.5 * light_ndc.y); + let in_shadow_bounds = all(light_uv >= vec2f(0.0)) && all(light_uv <= vec2f(1.0)) && + receiver > 0.0 && receiver <= 1.0; + let shadow_depth = load_shadow(vec2(light_uv * uniforms.size)); + + if uniforms.debug_mode == 4u { + let valid = select(0.0, 1.0, in_shadow_bounds); + return vec4f(saturate(light_uv.x), saturate(light_uv.y), valid, 1.0); + } + + if uniforms.debug_mode == 5u { + if !in_shadow_bounds { + return vec4f(0.0, 0.0, 0.0, 1.0); + } + let current_compare = select(0.0, 1.0, shadow_depth > receiver + uniforms.bias); + let opposite_compare = select(0.0, 1.0, shadow_depth < receiver - uniforms.bias); + return vec4f(current_compare, 0.0, opposite_compare, 1.0); + } + + if uniforms.debug_mode == 6u { + let valid = select(0.0, 1.0, in_shadow_bounds); + return vec4f(saturate(receiver), shadow_depth, valid, 1.0); + } + + if uniforms.debug_mode == 7u { + let beyond_far = select(0.0, 1.0, receiver <= 0.0); + let valid_depth = select(0.0, 1.0, receiver > 0.0 && receiver <= 1.0); + let before_near = select(0.0, 1.0, receiver > 1.0); + return vec4f(beyond_far, valid_depth, before_near, 1.0); + } + + if uniforms.debug_mode == 8u { + let valid_x = select(0.0, 1.0, light_uv.x >= 0.0 && light_uv.x <= 1.0); + let valid_y = select(0.0, 1.0, light_uv.y >= 0.0 && light_uv.y <= 1.0); + let valid_depth = select(0.0, 1.0, receiver > 0.0 && receiver <= 1.0); + return vec4f(valid_x, valid_y, valid_depth, 1.0); + } + + var occlusion = 0.0; + if in_shadow_bounds { + occlusion = sample_shadow_pcf(light_uv, receiver); + occlusion *= shadow_edge_fade(light_uv); + } + + if uniforms.debug_mode == 3u { + return vec4f(occlusion, occlusion, occlusion, 1.0); + } + + if uniforms.contact_enabled != 0.0 && occlusion < 1.0 { + let origin = view_position(in.uv, depth); + let fade = contact_shadow_fade(-origin.z); + if fade > 0.0 { + occlusion = max(occlusion, fade * contact_shadow(origin, in.position.xy)); + } + } + + let value = 1.0 - uniforms.strength * occlusion; + if uniforms.debug_mode == 2u { + return vec4f(value, value, value, 1.0); + } + return vec4f(value, value, value, 1.0); +} diff --git a/mods/shadow_mod/src/mod.cpp b/mods/shadow_mod/src/mod.cpp new file mode 100644 index 0000000000..fa4056040b --- /dev/null +++ b/mods/shadow_mod/src/mod.cpp @@ -0,0 +1,1349 @@ +// Dynamic shadows example mod. +// +// Replays the game's populated opaque scene draw lists into an offscreen pass with a light-space +// projection to produce a shadow map of the live scene, then composites deferred shadows over the +// world (scene depth + CameraService unproject + PCF against the map). +// +// The optional contact-shadow raymarch in the composite is reimplemented from Panos Karabelas' +// screen-space shadows (MIT, via Spartan Engine); see res/shadow.wgsl. + +#include "global.h" + +#include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/J3DU/J3DUClipper.h" +#include "JSystem/JMath/JMath.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" +#include "d/d_kankyo_rain.h" +#include "dolphin/gx/GXAurora.h" +#include "dolphin/gx/GXGet.h" +#include "dolphin/gx/GXPixel.h" +#include "dolphin/gx/GXTransform.h" +#include "m_Do/m_Do_mtx.h" +#include "mods/service.hpp" +#include "mods/svc/camera.h" +#include "mods/svc/config.h" +#include "mods/svc/gfx.h" +#include "mods/svc/hook.h" +#include "mods/svc/hook.hpp" +#include "mods/svc/log.h" +#include "mods/svc/resource.h" +#include "mods/svc/ui.h" +#include "mods/svc/window.h" + +#include +#include +#include +#include +#include +#include + +DEFINE_MOD(); +IMPORT_SERVICE(ConfigService, svc_config); +IMPORT_SERVICE(ResourceService, svc_resource); +IMPORT_SERVICE(UiService, svc_ui); +IMPORT_SERVICE(GfxService, svc_gfx); +IMPORT_SERVICE(CameraService, svc_camera); +IMPORT_SERVICE(HookService, svc_hook); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(WindowService, svc_window); + +namespace { + +ConfigVarHandle g_cvarEnabled = 0; +ConfigVarHandle g_cvarMapSize = 0; +ConfigVarHandle g_cvarNoFrustumClipping = 0; +ConfigVarHandle g_cvarStrength = 0; +ConfigVarHandle g_cvarPcf = 0; +ConfigVarHandle g_cvarBias = 0; +ConfigVarHandle g_cvarBoxRadius = 0; +ConfigVarHandle g_cvarEdgeFadeWidth = 0; +ConfigVarHandle g_cvarContactShadows = 0; +ConfigVarHandle g_cvarDebugView = 0; + +GfxDrawTypeHandle g_drawType = 0; +GfxStageHookHandle g_sceneBeginHook = 0; +GfxStageHookHandle g_sceneAfterTerrainHook = 0; +GfxStageHookHandle g_sceneAfterOpaqueHook = 0; +GfxStageHookHandle g_frameBeforeHudHook = 0; +UiWindowHandle g_controlsWindow = 0; +ResourceBuffer g_shaderSource = RESOURCE_BUFFER_INIT; +GfxDeviceInfo g_deviceInfo = GFX_DEVICE_INFO_INIT; +GfxRenderTargetLayout g_sceneTargetLayout = GFX_RENDER_TARGET_LAYOUT_INIT; +WGPURenderPipeline g_compositePipeline = nullptr; // multiply blend +WGPURenderPipeline g_compositeDebugPipeline = nullptr; // no blend (debug views) +WGPUBindGroupLayout g_compositeLayout = nullptr; +WGPUBindGroupLayout g_compositeDebugLayout = nullptr; +WGPURenderPipeline g_debugPresentPipeline = nullptr; +WGPUBindGroupLayout g_debugPresentLayout = nullptr; +WGPUTextureFormat g_debugPresentFormat = WGPUTextureFormat_Undefined; +WindowHandle g_debugWindow = 0; +GfxPresentTargetHandle g_debugPresentTarget = 0; + +struct MapPassOutput { + bool ready = false; + WGPUTextureView shadowMap = nullptr; // frame-pooled + WGPUTextureView lightColor = nullptr; // frame-pooled + uint32_t mapSize = 0; + Mtx44 lightVp; // world -> light receiver projection, row-major game convention + float dirToLightWorld[3]; // toward the light, normalized + float fade = 0.0f; +}; + +MapPassOutput g_mapPass; +bool g_replayingSceneLists = false; + +constexpr float kLightDistance = 30000.0f; +constexpr float kLightNear = 100.0f; +constexpr float kLightFar = 60000.0f; +constexpr float kMaxLightLookahead = 10000.0f; +constexpr float kSunMoonDistance = 80000.0f; +constexpr float kSunMoonZDistance = -48000.0f; + +DEFINE_HOOK(&dDlst_shadowControl_c::imageDraw, GameShadowImageDraw); +DEFINE_HOOK(&dDlst_shadowControl_c::draw, GameShadowDraw); +DEFINE_HOOK(&drawCloudShadow, CloudShadowDraw); +DEFINE_HOOK(static_cast(&J3DUClipper::clip), + ClipperSphereClip); +DEFINE_HOOK( + static_cast(&J3DUClipper::clip), + ClipperBoxClip); +DEFINE_HOOK(GXCopyTex, CopyTex); + +// Mirror of the WGSL Uniforms struct (keep in sync with res/shadow.wgsl). +struct ShadowUniforms { + float world_from_proj[16]; + float view_from_proj[16]; + float proj_from_view[16]; + float light_vp[16]; + float light_dir_view[3]; + float bias; + float size[2]; + float inv_size[2]; + float edge_fade_width; + float strength; + float pcf_taps; + float contact_enabled; + float contact_thickness; + float contact_length; + uint32_t debug_mode; + float _pad0; +}; +static_assert(sizeof(ShadowUniforms) % 16 == 0); + +struct DrawPayload { + WGPUTextureView sceneDepth; // frame-pooled + WGPUTextureView shadowMap; // frame-pooled + WGPUTextureView lightColor; // frame-pooled + uint32_t uniform_offset; + uint32_t uniform_size; + uint32_t debug_mode; +}; +static_assert(sizeof(DrawPayload) <= GFX_INLINE_DRAW_PAYLOAD_SIZE); +static_assert(std::is_trivially_copyable_v); + +struct LightCamera { + Mtx view; + Mtx44 ortho; + Mtx44 vp; + float dirToLight[3]; + float fade = 0.0f; +}; + +struct SceneCamera { + bool valid = false; + bool raw_valid = false; + CameraInfo info = CAMERA_INFO_INIT; + Mtx raw_view; + f32 raw_projection[7]{}; + Mtx44 raw_projection_mtx; +}; + +SceneCamera g_sceneCamera; + +struct ActualLightDebugState { + bool active = false; + Mtx savedView; + f32 savedProjection[7]; + f32 savedViewport[6]; + u32 savedScissor[4]; +}; + +ActualLightDebugState g_actualLightDebug; + +struct replay_scope { + replay_scope() { g_replayingSceneLists = true; } + ~replay_scope() { g_replayingSceneLists = false; } +}; + +int64_t get_int_option(ConfigVarHandle handle, int64_t fallback) { + int64_t value = fallback; + if (handle == 0 || svc_config->get_int(mod_ctx, handle, &value) != MOD_OK) { + return fallback; + } + return value; +} + +bool get_bool_option(ConfigVarHandle handle, bool fallback) { + bool value = fallback; + if (handle == 0 || svc_config->get_bool(mod_ctx, handle, &value) != MOD_OK) { + return fallback; + } + return value; +} + +int64_t get_debug_mode() { + return std::clamp(get_int_option(g_cvarDebugView, 0), 0, 10); +} + +bool debug_window_open() { + return g_debugWindow != 0 && g_debugPresentTarget != 0; +} + +ModResult close_debug_window() { + if (g_debugPresentTarget != 0) { + const auto result = svc_gfx->unregister_present_target(mod_ctx, g_debugPresentTarget); + if (result != MOD_OK) { + return result; + } + g_debugPresentTarget = 0; + } + if (g_debugWindow != 0) { + const auto result = svc_window->destroy_window(mod_ctx, g_debugWindow); + if (result != MOD_OK) { + return result; + } + g_debugWindow = 0; + } + return MOD_OK; +} + +void on_debug_window_event(ModContext*, WindowHandle, const WindowEvent* event, void*) { + if (event->type == WINDOW_EVENT_CLOSE_REQUESTED && close_debug_window() != MOD_OK) { + svc_log->error(mod_ctx, "failed to close shadow debug window"); + } +} + +bool matrix_ready(const Mtx m) { + float basis = 0.0f; + for (int r = 0; r < 3; ++r) { + for (int c = 0; c < 4; ++c) { + if (!std::isfinite(m[r][c])) { + return false; + } + if (c < 3) { + basis += std::fabs(m[r][c]); + } + } + } + return basis > 0.001f; +} + +bool projection_vector_ready(const f32 projection[7]) { + if (projection[0] != 0.0f) { + return false; + } + for (int i = 1; i < 7; ++i) { + if (!std::isfinite(projection[i])) { + return false; + } + } + return std::fabs(projection[1]) > 0.001f && std::fabs(projection[3]) > 0.001f && + std::fabs(projection[6]) > 0.001f; +} + +// Row-major game matrix -> column-major WGSL layout (matching CameraService). +void store_column_major(const Mtx44 in, float out[16]) { + for (int c = 0; c < 4; ++c) { + for (int r = 0; r < 4; ++r) { + out[c * 4 + r] = in[r][c]; + } + } +} + +void copy_projection(const Mtx44 in, Mtx44 out) { + std::memcpy(out, in, sizeof(Mtx44)); + // TODO: check GfxDeviceInfo.uses_reversed_z + for (int c = 0; c < 4; ++c) { + out[2][c] = -out[2][c]; + } +} + +void projection_vector_from_perspective(const Mtx44 projection, f32 out[7]) { + out[0] = 0.0f; + out[1] = projection[0][0]; + out[2] = projection[0][2]; + out[3] = projection[1][1]; + out[4] = projection[1][2]; + out[5] = projection[2][2]; + out[6] = projection[2][3]; +} + +const view_class* stage_game_view(const GfxStageContext* stageCtx) { + if (stageCtx == nullptr || stageCtx->struct_size < sizeof(GfxStageContext) || + stageCtx->game_view == nullptr) + { + return nullptr; + } + return static_cast(stageCtx->game_view); +} + +bool capture_raw_camera( + const view_class* gameView, Mtx outView, Mtx44 outProjectionMtx, f32 outProjection[7]) { + if (gameView == nullptr || !matrix_ready(gameView->viewMtx)) { + return false; + } + std::memcpy(outProjectionMtx, gameView->projMtx, sizeof(Mtx44)); + projection_vector_from_perspective(outProjectionMtx, outProjection); + if (!projection_vector_ready(outProjection)) { + return false; + } + cMtx_copy(gameView->viewMtx, outView); + return true; +} + +bool capture_scene_camera(const GfxStageContext* stageCtx) { + g_sceneCamera.valid = false; + g_sceneCamera.raw_valid = false; + const view_class* gameView = stage_game_view(stageCtx); + if (gameView == nullptr) { + return false; + } + CameraInfo info = CAMERA_INFO_INIT; + if (svc_camera->get_camera(mod_ctx, stageCtx->game_view, &info) != MOD_OK) { + return false; + } + g_sceneCamera.info = info; + g_sceneCamera.valid = true; + g_sceneCamera.raw_valid = capture_raw_camera(gameView, g_sceneCamera.raw_view, + g_sceneCamera.raw_projection_mtx, g_sceneCamera.raw_projection); + return true; +} + +bool get_replay_camera(Mtx outView, Mtx44 outProjectionMtx, f32 outProjection[7]) { + if (g_sceneCamera.raw_valid && matrix_ready(g_sceneCamera.raw_view)) { + cMtx_copy(g_sceneCamera.raw_view, outView); + std::memcpy(outProjectionMtx, g_sceneCamera.raw_projection_mtx, + sizeof(g_sceneCamera.raw_projection_mtx)); + std::memcpy( + outProjection, g_sceneCamera.raw_projection, sizeof(g_sceneCamera.raw_projection)); + return projection_vector_ready(outProjection); + } + + return false; +} + +float wrap_daytime(float daytime) { + if (!std::isfinite(daytime)) { + return 180.0f; + } + float wrapped = std::fmod(daytime, 360.0f); + if (wrapped < 0.0f) { + wrapped += 360.0f; + } + return wrapped; +} + +float daytime_percent(float max, float min, float value) { + const float range = max - min; + if (range == 0.0f) { + return 1.0f; + } + const float percent = 1.0f - ((max - value) / range); + return percent < 1.0f ? percent : 1.0f; +} + +float sun_moon_angle(float daytime) { + daytime = wrap_daytime(daytime); + if (daytime >= 90.0f && daytime <= 270.0f) { + return daytime_percent(270.0f, 90.0f, daytime) * 150.0f + 105.0f; + } + + float angle = daytime; + if (angle < 90.0f) { + angle += 360.0f; + } + + angle = daytime_percent(450.0f, 270.0f, angle) * 210.0f + 255.0f; + if (angle > 360.0f) { + angle -= 360.0f; + } + return angle; +} + +cXyz sun_moon_offset(float daytime) { + const float angle = DEG_TO_RAD(sun_moon_angle(daytime)); + const float angleSin = sinf(angle); + const float angleCos = cosf(angle); + return cXyz{ + angleSin * kSunMoonDistance, -angleCos * kSunMoonDistance, angleCos * kSunMoonZDistance}; +} + +bool build_composite_pipeline( + bool blend, WGPURenderPipeline& outPipeline, WGPUBindGroupLayout& outLayout) { + WGPUShaderSourceWGSL wgsl = WGPU_SHADER_SOURCE_WGSL_INIT; + wgsl.code = {static_cast(g_shaderSource.data), g_shaderSource.size}; + WGPUShaderModuleDescriptor moduleDesc = WGPU_SHADER_MODULE_DESCRIPTOR_INIT; + moduleDesc.nextInChain = &wgsl.chain; + moduleDesc.label = {"shadow composite", WGPU_STRLEN}; + WGPUShaderModule module = wgpuDeviceCreateShaderModule(g_deviceInfo.device, &moduleDesc); + if (module == nullptr) { + return false; + } + + // Multiply blend: fragment output is the darkening multiplier (result = dst * src). + WGPUBlendState blendState{ + .color = {.operation = WGPUBlendOperation_Add, + .srcFactor = WGPUBlendFactor_Dst, + .dstFactor = WGPUBlendFactor_Zero}, + .alpha = {.operation = WGPUBlendOperation_Add, + .srcFactor = WGPUBlendFactor_Zero, + .dstFactor = WGPUBlendFactor_One}, + }; + WGPUColorTargetState colorTargets[GFX_MAX_COLOR_ATTACHMENTS]; + const uint32_t colorTargetCount = gfx_init_color_target_states( + &g_sceneTargetLayout, colorTargets, blend ? &blendState : nullptr, WGPUColorWriteMask_All); + WGPUFragmentState fragment = WGPU_FRAGMENT_STATE_INIT; + fragment.module = module; + fragment.entryPoint = {"fs_main", WGPU_STRLEN}; + fragment.targetCount = colorTargetCount; + fragment.targets = colorTargets; + WGPUDepthStencilState depthStencil = WGPU_DEPTH_STENCIL_STATE_INIT; + depthStencil.format = g_sceneTargetLayout.depth_stencil_format; + depthStencil.depthWriteEnabled = WGPUOptionalBool_False; + depthStencil.depthCompare = WGPUCompareFunction_Always; + + WGPURenderPipelineDescriptor pipelineDesc = WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT; + pipelineDesc.label = {blend ? "shadow composite" : "shadow composite (debug)", WGPU_STRLEN}; + pipelineDesc.vertex.module = module; + pipelineDesc.vertex.entryPoint = {"vs_main", WGPU_STRLEN}; + pipelineDesc.primitive.topology = WGPUPrimitiveTopology_TriangleList; + pipelineDesc.depthStencil = &depthStencil; + pipelineDesc.multisample.count = g_sceneTargetLayout.sample_count; + pipelineDesc.fragment = &fragment; + outPipeline = wgpuDeviceCreateRenderPipeline(g_deviceInfo.device, &pipelineDesc); + wgpuShaderModuleRelease(module); + if (outPipeline == nullptr) { + return false; + } + outLayout = wgpuRenderPipelineGetBindGroupLayout(outPipeline, 0); + return outLayout != nullptr; +} + +void release_debug_present_pipeline() { + if (g_debugPresentPipeline != nullptr) { + wgpuRenderPipelineRelease(g_debugPresentPipeline); + g_debugPresentPipeline = nullptr; + } + if (g_debugPresentLayout != nullptr) { + wgpuBindGroupLayoutRelease(g_debugPresentLayout); + g_debugPresentLayout = nullptr; + } + g_debugPresentFormat = WGPUTextureFormat_Undefined; +} + +bool ensure_debug_present_pipeline(const GfxPresentContext& ctx) { + if (g_debugPresentPipeline != nullptr && g_debugPresentFormat == ctx.target_format) { + return true; + } + release_debug_present_pipeline(); + + WGPUShaderSourceWGSL wgsl = WGPU_SHADER_SOURCE_WGSL_INIT; + wgsl.code = {static_cast(g_shaderSource.data), g_shaderSource.size}; + WGPUShaderModuleDescriptor moduleDesc = WGPU_SHADER_MODULE_DESCRIPTOR_INIT; + moduleDesc.nextInChain = &wgsl.chain; + moduleDesc.label = {"shadow debug present", WGPU_STRLEN}; + WGPUShaderModule module = wgpuDeviceCreateShaderModule(ctx.device, &moduleDesc); + if (module == nullptr) { + return false; + } + + WGPUColorTargetState colorTarget = WGPU_COLOR_TARGET_STATE_INIT; + colorTarget.format = ctx.target_format; + WGPUFragmentState fragment = WGPU_FRAGMENT_STATE_INIT; + fragment.module = module; + fragment.entryPoint = {"fs_main", WGPU_STRLEN}; + fragment.targetCount = 1; + fragment.targets = &colorTarget; + + WGPURenderPipelineDescriptor pipelineDesc = WGPU_RENDER_PIPELINE_DESCRIPTOR_INIT; + pipelineDesc.label = {"shadow debug present", WGPU_STRLEN}; + pipelineDesc.vertex.module = module; + pipelineDesc.vertex.entryPoint = {"vs_main", WGPU_STRLEN}; + pipelineDesc.primitive.topology = WGPUPrimitiveTopology_TriangleList; + pipelineDesc.multisample.count = 1; + pipelineDesc.fragment = &fragment; + g_debugPresentPipeline = wgpuDeviceCreateRenderPipeline(ctx.device, &pipelineDesc); + wgpuShaderModuleRelease(module); + if (g_debugPresentPipeline == nullptr) { + return false; + } + g_debugPresentLayout = wgpuRenderPipelineGetBindGroupLayout(g_debugPresentPipeline, 0); + if (g_debugPresentLayout == nullptr) { + release_debug_present_pipeline(); + return false; + } + g_debugPresentFormat = ctx.target_format; + return true; +} + +WGPUBindGroup create_composite_bind_group(WGPUDevice device, WGPUBindGroupLayout layout, + WGPUBuffer uniformBuffer, const DrawPayload& data) { + if (data.sceneDepth == nullptr || data.shadowMap == nullptr || data.lightColor == nullptr || + layout == nullptr || uniformBuffer == nullptr) + { + return nullptr; + } + + WGPUBindGroupEntry entries[4] = {WGPU_BIND_GROUP_ENTRY_INIT, WGPU_BIND_GROUP_ENTRY_INIT, + WGPU_BIND_GROUP_ENTRY_INIT, WGPU_BIND_GROUP_ENTRY_INIT}; + entries[0].binding = 0; + entries[0].textureView = data.sceneDepth; + entries[1].binding = 1; + entries[1].textureView = data.shadowMap; + entries[2].binding = 2; + entries[2].buffer = uniformBuffer; + entries[2].offset = data.uniform_offset; + entries[2].size = data.uniform_size; + entries[3].binding = 3; + entries[3].textureView = data.lightColor; + WGPUBindGroupDescriptor bindGroupDesc = WGPU_BIND_GROUP_DESCRIPTOR_INIT; + bindGroupDesc.layout = layout; + bindGroupDesc.entryCount = 4; + bindGroupDesc.entries = entries; + return wgpuDeviceCreateBindGroup(device, &bindGroupDesc); +} + +// Render worker thread: fullscreen deferred-shadow composite. +void on_draw( + ModContext*, const GfxDrawContext* ctx, const void* payload, size_t payloadSize, void*) { + if (payloadSize != sizeof(DrawPayload) || ctx->layout.key != g_sceneTargetLayout.key) { + return; + } + DrawPayload data; + std::memcpy(&data, payload, sizeof(data)); + + WGPURenderPipeline pipeline = + data.debug_mode != 0 ? g_compositeDebugPipeline : g_compositePipeline; + WGPUBindGroupLayout layout = data.debug_mode != 0 ? g_compositeDebugLayout : g_compositeLayout; + if (pipeline == nullptr) { + return; + } + + WGPUBindGroup bindGroup = + create_composite_bind_group(ctx->device, layout, ctx->uniform_buffer, data); + if (bindGroup == nullptr) { + return; + } + + wgpuRenderPassEncoderSetPipeline(ctx->pass, pipeline); + wgpuRenderPassEncoderSetBindGroup(ctx->pass, 0, bindGroup, 0, nullptr); + wgpuRenderPassEncoderDraw(ctx->pass, 3, 1, 0, 0); + wgpuBindGroupRelease(bindGroup); +} + +// Render worker thread: draw the selected diagnostic into the auxiliary surface. +void on_debug_present( + ModContext*, const GfxPresentContext* ctx, const void* payload, size_t payloadSize, void*) { + WGPUBindGroup bindGroup = nullptr; + if (payloadSize == sizeof(DrawPayload)) { + DrawPayload data; + std::memcpy(&data, payload, sizeof(data)); + if (ensure_debug_present_pipeline(*ctx)) { + bindGroup = create_composite_bind_group( + ctx->device, g_debugPresentLayout, ctx->uniform_buffer, data); + } + } + + WGPURenderPassColorAttachment colorAttachment = WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT; + colorAttachment.view = ctx->target_view; + colorAttachment.loadOp = WGPULoadOp_Clear; + colorAttachment.storeOp = WGPUStoreOp_Store; + colorAttachment.clearValue = WGPUColor{0.0, 0.0, 0.0, 1.0}; + WGPURenderPassDescriptor passDesc = WGPU_RENDER_PASS_DESCRIPTOR_INIT; + passDesc.label = {"shadow debug present", WGPU_STRLEN}; + passDesc.colorAttachmentCount = 1; + passDesc.colorAttachments = &colorAttachment; + WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(ctx->encoder, &passDesc); + + if (bindGroup != nullptr) { + wgpuRenderPassEncoderSetPipeline(pass, g_debugPresentPipeline); + wgpuRenderPassEncoderSetBindGroup(pass, 0, bindGroup, 0, nullptr); + wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); + wgpuBindGroupRelease(bindGroup); + } + + wgpuRenderPassEncoderEnd(pass); + wgpuRenderPassEncoderRelease(pass); +} + +ModResult open_debug_window() { + if (g_debugWindow != 0) { + return MOD_CONFLICT; + } + + WindowDesc windowDesc = WINDOW_DESC_INIT; + windowDesc.title = "Shadow Debug View"; + windowDesc.width = 720; + windowDesc.height = 480; + windowDesc.on_event = on_debug_window_event; + auto result = svc_window->create_window(mod_ctx, &windowDesc, &g_debugWindow); + if (result != MOD_OK) { + return result; + } + + GfxPresentTargetDesc presentDesc = GFX_PRESENT_TARGET_DESC_INIT; + presentDesc.label = "Shadow debug surface"; + presentDesc.render = on_debug_present; + result = svc_gfx->register_window_present_target( + mod_ctx, g_debugWindow, &presentDesc, &g_debugPresentTarget); + if (result != MOD_OK) { + close_debug_window(); + return result; + } + + result = svc_window->show_window(mod_ctx, g_debugWindow); + if (result != MOD_OK) { + close_debug_window(); + } + return result; +} + +void on_toggle_debug_window(ModContext*, void*) { + const auto result = debug_window_open() ? close_debug_window() : open_debug_window(); + if (result != MOD_OK) { + svc_log->error(mod_ctx, debug_window_open() ? "failed to close shadow debug window" : + "failed to open shadow debug window"); + } +} + +// Picks the sun or moon (whichever is above the horizon) and returns the normalized +// world-space direction *toward* the light plus a horizon fade factor. False = no light. +bool compute_light(float outDirToLight[3], float& outFade) { + dScnKy_env_light_c* envLight = dKy_getEnvlight(); + if (envLight == nullptr) { + return false; + } + + // The packet positions can be stale when this runs before the world lists are consumed. + // Mirror dScnKy_env_light_c::setSunpos() so --time-of-day directly moves the debug light. + const float daytime = wrap_daytime(dComIfGs_getTime()); + cXyz offset = sun_moon_offset(daytime); + if (offset.y <= 0.0f) { + offset = sun_moon_offset(daytime + 180.0f); + } + const float length = std::sqrt(offset.x * offset.x + offset.y * offset.y + offset.z * offset.z); + if (length < 1.0f) { + return false; + } + outDirToLight[0] = offset.x / length; + outDirToLight[1] = offset.y / length; + outDirToLight[2] = offset.z / length; + // Fade shadows out as the light approaches the horizon (elevation below ~11 degrees). + outFade = std::clamp((outDirToLight[1] - 0.05f) / 0.15f, 0.0f, 1.0f); + return outFade > 0.0f; +} + +bool build_light_camera(const Mtx cameraView, uint32_t mapSize, float radius, LightCamera& out) { + Mtx cameraInvView; + cMtx_inverse(cameraView, cameraInvView); + if (!matrix_ready(cameraInvView)) { + return false; + } + if (!compute_light(out.dirToLight, out.fade)) { + return false; + } + + // Fit a fixed-radius ortho box around the visible play space. The camera target alone can sit + // behind the receiver field, while a far-horizon center drops foreground receivers. + const cXyz eye{cameraInvView[0][3], cameraInvView[1][3], cameraInvView[2][3]}; + cXyz forward{-cameraInvView[0][2], -cameraInvView[1][2], -cameraInvView[2][2]}; + const float forwardLength = + std::sqrt(forward.x * forward.x + forward.y * forward.y + forward.z * forward.z); + if (forwardLength > 0.001f) { + forward = forward / forwardLength; + } else { + forward = cXyz{0.0f, 0.0f, -1.0f}; + } + const float lookahead = std::min(radius * 0.75f, kMaxLightLookahead); + const cXyz center = eye + forward * lookahead; + const cXyz lightEye{center.x + out.dirToLight[0] * kLightDistance, + center.y + out.dirToLight[1] * kLightDistance, + center.z + out.dirToLight[2] * kLightDistance}; + const bool nearlyVertical = std::fabs(out.dirToLight[1]) > 0.99f; + cXyz up = nearlyVertical ? cXyz{0.0f, 0.0f, 1.0f} : cXyz{0.0f, 1.0f, 0.0f}; + + cMtx_lookAt(out.view, &lightEye, ¢er, &up, 0); + const float unitsPerTexel = (2.0f * radius) / static_cast(mapSize); + out.view[0][3] = std::round(out.view[0][3] / unitsPerTexel) * unitsPerTexel; + out.view[1][3] = std::round(out.view[1][3] / unitsPerTexel) * unitsPerTexel; + + C_MTXOrtho(out.ortho, radius, -radius, -radius, radius, kLightNear, kLightFar); + cMtx_concatProjView(out.ortho, out.view, out.vp); + return true; +} + +bool build_light_replay_projection( + const LightCamera& lightCamera, const Mtx cameraView, Mtx44 out) { + Mtx cameraInvView; + cMtx_inverse(cameraView, cameraInvView); + if (!matrix_ready(cameraInvView)) { + return false; + } + + Mtx lightFromCamera; + cMtx_concat(lightCamera.view, cameraInvView, lightFromCamera); + cMtx_concatProjView(lightCamera.ortho, lightFromCamera, out); + return true; +} + +// True when the dynamic shadow pass will run this frame: enabled, a camera exists, and the +// sun or moon is above the horizon. Also gates the game-shadow skip hooks, which fire earlier +// in the painter than our SCENE_AFTER_TERRAIN hook. +bool dynamic_shadows_wanted() { + if (!get_bool_option(g_cvarEnabled, true)) { + return false; + } + if (!g_sceneCamera.raw_valid) { + return false; + } + float dirToLight[3]; + float fade = 0.0f; + return compute_light(dirToLight, fade); +} + +HookAction on_game_shadow_pre(ModContext*, void*, void*, void*) { + if (!dynamic_shadows_wanted()) { + return HOOK_CONTINUE; + } + return HOOK_SKIP_ORIGINAL; +} + +HookAction on_frustum_clip_pre(ModContext*, void*, void* retval, void*) { + if (!get_bool_option(g_cvarNoFrustumClipping, false) || !dynamic_shadows_wanted()) { + return HOOK_CONTINUE; + } + if (retval != nullptr) { + *static_cast(retval) = 0; + } + return HOOK_SKIP_ORIGINAL; +} + +HookAction on_copy_tex_pre(ModContext*, void*, void*, void*) { + return g_replayingSceneLists ? HOOK_SKIP_ORIGINAL : HOOK_CONTINUE; +} + +void draw_opaque_scene_lists() { + dComIfGd_drawOpaListBG(); + dComIfGd_drawOpaListDarkBG(); + dComIfGd_drawOpaListMiddle(); + dComIfGd_drawOpaList(); + dComIfGd_drawOpaListDark(); + dComIfGd_drawOpaListPacket(); +} + +bool draw_lists_ready() { + return dComIfGd_getOpaListBG() != nullptr && dComIfGd_getOpaList() != nullptr && + dComIfGd_getOpaListDark() != nullptr && dComIfGd_getXluListBG() != nullptr && + dComIfGd_getListPacket() != nullptr; +} + +void render_shadow_map( + const Mtx replayView, const Mtx44 replayProjectionMtx, const f32 replayProjection[7]); + +void restore_actual_light_debug() { + if (!g_actualLightDebug.active) { + return; + } + + j3dSys.setViewMtx(g_actualLightDebug.savedView); + GXSetProjectionv(g_actualLightDebug.savedProjection); + GXSetViewport(g_actualLightDebug.savedViewport[0], g_actualLightDebug.savedViewport[1], + g_actualLightDebug.savedViewport[2], g_actualLightDebug.savedViewport[3], + g_actualLightDebug.savedViewport[4], g_actualLightDebug.savedViewport[5]); + GXSetScissor(g_actualLightDebug.savedScissor[0], g_actualLightDebug.savedScissor[1], + g_actualLightDebug.savedScissor[2], g_actualLightDebug.savedScissor[3]); + dKy_setLight(); + J3DShape::resetVcdVatCache(); + + g_actualLightDebug.active = false; +} + +void on_scene_begin(ModContext*, const GfxStageContext* stageCtx, void*) { + restore_actual_light_debug(); + capture_scene_camera(stageCtx); + if (!get_bool_option(g_cvarEnabled, true) || get_debug_mode() != 9 || debug_window_open()) { + return; + } + + Mtx cameraView; + if (!g_sceneCamera.raw_valid || !matrix_ready(g_sceneCamera.raw_view)) { + return; + } + cMtx_copy(g_sceneCamera.raw_view, cameraView); + + const uint32_t mapSize = 1024u << std::clamp(get_int_option(g_cvarMapSize, 1), 0, 2); + const float radius = + static_cast(std::clamp(get_int_option(g_cvarBoxRadius, 6000), 1000, 20000)); + LightCamera lightCamera{}; + if (!build_light_camera(cameraView, mapSize, radius, lightCamera)) { + return; + } + Mtx44 lightProjection; + if (!build_light_replay_projection(lightCamera, cameraView, lightProjection)) { + return; + } + + cMtx_copy(cameraView, g_actualLightDebug.savedView); + GXGetProjectionv(g_actualLightDebug.savedProjection); + GXGetViewportv(g_actualLightDebug.savedViewport); + GXGetScissor(&g_actualLightDebug.savedScissor[0], &g_actualLightDebug.savedScissor[1], + &g_actualLightDebug.savedScissor[2], &g_actualLightDebug.savedScissor[3]); + g_actualLightDebug.active = true; + + j3dSys.setViewMtx(g_actualLightDebug.savedView); + GXSetProjectionFull(lightProjection); + dKy_setLight(); + J3DShape::resetVcdVatCache(); +} + +void on_scene_after_terrain(ModContext*, const GfxStageContext* stageCtx, void*) { + if (g_mapPass.ready) { + return; + } + + const view_class* gameView = stage_game_view(stageCtx); + Mtx replayView; + Mtx44 replayProjectionMtx; + f32 replayProjection[7]; + if (!capture_raw_camera(gameView, replayView, replayProjectionMtx, replayProjection)) { + return; + } + render_shadow_map(replayView, replayProjectionMtx, replayProjection); +} + +// Game thread, after the draw handlers have populated next frame's scene lists: replay opaque scene +// geometry from the light's point of view. +void render_shadow_map( + const Mtx replayView, const Mtx44 replayProjectionMtx, const f32 replayProjection[7]) { + if (g_mapPass.ready || !get_bool_option(g_cvarEnabled, true)) { + return; + } + const int64_t debugMode = get_debug_mode(); + if (debugMode == 9 && !debug_window_open()) { + return; + } + if (!matrix_ready(replayView)) { + return; + } + Mtx replayViewMtx; + cMtx_copy(replayView, replayViewMtx); + + const uint32_t mapSize = 1024u << std::clamp(get_int_option(g_cvarMapSize, 1), 0, 2); + const bool cameraReplayDebug = debugMode == 10; + const float radius = + static_cast(std::clamp(get_int_option(g_cvarBoxRadius, 6000), 1000, 20000)); + LightCamera lightCamera{}; + if (!build_light_camera(replayViewMtx, mapSize, radius, lightCamera)) { + return; + } + Mtx44 lightReplayProjection; + if (!build_light_replay_projection(lightCamera, replayViewMtx, lightReplayProjection)) { + return; + } + f32 savedProjection[7]; + GXGetProjectionv(savedProjection); + f32 savedViewport[6]; + GXGetViewportv(savedViewport); + u32 savedScissor[4]; + GXGetScissor(&savedScissor[0], &savedScissor[1], &savedScissor[2], &savedScissor[3]); + Mtx savedView; + cMtx_copy(j3dSys.getViewMtx(), savedView); + + auto restore_game_camera = [&]() { + j3dSys.setViewMtx(savedView); + GXSetProjectionv(savedProjection); + GXSetViewport(savedViewport[0], savedViewport[1], savedViewport[2], savedViewport[3], + savedViewport[4], savedViewport[5]); + GXSetScissor(savedScissor[0], savedScissor[1], savedScissor[2], savedScissor[3]); + dKy_setLight(); + }; + auto set_replay_camera = [&]() { + j3dSys.setViewMtx(replayViewMtx); + if (cameraReplayDebug) { + GXSetProjectionv(replayProjection); + } else { + GXSetProjectionFull(lightReplayProjection); + } + dKy_setLight(); + }; + if (!draw_lists_ready()) { + return; + } + if (svc_gfx->create_pass(mod_ctx, mapSize, mapSize) != MOD_OK) { + return; + } + J3DShape::resetVcdVatCache(); + + set_replay_camera(); + GXSetViewport(0.0f, 0.0f, static_cast(mapSize), static_cast(mapSize), 0.0f, 1.0f); + GXSetViewportRender( + 0.0f, 0.0f, static_cast(mapSize), static_cast(mapSize), 0.0f, 1.0f); + GXSetScissorRender(0, 0, mapSize, mapSize); + dKy_setLight(); + GXSetColorUpdate(GX_TRUE); + GXSetAlphaUpdate(GX_TRUE); + GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + { + replay_scope replay; + draw_opaque_scene_lists(); + } + j3dSys.reinitGX(); + J3DShape::resetVcdVatCache(); + restore_game_camera(); + + GfxResolveDesc resolveDesc = GFX_RESOLVE_DESC_INIT; + resolveDesc.color = true; + resolveDesc.depth = true; + GfxResolvedTargets resolved = GFX_RESOLVED_TARGETS_INIT; + if (svc_gfx->resolve_pass(mod_ctx, &resolveDesc, &resolved) != MOD_OK || + resolved.color == nullptr || resolved.depth == nullptr) + { + return; + } + + j3dSys.reinitGX(); + J3DShape::resetVcdVatCache(); + restore_game_camera(); + + g_mapPass.lightColor = resolved.color; + g_mapPass.shadowMap = resolved.depth; + g_mapPass.mapSize = mapSize; + copy_projection(lightCamera.vp, g_mapPass.lightVp); + std::memcpy( + g_mapPass.dirToLightWorld, lightCamera.dirToLight, sizeof(g_mapPass.dirToLightWorld)); + g_mapPass.fade = lightCamera.fade; + g_mapPass.ready = true; +} + +// Game thread, after opaque scene draws and before translucent/fog overlays: deferred composite. +void on_scene_after_opaque(ModContext*, const GfxStageContext*, void*) { + const int64_t debugMode = get_debug_mode(); + const bool presentDebug = debug_window_open(); + restore_actual_light_debug(); + + if (presentDebug && debugMode == 0) { + svc_gfx->push_present(mod_ctx, g_debugPresentTarget, nullptr, 0); + } + + const MapPassOutput mapPass = std::exchange(g_mapPass, {}); + if (debugMode == 9 && !debug_window_open()) { + return; + } + if (!mapPass.ready || mapPass.shadowMap == nullptr || mapPass.lightColor == nullptr) { + if (presentDebug && debugMode != 0) { + svc_gfx->push_present(mod_ctx, g_debugPresentTarget, nullptr, 0); + } + return; + } + if (!g_sceneCamera.valid) { + if (presentDebug && debugMode != 0) { + svc_gfx->push_present(mod_ctx, g_debugPresentTarget, nullptr, 0); + } + return; + } + const CameraInfo& camera = g_sceneCamera.info; + + GfxResolveDesc resolveDesc = GFX_RESOLVE_DESC_INIT; + resolveDesc.color = false; + resolveDesc.depth = true; + GfxResolvedTargets resolved = GFX_RESOLVED_TARGETS_INIT; + if (svc_gfx->resolve_pass(mod_ctx, &resolveDesc, &resolved) != MOD_OK || + resolved.depth == nullptr) + { + if (presentDebug && debugMode != 0) { + svc_gfx->push_present(mod_ctx, g_debugPresentTarget, nullptr, 0); + } + return; + } + + ShadowUniforms uniforms{}; + std::memcpy(uniforms.world_from_proj, camera.world_from_proj, sizeof(uniforms.world_from_proj)); + std::memcpy(uniforms.view_from_proj, camera.view_from_proj, sizeof(uniforms.view_from_proj)); + std::memcpy(uniforms.proj_from_view, camera.proj_from_view, sizeof(uniforms.proj_from_view)); + store_column_major(mapPass.lightVp, uniforms.light_vp); + // Rotate the world-space light direction into view space (w = 0). + for (int r = 0; r < 3; ++r) { + uniforms.light_dir_view[r] = + camera.view_from_world[0 * 4 + r] * mapPass.dirToLightWorld[0] + + camera.view_from_world[1 * 4 + r] * mapPass.dirToLightWorld[1] + + camera.view_from_world[2 * 4 + r] * mapPass.dirToLightWorld[2]; + } + // Bias is configured in world units along the light direction. + uniforms.bias = + static_cast(std::clamp(get_int_option(g_cvarBias, 15), 0, 200)) / + (kLightFar - kLightNear); + uniforms.size[0] = static_cast(mapPass.mapSize); + uniforms.size[1] = static_cast(mapPass.mapSize); + uniforms.inv_size[0] = 1.0f / uniforms.size[0]; + uniforms.inv_size[1] = 1.0f / uniforms.size[1]; + uniforms.edge_fade_width = + static_cast(std::clamp(get_int_option(g_cvarEdgeFadeWidth, 32), 0, 256)); + uniforms.strength = + mapPass.fade * + static_cast(std::clamp(get_int_option(g_cvarStrength, 45), 0, 100)) / + 100.0f; + uniforms.pcf_taps = static_cast(std::clamp(get_int_option(g_cvarPcf, 1), 0, 2)); + uniforms.contact_enabled = get_bool_option(g_cvarContactShadows, false) ? 1.0f : 0.0f; + uniforms.contact_thickness = 25.0f; + uniforms.contact_length = 60.0f; + // Camera Replay intentionally uses the gameplay-camera offscreen pass instead of the light + // shadow map, so it remains diagnostic on both windows. Other external diagnostics leave the + // main window on the normal shadow composite. + uniforms.debug_mode = presentDebug && debugMode != 10 ? 0u : static_cast(debugMode); + + GfxRange uniformRange{0, 0}; + if (svc_gfx->push_uniform(mod_ctx, &uniforms, sizeof(uniforms), &uniformRange) != MOD_OK) { + return; + } + const DrawPayload payload{resolved.depth, mapPass.shadowMap, mapPass.lightColor, + uniformRange.offset, uniformRange.size, uniforms.debug_mode}; + svc_gfx->push_draw(mod_ctx, g_drawType, &payload, sizeof(payload)); + + if (presentDebug && debugMode != 0) { + uniforms.debug_mode = static_cast(debugMode); + GfxRange debugUniformRange{0, 0}; + if (svc_gfx->push_uniform(mod_ctx, &uniforms, sizeof(uniforms), &debugUniformRange) != + MOD_OK) + { + return; + } + const DrawPayload debugPayload{resolved.depth, mapPass.shadowMap, mapPass.lightColor, + debugUniformRange.offset, debugUniformRange.size, uniforms.debug_mode}; + svc_gfx->push_present(mod_ctx, g_debugPresentTarget, &debugPayload, sizeof(debugPayload)); + } +} + +// Frame tail hook: only needed to restore light-view debug camera state before HUD. +void on_frame_before_hud(ModContext*, const GfxStageContext*, void*) { + restore_actual_light_debug(); +} + +void add_control(UiElementHandle pane, const UiControlDesc& desc) { + svc_ui->pane_add_control(mod_ctx, pane, &desc, nullptr); +} + +void add_toggle(UiElementHandle pane, const char* label, ConfigVarHandle cvar, const char* help) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_TOGGLE; + control.label = label; + control.help_rml = help; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = cvar; + add_control(pane, control); +} + +void add_select(UiElementHandle pane, const char* label, ConfigVarHandle cvar, const char** options, + uint32_t optionCount, const char* help) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_SELECT; + control.label = label; + control.help_rml = help; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = cvar; + control.options = options; + control.option_count = optionCount; + add_control(pane, control); +} + +void add_number(UiElementHandle pane, const char* label, ConfigVarHandle cvar, int64_t min, + int64_t max, int64_t step, const char* suffix, const char* help) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_NUMBER; + control.label = label; + control.help_rml = help; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = cvar; + control.min = min; + control.max = max; + control.step = step; + control.suffix = suffix; + add_control(pane, control); +} + +ModResult build_controls_tab( + ModContext*, UiWindowHandle, UiElementHandle left, UiElementHandle right, void*, ModError*) { + (void)right; + + svc_ui->pane_add_section(mod_ctx, left, "Shadow Map"); + add_toggle(left, "Enabled", g_cvarEnabled, "Enables dynamic shadows."); + static const char* kMapSizes[] = {"1024", "2048", "4096"}; + add_select(left, "Map Size", g_cvarMapSize, kMapSizes, 3, + "Shadow map resolution. Larger is sharper and slower."); + add_toggle(left, "No Frustum Clipping", g_cvarNoFrustumClipping, + "Keeps camera-frustum-culled objects in draw lists so off-screen objects can cast " + "dynamic shadows. This can be expensive."); + add_number(left, "Coverage", g_cvarBoxRadius, 1000, 20000, 500, nullptr, + "Radius of the shadowed area around the camera, in world units. Smaller is sharper."); + add_number(left, "Fade Out", g_cvarEdgeFadeWidth, 0, 256, 32, " texels", + "Fade out shadows gradually near the edge of the coverage area."); + + svc_ui->pane_add_section(mod_ctx, left, "Appearance"); + add_number(left, "Strength", g_cvarStrength, 0, 100, 5, "%", "How dark shadowed areas become."); + static const char* kPcfOptions[] = {"Off", "3x3", "5x5"}; + add_select(left, "Soft Shadows", g_cvarPcf, kPcfOptions, 3, + "Percentage-closer filtering tap pattern; softens shadow edges."); + add_number(left, "Bias", g_cvarBias, 0, 200, 5, nullptr, + "Depth bias in world units. Raise to remove shadow acne; lower to reduce peter-panning."); + add_toggle(left, "Contact Shadows", g_cvarContactShadows, + "Adds a screen-space raymarch for small-scale contact darkening the map misses."); + + svc_ui->pane_add_section(mod_ctx, left, "Debug"); + static const char* kDebugOptions[] = {"Off", "Shadow Map", "Shadow Factor", "Occlusion", + "Light UV", "Compare Sign", "Depth Values", "Receiver Range", "Bounds", "Light View", + "Camera Replay"}; + add_select(left, "Debug View", g_cvarDebugView, kDebugOptions, 11, + "Shadow Map: light-space depth buffer
Shadow Factor: final " + "darkening term
Occlusion: map comparison result
Light UV: receiver " + "projection coverage
Compare Sign: current comparison in red and opposite " + "comparison in blue
Depth Values: receiver depth in red and map depth in green
" + "Receiver Range: beyond-far in red, valid depth in green, and before-near in blue
" + "Bounds: valid X in red, valid Y in green, and valid depth in blue
Light View: " + "renders the game world directly from the light camera
Camera Replay: " + "captures the same draw-list replay from the gameplay camera"); + UiControlDesc debugWindowControl = UI_CONTROL_DESC_INIT; + debugWindowControl.kind = UI_CONTROL_BUTTON; + debugWindowControl.label = "Open / Close Debug Window"; + debugWindowControl.help_rml = + "Shows the selected debug view in an auxiliary WebGPU window. Standard diagnostics leave " + "the main view on the normal shadow composite."; + debugWindowControl.on_pressed = on_toggle_debug_window; + add_control(left, debugWindowControl); + return MOD_OK; +} + +void on_controls_window_closed(ModContext*, UiWindowHandle, void*) { + g_controlsWindow = 0; +} + +void on_open_controls(ModContext*, void*) { + if (g_controlsWindow != 0) { + return; + } + UiTabDesc tabs[1] = {UI_TAB_DESC_INIT}; + tabs[0].title = "Controls"; + tabs[0].build = build_controls_tab; + UiWindowDesc desc = UI_WINDOW_DESC_INIT; + desc.tabs = tabs; + desc.tab_count = 1; + desc.on_closed = on_controls_window_closed; + if (svc_ui->window_push(mod_ctx, &desc, &g_controlsWindow) != MOD_OK) { + svc_log->error(mod_ctx, "failed to open shadow controls window"); + } +} + +ModResult build_panel(ModContext*, UiElementHandle panel, void*, ModError*) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_TOGGLE; + control.label = "Enabled"; + control.binding = UI_BINDING_CONFIG_VAR; + control.config_var = g_cvarEnabled; + add_control(panel, control); + + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_BUTTON; + control.label = "Open Controls"; + control.on_pressed = on_open_controls; + add_control(panel, control); + + control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_BUTTON; + control.label = "Open / Close Debug Window"; + control.on_pressed = on_toggle_debug_window; + add_control(panel, control); + return MOD_OK; +} + +ModResult register_bool_option( + const char* name, bool defaultValue, ConfigVarHandle& outHandle, ModError* error) { + ConfigVarDesc cvarDesc = CONFIG_VAR_DESC_INIT; + cvarDesc.name = name; + cvarDesc.type = CONFIG_VAR_BOOL; + cvarDesc.default_bool = defaultValue; + if (svc_config->register_var(mod_ctx, &cvarDesc, &outHandle) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register shadow option"); + } + return MOD_OK; +} + +ModResult register_int_option( + const char* name, int64_t defaultValue, ConfigVarHandle& outHandle, ModError* error) { + ConfigVarDesc cvarDesc = CONFIG_VAR_DESC_INIT; + cvarDesc.name = name; + cvarDesc.type = CONFIG_VAR_INT; + cvarDesc.default_int = defaultValue; + if (svc_config->register_var(mod_ctx, &cvarDesc, &outHandle) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register shadow option"); + } + return MOD_OK; +} + +} // namespace + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError* error) { + ModResult result = svc_resource->load(mod_ctx, "shadow.wgsl", &g_shaderSource); + if (result != MOD_OK || g_shaderSource.data == nullptr) { + return mods::set_error(error, result, "failed to load shadow.wgsl"); + } + + result = register_bool_option("effectEnabled", false, g_cvarEnabled, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("mapSize", 2, g_cvarMapSize, error); + if (result != MOD_OK) { + return result; + } + result = register_bool_option("noFrustumClipping", true, g_cvarNoFrustumClipping, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("strength", 45, g_cvarStrength, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("pcf", 2, g_cvarPcf, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("bias", 55, g_cvarBias, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("boxRadius", 6000, g_cvarBoxRadius, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("edgeFadeWidth", 128, g_cvarEdgeFadeWidth, error); + if (result != MOD_OK) { + return result; + } + result = register_bool_option("contactShadows", true, g_cvarContactShadows, error); + if (result != MOD_OK) { + return result; + } + result = register_int_option("debugView", 0, g_cvarDebugView, error); + if (result != MOD_OK) { + return result; + } + + if (svc_gfx->get_device_info(mod_ctx, &g_deviceInfo) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to query device info"); + } + if (svc_gfx->get_scene_target_layout(mod_ctx, &g_sceneTargetLayout) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to query scene target layout"); + } + if (!build_composite_pipeline(true, g_compositePipeline, g_compositeLayout) || + !build_composite_pipeline(false, g_compositeDebugPipeline, g_compositeDebugLayout)) + { + return mods::set_error(error, MOD_ERROR, "failed to create composite pipeline"); + } + + GfxDrawTypeDesc drawDesc = GFX_DRAW_TYPE_DESC_INIT; + drawDesc.label = "shadow composite"; + drawDesc.draw = on_draw; + if (svc_gfx->register_draw_type(mod_ctx, &drawDesc, &g_drawType) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to register draw type"); + } + GfxStageHookDesc stageDesc = GFX_STAGE_HOOK_DESC_INIT; + stageDesc.callback = on_scene_begin; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_SCENE_BEGIN, &stageDesc, &g_sceneBeginHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register stage hook"); + } + stageDesc.callback = on_scene_after_terrain; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_SCENE_AFTER_TERRAIN, &stageDesc, &g_sceneAfterTerrainHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register stage hook"); + } + stageDesc.callback = on_scene_after_opaque; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_SCENE_AFTER_OPAQUE, &stageDesc, &g_sceneAfterOpaqueHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register stage hook"); + } + stageDesc.callback = on_frame_before_hud; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_FRAME_BEFORE_HUD, &stageDesc, &g_frameBeforeHudHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register stage hook"); + } + + // Skip the game's own shadow rendering while the dynamic pass is active: the + // shadowControl pair covers the actor real/blob shadows, drawCloudShadow the weather + // cloud shadows. + if (mods::hook::add_pre(on_game_shadow_pre) != MOD_OK || + mods::hook::add_pre(on_game_shadow_pre) != MOD_OK || + mods::hook::add_pre(on_game_shadow_pre) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to hook game shadow rendering"); + } + if (mods::hook::add_pre(on_frustum_clip_pre) != MOD_OK || + mods::hook::add_pre(on_frustum_clip_pre) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to hook frustum clipping"); + } + if (mods::hook::add_pre(on_copy_tex_pre) != MOD_OK) { + return mods::set_error(error, MOD_ERROR, "failed to hook GXCopyTex"); + } + UiModsPanelDesc panelDesc = UI_MODS_PANEL_DESC_INIT; + panelDesc.build = build_panel; + svc_ui->register_mods_panel(mod_ctx, &panelDesc); + + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + restore_actual_light_debug(); + close_debug_window(); + release_debug_present_pipeline(); + svc_resource->free(mod_ctx, &g_shaderSource); + if (g_compositePipeline != nullptr) { + wgpuRenderPipelineRelease(g_compositePipeline); + g_compositePipeline = nullptr; + } + if (g_compositeDebugPipeline != nullptr) { + wgpuRenderPipelineRelease(g_compositeDebugPipeline); + g_compositeDebugPipeline = nullptr; + } + if (g_compositeLayout != nullptr) { + wgpuBindGroupLayoutRelease(g_compositeLayout); + g_compositeLayout = nullptr; + } + if (g_compositeDebugLayout != nullptr) { + wgpuBindGroupLayoutRelease(g_compositeDebugLayout); + g_compositeDebugLayout = nullptr; + } + g_cvarEnabled = g_cvarMapSize = g_cvarNoFrustumClipping = 0; + g_cvarStrength = 0; + g_cvarPcf = g_cvarBias = g_cvarBoxRadius = g_cvarEdgeFadeWidth = g_cvarContactShadows = + g_cvarDebugView = 0; + g_drawType = g_sceneBeginHook = g_sceneAfterTerrainHook = g_sceneAfterOpaqueHook = + g_frameBeforeHudHook = 0; + g_controlsWindow = 0; + g_debugWindow = 0; + g_debugPresentTarget = 0; + g_mapPass = {}; + g_sceneCamera.valid = false; + g_sceneCamera.raw_valid = false; + return MOD_OK; +} +} diff --git a/tools/mod_template/CMakeLists.txt b/mods/template_mod/CMakeLists.txt similarity index 100% rename from tools/mod_template/CMakeLists.txt rename to mods/template_mod/CMakeLists.txt diff --git a/mods/template_mod/mod.json b/mods/template_mod/mod.json new file mode 100644 index 0000000000..e60714edf5 --- /dev/null +++ b/mods/template_mod/mod.json @@ -0,0 +1,7 @@ +{ + "id": "com.example.mod", + "name": "Template Mod", + "version": "1.0.0", + "author": "You", + "description": "An example Dusklight mod" +} diff --git a/mods/template_mod/res/.gitkeep b/mods/template_mod/res/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/mod_template/src/mod.cpp b/mods/template_mod/src/mod.cpp similarity index 100% rename from tools/mod_template/src/mod.cpp rename to mods/template_mod/src/mod.cpp diff --git a/mods/window_demo/CMakeLists.txt b/mods/window_demo/CMakeLists.txt new file mode 100644 index 0000000000..4257f9686e --- /dev/null +++ b/mods/window_demo/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.25) +project(window_demo CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(window_demo + FEATURES fmt webgpu + SOURCES src/logging.cpp src/mod.cpp + MOD_JSON mod.json +) diff --git a/mods/window_demo/mod.json b/mods/window_demo/mod.json new file mode 100644 index 0000000000..ff79e62431 --- /dev/null +++ b/mods/window_demo/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.window_demo", + "name": "[Demo] Extra Window", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "Demonstrates creating an extra window through WindowService and rendering to it with GfxService." +} diff --git a/mods/window_demo/src/logging.cpp b/mods/window_demo/src/logging.cpp new file mode 100644 index 0000000000..87015c713a --- /dev/null +++ b/mods/window_demo/src/logging.cpp @@ -0,0 +1,35 @@ +#include "logging.hpp" + +#include "mods/svc/log.hpp" +#include "mods/svc/window.h" + +namespace { + +const char* window_event_name(WindowEventType type) { + switch (type) { + case WINDOW_EVENT_CLOSE_REQUESTED: + return "close requested"; + case WINDOW_EVENT_RESIZED: + return "resized"; + case WINDOW_EVENT_MOVED: + return "moved"; + case WINDOW_EVENT_FOCUS_GAINED: + return "focus gained"; + case WINDOW_EVENT_FOCUS_LOST: + return "focus lost"; + case WINDOW_EVENT_SHOWN: + return "shown"; + case WINDOW_EVENT_HIDDEN: + return "hidden"; + } + return "unknown"; +} + +} // namespace + +void window_demo::log_window_event(const WindowEvent* event) { + mods::log::info( + "window event: {}; position=({}, {}), size={}x{}, pixels={}x{}, scale={:.2f}", + window_event_name(event->type), event->x, event->y, event->width, event->height, + event->pixel_width, event->pixel_height, event->display_scale); +} diff --git a/mods/window_demo/src/logging.hpp b/mods/window_demo/src/logging.hpp new file mode 100644 index 0000000000..3f62800d86 --- /dev/null +++ b/mods/window_demo/src/logging.hpp @@ -0,0 +1,9 @@ +#pragma once + +struct WindowEvent; + +namespace window_demo { + +void log_window_event(const WindowEvent* event); + +} // namespace window_demo diff --git a/mods/window_demo/src/mod.cpp b/mods/window_demo/src/mod.cpp new file mode 100644 index 0000000000..0a1e9333ff --- /dev/null +++ b/mods/window_demo/src/mod.cpp @@ -0,0 +1,221 @@ +#include "logging.hpp" + +#include "mods/service.hpp" +#include "mods/svc/gfx.h" +#include "mods/svc/log.hpp" +#include "mods/svc/ui.h" +#include "mods/svc/window.h" + +#include +#include +#include + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(UiService, svc_ui); +IMPORT_SERVICE(WindowService, svc_window); +IMPORT_SERVICE(GfxService, svc_gfx); + +namespace { + +WindowHandle g_window = 0; +GfxPresentTargetHandle g_presentTarget = 0; +GfxStageHookHandle g_stageHook = 0; +uint32_t g_frame = 0; +bool g_recreatePresentTarget = false; + +struct ClearPayload { + float red; + float green; + float blue; + float alpha; +}; +static_assert(sizeof(ClearPayload) <= GFX_INLINE_DRAW_PAYLOAD_SIZE); + +ModResult close_window() { + g_recreatePresentTarget = false; + if (g_presentTarget != 0) { + const auto result = svc_gfx->unregister_present_target(mod_ctx, g_presentTarget); + if (result != MOD_OK) { + return result; + } + g_presentTarget = 0; + } + if (g_window != 0) { + const auto result = svc_window->destroy_window(mod_ctx, g_window); + if (result != MOD_OK) { + return result; + } + g_window = 0; + } + return MOD_OK; +} + +void on_window_event(ModContext*, WindowHandle, const WindowEvent* event, void*) { + window_demo::log_window_event(event); + + if (event->type == WINDOW_EVENT_CLOSE_REQUESTED) { + if (close_window() != MOD_OK) { + mods::log::error("failed to close auxiliary window"); + } + } +} + +// Render worker thread: record a clear of the acquired auxiliary surface texture. +void on_present( + ModContext*, const GfxPresentContext* ctx, const void* payload, size_t payloadSize, void*) { + if (payloadSize != sizeof(ClearPayload)) { + return; + } + ClearPayload color; + std::memcpy(&color, payload, sizeof(color)); + + WGPURenderPassColorAttachment colorAttachment = WGPU_RENDER_PASS_COLOR_ATTACHMENT_INIT; + colorAttachment.view = ctx->target_view; + colorAttachment.loadOp = WGPULoadOp_Clear; + colorAttachment.storeOp = WGPUStoreOp_Store; + colorAttachment.clearValue = WGPUColor{ + color.red, + color.green, + color.blue, + color.alpha, + }; + + WGPURenderPassDescriptor passDesc = WGPU_RENDER_PASS_DESCRIPTOR_INIT; + passDesc.label = {"Auxiliary window clear", WGPU_STRLEN}; + passDesc.colorAttachmentCount = 1; + passDesc.colorAttachments = &colorAttachment; + WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(ctx->encoder, &passDesc); + wgpuRenderPassEncoderEnd(pass); + wgpuRenderPassEncoderRelease(pass); +} + +ModResult register_present_target() { + if (g_window == 0 || g_presentTarget != 0) { + return MOD_CONFLICT; + } + GfxPresentTargetDesc presentDesc = GFX_PRESENT_TARGET_DESC_INIT; + presentDesc.label = "Auxiliary window surface"; + presentDesc.render = on_present; + presentDesc.preferred_alpha_mode = + WGPUCompositeAlphaMode_Premultiplied; // For transparent window + return svc_gfx->register_window_present_target( + mod_ctx, g_window, &presentDesc, &g_presentTarget); +} + +ModResult open_window() { + if (g_window != 0) { + return MOD_CONFLICT; + } + + WindowDesc windowDesc = WINDOW_DESC_INIT; + windowDesc.title = "Mod window"; + windowDesc.width = 640; + windowDesc.height = 480; + windowDesc.on_event = on_window_event; + windowDesc.flags |= WINDOW_FLAG_TRANSPARENT; // For transparent window + auto result = svc_window->create_window(mod_ctx, &windowDesc, &g_window); + if (result != MOD_OK) { + return result; + } + + result = register_present_target(); + if (result != MOD_OK) { + close_window(); + return result; + } + + result = svc_window->show_window(mod_ctx, g_window); + if (result != MOD_OK) { + close_window(); + } + return result; +} + +void on_frame_after_hud(ModContext*, const GfxStageContext*, void*) { + if (g_presentTarget == 0) { + return; + } + const float phase = static_cast(g_frame++) * 0.015f; + const ClearPayload color{ + .red = 0.08f + 0.06f * (std::sin(phase) + 1.0f), + .green = 0.10f + 0.06f * (std::sin(phase + 2.1f) + 1.0f), + .blue = 0.14f + 0.08f * (std::sin(phase + 4.2f) + 1.0f), + .alpha = 0.5f, + }; + if (svc_gfx->push_present(mod_ctx, g_presentTarget, &color, sizeof(color)) == MOD_ERROR) { + g_recreatePresentTarget = true; + } +} + +void on_toggle_window(ModContext*, void*) { + if (g_window != 0) { + if (close_window() != MOD_OK) { + mods::log::error("failed to close auxiliary window"); + } + return; + } + if (open_window() != MOD_OK) { + mods::log::error("failed to open auxiliary window"); + } +} + +ModResult build_panel(ModContext*, UiElementHandle panel, void*, ModError*) { + UiControlDesc control = UI_CONTROL_DESC_INIT; + control.kind = UI_CONTROL_BUTTON; + control.label = "Open / Close Window"; + control.on_pressed = on_toggle_window; + return svc_ui->pane_add_control(mod_ctx, panel, &control, nullptr); +} + +} // namespace + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError* error) { + GfxStageHookDesc stageDesc = GFX_STAGE_HOOK_DESC_INIT; + stageDesc.callback = on_frame_after_hud; + if (svc_gfx->register_stage_hook( + mod_ctx, GFX_STAGE_FRAME_AFTER_HUD, &stageDesc, &g_stageHook) != MOD_OK) + { + return mods::set_error(error, MOD_ERROR, "failed to register presentation hook"); + } + + UiModsPanelDesc panelDesc = UI_MODS_PANEL_DESC_INIT; + panelDesc.build = build_panel; + if (svc_ui->register_mods_panel(mod_ctx, &panelDesc) != MOD_OK) { + svc_gfx->unregister_stage_hook(mod_ctx, g_stageHook); + g_stageHook = 0; + return mods::set_error(error, MOD_ERROR, "failed to register mod panel"); + } + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError* error) { + if (!g_recreatePresentTarget || g_window == 0) { + return MOD_OK; + } + g_recreatePresentTarget = false; + if (g_presentTarget != 0) { + const auto result = svc_gfx->unregister_present_target(mod_ctx, g_presentTarget); + if (result != MOD_OK) { + return mods::set_error(error, result, "failed to unregister lost present target"); + } + g_presentTarget = 0; + } + const auto result = register_present_target(); + if (result != MOD_OK) { + return mods::set_error(error, result, "failed to recreate present target"); + } + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + if (g_stageHook != 0) { + svc_gfx->unregister_stage_hook(mod_ctx, g_stageHook); + g_stageHook = 0; + } + close_window(); + return MOD_OK; +} +} diff --git a/platforms/android/.gitignore b/platforms/android/.gitignore index 7775e3c7f4..002aaa86aa 100644 --- a/platforms/android/.gitignore +++ b/platforms/android/.gitignore @@ -3,3 +3,4 @@ build/ app/build/ local.properties app/src/main/jniLibs/*/*.so +app/src/main/bundled_mods/ diff --git a/platforms/android/README.md b/platforms/android/README.md index f478871392..c4f8a688df 100644 --- a/platforms/android/README.md +++ b/platforms/android/README.md @@ -1,10 +1,10 @@ # Android Shell -This directory contains a minimal SDLActivity-based Android app wrapper for Dusklight. +This directory contains Dusklight's Android shell built on top of Borealis. ## Prerequisites -- Android SDK installed (`ANDROID_HOME`) +- Android SDK with Platform 37 installed (`ANDROID_HOME`) - Android NDK version used by CMake presets (`ANDROID_NDK_VERSION`) - JDK 17+ @@ -21,45 +21,23 @@ export JAVA_HOME="/usr/lib/jvm/java-17-openjdk" ```bash cmake --preset android-arm64 cmake --build --preset android-arm64 - -cmake --preset android-x86_64 -cmake --build --preset android-x86_64 ``` -These builds produce: - -- `build/android-arm64/Binaries/libmain.so` -- `build/android-x86_64/Binaries/libmain.so` - -## Stage Libraries Into APK Project - -```bash -./android/scripts/stage-jni-libs.sh -``` - -This copies: - -- `libmain.so` -> `android/app/src/main/jniLibs/arm64-v8a/` -- `libmain.so` -> `android/app/src/main/jniLibs/x86_64/` - -## Refresh SDL Java Shim (Optional) - -If you update SDL and want to refresh the embedded Java shim files: - -```bash -./android/scripts/sync-sdl-java.sh -``` +This build produces `build/android-arm64/libmain.so` ## Build APK ```bash -cd android +cd platforms/android ./gradlew :app:assembleDebug ``` Output APK: -- `android/app/build/outputs/apk/debug/app-debug.apk` +- `app/build/outputs/apk/debug/app-arm64-v8a-debug.apk` + +Aurora needs a hardware-backed graphics adapter. If an AVD has GPU +acceleration disabled, launch it with `-gpu host`. ## Launch With Runtime Args (adb) @@ -67,10 +45,13 @@ You can pass command-line args through the activity intent: ```bash adb shell am start -n dev.twilitrealm.dusk/.DuskActivity \ - --es dusk_args "--backend vulkan" + --es borealis_args "--backend vulkan" ``` Supported extras: -- `dusk_args`: single shell-like argument string -- `dusk_argv`: string-array argv +- `borealis_args`: single shell-like argument string +- `borealis_argv`: string-array argv + +The legacy `dusk_args` and `dusk_argv` names remain accepted during the shell +transition. diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle index 8527cd1f4d..aba966b448 100644 --- a/platforms/android/app/build.gradle +++ b/platforms/android/app/build.gradle @@ -2,69 +2,32 @@ plugins { id 'com.android.application' } -def versionNameStr = (System.getenv("DUSK_VERSION") ?: "v0.1.0").replaceFirst("^v", "") -def versionCodeInt = (System.getenv("DUSK_VERSION_CODE") ?: "100000").toInteger() - def duskRepoDir = rootProject.projectDir.parentFile.parentFile -def duskGeneratedAssetsDir = layout.buildDirectory.dir('generated/assets/dusklight').get().asFile -def syncDuskAssets = tasks.register('syncDuskAssets', Sync) { - from(new File(duskRepoDir, 'res')) { - into 'res' - exclude '**/.DS_Store' - } - into duskGeneratedAssetsDir -} +def borealisDir = new File(duskRepoDir, 'extern/borealis') -android { - namespace 'dev.twilitrealm.dusk' - compileSdk 36 +ext.borealisAndroid = [ + borealisDir: borealisDir, + propertiesFile: new File(duskRepoDir, 'build/android-arm64/borealis-android.properties'), + namespace: 'dev.twilitrealm.dusk', + applicationId: 'dev.twilitrealm.dusk', + abis: ['arm64-v8a'], + assets: [ + [ + from: new File(duskRepoDir, 'res'), + into: 'res', + excludes: ['**/.DS_Store'] + ], + [ + from: new File(duskRepoDir, 'build/android-arm64/bundled_mods'), + into: 'mods', + includes: ['*.dusk'] + ] + ], + proguardRules: file('proguard-rules.pro') +] - defaultConfig { - applicationId 'dev.twilitrealm.dusk' - minSdk 26 - targetSdk 36 - versionCode versionCodeInt - versionName versionNameStr - } - - buildTypes { - debug { - minifyEnabled false - } - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - sourceSets { - main { - jniLibs.srcDirs = ['src/main/jniLibs'] - assets.srcDirs = [duskGeneratedAssetsDir] - } - } - - splits { - abi { - enable true - reset() - include 'arm64-v8a', 'x86_64' - universalApk false - } - } - - lint { - abortOnError false - } -} +apply from: new File(borealisDir, 'platforms/android/gradle/borealis-application.gradle') dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) } - -tasks.configureEach { task -> - if ((task.name.startsWith('merge') && task.name.endsWith('Assets')) || - task.name.toLowerCase().contains('lint')) { - task.dependsOn(syncDuskAssets) - } -} diff --git a/platforms/android/app/proguard-rules.pro b/platforms/android/app/proguard-rules.pro index 72b7ca16fa..308a46ab83 100644 --- a/platforms/android/app/proguard-rules.pro +++ b/platforms/android/app/proguard-rules.pro @@ -1,4 +1 @@ -# Keep SDL activity and related JNI bridge methods. --keep class org.libsdl.app.** { *; } --keep class dev.twilitrealm.dusk.DuskHttpClient { *; } --keep class dev.twilitrealm.dusk.DuskHttpClient$Response { *; } +-keep class dev.twilitrealm.dusk.DuskActivity { *; } diff --git a/platforms/android/app/src/main/AndroidManifest.xml b/platforms/android/app/src/main/AndroidManifest.xml index cd687963e1..8dc7bf3236 100644 --- a/platforms/android/app/src/main/AndroidManifest.xml +++ b/platforms/android/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ android:appCategory="game" android:icon="@mipmap/icon" android:label="@string/app_name" + android:networkSecurityConfig="@xml/network_security_config" android:theme="@android:style/Theme.NoTitleBar" android:enableOnBackInvokedCallback="false"> @@ -26,8 +27,8 @@ android:resource="@xml/game_mode_config" /> diff --git a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskActivity.java b/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskActivity.java index 96fc302d9e..4c1d8d41eb 100644 --- a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskActivity.java +++ b/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskActivity.java @@ -1,552 +1,86 @@ package dev.twilitrealm.dusk; -import android.app.ActionBar; -import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.ClipData; -import android.content.Context; import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Build; import android.os.Bundle; -import android.os.Environment; -import android.provider.DocumentsContract; -import android.provider.OpenableColumns; -import android.provider.Settings; import android.util.Log; -import android.view.Display; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.View; -import android.view.Window; -import android.view.WindowInsets; -import android.view.WindowInsetsController; -import org.libsdl.app.SDLActivity; -import org.libsdl.app.SDLSurface; +import dev.encounter.borealis.BorealisActivity; import java.io.File; -import java.util.ArrayList; -import java.util.List; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; -public class DuskActivity extends SDLActivity { +public class DuskActivity extends BorealisActivity { private static final String TAG = "DuskActivity"; - private static final float DEFAULT_SURFACE_FRAME_RATE = 60.0f; - private static final int FOLDER_DIALOG_REQUEST_CODE = 0x4455; - private static final int MANAGE_STORAGE_REQUEST_CODE = 0x4456; - private static final String EXTERNAL_STORAGE_AUTHORITY = - "com.android.externalstorage.documents"; - - private long folderDialogUserdata = 0; - private boolean awaitingManageStoragePermission = false; - - private static native void nativeFolderDialogResult(long userdata, String path, String error); - - private static String[] splitArgs(String raw) { - List out = new ArrayList<>(); - StringBuilder current = new StringBuilder(); - boolean inSingle = false; - boolean inDouble = false; - boolean escaped = false; - - for (int i = 0; i < raw.length(); ++i) { - char c = raw.charAt(i); - if (escaped) { - current.append(c); - escaped = false; - continue; - } - if (c == '\\' && !inSingle) { - escaped = true; - continue; - } - if (c == '"' && !inSingle) { - inDouble = !inDouble; - continue; - } - if (c == '\'' && !inDouble) { - inSingle = !inSingle; - continue; - } - if (!inSingle && !inDouble && Character.isWhitespace(c)) { - if (current.length() > 0) { - out.add(current.toString()); - current.setLength(0); - } - continue; - } - current.append(c); - } - - if (escaped) { - current.append('\\'); - } - if (current.length() > 0) { - out.add(current.toString()); - } - return out.toArray(new String[0]); - } - @Override protected void onCreate(Bundle savedInstanceState) { + extractBundledMods(); super.onCreate(savedInstanceState); - hideSystemBars(); } - @Override - protected SDLSurface createSDLSurface(Context context) { - return new DuskSurface(context); - } - - @Override - protected void onResume() { - super.onResume(); - hideSystemBars(); - if (awaitingManageStoragePermission) { - resumeFolderDialogAfterPermissionGrant(); - } - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - if (hasFocus) { - hideSystemBars(); - } - } - - private void hideSystemBars() { - Window window = getWindow(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - window.setDecorFitsSystemWindows(false); - WindowInsetsController ctrl = window.getDecorView().getWindowInsetsController(); - if (ctrl != null) { - ctrl.setSystemBarsBehavior( - WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - ctrl.hide(WindowInsets.Type.systemBars()); - } - } else { - View decorView = window.getDecorView(); - int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_STABLE; - decorView.setSystemUiVisibility(uiOptions); - ActionBar actionBar = getActionBar(); - if (actionBar != null) { - actionBar.hide(); - } - } - } - - @Override - protected String[] getLibraries() { - // SDL3 is statically linked into libmain.so in this build. - return new String[] { - "main" - }; - } - - public void setPreferredSurfaceFrameRate(float frameRate) { - runOnUiThread(() -> { - if (mSurface instanceof DuskSurface) { - ((DuskSurface)mSurface).setPreferredFrameRate(frameRate); - } - }); - } - - private static final class DuskSurface extends SDLSurface { - private float preferredFrameRate = DEFAULT_SURFACE_FRAME_RATE; - - DuskSurface(Context context) { - super(context); - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - super.surfaceChanged(holder, format, width, height); - setTargetFrameRate(holder); - } - - void setPreferredFrameRate(float frameRate) { - preferredFrameRate = frameRate; - setTargetFrameRate(getHolder()); - } - - private void setTargetFrameRate(SurfaceHolder holder) { - if (!mIsSurfaceReady || Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { + // Bundled mod packages ship as APK assets, which the native loader cannot read directly; + // mirror them into internal storage (the loader's CachePath/bundled_mods search dir) + // before SDL_main starts. + private void extractBundledMods() { + File outDir = new File(getFilesDir(), "bundled_mods"); + try { + deleteRecursively(outDir); // drop packages removed by an app update + String[] names = getAssets().list("mods"); + if (names == null || names.length == 0) { return; } - - Surface surface = holder != null ? holder.getSurface() : getHolder().getSurface(); - if (surface == null || !surface.isValid()) { + if (!outDir.mkdirs()) { + Log.w(TAG, "Unable to create " + outDir); return; } - - float targetFrameRate = getMaxSupportedFrameRate(); - if (preferredFrameRate > 0.0f) { - targetFrameRate = preferredFrameRate; - } - if (targetFrameRate <= 0.0f) { - return; + byte[] buffer = new byte[65536]; + for (String name : names) { + if (!name.endsWith(".dusk")) { + continue; + } + try (InputStream in = getAssets().open("mods/" + name); + OutputStream out = new FileOutputStream(new File(outDir, name))) + { + int count; + while ((count = in.read(buffer)) > 0) { + out.write(buffer, 0, count); + } + } } + } catch (IOException e) { + Log.w(TAG, "Failed to extract bundled mods", e); + } + } - try { - surface.setFrameRate( - targetFrameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT); - Log.v(TAG, "Requested surface frame rate " + targetFrameRate + " fps"); - } catch (RuntimeException e) { - Log.w(TAG, "Failed to request surface frame rate", e); + private static void deleteRecursively(File file) { + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + deleteRecursively(child); } } - - private float getMaxSupportedFrameRate() { - if (mDisplay == null) { - return 0.0f; - } - - float maxFrameRate = mDisplay.getRefreshRate(); - Display.Mode[] modes = mDisplay.getSupportedModes(); - if (modes == null) { - return maxFrameRate; - } - - for (Display.Mode mode : modes) { - maxFrameRate = Math.max(maxFrameRate, mode.getRefreshRate()); - } - return maxFrameRate; - } + file.delete(); } @Override protected String[] getArguments() { + String[] arguments = super.getArguments(); + if (arguments.length > 0) { + return arguments; + } + Intent intent = getIntent(); - if (intent != null) { - String[] argv = intent.getStringArrayExtra("dusk_argv"); - if (argv != null && argv.length > 0) { - return argv; - } - - String rawArgs = intent.getStringExtra("dusk_args"); - if (rawArgs != null) { - String trimmed = rawArgs.trim(); - if (!trimmed.isEmpty()) { - return splitArgs(trimmed); - } - } + if (intent == null) { + return arguments; } - return new String[0]; + String[] argv = intent.getStringArrayExtra("dusk_argv"); + if (argv != null && argv.length > 0) { + return argv; + } + String rawArgs = intent.getStringExtra("dusk_args"); + return rawArgs == null ? arguments : splitArguments(rawArgs.trim()); } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (resultCode == RESULT_OK) { - persistUriPermissions(data); - } - if (requestCode == FOLDER_DIALOG_REQUEST_CODE) { - finishFolderDialog(resultCode, data); - return; - } - super.onActivityResult(requestCode, resultCode, data); - } - - public boolean showFolderDialog(long userdata) { - if (userdata == 0 || folderDialogUserdata != 0) { - return false; - } - - folderDialogUserdata = userdata; - if (requiresManageStoragePermission() && !hasManageStoragePermission()) { - if (!requestManageStoragePermission()) { - finishFolderDialogWithError("Unable to request Android file access permission"); - return false; - } - return true; - } - - openFolderDialog(); - return true; - } - - private void openFolderDialog() { - runOnUiThread(() -> { - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | - Intent.FLAG_GRANT_WRITE_URI_PERMISSION | - Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | - Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); - - try { - startActivityForResult(intent, FOLDER_DIALOG_REQUEST_CODE); - } catch (ActivityNotFoundException e) { - Log.w(TAG, "Unable to open folder dialog.", e); - finishFolderDialog(Activity.RESULT_CANCELED, null); - } - }); - } - - private boolean requiresManageStoragePermission() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R; - } - - private boolean hasManageStoragePermission() { - return !requiresManageStoragePermission() || Environment.isExternalStorageManager(); - } - - private boolean requestManageStoragePermission() { - if (!requiresManageStoragePermission()) { - return true; - } - - awaitingManageStoragePermission = true; - runOnUiThread(() -> { - if (tryStartManageStorageIntent( - new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) - .setData(Uri.parse("package:" + getPackageName()))) || - tryStartManageStorageIntent( - new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION))) - { - return; - } - - finishFolderDialogWithError("Unable to request Android file access permission"); - }); - return true; - } - - private boolean tryStartManageStorageIntent(Intent intent) { - try { - startActivityForResult(intent, MANAGE_STORAGE_REQUEST_CODE); - return true; - } catch (ActivityNotFoundException e) { - Log.w(TAG, "Unable to open all-files access settings.", e); - return false; - } - } - - private void resumeFolderDialogAfterPermissionGrant() { - awaitingManageStoragePermission = false; - if (folderDialogUserdata == 0) { - return; - } - - if (hasManageStoragePermission()) { - openFolderDialog(); - return; - } - - finishFolderDialogWithError( - "Allow \"All files access\" for Dusklight before choosing a custom data folder"); - } - - private void finishFolderDialogWithError(String error) { - long userdata = folderDialogUserdata; - folderDialogUserdata = 0; - awaitingManageStoragePermission = false; - if (userdata != 0) { - nativeFolderDialogResult(userdata, null, error); - } - } - - private void finishFolderDialog(int resultCode, Intent data) { - long userdata = folderDialogUserdata; - folderDialogUserdata = 0; - if (userdata == 0) { - return; - } - - if (resultCode == RESULT_OK && data != null && data.getData() != null) { - String path = getRealPathForUri(data.getData()); - if (path != null && !path.isEmpty()) { - nativeFolderDialogResult(userdata, path, null); - } else { - nativeFolderDialogResult( - userdata, null, "Selected folder is not available as a filesystem path"); - } - return; - } - - nativeFolderDialogResult(userdata, null, null); - } - - private String getRealPathForUri(Uri uri) { - if (uri == null) { - return null; - } - - String scheme = uri.getScheme(); - if ("file".equals(scheme)) { - return uri.getPath(); - } - - if (!"content".equals(scheme) || - !EXTERNAL_STORAGE_AUTHORITY.equals(uri.getAuthority()) || - Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) - { - return null; - } - - try { - return getExternalStoragePathForDocumentId(getExternalStorageDocumentId(uri)); - } catch (IllegalArgumentException e) { - Log.w(TAG, "Unable to resolve URI: " + uri, e); - return null; - } - } - - private static String getExternalStorageDocumentId(Uri uri) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isTreeDocumentUri(uri)) { - return DocumentsContract.getTreeDocumentId(uri); - } - - return DocumentsContract.getDocumentId(uri); - } - - private static boolean isTreeDocumentUri(Uri uri) { - List segments = uri.getPathSegments(); - return segments.size() >= 2 && "tree".equals(segments.get(0)); - } - - private String getExternalStoragePathForDocumentId(String documentId) { - if (documentId == null || documentId.isEmpty()) { - return null; - } - if (documentId.startsWith("raw:")) { - return documentId.substring("raw:".length()); - } - - String[] parts = documentId.split(":", 2); - String volumeId = parts[0]; - String relativePath = parts.length > 1 ? parts[1] : ""; - - File root = getExternalStorageRoot(volumeId); - if (root == null) { - return null; - } - - return relativePath.isEmpty() - ? root.getAbsolutePath() - : new File(root, relativePath).getAbsolutePath(); - } - - private File getExternalStorageRoot(String volumeId) { - if ("primary".equalsIgnoreCase(volumeId)) { - return Environment.getExternalStorageDirectory(); - } - if ("home".equalsIgnoreCase(volumeId)) { - return new File( - Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DOCUMENTS); - } - - File[] externalFilesDirs = getExternalFilesDirs(null); - if (externalFilesDirs != null) { - for (File externalFilesDir : externalFilesDirs) { - File root = getStorageRootForExternalFilesDir(externalFilesDir); - if (root != null && volumeId.equalsIgnoreCase(root.getName())) { - return root; - } - } - } - - File fallback = new File("/storage", volumeId); - return fallback.exists() ? fallback : null; - } - - private File getStorageRootForExternalFilesDir(File externalFilesDir) { - if (externalFilesDir == null) { - return null; - } - - String path = externalFilesDir.getAbsolutePath(); - int androidDir = path.indexOf("/Android/"); - if (androidDir <= 0) { - return null; - } - - return new File(path.substring(0, androidDir)); - } - - private void persistUriPermissions(Intent data) { - if (data == null) { - return; - } - - int permissionFlags = - data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); - if (permissionFlags == 0) { - return; - } - - Uri uri = data.getData(); - if (uri != null) { - persistUriPermission(uri, permissionFlags); - } - - ClipData clipData = data.getClipData(); - if (clipData == null) { - return; - } - for (int i = 0; i < clipData.getItemCount(); ++i) { - Uri itemUri = clipData.getItemAt(i).getUri(); - if (itemUri != null) { - persistUriPermission(itemUri, permissionFlags); - } - } - } - - private void persistUriPermission(Uri uri, int permissionFlags) { - if ((permissionFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { - persistUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION, "read"); - } - if ((permissionFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { - persistUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, "write"); - } - } - - private void persistUriPermission(Uri uri, int permissionFlag, String permissionName) { - try { - getContentResolver().takePersistableUriPermission(uri, permissionFlag); - } catch (SecurityException | IllegalArgumentException e) { - Log.w(TAG, "Unable to persist " + permissionName + " URI permission for " + uri, e); - } - } - - public String getDisplayNameForUri(String uriString) { - if (uriString == null || uriString.isEmpty()) { - return ""; - } - - Uri uri = Uri.parse(uriString); - if ("content".equals(uri.getScheme())) { - try (Cursor cursor = getContentResolver().query( - uri, new String[] { OpenableColumns.DISPLAY_NAME }, null, null, null)) - { - if (cursor != null && cursor.moveToFirst()) { - int displayNameColumn = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); - if (displayNameColumn >= 0) { - String displayName = cursor.getString(displayNameColumn); - if (displayName != null && !displayName.isEmpty()) { - return displayName; - } - } - } - } catch (SecurityException | IllegalArgumentException e) { - Log.w(TAG, "Unable to query display name for " + uri, e); - } - } else if ("file".equals(uri.getScheme())) { - String path = uri.getPath(); - if (path != null && !path.isEmpty()) { - String name = new File(path).getName(); - if (!name.isEmpty()) { - return name; - } - } - } - - String lastSegment = uri.getLastPathSegment(); - return lastSegment != null ? lastSegment : ""; - } } diff --git a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskDocumentsProvider.java b/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskDocumentsProvider.java deleted file mode 100644 index d4ed6a3041..0000000000 --- a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskDocumentsProvider.java +++ /dev/null @@ -1,467 +0,0 @@ -package dev.twilitrealm.dusk; - -import android.content.ContentResolver; -import android.content.res.AssetFileDescriptor; -import android.database.Cursor; -import android.database.MatrixCursor; -import android.net.Uri; -import android.os.Bundle; -import android.os.CancellationSignal; -import android.os.ParcelFileDescriptor; -import android.provider.DocumentsContract; -import android.provider.DocumentsContract.Document; -import android.provider.DocumentsContract.Root; -import android.provider.DocumentsProvider; -import android.webkit.MimeTypeMap; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -public class DuskDocumentsProvider extends DocumentsProvider { - public static final String AUTHORITY = "dev.twilitrealm.dusk.documents"; - - private static final String ROOT_ID = "dusk"; - private static final String ROOT_DOCUMENT_ID = "root"; - private static final String LOCATION_DESCRIPTOR_NAME = "data_location.json"; - private static final String DIRECTORY_MIME_TYPE = Document.MIME_TYPE_DIR; - - private static final String[] DEFAULT_ROOT_PROJECTION = new String[] { - Root.COLUMN_ROOT_ID, - Root.COLUMN_FLAGS, - Root.COLUMN_TITLE, - Root.COLUMN_DOCUMENT_ID, - Root.COLUMN_ICON, - Root.COLUMN_AVAILABLE_BYTES, - Root.COLUMN_SUMMARY - }; - - private static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[] { - Document.COLUMN_DOCUMENT_ID, - Document.COLUMN_DISPLAY_NAME, - Document.COLUMN_FLAGS, - Document.COLUMN_MIME_TYPE, - Document.COLUMN_LAST_MODIFIED, - Document.COLUMN_SIZE - }; - - @Override - public boolean onCreate() { - if (!isCustomDataPathEnabled()) { - ensureUserDirectories(); - } - return true; - } - - @Override - public Cursor queryRoots(String[] projection) throws FileNotFoundException { - final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); - if (isCustomDataPathEnabled()) { - return result; - } - - final File root = getRootDirectory(); - final MatrixCursor.RowBuilder row = result.newRow(); - - row.add(Root.COLUMN_ROOT_ID, ROOT_ID); - row.add(Root.COLUMN_FLAGS, - Root.FLAG_LOCAL_ONLY | - Root.FLAG_SUPPORTS_CREATE | - Root.FLAG_SUPPORTS_IS_CHILD); - row.add(Root.COLUMN_TITLE, getContext().getString(R.string.app_name)); - row.add(Root.COLUMN_DOCUMENT_ID, ROOT_DOCUMENT_ID); - row.add(Root.COLUMN_ICON, R.mipmap.icon); - row.add(Root.COLUMN_AVAILABLE_BYTES, root.getFreeSpace()); - row.add(Root.COLUMN_SUMMARY, getContext().getString(R.string.documents_provider_summary)); - - return result; - } - - @Override - public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException { - final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection)); - includeDocument(result, documentId, getFileForDocumentId(documentId)); - return result; - } - - @Override - public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) - throws FileNotFoundException - { - return queryChildDocumentsInternal(parentDocumentId, projection); - } - - @Override - public Cursor queryChildDocuments(String parentDocumentId, String[] projection, Bundle queryArgs) - throws FileNotFoundException - { - return queryChildDocumentsInternal(parentDocumentId, projection); - } - - private Cursor queryChildDocumentsInternal(String parentDocumentId, String[] projection) - throws FileNotFoundException - { - final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection)); - final File parent = getFileForDocumentId(parentDocumentId); - final File[] files = parent.listFiles(); - result.setNotificationUri(getContext().getContentResolver(), getChildDocumentsUri(parentDocumentId)); - - if (files == null) { - return result; - } - - for (File file : files) { - includeDocument(result, getDocumentIdForFile(file), file); - } - - return result; - } - - @Override - public boolean isChildDocument(String parentDocumentId, String documentId) { - try { - final File parent = getFileForDocumentId(parentDocumentId); - final File child = getFileForDocumentId(documentId); - return isInside(parent, child); - } catch (FileNotFoundException e) { - return false; - } - } - - @Override - public String createDocument(String parentDocumentId, String mimeType, String displayName) - throws FileNotFoundException - { - final File parent = getFileForDocumentId(parentDocumentId); - if (!parent.isDirectory()) { - throw new FileNotFoundException("Parent is not a directory: " + parentDocumentId); - } - - final String safeDisplayName = sanitizeDisplayName(displayName); - final File file = buildUniqueFile(parent, safeDisplayName); - final boolean created; - if (DIRECTORY_MIME_TYPE.equals(mimeType)) { - created = file.mkdir(); - } else { - try { - created = file.createNewFile(); - } catch (IOException e) { - throw asFileNotFound("Unable to create document", e); - } - } - - if (!created) { - throw new FileNotFoundException("Unable to create document: " + displayName); - } - - notifyChildrenChanged(parentDocumentId); - return getDocumentIdForFile(file); - } - - @Override - public String renameDocument(String documentId, String displayName) throws FileNotFoundException { - final File file = getFileForDocumentId(documentId); - if (ROOT_DOCUMENT_ID.equals(documentId)) { - throw new FileNotFoundException("Cannot rename root document"); - } - - final File target = buildUniqueFile(file.getParentFile(), sanitizeDisplayName(displayName)); - final String parentDocumentId = getDocumentIdForFile(file.getParentFile()); - if (!file.renameTo(target)) { - throw new FileNotFoundException("Unable to rename document: " + documentId); - } - notifyDocumentChanged(documentId); - notifyDocumentChanged(getDocumentIdForFile(target)); - notifyChildrenChanged(parentDocumentId); - return getDocumentIdForFile(target); - } - - @Override - public void deleteDocument(String documentId) throws FileNotFoundException { - if (ROOT_DOCUMENT_ID.equals(documentId)) { - throw new FileNotFoundException("Cannot delete root document"); - } - - final File file = getFileForDocumentId(documentId); - final String parentDocumentId = getDocumentIdForFile(file.getParentFile()); - deleteRecursively(file); - notifyDocumentChanged(documentId); - notifyChildrenChanged(parentDocumentId); - } - - @Override - public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) - throws FileNotFoundException - { - return ParcelFileDescriptor.open(getFileForDocumentId(documentId), modeToParcelMode(mode)); - } - - @Override - public AssetFileDescriptor openDocumentThumbnail(String documentId, android.graphics.Point sizeHint, - CancellationSignal signal) throws FileNotFoundException - { - throw new FileNotFoundException("Thumbnails are not supported"); - } - - private void includeDocument(MatrixCursor result, String documentId, File file) throws FileNotFoundException { - final MatrixCursor.RowBuilder row = result.newRow(); - final boolean isDirectory = file.isDirectory(); - final String displayName = ROOT_DOCUMENT_ID.equals(documentId) - ? getContext().getString(R.string.documents_provider_root_name) - : file.getName(); - - int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_RENAME; - if (isDirectory) { - flags |= Document.FLAG_DIR_SUPPORTS_CREATE; - } else if (file.canWrite()) { - flags |= Document.FLAG_SUPPORTS_WRITE; - } - if (ROOT_DOCUMENT_ID.equals(documentId)) { - flags &= ~(Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_RENAME); - } - - row.add(Document.COLUMN_DOCUMENT_ID, documentId); - row.add(Document.COLUMN_DISPLAY_NAME, displayName); - row.add(Document.COLUMN_FLAGS, flags); - row.add(Document.COLUMN_MIME_TYPE, isDirectory ? DIRECTORY_MIME_TYPE : getMimeType(file)); - row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified()); - row.add(Document.COLUMN_SIZE, isDirectory ? null : file.length()); - } - - private File getRootDirectory() throws FileNotFoundException { - if (isCustomDataPathEnabled()) { - throw new FileNotFoundException( - "Dusk DocumentsProvider is disabled while a custom data path is configured"); - } - - final File root = getContext().getFilesDir(); - if (root == null) { - throw new FileNotFoundException("Dusklight files directory is unavailable"); - } - return root; - } - - private File getFileForDocumentId(String documentId) throws FileNotFoundException { - final File root = getRootDirectory(); - if (ROOT_DOCUMENT_ID.equals(documentId)) { - return root; - } - if (!documentId.startsWith(ROOT_DOCUMENT_ID + "/")) { - throw new FileNotFoundException("Invalid document id: " + documentId); - } - - final String relativePath = documentId.substring(ROOT_DOCUMENT_ID.length() + 1); - final File file = new File(root, relativePath); - if (!isInside(root, file)) { - throw new FileNotFoundException("Document escapes Dusklight files directory: " + documentId); - } - if (!file.exists()) { - throw new FileNotFoundException("Document does not exist: " + documentId); - } - return file; - } - - private String getDocumentIdForFile(File file) throws FileNotFoundException { - final File root = getRootDirectory(); - if (sameFile(root, file)) { - return ROOT_DOCUMENT_ID; - } - if (!isInside(root, file)) { - throw new FileNotFoundException("File escapes Dusklight files directory: " + file); - } - - final String rootPath = canonicalPath(root); - final String filePath = canonicalPath(file); - return ROOT_DOCUMENT_ID + "/" + filePath.substring(rootPath.length() + 1); - } - - private void ensureUserDirectories() { - final File root = getContext().getFilesDir(); - if (root == null) { - return; - } - new File(root, "texture_replacements").mkdirs(); - new File(root, "USA/Card A").mkdirs(); - new File(root, "EUR/Card A").mkdirs(); - } - - private boolean isCustomDataPathEnabled() { - if (getContext() == null) { - return false; - } - - final File filesDir = getContext().getFilesDir(); - if (filesDir == null) { - return false; - } - - final File descriptor = new File(filesDir, LOCATION_DESCRIPTOR_NAME); - if (!descriptor.isFile()) { - return false; - } - - try { - final JSONObject json = new JSONObject(readText(descriptor)); - return "custom".equals(json.optString("mode", "default")); - } catch (IOException | JSONException e) { - return false; - } - } - - private static String readText(File file) throws IOException { - try (FileInputStream input = new FileInputStream(file); - ByteArrayOutputStream output = new ByteArrayOutputStream()) - { - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = input.read(buffer)) != -1) { - output.write(buffer, 0, bytesRead); - } - return output.toString(StandardCharsets.UTF_8.name()); - } - } - - private static String[] resolveRootProjection(String[] projection) { - return projection != null ? projection : DEFAULT_ROOT_PROJECTION; - } - - private static String[] resolveDocumentProjection(String[] projection) { - return projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION; - } - - private static String sanitizeDisplayName(String displayName) throws FileNotFoundException { - if (displayName == null) { - throw new FileNotFoundException("Document name is empty"); - } - - final String sanitized = displayName.trim(); - if (sanitized.isEmpty() || ".".equals(sanitized) || "..".equals(sanitized) || - sanitized.contains("/") || sanitized.contains("\\")) - { - throw new FileNotFoundException("Invalid document name: " + displayName); - } - return sanitized; - } - - private static File buildUniqueFile(File parent, String displayName) { - File file = new File(parent, displayName); - if (!file.exists()) { - return file; - } - - final int dot = displayName.lastIndexOf('.'); - final String baseName = dot > 0 ? displayName.substring(0, dot) : displayName; - final String extension = dot > 0 ? displayName.substring(dot) : ""; - for (int i = 1; i < 100; ++i) { - file = new File(parent, baseName + " (" + i + ")" + extension); - if (!file.exists()) { - return file; - } - } - return new File(parent, baseName + " (" + System.currentTimeMillis() + ")" + extension); - } - - private static int modeToParcelMode(String mode) { - if ("r".equals(mode)) { - return ParcelFileDescriptor.MODE_READ_ONLY; - } - if ("w".equals(mode) || "wt".equals(mode)) { - return ParcelFileDescriptor.MODE_WRITE_ONLY | - ParcelFileDescriptor.MODE_CREATE | - ParcelFileDescriptor.MODE_TRUNCATE; - } - if ("wa".equals(mode)) { - return ParcelFileDescriptor.MODE_WRITE_ONLY | - ParcelFileDescriptor.MODE_CREATE | - ParcelFileDescriptor.MODE_APPEND; - } - if ("rw".equals(mode)) { - return ParcelFileDescriptor.MODE_READ_WRITE | - ParcelFileDescriptor.MODE_CREATE; - } - if ("rwt".equals(mode)) { - return ParcelFileDescriptor.MODE_READ_WRITE | - ParcelFileDescriptor.MODE_CREATE | - ParcelFileDescriptor.MODE_TRUNCATE; - } - return ParcelFileDescriptor.MODE_READ_ONLY; - } - - private static String getMimeType(File file) { - final int dot = file.getName().lastIndexOf('.'); - if (dot >= 0) { - final String extension = file.getName().substring(dot + 1).toLowerCase(); - final String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); - if (mimeType != null) { - return mimeType; - } - } - return "application/octet-stream"; - } - - private Uri getChildDocumentsUri(String parentDocumentId) { - return DocumentsContract.buildChildDocumentsUri(AUTHORITY, parentDocumentId); - } - - private void notifyChildrenChanged(String parentDocumentId) { - final ContentResolver resolver = getContext().getContentResolver(); - resolver.notifyChange(getChildDocumentsUri(parentDocumentId), null, false); - } - - private void notifyDocumentChanged(String documentId) { - final ContentResolver resolver = getContext().getContentResolver(); - resolver.notifyChange(DocumentsContract.buildDocumentUri(AUTHORITY, documentId), null, false); - } - - private static void deleteRecursively(File file) throws FileNotFoundException { - if (file.isDirectory()) { - final File[] children = file.listFiles(); - if (children != null) { - for (File child : children) { - deleteRecursively(child); - } - } - } - if (!file.delete()) { - throw new FileNotFoundException("Unable to delete document: " + file); - } - } - - private static boolean isInside(File parent, File child) { - try { - final String parentPath = canonicalPath(parent); - final String childPath = canonicalPath(child); - return childPath.equals(parentPath) || childPath.startsWith(parentPath + File.separator); - } catch (FileNotFoundException e) { - return false; - } - } - - private static boolean sameFile(File a, File b) { - try { - return canonicalPath(a).equals(canonicalPath(b)); - } catch (FileNotFoundException e) { - return false; - } - } - - private static String canonicalPath(File file) throws FileNotFoundException { - try { - return file.getCanonicalPath(); - } catch (IOException e) { - throw asFileNotFound("Unable to resolve path", e); - } - } - - private static FileNotFoundException asFileNotFound(String message, IOException cause) { - final FileNotFoundException exception = new FileNotFoundException(message + ": " + cause.getMessage()); - exception.initCause(cause); - return exception; - } -} diff --git a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskHttpClient.java b/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskHttpClient.java deleted file mode 100644 index be160d6a2d..0000000000 --- a/platforms/android/app/src/main/java/com/twilitrealm/dusk/DuskHttpClient.java +++ /dev/null @@ -1,237 +0,0 @@ -package dev.twilitrealm.dusk; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.SocketTimeoutException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.net.ssl.HttpsURLConnection; - -public final class DuskHttpClient { - public static final int ERROR_NONE = 0; - public static final int ERROR_INVALID_URL = 1; - public static final int ERROR_UNSUPPORTED_SCHEME = 2; - public static final int ERROR_TIMEOUT = 3; - public static final int ERROR_TOO_LARGE = 4; - public static final int ERROR_NETWORK = 5; - - private static final int MAX_REDIRECTS = 5; - - public static final class Response { - public int error; - public String message; - public int statusCode; - public String[] headerNames; - public String[] headerValues; - public byte[] body; - - Response(int error, String message, int statusCode, String[] headerNames, - String[] headerValues, byte[] body) { - this.error = error; - this.message = message; - this.statusCode = statusCode; - this.headerNames = headerNames != null ? headerNames : new String[0]; - this.headerValues = headerValues != null ? headerValues : new String[0]; - this.body = body != null ? body : new byte[0]; - } - } - - private DuskHttpClient() { - } - - public static Response get(String url, String[] headerNames, String[] headerValues, - int timeoutMs, long maxBodyBytes) { - if (url == null || url.isEmpty()) { - return fail(ERROR_INVALID_URL, "URL is empty"); - } - - try { - URL currentUrl = new URL(url); - if (!isHttps(currentUrl)) { - return fail(ERROR_UNSUPPORTED_SCHEME, "Only https:// URLs are supported"); - } - - for (int redirect = 0; redirect <= MAX_REDIRECTS; ++redirect) { - HttpsURLConnection connection = - (HttpsURLConnection) currentUrl.openConnection(); - try { - connection.setRequestMethod("GET"); - connection.setConnectTimeout(timeoutMs); - connection.setReadTimeout(timeoutMs); - connection.setUseCaches(false); - connection.setInstanceFollowRedirects(false); - applyHeaders(connection, headerNames, headerValues); - - int statusCode = connection.getResponseCode(); - if (isRedirect(statusCode)) { - String location = connection.getHeaderField("Location"); - if (location == null || location.isEmpty()) { - return fail(ERROR_NETWORK, "Redirect response did not include Location", - statusCode, connection, new byte[0]); - } - - URL nextUrl = new URL(currentUrl, location); - if (!isHttps(nextUrl)) { - return fail(ERROR_UNSUPPORTED_SCHEME, - "Only https:// redirects are supported", statusCode, - connection, new byte[0]); - } - currentUrl = nextUrl; - continue; - } - - byte[] body = readBody(connection, statusCode, maxBodyBytes); - return success(statusCode, connection, body); - } catch (ResponseTooLargeException e) { - return fail(ERROR_TOO_LARGE, "Response body exceeded the configured limit", - safeStatusCode(connection), connection, e.partialBody); - } finally { - connection.disconnect(); - } - } - - return fail(ERROR_NETWORK, "Too many redirects"); - } catch (MalformedURLException e) { - return fail(ERROR_INVALID_URL, "Failed to parse URL"); - } catch (SocketTimeoutException e) { - return fail(ERROR_TIMEOUT, "Request timed out"); - } catch (IOException e) { - String message = e.getMessage(); - return fail(ERROR_NETWORK, message != null ? message : e.toString()); - } catch (ClassCastException e) { - return fail(ERROR_UNSUPPORTED_SCHEME, "Only https:// URLs are supported"); - } - } - - private static void applyHeaders(HttpsURLConnection connection, String[] names, - String[] values) { - if (names == null || values == null) { - return; - } - - int count = Math.min(names.length, values.length); - for (int i = 0; i < count; ++i) { - if (names[i] != null && values[i] != null) { - connection.setRequestProperty(names[i], values[i]); - } - } - } - - private static boolean isHttps(URL url) { - return "https".equalsIgnoreCase(url.getProtocol()); - } - - private static boolean isRedirect(int statusCode) { - return statusCode == HttpURLConnection.HTTP_MOVED_PERM || - statusCode == HttpURLConnection.HTTP_MOVED_TEMP || - statusCode == HttpURLConnection.HTTP_SEE_OTHER || - statusCode == 307 || - statusCode == 308; - } - - private static byte[] readBody(HttpsURLConnection connection, int statusCode, - long maxBodyBytes) throws IOException, - ResponseTooLargeException { - InputStream stream = statusCode >= HttpURLConnection.HTTP_BAD_REQUEST ? - connection.getErrorStream() : connection.getInputStream(); - if (stream == null) { - return new byte[0]; - } - - try (InputStream bodyStream = stream; - ByteArrayOutputStream out = new ByteArrayOutputStream()) { - byte[] buffer = new byte[8192]; - long total = 0; - while (true) { - int read = bodyStream.read(buffer); - if (read < 0) { - return out.toByteArray(); - } - if (read == 0) { - continue; - } - if (read > maxBodyBytes || total > maxBodyBytes - read) { - throw new ResponseTooLargeException(out.toByteArray()); - } - out.write(buffer, 0, read); - total += read; - } - } - } - - private static int safeStatusCode(HttpsURLConnection connection) { - try { - return connection.getResponseCode(); - } catch (IOException e) { - return 0; - } - } - - private static Response success(int statusCode, HttpsURLConnection connection, byte[] body) { - HeaderLists headers = readHeaders(connection); - return new Response(ERROR_NONE, "", statusCode, headers.names, headers.values, body); - } - - private static Response fail(int error, String message) { - return new Response(error, message, 0, null, null, null); - } - - private static Response fail(int error, String message, int statusCode, - HttpsURLConnection connection, byte[] body) { - HeaderLists headers = readHeaders(connection); - return new Response(error, message, statusCode, headers.names, headers.values, body); - } - - private static HeaderLists readHeaders(HttpsURLConnection connection) { - List names = new ArrayList<>(); - List values = new ArrayList<>(); - - Map> headerFields = connection.getHeaderFields(); - if (headerFields == null) { - return new HeaderLists(new String[0], new String[0]); - } - - for (Map.Entry> entry : headerFields.entrySet()) { - String name = entry.getKey(); - if (name == null) { - continue; - } - List entryValues = entry.getValue(); - if (entryValues == null || entryValues.isEmpty()) { - names.add(name); - values.add(""); - continue; - } - for (String value : entryValues) { - names.add(name); - values.add(value != null ? value : ""); - } - } - - return new HeaderLists(names.toArray(new String[0]), values.toArray(new String[0])); - } - - private static final class HeaderLists { - final String[] names; - final String[] values; - - HeaderLists(String[] names, String[] values) { - this.names = names; - this.values = values; - } - } - - private static final class ResponseTooLargeException extends Exception { - final byte[] partialBody; - - ResponseTooLargeException(byte[] partialBody) { - this.partialBody = partialBody; - } - } -} diff --git a/platforms/android/app/src/main/java/org/libsdl/app/HIDDevice.java b/platforms/android/app/src/main/java/org/libsdl/app/HIDDevice.java deleted file mode 100644 index f96095324b..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDevice.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.libsdl.app; - -import android.hardware.usb.UsbDevice; - -interface HIDDevice -{ - public int getId(); - public int getVendorId(); - public int getProductId(); - public String getSerialNumber(); - public int getVersion(); - public String getManufacturerName(); - public String getProductName(); - public UsbDevice getDevice(); - public boolean open(); - public int writeReport(byte[] report, boolean feature); - public boolean readReport(byte[] report, boolean feature); - public void setFrozen(boolean frozen); - public void close(); - public void shutdown(); -} diff --git a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java b/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java deleted file mode 100644 index bcd8806c41..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java +++ /dev/null @@ -1,829 +0,0 @@ -package org.libsdl.app; - -import android.content.Context; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothGatt; -import android.bluetooth.BluetoothGattCallback; -import android.bluetooth.BluetoothGattCharacteristic; -import android.bluetooth.BluetoothGattDescriptor; -import android.bluetooth.BluetoothManager; -import android.bluetooth.BluetoothProfile; -import android.bluetooth.BluetoothGattService; -import android.hardware.usb.UsbDevice; -import android.os.Handler; -import android.os.Looper; -import android.util.Log; -import android.os.*; - -//import com.android.internal.util.HexDump; - -import java.lang.Runnable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.UUID; - -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDevice { - - private static final String TAG = "hidapi"; - private HIDDeviceManager mManager; - private BluetoothDevice mDevice; - private int mDeviceId; - private BluetoothGatt mGatt; - private boolean mIsRegistered = false; - private boolean mIsConnected = false; - private boolean mIsChromebook = false; - private boolean mIsReconnecting = false; - private boolean mHasEnabledNotifications = false; - private boolean mHasSeenInputUpdate = false; - private boolean mFrozen = false; - private LinkedList mOperations; - GattOperation mCurrentOperation = null; - private Handler mHandler; - private int mProductId = -1; - private int mReportId = 0; - private UUID mInputCharacteristic; - - private static final int D0G_BLE2_PID = 0x1106; - private static final int TRITON_BLE_PID = 0x1303; - - - private static final int TRANSPORT_AUTO = 0; - private static final int TRANSPORT_BREDR = 1; - private static final int TRANSPORT_LE = 2; - - private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000; - - static final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3"); - static final UUID inputCharacteristicD0G = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3"); - static final UUID inputCharacteristicTriton_0x45 = UUID.fromString("100F6C7A-1735-4313-B402-38567131E5F3"); - static final UUID inputCharacteristicTriton_0x47 = UUID.fromString("100F6C7C-1735-4313-B402-38567131E5F3"); - static final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3"); - static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 }; - - private HashMap mOutputReportChars = new HashMap(); - - static class GattOperation { - private enum Operation { - CHR_READ, - CHR_WRITE, - ENABLE_NOTIFICATION - } - - Operation mOp; - UUID mUuid; - byte[] mValue; - BluetoothGatt mGatt; - boolean mResult = true; - int mDelayMs = 0; - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - } - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, int delayMs) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - mDelayMs = delayMs; - } - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - mValue = value; - } - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value, int delayMs) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - mValue = value; - mDelayMs = delayMs; - } - - public void run() { - // This is executed in main thread - BluetoothGattCharacteristic chr; - - switch (mOp) { - case CHR_READ: - chr = getCharacteristic(mUuid); - //Log.v(TAG, "Reading characteristic " + chr.getUuid()); - if (!mGatt.readCharacteristic(chr)) { - Log.e(TAG, "Unable to read characteristic " + mUuid.toString()); - mResult = false; - break; - } - mResult = true; - break; - case CHR_WRITE: - chr = getCharacteristic(mUuid); - //Log.v(TAG, "Writing characteristic " + chr.getUuid() + " value=" + HexDump.toHexString(value)); - chr.setValue(mValue); - if (!mGatt.writeCharacteristic(chr)) { - Log.e(TAG, "Unable to write characteristic " + mUuid.toString()); - mResult = false; - break; - } - mResult = true; - break; - case ENABLE_NOTIFICATION: - chr = getCharacteristic(mUuid); - //Log.v(TAG, "Writing descriptor of " + chr.getUuid()); - if (chr != null) { - BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")); - if (cccd != null) { - int properties = chr.getProperties(); - byte[] value; - if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) { - value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE; - } else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) { - value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE; - } else { - Log.e(TAG, "Unable to start notifications on input characteristic"); - mResult = false; - return; - } - - mGatt.setCharacteristicNotification(chr, true); - cccd.setValue(value); - if (!mGatt.writeDescriptor(cccd)) { - Log.e(TAG, "Unable to write descriptor " + mUuid.toString()); - mResult = false; - return; - } - mResult = true; - } - } - } - } - - public boolean finish() { - return mResult; - } - - public int getDelayMs() { return mDelayMs; } - - private BluetoothGattCharacteristic getCharacteristic(UUID uuid) { - BluetoothGattService valveService = mGatt.getService(steamControllerService); - if (valveService == null) - return null; - return valveService.getCharacteristic(uuid); - } - - static public GattOperation readCharacteristic(BluetoothGatt gatt, UUID uuid) { - return new GattOperation(gatt, Operation.CHR_READ, uuid); - } - - static public GattOperation writeCharacteristic(BluetoothGatt gatt, UUID uuid, byte[] value) { - return new GattOperation(gatt, Operation.CHR_WRITE, uuid, value); - } - - static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) { - return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid); - } - - static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid, int delayMs) { - return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid, delayMs); - } - } - - HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) { - mManager = manager; - mDevice = device; - mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier()); - mIsRegistered = false; - mIsChromebook = SDLActivity.isChromebook(); - mOperations = new LinkedList(); - mHandler = new Handler(Looper.getMainLooper()); - - mGatt = connectGatt(); - mHasEnabledNotifications = false; - mHasSeenInputUpdate = false; - // final HIDDeviceBLESteamController finalThis = this; - // mHandler.postDelayed(new Runnable() { - // @Override - // void run() { - // finalThis.checkConnectionForChromebookIssue(); - // } - // }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL); - } - - String getIdentifier() { - return String.format("SteamController.%s", mDevice.getAddress()); - } - - BluetoothGatt getGatt() { - return mGatt; - } - - // Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead - // of TRANSPORT_LE. Let's force ourselves to connect low energy. - private BluetoothGatt connectGatt(boolean managed) { - if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) { - try { - return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE); - } catch (Exception e) { - return mDevice.connectGatt(mManager.getContext(), managed, this); - } - } else { - return mDevice.connectGatt(mManager.getContext(), managed, this); - } - } - - private BluetoothGatt connectGatt() { - return connectGatt(false); - } - - protected int getConnectionState() { - - Context context = mManager.getContext(); - if (context == null) { - // We are lacking any context to get our Bluetooth information. We'll just assume disconnected. - return BluetoothProfile.STATE_DISCONNECTED; - } - - BluetoothManager btManager = (BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE); - if (btManager == null) { - // This device doesn't support Bluetooth. We should never be here, because how did - // we instantiate a device to start with? - return BluetoothProfile.STATE_DISCONNECTED; - } - - return btManager.getConnectionState(mDevice, BluetoothProfile.GATT); - } - - void reconnect() { - - if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) { - mGatt.disconnect(); - mGatt = connectGatt(); - } - - } - - protected void checkConnectionForChromebookIssue() { - if (!mIsChromebook) { - // We only do this on Chromebooks, because otherwise it's really annoying to just attempt - // over and over. - return; - } - - int connectionState = getConnectionState(); - - switch (connectionState) { - case BluetoothProfile.STATE_CONNECTED: - if (!mIsConnected) { - // We are in the Bad Chromebook Place. We can force a disconnect - // to try to recover. - Log.v(TAG, "Chromebook: We are in a very bad state; the controller shows as connected in the underlying Bluetooth layer, but we never received a callback. Forcing a reconnect."); - mIsReconnecting = true; - mGatt.disconnect(); - mGatt = connectGatt(false); - break; - } - else if (!isRegistered()) { - if (mGatt.getServices().size() > 0) { - Log.v(TAG, "Chromebook: We are connected to a controller, but never got our registration. Trying to recover."); - probeService(this); - } - else { - Log.v(TAG, "Chromebook: We are connected to a controller, but never discovered services. Trying to recover."); - mIsReconnecting = true; - mGatt.disconnect(); - mGatt = connectGatt(false); - break; - } - } - else { - Log.v(TAG, "Chromebook: We are connected, and registered. Everything's good!"); - return; - } - break; - - case BluetoothProfile.STATE_DISCONNECTED: - Log.v(TAG, "Chromebook: We have either been disconnected, or the Chromebook BtGatt.ContextMap bug has bitten us. Attempting a disconnect/reconnect, but we may not be able to recover."); - - mIsReconnecting = true; - mGatt.disconnect(); - mGatt = connectGatt(false); - break; - - case BluetoothProfile.STATE_CONNECTING: - Log.v(TAG, "Chromebook: We're still trying to connect. Waiting a bit longer."); - break; - } - - final HIDDeviceBLESteamController finalThis = this; - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - finalThis.checkConnectionForChromebookIssue(); - } - }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL); - } - - private boolean isRegistered() { - return mIsRegistered; - } - - private void setRegistered() { - mIsRegistered = true; - } - - private boolean probeService(HIDDeviceBLESteamController controller) { - - if (isRegistered()) { - return true; - } - - if (!mIsConnected) { - return false; - } - - Log.v(TAG, "probeService controller=" + controller); - - for (BluetoothGattService service : mGatt.getServices()) { - if (service.getUuid().equals(steamControllerService)) { - Log.v(TAG, "Found Valve steam controller service " + service.getUuid()); - - for (BluetoothGattCharacteristic chr : service.getCharacteristics()) { - if (chr.getUuid().equals(inputCharacteristicTriton_0x45)) { - Log.v(TAG, "Found Triton input characteristic 0x45"); - mProductId = TRITON_BLE_PID; - mReportId = 0x45; - mInputCharacteristic = chr.getUuid(); - } else if (chr.getUuid().equals(inputCharacteristicTriton_0x47)) { - Log.v(TAG, "Found Triton input characteristic 0x47"); - mProductId = TRITON_BLE_PID; - mReportId = 0x47; - mInputCharacteristic = chr.getUuid(); - } else if (chr.getUuid().equals(inputCharacteristicD0G)) { - Log.v(TAG, "Found D0G input characteristic"); - mProductId = D0G_BLE2_PID; - mReportId = 0x03; - mInputCharacteristic = chr.getUuid(); - } else { - Pattern reportPattern = Pattern.compile("100F6C([0-9A-Z]{2})", Pattern.CASE_INSENSITIVE); - Matcher matcher = reportPattern.matcher(chr.getUuid().toString()); - - if (matcher.find()) { - try { - int reportId = Integer.parseInt(matcher.group(1), 16); - - reportId -= 0x35; - if (reportId >= 0x80) { - // This is a Triton output report characteristic that we need to care about. - Log.v(TAG, "Found Triton output report 0x" + Integer.toString(reportId, 16)); - mOutputReportChars.put(reportId, chr); - } - } - catch (NumberFormatException nfe) { - Log.w(TAG, "Could not parse report characteristic " + chr.getUuid().toString() + ": " + nfe.toString()); - } - } - } - } - - for (BluetoothGattCharacteristic chr : service.getCharacteristics()) { - if (chr.getUuid().equals(mInputCharacteristic)) { - // Start notifications - BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")); - if (cccd != null) { - enableNotification(chr.getUuid()); - } - } - } - return true; - } - } - - if ((mGatt.getServices().size() == 0) && mIsChromebook && !mIsReconnecting) { - Log.e(TAG, "Chromebook: Discovered services were empty; this almost certainly means the BtGatt.ContextMap bug has bitten us."); - mIsConnected = false; - mIsReconnecting = true; - mGatt.disconnect(); - mGatt = connectGatt(false); - } - - return false; - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - private void finishCurrentGattOperation() { - GattOperation op = null; - synchronized (mOperations) { - if (mCurrentOperation != null) { - op = mCurrentOperation; - mCurrentOperation = null; - } - } - if (op != null) { - boolean result = op.finish(); // TODO: Maybe in main thread as well? - - // Our operation failed, let's add it back to the beginning of our queue. - if (!result) { - mOperations.addFirst(op); - } - } - executeNextGattOperation(); - } - - private void executeNextGattOperation() { - synchronized (mOperations) { - if (mCurrentOperation != null) - return; - - if (mOperations.isEmpty()) - return; - - mCurrentOperation = mOperations.removeFirst(); - } - - Runnable gattOperationRunnable = new Runnable() { - @Override - public void run() { - synchronized (mOperations) { - if (mCurrentOperation == null) { - Log.e(TAG, "Current operation null in executor?"); - return; - } - - mCurrentOperation.run(); - // now wait for the GATT callback and when it comes, finish this operation - } - } - }; - - if (mCurrentOperation.getDelayMs() == 0) { - // Run in main thread - mHandler.post(gattOperationRunnable); - } - else { - // If we have a delay on this operation, wait before we post it. - mHandler.postDelayed(gattOperationRunnable, mCurrentOperation.getDelayMs()); - } - - } - - private void queueGattOperation(GattOperation op) { - synchronized (mOperations) { - mOperations.add(op); - } - executeNextGattOperation(); - } - - private void enableNotification(UUID chrUuid) { - // Add a 500ms delay to notification write for Amazon Fire TV devices, as otherwise if we do this too quickly after connecting - // it will return success and then silently drop the operation on the floor. - GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid, 500); - queueGattOperation(op); - - // Amazon Fire devices can also silently timeout on writeDescriptor, so - // set up a little delayed check that will attempt to write a second time. - // - // While this only seems to be needed on Amazon Fire TV devices at present, it - // doesn't hurt to have a retry on other devices as well. - // - final HIDDeviceBLESteamController finalThis = this; - final UUID finalUuid = chrUuid; - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - if (!finalThis.mHasEnabledNotifications) { - - if (finalThis.mHasSeenInputUpdate) { - // Amazon Five devices may have enabled notifications on the input characteristic and not given us a callback. If we've seen - // input reports, though, somewhat by definition notifications are enabled. - Log.w(TAG, "WriteDescriptor has never returned, but we've seen input reports. Moving on with controller initialization."); - finalThis.mHasEnabledNotifications = true; - finalThis.enableValveMode(); - return; - } - - // Give one more try. - GattOperation retry = HIDDeviceBLESteamController.GattOperation.enableNotification(finalThis.mGatt, finalUuid, 500); - finalThis.queueGattOperation(retry); - } - } - }, 1000); - } - - void writeCharacteristic(UUID uuid, byte[] value) { - GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value); - queueGattOperation(op); - } - - void readCharacteristic(UUID uuid) { - GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid); - queueGattOperation(op); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////// BluetoothGattCallback overridden methods - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public void onConnectionStateChange(BluetoothGatt g, int status, int newState) { - //Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState); - mIsReconnecting = false; - if (newState == 2) { - mIsConnected = true; - // Run directly, without GattOperation - if (!isRegistered()) { - mHandler.post(new Runnable() { - @Override - public void run() { - mGatt.discoverServices(); - } - }); - } - } - else if (newState == 0) { - mIsConnected = false; - } - - // Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent. - } - - @Override - public void onServicesDiscovered(BluetoothGatt gatt, int status) { - //Log.v(TAG, "onServicesDiscovered status=" + status); - if (status == 0) { - if (gatt.getServices().size() == 0) { - Log.v(TAG, "onServicesDiscovered returned zero services; something has gone horribly wrong down in Android's Bluetooth stack."); - mIsReconnecting = true; - mIsConnected = false; - gatt.disconnect(); - mGatt = connectGatt(false); - } else { - if (getProductId() == TRITON_BLE_PID) { - // Android will not properly play well with Data Length Extensions without manually requesting a large MTU, - // and Triton controllers require DLE support. - // - // 517 is basically a "magic number" as far as Android's bluetooth code is concerned, so do not change - // this value. It is functionally "please enable data length extensions" on some Android builds. - mGatt.requestMtu(517); - } - - probeService(this); - } - } - } - - @Override - public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - //Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid()); - - if (characteristic.getUuid().equals(reportCharacteristic) && !mFrozen) { - mManager.HIDDeviceReportResponse(getId(), characteristic.getValue()); - } - - finishCurrentGattOperation(); - } - - @Override - public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - //Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid()); - - if (characteristic.getUuid().equals(reportCharacteristic)) { - // Only register controller with the native side once it has been fully configured - if (!isRegistered()) { - Log.v(TAG, "Registering Steam Controller with ID: " + getId()); - mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0, true, mReportId); - setRegistered(); - } - } - - finishCurrentGattOperation(); - } - - @Override - public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { - // Enable this for verbose logging of controller input reports - //Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue())); - - if (characteristic.getUuid().equals(mInputCharacteristic) && !mFrozen) { - mHasSeenInputUpdate = true; - mManager.HIDDeviceInputReport(getId(), characteristic.getValue()); - } - } - - @Override - public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { - //Log.v(TAG, "onDescriptorRead status=" + status); - } - - private void enableValveMode() - { - BluetoothGattService valveService = mGatt.getService(steamControllerService); - if (valveService == null) - return; - - BluetoothGattCharacteristic reportChr = valveService.getCharacteristic(reportCharacteristic); - if (reportChr != null) { - if (getProductId() == TRITON_BLE_PID) { - // For Triton we just mark things registered. - Log.v(TAG, "Registering Triton Steam Controller with ID: " + getId()); - mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0, true, mReportId); - setRegistered(); - } else { - // For the original controller, we need to manually enter Valve mode. - Log.v(TAG, "Writing report characteristic to enter valve mode"); - reportChr.setValue(enterValveMode); - mGatt.writeCharacteristic(reportChr); - } - } - } - - @Override - public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { - BluetoothGattCharacteristic chr = descriptor.getCharacteristic(); - //Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid()); - - if (chr.getUuid().equals(mInputCharacteristic)) { - mHasEnabledNotifications = true; - enableValveMode(); - } - - finishCurrentGattOperation(); - } - - @Override - public void onReliableWriteCompleted(BluetoothGatt gatt, int status) { - //Log.v(TAG, "onReliableWriteCompleted status=" + status); - } - - @Override - public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { - //Log.v(TAG, "onReadRemoteRssi status=" + status); - } - - @Override - public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { - //Log.v(TAG, "onMtuChanged status=" + status); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - //////// Public API - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public int getId() { - return mDeviceId; - } - - @Override - public int getVendorId() { - // Valve Corporation - final int VALVE_USB_VID = 0x28DE; - return VALVE_USB_VID; - } - - @Override - public int getProductId() { - if (mProductId > 0) { - // We've already set a product ID. - return mProductId; - } - - if (mDevice.getName().startsWith("Steam Ctrl")) { - // We're a newer Triton device - mProductId = TRITON_BLE_PID; - } else { - // We're an OG Steam Controller - mProductId = D0G_BLE2_PID; - } - - return mProductId; - } - - @Override - public String getSerialNumber() { - // This will be read later via feature report by Steam - return "12345"; - } - - @Override - public int getVersion() { - return 0; - } - - @Override - public String getManufacturerName() { - return "Valve Corporation"; - } - - @Override - public String getProductName() { - return "Steam Controller"; - } - - @Override - public UsbDevice getDevice() { - return null; - } - - @Override - public boolean open() { - return true; - } - - @Override - public int writeReport(byte[] report, boolean feature) { - if (!isRegistered()) { - Log.e(TAG, "Attempted writeReport before Steam Controller is registered!"); - if (mIsConnected) { - probeService(this); - } - return -1; - } - - if (feature) { - // We need to skip the first byte, as that doesn't go over the air - byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1); - //Log.v(TAG, "writeFeatureReport " + HexDump.dumpHexString(actual_report)); - writeCharacteristic(reportCharacteristic, actual_report); - return report.length; - } else { - // If we're an original-recipe Steam Controller we just write to the characteristic directly. - if (getProductId() == D0G_BLE2_PID) { - //Log.v(TAG, "writeOutputReport " + HexDump.dumpHexString(report)); - writeCharacteristic(reportCharacteristic, report); - return report.length; - } - - // If we're a Triton, we need to find the correct report characteristic. - if (report.length > 0) { - int reportId = report[0] & 0xFF; - BluetoothGattCharacteristic targetedReportCharacteristic = mOutputReportChars.get(reportId); - if (targetedReportCharacteristic != null) { - byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1); - //Log.v(TAG, "writeOutputReport 0x" + Integer.toString(reportId, 16) + " " + HexDump.dumpHexString(report)); - writeCharacteristic(targetedReportCharacteristic.getUuid(), actual_report); - return report.length; - } else { - Log.w(TAG, "Got report write request for unknown report type 0x" + Integer.toString(reportId, 16)); - } - } - } - - return -1; - } - - @Override - public boolean readReport(byte[] report, boolean feature) { - if (!isRegistered()) { - Log.e(TAG, "Attempted readReport before Steam Controller is registered!"); - if (mIsConnected) { - probeService(this); - } - return false; - } - - if (feature) { - readCharacteristic(reportCharacteristic); - return true; - } else { - // Not implemented - return false; - } - } - - @Override - public void close() { - } - - @Override - public void setFrozen(boolean frozen) { - mFrozen = frozen; - } - - @Override - public void shutdown() { - close(); - - BluetoothGatt g = mGatt; - if (g != null) { - g.disconnect(); - g.close(); - mGatt = null; - } - mManager = null; - mIsRegistered = false; - mIsConnected = false; - mOperations.clear(); - } - -} - diff --git a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java deleted file mode 100644 index 691416c1c9..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ /dev/null @@ -1,698 +0,0 @@ -package org.libsdl.app; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.PendingIntent; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothManager; -import android.bluetooth.BluetoothProfile; -import android.os.Build; -import android.util.Log; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.hardware.usb.*; -import android.os.Handler; -import android.os.Looper; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -public class HIDDeviceManager { - private static final String TAG = "hidapi"; - private static final String ACTION_USB_PERMISSION = "org.libsdl.app.USB_PERMISSION"; - - private static HIDDeviceManager sManager; - private static int sManagerRefCount = 0; - - static public HIDDeviceManager acquire(Context context) { - if (sManagerRefCount == 0) { - sManager = new HIDDeviceManager(context); - } - ++sManagerRefCount; - return sManager; - } - - static public void release(HIDDeviceManager manager) { - if (manager == sManager) { - --sManagerRefCount; - if (sManagerRefCount == 0) { - sManager.close(); - sManager = null; - } - } - } - - private Context mContext; - private HashMap mDevicesById = new HashMap(); - private HashMap mBluetoothDevices = new HashMap(); - private int mNextDeviceId = 0; - private SharedPreferences mSharedPreferences = null; - private boolean mIsChromebook = false; - private UsbManager mUsbManager; - private Handler mHandler; - private BluetoothManager mBluetoothManager; - private List mLastBluetoothDevices; - - private final BroadcastReceiver mUsbBroadcast = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) { - UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); - handleUsbDeviceAttached(usbDevice); - } else if (action.equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) { - UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); - handleUsbDeviceDetached(usbDevice); - } else if (action.equals(HIDDeviceManager.ACTION_USB_PERMISSION)) { - UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); - handleUsbDevicePermission(usbDevice, intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)); - } - } - }; - - private final BroadcastReceiver mBluetoothBroadcast = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - // Bluetooth device was connected. If it was a Steam Controller, handle it - if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) { - BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - Log.d(TAG, "Bluetooth device connected: " + device); - - if (isSteamController(device)) { - connectBluetoothDevice(device); - } - } - - // Bluetooth device was disconnected, remove from controller manager (if any) - if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) { - BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - Log.d(TAG, "Bluetooth device disconnected: " + device); - - disconnectBluetoothDevice(device); - } - } - }; - - private HIDDeviceManager(final Context context) { - mContext = context; - - HIDDeviceRegisterCallback(); - - mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE); - mIsChromebook = SDLActivity.isChromebook(); - -// if (shouldClear) { -// SharedPreferences.Editor spedit = mSharedPreferences.edit(); -// spedit.clear(); -// spedit.apply(); -// } -// else - { - mNextDeviceId = mSharedPreferences.getInt("next_device_id", 0); - } - } - - Context getContext() { - return mContext; - } - - int getDeviceIDForIdentifier(String identifier) { - SharedPreferences.Editor spedit = mSharedPreferences.edit(); - - int result = mSharedPreferences.getInt(identifier, 0); - if (result == 0) { - result = mNextDeviceId++; - spedit.putInt("next_device_id", mNextDeviceId); - } - - spedit.putInt(identifier, result); - spedit.apply(); - return result; - } - - private void initializeUSB() { - mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE); - if (mUsbManager == null) { - return; - } - - /* - // Logging - for (UsbDevice device : mUsbManager.getDeviceList().values()) { - Log.i(TAG,"Path: " + device.getDeviceName()); - Log.i(TAG,"Manufacturer: " + device.getManufacturerName()); - Log.i(TAG,"Product: " + device.getProductName()); - Log.i(TAG,"ID: " + device.getDeviceId()); - Log.i(TAG,"Class: " + device.getDeviceClass()); - Log.i(TAG,"Protocol: " + device.getDeviceProtocol()); - Log.i(TAG,"Vendor ID " + device.getVendorId()); - Log.i(TAG,"Product ID: " + device.getProductId()); - Log.i(TAG,"Interface count: " + device.getInterfaceCount()); - Log.i(TAG,"---------------------------------------"); - - // Get interface details - for (int index = 0; index < device.getInterfaceCount(); index++) { - UsbInterface mUsbInterface = device.getInterface(index); - Log.i(TAG," ***** *****"); - Log.i(TAG," Interface index: " + index); - Log.i(TAG," Interface ID: " + mUsbInterface.getId()); - Log.i(TAG," Interface class: " + mUsbInterface.getInterfaceClass()); - Log.i(TAG," Interface subclass: " + mUsbInterface.getInterfaceSubclass()); - Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol()); - Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount()); - - // Get endpoint details - for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++) - { - UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi); - Log.i(TAG," ++++ ++++ ++++"); - Log.i(TAG," Endpoint index: " + epi); - Log.i(TAG," Attributes: " + mEndpoint.getAttributes()); - Log.i(TAG," Direction: " + mEndpoint.getDirection()); - Log.i(TAG," Number: " + mEndpoint.getEndpointNumber()); - Log.i(TAG," Interval: " + mEndpoint.getInterval()); - Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize()); - Log.i(TAG," Type: " + mEndpoint.getType()); - } - } - } - Log.i(TAG," No more devices connected."); - */ - - // Register for USB broadcasts and permission completions - IntentFilter filter = new IntentFilter(); - filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); - filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); - filter.addAction(HIDDeviceManager.ACTION_USB_PERMISSION); - if (Build.VERSION.SDK_INT >= 33) { /* Android 13.0 (TIRAMISU) */ - mContext.registerReceiver(mUsbBroadcast, filter, Context.RECEIVER_EXPORTED); - } else { - mContext.registerReceiver(mUsbBroadcast, filter); - } - - for (UsbDevice usbDevice : mUsbManager.getDeviceList().values()) { - handleUsbDeviceAttached(usbDevice); - } - } - - UsbManager getUSBManager() { - return mUsbManager; - } - - private void shutdownUSB() { - try { - mContext.unregisterReceiver(mUsbBroadcast); - } catch (Exception e) { - // We may not have registered, that's okay - } - } - - private boolean isHIDDeviceInterface(UsbDevice usbDevice, UsbInterface usbInterface) { - if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) { - return true; - } - if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) { - return true; - } - return false; - } - - private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) { - final int XB360_IFACE_SUBCLASS = 93; - final int XB360_IFACE_PROTOCOL = 1; // Wired - final int XB360W_IFACE_PROTOCOL = 129; // Wireless - final int[] SUPPORTED_VENDORS = { - 0x0079, // GPD Win 2 - 0x044f, // Thrustmaster - 0x045e, // Microsoft - 0x046d, // Logitech - 0x056e, // Elecom - 0x06a3, // Saitek - 0x0738, // Mad Catz - 0x07ff, // Mad Catz - 0x0e6f, // PDP - 0x0f0d, // Hori - 0x1038, // SteelSeries - 0x11c9, // Nacon - 0x12ab, // Unknown - 0x1430, // RedOctane - 0x146b, // BigBen - 0x1532, // Razer Sabertooth - 0x15e4, // Numark - 0x162e, // Joytech - 0x1689, // Razer Onza - 0x1949, // Lab126, Inc. - 0x1bad, // Harmonix - 0x20d6, // PowerA - 0x24c6, // PowerA - 0x2c22, // Qanba - 0x2dc8, // 8BitDo - 0x3537, // GameSir - 0x37d7, // Flydigi - 0x9886, // ASTRO Gaming - }; - - if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC && - usbInterface.getInterfaceSubclass() == XB360_IFACE_SUBCLASS && - (usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL || - usbInterface.getInterfaceProtocol() == XB360W_IFACE_PROTOCOL)) { - int vendor_id = usbDevice.getVendorId(); - for (int supportedVid : SUPPORTED_VENDORS) { - if (vendor_id == supportedVid) { - return true; - } - } - } - return false; - } - - private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) { - final int XB1_IFACE_SUBCLASS = 71; - final int XB1_IFACE_PROTOCOL = 208; - final int[] SUPPORTED_VENDORS = { - 0x03f0, // HP - 0x044f, // Thrustmaster - 0x045e, // Microsoft - 0x0738, // Mad Catz - 0x0b05, // ASUS - 0x0e6f, // PDP - 0x0f0d, // Hori - 0x10f5, // Turtle Beach - 0x1532, // Razer Wildcat - 0x20d6, // PowerA - 0x24c6, // PowerA - 0x294b, // Snakebyte - 0x2dc8, // 8BitDo - 0x2e24, // Hyperkin - 0x2e95, // SCUF - 0x3285, // Nacon - 0x3537, // GameSir - 0x366c, // ByoWave - }; - - if (usbInterface.getId() == 0 && - usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC && - usbInterface.getInterfaceSubclass() == XB1_IFACE_SUBCLASS && - usbInterface.getInterfaceProtocol() == XB1_IFACE_PROTOCOL) { - int vendor_id = usbDevice.getVendorId(); - for (int supportedVid : SUPPORTED_VENDORS) { - if (vendor_id == supportedVid) { - return true; - } - } - } - return false; - } - - private void handleUsbDeviceAttached(UsbDevice usbDevice) { - connectHIDDeviceUSB(usbDevice); - } - - private void handleUsbDeviceDetached(UsbDevice usbDevice) { - List devices = new ArrayList(); - for (HIDDevice device : mDevicesById.values()) { - if (usbDevice.equals(device.getDevice())) { - devices.add(device.getId()); - } - } - for (int id : devices) { - HIDDevice device = mDevicesById.get(id); - mDevicesById.remove(id); - device.shutdown(); - HIDDeviceDisconnected(id); - } - } - - private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) { - for (HIDDevice device : mDevicesById.values()) { - if (usbDevice.equals(device.getDevice())) { - boolean opened = false; - if (permission_granted) { - opened = device.open(); - } - HIDDeviceOpenResult(device.getId(), opened); - } - } - } - - private void connectHIDDeviceUSB(UsbDevice usbDevice) { - synchronized (this) { - int interface_mask = 0; - for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) { - UsbInterface usbInterface = usbDevice.getInterface(interface_index); - if (isHIDDeviceInterface(usbDevice, usbInterface)) { - // Check to see if we've already added this interface - // This happens with the Xbox Series X controller which has a duplicate interface 0, which is inactive - int interface_id = usbInterface.getId(); - if ((interface_mask & (1 << interface_id)) != 0) { - continue; - } - interface_mask |= (1 << interface_id); - - HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index); - int id = device.getId(); - mDevicesById.put(id, device); - HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol(), false, 0); - } - } - } - } - - private void initializeBluetooth() { - Log.d(TAG, "Initializing Bluetooth"); - - if (Build.VERSION.SDK_INT >= 31 /* Android 12 */ && - mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH_CONNECT, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) { - Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH_CONNECT"); - return; - } - - if (Build.VERSION.SDK_INT <= 30 /* Android 11.0 (R) */ && - mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) { - Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH"); - return; - } - - if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { - Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE"); - return; - } - - // Find bonded bluetooth controllers and create SteamControllers for them - mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE); - if (mBluetoothManager == null) { - // This device doesn't support Bluetooth. - return; - } - - BluetoothAdapter btAdapter = mBluetoothManager.getAdapter(); - if (btAdapter == null) { - // This device has Bluetooth support in the codebase, but has no available adapters. - return; - } - - // Get our bonded devices. - for (BluetoothDevice device : btAdapter.getBondedDevices()) { - - Log.d(TAG, "Bluetooth device available: " + device); - if (isSteamController(device)) { - connectBluetoothDevice(device); - } - - } - - // NOTE: These don't work on Chromebooks, to my undying dismay. - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); - filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); - if (Build.VERSION.SDK_INT >= 33) { /* Android 13.0 (TIRAMISU) */ - mContext.registerReceiver(mBluetoothBroadcast, filter, Context.RECEIVER_EXPORTED); - } else { - mContext.registerReceiver(mBluetoothBroadcast, filter); - } - - if (mIsChromebook) { - mHandler = new Handler(Looper.getMainLooper()); - mLastBluetoothDevices = new ArrayList(); - - // final HIDDeviceManager finalThis = this; - // mHandler.postDelayed(new Runnable() { - // @Override - // public void run() { - // finalThis.chromebookConnectionHandler(); - // } - // }, 5000); - } - } - - private void shutdownBluetooth() { - try { - mContext.unregisterReceiver(mBluetoothBroadcast); - } catch (Exception e) { - // We may not have registered, that's okay - } - } - - // Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly. - // This function provides a sort of dummy version of that, watching for changes in the - // connected devices and attempting to add controllers as things change. - void chromebookConnectionHandler() { - if (!mIsChromebook) { - return; - } - - ArrayList disconnected = new ArrayList(); - ArrayList connected = new ArrayList(); - - List currentConnected = mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT); - - for (BluetoothDevice bluetoothDevice : currentConnected) { - if (!mLastBluetoothDevices.contains(bluetoothDevice)) { - connected.add(bluetoothDevice); - } - } - for (BluetoothDevice bluetoothDevice : mLastBluetoothDevices) { - if (!currentConnected.contains(bluetoothDevice)) { - disconnected.add(bluetoothDevice); - } - } - - mLastBluetoothDevices = currentConnected; - - for (BluetoothDevice bluetoothDevice : disconnected) { - disconnectBluetoothDevice(bluetoothDevice); - } - for (BluetoothDevice bluetoothDevice : connected) { - connectBluetoothDevice(bluetoothDevice); - } - - final HIDDeviceManager finalThis = this; - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - finalThis.chromebookConnectionHandler(); - } - }, 10000); - } - - boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) { - Log.v(TAG, "connectBluetoothDevice device=" + bluetoothDevice); - synchronized (this) { - if (mBluetoothDevices.containsKey(bluetoothDevice)) { - Log.v(TAG, "Steam controller with address " + bluetoothDevice + " already exists, attempting reconnect"); - - HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice); - device.reconnect(); - - return false; - } - HIDDeviceBLESteamController device = new HIDDeviceBLESteamController(this, bluetoothDevice); - int id = device.getId(); - mBluetoothDevices.put(bluetoothDevice, device); - mDevicesById.put(id, device); - - // The Steam Controller will mark itself connected once initialization is complete - } - return true; - } - - void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) { - synchronized (this) { - HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice); - if (device == null) - return; - - int id = device.getId(); - mBluetoothDevices.remove(bluetoothDevice); - mDevicesById.remove(id); - device.shutdown(); - HIDDeviceDisconnected(id); - } - } - - boolean isSteamController(BluetoothDevice bluetoothDevice) { - // Sanity check. If you pass in a null device, by definition it is never a Steam Controller. - if (bluetoothDevice == null) { - return false; - } - - // If the device has no local name, we really don't want to try an equality check against it. - if (bluetoothDevice.getName() == null) { - return false; - } - - // Steam Controllers will always support Bluetooth Low Energy - if ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) == 0) { - return false; - } - - // Match on the name either the original Steam Controller or the new second-generation one advertise with. - return bluetoothDevice.getName().equals("SteamController") || bluetoothDevice.getName().startsWith("Steam Ctrl"); - } - - private void close() { - shutdownUSB(); - shutdownBluetooth(); - synchronized (this) { - for (HIDDevice device : mDevicesById.values()) { - device.shutdown(); - } - mDevicesById.clear(); - mBluetoothDevices.clear(); - HIDDeviceReleaseCallback(); - } - } - - public void setFrozen(boolean frozen) { - synchronized (this) { - for (HIDDevice device : mDevicesById.values()) { - device.setFrozen(frozen); - } - } - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - private HIDDevice getDevice(int id) { - synchronized (this) { - HIDDevice result = mDevicesById.get(id); - if (result == null) { - Log.v(TAG, "No device for id: " + id); - Log.v(TAG, "Available devices: " + mDevicesById.keySet()); - } - return result; - } - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////// JNI interface functions - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - boolean initialize(boolean usb, boolean bluetooth) { - Log.v(TAG, "initialize(" + usb + ", " + bluetooth + ")"); - - if (usb) { - initializeUSB(); - } - if (bluetooth) { - initializeBluetooth(); - } - return true; - } - - boolean openDevice(int deviceID) { - Log.v(TAG, "openDevice deviceID=" + deviceID); - HIDDevice device = getDevice(deviceID); - if (device == null) { - HIDDeviceDisconnected(deviceID); - return false; - } - - // Look to see if this is a USB device and we have permission to access it - UsbDevice usbDevice = device.getDevice(); - if (usbDevice != null && !mUsbManager.hasPermission(usbDevice)) { - HIDDeviceOpenPending(deviceID); - try { - final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31 - int flags; - if (Build.VERSION.SDK_INT >= 31 /* Android 12.0 (S) */) { - flags = FLAG_MUTABLE; - } else { - flags = 0; - } - - Intent intent = new Intent(HIDDeviceManager.ACTION_USB_PERMISSION); - intent.setPackage(mContext.getPackageName()); - mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, intent, flags)); - } catch (Exception e) { - Log.v(TAG, "Couldn't request permission for USB device " + usbDevice); - HIDDeviceOpenResult(deviceID, false); - } - return false; - } - - try { - return device.open(); - } catch (Exception e) { - Log.e(TAG, "Got exception: " + Log.getStackTraceString(e)); - } - return false; - } - - int writeReport(int deviceID, byte[] report, boolean feature) { - try { - //Log.v(TAG, "writeReport deviceID=" + deviceID + " length=" + report.length); - HIDDevice device; - device = getDevice(deviceID); - if (device == null) { - HIDDeviceDisconnected(deviceID); - return -1; - } - - return device.writeReport(report, feature); - } catch (Exception e) { - Log.e(TAG, "Got exception: " + Log.getStackTraceString(e)); - } - return -1; - } - - boolean readReport(int deviceID, byte[] report, boolean feature) { - try { - //Log.v(TAG, "readReport deviceID=" + deviceID); - HIDDevice device; - device = getDevice(deviceID); - if (device == null) { - HIDDeviceDisconnected(deviceID); - return false; - } - - return device.readReport(report, feature); - } catch (Exception e) { - Log.e(TAG, "Got exception: " + Log.getStackTraceString(e)); - } - return false; - } - - void closeDevice(int deviceID) { - try { - Log.v(TAG, "closeDevice deviceID=" + deviceID); - HIDDevice device; - device = getDevice(deviceID); - if (device == null) { - HIDDeviceDisconnected(deviceID); - return; - } - - device.close(); - } catch (Exception e) { - Log.e(TAG, "Got exception: " + Log.getStackTraceString(e)); - } - } - - - ////////////////////////////////////////////////////////////////////////////////////////////////////// - /////////////// Native methods - ////////////////////////////////////////////////////////////////////////////////////////////////////// - - private native void HIDDeviceRegisterCallback(); - private native void HIDDeviceReleaseCallback(); - - native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol, boolean bBluetooth, int reportID); - native void HIDDeviceOpenPending(int deviceID); - native void HIDDeviceOpenResult(int deviceID, boolean opened); - native void HIDDeviceDisconnected(int deviceID); - - native void HIDDeviceInputReport(int deviceID, byte[] report); - native void HIDDeviceReportResponse(int deviceID, byte[] report); -} diff --git a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java b/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java deleted file mode 100644 index 8954639733..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java +++ /dev/null @@ -1,354 +0,0 @@ -package org.libsdl.app; - -import android.hardware.usb.*; -import android.os.Build; -import android.util.Log; -import java.util.Arrays; -import java.util.Locale; - -class HIDDeviceUSB implements HIDDevice { - - private static final String TAG = "hidapi"; - - protected HIDDeviceManager mManager; - protected UsbDevice mDevice; - protected int mInterfaceIndex; - protected int mInterface; - protected int mDeviceId; - protected UsbDeviceConnection mConnection; - protected UsbEndpoint mInputEndpoint; - protected UsbEndpoint mOutputEndpoint; - protected InputThread mInputThread; - protected boolean mRunning; - protected boolean mFrozen; - protected boolean mClaimed; - - public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_index) { - mManager = manager; - mDevice = usbDevice; - mInterfaceIndex = interface_index; - mInterface = mDevice.getInterface(mInterfaceIndex).getId(); - mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier()); - mRunning = false; - mClaimed = false; - } - - String getIdentifier() { - return String.format(Locale.ENGLISH, "%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex); - } - - @Override - public int getId() { - return mDeviceId; - } - - @Override - public int getVendorId() { - return mDevice.getVendorId(); - } - - @Override - public int getProductId() { - return mDevice.getProductId(); - } - - @Override - public String getSerialNumber() { - String result = null; - try { - result = mDevice.getSerialNumber(); - } - catch (SecurityException exception) { - //Log.w(TAG, "App permissions mean we cannot get serial number for device " + getDeviceName() + " message: " + exception.getMessage()); - } - if (result == null) { - result = ""; - } - return result; - } - - @Override - public int getVersion() { - return 0; - } - - @Override - public String getManufacturerName() { - String result; - result = mDevice.getManufacturerName(); - if (result == null) { - result = String.format("%x", getVendorId()); - } - return result; - } - - @Override - public String getProductName() { - String result; - result = mDevice.getProductName(); - if (result == null) { - result = String.format("%x", getProductId()); - } - return result; - } - - @Override - public UsbDevice getDevice() { - return mDevice; - } - - String getDeviceName() { - return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")"; - } - - @Override - public boolean open() { - mConnection = mManager.getUSBManager().openDevice(mDevice); - if (mConnection == null) { - Log.w(TAG, "Unable to open USB device " + getDeviceName()); - return false; - } - - // Force claim our interface - UsbInterface iface = mDevice.getInterface(mInterfaceIndex); - if (!mConnection.claimInterface(iface, true)) { - Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName()); - close(); - return false; - } - mClaimed = true; - - // Find the endpoints - for (int j = 0; j < iface.getEndpointCount(); j++) { - UsbEndpoint endpt = iface.getEndpoint(j); - switch (endpt.getDirection()) { - case UsbConstants.USB_DIR_IN: - if (mInputEndpoint == null) { - mInputEndpoint = endpt; - } - break; - case UsbConstants.USB_DIR_OUT: - if (mOutputEndpoint == null) { - mOutputEndpoint = endpt; - } - break; - } - } - - // Make sure the required endpoints were present. The original Steam Controller and the wireless dongle for it do NOT - // actually have -- or require -- output endpoints, so we need to accept only an input one for them or else we'll fall - // back to the Android system gamepad functionality (and lose our paddles et al). - if (mInputEndpoint == null) { - Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName()); - mConnection.releaseInterface(iface); - close(); - return false; - } - - // Start listening for input - mRunning = true; - mInputThread = new InputThread(); - mInputThread.start(); - - return true; - } - - @Override - public int writeReport(byte[] report, boolean feature) { - if (mConnection == null) { - Log.w(TAG, "writeReport() called with no device connection"); - return -1; - } - - if (!mClaimed) { - Log.w(TAG, "writeReport() called but some other process currently owns the USB device"); - return -1; - } - - if (feature) { - int res = -1; - int offset = 0; - int length = report.length; - boolean skipped_report_id = false; - byte report_number = report[0]; - - if (report_number == 0x0) { - ++offset; - --length; - skipped_report_id = true; - } - - res = mConnection.controlTransfer( - UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT, - 0x09/*HID set_report*/, - (3/*HID feature*/ << 8) | report_number, - mInterface, - report, offset, length, - 1000/*timeout millis*/); - - if (res < 0) { - Log.w(TAG, "writeFeatureReport() returned " + res + " on device " + getDeviceName()); - return -1; - } - - if (skipped_report_id) { - ++length; - } - return length; - } else { - if (mOutputEndpoint == null) - { - Log.e(TAG, "Tried to write an output report to an interface with no output endpoint!"); - return -1; - } - int res = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000); - if (res != report.length) { - Log.w(TAG, "writeOutputReport() returned " + res + " on device " + getDeviceName()); - } - return res; - } - } - - @Override - public boolean readReport(byte[] report, boolean feature) { - int res = -1; - int offset = 0; - int length = report.length; - boolean skipped_report_id = false; - byte report_number = report[0]; - - if (mConnection == null) { - Log.w(TAG, "readReport() called with no device connection"); - return false; - } - if (!mClaimed) { - if (feature) { - return false; - } - return true; - } - - if (report_number == 0x0) { - /* Offset the return buffer by 1, so that the report ID - will remain in byte 0. */ - ++offset; - --length; - skipped_report_id = true; - } - - res = mConnection.controlTransfer( - UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN, - 0x01/*HID get_report*/, - ((feature ? 3/*HID feature*/ : 1/*HID Input*/) << 8) | report_number, - mInterface, - report, offset, length, - 1000/*timeout millis*/); - - if (res < 0) { - Log.w(TAG, "getFeatureReport() returned " + res + " on device " + getDeviceName()); - return false; - } - - if (skipped_report_id) { - ++res; - ++length; - } - - byte[] data; - if (res == length) { - data = report; - } else { - data = Arrays.copyOfRange(report, 0, res); - } - mManager.HIDDeviceReportResponse(mDeviceId, data); - - return true; - } - - @Override - public void close() { - mRunning = false; - if (mInputThread != null) { - while (mInputThread.isAlive()) { - mInputThread.interrupt(); - try { - mInputThread.join(); - } catch (InterruptedException e) { - // Keep trying until we're done - } - } - mInputThread = null; - } - if (mConnection != null) { - if (mClaimed) { - UsbInterface iface = mDevice.getInterface(mInterfaceIndex); - mConnection.releaseInterface(iface); - } - mConnection.close(); - mConnection = null; - mClaimed = false; - } - } - - @Override - public void shutdown() { - close(); - mManager = null; - } - - @Override - public void setFrozen(boolean frozen) { - mFrozen = frozen; - - /* If we have a valid device connection and the claim state doesn't match what we want, try to correct that. */ - if (mConnection != null && mClaimed == mFrozen) { - UsbInterface iface = mDevice.getInterface(mInterfaceIndex); - if (frozen) { - mClaimed = !mConnection.releaseInterface(iface); - if (mClaimed) { - Log.e(TAG, "Tried to release claim on USB device, but failed!"); - } - } else { - mClaimed = mConnection.claimInterface(iface, true); - if (!mClaimed) { - Log.e(TAG, "Tried to regain claim on USB device, but failed!"); - } - } - } - } - - protected class InputThread extends Thread { - @Override - public void run() { - int packetSize = mInputEndpoint.getMaxPacketSize(); - byte[] packet = new byte[packetSize]; - while (mRunning) { - int r; - try - { - r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000); - } - catch (Exception e) - { - Log.v(TAG, "Exception in UsbDeviceConnection bulktransfer: " + e); - break; - } - if (r < 0) { - // Could be a timeout or an I/O error - } - if (r > 0) { - byte[] data; - if (r == packetSize) { - data = packet; - } else { - data = Arrays.copyOfRange(packet, 0, r); - } - - if (!mFrozen) { - mManager.HIDDeviceInputReport(mDeviceId, data); - } - } - } - } - } -} diff --git a/platforms/android/app/src/main/java/org/libsdl/app/SDL.java b/platforms/android/app/src/main/java/org/libsdl/app/SDL.java deleted file mode 100644 index d9650a72e4..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/SDL.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.libsdl.app; - -import android.app.Activity; -import android.content.Context; - -import java.lang.reflect.Method; - -/** - SDL library initialization -*/ -public class SDL { - - // This function should be called first and sets up the native code - // so it can call into the Java classes - static public void setupJNI() { - SDLActivity.nativeSetupJNI(); - SDLAudioManager.nativeSetupJNI(); - SDLControllerManager.nativeSetupJNI(); - } - - // This function should be called each time the activity is started - static public void initialize() { - setContext(null); - - SDLActivity.initialize(); - SDLAudioManager.initialize(); - SDLControllerManager.initialize(); - } - - // This function stores the current activity (SDL or not) - static public void setContext(Activity context) { - SDLAudioManager.setContext(context); - mContext = context; - } - - static public Activity getContext() { - return mContext; - } - - static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { - loadLibrary(libraryName, mContext); - } - - static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException { - - if (libraryName == null) { - throw new NullPointerException("No library name provided."); - } - - try { - // Let's see if we have ReLinker available in the project. This is necessary for - // some projects that have huge numbers of local libraries bundled, and thus may - // trip a bug in Android's native library loader which ReLinker works around. (If - // loadLibrary works properly, ReLinker will simply use the normal Android method - // internally.) - // - // To use ReLinker, just add it as a dependency. For more information, see - // https://github.com/KeepSafe/ReLinker for ReLinker's repository. - // - Class relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); - Class relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); - Class contextClass = context.getClassLoader().loadClass("android.content.Context"); - Class stringClass = context.getClassLoader().loadClass("java.lang.String"); - - // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if - // they've changed during updates. - Method forceMethod = relinkClass.getDeclaredMethod("force"); - Object relinkInstance = forceMethod.invoke(null); - Class relinkInstanceClass = relinkInstance.getClass(); - - // Actually load the library! - Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); - loadMethod.invoke(relinkInstance, context, libraryName, null, null); - } - catch (final Throwable e) { - // Fall back - try { - System.loadLibrary(libraryName); - } - catch (final UnsatisfiedLinkError ule) { - throw ule; - } - catch (final SecurityException se) { - throw se; - } - } - } - - protected static Activity mContext; -} diff --git a/platforms/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/platforms/android/app/src/main/java/org/libsdl/app/SDLActivity.java deleted file mode 100644 index dcc49852ac..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ /dev/null @@ -1,2240 +0,0 @@ -package org.libsdl.app; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.UiModeManager; -import android.content.ActivityNotFoundException; -import android.content.ClipboardManager; -import android.content.ClipData; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.res.Configuration; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; -import android.hardware.Sensor; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.LocaleList; -import android.os.Message; -import android.os.ParcelFileDescriptor; -import android.util.DisplayMetrics; -import android.util.Log; -import android.util.SparseArray; -import android.view.Display; -import android.view.Gravity; -import android.view.InputDevice; -import android.view.KeyEvent; -import android.view.PointerIcon; -import android.view.Surface; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodManager; -import android.webkit.MimeTypeMap; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Locale; - - -/** - SDL Activity -*/ -public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener { - private static final String TAG = "SDL"; - private static final int SDL_MAJOR_VERSION = 3; - private static final int SDL_MINOR_VERSION = 4; - private static final int SDL_MICRO_VERSION = 10; -/* - // Display InputType.SOURCE/CLASS of events and devices - // - // SDLActivity.debugSource(device.getSources(), "device[" + device.getName() + "]"); - // SDLActivity.debugSource(event.getSource(), "event"); - public static void debugSource(int sources, String prefix) { - int s = sources; - int s_copy = sources; - String cls = ""; - String src = ""; - int tst = 0; - int FLAG_TAINTED = 0x80000000; - - if ((s & InputDevice.SOURCE_CLASS_BUTTON) != 0) cls += " BUTTON"; - if ((s & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) cls += " JOYSTICK"; - if ((s & InputDevice.SOURCE_CLASS_POINTER) != 0) cls += " POINTER"; - if ((s & InputDevice.SOURCE_CLASS_POSITION) != 0) cls += " POSITION"; - if ((s & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) cls += " TRACKBALL"; - - - int s2 = s_copy & ~InputDevice.SOURCE_ANY; // keep class bits - s2 &= ~( InputDevice.SOURCE_CLASS_BUTTON - | InputDevice.SOURCE_CLASS_JOYSTICK - | InputDevice.SOURCE_CLASS_POINTER - | InputDevice.SOURCE_CLASS_POSITION - | InputDevice.SOURCE_CLASS_TRACKBALL); - - if (s2 != 0) cls += "Some_Unknown"; - - s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class; - - if (Build.VERSION.SDK_INT >= 23) { - tst = InputDevice.SOURCE_BLUETOOTH_STYLUS; - if ((s & tst) == tst) src += " BLUETOOTH_STYLUS"; - s2 &= ~tst; - } - - tst = InputDevice.SOURCE_DPAD; - if ((s & tst) == tst) src += " DPAD"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_GAMEPAD; - if ((s & tst) == tst) src += " GAMEPAD"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_HDMI; - if ((s & tst) == tst) src += " HDMI"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_JOYSTICK; - if ((s & tst) == tst) src += " JOYSTICK"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_KEYBOARD; - if ((s & tst) == tst) src += " KEYBOARD"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_MOUSE; - if ((s & tst) == tst) src += " MOUSE"; - s2 &= ~tst; - - if (Build.VERSION.SDK_INT >= 26) { - tst = InputDevice.SOURCE_MOUSE_RELATIVE; - if ((s & tst) == tst) src += " MOUSE_RELATIVE"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_ROTARY_ENCODER; - if ((s & tst) == tst) src += " ROTARY_ENCODER"; - s2 &= ~tst; - } - tst = InputDevice.SOURCE_STYLUS; - if ((s & tst) == tst) src += " STYLUS"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_TOUCHPAD; - if ((s & tst) == tst) src += " TOUCHPAD"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_TOUCHSCREEN; - if ((s & tst) == tst) src += " TOUCHSCREEN"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_TOUCH_NAVIGATION; - if ((s & tst) == tst) src += " TOUCH_NAVIGATION"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_TRACKBALL; - if ((s & tst) == tst) src += " TRACKBALL"; - s2 &= ~tst; - - tst = InputDevice.SOURCE_ANY; - if ((s & tst) == tst) src += " ANY"; - s2 &= ~tst; - - if (s == FLAG_TAINTED) src += " FLAG_TAINTED"; - s2 &= ~FLAG_TAINTED; - - if (s2 != 0) src += " Some_Unknown"; - - Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src); - } -*/ - - public static boolean mIsResumedCalled, mHasFocus; - public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */); - - // Cursor types - // private static final int SDL_SYSTEM_CURSOR_NONE = -1; - private static final int SDL_SYSTEM_CURSOR_ARROW = 0; - private static final int SDL_SYSTEM_CURSOR_IBEAM = 1; - private static final int SDL_SYSTEM_CURSOR_WAIT = 2; - private static final int SDL_SYSTEM_CURSOR_CROSSHAIR = 3; - private static final int SDL_SYSTEM_CURSOR_WAITARROW = 4; - private static final int SDL_SYSTEM_CURSOR_SIZENWSE = 5; - private static final int SDL_SYSTEM_CURSOR_SIZENESW = 6; - private static final int SDL_SYSTEM_CURSOR_SIZEWE = 7; - private static final int SDL_SYSTEM_CURSOR_SIZENS = 8; - private static final int SDL_SYSTEM_CURSOR_SIZEALL = 9; - private static final int SDL_SYSTEM_CURSOR_NO = 10; - private static final int SDL_SYSTEM_CURSOR_HAND = 11; - private static final int SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT = 12; - private static final int SDL_SYSTEM_CURSOR_WINDOW_TOP = 13; - private static final int SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT = 14; - private static final int SDL_SYSTEM_CURSOR_WINDOW_RIGHT = 15; - private static final int SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT = 16; - private static final int SDL_SYSTEM_CURSOR_WINDOW_BOTTOM = 17; - private static final int SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT = 18; - private static final int SDL_SYSTEM_CURSOR_WINDOW_LEFT = 19; - - protected static final int SDL_ORIENTATION_UNKNOWN = 0; - protected static final int SDL_ORIENTATION_LANDSCAPE = 1; - protected static final int SDL_ORIENTATION_LANDSCAPE_FLIPPED = 2; - protected static final int SDL_ORIENTATION_PORTRAIT = 3; - protected static final int SDL_ORIENTATION_PORTRAIT_FLIPPED = 4; - - protected static int mCurrentRotation; - protected static Locale mCurrentLocale; - - // Handle the state of the native layer - public enum NativeState { - INIT, RESUMED, PAUSED - } - - public static NativeState mNextNativeState; - public static NativeState mCurrentNativeState; - - /** If shared libraries (e.g. SDL or the native application) could not be loaded. */ - public static boolean mBrokenLibraries = true; - - // Main components - protected static SDLActivity mSingleton; - protected static SDLSurface mSurface; - protected static SDLDummyEdit mTextEdit; - protected static ViewGroup mLayout; - protected static SDLClipboardHandler mClipboardHandler; - protected static Hashtable mCursors; - protected static int mLastCursorID; - protected static SDLGenericMotionListener_API14 mMotionListener; - protected static HIDDeviceManager mHIDDeviceManager; - - // This is what SDL runs in. It invokes SDL_main(), eventually - protected static Thread mSDLThread; - protected static boolean mSDLMainFinished = false; - protected static boolean mActivityCreated = false; - private static SDLFileDialogState mFileDialogState = null; - protected static boolean mDispatchingKeyEvent = false; - - public static SDLGenericMotionListener_API14 getMotionListener() { - if (mMotionListener == null) { - if (Build.VERSION.SDK_INT >= 29 /* Android 10 (Q) */) { - mMotionListener = new SDLGenericMotionListener_API29(); - } else if (Build.VERSION.SDK_INT >= 26 /* Android 8.0 (O) */) { - mMotionListener = new SDLGenericMotionListener_API26(); - } else if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) { - mMotionListener = new SDLGenericMotionListener_API24(); - } else { - mMotionListener = new SDLGenericMotionListener_API14(); - } - } - - return mMotionListener; - } - - /** - * The application entry point, called on a dedicated thread (SDLThread). - * The default implementation uses the getMainSharedObject() and getMainFunction() methods - * to invoke native code from the specified shared library. - * It can be overridden by derived classes. - */ - protected void main() { - String library = SDLActivity.mSingleton.getMainSharedObject(); - String function = SDLActivity.mSingleton.getMainFunction(); - String[] arguments = SDLActivity.mSingleton.getArguments(); - - Log.v("SDL", "Running main function " + function + " from library " + library); - SDLActivity.nativeRunMain(library, function, arguments); - Log.v("SDL", "Finished main function"); - } - - /** - * This method returns the name of the shared object with the application entry point - * It can be overridden by derived classes. - */ - protected String getMainSharedObject() { - String library; - String[] libraries = SDLActivity.mSingleton.getLibraries(); - if (libraries.length > 0) { - library = "lib" + libraries[libraries.length - 1] + ".so"; - } else { - library = "libmain.so"; - } - return getContext().getApplicationInfo().nativeLibraryDir + "/" + library; - } - - /** - * This method returns the name of the application entry point - * It can be overridden by derived classes. - */ - protected String getMainFunction() { - return "SDL_main"; - } - - /** - * This method is called by SDL before loading the native shared libraries. - * It can be overridden to provide names of shared libraries to be loaded. - * The default implementation returns the defaults. It never returns null. - * An array returned by a new implementation must at least contain "SDL3". - * Also keep in mind that the order the libraries are loaded may matter. - * @return names of shared libraries to be loaded (e.g. "SDL3", "main"). - */ - protected String[] getLibraries() { - return new String[] { - "SDL3", - // "SDL3_image", - // "SDL3_mixer", - // "SDL3_net", - // "SDL3_ttf", - "main" - }; - } - - // Load the .so - public void loadLibraries() { - for (String lib : getLibraries()) { - SDL.loadLibrary(lib, this); - } - } - - /** - * This method is called by SDL before starting the native application thread. - * It can be overridden to provide the arguments after the application name. - * The default implementation returns an empty array. It never returns null. - * @return arguments for the native application. - */ - protected String[] getArguments() { - return new String[0]; - } - - public static void initialize() { - // The static nature of the singleton and Android quirkyness force us to initialize everything here - // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values - mSingleton = null; - mSurface = null; - mTextEdit = null; - mLayout = null; - mClipboardHandler = null; - mCursors = new Hashtable(); - mLastCursorID = 0; - mSDLThread = null; - mIsResumedCalled = false; - mHasFocus = true; - mNextNativeState = NativeState.INIT; - mCurrentNativeState = NativeState.INIT; - } - - protected SDLSurface createSDLSurface(Context context) { - return new SDLSurface(context); - } - - // Setup - @Override - protected void onCreate(Bundle savedInstanceState) { - Log.v(TAG, "Manufacturer: " + Build.MANUFACTURER); - Log.v(TAG, "Device: " + Build.DEVICE); - Log.v(TAG, "Model: " + Build.MODEL); - Log.v(TAG, "onCreate()"); - super.onCreate(savedInstanceState); - - - /* Control activity re-creation */ - if (mSDLMainFinished || mActivityCreated) { - boolean allow_recreate = SDLActivity.nativeAllowRecreateActivity(); - if (mSDLMainFinished) { - Log.v(TAG, "SDL main() finished"); - } - if (allow_recreate) { - Log.v(TAG, "activity re-created"); - } else { - Log.v(TAG, "activity finished"); - System.exit(0); - return; - } - } - - mActivityCreated = true; - - try { - Thread.currentThread().setName("SDLActivity"); - } catch (Exception e) { - Log.v(TAG, "modify thread properties failed " + e.toString()); - } - - // Load shared libraries - String errorMsgBrokenLib = ""; - try { - loadLibraries(); - mBrokenLibraries = false; /* success */ - } catch(UnsatisfiedLinkError e) { - System.err.println(e.getMessage()); - mBrokenLibraries = true; - errorMsgBrokenLib = e.getMessage(); - } catch(Exception e) { - System.err.println(e.getMessage()); - mBrokenLibraries = true; - errorMsgBrokenLib = e.getMessage(); - } - - if (!mBrokenLibraries) { - String expected_version = String.valueOf(SDL_MAJOR_VERSION) + "." + - String.valueOf(SDL_MINOR_VERSION) + "." + - String.valueOf(SDL_MICRO_VERSION); - String version = nativeGetVersion(); - if (!version.equals(expected_version)) { - mBrokenLibraries = true; - errorMsgBrokenLib = "SDL C/Java version mismatch (expected " + expected_version + ", got " + version + ")"; - } - } - - if (mBrokenLibraries) { - mSingleton = this; - AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); - dlgAlert.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall." - + System.getProperty("line.separator") - + System.getProperty("line.separator") - + "Error: " + errorMsgBrokenLib); - dlgAlert.setTitle("SDL Error"); - dlgAlert.setPositiveButton("Exit", - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog,int id) { - // if this button is clicked, close current activity - SDLActivity.mSingleton.finish(); - } - }); - dlgAlert.setCancelable(false); - dlgAlert.create().show(); - - return; - } - - - /* Control activity re-creation */ - /* Robustness: check that the native code is run for the first time. - * (Maybe Activity was reset, but not the native code.) */ - { - int run_count = SDLActivity.nativeCheckSDLThreadCounter(); /* get and increment a native counter */ - if (run_count != 0) { - boolean allow_recreate = SDLActivity.nativeAllowRecreateActivity(); - if (allow_recreate) { - Log.v(TAG, "activity re-created // run_count: " + run_count); - } else { - Log.v(TAG, "activity finished // run_count: " + run_count); - System.exit(0); - return; - } - } - } - - // Set up JNI - SDL.setupJNI(); - - // Initialize state - SDL.initialize(); - - // So we can call stuff from static callbacks - mSingleton = this; - SDL.setContext(this); - - mClipboardHandler = new SDLClipboardHandler(); - - mHIDDeviceManager = HIDDeviceManager.acquire(this); - - // Set up the surface - mSurface = createSDLSurface(this); - - mLayout = new RelativeLayout(this); - mLayout.addView(mSurface); - - // Get our current screen orientation and pass it down. - SDLActivity.nativeSetNaturalOrientation(SDLActivity.getNaturalOrientation()); - mCurrentRotation = SDLActivity.getCurrentRotation(); - SDLActivity.onNativeRotationChanged(mCurrentRotation); - - try { - if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) { - mCurrentLocale = getContext().getResources().getConfiguration().locale; - } else { - mCurrentLocale = getContext().getResources().getConfiguration().getLocales().get(0); - } - } catch(Exception ignored) { - } - - switch (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) { - case Configuration.UI_MODE_NIGHT_NO: - SDLActivity.onNativeDarkModeChanged(false); - break; - case Configuration.UI_MODE_NIGHT_YES: - SDLActivity.onNativeDarkModeChanged(true); - break; - } - - setContentView(mLayout); - - setWindowStyle(false); - - getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this); - - // Get filename from "Open with" of another application - Intent intent = getIntent(); - if (intent != null && intent.getData() != null) { - String filename = intent.getData().getPath(); - if (filename != null) { - Log.v(TAG, "Got filename: " + filename); - SDLActivity.onNativeDropFile(filename); - } - } - } - - protected void pauseNativeThread() { - mNextNativeState = NativeState.PAUSED; - mIsResumedCalled = false; - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.handleNativeState(); - } - - protected void resumeNativeThread() { - mNextNativeState = NativeState.RESUMED; - mIsResumedCalled = true; - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.handleNativeState(); - } - - // Events - @Override - protected void onPause() { - Log.v(TAG, "onPause()"); - super.onPause(); - - if (mHIDDeviceManager != null) { - mHIDDeviceManager.setFrozen(true); - } - - if (!mHasMultiWindow) { - pauseNativeThread(); - } - } - - @Override - protected void onResume() { - Log.v(TAG, "onResume()"); - super.onResume(); - - if (mHIDDeviceManager != null) { - mHIDDeviceManager.setFrozen(false); - } - - if (!mHasMultiWindow) { - resumeNativeThread(); - } - } - - @Override - protected void onStop() { - Log.v(TAG, "onStop()"); - super.onStop(); - if (mHasMultiWindow) { - pauseNativeThread(); - } - } - - @Override - protected void onStart() { - Log.v(TAG, "onStart()"); - super.onStart(); - if (mHasMultiWindow) { - resumeNativeThread(); - } - } - - public static int getNaturalOrientation() { - int result = SDL_ORIENTATION_UNKNOWN; - - Activity activity = getContext(); - if (activity != null) { - Configuration config = activity.getResources().getConfiguration(); - Display display = activity.getWindowManager().getDefaultDisplay(); - int rotation = display.getRotation(); - if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && - config.orientation == Configuration.ORIENTATION_LANDSCAPE) || - ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && - config.orientation == Configuration.ORIENTATION_PORTRAIT)) { - result = SDL_ORIENTATION_LANDSCAPE; - } else { - result = SDL_ORIENTATION_PORTRAIT; - } - } - return result; - } - - public static int getCurrentRotation() { - int result = 0; - - Activity activity = getContext(); - if (activity != null) { - Display display = activity.getWindowManager().getDefaultDisplay(); - switch (display.getRotation()) { - case Surface.ROTATION_0: - result = 0; - break; - case Surface.ROTATION_90: - result = 90; - break; - case Surface.ROTATION_180: - result = 180; - break; - case Surface.ROTATION_270: - result = 270; - break; - } - } - return result; - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - Log.v(TAG, "onWindowFocusChanged(): " + hasFocus); - - // If we are gaining focus, we can always try to restore our USB devices. If we are losing focus, - // only try to relinquish them if we don't have background events allowed (for multi-window Android setups). - if (hasFocus || !SDLActivity.nativeGetHintBoolean("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", false)) { - if (mHIDDeviceManager != null) { - mHIDDeviceManager.setFrozen(!hasFocus); - } - } - - if (SDLActivity.mBrokenLibraries) { - return; - } - - mHasFocus = hasFocus; - if (hasFocus) { - mNextNativeState = NativeState.RESUMED; - SDLActivity.getMotionListener().reclaimRelativeMouseModeIfNeeded(); - - SDLActivity.handleNativeState(); - nativeFocusChanged(true); - - } else { - nativeFocusChanged(false); - if (!mHasMultiWindow) { - mNextNativeState = NativeState.PAUSED; - SDLActivity.handleNativeState(); - } - } - } - - @Override - public void onTrimMemory(int level) { - Log.v(TAG, "onTrimMemory()"); - super.onTrimMemory(level); - - if (SDLActivity.mBrokenLibraries) { - return; - } - - SDLActivity.nativeLowMemory(); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - Log.v(TAG, "onConfigurationChanged()"); - super.onConfigurationChanged(newConfig); - - if (SDLActivity.mBrokenLibraries) { - return; - } - - if (mCurrentLocale == null || !mCurrentLocale.equals(newConfig.locale)) { - mCurrentLocale = newConfig.locale; - SDLActivity.onNativeLocaleChanged(); - } - - switch (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) { - case Configuration.UI_MODE_NIGHT_NO: - SDLActivity.onNativeDarkModeChanged(false); - break; - case Configuration.UI_MODE_NIGHT_YES: - SDLActivity.onNativeDarkModeChanged(true); - break; - } - } - - @Override - protected void onDestroy() { - Log.v(TAG, "onDestroy()"); - - if (mHIDDeviceManager != null) { - HIDDeviceManager.release(mHIDDeviceManager); - mHIDDeviceManager = null; - } - - SDLAudioManager.release(this); - - if (SDLActivity.mBrokenLibraries) { - super.onDestroy(); - return; - } - - if (SDLActivity.mSDLThread != null) { - - // Send Quit event to "SDLThread" thread - SDLActivity.nativeSendQuit(); - - // Wait for "SDLThread" thread to end - try { - // Use a timeout because: - // C SDLmain() thread might have started (mSDLThread.start() called) - // while the SDL_Init() might not have been called yet, - // and so the previous QUIT event will be discarded by SDL_Init() and app is running, not exiting. - SDLActivity.mSDLThread.join(1000); - } catch(Exception e) { - Log.v(TAG, "Problem stopping SDLThread: " + e); - } - } - - SDLActivity.nativeQuit(); - - super.onDestroy(); - } - - @Override - public void onBackPressed() { - // Check if we want to block the back button in case of mouse right click. - // - // If we do, the normal hardware back button will no longer work and people have to use home, - // but the mouse right click will work. - // - boolean trapBack = SDLActivity.nativeGetHintBoolean("SDL_ANDROID_TRAP_BACK_BUTTON", false); - if (trapBack) { - // Exit and let the mouse handler handle this button (if appropriate) - return; - } - - // Default system back button behavior. - if (!isFinishing()) { - super.onBackPressed(); - } - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - - if (mFileDialogState != null && mFileDialogState.requestCode == requestCode) { - /* This is our file dialog */ - String[] filelist = null; - - if (data != null) { - Uri singleFileUri = data.getData(); - - if (singleFileUri == null) { - /* Use Intent.getClipData to get multiple choices */ - ClipData clipData = data.getClipData(); - assert clipData != null; - - filelist = new String[clipData.getItemCount()]; - - for (int i = 0; i < filelist.length; i++) { - String uri = clipData.getItemAt(i).getUri().toString(); - filelist[i] = uri; - } - } else { - /* Only one file is selected. */ - filelist = new String[]{singleFileUri.toString()}; - } - } else { - /* User cancelled the request. */ - filelist = new String[0]; - } - - // TODO: Detect the file MIME type and pass the filter value accordingly. - SDLActivity.onNativeFileDialog(requestCode, filelist, -1); - mFileDialogState = null; - } - } - - // Called by JNI from SDL. - public static void manualBackButton() { - mSingleton.pressBackButton(); - } - - // Used to get us onto the activity's main thread - public void pressBackButton() { - runOnUiThread(new Runnable() { - @Override - public void run() { - if (!SDLActivity.this.isFinishing()) { - SDLActivity.this.superOnBackPressed(); - } - } - }); - } - - // Used to access the system back behavior. - public void superOnBackPressed() { - super.onBackPressed(); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - - if (SDLActivity.mBrokenLibraries) { - return false; - } - - int keyCode = event.getKeyCode(); - // Ignore certain special keys so they're handled by Android - if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || - keyCode == KeyEvent.KEYCODE_VOLUME_UP || - keyCode == KeyEvent.KEYCODE_CAMERA || - keyCode == KeyEvent.KEYCODE_ZOOM_IN || /* API 11 */ - keyCode == KeyEvent.KEYCODE_ZOOM_OUT /* API 11 */ - ) { - return false; - } - mDispatchingKeyEvent = true; - boolean result = super.dispatchKeyEvent(event); - mDispatchingKeyEvent = false; - return result; - } - - public static boolean dispatchingKeyEvent() { - return mDispatchingKeyEvent; - } - - /* Transition to next state */ - public static void handleNativeState() { - - if (mNextNativeState == mCurrentNativeState) { - // Already in same state, discard. - return; - } - - // Try a transition to init state - if (mNextNativeState == NativeState.INIT) { - - mCurrentNativeState = mNextNativeState; - return; - } - - // Try a transition to paused state - if (mNextNativeState == NativeState.PAUSED) { - if (mSDLThread != null) { - nativePause(); - } - if (mSurface != null) { - mSurface.handlePause(); - } - mCurrentNativeState = mNextNativeState; - return; - } - - // Try a transition to resumed state - if (mNextNativeState == NativeState.RESUMED) { - if (mSurface.mIsSurfaceReady && (mHasFocus || mHasMultiWindow) && mIsResumedCalled) { - if (mSDLThread == null) { - // This is the entry point to the C app. - // Start up the C app thread and enable sensor input for the first time - // FIXME: Why aren't we enabling sensor input at start? - - mSDLThread = new Thread(new SDLMain(), "SDLThread"); - mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true); - mSDLThread.start(); - - // No nativeResume(), don't signal Android_ResumeSem - } else { - nativeResume(); - } - mSurface.handleResume(); - - mCurrentNativeState = mNextNativeState; - } - } - } - - // Messages from the SDLMain thread - protected static final int COMMAND_CHANGE_TITLE = 1; - protected static final int COMMAND_CHANGE_WINDOW_STYLE = 2; - protected static final int COMMAND_TEXTEDIT_HIDE = 3; - protected static final int COMMAND_SET_KEEP_SCREEN_ON = 5; - protected static final int COMMAND_USER = 0x8000; - - protected static boolean mFullscreenModeActive; - - /** - * This method is called by SDL if SDL did not handle a message itself. - * This happens if a received message contains an unsupported command. - * Method can be overwritten to handle Messages in a different class. - * @param command the command of the message. - * @param param the parameter of the message. May be null. - * @return if the message was handled in overridden method. - */ - protected boolean onUnhandledMessage(int command, Object param) { - return false; - } - - /** - * A Handler class for Messages from native SDL applications. - * It uses current Activities as target (e.g. for the title). - * static to prevent implicit references to enclosing object. - */ - protected static class SDLCommandHandler extends Handler { - @Override - public void handleMessage(Message msg) { - Context context = getContext(); - if (context == null) { - Log.e(TAG, "error handling message, getContext() returned null"); - return; - } - switch (msg.arg1) { - case COMMAND_CHANGE_TITLE: - if (context instanceof Activity) { - ((Activity) context).setTitle((String)msg.obj); - } else { - Log.e(TAG, "error handling message, getContext() returned no Activity"); - } - break; - case COMMAND_CHANGE_WINDOW_STYLE: - if (context instanceof Activity) { - Window window = ((Activity) context).getWindow(); - if (window != null) { - if ((msg.obj instanceof Integer) && ((Integer) msg.obj != 0)) { - int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE; - window.getDecorView().setSystemUiVisibility(flags); - window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - SDLActivity.mFullscreenModeActive = true; - } else { - int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE; - window.getDecorView().setSystemUiVisibility(flags); - window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - SDLActivity.mFullscreenModeActive = false; - } - if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) { - window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; - } - if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */ && - Build.VERSION.SDK_INT < 35 /* Android 15 */) { - SDLActivity.onNativeInsetsChanged(0, 0, 0, 0); - } - } - } else { - Log.e(TAG, "error handling message, getContext() returned no Activity"); - } - break; - case COMMAND_TEXTEDIT_HIDE: - if (mTextEdit != null) { - // Note: On some devices setting view to GONE creates a flicker in landscape. - // Setting the View's sizes to 0 is similar to GONE but without the flicker. - // The sizes will be set to useful values when the keyboard is shown again. - mTextEdit.setLayoutParams(new RelativeLayout.LayoutParams(0, 0)); - - InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0); - - onNativeScreenKeyboardHidden(); - - mSurface.requestFocus(); - } - break; - case COMMAND_SET_KEEP_SCREEN_ON: - { - if (context instanceof Activity) { - Window window = ((Activity) context).getWindow(); - if (window != null) { - if ((msg.obj instanceof Integer) && ((Integer) msg.obj != 0)) { - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } else { - window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } - } - } - break; - } - default: - if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) { - Log.e(TAG, "error handling message, command is " + msg.arg1); - } - } - } - } - - // Handler for the messages - Handler commandHandler = new SDLCommandHandler(); - - // Send a message from the SDLMain thread - protected boolean sendCommand(int command, Object data) { - Message msg = commandHandler.obtainMessage(); - msg.arg1 = command; - msg.obj = data; - boolean result = commandHandler.sendMessage(msg); - - if (command == COMMAND_CHANGE_WINDOW_STYLE) { - // Ensure we don't return until the resize has actually happened, - // or 500ms have passed. - - boolean bShouldWait = false; - - if (data instanceof Integer) { - // Let's figure out if we're already laid out fullscreen or not. - Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - DisplayMetrics realMetrics = new DisplayMetrics(); - display.getRealMetrics(realMetrics); - - boolean bFullscreenLayout = ((realMetrics.widthPixels == mSurface.getWidth()) && - (realMetrics.heightPixels == mSurface.getHeight())); - - if ((Integer) data == 1) { - // If we aren't laid out fullscreen or actively in fullscreen mode already, we're going - // to change size and should wait for surfaceChanged() before we return, so the size - // is right back in native code. If we're already laid out fullscreen, though, we're - // not going to change size even if we change decor modes, so we shouldn't wait for - // surfaceChanged() -- which may not even happen -- and should return immediately. - bShouldWait = !bFullscreenLayout; - } else { - // If we're laid out fullscreen (even if the status bar and nav bar are present), - // or are actively in fullscreen, we're going to change size and should wait for - // surfaceChanged before we return, so the size is right back in native code. - bShouldWait = bFullscreenLayout; - } - } - - if (bShouldWait && (getContext() != null)) { - // We'll wait for the surfaceChanged() method, which will notify us - // when called. That way, we know our current size is really the - // size we need, instead of grabbing a size that's still got - // the navigation and/or status bars before they're hidden. - // - // We'll wait for up to half a second, because some devices - // take a surprisingly long time for the surface resize, but - // then we'll just give up and return. - // - synchronized (getContext()) { - try { - getContext().wait(500); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - } - } - - return result; - } - - // C functions we call - public static native String nativeGetVersion(); - public static native void nativeSetupJNI(); - public static native void nativeInitMainThread(); - public static native void nativeCleanupMainThread(); - public static native int nativeRunMain(String library, String function, Object arguments); - public static native void nativeLowMemory(); - public static native void nativeSendQuit(); - public static native void nativeQuit(); - public static native void nativePause(); - public static native void nativeResume(); - public static native void nativeFocusChanged(boolean hasFocus); - public static native void onNativeDropFile(String filename); - public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float density, float rate); - public static native void onNativeResize(); - public static native void onNativeKeyDown(int keycode); - public static native void onNativeKeyUp(int keycode); - public static native boolean onNativeSoftReturnKey(); - public static native void onNativeKeyboardFocusLost(); - public static native void onNativeMouse(int button, int action, float x, float y, boolean relative); - public static native void onNativeTouch(int touchDevId, int pointerFingerId, - int action, float x, - float y, float p); - public static native void onNativePen(int penId, int device_type, int button, int action, float x, float y, float p); - public static native void onNativeAccel(float x, float y, float z); - public static native void onNativeClipboardChanged(); - public static native void onNativeSurfaceCreated(); - public static native void onNativeSurfaceChanged(); - public static native void onNativeSurfaceDestroyed(); - public static native void onNativeScreenKeyboardShown(); - public static native void onNativeScreenKeyboardHidden(); - public static native String nativeGetHint(String name); - public static native boolean nativeGetHintBoolean(String name, boolean default_value); - public static native void nativeSetenv(String name, String value); - public static native void nativeSetNaturalOrientation(int orientation); - public static native void onNativeRotationChanged(int rotation); - public static native void onNativeInsetsChanged(int left, int right, int top, int bottom); - public static native void nativeAddTouch(int touchId, String name); - public static native void nativePermissionResult(int requestCode, boolean result); - public static native void onNativeLocaleChanged(); - public static native void onNativeDarkModeChanged(boolean enabled); - public static native boolean nativeAllowRecreateActivity(); - public static native int nativeCheckSDLThreadCounter(); - public static native void onNativeFileDialog(int requestCode, String[] filelist, int filter); - public static native void onNativePinchStart(); - public static native void onNativePinchUpdate(float scale); - public static native void onNativePinchEnd(); - - /** - * This method is called by SDL using JNI. - */ - public static boolean setActivityTitle(String title) { - // Called from SDLMain() thread and can't directly affect the view - return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title); - } - - /** - * This method is called by SDL using JNI. - */ - public static void setWindowStyle(boolean fullscreen) { - // Called from SDLMain() thread and can't directly affect the view - mSingleton.sendCommand(COMMAND_CHANGE_WINDOW_STYLE, fullscreen ? 1 : 0); - } - - /** - * This method is called by SDL using JNI. - * This is a static method for JNI convenience, it calls a non-static method - * so that is can be overridden - */ - public static void setOrientation(int w, int h, boolean resizable, String hint) - { - if (mSingleton != null) { - mSingleton.setOrientationBis(w, h, resizable, hint); - } - } - - /** - * This can be overridden - */ - public void setOrientationBis(int w, int h, boolean resizable, String hint) - { - int orientation_landscape = -1; - int orientation_portrait = -1; - - if (w <= 1 || h <= 1) { - // Invalid width/height, ignore this request - return; - } - - /* If set, hint "explicitly controls which UI orientations are allowed". */ - if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { - orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE; - } else if (hint.contains("LandscapeLeft")) { - orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; - } else if (hint.contains("LandscapeRight")) { - orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; - } - - /* exact match to 'Portrait' to distinguish with PortraitUpsideDown */ - boolean contains_Portrait = hint.contains("Portrait ") || hint.endsWith("Portrait"); - - if (contains_Portrait && hint.contains("PortraitUpsideDown")) { - orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT; - } else if (contains_Portrait) { - orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - } else if (hint.contains("PortraitUpsideDown")) { - orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; - } - - boolean is_landscape_allowed = (orientation_landscape != -1); - boolean is_portrait_allowed = (orientation_portrait != -1); - int req; /* Requested orientation */ - - /* No valid hint, nothing is explicitly allowed */ - if (!is_portrait_allowed && !is_landscape_allowed) { - if (resizable) { - /* All orientations are allowed, respecting user orientation lock setting */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; - } else { - /* Fixed window and nothing specified. Get orientation from w/h of created window */ - req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); - } - } else { - /* At least one orientation is allowed */ - if (resizable) { - if (is_portrait_allowed && is_landscape_allowed) { - /* hint allows both landscape and portrait, promote to full user */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; - } else { - /* Use the only one allowed "orientation" */ - req = (is_landscape_allowed ? orientation_landscape : orientation_portrait); - } - } else { - /* Fixed window and both orientations are allowed. Choose one. */ - if (is_portrait_allowed && is_landscape_allowed) { - req = (w > h ? orientation_landscape : orientation_portrait); - } else { - /* Use the only one allowed "orientation" */ - req = (is_landscape_allowed ? orientation_landscape : orientation_portrait); - } - } - } - - Log.v(TAG, "setOrientation() requestedOrientation=" + req + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint); - mSingleton.setRequestedOrientation(req); - } - - /** - * This method is called by SDL using JNI. - */ - public static void minimizeWindow() { - - if (mSingleton == null) { - return; - } - - Intent startMain = new Intent(Intent.ACTION_MAIN); - startMain.addCategory(Intent.CATEGORY_HOME); - startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mSingleton.startActivity(startMain); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean shouldMinimizeOnFocusLoss() { - return false; - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean supportsRelativeMouse() - { - // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under - // Android 7 APIs, and simply returns no data under Android 8 APIs. - // - // This is fixed in Samsung Experience 9.5, which corresponds to Android 8.1.0, and - // thus SDK version 27. If we are in DeX mode and not API 27 or higher, as a result, - // we should stick to relative mode. - // - if (Build.VERSION.SDK_INT < 27 /* Android 8.1 (O_MR1) */ && isDeXMode()) { - return false; - } - - return SDLActivity.getMotionListener().supportsRelativeMouse(); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean setRelativeMouseEnabled(boolean enabled) - { - if (enabled && !supportsRelativeMouse()) { - return false; - } - - return SDLActivity.getMotionListener().setRelativeMouseEnabled(enabled); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean sendMessage(int command, int param) { - if (mSingleton == null) { - return false; - } - return mSingleton.sendCommand(command, param); - } - - /** - * This method is called by SDL using JNI. - */ - public static Activity getContext() { - return SDL.getContext(); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean isAndroidTV() { - UiModeManager uiModeManager = (UiModeManager) getContext().getSystemService(UI_MODE_SERVICE); - if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) { - return true; - } - if (Build.MANUFACTURER.equals("MINIX") && Build.MODEL.equals("NEO-U1")) { - return true; - } - if (Build.MANUFACTURER.equals("Amlogic") && - (Build.MODEL.startsWith("TV") || - Build.MODEL.equals("X96-W") || - Build.MODEL.equals("A95X-R1"))) { - return true; - } - return false; - } - - public static boolean isVRHeadset() { - if (Build.MANUFACTURER.equals("Oculus") && Build.MODEL.startsWith("Quest")) { - return true; - } - if (Build.MANUFACTURER.equals("Pico")) { - return true; - } - return false; - } - - public static double getDiagonal() - { - DisplayMetrics metrics = new DisplayMetrics(); - Activity activity = getContext(); - if (activity == null) { - return 0.0; - } - activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); - - double dWidthInches = metrics.widthPixels / (double)metrics.xdpi; - double dHeightInches = metrics.heightPixels / (double)metrics.ydpi; - - return Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches)); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean isTablet() { - // If our diagonal size is seven inches or greater, we consider ourselves a tablet. - return (getDiagonal() >= 7.0); - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean isChromebook() { - // https://stackoverflow.com/questions/39784415/how-to-detect-programmatically-if-android-app-is-running-in-chrome-book-or-in - if (getContext() != null) { - if (getContext().getPackageManager().hasSystemFeature("org.chromium.arc") - || getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management")) { - return true; - } - } - - // Running on AVD emulator - boolean isChromebookEmulator = (Build.MODEL != null && Build.MODEL.startsWith("sdk_gpc_")); - return isChromebookEmulator; - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean isDeXMode() { - if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) { - return false; - } - try { - final Configuration config = getContext().getResources().getConfiguration(); - final Class configClass = config.getClass(); - return configClass.getField("SEM_DESKTOP_MODE_ENABLED").getInt(configClass) - == configClass.getField("semDesktopModeEnabled").getInt(config); - } catch(Exception ignored) { - return false; - } - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean getManifestEnvironmentVariables() { - try { - if (getContext() == null) { - return false; - } - - ApplicationInfo applicationInfo = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA); - Bundle bundle = applicationInfo.metaData; - if (bundle == null) { - return false; - } - String prefix = "SDL_ENV."; - final int trimLength = prefix.length(); - for (String key : bundle.keySet()) { - if (key.startsWith(prefix)) { - String name = key.substring(trimLength); - String value = bundle.get(key).toString(); - nativeSetenv(name, value); - } - } - /* environment variables set! */ - return true; - } catch (Exception e) { - Log.v(TAG, "exception " + e.toString()); - } - return false; - } - - // This method is called by SDLControllerManager's API 26 Generic Motion Handler. - public static View getContentView() { - return mLayout; - } - - static class ShowTextInputTask implements Runnable { - /* - * This is used to regulate the pan&scan method to have some offset from - * the bottom edge of the input region and the top edge of an input - * method (soft keyboard) - */ - static final int HEIGHT_PADDING = 15; - - public int input_type; - public int x, y, w, h; - - public ShowTextInputTask(int input_type, int x, int y, int w, int h) { - this.input_type = input_type; - this.x = x; - this.y = y; - this.w = w; - this.h = h; - - /* Minimum size of 1 pixel, so it takes focus. */ - if (this.w <= 0) { - this.w = 1; - } - if (this.h + HEIGHT_PADDING <= 0) { - this.h = 1 - HEIGHT_PADDING; - } - } - - @Override - public void run() { - RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING); - params.leftMargin = x; - params.topMargin = y; - - if (mTextEdit == null) { - mTextEdit = new SDLDummyEdit(getContext()); - - mLayout.addView(mTextEdit, params); - } else { - mTextEdit.setLayoutParams(params); - } - mTextEdit.setInputType(input_type); - - mTextEdit.setVisibility(View.VISIBLE); - mTextEdit.requestFocus(); - - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextEdit, 0); - - if (imm.isAcceptingText()) { - onNativeScreenKeyboardShown(); - } - } - } - - /** - * This method is called by SDL using JNI. - */ - public static boolean showTextInput(int input_type, int x, int y, int w, int h) { - // Transfer the task to the main thread as a Runnable - return mSingleton.commandHandler.post(new ShowTextInputTask(input_type, x, y, w, h)); - } - - public static boolean isTextInputEvent(KeyEvent event) { - - // Key pressed with Ctrl should be sent as SDL_KEYDOWN/SDL_KEYUP and not SDL_TEXTINPUT - if (event.isCtrlPressed()) { - return false; - } - - return event.isPrintingKey() || event.getKeyCode() == KeyEvent.KEYCODE_SPACE; - } - - public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputConnection ic) { - int deviceId = event.getDeviceId(); - int source = event.getSource(); - - if (source == InputDevice.SOURCE_UNKNOWN) { - InputDevice device = InputDevice.getDevice(deviceId); - if (device != null) { - source = device.getSources(); - } - } - -// if (event.getAction() == KeyEvent.ACTION_DOWN) { -// Log.v("SDL", "key down: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); -// } else if (event.getAction() == KeyEvent.ACTION_UP) { -// Log.v("SDL", "key up: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); -// } - - // Dispatch the different events depending on where they come from - // Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD - // So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD - // - // Furthermore, it's possible a game controller has SOURCE_KEYBOARD and - // SOURCE_JOYSTICK, while its key events arrive from the keyboard source - // So, retrieve the device itself and check all of its sources - if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) { - // Note that we process events with specific key codes here - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (SDLControllerManager.onNativePadDown(deviceId, keyCode, event.getScanCode())) { - return true; - } - } else if (event.getAction() == KeyEvent.ACTION_UP) { - if (SDLControllerManager.onNativePadUp(deviceId, keyCode, event.getScanCode())) { - return true; - } - } - } - - if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) { - if (SDLActivity.isVRHeadset()) { - // The Oculus Quest controller back button comes in as source mouse, so accept that - } else { - // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses - // they are ignored here because sending them as mouse input to SDL is messy - if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) { - switch (event.getAction()) { - case KeyEvent.ACTION_DOWN: - case KeyEvent.ACTION_UP: - // mark the event as handled or it will be handled by system - // handling KEYCODE_BACK by system will call onBackPressed() - return true; - } - } - } - } - - if (event.getAction() == KeyEvent.ACTION_DOWN) { - onNativeKeyDown(keyCode); - - if (isTextInputEvent(event)) { - if (ic != null) { - ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1); - } else { - SDLInputConnection.nativeCommitText(String.valueOf((char) event.getUnicodeChar()), 1); - } - } - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - onNativeKeyUp(keyCode); - return true; - } - - return false; - } - - /** - * This method is called by SDL using JNI. - */ - public static Surface getNativeSurface() { - if (SDLActivity.mSurface == null) { - return null; - } - return SDLActivity.mSurface.getNativeSurface(); - } - - // Input - - /** - * This method is called by SDL using JNI. - */ - public static void initTouch() { - int[] ids = InputDevice.getDeviceIds(); - - for (int id : ids) { - InputDevice device = InputDevice.getDevice(id); - /* Allow SOURCE_TOUCHSCREEN and also Virtual InputDevices because they can send TOUCHSCREEN events */ - if (device != null && ((device.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN - || device.isVirtual())) { - - nativeAddTouch(device.getId(), device.getName()); - } - } - } - - // Messagebox - - /** Result of current messagebox. Also used for blocking the calling thread. */ - protected final int[] messageboxSelection = new int[1]; - - /** - * This method is called by SDL using JNI. - * Shows the messagebox from UI thread and block calling thread. - * buttonFlags, buttonIds and buttonTexts must have same length. - * @param buttonFlags array containing flags for every button. - * @param buttonIds array containing id for every button. - * @param buttonTexts array containing text for every button. - * @param colors null for default or array of length 5 containing colors. - * @return button id or -1. - */ - public int messageboxShowMessageBox( - final int flags, - final String title, - final String message, - final int[] buttonFlags, - final int[] buttonIds, - final String[] buttonTexts, - final int[] colors) { - - messageboxSelection[0] = -1; - - // sanity checks - - if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) { - return -1; // implementation broken - } - - // collect arguments for Dialog - - final Bundle args = new Bundle(); - args.putInt("flags", flags); - args.putString("title", title); - args.putString("message", message); - args.putIntArray("buttonFlags", buttonFlags); - args.putIntArray("buttonIds", buttonIds); - args.putStringArray("buttonTexts", buttonTexts); - args.putIntArray("colors", colors); - - // trigger Dialog creation on UI thread - - runOnUiThread(new Runnable() { - @Override - public void run() { - messageboxCreateAndShow(args); - } - }); - - // block the calling thread - - synchronized (messageboxSelection) { - try { - messageboxSelection.wait(); - } catch (InterruptedException ex) { - ex.printStackTrace(); - return -1; - } - } - - // return selected value - - return messageboxSelection[0]; - } - - protected void messageboxCreateAndShow(Bundle args) { - - // TODO set values from "flags" to messagebox dialog - - // get colors - - int[] colors = args.getIntArray("colors"); - int backgroundColor; - int textColor; - int buttonBorderColor; - int buttonBackgroundColor; - int buttonSelectedColor; - if (colors != null) { - int i = -1; - backgroundColor = colors[++i]; - textColor = colors[++i]; - buttonBorderColor = colors[++i]; - buttonBackgroundColor = colors[++i]; - buttonSelectedColor = colors[++i]; - } else { - backgroundColor = Color.TRANSPARENT; - textColor = Color.TRANSPARENT; - buttonBorderColor = Color.TRANSPARENT; - buttonBackgroundColor = Color.TRANSPARENT; - buttonSelectedColor = Color.TRANSPARENT; - } - - // create dialog with title and a listener to wake up calling thread - - final AlertDialog dialog = new AlertDialog.Builder(this).create(); - dialog.setTitle(args.getString("title")); - dialog.setCancelable(false); - dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface unused) { - synchronized (messageboxSelection) { - messageboxSelection.notify(); - } - } - }); - - // create text - - TextView message = new TextView(this); - message.setGravity(Gravity.CENTER); - message.setText(args.getString("message")); - if (textColor != Color.TRANSPARENT) { - message.setTextColor(textColor); - } - - // create buttons - - int[] buttonFlags = args.getIntArray("buttonFlags"); - int[] buttonIds = args.getIntArray("buttonIds"); - String[] buttonTexts = args.getStringArray("buttonTexts"); - - final SparseArray - + )RML"; -constexpr std::array kDiscFileFilters{{ +const std::vector kDiscFileFilters{ {"Game Disc Images", "iso;gcm;ciso;gcz;nfs;rvz;wbfs;wia;tgc"}, {"All Files", "*"}, -}}; +}; struct DiscVerificationResult { std::string path; @@ -102,7 +111,7 @@ struct DiscVerificationTask { } ~DiscVerificationTask() { - status.shouldCancel.store(true, std::memory_order_relaxed); + status.cancelRequested.store(true, std::memory_order_relaxed); join(); } @@ -125,43 +134,8 @@ struct DiscVerificationTask { std::unique_ptr sDiscVerificationTask; bool sDiscVerificationModalPushed = false; -struct UpdateCheckTask { - UpdateCheckTask() { - worker = std::thread([this] { - try { - result = update_check::check_latest_github_release("TwilitRealm", "dusklight"); - } catch (const std::exception& e) { - result = { - .status = update_check::Status::Failed, - .message = fmt::format("Update check failed with exception: {}", e.what()), - }; - } catch (...) { - result = { - .status = update_check::Status::Failed, - .message = "Update check failed with an unknown exception", - }; - } - done.store(true, std::memory_order_release); - }); - } - - ~UpdateCheckTask() { join(); } - - void join() { - if (worker.joinable()) { - worker.join(); - } - } - - [[nodiscard]] bool finished() const { return done.load(std::memory_order_acquire); } - - update_check::Result result; - std::atomic_bool done = false; - std::thread worker; -}; - -std::unique_ptr sUpdateCheckTask; -std::optional sUpdateCheckResult; +borealis::Task sUpdateCheck; +std::optional sUpdateCheckResult; bool verification_state_allows_launch(iso::ValidationError validation) noexcept { return validation == iso::ValidationError::Unknown || @@ -191,28 +165,12 @@ DiscVerificationState verification_to_config(iso::ValidationError validation) { } } -std::string format_bytes(std::size_t bytes) { - constexpr double KiB = 1024.0; - constexpr double MiB = KiB * 1024.0; - constexpr double GiB = MiB * 1024.0; - if (bytes >= static_cast(GiB)) { - return fmt::format("{:.2f} GiB", static_cast(bytes) / GiB); - } - if (bytes >= static_cast(MiB)) { - return fmt::format("{:.0f} MiB", static_cast(bytes) / MiB); - } - if (bytes >= static_cast(KiB)) { - return fmt::format("{:.0f} KiB", static_cast(bytes) / KiB); - } - return fmt::format("{} B", bytes); -} - void begin_disc_verification(std::string path) noexcept { if (path.empty()) { return; } if (sDiscVerificationTask != nullptr) { - sDiscVerificationTask->status.shouldCancel.store(true, std::memory_order_relaxed); + sDiscVerificationTask->status.cancelRequested.store(true, std::memory_order_relaxed); sDiscVerificationTask.reset(); } sDiscVerificationTask = std::make_unique(std::move(path)); @@ -238,24 +196,23 @@ void begin_update_check() { if (!getSettings().backend.checkForUpdates.getValue()) { return; } - if (sUpdateCheckTask != nullptr || sUpdateCheckResult.has_value()) { + if (sUpdateCheck || sUpdateCheckResult.has_value()) { return; } - sUpdateCheckTask = std::make_unique(); + sUpdateCheck = borealis::update::check_latest_github_release(AppInfo); } -std::optional take_finished_update_check() { - if (sUpdateCheckTask == nullptr || !sUpdateCheckTask->finished()) { +std::optional take_finished_update_check() { + if (!sUpdateCheck || !sUpdateCheck.ready()) { return std::nullopt; } - sUpdateCheckTask->join(); - auto result = std::move(sUpdateCheckTask->result); - sUpdateCheckTask.reset(); + auto result = sUpdateCheck.try_take(); + sUpdateCheck = {}; return result; } -std::string update_release_label(const update_check::Release& release) { +std::string update_release_label(const borealis::update::Release& release) { std::string_view tagName = release.tagName; if (!tagName.empty() && tagName.front() == 'v') { tagName.remove_prefix(1); @@ -265,7 +222,7 @@ std::string update_release_label(const update_check::Release& release) { void open_update_release() { if (!sUpdateCheckResult.has_value() || - sUpdateCheckResult->status != update_check::Status::UpdateAvailable) + sUpdateCheckResult->status != borealis::update::Status::UpdateAvailable) { return; } @@ -291,7 +248,7 @@ std::string get_error_msg(iso::ValidationError error) { case iso::ValidationError::WrongGame: return "The selected game is not supported by Dusklight."; case iso::ValidationError::WrongVersion: - return "Dusklight currently supports GameCube USA and PAL disc images only."; + return "Dusklight does not currently support the Wii's Korean version."; case iso::ValidationError::Canceled: return "Disc verification was canceled. Dusklight cannot guarantee the selected disc " "image is compatible."; @@ -317,6 +274,24 @@ void persist_disc_choice(const std::string& path, iso::ValidationError validatio } } +void apply_language_for_disc(const iso::DiscInfo& info) { + const auto langs = language::available_languages(info); + auto& language = getSettings().game.language; + const GameLanguage previous = language.getValue(); + if (std::ranges::find(langs, previous) != langs.end()) { + return; + } + + const GameLanguage fallback = langs.front(); + language.setValue(fallback); + config::save(); + + auto& state = prelaunch_state(); + state.initialLanguage = fallback; + state.unavailableLanguage = previous; + state.pendingLanguageUnavailableNotice = true; +} + void apply_valid_disc_result( const std::string& path, const iso::DiscInfo& info, iso::ValidationError validation) { auto& state = prelaunch_state(); @@ -329,6 +304,7 @@ void apply_valid_disc_result( state.activeDiscInfo = info; } persist_disc_choice(path, validation); + apply_language_for_disc(info); } void apply_disc_verification_result(const DiscVerificationResult& result) { @@ -340,7 +316,7 @@ void apply_disc_verification_result(const DiscVerificationResult& result) { state.pendingDiscPath = result.path; state.pendingDiscInfo = result.info; state.pendingDiscValidation = result.validation; - state.errorString = escape(get_error_msg(result.validation)); + state.errorString = get_error_msg(result.validation); return; } @@ -356,41 +332,34 @@ void apply_disc_verification_result(const DiscVerificationResult& result) { state.pendingDiscPath.clear(); state.pendingDiscInfo = {}; state.pendingDiscValidation = iso::ValidationError::Unknown; - state.errorString = escape(get_error_msg(result.validation)); + state.errorString = get_error_msg(result.validation); } class DiscVerificationModal : public WindowSmall { public: - DiscVerificationModal() : WindowSmall("modal", "modal-dialog") { - auto* header = append(mDialog, "div"); - header->SetClass("modal-header", true); + DiscVerificationModal() : WindowSmall("modal") { + auto* header = append(mDialog, "modal-header"); - auto* title = append(header, "div"); - title->SetClass("modal-title", true); - title->SetInnerRML("Verifying disc image"); + auto* title = append(header, "modal-title"); + append_text(title, "Verifying disc image"); auto* icon = append(header, "icon"); icon->SetClass("verifying", true); - auto* body = append(mDialog, "div"); - body->SetClass("modal-body", true); + auto* body = append(mDialog, "modal-body"); - auto* content = append(body, "div"); - content->SetClass("verification-progress", true); + auto* content = append(body, "verification-progress"); - mFileName = append(content, "div"); - mFileName->SetClass("verification-file", true); + mFileName = append(content, "verification-file"); mProgress = append(content, "progress"); mProgress->SetClass("progress-ongoing", true); mProgress->SetClass("verification-progress-bar", true); mProgress->SetAttribute("value", 0.f); - mDetail = append(content, "div"); - mDetail->SetClass("verification-detail", true); + mDetail = append(content, "verification-detail"); - auto* actions = append(mDialog, "div"); - actions->SetClass("modal-actions", true); + auto* actions = append(mDialog, "modal-actions"); mCancelButton = std::make_unique