diff --git a/.clang-format b/.clang-format index 8ffd4ebe96..1cf581604c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,6 @@ --- Language: Cpp -Standard: C++03 +Standard: c++20 AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign AlignConsecutiveAssignments: false 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..f05842fa7b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [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 diff --git a/CMakeLists.txt b/CMakeLists.txt index f36987ad96..f89d82f587 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,98 +5,11 @@ if (NOT CMAKE_BUILD_TYPE) "Build type options: Debug Release RelWithDebInfo MinSizeRel" FORCE) endif () -set(DUSK_VERSION_OVERRIDE "" CACHE STRING "Override version string (skips git detection and format validation)") - -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 ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD - OUTPUT_VARIABLE dusk_git_head_filename - OUTPUT_STRIP_TRAILING_WHITESPACE) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_filename}") - - execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD - OUTPUT_VARIABLE dusk_git_head_symbolic - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${dusk_git_head_symbolic} - OUTPUT_VARIABLE dusk_git_head_symbolic_filename - OUTPUT_STRIP_TRAILING_WHITESPACE) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_symbolic_filename}") - - # defines DUSK_WC_REVISION - execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - OUTPUT_VARIABLE DUSK_WC_REVISION - OUTPUT_STRIP_TRAILING_WHITESPACE) - # defines DUSK_WC_DESCRIBE - execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 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 ${CMAKE_SOURCE_DIR} 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 ${CMAKE_SOURCE_DIR} 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}") +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 () @@ -120,12 +33,40 @@ 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 set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_cmake") +option(ENABLE_ASAN "Enable AddressSanitizer" OFF) +if (ENABLE_ASAN) + if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" AND + CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + add_compile_options($<$:/fsanitize=address>) + add_link_options(/fsanitize=address /INCREMENTAL:NO) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase") + foreach (_lang C CXX) + foreach (_rtc_flag /RTC1 /RTCc /RTCs /RTCu) + string(REPLACE "${_rtc_flag}" "" CMAKE_${_lang}_FLAGS_DEBUG "${CMAKE_${_lang}_FLAGS_DEBUG}") + endforeach () + endforeach () + elseif (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" AND + CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + add_compile_options( + $<$:-fsanitize=address> + $<$:-fno-omit-frame-pointer> + ) + add_link_options(-fsanitize=address) + else () + message(FATAL_ERROR "ENABLE_ASAN requires GNU-like or MSVC-like C/C++ compiler frontends") + endif () + + add_compile_definitions(NDEBUG_SANITIZER) # Avoids absl issue with SwissTable debug code + message(STATUS "dusklight: Enabled AddressSanitizer") +endif () + if (CMAKE_SYSTEM_NAME STREQUAL Linux) set(DAWN_USE_WAYLAND ON CACHE BOOL "Enable support for Wayland surface" FORCE) endif () @@ -135,6 +76,8 @@ 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") @@ -146,15 +89,43 @@ 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}) -set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") -set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") +option(DUSK_ENABLE_CODE_MODS "Enable code mods" OFF) + +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) - if ("${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}" STREQUAL "" AND CMAKE_BUILD_TYPE STREQUAL "Debug") + if ("${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}" STREQUAL "" AND CMAKE_BUILD_TYPE STREQUAL "Debug" + AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue") endif () if (CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "EditAndContinue") @@ -181,6 +152,7 @@ if (DUSK_MOVIE_SUPPORT) -DENABLE_SHARED=OFF -DWITH_TURBOJPEG=ON -DWITH_JAVA=OFF + -DCMAKE_INSTALL_LIBDIR=lib ) if (CMAKE_TOOLCHAIN_FILE) get_filename_component(_jpeg_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") @@ -224,24 +196,21 @@ if (DUSK_MOVIE_SUPPORT) 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) @@ -256,49 +225,59 @@ 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 +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 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 TRUE -) -FetchContent_MakeAvailable(cxxopts json) -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 +set(_fetch_content_deps miniz) +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 + # cmake/PatchCapstone.cmake after capstone is cloned, which removes the + # cmake_policy(SET CMP0048 OLD) line that CMake >= 3.27 rejects. + # This is incredibly scuffed and we should probably think of a better way to do this + set(CAPSTONE_FIX_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/PatchCapstone.cmake") + FetchContent_Declare(funchook + GIT_REPOSITORY https://github.com/kubo/funchook.git + GIT_TAG v1.1.3 GIT_SHALLOW TRUE GIT_PROGRESS TRUE - GIT_SUBMODULES_RECURSE TRUE + PATCH_COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR= -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PatchFunchook.cmake + EXCLUDE_FROM_ALL ) - 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}) + set(FUNCHOOK_BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(FUNCHOOK_BUILD_SHARED OFF CACHE BOOL "" FORCE) + set(FUNCHOOK_INSTALL OFF CACHE BOOL "" FORCE) + if (APPLE AND CMAKE_OSX_ARCHITECTURES) + list(LENGTH CMAKE_OSX_ARCHITECTURES _osx_arch_count) + if (_osx_arch_count EQUAL 1) + list(GET CMAKE_OSX_ARCHITECTURES 0 _osx_arch) + if (_osx_arch MATCHES "^(arm64|aarch64|ARM64)$") + set(FUNCHOOK_CPU arm64 CACHE STRING "" FORCE) + elseif (_osx_arch MATCHES "^(x86_64|AMD64|amd64|i[3-6]86|x86)$") + set(FUNCHOOK_CPU x86 CACHE STRING "" FORCE) + endif () + endif () endif () + list(APPEND _fetch_content_deps funchook) endif () +FetchContent_MakeAvailable(${_fetch_content_deps}) # Use signed char on ARM to match the original game (and x86) string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _arch) @@ -306,22 +285,6 @@ if(_arch MATCHES "^(arm|aarch64)" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQU add_compile_options(-fsigned-char) endif() -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(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h) - include(files.cmake) # TODO: version handling for res includes @@ -334,75 +297,23 @@ 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}) -set(GAME_COMPILE_DEFS TARGET_PC WIDESCREEN_SUPPORT=1 AVOID_UB=1 VERSION=0 MTX_USE_PS=1) - -set(GAME_INCLUDE_DIRS - include - src - assets/GZ2E01 # TODO: make this dynamic if needed? - libs/JSystem/include - libs - extern/aurora/include/dolphin - extern - ${CMAKE_BINARY_DIR}) +include(cmake/GameABIConfig.cmake) find_package(Threads REQUIRED) +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::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt - Threads::Threads) - -list(APPEND GAME_LIBS zstd::libzstd) - -if (DUSK_ENABLE_SENTRY_NATIVE) - list(APPEND GAME_LIBS sentry) - list(APPEND GAME_COMPILE_DEFS DUSK_ENABLE_SENTRY_NATIVE=1 SENTRY_BUILD_STATIC=1) + aurora::card borealis::cli borealis::crash borealis::data borealis::disc borealis::discord borealis::file_select borealis::log borealis::presentation borealis::sentry borealis::update freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt + Threads::Threads zstd::libzstd dusklight_game_headers) +if (DUSK_HAS_FUNCHOOK) + list(APPEND GAME_LIBS funchook-static) 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) @@ -412,17 +323,16 @@ if (DUSK_MOVIE_SUPPORT) 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) +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(ANDROID) - list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1) +if (DUSK_PACKAGE_INSTALL) + include(GNUInstallDirs) + list(APPEND GAME_COMPILE_DEFS DUSK_ASSET_DIR="${CMAKE_INSTALL_FULL_DATADIR}/dusklight/") endif () if (DUSK_GFX_DEBUG_GROUPS) @@ -444,7 +354,7 @@ set(GAME_DEBUG_FILES set_source_files_properties( ${GAME_DEBUG_FILES} PROPERTIES - COMPILE_DEFINITIONS "$<$:DEBUG=1>;$<$:PARTIAL_DEBUG=1>" + COMPILE_DEFINITIONS "$<$:DEBUG=1>" ) # game_base is for all other game code files @@ -458,16 +368,11 @@ set(GAME_BASE_FILES set_source_files_properties( ${GAME_BASE_FILES} PROPERTIES - COMPILE_DEFINITIONS "NDEBUG=1;NDEBUG_DEFINED=1;DEBUG_DEFINED=0;$<$:PARTIAL_DEBUG=1>" + COMPILE_DEFINITIONS "NDEBUG=1;NDEBUG_DEFINED=1;DEBUG_DEFINED=0" ) foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) - target_compile_definitions(${jsystem_lib} PRIVATE - ${GAME_COMPILE_DEFS} - $<$:DEBUG=1> - $<$:PARTIAL_DEBUG=1> - ) - target_include_directories(${jsystem_lib} PRIVATE ${GAME_INCLUDE_DIRS}) + target_compile_definitions(${jsystem_lib} PRIVATE ${GAME_COMPILE_DEFS} $<$:DEBUG=1>) target_link_libraries(${jsystem_lib} PRIVATE ${GAME_LIBS}) set_target_properties(${jsystem_lib} PROPERTIES FOLDER "JSystem") endforeach() @@ -479,18 +384,80 @@ 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}) +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 () +borealis_configure_android_application(dusklight) +if (ENABLE_ASAN) + target_sources(dusklight PRIVATE src/dusk/asan_options.c) +endif () target_compile_definitions(dusklight PRIVATE ${GAME_COMPILE_DEFS}) -target_include_directories(dusklight PRIVATE ${GAME_INCLUDE_DIRS}) +target_include_directories(dusklight PRIVATE ${miniz_SOURCE_DIR}) target_link_libraries(dusklight PRIVATE aurora::main ${GAME_LIBS} ${JSYSTEM_LINK_LIBRARIES}) target_precompile_headers(dusklight PRIVATE "$<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") + +if (DUSK_ENABLE_CODE_MODS) + include(cmake/SymbolManifest.cmake) + if (WIN32) + # Game ABI exports & import library for mod linking + include(cmake/WindowsExports.cmake) + setup_windows_exports(dusklight) + endif () + # Post-link symbol manifest: hookable-surface name->address map keyed to the build. + 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>) + 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)$") + 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>) + 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 () + +if (WIN32) + target_link_libraries(dusklight PRIVATE Psapi) +endif () +if (APPLE) + 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 () + if (TARGET crashpad_handler) add_dependencies(dusklight crashpad_handler) add_custom_command(TARGET dusklight POST_BUILD @@ -501,14 +468,9 @@ 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) endif () if (NOT APPLE) @@ -549,6 +511,16 @@ if (WIN32) endif () endif () +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(mods/template_mod) + add_subdirectory(mods/ao_mod) + add_subdirectory(mods/shadow_mod) + add_subdirectory(mods/window_demo) +endif () + if (APPLE) if (IOS) set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios) @@ -556,6 +528,7 @@ if (APPLE) set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/tvos) else () set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/macos) + set(DUSK_ENTITLEMENTS ${DUSK_RESOURCE_DIR}/Dusklight.entitlements) endif () set(DUSK_INFO_PLIST ${DUSK_RESOURCE_DIR}/Info.plist.in) file(GLOB_RECURSE DUSK_RESOURCE_FILES @@ -575,33 +548,42 @@ if (APPLE) get_filename_component(NEW_FILE_PATH ${NEW_FILE} DIRECTORY) set_property(SOURCE ${FILE} PROPERTY MACOSX_PACKAGE_LOCATION "Resources/${NEW_FILE_PATH}") endforeach () - set_target_properties( - dusklight PROPERTIES + set(_apple_bundle_properties 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" XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES" ) -endif () + if (DUSK_ENTITLEMENTS) + list(APPEND _apple_bundle_properties + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${DUSK_ENTITLEMENTS}) + endif () + 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 (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}) + 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 + COMMAND /usr/bin/codesign --force --sign - + "$/crashpad_handler") + endif () + add_custom_command(TARGET dusklight POST_BUILD + ${_sign_nested_commands} + COMMAND /usr/bin/codesign --force --sign - --entitlements + "${DUSK_ENTITLEMENTS}" "$" + COMMENT "Signing Dusklight.app with entitlements" + VERBATIM + ) + endif () endif () include(extern/aurora/cmake/AuroraCopyRuntimeDLLs.cmake) @@ -648,12 +630,20 @@ set(EXTRA_TARGETS "") if (TARGET crashpad_handler) list(APPEND EXTRA_TARGETS crashpad_handler) endif () -install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) +if (DUSK_PACKAGE_INSTALL) + install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR}) +else() + install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) +endif() aurora_install_runtime_dlls(dusklight ${CMAKE_INSTALL_PREFIX}) if (NOT APPLE) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) + if (DUSK_PACKAGE_INSTALL) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dusklight) + else() + install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif() endif () -if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) +if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo AND NOT DUSK_PACKAGE_INSTALL) set(DEBUG_FILES_LIST "") foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS) get_target_output_name(${target} output_name) @@ -702,3 +692,5 @@ foreach (target IN LISTS BINARY_TARGETS) endif () endforeach () endforeach () + +install_bundled_mods() diff --git a/CMakePresets.json b/CMakePresets.json index 6c3a2c46ef..45a6522625 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,30 +23,28 @@ } }, { - "name": "release", + "name": "ci", "hidden": true, "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDLL", - "CMAKE_INTERPROCEDURAL_OPTIMIZATION": { + "CMAKE_C_COMPILER_LAUNCHER": "sccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "sccache", + "BOREALIS_ENABLE_SENTRY": { + "type": "BOOL", + "value": true + }, + "BOREALIS_SENTRY_DSN": "$env{SENTRY_DSN}", + "BOREALIS_SENTRY_ENVIRONMENT": "production", + "Rust_RUSTUP_INSTALL_MISSING_TARGET": { "type": "BOOL", "value": true } } }, { - "name": "ci", + "name": "asan", "hidden": true, "cacheVariables": { - "CMAKE_C_COMPILER_LAUNCHER": "sccache", - "CMAKE_CXX_COMPILER_LAUNCHER": "sccache", - "DUSK_ENABLE_SENTRY_NATIVE": { - "type": "BOOL", - "value": true - }, - "DUSK_SENTRY_DSN": "$env{SENTRY_DSN}", - "DUSK_SENTRY_ENVIRONMENT": "production", - "Rust_RUSTUP_INSTALL_MISSING_TARGET": { + "ENABLE_ASAN": { "type": "BOOL", "value": true } @@ -62,7 +60,11 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + } }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -83,6 +85,15 @@ "linux-default" ] }, + { + "name": "linux-default-debug-asan", + "displayName": "Linux (default) Debug ASan", + "inherits": [ + "debug", + "linux-default", + "asan" + ] + }, { "name": "linux-default-relwithdebinfo", "displayName": "Linux (default) RelWithDebInfo", @@ -110,6 +121,15 @@ "linux-clang" ] }, + { + "name": "linux-clang-debug-asan", + "displayName": "Linux (Clang) Debug ASan", + "inherits": [ + "debug", + "linux-clang", + "asan" + ] + }, { "name": "linux-clang-relwithdebinfo", "displayName": "Linux (Clang) RelWithDebInfo", @@ -130,7 +150,15 @@ "cacheVariables": { "CMAKE_C_COMPILER": "cl", "CMAKE_CXX_COMPILER": "cl", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + }, + "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { + "type": "BOOL", + "value": true + } }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -148,6 +176,15 @@ "windows-msvc" ] }, + { + "name": "windows-msvc-debug-asan", + "displayName": "Windows (MSVC) Debug ASan", + "inherits": [ + "debug", + "windows-msvc", + "asan" + ] + }, { "name": "windows-msvc-relwithdebinfo", "displayName": "Windows (MSVC) RelWithDebInfo", @@ -159,17 +196,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": [ @@ -221,7 +254,11 @@ "type": "BOOL", "value": false }, - "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install" + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install", + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + } }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -239,6 +276,15 @@ "macos-default" ] }, + { + "name": "macos-default-debug-asan", + "displayName": "macOS (default) Debug ASan", + "inherits": [ + "debug", + "macos-default", + "asan" + ] + }, { "name": "macos-default-relwithdebinfo", "displayName": "macOS (default) RelWithDebInfo", @@ -268,11 +314,19 @@ "type": "BOOL", "value": false }, + "ENABLE_VISIBILITY": { + "type": "BOOL", + "value": true + }, "Rust_CARGO_TARGET": "aarch64-apple-ios", "BUILD_SHARED_LIBS": { "type": "BOOL", "value": false }, + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -308,12 +362,20 @@ "type": "BOOL", "value": false }, + "ENABLE_VISIBILITY": { + "type": "BOOL", + "value": true + }, "Rust_CARGO_TARGET": "aarch64-apple-tvos", "Rust_TOOLCHAIN": "nightly", "BUILD_SHARED_LIBS": { "type": "BOOL", "value": false }, + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -344,6 +406,10 @@ "type": "BOOL", "value": false }, + "DUSK_ENABLE_CODE_MODS": { + "type": "BOOL", + "value": true + }, "CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": { "type": "BOOL", "value": true @@ -379,11 +445,10 @@ "hidden": true, "inherits": [ "android-base", - "ci", - "release" + "ci" ], "cacheVariables": { - "DUSK_ENABLE_SENTRY_NATIVE": { + "BOREALIS_ENABLE_SENTRY": { "type": "BOOL", "value": false } @@ -529,6 +594,12 @@ "description": "Linux (default) debug build", "displayName": "Linux (default) Debug" }, + { + "name": "linux-default-debug-asan", + "configurePreset": "linux-default-debug-asan", + "description": "Linux (default) debug build with AddressSanitizer", + "displayName": "Linux (default) Debug ASan" + }, { "name": "linux-default-relwithdebinfo", "configurePreset": "linux-default-relwithdebinfo", @@ -541,6 +612,12 @@ "description": "Linux (Clang) debug build", "displayName": "Linux (Clang) Debug" }, + { + "name": "linux-clang-debug-asan", + "configurePreset": "linux-clang-debug-asan", + "description": "Linux (Clang) debug build with AddressSanitizer", + "displayName": "Linux (Clang) Debug ASan" + }, { "name": "linux-clang-relwithdebinfo", "configurePreset": "linux-clang-relwithdebinfo", @@ -553,6 +630,12 @@ "description": "macOS debug build", "displayName": "macOS Debug" }, + { + "name": "macos-default-debug-asan", + "configurePreset": "macos-default-debug-asan", + "description": "macOS debug build with AddressSanitizer", + "displayName": "macOS Debug ASan" + }, { "name": "macos-default-relwithdebinfo", "configurePreset": "macos-default-relwithdebinfo", @@ -610,6 +693,12 @@ "description": "Windows (MSVC) debug build", "displayName": "Windows (MSVC) Debug" }, + { + "name": "windows-msvc-debug-asan", + "configurePreset": "windows-msvc-debug-asan", + "description": "Windows (MSVC) debug build with AddressSanitizer", + "displayName": "Windows (MSVC) Debug ASan" + }, { "name": "windows-msvc-relwithdebinfo", "configurePreset": "windows-msvc-relwithdebinfo", diff --git a/README.md b/README.md index 5a9701bede..b5a9ecae72 100644 --- a/README.md +++ b/README.md @@ -20,31 +20,17 @@ It aims to be as accurate as possible to the original while also providing new o > Dusklight does *not* provide any copyrighted assets. You must provide your own copy of the original game. > [!IMPORTANT] -> At a minimum, Dusklight requires a GPU with support for either D3D12, Vulkan, or Metal. Your experience with specific hardware, operating systems, and drivers may vary. In particular, older Intel iGPUs have a high likelihood of incompatibility. We are also aware of a number of issues on devices with Adreno GPUs and are working to resolve them. +> At a minimum, Dusklight requires a GPU with support for D3D12, Vulkan 1.1+, or Metal. For older devices, best-effort support is provided for D3D11 and OpenGL ES (Android), but will not achieve full accuracy or performance. Your experience with specific hardware, operating systems, and drivers may vary. ### 1. Dump your game -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 a `.rvz` to save space. +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. +Currently, only the GameCube releases are supported. Support for other versions of the game is planned in the future. -### 2. Download [Dusklight](https://github.com/TwilitRealm/dusklight/releases) +### 2. Install Dusklight -### 3. Setup the game -**Windows / macOS / Linux** -- Extract the .zip file -- Launch Dusklight -- Press **Select Disc Image** and provide the path to your supported game dump -- Press **Play**! - -**iOS** -- Follow the [iOS setup guide](docs/ios-install-altstore.md) - -**Android** -- Install the Dusklight APK -- Launch Dusklight -- Press **Select Disc Image** and provide the path to your supported game dump -- Press **Play**! +Visit the [official installation guide](https://twilitrealm.dev/install/) for full instructions. # Building 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..66e80d3f4a --- /dev/null +++ b/cmake/AndroidExports.cmake @@ -0,0 +1,63 @@ +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 + --exclude asan_options + --exclude src/dusk + # 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..2c78939811 --- /dev/null +++ b/cmake/AppleExports.cmake @@ -0,0 +1,90 @@ +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 + --exclude asan_options + --exclude src/dusk + ${_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/GameABIConfig.cmake b/cmake/GameABIConfig.cmake new file mode 100644 index 0000000000..ef3b5818dc --- /dev/null +++ b/cmake/GameABIConfig.cmake @@ -0,0 +1,68 @@ +# The game ABI surface shared by the main build and the mod SDK (sdk/CMakeLists.txt) +include_guard(GLOBAL) + +get_filename_component(_game_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) + +# PARTIAL_DEBUG makes debug and release share one struct/vtable ABI so a mod binary loads into either +set(_game_compile_defs TARGET_PC=1 WIDESCREEN_SUPPORT=1 AVOID_UB=1 VERSION=0 MTX_USE_PS=1 PARTIAL_DEBUG=1) +if (ANDROID) + list(APPEND _game_compile_defs TARGET_ANDROID=1) +endif () + +# Public game headers +set(_game_abi_include_dirs + ${_game_root}/include + ${_game_root}/assets/GZ2E01 + ${_game_root}/libs/JSystem/include + ${_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} +) + +# 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/ModSDK.cmake b/cmake/ModSDK.cmake new file mode 100644 index 0000000000..da9aa51f38 --- /dev/null +++ b/cmake/ModSDK.cmake @@ -0,0 +1,518 @@ +# 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_info out_platform_var out_name_var) + set(_arch "${CMAKE_SYSTEM_PROCESSOR}") + if (APPLE AND CMAKE_OSX_ARCHITECTURES) + list(LENGTH CMAKE_OSX_ARCHITECTURES _count) + if (_count GREATER 1) + 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") + else () + set(_ext ".so") + endif () + 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) + if (IS_ABSOLUTE "${path}") + set(_path "${path}") + else () + set(_path "${CMAKE_CURRENT_SOURCE_DIR}/${path}") + endif () + set(${out_var} "${_path}" PARENT_SCOPE) +endfunction() + +function(_mod_collect_assets out_var dir) + if (NOT IS_DIRECTORY "${dir}") + message(FATAL_ERROR "add_mod: asset directory does not exist: ${dir}") + endif () + + file(GLOB_RECURSE _files CONFIGURE_DEPENDS LIST_DIRECTORIES false "${dir}/*") + # 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;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 () + _mod_resolve_source_path(_mod_json "${ARG_MOD_JSON}") + if (NOT EXISTS "${_mod_json}") + message(FATAL_ERROR "add_mod: MOD_JSON does not exist: ${_mod_json}") + endif () + + 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 () + 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 () + + 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) + 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 () + 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 () + set_target_properties(${target_name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") + target_compile_definitions(${target_name} PRIVATE _ITERATOR_DEBUG_LEVEL=0) + 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}") + if (ARG_OUTPUT_DIR) + set(_output_dir "${ARG_OUTPUT_DIR}") + endif () + set(_stage "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_stage") + set(_out "${_output_dir}/${target_name}.dusk") + + set(_zip_args mod.json) + set(_package_deps "${_mod_json}") + set(_package_inputs "${_mod_json}") + set(_extra_cmds "") + set(_lib_copy_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}") + 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} "-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}") + _mod_collect_assets(_overlay_deps "${_overlay_dir}") + 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} "-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}") + _mod_collect_assets(_textures_deps "${_textures_dir}") + 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} "-DSRC=${_textures_dir}" + "-DDST=${_stage}/textures" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CopyModAssets.cmake") + endif () + + set(_bundle_cmds "") + if (ARG_BUNDLE AND TARGET dusklight) + file(READ "${_mod_json}" _mod_json_text) + string(JSON _mod_id GET "${_mod_json_text}" id) + set_property(GLOBAL APPEND PROPERTY DUSK_BUNDLED_MOD_TARGETS "${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" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_out}" "${CMAKE_BINARY_DIR}/bundled_mods/${target_name}.dusk") + endif () + + set(_package_target "${target_name}_package") + set(_package_inputs_file "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_package_inputs.txt") + list(SORT _package_inputs) + set(_package_inputs_text "") + foreach (_package_input IN LISTS _package_inputs) + string(APPEND _package_inputs_text "${_package_input}\n") + endforeach () + file(GENERATE OUTPUT "${_package_inputs_file}" CONTENT "${_package_inputs_text}") + add_custom_command(OUTPUT "${_out}" + COMMAND ${CMAKE_COMMAND} -E rm -rf "${_stage}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${_stage}" "${_output_dir}" + ${_lib_copy_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_depend} ${_package_deps} "${_package_inputs_file}" + COMMENT "Packaging ${target_name} -> ${_out}" + COMMAND_EXPAND_LISTS + VERBATIM + ) + add_custom_target(${_package_target} ALL DEPENDS "${_out}") + if (TARGET dusklight_mods) + add_dependencies(dusklight_mods ${_package_target}) + endif () +endfunction() + +# Install rules for BUNDLE mods. +# - Windows: the .dusk archives into /mods (the loader extracts native libs to the +# 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, 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) + if (NOT _targets OR ANDROID) + return () + 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") + + if (APPLE) + get_target_property(_app_name dusklight OUTPUT_NAME) + if (NOT _app_name) + set(_app_name dusklight) + endif () + set(_bundle_dir "${CMAKE_INSTALL_PREFIX}/${_app_name}.app") + if (IOS OR TVOS) + foreach (_i RANGE ${_last}) + 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" EXCLUDE) + install(PROGRAMS "$" + 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 " + 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 () + endif () + + if (DUSK_PACKAGE_INSTALL) + set(_mods_dest "${CMAKE_INSTALL_DATAROOTDIR}/dusklight/mods") + else () + set(_mods_dest "${CMAKE_INSTALL_PREFIX}/mods") + endif () + if (WIN32) + foreach (_target IN LISTS _targets) + install(FILES "${CMAKE_BINARY_DIR}/bundled_mods/${_target}.dusk" DESTINATION "${_mods_dest}") + endforeach () + else () + foreach (_i RANGE ${_last}) + list(GET _ids ${_i} _id) + list(GET _stages ${_i} _stage) + install(DIRECTORY "${_stage}/" DESTINATION "${_mods_dest}/${_id}") + endforeach () + endif () +endfunction() diff --git a/cmake/PatchCapstone.cmake b/cmake/PatchCapstone.cmake new file mode 100644 index 0000000000..fa8a1dd160 --- /dev/null +++ b/cmake/PatchCapstone.cmake @@ -0,0 +1,13 @@ +# Patches capstone's CMakeLists.txt for compatibility with CMake >= 4.0: +# - Bumps cmake_minimum_required to 3.10 (CMake >= 4.0 dropped < 3.5 support; < 3.10 warns) +# - Removes cmake_policy(SET CMP0048 OLD) (rejected by CMake >= 3.27) +file(READ "${DIR}/CMakeLists.txt" _content) +string(REGEX REPLACE + "cmake_minimum_required[ \t]*\\([ \t]*VERSION[ \t]+[0-9]+\\.[0-9]+(\\.[0-9]+)?[ \t]*\\)" + "cmake_minimum_required(VERSION 3.10)" + _content "${_content}") +string(REGEX REPLACE + "cmake_policy[ \t]*\\([ \t]*SET[ \t]+CMP0048[ \t]+OLD[ \t]*\\)" + "# cmake_policy(SET CMP0048 OLD)" + _content "${_content}") +file(WRITE "${DIR}/CMakeLists.txt" "${_content}") diff --git a/cmake/PatchFunchook.cmake b/cmake/PatchFunchook.cmake new file mode 100644 index 0000000000..6d5a6e36b4 --- /dev/null +++ b/cmake/PatchFunchook.cmake @@ -0,0 +1,60 @@ +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}" + 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}") +endif () + +file(WRITE "${SOURCE_DIR}/src/funchook_unix.c" "${_unix_content}") diff --git a/cmake/SymbolManifest.cmake b/cmake/SymbolManifest.cmake new file mode 100644 index 0000000000..7ef57f7ced --- /dev/null +++ b/cmake/SymbolManifest.cmake @@ -0,0 +1,153 @@ +include_guard(GLOBAL) + +get_filename_component(_SYMBOL_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) + +set(_SYMGEN_VERSION "1.3.2") +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 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=0344838d1674df09c17c3eeddcf26eb89c333fdb85dfd78f68adc436070eccbe") + elseif (_host_processor MATCHES "^(x86_64|amd64)$") + set(_asset "symgen-macos-x86_64") + set(_asset_hash "SHA256=ae0674f4a1e9d0dedfa02d35939ac28cdd229276b331c1f507df5df809cbec7e") + endif () + elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + if (_host_processor MATCHES "^(aarch64|arm64)$") + set(_asset "symgen-linux-aarch64") + set(_asset_hash "SHA256=af766de2bfaeb0a06f6d7bc17bb2510b4a9c40f44a56e49bc4a4b798a6223042") + elseif (_host_processor MATCHES "^(x86_64|amd64)$") + set(_asset "symgen-linux-x86_64") + set(_asset_hash "SHA256=ebd62fb9623acc942b6295609e2306f85a73043b0a8a117f2072b761dd08e68f") + elseif (_host_processor MATCHES "^(i[3-6]86|x86)$") + set(_asset "symgen-linux-i686") + set(_asset_hash "SHA256=07780a4513fd29726578efc4ff2d88736b22f407ed821b32a68e35ff1e9af5f4") + endif () + elseif (CMAKE_HOST_WIN32) + if (_host_processor MATCHES "^(arm64|aarch64)$") + set(_asset "symgen-windows-arm64.exe") + set(_asset_hash "SHA256=5bb22b4a4a9b5ad45646af411bfb09b8321a732ff3a077eb4c9de1feaef27d2b") + elseif (_host_processor MATCHES "^(x86_64|amd64)$") + set(_asset "symgen-windows-x86_64.exe") + set(_asset_hash "SHA256=1d1ac087f991a96932d108969e15998becfec643e88f3e7d182ca97ebfc6a46f") + elseif (_host_processor MATCHES "^(i[3-6]86|x86)$") + set(_asset "symgen-windows-x86.exe") + set(_asset_hash "SHA256=c113f4cd05f813efe2b1878dbfcf44d6302aee3974271736e0036430b0cced78") + endif () + endif () + + set(${out_name} "${_asset}" PARENT_SCOPE) + set(${out_hash} "${_asset_hash}" PARENT_SCOPE) +endfunction() + +function(ensure_symgen required) + if (TARGET symgen) + return() + endif () + + if (SYMGEN_PATH) + get_filename_component(_symgen "${SYMGEN_PATH}" ABSOLUTE) + if (NOT EXISTS "${_symgen}") + if (required) + message(FATAL_ERROR "symgen: SYMGEN_PATH does not exist: ${_symgen}") + endif () + message(STATUS "symgen: SYMGEN_PATH does not exist, symbol manifest generation " + "skipped (by-name hook resolution will be unavailable)") + return() + endif () + else () + symgen_host_asset(_asset _asset_hash) + if (_asset STREQUAL "") + if (required) + message(FATAL_ERROR "symgen: no prebuilt binary for host " + "${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR} " + "(configure with -DDUSK_ENABLE_CODE_MODS=OFF)") + endif () + message(STATUS "symgen: no prebuilt binary for host " + "${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR}; " + "symbol manifest generation skipped (by-name hook resolution will be unavailable)") + return() + endif () + + set(_symgen_dir "${CMAKE_BINARY_DIR}/_deps/symgen") + set(_symgen "${_symgen_dir}/${_asset}") + set(_url "${_SYMGEN_RELEASE_BASE_URL}/${_asset}") + message(STATUS "dusklight: Fetching symgen ${_SYMGEN_VERSION} (${_asset})") + file(MAKE_DIRECTORY "${_symgen_dir}") + file(DOWNLOAD "${_url}" "${_symgen}" + TLS_VERIFY ON + STATUS _download_status + 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) + file(REMOVE "${_symgen}") + if (required) + message(FATAL_ERROR "symgen: failed to download ${_url}: ${_download_message}") + endif () + message(STATUS "symgen: failed to download ${_url}: ${_download_message}; " + "symbol manifest generation skipped (by-name hook resolution will be unavailable)") + return() + endif () + if (NOT CMAKE_HOST_WIN32) + file(CHMOD "${_symgen}" PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + endif () + endif () + + add_custom_target(symgen DEPENDS "${_symgen}") + set(SYMGEN_EXE "${_symgen}" CACHE INTERNAL "symgen executable" FORCE) +endfunction() + +function(setup_symbol_manifest target) + ensure_symgen(TRUE) + if (NOT TARGET symgen) + return() + endif () + add_dependencies(${target} symgen) + + # 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} --embed "$" + COMMENT "Embedding symbol manifest" + VERBATIM) +endfunction() diff --git a/cmake/WindowsExports.cmake b/cmake/WindowsExports.cmake new file mode 100644 index 0000000000..4596ac7b69 --- /dev/null +++ b/cmake/WindowsExports.cmake @@ -0,0 +1,93 @@ +include_guard(GLOBAL) + +get_filename_component(_DUSK_WINDOWS_EXPORTS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) + +# Windows mod linking: generate the curated export surface for the game executable and the +# 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) + 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") + 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 () + + 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 + COMMAND "${_symgen}" def + "@${_rsp}" + --out "${_def}" + --exclude cmake_pch + --exclude miniz + --exclude asan_options + --exclude src/dusk + --max-exports 58000 + ${_sdk_args} + ${_forward_args} + COMMENT "Generating dusklight exports" + VERBATIM) + target_link_options(${target} PRIVATE "/DEF:${_def}") + + # Generate import library for mods to link against. + set(_implib "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_imports.lib") + 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 "${_dlltool_machine}" -l "${_implib}") + else () + 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} + BYPRODUCTS "${_implib}" + COMMENT "Generating dusklight import library" + VERBATIM) + set(DUSK_GAME_IMPLIB "${_implib}" CACHE INTERNAL "Import library for Windows mod linking") + + install(FILES "${_implib}" DESTINATION sdk RENAME "windows-${_implib_arch}.lib") +endfunction() diff --git a/docs/building.md b/docs/building.md index 9f7879ab48..31222df414 100644 --- a/docs/building.md +++ b/docs/building.md @@ -180,6 +180,7 @@ cmake --build --preset macos-default-relwithdebinfo Alternate presets available: * `macos-default-debug`: Clang, Debug +* `macos-default-debug-asan`: Clang, Debug, AddressSanitizer **ninja (Linux)** @@ -191,8 +192,10 @@ cmake --build --preset linux-default-relwithdebinfo Alternate presets available: * `linux-default-debug`: GCC, Debug +* `linux-default-debug-asan`: GCC, Debug, AddressSanitizer * `linux-clang-relwithdebinfo`: Clang, RelWithDebInfo * `linux-clang-debug`: Clang, Debug +* `linux-clang-debug-asan`: Clang, Debug, AddressSanitizer **ninja (Windows)** @@ -204,6 +207,7 @@ cmake --build --preset windows-msvc-relwithdebinfo Alternate presets available: * `windows-msvc-debug`: MSVC, Debug +* `windows-msvc-debug-asan`: MSVC, Debug, AddressSanitizer * `windows-clang-relwithdebinfo`: Clang-cl, RelWithDebInfo * `windows-clang-debug`: Clang-cl, Debug diff --git a/docs/modding.md b/docs/modding.md new file mode 100644 index 0000000000..ab100b5add --- /dev/null +++ b/docs/modding.md @@ -0,0 +1,943 @@ +# Dusklight Mod API + +Mods are `.dusk` bundles: zip archives that can contain code (in the form of native libraries), 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. + +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. + +## 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](#advanced) + +--- + +## Getting Started + +Fork the [mod template](https://github.com/TwilitRealm/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.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`. +- `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`). 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. + +--- + +## mod.json + +```json +{ + "id": "com.example.my_mod", + "name": "My Mod", + "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" +} +``` + +`id` is required: a unique, stable identifier (reverse-DNS style; periods, underscores, and 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. + +--- + +## Anatomy of a Code Mod + +```cpp +#include "mods/service.hpp" +#include "mods/svc/log.h" + +DEFINE_MOD(); // once, in exactly one translation unit +IMPORT_SERVICE(LogService, svc_log); // resolved by the loader before mod_initialize + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError* error) { + svc_log->info(mod_ctx, "hello from my_mod"); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError* error) { // called every frame + return MOD_OK; +} + +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. + +--- + +## 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: + +```cpp +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 must 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. + +`IMPORT_SERVICE` and `IMPORT_OPTIONAL_SERVICE` require the latest minor version compiled against, making every field in +the service safe to call. A mod can use `IMPORT_SERVICE_VERSION` (or its optional counterpart) with an older minor +version to remain compatible with older Dusklight versions, then use `SERVICE_HAS` to check at runtime for fields added +after that explicitly requested version. + +The contract (see `sdk/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.** The default macros import + the service type's current minor version; the versioned macros explicitly override that minimum. +- Optional imports may be null; check once in `mod_initialize`. +- Fields newer than your imported minor version must be gated behind `SERVICE_HAS(service, ServiceType, field)` plus a + null check. + +--- + +## Built-in Services + +### LogService (`mods/svc/log.h`) + +```cpp +IMPORT_SERVICE(LogService, svc_log); + +svc_log->info(mod_ctx, "spawned the thing"); +svc_log->warn(mod_ctx, "that looks wrong"); +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. C++ mods can enable `add_mod(... FEATURES fmt)` and use the formatted logging helpers in +`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`) + +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. + +```cpp +IMPORT_SERVICE(ResourceService, svc_resource); + +ResourceBuffer buf = RESOURCE_BUFFER_INIT; +if (svc_resource->load(mod_ctx, "config.txt", &buf) == MOD_OK) { + // buf.data / buf.size + svc_resource->free(mod_ctx, &buf); +} +``` + +Missing files return `MOD_UNAVAILABLE`. Always `free` what you `load`. The bundle is read-only; use +`HostService::data_dir` for persistent storage. + +### HostService (`mods/svc/host.h`) + +Mod metadata and runtime interaction with the loader: + +```cpp +IMPORT_SERVICE(HostService, svc_host); + +// 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 [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(HostService, svc_host); + +void on_mod_lifecycle(ModContext* ctx, ModContext* subject, const char* subject_id, + ModLifecycleEvent event, void* user_data) { + if (event == MOD_LIFECYCLE_DETACHED) { + drop_state_for(subject); // same ModContext* the subject passed into your service + } +} + +uint64_t watch = 0; +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`) + +Installs hooks on game functions and resolves symbols by name. You'll rarely call it directly; use the typed helpers in +`mods/svc/hook.hpp` described in [Hooking Game Functions](#hooking-game-functions). + +### OverlayService (`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): + +```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_buffer(mod_ctx, "/generated.txt", data, size, nullptr); +svc_overlay->remove(mod_ctx, handle); +``` + +`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. + +See [Asset Overlays](#asset-overlays) for priority and conflict handling. + +### TextureService (`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: + +```cpp +IMPORT_SERVICE(TextureService, svc_texture); + +// Encoded file; filename follows the replacement naming convention. +TextureReplacementHandle handle = 0; +svc_texture->register_file(mod_ctx, "res/tex1_32x32_$_6.png", &handle); + +// Raw data: match by texel-data pointer or by content hash (TEXTURE_KEY_SOURCE). +TextureKey key = TEXTURE_KEY_INIT; +key.kind = TEXTURE_KEY_POINTER; +key.pointer = someTexObj.data; +TextureData data = TEXTURE_DATA_INIT; +data.data = pixels; data.size = pixelsSize; +data.width = 32; data.height = 32; data.gx_format = GX_TF_RGBA8_PC; +svc_texture->register_data(mod_ctx, &key, &data, nullptr); + +svc_texture->unregister(mod_ctx, handle); +``` + +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 +at registration. Registrations follow your mod's lifecycle. + +See [Asset Overlays](#asset-overlays) for priority and conflict handling. + +### ConfigService (`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: + +```cpp +IMPORT_SERVICE(ConfigService, svc_config); + +ConfigVarDesc desc = CONFIG_VAR_DESC_INIT; +desc.name = "speedMultiplier"; // 1-64 chars from [A-Za-z0-9_-]; "enabled" is reserved +desc.type = CONFIG_VAR_FLOAT; +desc.default_float = 1.0; +ConfigVarHandle var = 0; +svc_config->register_var(mod_ctx, &desc, &var); + +double speed = 1.0; +svc_config->get_float(mod_ctx, var, &speed); +svc_config->set_float(mod_ctx, var, 2.0); + +// Optional: get notified when the value changes. +void on_speed_changed(ModContext* ctx, ConfigVarHandle var, const ConfigVarValue* value, + const ConfigVarValue* previous, void* user_data) { + /* value->float_value is the new value, previous->float_value the old one */ +} +svc_config->subscribe(mod_ctx, var, on_speed_changed, nullptr, nullptr); +``` + +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. + +Change callbacks fire on the game thread whenever the value changes at runtime (your own `set_*` calls included). +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. + +### SaveService (`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`) + +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`) + +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. + +**Mod panel:** Registers or replaces the panel rendered in your mod's detail pane; `build` runs every time the detail +content is rebuilt, and `update` runs every frame while that mod is selected. While your mod is selected, the detail +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"]`). + +```cpp +IMPORT_SERVICE(UiService, svc_ui); + +UiElementHandle statusText = 0; + +ModResult build(ModContext*, UiElementHandle panel, void*, ModError*) { + svc_ui->pane_add_section(mod_ctx, panel, "Status"); + svc_ui->pane_add_text(mod_ctx, panel, "starting...", &statusText); + svc_ui->pane_add_progress(mod_ctx, panel, 0.5f, nullptr); + return MOD_OK; +} + +ModResult update(ModContext*, void*, ModError*) { + svc_ui->elem_set_text(mod_ctx, statusText, "running"); + return MOD_OK; +} + +UiModsPanelDesc panel = UI_MODS_PANEL_DESC_INIT; +panel.build = build; +panel.update = update; +svc_ui->register_mods_panel(mod_ctx, &panel); +``` + +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. + +```cpp +UiControlDesc control = UI_CONTROL_DESC_INIT; +control.kind = UI_CONTROL_TOGGLE; +control.label = "Enable rainbows"; +control.help_rml = "Shown in the help pane while focused."; +control.binding = UI_BINDING_CONFIG_VAR; +control.config_var = myBoolVar; // from svc_config->register_var +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. + +**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` +runs each frame while that tab is active. `on_closed` fires when the window is destroyed. `desc.rcss` optionally styles +that window's document only; custom windows carry the owning mod's id as a `mod-id` attribute on the window root, so +scoped RCSS can target your specific mod's windows (e.g. `window[mod-id="com.example.mod"]`). + +```cpp +UiTabDesc tabs[1] = {UI_TAB_DESC_INIT}; +tabs[0].title = "Options"; +tabs[0].build = build_options_tab; + +UiWindowDesc desc = UI_WINDOW_DESC_INIT; +desc.tabs = tabs; +desc.tab_count = 1; +desc.on_closed = options_window_closed; +UiWindowHandle window = 0; +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. + +**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 +mod is disabled. + +**Custom styles:** `register_styles(scope, rcss, &handle)` applies an RCSS stylesheet to every document of a scope: +existing documents restyle immediately, and future ones pick it up when created. `register_styles_file(scope, path, +&handle)` reads the sheet from your bundle's `res/` directory. Scopes are `UI_SCOPE_PRELAUNCH`, `UI_SCOPE_WINDOW`, +`UI_SCOPE_MENU_BAR`, `UI_SCOPE_OVERLAY`, `UI_SCOPE_TOUCH_CONTROLS`, and `UI_SCOPE_GRAPHICS_TUNER`. Sheets apply after +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`) + +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`) + +**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`) 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`) + +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`. + +--- + +## 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/svc/hook.hpp` provides typed helpers over the hook service: + +```cpp +#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 = mods::arg(args, 0); // arg 0 is `this` + if (link->shape_angle.y > 10000) { + return HOOK_SKIP_ORIGINAL; + } + return HOOK_CONTINUE; +} + +mods::hook::add_pre(on_pos_move_pre); +``` + +### Post-hooks + +Run after the original (or after a replace-hook, or after a cancelled original). `retval` points to the return value, +if any. + +```cpp +void on_pos_move_post(ModContext*, void* args, void* retval, void* userdata) { ... } + +mods::hook::add_post(on_pos_move_post); +``` + +### Replace-hooks + +Substitute the original entirely. Call through to it via the declaration's `g_orig` if needed: + +```cpp +void on_execute_replace(ModContext*, void* args, void* retval, void*) { + int result = LinkExecute::g_orig(mods::arg(args, 0)); + if (retval != nullptr) { + *static_cast(retval) = result; + } +} + +mods::hook::replace(on_execute_replace); +``` + +By default a second replace-hook on the same function is a conflict; `HookOptions` (`replace_policy`, `priority`, +`userdata`) controls this and callback ordering. Multiple mods can attach pre/post hooks to the same function +independently. + +### Hooking by name + +Functions you can't name in C++ (file-local statics, private class members, anything not in a header) can be hooked by +symbol name instead. You must supply the signature along with the name. + +```cpp +DEFINE_HOOK_SYMBOL("daAlink_hookshotAtHitCallBack", + void(fopAc_ac_c*, dCcD_GObjInf*, fopAc_ac_c*, dCcD_GObjInf*), HookshotHit); + +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. + +Two spellings work on every platform: + +- **Display names** (`daAlink_c::posMove`, `fapGm_Before`): the qualified name with no parameter list. They carry no + signature, so overload sets (and file-local statics sharing a name) return `MOD_CONFLICT`. +- **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. + +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. + +### 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 = mods::arg(args, n); // copy +T& ref = mods::arg_ref(args, n); // read/write reference +``` + +```cpp +DEFINE_HOOK(fopAcM_createItem, CreateItem); + +// 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. + +--- + +## Asset Overlays + +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. + +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 +(`tex1_{w}x{h}_{texhash}[_{tluthash}]_{fmt}.dds|.png`, `$` as a hash wildcard). Subdirectories are scanned recursively; +only the filename needs to match. + +Both mechanisms are tied to the mod's lifecycle: disabling the mod removes its overrides (files revert to the disc +contents on their next open; added files stop existing), and reloading serves the new bundle's content. However, game +data the engine already read stays as-is until it is loaded again, which may require a scene change or, in the worst +case, a full restart. Texture replacements usually take effect immediately. + +If multiple sources replace the same file or texture, the last one wins: runtime registrations override static +`textures/` or `overlay/` files, and later-loaded mods override earlier ones. Cross-mod conflicts log warnings. +**All** mod-provided texture replacements override the user's `texture_replacements/`. + +To configure overlays and texture replacements at runtime instead, see [OverlayService](#overlayservice-modssvcoverlayh) +and [TextureService](#textureservice-modssvctextureh). + +--- + +## Runtime Lifecycle + +Mods can be disabled, re-enabled, and reloaded at runtime without restarting the game (the enabled state persists as the +`mod..enabled` config var). Write your mod assuming this happens: + +- **Disable** calls `mod_shutdown`, removes your hooks, services, overlays, and texture replacements (both static and + runtime-registered), and unloads your library. +- **Enable** and **Reload** load a *fresh copy* of your library, imports are re-resolved, and `mod_initialize` runs + again. You never see a second `mod_initialize` on the same image, so just make `mod_shutdown` release anything the + loader doesn't manage for you (threads, files, game-side state you mutated). +- **Reload** additionally re-reads the `.dusk` from disk, picking up a rebuilt library and changed assets. This is the + fast iteration loop during development: rebuild, click Reload. + +**Dependents restart too.** Disabling or reloading a mod that exports services shuts down the mods importing them +first (in reverse dependency order) and brings them back afterward. A mod whose *required* provider is disabled stays +suspended and resumes automatically when the provider returns. Mods with an *optional* import of a disabled provider +restart with that import null. + +**One caution for hooks:** lifecycle changes are applied between frames, which is safe for hooks on functions +that return every frame (effectively everything you'd normally hook). Avoid hooking a function that stays on +the stack for the whole session (e.g. the outermost main loop); a mod that does cannot be safely unloaded. + +--- + +## Error Handling + +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 +`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 mods::set_error(error, MOD_ERROR, "failed to load data"); + } + return MOD_OK; +} +``` + +Throwing exceptions out of lifecycle functions also disables the mod (they are caught by the loader), but prefer +explicit results. + +--- + +## 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: + +```cpp +// my_mod_api.h +#include "mods/api.h" + +#define MY_MOD_SERVICE_ID "com.example.my_mod.api" +#define MY_MOD_SERVICE_MAJOR 1u +#define MY_MOD_SERVICE_MINOR 0u + +typedef struct MyModService { + ServiceHeader header; + ModResult (*do_thing)(ModContext* ctx, int value); +} MyModService; + +#ifdef __cplusplus +#include "mods/service.hpp" +template <> +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 +``` + +**Provider:** + +```cpp +ModResult do_thing(ModContext* ctx, int value) { ... } + +constexpr MyModService g_service{ + .header = SERVICE_HEADER(MyModService, MY_MOD_SERVICE_MAJOR, MY_MOD_SERVICE_MINOR), + .do_thing = do_thing, +}; +EXPORT_SERVICE(g_service); +``` + +**Consumer:** + +```cpp +IMPORT_SERVICE(MyModService, svc_my_mod); +// or IMPORT_OPTIONAL_SERVICE if the dependency is optional + +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 + +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 +`mod_initialize`. This includes deferred services: a service the provider publishes during its initialization resolves +into your import slot just like a static export. + +Consequences of that contract: + +- If a provider fails to load, every mod that *requires* one of its services is disabled too, with an error naming the + provider. Optional imports of a failed provider simply resolve to `NULL`. +- Mods whose **required** imports form a cycle all fail to load. If the cycle runs through an **optional** import, the + loader breaks it there: the optional import still resolves, but its provider may not be initialized yet when you run. +- `svc_host->get_service(...)` is outside this system. It sees whatever is published at call time and gives no + initialization-order guarantee, which also makes it the escape hatch for intentionally cyclic designs. + +Mods shut down in reverse initialization order, so services you import remain safe to call from `mod_shutdown`. + +Rules for providers: + +- Service IDs are global and use reverse-DNS names (e.g. `com.mydomain.mod.service`) +- Every function pointer covered by your declared minor version must be populated. +- Within a major version, only append fields; never reorder, remove, or repurpose them. Breaking changes require a major + bump (which is, in effect, a new service). +- Only one provider per `(id, major)` pair may be registered; duplicates are load errors. + +For services whose construction can't happen at static-init time, declare the export with `EXPORT_DEFERRED_SERVICE(...)` +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 19479a53e4..8005d336ab 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 19479a53e4e82c58fb1b4fe07498383b89688713 +Subproject commit 8005d336ab02f0c617fc27fabbea4af42ab04caa diff --git a/extern/borealis b/extern/borealis new file mode 160000 index 0000000000..6fd955e7e6 --- /dev/null +++ b/extern/borealis @@ -0,0 +1 @@ +Subproject commit 6fd955e7e6a2d2d47c5a4eaf363fb49847e490ba diff --git a/files.cmake b/files.cmake index 4429a5cb2e..1196f6c503 100644 --- a/files.cmake +++ b/files.cmake @@ -1411,65 +1411,107 @@ set(DOLPHIN_FILES ) 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/endian_gx.hpp src/d/actor/d_a_alink_dusk.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/asserts.cpp + 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/game_combos.cpp + src/dusk/gamepad_color.cpp src/dusk/globals.cpp src/dusk/gyro.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/game_combos.cpp src/dusk/d_trigger_view.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/update_check.cpp - src/dusk/update_check.hpp #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/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/io.cpp + src/dusk/iso_validate.cpp + 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/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/log_buffer.cpp + src/dusk/mods/log_buffer.hpp + src/dusk/mods/manifest.cpp + src/dusk/mods/manifest.hpp + src/dusk/mods/svc/camera.cpp + src/dusk/mods/svc/config.cpp + src/dusk/mods/svc/config.hpp + src/dusk/mods/svc/game.cpp + src/dusk/mods/svc/gfx.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/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/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 @@ -1482,6 +1524,7 @@ set(DUSK_FILES src/dusk/ui/component.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/editor.cpp @@ -1490,10 +1533,22 @@ set(DUSK_FILES src/dusk/ui/event.hpp src/dusk/ui/graphics_tuner.cpp src/dusk/ui/graphics_tuner.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/menu_bar.cpp + src/dusk/ui/menu_bar.hpp + src/dusk/ui/mod_texture_provider.cpp + src/dusk/ui/mod_texture_provider.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/number_button.cpp src/dusk/ui/number_button.hpp @@ -1501,8 +1556,6 @@ set(DUSK_FILES 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/prelaunch.cpp src/dusk/ui/prelaunch.hpp src/dusk/ui/preset.cpp @@ -1517,30 +1570,22 @@ 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.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 src/dusk/ui/ui.hpp src/dusk/ui/warp.cpp 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/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 99fcd49f94..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 }: @@ -16,37 +17,37 @@ ]; forAllSystems = lib.genAttrs supportedSystems; - dawnVersion = "v20260423.175430"; - nodVersion = "v2.0.0-alpha.8"; + dawnVersion = "v20260618.032059"; + nodVersion = "v2.0.0-alpha.10"; versionSuffix = "nix-" + (self.shortRev or self.dirtyShortRev or "dirty"); dawnInfo = { "x86_64-linux" = { triple = "linux-x86_64"; - hash = "sha256-HXfKTLHtMPwupnFnaflCARtXVPuS/0PoCePXidjE5xs="; + hash = "sha256-GFSd573b+VQx/VmFdNQgWDd0V9ayQlcw0Zuopke12ak="; }; "aarch64-linux" = { triple = "linux-aarch64"; - hash = "sha256-34yyFpfqBZUwoFXQ41F0AwAU78FaNihOSY0oriwn6B0="; + hash = "sha256-ZaoP7BAjBMnfAv2/AMRi3FNH2ZtyqASCSFyU/oB2Mzg="; }; "aarch64-darwin" = { triple = "darwin-arm64"; - hash = "sha256-eQnzrBp6gjiBek1VYQ9A5W13ClYWrDDKjIqv/7eNTR4="; + hash = "sha256-HT+qtlLaSHyoXPrUcXgcTGa877X5YfzbxRD4bJb7i1Y="; }; "x86_64-darwin" = { triple = "darwin-x86_64"; - hash = "sha256-QGWiGdxiI9kci3NPXH6QFFirxn16851zB/w3jqhIBJ4="; + hash = "sha256-cUNaCbA7rlKSukDVKGaVEVw0Zt1+mSbaHbmUCMvMVWc="; }; }; nodPrebuiltInfo = { "x86_64-linux" = { triple = "linux-x86_64"; - hash = "sha256-mUqvLsbsqaZ+HAjMmHYPYO+MgtanGRTw7Gzn5uXR5rE="; + hash = "sha256-FVQWECVA2gWdc+n5OQ/Tvwn8z0qdgjSd1WlFt5HKOec="; }; "aarch64-darwin" = { triple = "macos-arm64"; - hash = "sha256-UPy1ywCcv0K6VJOU3uUelJuUdBh3UNaPRlyP5LOBeDw="; + hash = "sha256-8ZEejxksVgShNKUVRCBYaLOp9x/qOC9pAeVrElQUGUk="; }; }; @@ -58,24 +59,9 @@ 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-build/releases/download/${dawnVersion}/dawn-${dawnInfo.${system}.triple}.tar.gz"; + url = "https://github.com/encounter/dawn/releases/download/${dawnVersion}/dawn-${dawnInfo.${system}.triple}.tar.gz"; hash = dawnInfo.${system}.hash; stripRoot = false; }; @@ -94,7 +80,7 @@ owner = "encounter"; repo = "nod"; rev = nodVersion; - hash = "sha256-+zrtVzjo0+X/6uMcNUn1+FaSR+jOhrcQSDNBFjw0NDs="; + hash = "sha256-r8qDlOVxv5iKiFjJQrcBuL9HVoOM3yEjRVnQIMqaICs="; }; patches = [ ./fix-cmake-paths.patch ]; cargoDeps = pkgs.rustPlatform.importCargoLock { @@ -138,15 +124,23 @@ NOD_PREBUILT = nod; CXXOPTS = pkgs.cxxopts.src; JSON = pkgs.nlohmann_json.src; - XXHASH = pkgs.xxHash.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/11.1.4.tar.gz"; - hash = "sha256-sUbxlYi/Aupaox3JjWFqXIjcaQa0LFjclQAOleT+FRA="; + url = "https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz"; + hash = "sha256-ZmI1Dv0ZabPlxa02OpERI47jp7zFfjpeWCy1WyuPYZ0="; }; TRACY = pkgs.fetchzip { - url = "https://github.com/wolfpld/tracy/archive/a64b9a20294d59421a2f57aeca3c6383d8c48169.tar.gz"; - hash = "sha256-hbNGOsGeyGSvCJ2No8RkwOib1lX2on3vNZSzyVkZdXw="; + url = "https://github.com/wolfpld/tracy/archive/6789e7d6f9a65ec98926b602097a33a9676d2606.tar.gz"; + hash = "sha256-Xxyd7G/mnXEPpN+ehmwl0AkAhS3CwObpJNDgcqbdUJg="; }; IMGUI = pkgs.fetchFromGitHub { owner = "ocornut"; @@ -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 @@ -194,7 +185,7 @@ pkgs.zstd pkgs.cxxopts pkgs.nlohmann_json - pkgs.xxHash + pkgs.xxhash pkgs.abseil-cpp pkgs.zlib pkgs.libpng @@ -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" @@ -269,6 +260,12 @@ runHook postInstall ''; + postFixup = lib.optionalString (!isDarwin) '' + patchelf \ + --add-needed "${pkgs.vulkan-loader}/lib/libvulkan.so" \ + $out/bin/dusklight + ''; + dontStrip = true; meta = { 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..6908ef80ed 100644 --- a/include/SSystem/SComponent/c_bg_s_chk.h +++ b/include/SSystem/SComponent/c_bg_s_chk.h @@ -5,7 +5,7 @@ #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" +#include "helpers/endian.h" struct cBgD_Vtx_t : public Vec {}; diff --git a/include/SSystem/SComponent/c_bg_s_shdw_draw.h b/include/SSystem/SComponent/c_bg_s_shdw_draw.h index 9ec3023306..55792f8410 100644 --- a/include/SSystem/SComponent/c_bg_s_shdw_draw.h +++ b/include/SSystem/SComponent/c_bg_s_shdw_draw.h @@ -20,7 +20,7 @@ public: /* 0x14 */ cM3dGAab mM3dGAab; /* 0x30 */ cBgS_ShdwDraw_Callback mCallbackFun; - #if DEBUG + #if PARTIAL_DEBUG || DEBUG /* 0x34 */ int field_0x34; #endif }; 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..9947616d54 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -2,7 +2,7 @@ #define C_M3D_G_TRI_H_ #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/endian.h" +#include "helpers/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/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 e543bf6061..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; @@ -48,6 +48,8 @@ public: /* 0x1370 */ Z2FxLineMgr mFxLineMgr; #if DEBUG /* 0x13BC */ Z2DebugSys mDebugSys; + #elif PARTIAL_DEBUG + alignas(Z2DebugSys) u8 mDebugSys[sizeof(Z2DebugSys)]; #endif }; // Size: 0x138C 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/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..705394df5e 100644 --- a/include/Z2AudioLib/Z2LinkMgr.h +++ b/include/Z2AudioLib/Z2LinkMgr.h @@ -57,7 +57,7 @@ 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; 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/Z2SeqMgr.h b/include/Z2AudioLib/Z2SeqMgr.h index 76c2674697..94191a1318 100644 --- a/include/Z2AudioLib/Z2SeqMgr.h +++ b/include/Z2AudioLib/Z2SeqMgr.h @@ -194,7 +194,7 @@ public: JAISoundHandle* getMainBgmHandle() { return &mMainBgmHandle; } JAISoundHandle* getSubBgmHandle() { return &mSubBgmHandle; } - #if DEBUG + #if PARTIAL_DEBUG || DEBUG f32 field_0x00_debug; u8 field_0x04_debug; #endif diff --git a/include/Z2AudioLib/Z2SoundObjMgr.h b/include/Z2AudioLib/Z2SoundObjMgr.h index c0b4ed778c..687f9eaf0a 100644 --- a/include/Z2AudioLib/Z2SoundObjMgr.h +++ b/include/Z2AudioLib/Z2SoundObjMgr.h @@ -100,13 +100,13 @@ public: bool isForceBattle() { return forceBattle_; } JSUList* getEnemyList() { return &field_0x0; } - #if DEBUG + #if PARTIAL_DEBUG || DEBUG JSUList* getAllList() { return &allList_; } #endif private: /* 0x00 */ JSUList field_0x0; - #if DEBUG + #if PARTIAL_DEBUG || DEBUG /* 0x0C */ JSUList allList_; #endif /* 0x0C */ Z2EnemyArea enemyArea_; diff --git a/include/Z2AudioLib/Z2SoundObject.h b/include/Z2AudioLib/Z2SoundObject.h index ca4b69a520..2d85db34c0 100644 --- a/include/Z2AudioLib/Z2SoundObject.h +++ b/include/Z2AudioLib/Z2SoundObject.h @@ -7,7 +7,7 @@ struct Z2SoundStarter; class Z2SoundObjBase : public Z2SoundHandles -#if DEBUG +#if PARTIAL_DEBUG || DEBUG , public JSULink #endif { 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 fa75c085fb..8728bc16a8 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; @@ -3913,20 +3913,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; @@ -4556,6 +4556,7 @@ public: void handleWolfHowl(); void handleQuickTransform(); bool checkAimContext(); + bool checkAimInputContext(); void onIronBallChainInterpCallback(); @@ -4648,7 +4649,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 { @@ -4699,7 +4700,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 { @@ -4745,7 +4746,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 { @@ -4791,7 +4792,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 { @@ -4833,7 +4834,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 { @@ -4863,7 +4864,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 { @@ -4897,7 +4898,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 { @@ -4935,7 +4936,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 { @@ -4963,27 +4964,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 { @@ -5014,32 +5015,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 { @@ -5076,7 +5077,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 { @@ -5103,17 +5104,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 { @@ -5145,7 +5146,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 { @@ -5196,7 +5197,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 { @@ -5224,22 +5225,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 { @@ -5272,7 +5273,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 { @@ -5306,7 +5307,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 { @@ -5342,7 +5343,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 { @@ -5379,7 +5380,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 { @@ -5456,7 +5457,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 { @@ -5512,12 +5513,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 { @@ -5549,7 +5550,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 { @@ -5594,7 +5595,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 { @@ -5633,7 +5634,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 { @@ -5688,7 +5689,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 { @@ -5718,7 +5719,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 { @@ -5747,7 +5748,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 { @@ -5773,7 +5774,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 { @@ -5802,7 +5803,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 { @@ -5838,7 +5839,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 { @@ -5885,7 +5886,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 { @@ -5919,7 +5920,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 { @@ -5958,12 +5959,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 { @@ -5991,7 +5992,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 { @@ -6026,7 +6027,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 { @@ -6056,7 +6057,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 { @@ -6092,7 +6093,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 { @@ -6139,7 +6140,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; @@ -6191,7 +6192,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 { @@ -6230,7 +6231,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 { @@ -6275,7 +6276,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 { @@ -6311,7 +6312,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 { @@ -6355,7 +6356,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 { @@ -6390,7 +6391,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 { @@ -6409,7 +6410,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 @@ -6428,7 +6429,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 { @@ -6464,7 +6465,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 { @@ -6503,7 +6504,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 { @@ -6529,7 +6530,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 { @@ -6569,7 +6570,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 { @@ -6607,7 +6608,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 { @@ -6663,7 +6664,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 { @@ -6693,7 +6694,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 { @@ -6721,7 +6722,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 { @@ -6768,7 +6769,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 { @@ -6801,7 +6802,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 { @@ -6849,7 +6850,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 { @@ -6908,7 +6909,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 { @@ -6948,7 +6949,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 { @@ -6986,7 +6987,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 { @@ -7061,7 +7062,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 { @@ -7137,7 +7138,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 { @@ -7180,7 +7181,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 { @@ -7219,7 +7220,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 { @@ -7251,7 +7252,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 { @@ -7285,7 +7286,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 { @@ -7315,7 +7316,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 { @@ -7360,7 +7361,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 { @@ -7389,7 +7390,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 { @@ -7425,7 +7426,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 { @@ -7464,7 +7465,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 { @@ -7496,7 +7497,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 { @@ -7531,12 +7532,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 { @@ -7565,7 +7566,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 { @@ -7598,7 +7599,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 { @@ -7625,7 +7626,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; @@ -7675,7 +7676,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 { @@ -7710,7 +7711,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 { @@ -7746,17 +7747,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 { @@ -7783,7 +7784,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 { @@ -7818,7 +7819,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 { @@ -7859,7 +7860,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 { @@ -7887,7 +7888,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 { @@ -7923,7 +7924,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 { @@ -7960,7 +7961,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 { @@ -8000,7 +8001,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 { @@ -8045,7 +8046,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 { @@ -8092,7 +8093,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 { @@ -8128,7 +8129,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 { @@ -8185,7 +8186,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 { @@ -8214,7 +8215,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 { @@ -8244,7 +8245,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 { @@ -8299,7 +8300,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 { diff --git a/include/d/actor/d_a_arrow.h b/include/d/actor/d_a_arrow.h index 682ffd43d7..47f86eeb50 100644 --- a/include/d/actor/d_a_arrow.h +++ b/include/d/actor/d_a_arrow.h @@ -161,7 +161,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_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_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..fe39f226b7 100644 --- a/include/d/actor/d_a_boomerang.h +++ b/include/d/actor/d_a_boomerang.h @@ -190,12 +190,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_coach_fire.h b/include/d/actor/d_a_coach_fire.h index c5f890dc3d..f669525e9c 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(); diff --git a/include/d/actor/d_a_cstaF.h b/include/d/actor/d_a_cstaF.h index 0e8b5c1ca7..9cb9e06ff7 100644 --- a/include/d/actor/d_a_cstaF.h +++ b/include/d/actor/d_a_cstaF.h @@ -38,7 +38,7 @@ 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; diff --git a/include/d/actor/d_a_cstatue.h b/include/d/actor/d_a_cstatue.h index e20e683398..ca0b3ca616 100644 --- a/include/d/actor/d_a_cstatue.h +++ b/include/d/actor/d_a_cstatue.h @@ -99,7 +99,7 @@ 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; 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_dt.h b/include/d/actor/d_a_e_dt.h index 1296a78e5b..c5c83c76e0 100644 --- a/include/d/actor/d_a_e_dt.h +++ b/include/d/actor/d_a_e_dt.h @@ -175,14 +175,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_ge.h b/include/d/actor/d_a_e_ge.h index c202e75231..527e5bb5fa 100644 --- a/include/d/actor/d_a_e_ge.h +++ b/include/d/actor/d_a_e_ge.h @@ -101,7 +101,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_oc.h b/include/d/actor/d_a_e_oc.h index ada1b5310b..7f60afa878 100644 --- a/include/d/actor/d_a_e_oc.h +++ b/include/d/actor/d_a_e_oc.h @@ -159,14 +159,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_ym.h b/include/d/actor/d_a_e_ym.h index 3217592e13..9638736b46 100644 --- a/include/d/actor/d_a_e_ym.h +++ b/include/d/actor/d_a_e_ym.h @@ -215,7 +215,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_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..bb7ce7ccb1 100644 --- a/include/d/actor/d_a_horse.h +++ b/include/d/actor/d_a_horse.h @@ -351,8 +351,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 +567,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..da1f541cd7 100644 --- a/include/d/actor/d_a_itembase.h +++ b/include/d/actor/d_a_itembase.h @@ -60,7 +60,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; diff --git a/include/d/actor/d_a_mant.h b/include/d/actor/d_a_mant.h index 7514bc6fca..6d5b173d1a 100644 --- a/include/d/actor/d_a_mant.h +++ b/include/d/actor/d_a_mant.h @@ -88,9 +88,14 @@ public: /* 0x396A */ u8 field_0x396A[0x399E - 0x396A]; /* 0x399E */ s16 field_0x399e; /* 0x39A0 */ u8 field_0x39A0[0x39A4 - 0x39A0]; - +#if TARGET_PC + /* 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_midna.h b/include/d/actor/d_a_midna.h index c9e84ee9d4..7793179066 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,8 +420,8 @@ 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; 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..fbd8784d40 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -95,12 +95,6 @@ static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); #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,7 +164,7 @@ 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); 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..7b99f1e2fe 100644 --- a/include/d/actor/d_a_npc.h +++ b/include/d/actor/d_a_npc.h @@ -776,12 +776,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..0f8ab6ba20 100644 --- a/include/d/actor/d_a_npc2.h +++ b/include/d/actor/d_a_npc2.h @@ -113,9 +113,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 +173,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..d195eb9669 100644 --- a/include/d/actor/d_a_npc4.h +++ b/include/d/actor/d_a_npc4.h @@ -394,13 +394,13 @@ 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); diff --git a/include/d/actor/d_a_npc_aru.h b/include/d/actor/d_a_npc_aru.h index a0a30a676f..e822850a7e 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,8 +171,8 @@ 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; diff --git a/include/d/actor/d_a_npc_ash.h b/include/d/actor/d_a_npc_ash.h index 084569a66e..46c850a372 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,7 +143,7 @@ public: inline bool step(s16, bool); inline void playExpression(); - static EventFn mEvtSeqList[6]; + static DUSK_GAME_DATA EventFn mEvtSeqList[6]; private: /* 0xB48 */ Z2Creature mCreatureSound; diff --git a/include/d/actor/d_a_npc_ashB.h b/include/d/actor/d_a_npc_ashB.h index 12037188c6..e257db2402 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,7 +135,7 @@ 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; 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..646c4860bd 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,8 +140,8 @@ 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; 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..d2c1c0ef2f 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; diff --git a/include/d/actor/d_a_npc_bouS.h b/include/d/actor/d_a_npc_bouS.h index 27eafb48fd..a3431cfec7 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,7 +128,7 @@ public: mForcibleTalk = 1; } - static eventFunc mEvtSeqList[4]; + static DUSK_GAME_DATA eventFunc mEvtSeqList[4]; private: /* 0xB48 */ Z2Creature mSound; 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..5bdbee8869 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,7 +102,7 @@ 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; 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..12ef5a3b97 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,8 +124,8 @@ 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; diff --git a/include/d/actor/d_a_npc_clerkb.h b/include/d/actor/d_a_npc_clerkb.h index 79e13f3a0e..c6c2ef83fb 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,8 +137,8 @@ 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; diff --git a/include/d/actor/d_a_npc_clerkt.h b/include/d/actor/d_a_npc_clerkt.h index e21f000c32..6acfb8970f 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,8 +125,8 @@ 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; diff --git a/include/d/actor/d_a_npc_coach.h b/include/d/actor/d_a_npc_coach.h index 3917d6f11c..f50cbd87a5 100644 --- a/include/d/actor/d_a_npc_coach.h +++ b/include/d/actor/d_a_npc_coach.h @@ -295,7 +295,7 @@ 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; diff --git a/include/d/actor/d_a_npc_doc.h b/include/d/actor/d_a_npc_doc.h index 7d9c6dabfe..417251e10b 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,8 +133,8 @@ 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; diff --git a/include/d/actor/d_a_npc_doorboy.h b/include/d/actor/d_a_npc_doorboy.h index 7d6cb47436..31568dd2f6 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,7 +78,7 @@ 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; 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..efa9d760c1 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,8 +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]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[18]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[18]; private: /* 0x0E40 */ NPC_FAIRY_HIO_CLASS* mHIO; /* 0x0E44 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_fairy_seirei.h b/include/d/actor/d_a_npc_fairy_seirei.h index 62b3cbcc6c..a0ad9342ed 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,8 +90,8 @@ 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; diff --git a/include/d/actor/d_a_npc_gnd.h b/include/d/actor/d_a_npc_gnd.h index d76fae5d61..f61d7e0214 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,8 +96,8 @@ 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; diff --git a/include/d/actor/d_a_npc_gra.h b/include/d/actor/d_a_npc_gra.h index 117aa9ade0..333cf5d299 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,9 +138,9 @@ 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*); diff --git a/include/d/actor/d_a_npc_grc.h b/include/d/actor/d_a_npc_grc.h index 072a4f9fd2..ac7dfa9869 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,8 +89,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grd.h b/include/d/actor/d_a_npc_grd.h index e8a9e19baf..24871ab24c 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,8 +81,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grm.h b/include/d/actor/d_a_npc_grm.h index addd5485be..d7c30ba90f 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,8 +131,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grmc.h b/include/d/actor/d_a_npc_grmc.h index 4d1752c266..1761c82869 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,8 +124,8 @@ 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; diff --git a/include/d/actor/d_a_npc_gro.h b/include/d/actor/d_a_npc_gro.h index 0881270516..b2a5595bd9 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,8 +85,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grr.h b/include/d/actor/d_a_npc_grr.h index 280df27a48..6dfa8512bc 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,8 +83,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grs.h b/include/d/actor/d_a_npc_grs.h index d08b4ec008..5ec4354dd1 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,8 +84,8 @@ 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; diff --git a/include/d/actor/d_a_npc_grz.h b/include/d/actor/d_a_npc_grz.h index 555b1f09e2..f49c878ff7 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,8 +116,8 @@ 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; diff --git a/include/d/actor/d_a_npc_guard.h b/include/d/actor/d_a_npc_guard.h index bae98e223c..bceab108e5 100644 --- a/include/d/actor/d_a_npc_guard.h +++ b/include/d/actor/d_a_npc_guard.h @@ -60,7 +60,7 @@ 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; diff --git a/include/d/actor/d_a_npc_gwolf.h b/include/d/actor/d_a_npc_gwolf.h index e9c37a38bb..bd577e18e7 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,8 +104,8 @@ 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; diff --git a/include/d/actor/d_a_npc_hanjo.h b/include/d/actor/d_a_npc_hanjo.h index 6e912cb638..e9daf3bb0e 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,10 +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; + 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; private: /* 0x0E40 */ NPC_HANJO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mModel1; diff --git a/include/d/actor/d_a_npc_hoz.h b/include/d/actor/d_a_npc_hoz.h index 72ec648696..aec84cf761 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,8 +125,8 @@ 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; diff --git a/include/d/actor/d_a_npc_impal.h b/include/d/actor/d_a_npc_impal.h index 7b8234717a..f0102ab698 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,7 +121,7 @@ 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; diff --git a/include/d/actor/d_a_npc_ins.h b/include/d/actor/d_a_npc_ins.h index 3f8b40a9a0..620358a297 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,7 +119,7 @@ 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; diff --git a/include/d/actor/d_a_npc_jagar.h b/include/d/actor/d_a_npc_jagar.h index 3c4a4ac723..13147762dd 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,8 +223,8 @@ public: return 0; } - 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_JAGAR_HIO_CLASS* mpHIO; /* 0x0E44 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_kakashi.h b/include/d/actor/d_a_npc_kakashi.h index 7a5cca61f3..c3f57b383a 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,8 +113,8 @@ 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; diff --git a/include/d/actor/d_a_npc_kasi_hana.h b/include/d/actor/d_a_npc_kasi_hana.h index e355ed8c55..625cb31845 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,10 +201,10 @@ 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; diff --git a/include/d/actor/d_a_npc_kasi_kyu.h b/include/d/actor/d_a_npc_kasi_kyu.h index 8353648675..962a2e04cc 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,10 +120,10 @@ 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; diff --git a/include/d/actor/d_a_npc_kasi_mich.h b/include/d/actor/d_a_npc_kasi_mich.h index 460c5c191a..efa1a221c6 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,10 +121,10 @@ 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; diff --git a/include/d/actor/d_a_npc_kkri.h b/include/d/actor/d_a_npc_kkri.h index a5e74880a9..c6e173480d 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,8 +118,8 @@ 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; diff --git a/include/d/actor/d_a_npc_kn.h b/include/d/actor/d_a_npc_kn.h index 37b248fbe5..9e1794db97 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,14 +412,14 @@ 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; diff --git a/include/d/actor/d_a_npc_knj.h b/include/d/actor/d_a_npc_knj.h index 8aa5ff860a..f8db1cdedb 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,8 +80,8 @@ 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; diff --git a/include/d/actor/d_a_npc_kolin.h b/include/d/actor/d_a_npc_kolin.h index 819eb81078..28f455be35 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; diff --git a/include/d/actor/d_a_npc_kolinb.h b/include/d/actor/d_a_npc_kolinb.h index b3858a908e..bf4392a697 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; diff --git a/include/d/actor/d_a_npc_kyury.h b/include/d/actor/d_a_npc_kyury.h index 62ba0433cf..8469dd3528 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,8 +123,8 @@ 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; diff --git a/include/d/actor/d_a_npc_len.h b/include/d/actor/d_a_npc_len.h index da5a0e0777..13b959c3b7 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; diff --git a/include/d/actor/d_a_npc_lud.h b/include/d/actor/d_a_npc_lud.h index b84e6aafac..afecfdc0c7 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,8 +111,8 @@ 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; diff --git a/include/d/actor/d_a_npc_maro.h b/include/d/actor/d_a_npc_maro.h index b8ec85b9fb..1c51a63b44 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; diff --git a/include/d/actor/d_a_npc_midp.h b/include/d/actor/d_a_npc_midp.h index 810f9eca45..60efbbac80 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,8 +148,8 @@ 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; diff --git a/include/d/actor/d_a_npc_moi.h b/include/d/actor/d_a_npc_moi.h index eb00654fd9..547c3a1dcd 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,8 +158,8 @@ 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; diff --git a/include/d/actor/d_a_npc_moir.h b/include/d/actor/d_a_npc_moir.h index 0cc8be336a..f9aa841a60 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,7 +212,7 @@ 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; 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..7fa17d8b2d 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,8 +144,8 @@ 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; diff --git a/include/d/actor/d_a_npc_pachi_maro.h b/include/d/actor/d_a_npc_pachi_maro.h index ffb33d1fbc..379c2c204b 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,8 +184,8 @@ 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; diff --git a/include/d/actor/d_a_npc_pachi_taro.h b/include/d/actor/d_a_npc_pachi_taro.h index 9faee13c23..12de6aedf4 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,8 +196,8 @@ 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; diff --git a/include/d/actor/d_a_npc_passer.h b/include/d/actor/d_a_npc_passer.h index f6c05ae7a5..d2f6f0b764 100644 --- a/include/d/actor/d_a_npc_passer.h +++ b/include/d/actor/d_a_npc_passer.h @@ -92,36 +92,36 @@ 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; diff --git a/include/d/actor/d_a_npc_passer2.h b/include/d/actor/d_a_npc_passer2.h index 529b99fc35..792bbfd329 100644 --- a/include/d/actor/d_a_npc_passer2.h +++ b/include/d/actor/d_a_npc_passer2.h @@ -51,7 +51,7 @@ 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; diff --git a/include/d/actor/d_a_npc_post.h b/include/d/actor/d_a_npc_post.h index 5450dbfe68..7b31506513 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,8 +153,8 @@ 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; diff --git a/include/d/actor/d_a_npc_pouya.h b/include/d/actor/d_a_npc_pouya.h index c94f777d87..c30b0e0199 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,8 +146,8 @@ 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; diff --git a/include/d/actor/d_a_npc_prayer.h b/include/d/actor/d_a_npc_prayer.h index fd1afa2ddf..bc2735a43f 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,7 +77,7 @@ 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; diff --git a/include/d/actor/d_a_npc_raca.h b/include/d/actor/d_a_npc_raca.h index 985f370dbb..9cd1849880 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,8 +145,8 @@ 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; diff --git a/include/d/actor/d_a_npc_rafrel.h b/include/d/actor/d_a_npc_rafrel.h index ae804cf15a..3b3ac191bd 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,7 +105,7 @@ 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; diff --git a/include/d/actor/d_a_npc_saru.h b/include/d/actor/d_a_npc_saru.h index 05535786fe..7f04c509e2 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,8 +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]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[4]; private: /* 0xE40 */ NPC_SARU_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpRoseModels[2]; diff --git a/include/d/actor/d_a_npc_seib.h b/include/d/actor/d_a_npc_seib.h index b7af300cee..f2d0e04820 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,8 +84,8 @@ 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; diff --git a/include/d/actor/d_a_npc_seic.h b/include/d/actor/d_a_npc_seic.h index bbdaf19431..526331f05e 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,8 +87,8 @@ 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; diff --git a/include/d/actor/d_a_npc_seid.h b/include/d/actor/d_a_npc_seid.h index f83d8a2909..37cc6302d6 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,8 +86,8 @@ 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; diff --git a/include/d/actor/d_a_npc_seira.h b/include/d/actor/d_a_npc_seira.h index 0528dd5c01..d750c70711 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,8 +114,8 @@ 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; diff --git a/include/d/actor/d_a_npc_seira2.h b/include/d/actor/d_a_npc_seira2.h index b3157b2924..496357af4e 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,8 +106,8 @@ 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; diff --git a/include/d/actor/d_a_npc_seirei.h b/include/d/actor/d_a_npc_seirei.h index ca0c7f9985..a25c9671ae 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,8 +99,8 @@ 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; diff --git a/include/d/actor/d_a_npc_shad.h b/include/d/actor/d_a_npc_shad.h index d33a6af350..7f4490c183 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; } diff --git a/include/d/actor/d_a_npc_shaman.h b/include/d/actor/d_a_npc_shaman.h index 76231f2756..cdb7f7d7e9 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,12 +110,12 @@ 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; diff --git a/include/d/actor/d_a_npc_shoe.h b/include/d/actor/d_a_npc_shoe.h index 67b746546b..f9bee53132 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,7 +110,7 @@ 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; 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..bfeb993cc7 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,8 +111,8 @@ 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; diff --git a/include/d/actor/d_a_npc_soldierA.h b/include/d/actor/d_a_npc_soldierA.h index f7c9153dd9..dfc114d97e 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,8 +79,8 @@ 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; diff --git a/include/d/actor/d_a_npc_soldierB.h b/include/d/actor/d_a_npc_soldierB.h index a99e10a813..66813628f9 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,8 +75,8 @@ 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; diff --git a/include/d/actor/d_a_npc_taro.h b/include/d/actor/d_a_npc_taro.h index 6e7e394406..1d0fa6274b 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,8 +156,8 @@ 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; diff --git a/include/d/actor/d_a_npc_the.h b/include/d/actor/d_a_npc_the.h index c131d442f6..fba5678e01 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); @@ -231,8 +231,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..92e0b0b3f0 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,7 +149,7 @@ public: } } - static cutFunc mEvtSeqList[6]; + static DUSK_GAME_DATA cutFunc mEvtSeqList[6]; private: /* 0xB48 */ Z2Creature mSound; diff --git a/include/d/actor/d_a_npc_tkc.h b/include/d/actor/d_a_npc_tkc.h index ab2c871be2..3148354b36 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,7 +106,7 @@ 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; diff --git a/include/d/actor/d_a_npc_tkj.h b/include/d/actor/d_a_npc_tkj.h index dc0e595cb7..8e7e2567b1 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,8 +94,8 @@ 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; diff --git a/include/d/actor/d_a_npc_tks.h b/include/d/actor/d_a_npc_tks.h index c2f7e6ff53..0342a378fe 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 diff --git a/include/d/actor/d_a_npc_toby.h b/include/d/actor/d_a_npc_toby.h index 7cce8adf7e..4f53117112 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,8 +129,8 @@ 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; diff --git a/include/d/actor/d_a_npc_uri.h b/include/d/actor/d_a_npc_uri.h index 0c29bd56ee..78a327592a 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,8 +136,8 @@ 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; diff --git a/include/d/actor/d_a_npc_wrestler.h b/include/d/actor/d_a_npc_wrestler.h index e4c98c8abb..b910ed50f9 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,7 +230,7 @@ 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; diff --git a/include/d/actor/d_a_npc_yamid.h b/include/d/actor/d_a_npc_yamid.h index 3133cbd84f..b175aa7a53 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,8 +129,8 @@ 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; diff --git a/include/d/actor/d_a_npc_yamis.h b/include/d/actor/d_a_npc_yamis.h index edf87ee174..4c23311c5e 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,8 +124,8 @@ 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; diff --git a/include/d/actor/d_a_npc_yamit.h b/include/d/actor/d_a_npc_yamit.h index 4f7a5393f8..a59b6a841f 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,8 +123,8 @@ 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; diff --git a/include/d/actor/d_a_npc_yelia.h b/include/d/actor/d_a_npc_yelia.h index fb934a25c5..737a3b4e28 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,8 +102,8 @@ public: return no; } - static char DUSK_CONST* DUSK_CONST mCutNameList[6]; - static int (daNpc_Yelia_c::*mCutList[6])(int); + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[6]; + static DUSK_GAME_DATA int (daNpc_Yelia_c::*mCutList[6])(int); private: /* 0xE40 */ NPC_YELIA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_npc_ykm.h b/include/d/actor/d_a_npc_ykm.h index 391203948d..d486d6fe6a 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,8 +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]; + static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[10]; + static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[10]; private: /* 0x0E40 */ mDoExt_McaMorfSO* mFishModelMorf; /* 0x0E44 */ mDoExt_McaMorfSO* mLeafModelMorf; 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..51d99c8253 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,8 +99,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zant.h b/include/d/actor/d_a_npc_zant.h index d2d1949bda..cbd33863d2 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,8 +83,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zelR.h b/include/d/actor/d_a_npc_zelR.h index ce3314c694..e7810c850c 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,8 +93,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zelRo.h b/include/d/actor/d_a_npc_zelRo.h index 40e0b3e391..b3e2533999 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,8 +147,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zelda.h b/include/d/actor/d_a_npc_zelda.h index 5a2d70b658..6c3da5a2b3 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,8 +100,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zra.h b/include/d/actor/d_a_npc_zra.h index 31ea1431b7..ee786522f9 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 @@ -443,8 +443,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..f4aeee6ac9 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,8 +93,8 @@ 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; diff --git a/include/d/actor/d_a_npc_zrz.h b/include/d/actor/d_a_npc_zrz.h index a9a294b97f..76c782b7d3 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); @@ -160,8 +160,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_Turara.h b/include/d/actor/d_a_obj_Turara.h index d8a45097d9..99d5a3a245 100644 --- a/include/d/actor/d_a_obj_Turara.h +++ b/include/d/actor/d_a_obj_Turara.h @@ -53,8 +53,8 @@ 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; diff --git a/include/d/actor/d_a_obj_TvCdlst.h b/include/d/actor/d_a_obj_TvCdlst.h index 7d94a35676..afe204bc03 100644 --- a/include/d/actor/d_a_obj_TvCdlst.h +++ b/include/d/actor/d_a_obj_TvCdlst.h @@ -26,8 +26,8 @@ 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); } diff --git a/include/d/actor/d_a_obj_automata.h b/include/d/actor/d_a_obj_automata.h index 3468ccc3e8..95fec65cff 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 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_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..38501b708b 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,7 +130,7 @@ public: #endif int Delete(); - static s16 const M_dir_base[4]; + static DUSK_GAME_DATA s16 const M_dir_base[4]; // private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_bky_rock.h b/include/d/actor/d_a_obj_bky_rock.h index 99f23557e4..1f5952c35e 100644 --- a/include/d/actor/d_a_obj_bky_rock.h +++ b/include/d/actor/d_a_obj_bky_rock.h @@ -60,8 +60,8 @@ 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; diff --git a/include/d/actor/d_a_obj_bmWindow.h b/include/d/actor/d_a_obj_bmWindow.h index 85b5ab8f86..161f4768a9 100644 --- a/include/d/actor/d_a_obj_bmWindow.h +++ b/include/d/actor/d_a_obj_bmWindow.h @@ -66,8 +66,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_boumato.h b/include/d/actor/d_a_obj_boumato.h index 3a988d9b4b..4852aee6f9 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 diff --git a/include/d/actor/d_a_obj_bubblePilar.h b/include/d/actor/d_a_obj_bubblePilar.h index b9abdd1fdd..7fb8009564 100644 --- a/include/d/actor/d_a_obj_bubblePilar.h +++ b/include/d/actor/d_a_obj_bubblePilar.h @@ -36,8 +36,8 @@ 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; diff --git a/include/d/actor/d_a_obj_carry.h b/include/d/actor/d_a_obj_carry.h index 621b8efabb..8147cbfb60 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; diff --git a/include/d/actor/d_a_obj_catdoor.h b/include/d/actor/d_a_obj_catdoor.h index dd7141d920..b7ed95bd14 100644 --- a/include/d/actor/d_a_obj_catdoor.h +++ b/include/d/actor/d_a_obj_catdoor.h @@ -88,7 +88,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_chandelier.h b/include/d/actor/d_a_obj_chandelier.h index 4aae0160d8..45158dea34 100644 --- a/include/d/actor/d_a_obj_chandelier.h +++ b/include/d/actor/d_a_obj_chandelier.h @@ -67,7 +67,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_fireWood.h b/include/d/actor/d_a_obj_fireWood.h index 116af1203c..07a5d5334b 100644 --- a/include/d/actor/d_a_obj_fireWood.h +++ b/include/d/actor/d_a_obj_fireWood.h @@ -24,8 +24,8 @@ 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]; diff --git a/include/d/actor/d_a_obj_fireWood2.h b/include/d/actor/d_a_obj_fireWood2.h index 3b288edeeb..bcb1bee95d 100644 --- a/include/d/actor/d_a_obj_fireWood2.h +++ b/include/d/actor/d_a_obj_fireWood2.h @@ -25,8 +25,8 @@ 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]; diff --git a/include/d/actor/d_a_obj_flag.h b/include/d/actor/d_a_obj_flag.h index eee36b0842..8187fe33b2 100644 --- a/include/d/actor/d_a_obj_flag.h +++ b/include/d/actor/d_a_obj_flag.h @@ -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..c9ef033190 100644 --- a/include/d/actor/d_a_obj_flag2.h +++ b/include/d/actor/d_a_obj_flag2.h @@ -81,7 +81,7 @@ 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; diff --git a/include/d/actor/d_a_obj_flag3.h b/include/d/actor/d_a_obj_flag3.h index c6a94f6538..b93394ce15 100644 --- a/include/d/actor/d_a_obj_flag3.h +++ b/include/d/actor/d_a_obj_flag3.h @@ -93,7 +93,7 @@ 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: diff --git a/include/d/actor/d_a_obj_gadget.h b/include/d/actor/d_a_obj_gadget.h index db7f5a53f7..cb2c99af97 100644 --- a/include/d/actor/d_a_obj_gadget.h +++ b/include/d/actor/d_a_obj_gadget.h @@ -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_glowSphere.h b/include/d/actor/d_a_obj_glowSphere.h index f620306408..c6c2ee220e 100644 --- a/include/d/actor/d_a_obj_glowSphere.h +++ b/include/d/actor/d_a_obj_glowSphere.h @@ -68,8 +68,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 +135,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_gpTaru.h b/include/d/actor/d_a_obj_gpTaru.h index 79ed31b3ae..b3b31a5c9d 100644 --- a/include/d/actor/d_a_obj_gpTaru.h +++ b/include/d/actor/d_a_obj_gpTaru.h @@ -43,8 +43,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; private: /* 0x56C */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_gra2.h b/include/d/actor/d_a_obj_gra2.h index 59fd35343b..3cf17e090c 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; } diff --git a/include/d/actor/d_a_obj_gra_rock.h b/include/d/actor/d_a_obj_gra_rock.h index e3cf568871..24e816a829 100644 --- a/include/d/actor/d_a_obj_gra_rock.h +++ b/include/d/actor/d_a_obj_gra_rock.h @@ -31,7 +31,7 @@ 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]; diff --git a/include/d/actor/d_a_obj_grave_stone.h b/include/d/actor/d_a_obj_grave_stone.h index dee38757a3..d41d58348a 100644 --- a/include/d/actor/d_a_obj_grave_stone.h +++ b/include/d/actor/d_a_obj_grave_stone.h @@ -49,8 +49,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_hakai_brl.h b/include/d/actor/d_a_obj_hakai_brl.h index 394cab0366..dba4b3cd3f 100644 --- a/include/d/actor/d_a_obj_hakai_brl.h +++ b/include/d/actor/d_a_obj_hakai_brl.h @@ -32,7 +32,7 @@ public: } void callEmt(); - static dCcD_SrcCyl const s_CcDCyl; + static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; private: /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_hakai_ftr.h b/include/d/actor/d_a_obj_hakai_ftr.h index cc94ba6021..45c815c5f9 100644 --- a/include/d/actor/d_a_obj_hakai_ftr.h +++ b/include/d/actor/d_a_obj_hakai_ftr.h @@ -29,7 +29,7 @@ public: bool chkHit(); void callEmt(); - static dCcD_SrcCyl const s_CcDCyl; + static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; private: /* 0x574 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_itamato.h b/include/d/actor/d_a_obj_itamato.h index 0aece512cd..10c6459887 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 diff --git a/include/d/actor/d_a_obj_kago.h b/include/d/actor/d_a_obj_kago.h index c2ea85d8f2..265db41c57 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 diff --git a/include/d/actor/d_a_obj_kazeneko.h b/include/d/actor/d_a_obj_kazeneko.h index 3ac12b40f3..73147b6fbe 100644 --- a/include/d/actor/d_a_obj_kazeneko.h +++ b/include/d/actor/d_a_obj_kazeneko.h @@ -45,7 +45,7 @@ public: const KazoNekoAttr& attr() { return M_attr; } - static KazoNekoAttr const M_attr; + static DUSK_GAME_DATA KazoNekoAttr const M_attr; private: /* 0x568 */ J3DModel* mModel; /* 0x56C */ J3DModel* mArmModels[4]; 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_ktOnFire.h b/include/d/actor/d_a_obj_ktOnFire.h index bd0e23a82d..39875e122e 100644 --- a/include/d/actor/d_a_obj_ktOnFire.h +++ b/include/d/actor/d_a_obj_ktOnFire.h @@ -23,8 +23,8 @@ 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; diff --git a/include/d/actor/d_a_obj_kznkarm.h b/include/d/actor/d_a_obj_kznkarm.h index 343285f8f8..c70908fcb8 100644 --- a/include/d/actor/d_a_obj_kznkarm.h +++ b/include/d/actor/d_a_obj_kznkarm.h @@ -60,8 +60,8 @@ 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; diff --git a/include/d/actor/d_a_obj_ladder.h b/include/d/actor/d_a_obj_ladder.h index eb48cf0f16..72f6fce4d2 100644 --- a/include/d/actor/d_a_obj_ladder.h +++ b/include/d/actor/d_a_obj_ladder.h @@ -74,8 +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; + static DUSK_GAME_DATA char const M_arcname[5]; + static DUSK_GAME_DATA Mtx M_tmp_mtx; private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_laundry.h b/include/d/actor/d_a_obj_laundry.h index 7d50dfa28e..cc79bc4e05 100644 --- a/include/d/actor/d_a_obj_laundry.h +++ b/include/d/actor/d_a_obj_laundry.h @@ -57,7 +57,7 @@ public: 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..3ecab164b2 100644 --- a/include/d/actor/d_a_obj_laundry_rope.h +++ b/include/d/actor/d_a_obj_laundry_rope.h @@ -55,7 +55,7 @@ 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: diff --git a/include/d/actor/d_a_obj_lv1Candle00.h b/include/d/actor/d_a_obj_lv1Candle00.h index 48fca4acb6..e9e62da388 100644 --- a/include/d/actor/d_a_obj_lv1Candle00.h +++ b/include/d/actor/d_a_obj_lv1Candle00.h @@ -46,8 +46,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..632c117f10 100644 --- a/include/d/actor/d_a_obj_lv1Candle01.h +++ b/include/d/actor/d_a_obj_lv1Candle01.h @@ -42,8 +42,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..19be29a16e 100644 --- a/include/d/actor/d_a_obj_lv2Candle.h +++ b/include/d/actor/d_a_obj_lv2Candle.h @@ -60,8 +60,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..7b9765136d 100644 --- a/include/d/actor/d_a_obj_lv3Candle.h +++ b/include/d/actor/d_a_obj_lv3Candle.h @@ -44,8 +44,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_lv5FloorBoard.h b/include/d/actor/d_a_obj_lv5FloorBoard.h index f4f5c50582..1dcba0ade2 100644 --- a/include/d/actor/d_a_obj_lv5FloorBoard.h +++ b/include/d/actor/d_a_obj_lv5FloorBoard.h @@ -35,8 +35,8 @@ 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; diff --git a/include/d/actor/d_a_obj_lv5IceWall.h b/include/d/actor/d_a_obj_lv5IceWall.h index 737aaf9318..c9f459e75d 100644 --- a/include/d/actor/d_a_obj_lv5IceWall.h +++ b/include/d/actor/d_a_obj_lv5IceWall.h @@ -39,8 +39,8 @@ 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; diff --git a/include/d/actor/d_a_obj_lv5SwIce.h b/include/d/actor/d_a_obj_lv5SwIce.h index 7c61e04d3b..8adc14f2af 100644 --- a/include/d/actor/d_a_obj_lv5SwIce.h +++ b/include/d/actor/d_a_obj_lv5SwIce.h @@ -35,8 +35,8 @@ 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; 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..8a5f17336d 100644 --- a/include/d/actor/d_a_obj_lv6FurikoTrap.h +++ b/include/d/actor/d_a_obj_lv6FurikoTrap.h @@ -25,8 +25,8 @@ 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; diff --git a/include/d/actor/d_a_obj_lv6SwGate.h b/include/d/actor/d_a_obj_lv6SwGate.h index 964c073c1d..331e7ae07d 100644 --- a/include/d/actor/d_a_obj_lv6SwGate.h +++ b/include/d/actor/d_a_obj_lv6SwGate.h @@ -36,8 +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; + static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; + static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcDCyls[12]; diff --git a/include/d/actor/d_a_obj_lv6TogeRoll.h b/include/d/actor/d_a_obj_lv6TogeRoll.h index 6e6357d552..9fedcd5932 100644 --- a/include/d/actor/d_a_obj_lv6TogeRoll.h +++ b/include/d/actor/d_a_obj_lv6TogeRoll.h @@ -60,11 +60,11 @@ 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; 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_lv8Lift.h b/include/d/actor/d_a_obj_lv8Lift.h index c327f4cf3c..0b39e25e89 100644 --- a/include/d/actor/d_a_obj_lv8Lift.h +++ b/include/d/actor/d_a_obj_lv8Lift.h @@ -66,7 +66,7 @@ public: 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; 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_magLift.h b/include/d/actor/d_a_obj_magLift.h index e9b4e8bcf3..a8f597bfef 100644 --- a/include/d/actor/d_a_obj_magLift.h +++ b/include/d/actor/d_a_obj_magLift.h @@ -47,7 +47,7 @@ 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; diff --git a/include/d/actor/d_a_obj_master_sword.h b/include/d/actor/d_a_obj_master_sword.h index e99b8832d7..a971aa335c 100644 --- a/include/d/actor/d_a_obj_master_sword.h +++ b/include/d/actor/d_a_obj_master_sword.h @@ -48,8 +48,8 @@ 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; diff --git a/include/d/actor/d_a_obj_mie.h b/include/d/actor/d_a_obj_mie.h index 0f1df429be..6c95ed7f84 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 diff --git a/include/d/actor/d_a_obj_mirror_6pole.h b/include/d/actor/d_a_obj_mirror_6pole.h index 702b1cb66b..17cf211be3 100644 --- a/include/d/actor/d_a_obj_mirror_6pole.h +++ b/include/d/actor/d_a_obj_mirror_6pole.h @@ -54,7 +54,7 @@ public: inline void callInit(); inline void callExecute(); - static const actionFunc ActionTable[][2]; + static DUSK_GAME_DATA const actionFunc ActionTable[][2]; private: /* 0x568 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_mirror_screw.h b/include/d/actor/d_a_obj_mirror_screw.h index feeb6bf294..482506ffc0 100644 --- a/include/d/actor/d_a_obj_mirror_screw.h +++ b/include/d/actor/d_a_obj_mirror_screw.h @@ -80,8 +80,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..d6aa6356bb 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); } 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_oiltubo.h b/include/d/actor/d_a_obj_oiltubo.h index fa1dc47fd9..b4ee8612bc 100644 --- a/include/d/actor/d_a_obj_oiltubo.h +++ b/include/d/actor/d_a_obj_oiltubo.h @@ -33,8 +33,8 @@ 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; 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_picture.h b/include/d/actor/d_a_obj_picture.h index 3460b60077..50d44d808b 100644 --- a/include/d/actor/d_a_obj_picture.h +++ b/include/d/actor/d_a_obj_picture.h @@ -39,11 +39,11 @@ 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; diff --git a/include/d/actor/d_a_obj_pleaf.h b/include/d/actor/d_a_obj_pleaf.h index 3571bb4026..5e7a5cde1c 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 diff --git a/include/d/actor/d_a_obj_pumpkin.h b/include/d/actor/d_a_obj_pumpkin.h index b1b36bfa1f..9dd015c00e 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 diff --git a/include/d/actor/d_a_obj_rotTrap.h b/include/d/actor/d_a_obj_rotTrap.h index 4b7b669afc..9534358f4a 100644 --- a/include/d/actor/d_a_obj_rotTrap.h +++ b/include/d/actor/d_a_obj_rotTrap.h @@ -34,8 +34,8 @@ 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; diff --git a/include/d/actor/d_a_obj_sakuita.h b/include/d/actor/d_a_obj_sakuita.h index 29b101586d..e9e4e82120 100644 --- a/include/d/actor/d_a_obj_sakuita.h +++ b/include/d/actor/d_a_obj_sakuita.h @@ -43,7 +43,7 @@ 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; diff --git a/include/d/actor/d_a_obj_sakuita_rope.h b/include/d/actor/d_a_obj_sakuita_rope.h index 9567b7f25f..dfbed5af0e 100644 --- a/include/d/actor/d_a_obj_sakuita_rope.h +++ b/include/d/actor/d_a_obj_sakuita_rope.h @@ -80,7 +80,7 @@ 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; diff --git a/include/d/actor/d_a_obj_scannon.h b/include/d/actor/d_a_obj_scannon.h index 9aa871bd77..0b1a79e18f 100644 --- a/include/d/actor/d_a_obj_scannon.h +++ b/include/d/actor/d_a_obj_scannon.h @@ -76,12 +76,12 @@ 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; diff --git a/include/d/actor/d_a_obj_scannon_crs.h b/include/d/actor/d_a_obj_scannon_crs.h index e390c60128..d7eb7c8121 100644 --- a/include/d/actor/d_a_obj_scannon_crs.h +++ b/include/d/actor/d_a_obj_scannon_crs.h @@ -49,7 +49,7 @@ 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; diff --git a/include/d/actor/d_a_obj_scannon_ten.h b/include/d/actor/d_a_obj_scannon_ten.h index 503a1e0522..7bc5b24ed8 100644 --- a/include/d/actor/d_a_obj_scannon_ten.h +++ b/include/d/actor/d_a_obj_scannon_ten.h @@ -57,8 +57,8 @@ 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; diff --git a/include/d/actor/d_a_obj_sekidoor.h b/include/d/actor/d_a_obj_sekidoor.h index ae4ff9acd4..46da5cb8a9 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 diff --git a/include/d/actor/d_a_obj_sekizo.h b/include/d/actor/d_a_obj_sekizo.h index 54fa84f5df..0f0847dc24 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 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_smtile.h b/include/d/actor/d_a_obj_smtile.h index 1832a7c4b8..735914f0a0 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 diff --git a/include/d/actor/d_a_obj_ss_drink.h b/include/d/actor/d_a_obj_ss_drink.h index c20992163b..e49644f6b6 100644 --- a/include/d/actor/d_a_obj_ss_drink.h +++ b/include/d/actor/d_a_obj_ss_drink.h @@ -47,8 +47,8 @@ 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; diff --git a/include/d/actor/d_a_obj_ss_item.h b/include/d/actor/d_a_obj_ss_item.h index 2b05046e28..cd219a1832 100644 --- a/include/d/actor/d_a_obj_ss_item.h +++ b/include/d/actor/d_a_obj_ss_item.h @@ -46,8 +46,8 @@ 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; diff --git a/include/d/actor/d_a_obj_stairBlock.h b/include/d/actor/d_a_obj_stairBlock.h index 63a0c5b178..3d3b8d5283 100644 --- a/include/d/actor/d_a_obj_stairBlock.h +++ b/include/d/actor/d_a_obj_stairBlock.h @@ -23,8 +23,8 @@ 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; diff --git a/include/d/actor/d_a_obj_stick.h b/include/d/actor/d_a_obj_stick.h index fe43aabd15..ebc08e08b8 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 @@ -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_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..2c881585ed 100644 --- a/include/d/actor/d_a_obj_syRock.h +++ b/include/d/actor/d_a_obj_syRock.h @@ -43,8 +43,8 @@ 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; 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_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_togeTrap.h b/include/d/actor/d_a_obj_togeTrap.h index 161c958ce0..4055d6a42e 100644 --- a/include/d/actor/d_a_obj_togeTrap.h +++ b/include/d/actor/d_a_obj_togeTrap.h @@ -44,8 +44,8 @@ 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; diff --git a/include/d/actor/d_a_obj_waterPillar.h b/include/d/actor/d_a_obj_waterPillar.h index 6bcad283da..19b55971e8 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; diff --git a/include/d/actor/d_a_obj_wdStick.h b/include/d/actor/d_a_obj_wdStick.h index c82b115b84..08bc2a1faf 100644 --- a/include/d/actor/d_a_obj_wdStick.h +++ b/include/d/actor/d_a_obj_wdStick.h @@ -50,8 +50,8 @@ 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; diff --git a/include/d/actor/d_a_obj_yel_bag.h b/include/d/actor/d_a_obj_yel_bag.h index 69b428da49..caeba24ae5 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 @@ -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..a3dfa944fa 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; } diff --git a/include/d/actor/d_a_obj_zrTurara.h b/include/d/actor/d_a_obj_zrTurara.h index 9f48464cf9..679ae20635 100644 --- a/include/d/actor/d_a_obj_zrTurara.h +++ b/include/d/actor/d_a_obj_zrTurara.h @@ -50,8 +50,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..1f92de6e82 100644 --- a/include/d/actor/d_a_obj_zrTuraraRock.h +++ b/include/d/actor/d_a_obj_zrTuraraRock.h @@ -45,8 +45,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_passer_mng.h b/include/d/actor/d_a_passer_mng.h index 230432336c..ced02d9d1d 100644 --- a/include/d/actor/d_a_passer_mng.h +++ b/include/d/actor/d_a_passer_mng.h @@ -257,7 +257,7 @@ public: int field_0x04[0]; }; - static const Group* mGroupTbl[4]; + static DUSK_GAME_DATA const Group* mGroupTbl[4]; private: /* 0x568 */ fpc_ProcID* childProcIds; diff --git a/include/d/actor/d_a_peru.h b/include/d/actor/d_a_peru.h index 9ea1ce80c1..771e879b10 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,8 +186,8 @@ 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]; diff --git a/include/d/actor/d_a_player.h b/include/d/actor/d_a_player.h index 1dfbec8783..66139b54cf 100644 --- a/include/d/actor/d_a_player.h +++ b/include/d/actor/d_a_player.h @@ -67,8 +67,8 @@ 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; @@ -1213,7 +1213,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_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_tag_TWgate.h b/include/d/actor/d_a_tag_TWgate.h index e5952da286..1886690db2 100644 --- a/include/d/actor/d_a_tag_TWgate.h +++ b/include/d/actor/d_a_tag_TWgate.h @@ -112,11 +112,11 @@ 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; 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_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_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_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_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_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_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 cd505335a8..db8661b92f 100644 --- a/include/d/actor/d_flower.h +++ b/include/d/actor/d_flower.h @@ -4,6 +4,10 @@ #include "JSystem/J3DGraphBase/J3DPacket.h" #include "SSystem/SComponent/c_xyz.h" +#if TARGET_PC +#include "helpers/batch.hpp" +#endif + class cCcD_Obj; class dCcMassS_HitInf; class fopAc_ac_c; @@ -70,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]; } @@ -107,6 +111,12 @@ public: #if TARGET_PC TGXTexObj mTexObj_l_J_Ohana00_64TEX; TGXTexObj mTexObj_l_J_Ohana01_64128_0419TEX; + + 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 47b948679d..4eee08c0e8 100644 --- a/include/d/actor/d_grass.h +++ b/include/d/actor/d_grass.h @@ -4,6 +4,10 @@ #include "JSystem/J3DGraphBase/J3DPacket.h" #include "SSystem/SComponent/c_xyz.h" +#if TARGET_PC +#include +#endif + class cCcD_Obj; class csXyz; class dCcMassS_HitInf; @@ -80,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]; } @@ -110,6 +114,10 @@ public: #if TARGET_PC TGXTexObj mTexObj_l_M_Hijiki00TEX; TGXTexObj mTexObj_l_M_kusa05_RGBATEX; + + 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..36c445d511 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; diff --git a/include/d/d_a_shop_item_static.h b/include/d/d_a_shop_item_static.h index 0091c0b83c..eeda9185da 100644 --- a/include/d/d_a_shop_item_static.h +++ b/include/d/d_a_shop_item_static.h @@ -74,8 +74,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, diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 455516e54f..8e3b8be1f5 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -45,7 +45,7 @@ private: class dAttParam_c : public JORReflexible { public: -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x04 */ s8 mHIOChildNo; #endif @@ -66,7 +66,7 @@ public: /* 0x35 */ u8 mAttnCursorDisappearFrames; /* 0x38 */ f32 field_0x38; /* 0x3C */ f32 field_0x3c; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x44 */ s32 mDebugDispPosX; /* 0x48 */ s32 mDebugDispPosY; #endif @@ -286,13 +286,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_s_acch.h b/include/d/d_bg_s_acch.h index 33bca24c0a..04a388c61b 100644 --- a/include/d/d_bg_s_acch.h +++ b/include/d/d_bg_s_acch.h @@ -201,7 +201,7 @@ private: /* 0x02C */ u32 m_flags; /* 0x030 */ cXyz* pm_pos; /* 0x034 */ cXyz* pm_old_pos; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x038 */ cXyz unk_0x38; #endif /* 0x038 */ cXyz* pm_speed; @@ -229,7 +229,7 @@ private: /* 0x0CC */ f32 field_0xcc; /* 0x0D0 */ f32 m_wtr_chk_offset; /* 0x0D4 */ cBgS_PolyInfo* pm_out_poly_info; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x0E4 */ cXyz unk_0xe4; #endif /* 0x0D8 */ f32 field_0xd8; 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_w.h b/include/d/d_bg_w.h index 580e22d904..ae37d1c6d9 100644 --- a/include/d/d_bg_w.h +++ b/include/d/d_bg_w.h @@ -6,9 +6,9 @@ #include "d/d_bg_w_base.h" #include #include -#include "dusk/offset_ptr.h" -#include "dusk/endian.h" -#include "dusk/endian_ssystem.h" +#include "helpers/offset_ptr.h" +#include "helpers/endian.h" +#include "helpers/endian_ssystem.h" class cBgS_GrpPassChk; class cBgS_PolyPassChk; diff --git a/include/d/d_bg_w_kcol.h b/include/d/d_bg_w_kcol.h index 1fc812dd98..84b0da03f2 100644 --- a/include/d/d_bg_w_kcol.h +++ b/include/d/d_bg_w_kcol.h @@ -6,7 +6,7 @@ #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" +#include "helpers/offset_ptr.h" class cBgS_GrpPassChk; class cBgS_PolyPassChk; diff --git a/include/d/d_camera.h b/include/d/d_camera.h index 0698bbbe5a..6c95d1ce51 100644 --- a/include/d/d_camera.h +++ b/include/d/d_camera.h @@ -1037,7 +1037,7 @@ public: bool test1Camera(s32); bool test2Camera(s32); #if TARGET_PC - static bool canUseFreeCam(); + static bool isAimActive(); bool freeCamera(); bool executeDebugFlyCam(); void deactivateDebugFlyCam(); @@ -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..40ffae33da 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -424,7 +424,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_s.h b/include/d/d_cc_s.h index b4d90787ae..0ebf4a5265 100644 --- a/include/d/d_cc_s.h +++ b/include/d/d_cc_s.h @@ -75,11 +75,11 @@ 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; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x2AD0 */ u8 m_is_mass_all_timer; #endif }; // Size = 0x2AC4 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 fbc9964ca2..a598cbcc10 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -17,7 +17,15 @@ #include "m_Do/m_Do_graphic.h" #include -#include "tracy/Tracy.hpp" +#if defined(DUSK_BUILDING_GAME) +#include +#include "dusk/settings.h" +#else +#ifndef ZoneScoped +#define ZoneScoped +#define ZoneScopedN(name) +#endif +#endif enum dComIfG_ButtonStatus { /* 0x00 */ BUTTON_STATUS_NONE, @@ -1037,7 +1045,7 @@ public: /* 0x1DE09 */ u8 field_0x1de09; /* 0x1DE0A */ u8 field_0x1de0a; /* 0x1DE0B */ u8 mIsDebugMode; - #if DEBUG + #if PARTIAL_DEBUG || DEBUG /* 0x1DE0C */ OSStopwatch mStopwatch; #endif @@ -1049,11 +1057,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*); @@ -4837,27 +4845,23 @@ inline void dComIfGd_drawXluListDark() { g_dComIfG_gameInfo.drawlist.drawXluListDark(); } +#if TARGET_PC +void dComIfGd_drawXluListInvisible(); +#else 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(); } +#endif +#if TARGET_PC +void dComIfGd_drawOpaListInvisible(); +#else 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(); } +#endif inline void dComIfGd_drawXluListZxlu() { ZoneScoped; 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..8eef24d7e3 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -381,26 +381,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..25d92aff54 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -5,7 +5,7 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "f_op/f_op_view.h" #include "global.h" #include "m_Do/m_Do_ext.h" @@ -301,7 +301,7 @@ public: static TGXTexObj* getSimpleTex() { return &mSimpleTexObj; } - static TGXTexObj mSimpleTexObj; + static DUSK_GAME_DATA TGXTexObj mSimpleTexObj; private: /* 0x00000 */ u8 field_0x0; @@ -512,11 +512,11 @@ 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]; diff --git a/include/d/d_event_data.h b/include/d/d_event_data.h index ee9b868af4..eef55b1164 100644 --- a/include/d/d_event_data.h +++ b/include/d/d_event_data.h @@ -3,7 +3,7 @@ #include "global.h" #include "f_pc/f_pc_base.h" -#include "dusk/endian.h" +#include "helpers/endian.h" struct msg_class; diff --git a/include/d/d_event_manager.h b/include/d/d_event_manager.h index 03a8ef7ac3..de046797ff 100644 --- a/include/d/d_event_manager.h +++ b/include/d/d_event_manager.h @@ -41,7 +41,7 @@ public: BASE_ROOM5, BASE_DEMO, - #if DEBUG + #if PARTIAL_DEBUG || DEBUG BASE_DEBUG, #endif 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_select.h b/include/d/d_file_select.h index d478126b38..634c0db352 100644 --- a/include/d/d_file_select.h +++ b/include/d/d_file_select.h @@ -287,6 +287,11 @@ public: MEMCARDCHECKPROC_ERR_YESNO_CURSOR_MOVE_ANM, MEMCARDCHECKPROC_SAVEDATA_CLEAR, +#if TARGET_PC + MEMCARDCHECKPROC_AUTO_MAKE_GAMEFILE, + MEMCARDCHECKPROC_AUTO_MAKE_GAMEFILE_ERR_WAIT, +#endif + #if PLATFORM_WII || PLATFORM_SHIELD MEMCARDCHECKPROC_NAND_STAT_CHECK, MEMCARDCHECKPROC_GAMEFILE_INIT_SEL, @@ -411,6 +416,10 @@ public: bool yesnoWakuAlpahAnm(u8); #if TARGET_PC void fileSelectWide(); + bool pointerDataSelect(); + bool pointerMenuSelect(); + bool pointerCopyDataToSelect(); + bool pointerYesNoSelect(bool errorSelect); #endif void _draw(); void errorMoveAnmInitSet(int, int); @@ -445,6 +454,10 @@ public: void MemCardMakeGameFile(); void MemCardMakeGameFileWait(); void MemCardMakeGameFileCheck(); +#if TARGET_PC + void MemCardAutoMakeGameFile(); + void MemCardAutoMakeGameFileErrWait(); +#endif void MemCardMsgWindowInitOpen(); void MemCardMsgWindowOpen(); void MemCardMsgWindowClose(); diff --git a/include/d/d_item.h b/include/d/d_item.h index 0d379c0578..d9bdfd18c9 100644 --- a/include/d/d_item.h +++ b/include/d/d_item.h @@ -8,7 +8,7 @@ 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); diff --git a/include/d/d_item_data.h b/include/d/d_item_data.h index a1770be241..0044573976 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 { 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 3c81f08d10..1a43d811f7 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -259,7 +259,7 @@ public: /* 0x09B8 */ DUNGEON_LIGHT dungeonlight[8]; /* 0x0C18 */ BOSS_LIGHT field_0x0c18[8]; /* 0x0D58 */ BOSS_LIGHT field_0x0d58[6]; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x0E48 */ NAVYCHAN navy; /* 0x0E58 */ u8 field_0xe58[0xE68 - 0xE58]; // part of NAVYCHAN? #endif @@ -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_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 1acc7e4519..b42def27c7 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; }; @@ -157,6 +157,9 @@ public: int getDispType() const; void _move(f32, f32, int, f32); void _draw(); +#if TARGET_PC + bool refreshTextureSize(); +#endif virtual ~dMap_c() { #if DEBUG 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 28a095896e..b7d5ec2976 100644 --- a/include/d/d_menu_collect.h +++ b/include/d/d_menu_collect.h @@ -74,6 +74,8 @@ public: #if TARGET_PC void menuCollectWide(); + bool pointerWait(); + void pointerActivateCurrent(); #endif void _create(); @@ -264,7 +266,7 @@ public: mViewOffsetY = i_offset; } - static f32 mViewOffsetY; + static DUSK_GAME_DATA f32 mViewOffsetY; private: /* 0x004 */ JKRExpHeap* mpHeap; diff --git a/include/d/d_menu_dmap.h b/include/d/d_menu_dmap.h index 7740927f4e..4d1341cc67 100644 --- a/include/d/d_menu_dmap.h +++ b/include/d/d_menu_dmap.h @@ -253,7 +253,7 @@ 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; 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_fmap.h b/include/d/d_menu_fmap.h index 48db37fef3..110298798a 100644 --- a/include/d/d_menu_fmap.h +++ b/include/d/d_menu_fmap.h @@ -268,7 +268,7 @@ public: /* 0x1D */ PROC_HOWL_DEMO3, }; - static dMenu_Fmap_c* MyClass; + static DUSK_GAME_DATA dMenu_Fmap_c* MyClass; private: /* 0x004 */ JKRExpHeap* mpHeap; @@ -356,7 +356,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 6b23a3845d..90cfca7d5a 100644 --- a/include/d/d_menu_insect.h +++ b/include/d/d_menu_insect.h @@ -51,6 +51,10 @@ public: void setBButtonString(u16); void setHIO(bool); +#if TARGET_PC + bool pointerWait(); +#endif + virtual void draw() { _draw(); } virtual ~dMenu_Insect_c(); diff --git a/include/d/d_menu_letter.h b/include/d/d_menu_letter.h index 163c381699..208f8b65a9 100644 --- a/include/d/d_menu_letter.h +++ b/include/d/d_menu_letter.h @@ -55,6 +55,10 @@ public: u8 getLetterNum(); void setHIO(bool); +#if TARGET_PC + bool pointerWait(); +#endif + virtual void draw() { _draw(); } virtual ~dMenu_Letter_c(); diff --git a/include/d/d_menu_option.h b/include/d/d_menu_option.h index 7204d62974..49e81f98ae 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 @@ -80,6 +94,9 @@ public: void setBButtonString(u16); bool isRumbleSupported(); bool dpdMenuMove(); +#if TARGET_PC + bool pointerConfirmSelect(); +#endif void paneResize(u64); void initialize(); void yesnoMenuMoveAnmInitSet(int, int); @@ -186,7 +203,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 74624eac80..c7467d2a4b 100644 --- a/include/d/d_menu_ring.h +++ b/include/d/d_menu_ring.h @@ -74,6 +74,9 @@ public: void clacEllipsePlotAverage(int, f32, f32); bool dpdMove(); u8 openExplain(u8); +#if TARGET_PC + bool pointerMove(); +#endif virtual void draw() { _draw(); } virtual ~dMenu_Ring_c(); @@ -215,6 +218,7 @@ private: bool mCursorInterpPrevAngular; bool mCursorInterpCurrAngular; bool mCursorInterpInit; + bool mPointerTouchPressHoveredCurrent; #endif }; diff --git a/include/d/d_menu_save.h b/include/d/d_menu_save.h index 116795f7be..d9d052aa33 100644 --- a/include/d/d_menu_save.h +++ b/include/d/d_menu_save.h @@ -266,6 +266,8 @@ public: #if TARGET_PC void menuSaveWide(); + bool pointerSaveSelect(); + bool pointerYesNoSelect(bool errorSelect, u8 errParam = 0, u8 soundParam = 0); #endif void _draw2(); diff --git a/include/d/d_menu_skill.h b/include/d/d_menu_skill.h index 9ea305163e..2f9097b165 100644 --- a/include/d/d_menu_skill.h +++ b/include/d/d_menu_skill.h @@ -49,6 +49,10 @@ public: u8 getSkillNum(); void setHIO(bool); +#if TARGET_PC + bool pointerWait(); +#endif + virtual void draw() { _draw(); } virtual ~dMenu_Skill_c(); 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_info.h b/include/d/d_meter2_info.h index 683e555386..410cf642b1 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); 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_model.h b/include/d/d_model.h index 2dd1abaabf..72949f5f03 100644 --- a/include/d/d_model.h +++ b/include/d/d_model.h @@ -53,7 +53,7 @@ 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]; diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index 307d48f291..a8bba32351 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -4,10 +4,14 @@ #include "JSystem/JMessage/control.h" #include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" -#include "dusk/endian.h" -#include "dusk/string.hpp" +#include "helpers/endian.h" +#include "helpers/string.hpp" -#if REGION_JPN +#if TARGET_PC +#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 diff --git a/include/d/d_msg_flow.h b/include/d/d_msg_flow.h index cd9a7c4e5f..233dad7170 100644 --- a/include/d/d_msg_flow.h +++ b/include/d/d_msg_flow.h @@ -2,7 +2,7 @@ #define D_MSG_D_MSG_FLOW_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" enum { NODETYPE_MESSAGE_e = 1, @@ -185,8 +185,8 @@ 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; diff --git a/include/d/d_msg_object.h b/include/d/d_msg_object.h index 6cf9ea7681..7ca53064a7 100644 --- a/include/d/d_msg_object.h +++ b/include/d/d_msg_object.h @@ -360,7 +360,12 @@ inline void dMsgObject_demoMessageGroup() { } inline bool dMsgObject_isTalkNowCheck() { +#if TARGET_PC + dMsgObject_c* msgObject = dMsgObject_getMsgObjectClass(); + return msgObject != NULL && msgObject->getStatus() != 1; +#else return dMsgObject_getMsgObjectClass()->getStatus() == 1 ? false : true; +#endif } inline bool dMsgObject_isKillMessageFlag() { @@ -497,7 +502,12 @@ inline void dMsgObject_onMsgSend() { } inline bool dMsgObject_isFukidashiCheck() { +#if TARGET_PC + dMsgObject_c* msgObject = dMsgObject_getMsgObjectClass(); + return msgObject != NULL && msgObject->getScrnDrawPtr() != NULL; +#else return dMsgObject_getMsgObjectClass()->getScrnDrawPtr() == NULL ? false : true; +#endif } inline void* dMsgObject_getTalkHeap() { @@ -761,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_scrn_3select.h b/include/d/d_msg_scrn_3select.h index 949db3f130..1cb92e5be6 100644 --- a/include/d/d_msg_scrn_3select.h +++ b/include/d/d_msg_scrn_3select.h @@ -49,6 +49,10 @@ public: void selectScale(); void selectTrans(); void selectAnimeTransform(int); +#if TARGET_PC + bool pointerMove(); + bool consumePointerClick(); +#endif void setOffsetX(f32 i_offsetX) { mOffsetX = i_offsetX; } bool isAnimeUpdate(int param_0) { return (field_0x114 & (u8)(1 << param_0)) ? TRUE : FALSE; } 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_particle.h b/include/d/d_particle.h index c9db174fcd..7ae4d12c07 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 @@ -495,20 +495,20 @@ 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; @@ -521,13 +521,13 @@ private: /* 0x019 */ u8 field_0x19; /* 0x01A */ u8 field_0x1a; /* 0x01B */ u8 field_0x1b; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x01C */ dPa_simpleEcallBack field_0x1c[48]; #else /* 0x01C */ dPa_simpleEcallBack field_0x1c[25]; #endif /* 0x210 */ level_c field_0x210; - #if DEBUG + #if PARTIAL_DEBUG || DEBUG u8 mSceneCount; #endif }; 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 31d028a082..b70d2d5452 100644 --- a/include/d/d_resorce.h +++ b/include/d/d_resorce.h @@ -59,7 +59,7 @@ private: /* 0x18 */ JKRHeap* heap; /* 0x1C */ JKRSolidHeap* mDataHeap; /* 0x20 */ void** mRes; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x24 */ int mSize; #endif }; // Size: 0x24 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 69d4d3174d..06458890e4 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -8,7 +8,7 @@ #include "d/d_item_data.h" #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JHostIO/JORReflexible.h" -#include "dusk/endian.h" +#include "helpers/endian.h" static const int DEFAULT_SELECT_ITEM_INDEX = 0; static const int MAX_SELECT_ITEM = 4; @@ -494,7 +494,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 +506,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 @@ -1008,7 +1008,7 @@ public: static const int ZONE_MAX = 0x20; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x000 */ u8 unk_0x0; /* 0x001 */ char unk_0x1; /* 0x000 */ u8 unk_0x2[0x48 - 0x2]; @@ -1029,6 +1029,9 @@ public: /* 0xF30 */ s64 mSaveTotalTime; #if DEBUG /* 0xF80 */ flagFile_c mFlagFile; +#elif PARTIAL_DEBUG + // flagFile_c's ctor/virtuals are only defined under #if DEBUG (d_save.cpp) + alignas(flagFile_c) u8 mFlagFile[sizeof(flagFile_c)]; #endif }; // Size: 0xF38 @@ -1046,7 +1049,7 @@ public: #else u16 #endif - static saveBitLabels[822]; + static DUSK_GAME_DATA saveBitLabels[822]; }; class dSv_event_tmp_flag_c { @@ -1055,7 +1058,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..2ee6e4570b 100644 --- a/include/d/d_save_HIO.h +++ b/include/d/d_save_HIO.h @@ -229,6 +229,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_stage.h b/include/d/d_stage.h index a27a9dc9c5..487488d7c6 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -4,7 +4,7 @@ #include "SSystem/SComponent/c_lib.h" #include "d/d_kankyo.h" #include "d/d_kankyo_data.h" -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" #include "f_op/f_op_actor_mng.h" #include "global.h" #include "os_report.h" @@ -538,7 +538,7 @@ public: /* vt[86] */ virtual stage_tgsc_class* getDrTg(void) const = 0; /* vt[87] */ virtual void setDoor(stage_tgsc_class*) = 0; /* vt[88] */ virtual stage_tgsc_class* getDoor(void) const = 0; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG virtual void setUnit(void*) = 0; virtual void* getUnit() = 0; #endif @@ -796,7 +796,7 @@ public: virtual stage_tgsc_class* getDrTg(void) const { return mDrTg; } virtual void setDoor(stage_tgsc_class* i_Door) { mDoor = i_Door; } virtual stage_tgsc_class* getDoor(void) const { return mDoor; } -#if DEBUG +#if PARTIAL_DEBUG || DEBUG virtual void setUnit(void* i_Unit) { mUnit = i_Unit; } virtual void* getUnit() { return mUnit; } #endif @@ -845,7 +845,7 @@ public: /* 0x54 */ stage_tgsc_class* mDrTg; /* 0x58 */ stage_tgsc_class* mDoor; /* 0x5C */ dStage_FloorInfo_c* mFloorInfo; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x60 */ void* mUnit; #endif /* 0x60 */ u16 mPlayerNum; @@ -990,7 +990,7 @@ public: /* vt[86] */ virtual stage_tgsc_class* getDrTg(void) const { return mDrTg; } /* vt[87] */ virtual void setDoor(stage_tgsc_class* i_Door) { mDoor = i_Door; } /* vt[88] */ virtual stage_tgsc_class* getDoor(void) const { return mDoor; } -#if DEBUG +#if PARTIAL_DEBUG || DEBUG virtual void setUnit(void* i_Unit) { UNUSED(i_Unit); OSReport("stage non unit list data !!\n"); @@ -1237,20 +1237,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() { diff --git a/include/d/d_timer.h b/include/d/d_timer.h index 9d3bd7ce1f..104a4cae9e 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); diff --git a/include/d/d_tresure.h b/include/d/d_tresure.h index 236e2690c6..e043dd94fb 100644 --- a/include/d/d_tresure.h +++ b/include/d/d_tresure.h @@ -2,7 +2,7 @@ #define D_D_TRESURE_H #include -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" class dTres_c { public: @@ -113,10 +113,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 4018acea50..b61d0099b4 100644 --- a/include/d/d_vibration.h +++ b/include/d/d_vibration.h @@ -89,14 +89,17 @@ 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 + // dVibTest_c's ctor/virtuals are only defined under #if DEBUG (d_vibration.cpp) + alignas(dVibTest_c) u8 mVibTest[sizeof(dVibTest_c)]; #endif class { @@ -130,7 +133,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/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/texture_replacements.hpp b/include/dusk/texture_replacements.hpp deleted file mode 100644 index ffb3fe8d62..0000000000 --- a/include/dusk/texture_replacements.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DUSK_TEXTURE_REPLACEMENTS_HPP -#define DUSK_TEXTURE_REPLACEMENTS_HPP - -namespace dusk::texture_replacements { - -void reload(); -void set_enabled(bool enabled); -void shutdown(); - -} - -#endif 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..1dce990866 100644 --- a/include/f_op/f_op_actor.h +++ b/include/f_op/f_op_actor.h @@ -332,7 +332,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 +431,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..6461c823d1 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -12,7 +12,7 @@ #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" +#include "helpers/endian_ssystem.h" #if !__MWERKS__ // mwerks compiler makes value initialization act like default initialization so we need @@ -50,14 +50,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 { @@ -826,8 +826,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 +854,7 @@ public: return cBgW_CheckBGround(poly.mNormal.y); } - static dBgS_ObjLinChk mLineCheck; + static DUSK_GAME_DATA dBgS_ObjLinChk mLineCheck; }; class dBgS_RoofChk; @@ -864,16 +864,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 +900,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..21694f0af1 100644 --- a/include/f_op/f_op_msg.h +++ b/include/f_op/f_op_msg.h @@ -36,7 +36,7 @@ struct msg_class { /* 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_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_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_node_req.h b/include/f_pc/f_pc_node_req.h index d710379c89..880e733ac9 100644 --- a/include/f_pc/f_pc_node_req.h +++ b/include/f_pc/f_pc_node_req.h @@ -36,7 +36,7 @@ typedef struct node_create_request { /* 0x58 */ s16 name; /* 0x5C */ void* data; /* 0x60 */ s16 unk_0x60; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x64 */ int unk_0x64; /* 0x68 */ int unk_0x68; #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 2a8e182bfa..f77694c133 100644 --- a/include/global.h +++ b/include/global.h @@ -114,6 +114,15 @@ inline int __builtin_clz(unsigned int v) { #endif +// 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_DATA __declspec(dllimport) +#else +#define DUSK_GAME_DATA +#endif +#define DUSK_GAME_EXTERN extern DUSK_GAME_DATA + #define FAST_DIV(x, n) (x >> (n / 2)) #define SQUARE(x) ((x) * (x)) 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/include/helpers/batch.hpp b/include/helpers/batch.hpp new file mode 100644 index 0000000000..0eaeb17a2c --- /dev/null +++ b/include/helpers/batch.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include + +namespace batch { + +struct LeafTemplate { + static constexpr u32 kMaxVtx = 192; + static constexpr u32 kMaxPosRefs = 64; + + struct Vtx { + u8 pos; + u8 nrm; + u8 clr; + u8 tex; + }; + Vtx vtx[kMaxVtx]; + u16 vtxCount = 0; + u8 posRefs[kMaxPosRefs]; + u8 posRefCount = 0; +}; + +void decode_leaf_template(const u8* dl, u32 size, LeafTemplate& out); + +} // namespace batch 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 bf5f3c4d3a..32cf340ed5 100644 --- a/include/dusk/gx_helper.h +++ b/include/helpers/gx_helper.h @@ -1,11 +1,17 @@ -#ifndef DUSK_GX_HELPER_H -#define DUSK_GX_HELPER_H +#pragma once #include #include #include -#include "tracy/Tracy.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, ...) \ @@ -78,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..555d7a6a9f 100644 --- a/include/m_Do/m_Do_MemCard.h +++ b/include/m_Do/m_Do_MemCard.h @@ -130,7 +130,7 @@ 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(); 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 4bc2f20c94..43d0b81766 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -4,20 +4,24 @@ #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: void reset(); mDoAud_zelAudio_c() { -#if DEBUG +#if PARTIAL_DEBUG || DEBUG setMode(2); #endif } ~mDoAud_zelAudio_c() {} -#if DEBUG +#if PARTIAL_DEBUG || DEBUG u8 getMode() { return field_0x13bd; } void setMode(u8 mode) { field_0x13bd = mode; } @@ -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..bd1baac2df 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 { @@ -840,7 +840,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 +889,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_hostIO.h b/include/m_Do/m_Do_hostIO.h index fa4eb8b1af..d88a0a9853 100644 --- a/include/m_Do/m_Do_hostIO.h +++ b/include/m_Do/m_Do_hostIO.h @@ -35,6 +35,11 @@ public: /* 0x4 */ s8 mNo; /* 0x5 */ u8 mCount; #else +#if PARTIAL_DEBUG + // Initialized here since the DEBUG ctor doesn't run. + /* 0x4 */ s8 mNo = -1; + /* 0x5 */ u8 mCount = 0; +#endif virtual ~mDoHIO_entry_c() {} #endif }; diff --git a/include/m_Do/m_Do_lib.h b/include/m_Do/m_Do_lib.h index f194a4591b..6b85cc0660 100644 --- a/include/m_Do/m_Do_lib.h +++ b/include/m_Do/m_Do_lib.h @@ -8,7 +8,7 @@ #include "JSystem/JGeometry.h" #endif -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" typedef struct Vec Vec; struct ResTIMG; @@ -37,9 +37,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..89e7e8b7cf 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -6,10 +6,10 @@ #include #include "JSystem/JMath/JMath.h" -#include "dusk/endian.h" +#include "helpers/endian.h" 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 +373,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..a71669f432 100644 --- a/include/m_Do/m_Do_printf.h +++ b/include/m_Do/m_Do_printf.h @@ -2,7 +2,7 @@ #define M_DO_M_DO_PRINTF_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" void my_PutString(const char*); void mDoPrintf_vprintf_Interrupt(char const*, va_list); 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/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 b054c97fae..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; @@ -212,6 +212,9 @@ public: void setCornerColor(JUtility::TColor c0) { setCornerColor(c0, c0, c0, c0); } +#if TARGET_PC + JUtility::TColor corner(size_t index) const { return mCornerColor[index]; } +#endif protected: /* 0x100 */ JUTTexture* mTexture[2]; 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..d55bb82465 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 { @@ -106,12 +105,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; } 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..5b05b08bcc 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 @@ -85,7 +85,7 @@ public: } }; -extern J3DTexMtxInfo const j3dDefaultTexMtxInfo; +DUSK_GAME_EXTERN J3DTexMtxInfo const j3dDefaultTexMtxInfo; /** * @ingroup jsystem-j3d @@ -117,7 +117,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..05fc99785b 100644 --- a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h +++ b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DModelData; class J3DMaterialTable; 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/JORReflexible.h b/libs/JSystem/include/JSystem/JHostIO/JORReflexible.h index 533a3184ba..84894de275 100644 --- a/libs/JSystem/include/JSystem/JHostIO/JORReflexible.h +++ b/libs/JSystem/include/JSystem/JHostIO/JORReflexible.h @@ -12,12 +12,23 @@ struct JORNodeEvent; class JORMContext; class JORServer; +// NOTE (stable game ABI): these classes stay non-polymorphic outside DEBUG +// on purpose. Making them polymorphic under PARTIAL_DEBUG would give every one of the ~250 +// derived HIO classes a vptr and turn their plain `void genMessage(JORMContext*);` +// declarations into implicit virtual overrides whose definitions are #if DEBUG-gated; every +// instantiated one then fails to link (missing vtable). Closure types shared with DEBUG TUs +// either declare their own unconditional virtuals (vptr in all TUs anyway) or add a +// PARTIAL_DEBUG-only virtual dtor for vptr parity (see dAttParam_c). class JOREventListener { public: #if DEBUG JOREventListener() {} +#if TARGET_PC + virtual void listenPropertyEvent(const JORPropertyEvent*) {} +#else virtual void listenPropertyEvent(const JORPropertyEvent*) = 0; #endif +#endif }; class JORReflexible : public JOREventListener { @@ -30,7 +41,11 @@ public: virtual void listenPropertyEvent(const JORPropertyEvent*); virtual void listen(u32, const JOREvent*); virtual void genObjectInfo(const JORGenEvent*); +#if TARGET_PC + virtual void genMessage(JORMContext*) {} +#else virtual void genMessage(JORMContext*) = 0; +#endif virtual void listenNodeEvent(const JORNodeEvent*); #endif }; 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..4ac5de7a46 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRArchive.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRArchive.h @@ -4,7 +4,7 @@ #include "JSystem/JKernel/JKRCompression.h" #include "JSystem/JKernel/JKRFileLoader.h" #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class JKRHeap; @@ -242,7 +242,7 @@ public: static void setCurrentDirID(u32 dirID) { sCurrentDirID = dirID; } protected: - static u32 sCurrentDirID; + static DUSK_GAME_DATA u32 sCurrentDirID; }; inline JKRCompression JKRConvertAttrToCompressionType(int attr) { 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..ace28de6e3 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h @@ -11,12 +11,12 @@ 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 +194,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/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 795a5a2628..84fc657387 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h +++ b/libs/JSystem/include/JSystem/JParticle/JPABaseShape.h @@ -3,6 +3,20 @@ #include +#if TARGET_PC +#include + +struct ParticleDrawCtx { + bool batch; // off = immediate mode + bool useTexMtx; // UVs transformed by texMtx + bool useClr0; // prm color in GX_VA_CLR0 + bool useClr1; // env color in GX_VA_CLR1 + Mtx texMtx; + GXColor clr0; + GXColor clr1; +}; +#endif + struct JPAEmitterWorkData; class JPABaseParticle; class JKRHeap; @@ -49,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]; } @@ -75,6 +89,9 @@ public: const GXTevColorArg* getTevColorArg() const { return st_ca[(pBsd->mFlags >> 0x0F) & 0x07]; } const GXTevAlphaArg* getTevAlphaArg() const { return st_aa[(pBsd->mFlags >> 0x12) & 0x01]; } +#if TARGET_PC + u32 getTevColorArgSel() const { return (pBsd->mFlags >> 0x0F) & 0x07; } +#endif u32 getType() const { return (pBsd->mFlags >> 0) & 0x0F; } u32 getDirType() const { return (pBsd->mFlags >> 4) & 0x07; } @@ -186,26 +203,34 @@ void JPARegistPrm(JPAEmitterWorkData*); void JPARegistEnv(JPAEmitterWorkData*); void JPARegistPrmEnv(JPAEmitterWorkData*); -void JPADrawPoint(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawLine(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawRotBillboard(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawBillboard(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawRotDirection(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawDirection(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawRotation(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawDBillboard(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawRotYBillboard(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawYBillboard(JPAEmitterWorkData*, JPABaseParticle*); -void JPADrawParticleCallBack(JPAEmitterWorkData*, JPABaseParticle*); -void JPALoadTexAnm(JPAEmitterWorkData*, JPABaseParticle*); -void JPASetPointSize(JPAEmitterWorkData*, JPABaseParticle*); -void JPASetLineWidth(JPAEmitterWorkData*, JPABaseParticle*); -void JPALoadCalcTexCrdMtxAnm(JPAEmitterWorkData*, JPABaseParticle*); -void JPARegistAlpha(JPAEmitterWorkData*, JPABaseParticle*); -void JPARegistEnv(JPAEmitterWorkData*, JPABaseParticle*); -void JPARegistAlphaEnv(JPAEmitterWorkData*, JPABaseParticle*); -void JPARegistPrmAlpha(JPAEmitterWorkData*, JPABaseParticle*); -void JPARegistPrmAlphaEnv(JPAEmitterWorkData*, JPABaseParticle*); +#if TARGET_PC +#define JPA_DRAW_PARTICLE_ARGS JPAEmitterWorkData*, JPABaseParticle*, ParticleDrawCtx* +#else +#define JPA_DRAW_PARTICLE_ARGS JPAEmitterWorkData*, JPABaseParticle* +#endif + +void JPADrawPoint(JPA_DRAW_PARTICLE_ARGS); +void JPADrawLine(JPA_DRAW_PARTICLE_ARGS); +void JPADrawRotBillboard(JPA_DRAW_PARTICLE_ARGS); +void JPADrawBillboard(JPA_DRAW_PARTICLE_ARGS); +void JPADrawRotDirection(JPA_DRAW_PARTICLE_ARGS); +void JPADrawDirection(JPA_DRAW_PARTICLE_ARGS); +void JPADrawRotation(JPA_DRAW_PARTICLE_ARGS); +void JPADrawDBillboard(JPA_DRAW_PARTICLE_ARGS); +void JPADrawRotYBillboard(JPA_DRAW_PARTICLE_ARGS); +void JPADrawYBillboard(JPA_DRAW_PARTICLE_ARGS); +void JPADrawParticleCallBack(JPA_DRAW_PARTICLE_ARGS); +void JPALoadTexAnm(JPA_DRAW_PARTICLE_ARGS); +void JPASetPointSize(JPA_DRAW_PARTICLE_ARGS); +void JPASetLineWidth(JPA_DRAW_PARTICLE_ARGS); +void JPALoadCalcTexCrdMtxAnm(JPA_DRAW_PARTICLE_ARGS); +void JPARegistAlpha(JPA_DRAW_PARTICLE_ARGS); +void JPARegistEnv(JPA_DRAW_PARTICLE_ARGS); +void JPARegistAlphaEnv(JPA_DRAW_PARTICLE_ARGS); +void JPARegistPrmAlpha(JPA_DRAW_PARTICLE_ARGS); +void JPARegistPrmAlphaEnv(JPA_DRAW_PARTICLE_ARGS); + +#undef JPA_DRAW_PARTICLE_ARGS #if TARGET_PC void JPAInterpBillboard(JPAEmitterWorkData*, JPABaseParticle*); 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 ebf2127033..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; @@ -17,6 +17,10 @@ class JPADynamicsBlock; class JPAFieldBlock; class JPAKeyBlock; +#if TARGET_PC +struct ParticleDrawCtx; +#endif + /** * @ingroup jsystem-jparticle * @@ -50,13 +54,19 @@ public: public: typedef void (*EmitterFunc)(JPAEmitterWorkData*); typedef void (*ParticleFunc)(JPAEmitterWorkData*, JPABaseParticle*); +#if TARGET_PC + typedef void (*DrawParticleFunc)(JPAEmitterWorkData*, JPABaseParticle*, + ParticleDrawCtx*); +#else + typedef ParticleFunc DrawParticleFunc; +#endif /* 0x00 */ EmitterFunc* mpCalcEmitterFuncList; /* 0x04 */ EmitterFunc* mpDrawEmitterFuncList; /* 0x08 */ EmitterFunc* mpDrawEmitterChildFuncList; /* 0x0C */ ParticleFunc* mpCalcParticleFuncList; - /* 0x10 */ ParticleFunc* mpDrawParticleFuncList; + /* 0x10 */ DrawParticleFunc* mpDrawParticleFuncList; /* 0x14 */ ParticleFunc* mpCalcParticleChildFuncList; - /* 0x18 */ ParticleFunc* mpDrawParticleChildFuncList; + /* 0x18 */ DrawParticleFunc* mpDrawParticleChildFuncList; /* 0x1C */ JPABaseShape* pBsp; /* 0x20 */ JPAExtraShape* pEsp; @@ -77,6 +87,20 @@ public: /* 0x45 */ u8 mpDrawParticleFuncListNum; /* 0x46 */ u8 mpCalcParticleChildFuncListNum; /* 0x47 */ u8 mpDrawParticleChildFuncListNum; + +#if TARGET_PC + struct BatchInfo { + f32 vtxPos[8][3]; + f32 vtxUv[8][2]; + u8 vtxCount; // 4 (quad) or 8 (cross) + bool supported; // draw func list contains only batchable funcs + bool hasPtclColor; // per-particle JPARegist* func is present + bool hasPtclTexMtx; // JPALoadCalcTexCrdMtxAnm is present + }; + BatchInfo mBatchInfo; + + void initBatchInfo(); +#endif }; #endif /* JPARESOURCE_H */ 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/functionvalue.h b/libs/JSystem/include/JSystem/JStudio/JStudio/functionvalue.h index 7b2c935272..8acdbe1623 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/functionvalue.h @@ -314,7 +314,7 @@ public: > { TIterator_data_(const TFunctionValue_list_parameter& rParent, const f32* value) { -#if DEBUG +#if PARTIAL_DEBUG || DEBUG pOwn_ = &rParent; #endif pf_ = value; @@ -372,7 +372,7 @@ public: return (r1.pf_ - r2.pf_) / suData_size; } -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x00 */ const TFunctionValue_list_parameter* pOwn_; #endif /* 0x00 */ const f32* pf_; @@ -425,7 +425,7 @@ public: > { TIterator_data_(const TFunctionValue_hermite& rParent, const f32* value) { -#if DEBUG +#if PARTIAL_DEBUG || DEBUG pOwn_ = &rParent; #endif pf_ = value; @@ -491,7 +491,7 @@ public: return (r1.pf_ - r2.pf_) / r1.uSize_; } -#if DEBUG +#if PARTIAL_DEBUG || DEBUG /* 0x00 */ const TFunctionValue_hermite* pOwn_; /* 0x04 */ const f32* pf_; /* 0x08 */ u32 uSize_; 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 8c895d5077..51f3951e38 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" + +#if TARGET_PC #include "dusk/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) @@ -105,6 +108,11 @@ void J3DModel::interp_callback(bool isSimFrame, void* pUserWork) { i_this->diff(); } } + +void J3DModel::setAnmMtx(int jointNo, Mtx m) { + mMtxBuffer->setAnmMtx(jointNo, m); + dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); +} #endif s32 J3DModel::createShapePacket(J3DModelData* pModelData) { @@ -542,8 +550,11 @@ void J3DModel::viewCalc() { } #ifdef TARGET_PC - for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(getDrawMtxPtr()[i]); + Mtx* drawMtx = getDrawMtxPtr(); + if (drawMtx != J3DMtxBuffer::sNoUseDrawMtxPtr) { + for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { + dusk::frame_interp::record_final_mtx(drawMtx[i]); + } } #endif 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..40c523643e 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp @@ -205,17 +205,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/J3DPacket.cpp b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp index 9e28a7f7cb..f87283df47 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp @@ -68,9 +68,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(); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp index fc7ac5b727..22eb76a533 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp @@ -136,8 +136,8 @@ void J3DLoadCPCmd(u8 addr, u32 val) { #if TARGET_PC static void J3DLoadArrayBasePtr(GXAttr attr, void* data, u32 size, bool le) { u32 idx = (attr == GX_VA_NBT) ? 1 : (attr - GX_VA_POS); - GXCmd1u8(GX_LOAD_AURORA); - GXCmd1u16(GX_LOAD_AURORA_ARRAYBASE | idx); + GXCmd1u8(GX_AURORA); + GXCmd1u16(GX_AURORA_LOAD_ARRAYBASE | idx); GXCmd1u64((u64)data); GXCmd1u32(size); GXCmd1u8(le ? 1 : 0); @@ -289,7 +289,7 @@ void J3DShape::makeVcdVatCmd() { OSRestoreInterrupts(sInterruptFlag); } -void* J3DShape::sOldVcdVatCmd; +DUSK_GAME_DATA void* J3DShape::sOldVcdVatCmd; void J3DShape::loadCurrentMtx() const { mCurrentMtx.load(); @@ -304,7 +304,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/J3DShapeDraw.cpp b/libs/JSystem/src/J3DGraphBase/J3DShapeDraw.cpp index b40f577d79..e9abdc85f1 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShapeDraw.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShapeDraw.cpp @@ -7,265 +7,11 @@ #include "JSystem/JKernel/JKRHeap.h" #if TARGET_PC -#include +#include #include -#include -#include "dusk/logging.h" namespace { -u16 read_be16(const u8* data) { - return (u16(data[0]) << 8) | data[1]; -} - -void append_be16(std::vector& out, u16 value) { - out.push_back(value >> 8); - out.push_back(value & 0xFF); -} - -void append_bytes(std::vector& out, const u8* data, u32 size) { - out.insert(out.end(), data, data + size); -} - -bool is_matrix_idx_attr(GXAttr attr) { - return attr >= GX_VA_PNMTXIDX && attr <= GX_VA_TEX7MTXIDX; -} - -bool is_draw_opcode(u8 opcode) { - return opcode == GX_QUADS || opcode == GX_TRIANGLES || opcode == GX_TRIANGLESTRIP || - opcode == GX_TRIANGLEFAN || opcode == GX_LINES || opcode == GX_LINESTRIP || - opcode == GX_POINTS; -} - -bool is_mergeable_draw_opcode(u8 opcode) { - return opcode == GX_QUADS || opcode == GX_TRIANGLES || opcode == GX_TRIANGLESTRIP || - opcode == GX_TRIANGLEFAN; -} - -bool calc_vtx_stride(const GXVtxDescList* vtxDesc, u32& stride) { - stride = 0; - for (; vtxDesc->attr != GX_VA_NULL; vtxDesc++) { - switch (vtxDesc->type) { - case GX_NONE: - break; - case GX_DIRECT: - if (!is_matrix_idx_attr(vtxDesc->attr)) { - return false; - } - stride += 1; - break; - case GX_INDEX8: - stride += 1; - break; - case GX_INDEX16: - stride += 2; - break; - default: - return false; - } - } - return stride != 0; -} - -bool get_command_size(const u8* dlStart, u32 dlSize, u32 offset, u32 stride, u32& cmdSize) { - if (offset >= dlSize) { - return false; - } - - const u8 cmd = dlStart[offset]; - const u8 opcode = cmd & GX_OPCODE_MASK; - switch (opcode) { - case GX_NOP: - case GX_CMD_INVL_VC: - cmdSize = 1; - return true; - case (GX_LOAD_BP_REG & GX_OPCODE_MASK): - cmdSize = 5; - return offset + cmdSize <= dlSize; - case GX_LOAD_CP_REG: - cmdSize = 6; - return offset + cmdSize <= dlSize; - case GX_LOAD_XF_REG: { - if (offset + 5 > dlSize) { - return false; - } - const u16 count = read_be16(dlStart + offset + 1) + 1; - cmdSize = 5 + count * 4; - return offset + cmdSize <= dlSize; - } - case GX_LOAD_INDX_A: - case GX_LOAD_INDX_B: - case GX_LOAD_INDX_C: - case GX_LOAD_INDX_D: - cmdSize = 5; - return offset + cmdSize <= dlSize; - case GX_CMD_CALL_DL: - cmdSize = 9; - return offset + cmdSize <= dlSize; - default: - if (is_draw_opcode(opcode)) { - if (offset + 3 > dlSize) { - return false; - } - const u16 vtxCount = read_be16(dlStart + offset + 1); - cmdSize = 3 + vtxCount * stride; - return offset + cmdSize <= dlSize; - } - return false; - } -} - -struct MergeRun { - u8 cmd = 0; - u16 vtxCount = 0; - std::vector vertices; -}; - -void flush_merge_run(std::vector& out, MergeRun& run) { - if (run.vtxCount == 0) { - return; - } - - out.push_back(run.cmd); - append_be16(out, run.vtxCount); - append_bytes(out, run.vertices.data(), run.vertices.size()); - run.vertices.clear(); - run.vtxCount = 0; -} - -void append_vertex(std::vector& out, const u8* vertices, u32 stride, u16 idx) { - append_bytes(out, vertices + idx * stride, stride); -} - -bool triangulate_draw( - std::vector& out, u8 opcode, const u8* vertices, u32 stride, u16 vtxCount) { - switch (opcode) { - case GX_TRIANGLES: - append_bytes(out, vertices, vtxCount * stride); - return true; - case GX_TRIANGLEFAN: - if (vtxCount < 3) { - return false; - } - for (u16 v = 2; v < vtxCount; v++) { - append_vertex(out, vertices, stride, 0); - append_vertex(out, vertices, stride, v - 1); - append_vertex(out, vertices, stride, v); - } - return true; - case GX_TRIANGLESTRIP: - if (vtxCount < 3) { - return false; - } - for (u16 v = 2; v < vtxCount; v++) { - if ((v & 1) == 0) { - append_vertex(out, vertices, stride, v - 2); - append_vertex(out, vertices, stride, v - 1); - } else { - append_vertex(out, vertices, stride, v - 1); - append_vertex(out, vertices, stride, v - 2); - } - append_vertex(out, vertices, stride, v); - } - return true; - case GX_QUADS: - if ((vtxCount & 3) != 0) { - return false; - } - for (u16 v = 0; v < vtxCount; v += 4) { - append_vertex(out, vertices, stride, v); - append_vertex(out, vertices, stride, v + 1); - append_vertex(out, vertices, stride, v + 2); - append_vertex(out, vertices, stride, v + 2); - append_vertex(out, vertices, stride, v + 3); - append_vertex(out, vertices, stride, v); - } - return true; - default: - return false; - } -} - -void append_triangles_to_run( - std::vector& out, MergeRun& run, u8 cmd, const std::vector& vertices, u32 stride) { - u32 offset = 0; - u32 remaining = vertices.size() / stride; - while (remaining != 0) { - if (run.vtxCount != 0 && run.cmd != cmd) { - flush_merge_run(out, run); - } - - if (run.vtxCount == 0) { - run.cmd = cmd; - } - - u32 available = 0xFFFF - run.vtxCount; - if (available == 0) { - flush_merge_run(out, run); - continue; - } - - u32 toCopy = std::min(remaining, available); - append_bytes(run.vertices, vertices.data() + offset * stride, toCopy * stride); - run.vtxCount += toCopy; - offset += toCopy; - remaining -= toCopy; - - if (run.vtxCount == 0xFFFF) { - flush_merge_run(out, run); - } - } -} - -bool optimize_display_list(const u8* dlStart, u32 dlSize, u32 stride, std::vector& out) { - MergeRun run; - out.reserve(dlSize); - - for (u32 offset = 0; offset < dlSize;) { - u32 cmdSize = 0; - if (!get_command_size(dlStart, dlSize, offset, stride, cmdSize)) { - return false; - } - - const u8 cmd = dlStart[offset]; - const u8 opcode = cmd & GX_OPCODE_MASK; - if (opcode == GX_NOP) { - offset += cmdSize; - continue; - } - - if (!is_draw_opcode(opcode)) { - flush_merge_run(out, run); - append_bytes(out, dlStart + offset, cmdSize); - offset += cmdSize; - continue; - } - - if (!is_mergeable_draw_opcode(opcode)) { - flush_merge_run(out, run); - append_bytes(out, dlStart + offset, cmdSize); - offset += cmdSize; - continue; - } - - const u16 vtxCount = read_be16(dlStart + offset + 1); - const u8* vertices = dlStart + offset + 3; - std::vector triangles; - if (!triangulate_draw(triangles, opcode, vertices, stride, vtxCount)) { - flush_merge_run(out, run); - append_bytes(out, dlStart + offset, cmdSize); - offset += cmdSize; - continue; - } - - append_triangles_to_run(out, run, (GX_TRIANGLES | (cmd & GX_VAT_MASK)), triangles, stride); - offset += cmdSize; - } - - flush_merge_run(out, run); - return true; -} - void set_display_list_copy(void*& displayList, u32& displayListSize, const u8* data, u32 size) { const u32 alignedSize = ALIGN_NEXT(size, 0x20); u8* newDL = JKR_NEW_ARRAY_ARGS(u8, alignedSize, 0x20); @@ -289,20 +35,11 @@ u32 J3DShapeDraw::countVertex(u32 stride) { u8* dlStart = (u8*)getDisplayList(); #if TARGET_PC - for (u32 offset = 0; offset < getDisplayListSize();) { - u8 cmd = dlStart[offset]; - u8 opcode = cmd & GX_OPCODE_MASK; - u32 cmdSize = 0; - if (!get_command_size(dlStart, getDisplayListSize(), offset, stride, cmdSize)) { - break; + aurora::gx::dl::Reader reader{dlStart, getDisplayListSize(), static_cast(stride)}; + while (const auto cmd = reader.next()) { + if (cmd->kind != aurora::gx::dl::Command::Kind::Passthrough) { + count += cmd->draw.vtxCount; } - if (!is_draw_opcode(opcode)) { - offset += cmdSize; - continue; - } - int vtxNum = be16(*reinterpret_cast(dlStart + offset + 1)); - count += vtxNum; - offset += 3 + stride * vtxNum; } #else for (u8* dl = dlStart; (dl - dlStart) < getDisplayListSize();) { @@ -320,6 +57,53 @@ u32 J3DShapeDraw::countVertex(u32 stride) { return count; } +#if TARGET_PC +void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) { + u32 byteNum = countVertex(stride); + u32 oldSize = mDisplayListSize; + u32 newSize = ALIGN_NEXT(oldSize + byteNum, 0x20); + u8* newDLStart = JKR_NEW_ARRAY_ARGS(u8, newSize, 0x20); + u8* oldDLStart = (u8*)mDisplayList; + u8* newDL = newDLStart; + + aurora::gx::dl::Reader reader{oldDLStart, mDisplayListSize, static_cast(stride)}; + while (const auto cmd = reader.next()) { + if (cmd->kind == aurora::gx::dl::Command::Kind::Passthrough) { + std::memcpy(newDL, cmd->data, cmd->size); + newDL += cmd->size; + continue; + } + + const auto& draw = cmd->draw; + const u32 headerSize = draw.vertices - cmd->data; + std::memcpy(newDL, cmd->data, headerSize); + newDL += headerSize; + + for (u32 i = 0; i < draw.vtxCount; i++) { + const u8* oldVtx = draw.vertices + stride * i; + u8 pnmtxidx = oldVtx[0]; + std::memcpy(newDL, oldVtx, attrOffs); + newDL += attrOffs; + *newDL++ = valueBase + pnmtxidx; + std::memcpy(newDL, oldVtx + attrOffs, stride - attrOffs); + newDL += stride - attrOffs; + } + } + if (reader.failed()) { + // preserve the remainder untouched + std::memcpy(newDL, oldDLStart + reader.pos(), mDisplayListSize - reader.pos()); + newDL += mDisplayListSize - reader.pos(); + } + + u32 realSize = ALIGN_NEXT((uintptr_t)newDL - (uintptr_t)newDLStart, 0x20); + for (; (newDL - newDLStart) < newSize; newDL++) + *newDL = 0; + + mDisplayListSize = realSize; + mDisplayList = newDLStart; + DCStoreRange(newDLStart, mDisplayListSize); +} +#else void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) { u32 byteNum = countVertex(stride); u32 oldSize = mDisplayListSize; @@ -330,32 +114,13 @@ void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) { u8* newDL = newDLStart; for (; (oldDL - oldDLStart) < mDisplayListSize;) { -#if TARGET_PC - u32 oldOffset = oldDL - oldDLStart; - u32 cmdSize = 0; - if (!get_command_size(oldDLStart, mDisplayListSize, oldOffset, stride, cmdSize)) { - memcpy(newDL, oldDL, mDisplayListSize - oldOffset); - newDL += mDisplayListSize - oldOffset; - break; - } -#endif // Copy command u8 cmd = *(u8*)oldDL; oldDL++; *newDL++ = cmd; -#if TARGET_PC - u8 opcode = cmd & GX_OPCODE_MASK; - if (!is_draw_opcode(opcode)) { - memcpy(newDL, oldDL, cmdSize - 1); - oldDL += cmdSize - 1; - newDL += cmdSize - 1; - continue; - } -#else if (cmd != GX_TRIANGLEFAN && cmd != GX_TRIANGLESTRIP) break; -#endif // Copy count int vtxNum = *(u16*)oldDL; @@ -384,6 +149,7 @@ void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) { mDisplayList = newDLStart; DCStoreRange(newDLStart, mDisplayListSize); } +#endif J3DShapeDraw::J3DShapeDraw(const u8* displayList, u32 displayListSize) { #if TARGET_PC @@ -397,12 +163,8 @@ J3DShapeDraw::J3DShapeDraw(const u8* displayList, u32 displayListSize) { #if TARGET_PC J3DShapeDraw::J3DShapeDraw( const u8* displayList, u32 displayListSize, const GXVtxDescList* vtxDesc) { - u32 stride = 0; - std::vector optimized; - if (calc_vtx_stride(vtxDesc, stride) && - optimize_display_list(displayList, displayListSize, stride, optimized)) - { - set_display_list_copy(mDisplayList, mDisplayListSize, optimized.data(), optimized.size()); + if (const auto optimized = aurora::gx::dl::optimize(displayList, displayListSize, vtxDesc)) { + set_display_list_copy(mDisplayList, mDisplayListSize, optimized->data(), optimized->size()); } else { set_display_list_copy(mDisplayList, mDisplayListSize, displayList, displayListSize); } diff --git a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp index d9af135999..41d2e96ef0 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp @@ -8,7 +8,7 @@ #include "JSystem/J3DGraphBase/J3DTexture.h" #include "dusk/frame_interpolation.h" -u16 J3DShapeMtx::sMtxLoadCache[10]; +DUSK_GAME_DATA u16 J3DShapeMtx::sMtxLoadCache[10]; #ifdef TARGET_PC static void J3DFrameInterpConcat(MtxP lhs, MtxP rhs, Mtx out) { @@ -54,42 +54,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..bdacff4276 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp @@ -4,24 +4,28 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "global.h" #include "tracy/Tracy.hpp" -J3DSys j3dSys; +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif -Mtx J3DSys::mCurrentMtx; +DUSK_GAME_DATA J3DSys j3dSys; -Vec J3DSys::mCurrentS; +DUSK_GAME_DATA Mtx J3DSys::mCurrentMtx; -Vec J3DSys::mParentS; +DUSK_GAME_DATA Vec J3DSys::mCurrentS; -J3DTexCoordScaleInfo J3DSys::sTexCoordScaleTable[8]; +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 +39,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 +374,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::frame_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..1bfb22e73e 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DTevs.cpp @@ -315,7 +315,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 +323,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 +341,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 +399,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 +417,7 @@ void makeAlphaCmpTable() { } } -u8 j3dZModeTable[96]; +DUSK_GAME_DATA u8 j3dZModeTable[96]; void makeZModeTable() { u8* table = j3dZModeTable; @@ -495,44 +495,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/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..545b0d41dc 100644 --- a/libs/JSystem/src/JAudio2/JASAiCtrl.cpp +++ b/libs/JSystem/src/JAudio2/JASAiCtrl.cpp @@ -20,33 +20,33 @@ #include "tracy/Tracy.hpp" -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 +114,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 +227,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..a99c13ce63 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), 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..87a88adca0 100644 --- a/libs/JSystem/src/JAudio2/JASDriverIF.cpp +++ b/libs/JSystem/src/JAudio2/JASDriverIF.cpp @@ -9,7 +9,7 @@ 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,7 +23,7 @@ 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; @@ -40,11 +40,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/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..0c26e77a53 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -14,11 +14,12 @@ #ifdef TARGET_PC #include "dusk/dusk.h" -#include "dusk/gx_helper.h" +#include "dusk/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" #include "dusk/time.h" #include "f_op/f_op_overlap_mng.h" +#include "helpers/gx_helper.h" #include "SDL3/SDL_timer.h" #include "tracy/Tracy.hpp" @@ -65,7 +66,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) { @@ -428,7 +429,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 +452,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/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..a14ab763b0 100644 --- a/libs/JSystem/src/JKernel/JKRArchivePri.cpp +++ b/libs/JSystem/src/JKernel/JKRArchivePri.cpp @@ -9,7 +9,7 @@ #include #endif -u32 JKRArchive::sCurrentDirID; +DUSK_GAME_DATA u32 JKRArchive::sCurrentDirID; JKRArchive::JKRArchive() { mIsMounted = false; 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/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/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/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/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 add61135fe..c47d978b00 100644 --- a/libs/JSystem/src/JParticle/JPABaseShape.cpp +++ b/libs/JSystem/src/JParticle/JPABaseShape.cpp @@ -14,6 +14,33 @@ #endif #include "tracy/Tracy.hpp" +#if TARGET_PC +#define JPA_DRAW_CTX_PARAM , ParticleDrawCtx* ctx + +namespace { +GXColor emitter_prm_color(JPAEmitterWorkData* work) { + JPABaseEmitter* emtr = work->mpEmtr; + GXColor prm = emtr->mPrmClr; + prm.r = COLOR_MULTI(prm.r, emtr->mGlobalPrmClr.r); + prm.g = COLOR_MULTI(prm.g, emtr->mGlobalPrmClr.g); + prm.b = COLOR_MULTI(prm.b, emtr->mGlobalPrmClr.b); + prm.a = COLOR_MULTI(prm.a, emtr->mGlobalPrmClr.a); + return prm; +} + +GXColor emitter_env_color(JPAEmitterWorkData* work) { + JPABaseEmitter* emtr = work->mpEmtr; + GXColor env = emtr->mEnvClr; + env.r = COLOR_MULTI(env.r, emtr->mGlobalEnvClr.r); + env.g = COLOR_MULTI(env.g, emtr->mGlobalEnvClr.g); + env.b = COLOR_MULTI(env.b, emtr->mGlobalEnvClr.b); + return env; +} +} // namespace +#else +#define JPA_DRAW_CTX_PARAM +#endif + void JPASetPointSize(JPAEmitterWorkData* work) { GXSetPointSize((u8)(25.0f * work->mGlobalPtclScl.x), GX_TO_ONE); } @@ -22,15 +49,16 @@ void JPASetLineWidth(JPAEmitterWorkData* work) { GXSetLineWidth((u8)(25.0f * work->mGlobalPtclScl.x), GX_TO_ONE); } -void JPASetPointSize(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPASetPointSize(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { GXSetPointSize((u8)(ptcl->mParticleScaleX * (25.0f * work->mGlobalPtclScl.x)), GX_TO_ONE); } -void JPASetLineWidth(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPASetLineWidth(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { GXSetLineWidth((u8)(ptcl->mParticleScaleX * (25.0f * work->mGlobalPtclScl.x)), GX_TO_ONE); } void JPARegistPrm(JPAEmitterWorkData* work) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = emtr->mPrmClr; prm.r = COLOR_MULTI(prm.r, emtr->mGlobalPrmClr.r); @@ -41,6 +69,7 @@ void JPARegistPrm(JPAEmitterWorkData* work) { } void JPARegistEnv(JPAEmitterWorkData* work) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor env = emtr->mEnvClr; env.r = COLOR_MULTI(env.r, emtr->mGlobalEnvClr.r); @@ -50,6 +79,7 @@ void JPARegistEnv(JPAEmitterWorkData* work) { } void JPARegistPrmEnv(JPAEmitterWorkData* work) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = emtr->mPrmClr; GXColor env = emtr->mEnvClr; @@ -64,7 +94,8 @@ void JPARegistPrmEnv(JPAEmitterWorkData* work) { GXSetTevColor(GX_TEVREG1, env); } -void JPARegistAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPARegistAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = emtr->mPrmClr; prm.r = COLOR_MULTI(prm.r, emtr->mGlobalPrmClr.r); @@ -72,10 +103,19 @@ void JPARegistAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { prm.b = COLOR_MULTI(prm.b, emtr->mGlobalPrmClr.b); prm.a = COLOR_MULTI(prm.a, emtr->mGlobalPrmClr.a); prm.a = COLOR_MULTI(prm.a, ptcl->mPrmColorAlphaAnm); +#if TARGET_PC + if (ctx->batch) { + ctx->clr0 = prm; + if (ctx->useClr1) { + ctx->clr1 = emitter_env_color(work); + } + return; + } +#endif GXSetTevColor(GX_TEVREG0, prm); } -void JPARegistPrmAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPARegistPrmAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = ptcl->mPrmClr; @@ -84,10 +124,19 @@ void JPARegistPrmAlpha(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { prm.b = COLOR_MULTI(prm.b, emtr->mGlobalPrmClr.b); prm.a = COLOR_MULTI(prm.a, emtr->mGlobalPrmClr.a); prm.a = COLOR_MULTI(prm.a, ptcl->mPrmColorAlphaAnm); +#if TARGET_PC + if (ctx->batch) { + ctx->clr0 = prm; + if (ctx->useClr1) { + ctx->clr1 = emitter_env_color(work); + } + return; + } +#endif GXSetTevColor(GX_TEVREG0, prm); } -void JPARegistPrmAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPARegistPrmAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = ptcl->mPrmClr; @@ -100,11 +149,19 @@ void JPARegistPrmAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { env.r = COLOR_MULTI(env.r, emtr->mGlobalEnvClr.r); env.g = COLOR_MULTI(env.g, emtr->mGlobalEnvClr.g); env.b = COLOR_MULTI(env.b, emtr->mGlobalEnvClr.b); +#if TARGET_PC + if (ctx->batch) { + ctx->clr0 = prm; + ctx->clr1 = env; + return; + } +#endif GXSetTevColor(GX_TEVREG0, prm); GXSetTevColor(GX_TEVREG1, env); } -void JPARegistAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPARegistAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor prm = emtr->mPrmClr; GXColor env = ptcl->mEnvClr; @@ -116,16 +173,31 @@ void JPARegistAlphaEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { env.r = COLOR_MULTI(env.r, emtr->mGlobalEnvClr.r); env.g = COLOR_MULTI(env.g, emtr->mGlobalEnvClr.g); env.b = COLOR_MULTI(env.b, emtr->mGlobalEnvClr.b); +#if TARGET_PC + if (ctx->batch) { + ctx->clr0 = prm; + ctx->clr1 = env; + return; + } +#endif GXSetTevColor(GX_TEVREG0, prm); GXSetTevColor(GX_TEVREG1, env); } -void JPARegistEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPARegistEnv(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { + ZoneScoped; JPABaseEmitter* emtr = work->mpEmtr; GXColor env = ptcl->mEnvClr; env.r = COLOR_MULTI(env.r, emtr->mGlobalEnvClr.r); env.g = COLOR_MULTI(env.g, emtr->mGlobalEnvClr.g); env.b = COLOR_MULTI(env.b, emtr->mGlobalEnvClr.b); +#if TARGET_PC + if (ctx->batch) { + ctx->clr0 = emitter_prm_color(work); + ctx->clr1 = env; + return; + } +#endif GXSetTevColor(GX_TEVREG1, env); } @@ -258,7 +330,7 @@ void JPAGenCalcTexCrdMtxAnm(JPAEmitterWorkData* work) { GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX0); } -void JPALoadCalcTexCrdMtxAnm(JPAEmitterWorkData* work, JPABaseParticle* param_1) { +void JPALoadCalcTexCrdMtxAnm(JPAEmitterWorkData* work, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { ZoneScoped; JPABaseShape* shape = work->mpRes->getBsp(); f32 dVar16 = param_1->mAge; @@ -286,6 +358,12 @@ void JPALoadCalcTexCrdMtxAnm(JPAEmitterWorkData* work, JPABaseParticle* param_1) local_108[2][1] = 0.0f; local_108[2][2] = 1.0f; local_108[2][3] = 0.0f; +#if TARGET_PC + if (ctx->batch) { + MTXCopy(local_108, ctx->texMtx); + return; + } +#endif GXLoadTexMtxImm(local_108, 0x1e, GX_MTX2x4); } @@ -299,7 +377,7 @@ void JPALoadTexAnm(JPAEmitterWorkData* work) { work->mpResMgr->load(work->mpRes->getTexIdx(work->mpEmtr->mTexAnmIdx), GX_TEXMAP0); } -void JPALoadTexAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPALoadTexAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { ZoneScoped; work->mpResMgr->load(work->mpRes->getTexIdx(ptcl->mTexAnmIdx), GX_TEXMAP0); } @@ -429,6 +507,47 @@ static projectionFunc p_prj[3] = { }; #if TARGET_PC +static void emit_batch_quad(JPAEmitterWorkData* work, const ParticleDrawCtx* ctx, + const Mtx posMtx) { + const JPAResource::BatchInfo& info = work->mpRes->mBatchInfo; + + for (int i = 0; i < info.vtxCount; i++) { + Vec localPos = {info.vtxPos[i][0], info.vtxPos[i][1], info.vtxPos[i][2]}; + Vec drawPos; + MTXMultVec(posMtx, &localPos, &drawPos); + + f32 texS = info.vtxUv[i][0]; + f32 texT = info.vtxUv[i][1]; + if (ctx->useTexMtx) { + f32 srcS = texS; + f32 srcT = texT; + texS = ctx->texMtx[0][0] * srcS + ctx->texMtx[0][1] * srcT + ctx->texMtx[0][3]; + texT = ctx->texMtx[1][0] * srcS + ctx->texMtx[1][1] * srcT + ctx->texMtx[1][3]; + } + + GXPosition3f32(drawPos.x, drawPos.y, drawPos.z); + if (ctx->useClr0) { + GXColor4u8(ctx->clr0.r, ctx->clr0.g, ctx->clr0.b, ctx->clr0.a); + } + if (ctx->useClr1) { + GXColor4u8(ctx->clr1.r, ctx->clr1.g, ctx->clr1.b, ctx->clr1.a); + } + GXTexCoord2f32(texS, texT); + } +} + +static void submit_particle_quad( + JPAEmitterWorkData* work, ParticleDrawCtx* ctx, const Mtx posMtx, const u8* dl, u32 dlSize) { + if (ctx->batch) { + emit_batch_quad(work, ctx, posMtx); + return; + } + + GXLoadPosMtxImm(posMtx, GX_PNMTX0); + p_prj[work->mPrjType](work, posMtx); + GXCallDisplayList(dl, dlSize); +} + void JPAInterpBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); @@ -448,7 +567,7 @@ void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { } #endif -void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { if (ptcl->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -473,12 +592,16 @@ void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][2] = 1.0f; posMtx[2][3] = pos.z; posMtx[0][1] = posMtx[0][2] = posMtx[1][0] = posMtx[1][2] = posMtx[2][0] = posMtx[2][1] = 0.0f; +#if TARGET_PC + submit_particle_quad(work, ctx, posMtx, jpa_dl, sizeof(jpa_dl)); +#else GXLoadPosMtxImm(posMtx, GX_PNMTX0); p_prj[work->mPrjType](work, posMtx); GXCallDisplayList(jpa_dl, sizeof(jpa_dl)); +#endif } -void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { if (ptcl->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -517,12 +640,16 @@ void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][2] = 1.0f; posMtx[2][3] = pos.z; posMtx[0][2] = posMtx[1][2] = posMtx[2][0] = posMtx[2][1] = 0.0f; +#if TARGET_PC + submit_particle_quad(work, ctx, posMtx, jpa_dl, sizeof(jpa_dl)); +#else GXLoadPosMtxImm(posMtx, GX_PNMTX0); p_prj[work->mPrjType](work, posMtx); GXCallDisplayList(jpa_dl, sizeof(jpa_dl)); +#endif } -void JPADrawYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) { +void JPADrawYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { if (param_1->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -542,12 +669,16 @@ void JPADrawYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) { local_38[2][2] = work->mYBBCamMtx[2][2]; local_38[2][3] = local_48.z; local_38[0][1] = local_38[0][2] = local_38[1][0] = local_38[2][0] = 0.0f; +#if TARGET_PC + submit_particle_quad(work, ctx, local_38, jpa_dl, sizeof(jpa_dl)); +#else GXLoadPosMtxImm(local_38, GX_PNMTX0); p_prj[work->mPrjType](work, local_38); GXCallDisplayList(jpa_dl, sizeof(jpa_dl)); +#endif } -void JPADrawRotYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) { +void JPADrawRotYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { if (param_1->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -576,9 +707,13 @@ void JPADrawRotYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) { local_38[2][1] = local_94 * fVar1; local_38[2][2] = local_90; local_38[2][3] = local_48.z; +#if TARGET_PC + submit_particle_quad(work, ctx, local_38, jpa_dl, sizeof(jpa_dl)); +#else GXLoadPosMtxImm(local_38, GX_PNMTX0); p_prj[work->mPrjType](work, local_38); GXCallDisplayList(jpa_dl, sizeof(jpa_dl)); +#endif } void dirTypeVel(JPAEmitterWorkData const* work, JPABaseParticle const* param_1, @@ -741,6 +876,88 @@ static u8* p_dl[2] = { }; #if TARGET_PC +static bool make_direction_mtx(JPAEmitterWorkData* work, JPABaseParticle* ptcl, Mtx posMtx) { + JGeometry::TVec3 axisY; + JGeometry::TVec3 axisZ; + JGeometry::TVec3 baseAxis(ptcl->mBaseAxis); + p_direction[work->mDirType](work, ptcl, &axisY); + if (axisY.isZero()) { + return false; + } + + axisY.normalize(); + axisZ.cross(baseAxis, axisY); + if (axisZ.isZero()) { + return false; + } + + axisZ.normalize(); + baseAxis.cross(axisY, axisZ); + baseAxis.normalize(); + ptcl->mBaseAxis.set(baseAxis); + + f32 scaleX = work->mGlobalPtclScl.x * ptcl->mParticleScaleX; + f32 scaleY = work->mGlobalPtclScl.y * ptcl->mParticleScaleY; + posMtx[0][0] = baseAxis.x; + posMtx[0][1] = axisY.x; + posMtx[0][2] = axisZ.x; + posMtx[0][3] = ptcl->mPosition.x; + posMtx[1][0] = baseAxis.y; + posMtx[1][1] = axisY.y; + posMtx[1][2] = axisZ.y; + posMtx[1][3] = ptcl->mPosition.y; + posMtx[2][0] = baseAxis.z; + posMtx[2][1] = axisY.z; + posMtx[2][2] = axisZ.z; + posMtx[2][3] = ptcl->mPosition.z; + p_plane[work->mPlaneType](posMtx, scaleX, scaleY); + return true; +} + +static bool make_rot_direction_mtx(JPAEmitterWorkData* work, JPABaseParticle* ptcl, Mtx posMtx) { + f32 sinRot = JMASSin(ptcl->mRotateAngle); + f32 cosRot = JMASCos(ptcl->mRotateAngle); + JGeometry::TVec3 axisY; + JGeometry::TVec3 axisZ; + JGeometry::TVec3 baseAxis(ptcl->mBaseAxis); + p_direction[work->mDirType](work, ptcl, &axisY); + if (axisY.isZero()) { + return false; + } + + axisY.normalize(); + axisZ.cross(baseAxis, axisY); + if (axisZ.isZero()) { + return false; + } + + axisZ.normalize(); + baseAxis.cross(axisY, axisZ); + baseAxis.normalize(); + ptcl->mBaseAxis.set(baseAxis); + + f32 scaleX = work->mGlobalPtclScl.x * ptcl->mParticleScaleX; + f32 scaleY = work->mGlobalPtclScl.y * ptcl->mParticleScaleY; + Mtx rotMtx; + Mtx dirMtx; + p_rot[work->mRotType](sinRot, cosRot, rotMtx); + p_plane[work->mPlaneType](rotMtx, scaleX, scaleY); + dirMtx[0][0] = baseAxis.x; + dirMtx[0][1] = axisY.x; + dirMtx[0][2] = axisZ.x; + dirMtx[0][3] = ptcl->mPosition.x; + dirMtx[1][0] = baseAxis.y; + dirMtx[1][1] = axisY.y; + dirMtx[1][2] = axisZ.y; + dirMtx[1][3] = ptcl->mPosition.y; + dirMtx[2][0] = baseAxis.z; + dirMtx[2][1] = axisY.z; + dirMtx[2][2] = axisZ.z; + dirMtx[2][3] = ptcl->mPosition.z; + MTXConcat(dirMtx, rotMtx, posMtx); + return true; +} + void JPAInterpDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { JGeometry::TVec3 axisY; JGeometry::TVec3 axisZ; @@ -823,7 +1040,7 @@ void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { } #endif -void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { if (ptcl->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -832,8 +1049,12 @@ void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx posMtx; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, posMtx)) -#endif + if (!dusk::frame_interp::lookup_replacement(ptcl, posMtx) && + !make_direction_mtx(work, ptcl, posMtx)) + { + return; + } +#else { JGeometry::TVec3 axisY; JGeometry::TVec3 axisZ; @@ -869,14 +1090,19 @@ void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][3] = ptcl->mPosition.z; p_plane[work->mPlaneType](posMtx, scaleX, scaleY); } +#endif MTXConcat(work->mPosCamMtx, posMtx, posMtx); +#if TARGET_PC + submit_particle_quad(work, ctx, posMtx, p_dl[work->mDLType], sizeof(jpa_dl)); +#else GXLoadPosMtxImm(posMtx, GX_PNMTX0); p_prj[work->mPrjType](work, posMtx); GXCallDisplayList(p_dl[work->mDLType], sizeof(jpa_dl)); +#endif } -void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { if (ptcl->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -886,8 +1112,12 @@ void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx mtx1; Mtx mtx2; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, mtx1)) -#endif + if (!dusk::frame_interp::lookup_replacement(ptcl, mtx1) && + !make_rot_direction_mtx(work, ptcl, mtx1)) + { + return; + } +#else { f32 sinRot = JMASSin(ptcl->mRotateAngle); f32 cosRot = JMASCos(ptcl->mRotateAngle); @@ -927,13 +1157,18 @@ void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { mtx2[2][3] = ptcl->mPosition.z; MTXConcat(mtx2, mtx1, mtx1); } +#endif MTXConcat(work->mPosCamMtx, mtx1, mtx2); +#if TARGET_PC + submit_particle_quad(work, ctx, mtx2, p_dl[work->mDLType], sizeof(jpa_dl)); +#else GXLoadPosMtxImm(mtx2, GX_PNMTX0); p_prj[work->mPrjType](work, mtx2); GXCallDisplayList(p_dl[work->mDLType], sizeof(jpa_dl)); +#endif } -void JPADrawDBillboard(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) { +void JPADrawDBillboard(JPAEmitterWorkData* param_0, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { if (param_1->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -970,7 +1205,7 @@ void JPADrawDBillboard(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) { GXCallDisplayList(jpa_dl, sizeof(jpa_dl)); } -void JPADrawRotation(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) { +void JPADrawRotation(JPAEmitterWorkData* param_0, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { if (param_1->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -988,12 +1223,16 @@ void JPADrawRotation(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) { auStack_88[1][3] = param_1->mPosition.y; auStack_88[2][3] = param_1->mPosition.z; MTXConcat(param_0->mPosCamMtx, auStack_88, auStack_88); +#if TARGET_PC + submit_particle_quad(param_0, ctx, auStack_88, p_dl[param_0->mDLType], sizeof(jpa_dl)); +#else GXLoadPosMtxImm(auStack_88, 0); p_prj[param_0->mPrjType](param_0, auStack_88); GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl)); +#endif } -void JPADrawPoint(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawPoint(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { if (ptcl->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -1010,7 +1249,7 @@ void JPADrawPoint(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); } -void JPADrawLine(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) { +void JPADrawLine(JPAEmitterWorkData* param_0, JPABaseParticle* param_1 JPA_DRAW_CTX_PARAM) { if (param_1->checkStatus(JPAPtclStts_Invisible)) { return; } @@ -1086,7 +1325,7 @@ void JPADrawStripe(JPAEmitterWorkData* param_0) { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT1, ptcl_num << 1); - for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); + for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); node = node_func(node), coord += step) { param_0->mpCurNode = node; JPABaseParticle* particle = node->getObject(); @@ -1111,7 +1350,7 @@ void JPADrawStripe(JPAEmitterWorkData* param_0) { } particle->mBaseAxis.cross(local_f8, local_104); particle->mBaseAxis.normalize(); - + local_c8[0][0] = local_104.x; local_c8[0][1] = local_f8.x; local_c8[0][2] = particle->mBaseAxis.x; @@ -1177,7 +1416,7 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT1, ptcl_num << 1); - for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); + for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); node = node_func(node), coord += step) { param_0->mpCurNode = node; JPABaseParticle* particle = node->getObject(); @@ -1202,7 +1441,7 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) { } particle->mBaseAxis.cross(local_c0, local_cc); particle->mBaseAxis.normalize(); - + local_90[0][0] = local_cc.x; local_90[0][1] = local_c0.x; local_90[0][2] = particle->mBaseAxis.x; @@ -1227,7 +1466,7 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) { coord = start_coord; GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT1, ptcl_num << 1); - for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); + for (JPANode* node = startNode; node != param_0->mpAlivePtcl->getEnd(); node = node_func(node), coord += step) { param_0->mpCurNode = node; JPABaseParticle* particle = node->getObject(); @@ -1252,7 +1491,7 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) { } particle->mBaseAxis.cross(local_c0, local_cc); particle->mBaseAxis.normalize(); - + local_90[0][0] = local_cc.x; local_90[0][1] = local_c0.x; local_90[0][2] = particle->mBaseAxis.x; @@ -1289,7 +1528,7 @@ void JPADrawEmitterCallBackB(JPAEmitterWorkData* work) { emtr->mpEmtrCallBack->draw(emtr); } -void JPADrawParticleCallBack(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { +void JPADrawParticleCallBack(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_CTX_PARAM) { JPABaseEmitter* emtr = work->mpEmtr; if (emtr->mpPtclCallBack == NULL) { return; @@ -1341,36 +1580,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, @@ -1409,7 +1648,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/JPAParticle.cpp b/libs/JSystem/src/JParticle/JPAParticle.cpp index eb2395e346..99ba95453c 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/frame_interpolation.h" +#endif + JPAParticleCallBack::~JPAParticleCallBack() { /* empty function */ } diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index 59e679d449..b67ac47489 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -18,9 +18,23 @@ #include "global.h" #include "tracy/Tracy.hpp" +#if TARGET_PC +#include "dusk/frame_interpolation.h" + +#define JPA_DRAW_CTX_ARG , &ctx +#else +#define JPA_DRAW_CTX_ARG +#endif + JPAResource::JPAResource() { mpCalcEmitterFuncList = mpDrawEmitterFuncList = mpDrawEmitterChildFuncList = NULL; +#if TARGET_PC + mpCalcParticleFuncList = mpCalcParticleChildFuncList = NULL; + mpDrawParticleFuncList = mpDrawParticleChildFuncList = NULL; + mBatchInfo = {}; +#else mpCalcParticleFuncList = mpDrawParticleFuncList = mpCalcParticleChildFuncList = mpDrawParticleChildFuncList = NULL; +#endif pBsp = NULL; pEsp = NULL; pCsp = NULL; @@ -32,7 +46,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, @@ -56,11 +70,65 @@ 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, }; +#if TARGET_PC +void JPAResource::initBatchInfo() { + mBatchInfo = {}; + + bool hasDrawFunc = false; + for (int i = 0; i < mpDrawParticleFuncListNum; i++) { + DrawParticleFunc func = mpDrawParticleFuncList[i]; + if (func == JPADrawBillboard || func == JPADrawRotBillboard || + func == JPADrawYBillboard || func == JPADrawRotYBillboard || + func == JPADrawDirection || func == JPADrawRotDirection || func == JPADrawRotation) + { + hasDrawFunc = true; + } else if (func == JPADrawParticleCallBack) { + // Batchable only for emitters without a particle callback; checked per draw + } else if (func == JPALoadCalcTexCrdMtxAnm) { + mBatchInfo.hasPtclTexMtx = true; + } else if (func == JPARegistAlpha || func == JPARegistPrmAlpha || + func == JPARegistPrmAlphaEnv || func == JPARegistAlphaEnv || + func == static_cast(JPARegistEnv)) // overloaded + { + mBatchInfo.hasPtclColor = true; + } else { + // JPADrawPoint, JPADrawLine, JPADrawDBillboard, JPALoadTexAnm, + // JPASetPointSize, JPASetLineWidth + return; + } + } + if (!hasDrawFunc) { + return; + } + + // Template array offsets, same math as setPTev + int base_plane_type = (pBsp->getType() == 3 || pBsp->getType() == 7) ? + pBsp->getBasePlaneType() : 0; + int center_offset = pEsp != nullptr ? (pEsp->getScaleCenterX() + 3 * pEsp->getScaleCenterY()) * 0xC : 0x30; + const s8* pos = reinterpret_cast(jpa_pos) + center_offset + base_plane_type * 0x6C; + const s8* crd = reinterpret_cast(jpa_crd) + (pBsp->getTilingS() + 2 * pBsp->getTilingT()) * 8; + + bool cross = pBsp->getType() == 4 || pBsp->getType() == 8; + mBatchInfo.vtxCount = cross ? 8 : 4; + for (int i = 0; i < mBatchInfo.vtxCount; i++) { + int posIdx = i < 4 ? i : 72 + (i - 4); + int crdIdx = i & 3; + mBatchInfo.vtxPos[i][0] = pos[posIdx * 3 + 0]; + mBatchInfo.vtxPos[i][1] = pos[posIdx * 3 + 1]; + mBatchInfo.vtxPos[i][2] = pos[posIdx * 3 + 2]; + mBatchInfo.vtxUv[i][0] = crd[crdIdx * 2 + 0]; + mBatchInfo.vtxUv[i][1] = crd[crdIdx * 2 + 1]; + } + + mBatchInfo.supported = true; +} +#endif + void JPAResource::init(JKRHeap* heap) { BOOL is_glbl_clr_anm = pBsp->isGlblClrAnm(); BOOL is_glbl_tex_anm = pBsp->isGlblTexAnm(); @@ -525,7 +593,10 @@ void JPAResource::init(JKRHeap* heap) { if (mpDrawParticleFuncListNum != 0) { mpDrawParticleFuncList = - (ParticleFunc*)JKRAllocFromHeap(heap, mpDrawParticleFuncListNum * sizeof(ParticleFunc), alignof(ParticleFunc)); + (DrawParticleFunc*)JKRAllocFromHeap( + heap, + mpDrawParticleFuncListNum * sizeof(DrawParticleFunc), + alignof(DrawParticleFunc)); } func_no = 0; @@ -635,7 +706,10 @@ void JPAResource::init(JKRHeap* heap) { if (mpDrawParticleChildFuncListNum != 0) { mpDrawParticleChildFuncList = - (ParticleFunc*)JKRAllocFromHeap(heap, mpDrawParticleChildFuncListNum * sizeof(ParticleFunc), sizeof(EmitterFunc)); + (DrawParticleFunc*)JKRAllocFromHeap( + heap, + mpDrawParticleChildFuncListNum * sizeof(DrawParticleFunc), + alignof(DrawParticleFunc)); } func_no = 0; @@ -699,6 +773,10 @@ void JPAResource::init(JKRHeap* heap) { mpDrawParticleChildFuncList[func_no] = &JPARegistPrmAlphaEnv; func_no++; } + +#if TARGET_PC + initBatchInfo(); +#endif } bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) { @@ -808,6 +886,183 @@ void JPAResource::draw(JPAEmitterWorkData* work, JPABaseEmitter* emtr) { } } +#if TARGET_PC +static GXTevAlphaArg to_vtx_alpha_arg(GXTevAlphaArg arg) { + return arg == GX_CA_A0 ? GX_CA_RASA : arg; +} + +static void batch_set_tev_op(GXTevStageID stage) { + GXSetTevColorOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); +} + +static void batch_setup_tev(JPAEmitterWorkData* work, bool useClr1) { + JPABaseShape* shape = work->mpRes->getBsp(); + JPAExTexShape* ets = work->mpRes->getEts(); + bool useIndirect = ets != nullptr && ets->isUseIndirect(); + + // JPAEmitterManager::draw configures both channels to pass vertex color through + GXSetNumChans(useClr1 ? 2 : 1); + + const GXTevAlphaArg* alphaArg = shape->getTevAlphaArg(); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevAlphaIn(GX_TEVSTAGE0, to_vtx_alpha_arg(alphaArg[0]), to_vtx_alpha_arg(alphaArg[1]), + to_vtx_alpha_arg(alphaArg[2]), to_vtx_alpha_arg(alphaArg[3])); + batch_set_tev_op(GX_TEVSTAGE0); + if (!useIndirect) { + GXSetTevDirect(GX_TEVSTAGE0); + } + GXTevStageID nextStage = GX_TEVSTAGE1; + + switch (shape->getTevColorArgSel()) { + case 0: // TEXC + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_ONE, GX_CC_ZERO); + break; + case 1: // C0 * TEXC + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_TEXC, GX_CC_ZERO); + break; + case 2: // lerp(C0, 1, TEXC) + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_RASC, GX_CC_ONE, GX_CC_TEXC, GX_CC_ZERO); + break; + case 3: // lerp(C1, C0, TEXC) = C0 * TEXC (stage 0) + C1 * (1 - TEXC) (stage 1) + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevOrder(nextStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR1A1); + GXSetTevColorIn(nextStage, GX_CC_RASC, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV); + GXSetTevAlphaIn(nextStage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV); + batch_set_tev_op(nextStage); + GXSetTevDirect(nextStage); + nextStage = static_cast(nextStage + 1); + break; + case 4: // TEXC * C0 + C1: C0 * TEXC (stage 0), + C1 (stage 1) + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevOrder(nextStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR1A1); + GXSetTevColorIn(nextStage, GX_CC_CPREV, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC); + GXSetTevAlphaIn(nextStage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV); + batch_set_tev_op(nextStage); + GXSetTevDirect(nextStage); + nextStage = static_cast(nextStage + 1); + break; + case 5: // C0 + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC); + break; + } + + if (ets != nullptr && ets->isUseSecTex()) { + // Mirrors setPTev's secondary texture stage, at the next free stage + GXTexCoordID texCoord = useIndirect ? GX_TEXCOORD2 : GX_TEXCOORD1; + GXSetTevOrder(nextStage, texCoord, GX_TEXMAP3, GX_COLOR_NULL); + GXSetTevColorIn(nextStage, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV, GX_CC_ZERO); + GXSetTevAlphaIn(nextStage, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO); + batch_set_tev_op(nextStage); + GXSetTevDirect(nextStage); + nextStage = static_cast(nextStage + 1); + } + + GXSetNumTevStages(nextStage); +} + +static void batch_setup_vtx_desc(bool useClr0, bool useClr1) { + static Mtx identityMtx = { + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 0.0f}, + }; + + GXLoadPosMtxImm(identityMtx, GX_PNMTX0); + GXSetCurrentMtx(GX_PNMTX0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + if (useClr0) { + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + } + if (useClr1) { + GXSetVtxDesc(GX_VA_CLR1, GX_DIRECT); + } + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + if (useClr0) { + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + } + if (useClr1) { + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_CLR1, GX_CLR_RGBA, GX_RGBA8, 0); + } + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); +} + +static void batch_restore_gx(JPAEmitterWorkData* work, bool changedTev, bool changedTexMtx) { + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX8); + GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S8, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_S8, 0); + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GXSetCurrentMtx(GX_PNMTX0); + + if (changedTexMtx) { + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX0); + } + + if (changedTev) { + GXSetNumChans(0); + work->mpRes->getBsp()->setGX(work); + work->mpRes->setPTev(); + } +} + +static bool draw_particle_batch(JPAEmitterWorkData* work) { + ZoneScoped; + + JPAResource* res = work->mpRes; + const JPAResource::BatchInfo& info = res->mBatchInfo; + if (!info.supported || work->mPrjType != 0 || work->mpEmtr->mpPtclCallBack != nullptr) { + return false; + } + + bool useClr0 = false; + bool useClr1 = false; + if (info.hasPtclColor) { + u32 colorSel = res->getBsp()->getTevColorArgSel(); + if (colorSel >= 6) { + return false; + } + useClr0 = true; + useClr1 = colorSel == 3 || colorSel == 4; + batch_setup_tev(work, useClr1); + } + + if (info.hasPtclTexMtx) { + // UVs are CPU-transformed; drop the texgen + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + } + + batch_setup_vtx_desc(useClr0, useClr1); + + ParticleDrawCtx ctx{}; + ctx.batch = true; + ctx.useTexMtx = info.hasPtclTexMtx; + ctx.useClr0 = useClr0; + ctx.useClr1 = useClr1; + + bool fwdAhead = res->getBsp()->isDrawFwdAhead(); + JPANode* node = fwdAhead ? work->mpEmtr->mAlivePtclBase.getLast() : + work->mpEmtr->mAlivePtclBase.getFirst(); + + GXBegin(GX_QUADS, GX_VTXFMT1, GX_AUTO); + while (node != work->mpEmtr->mAlivePtclBase.getEnd()) { + work->mpCurNode = node; + for (int i = res->mpDrawParticleFuncListNum - 1; i >= 0; i--) { + (*res->mpDrawParticleFuncList[i])(work, node->getObject(), &ctx); + } + node = fwdAhead ? node->getPrev() : node->getNext(); + } + GXEnd(); + + batch_restore_gx(work, useClr0, info.hasPtclTexMtx); + return true; +} +#endif + void JPAResource::drawP(JPAEmitterWorkData* work) { ZoneScoped; work->mpEmtr->clearStatus(0x80); @@ -842,13 +1097,25 @@ void JPAResource::drawP(JPAEmitterWorkData* work) { (*mpDrawEmitterFuncList[i])(work); } +#if TARGET_PC + if (draw_particle_batch(work)) { + GXSetMisc(GX_MT_XF_FLUSH, 0); + if (work->mpEmtr->mpEmtrCallBack != nullptr) { + work->mpEmtr->mpEmtrCallBack->drawAfter(work->mpEmtr); + } + return; + } + + ParticleDrawCtx ctx{}; // immediate mode +#endif + if (pBsp->isDrawFwdAhead()) { JPANode* node = work->mpEmtr->mAlivePtclBase.getLast(); for (; node != work->mpEmtr->mAlivePtclBase.getEnd(); node = node->getPrev()) { work->mpCurNode = node; if (mpDrawParticleFuncList != NULL) { for (int i = mpDrawParticleFuncListNum - 1; i >= 0; i--) { - (*mpDrawParticleFuncList[i])(work, node->getObject()); + (*mpDrawParticleFuncList[i])(work, node->getObject() JPA_DRAW_CTX_ARG); } } } @@ -858,7 +1125,7 @@ void JPAResource::drawP(JPAEmitterWorkData* work) { work->mpCurNode = node; if (mpDrawParticleFuncList != NULL) { for (int i = mpDrawParticleFuncListNum - 1; i >= 0; i--) { - (*mpDrawParticleFuncList[i])(work, node->getObject()); + (*mpDrawParticleFuncList[i])(work, node->getObject() JPA_DRAW_CTX_ARG); } } } @@ -905,13 +1172,17 @@ void JPAResource::drawC(JPAEmitterWorkData* work) { (*mpDrawEmitterChildFuncList[i])(work); } +#if TARGET_PC + ParticleDrawCtx ctx{}; // immediate mode +#endif + if (pBsp->isDrawFwdAhead()) { JPANode* node = work->mpEmtr->mAlivePtclChld.getLast(); for (; node != work->mpEmtr->mAlivePtclChld.getEnd(); node = node->getPrev()) { work->mpCurNode = node; if (mpDrawParticleChildFuncList != NULL) { for (int i = mpDrawParticleChildFuncListNum - 1; i >= 0; i--) { - (*mpDrawParticleChildFuncList[i])(work, node->getObject()); + (*mpDrawParticleChildFuncList[i])(work, node->getObject() JPA_DRAW_CTX_ARG); } } } @@ -921,7 +1192,7 @@ void JPAResource::drawC(JPAEmitterWorkData* work) { work->mpCurNode = node; if (mpDrawParticleChildFuncList != NULL) { for (int i = mpDrawParticleChildFuncListNum - 1; i >= 0; i--) { - (*mpDrawParticleChildFuncList[i])(work, node->getObject()); + (*mpDrawParticleChildFuncList[i])(work, node->getObject() JPA_DRAW_CTX_ARG); } } } 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..2f408d6184 100644 --- a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp +++ b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp @@ -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, }; @@ -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..a8d9fe6028 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -10,6 +10,7 @@ #ifdef TARGET_PC #include +#include "dusk/frame_interpolation.h" #endif JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) 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..4ec23dff44 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::getGameVersion() == dusk::version::GameVersion::GcnJpn) { + 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..2135c8fc22 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; 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..723ed55006 --- /dev/null +++ b/mods/ao_mod/CMakeLists.txt @@ -0,0 +1,21 @@ +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 + BUNDLE +) 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..fb36ddb40c --- /dev/null +++ b/mods/ao_mod/src/mod.cpp @@ -0,0 +1,931 @@ +// 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; +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 colorTarget = WGPU_COLOR_TARGET_STATE_INIT; + colorTarget.format = g_deviceInfo.color_format; + if (blend) { + colorTarget.blend = &blendState; + } + WGPUFragmentState fragment = WGPU_FRAGMENT_STATE_INIT; + fragment.module = module; + fragment.entryPoint = {"fs_main", WGPU_STRLEN}; + fragment.targetCount = 1; + fragment.targets = &colorTarget; + // Depth state must match the EFB pass despite never touching depth. + WGPUDepthStencilState depthStencil = WGPU_DEPTH_STENCIL_STATE_INIT; + depthStencil.format = g_deviceInfo.depth_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_deviceInfo.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)) { + 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 (!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/shadow_mod/CMakeLists.txt b/mods/shadow_mod/CMakeLists.txt new file mode 100644 index 0000000000..ae44eca49c --- /dev/null +++ b/mods/shadow_mod/CMakeLists.txt @@ -0,0 +1,21 @@ +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 + BUNDLE +) 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..36f33de41d --- /dev/null +++ b/mods/shadow_mod/src/mod.cpp @@ -0,0 +1,1347 @@ +// 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/svc/hook.hpp" +#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/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; +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 colorTarget = WGPU_COLOR_TARGET_STATE_INIT; + colorTarget.format = g_deviceInfo.color_format; + if (blend) { + colorTarget.blend = &blendState; + } + WGPUFragmentState fragment = WGPU_FRAGMENT_STATE_INIT; + fragment.module = module; + fragment.entryPoint = {"fs_main", WGPU_STRLEN}; + fragment.targetCount = 1; + fragment.targets = &colorTarget; + WGPUDepthStencilState depthStencil = WGPU_DEPTH_STENCIL_STATE_INIT; + depthStencil.format = g_deviceInfo.depth_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_deviceInfo.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)) { + 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 (!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/mods/template_mod/CMakeLists.txt b/mods/template_mod/CMakeLists.txt new file mode 100644 index 0000000000..3d40c3c5c4 --- /dev/null +++ b/mods/template_mod/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.25) +project(template_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(template_mod + SOURCES src/mod.cpp + MOD_JSON mod.json + RES_DIR res +) 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/mods/template_mod/src/mod.cpp b/mods/template_mod/src/mod.cpp new file mode 100644 index 0000000000..35d19331fd --- /dev/null +++ b/mods/template_mod/src/mod.cpp @@ -0,0 +1,22 @@ +#include "mods/service.hpp" +#include "mods/svc/log.h" + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError*) { + svc_log->info(mod_ctx, "template_mod initialized"); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + svc_log->info(mod_ctx, "template_mod unloaded"); + return MOD_OK; +} +} diff --git a/mods/window_demo/CMakeLists.txt b/mods/window_demo/CMakeLists.txt new file mode 100644 index 0000000000..9150ec7de6 --- /dev/null +++ b/mods/window_demo/CMakeLists.txt @@ -0,0 +1,20 @@ +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 + BUNDLE +) 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..fb3cc31809 --- /dev/null +++ b/mods/window_demo/src/mod.cpp @@ -0,0 +1,229 @@ +#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"); + } + + if (open_window() != MOD_OK) { + svc_gfx->unregister_stage_hook(mod_ctx, g_stageHook); + g_stageHook = 0; + return mods::set_error(error, MOD_ERROR, "failed to open auxiliary window"); + } + + mods::log::info("auxiliary WebGPU window ready"); + 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..6ebcac23cd 100644 --- a/platforms/android/README.md +++ b/platforms/android/README.md @@ -1,6 +1,6 @@ # 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 @@ -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..b7270ee433 100644 --- a/platforms/android/app/src/main/AndroidManifest.xml +++ b/platforms/android/app/src/main/AndroidManifest.xml @@ -26,8 +26,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 cc1c985193..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,470 +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.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.View; -import android.view.Window; -import android.view.WindowInsets; -import android.view.WindowInsetsController; -import org.libsdl.app.SDLActivity; +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 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 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()); + // 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; } - } 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(); + if (!outDir.mkdirs()) { + Log.w(TAG, "Unable to create " + outDir); + 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); + } + } + + private static void deleteRecursively(File file) { + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + deleteRecursively(child); } } - } - - @Override - protected String[] getLibraries() { - // SDL3 is statically linked into libmain.so in this build. - return new String[] { - "main" - }; + 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 bf1ca2149d..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java +++ /dev/null @@ -1,655 +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.LinkedList; -import java.util.UUID; - -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 mFrozen = false; - private LinkedList mOperations; - GattOperation mCurrentOperation = null; - private Handler mHandler; - - 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 inputCharacteristic = UUID.fromString("100F6C33-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 }; - - static class GattOperation { - private enum Operation { - CHR_READ, - CHR_WRITE, - ENABLE_NOTIFICATION - } - - Operation mOp; - UUID mUuid; - byte[] mValue; - BluetoothGatt mGatt; - boolean mResult = true; - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - } - - private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) { - mGatt = gatt; - mOp = operation; - mUuid = uuid; - mValue = value; - } - - 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; - } - - 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); - } - } - - 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(); - // 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(inputCharacteristic)) { - Log.v(TAG, "Found input characteristic"); - // 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(); - } - - // Run in main thread - mHandler.post(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 - } - } - }); - } - - private void queueGattOperation(GattOperation op) { - synchronized (mOperations) { - mOperations.add(op); - } - executeNextGattOperation(); - } - - private void enableNotification(UUID chrUuid) { - GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid); - queueGattOperation(op); - } - - 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 { - 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); - 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(inputCharacteristic) && !mFrozen) { - mManager.HIDDeviceInputReport(getId(), characteristic.getValue()); - } - } - - @Override - public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { - //Log.v(TAG, "onDescriptorRead status=" + status); - } - - @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(inputCharacteristic)) { - boolean hasWrittenInputDescriptor = true; - BluetoothGattCharacteristic reportChr = chr.getService().getCharacteristic(reportCharacteristic); - if (reportChr != null) { - Log.v(TAG, "Writing report characteristic to enter valve mode"); - reportChr.setValue(enterValveMode); - gatt.writeCharacteristic(reportChr); - } - } - - 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() { - // We don't have an easy way to query from the Bluetooth device, but we know what it is - final int D0G_BLE2_PID = 0x1106; - return D0G_BLE2_PID; - } - - @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 { - //Log.v(TAG, "writeOutputReport " + HexDump.dumpHexString(report)); - writeCharacteristic(reportCharacteristic, report); - return report.length; - } - } - - @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 1fb2bfb4a7..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ /dev/null @@ -1,691 +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 - 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); - } - } - } - } - - 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; - } - - return bluetoothDevice.getName().equals("SteamController") && ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) != 0); - } - - 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); - 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 f9e9389802..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java +++ /dev/null @@ -1,313 +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; - - 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; - } - - 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; - } - - // 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 - if (mInputEndpoint == null || mOutputEndpoint == null) { - Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName()); - 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 (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 { - 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 (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) { - UsbInterface iface = mDevice.getInterface(mInterfaceIndex); - mConnection.releaseInterface(iface); - mConnection.close(); - mConnection = null; - } - } - - @Override - public void shutdown() { - close(); - mManager = null; - } - - @Override - public void setFrozen(boolean frozen) { - mFrozen = frozen; - } - - 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 5c54cde863..0000000000 --- a/platforms/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ /dev/null @@ -1,2229 +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 = 8; -/* - // 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 (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)) { - return true; - } - } else if (event.getAction() == KeyEvent.ACTION_UP) { - if (SDLControllerManager.onNativePadUp(deviceId, keyCode)) { - 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"; + +} // namespace + +std::string_view touch_controls_rml_fragment() noexcept { + return kTouchControlsRmlFragment; +} + +std::span touch_layout_controls() noexcept { + return kLayoutControls; +} + +const TouchLayoutControlInfo* find_touch_layout_control(std::string_view layoutId) noexcept { + for (const auto& info : kLayoutControls) { + if (info.layoutId == layoutId) { + return &info; + } + } + return nullptr; +} + +const TouchLayoutControlInfo* find_touch_layout_control(Control control) noexcept { + for (const auto& info : kLayoutControls) { + if (info.hasControl && info.control == control) { + return &info; + } + } + return nullptr; +} + +SDL_FingerID touch_event_id(const Rml::Event& event) noexcept { + return event.GetParameter("finger_id", 0); +} + +Rml::Vector2f touch_event_position(const Rml::Event& event) noexcept { + return { + event.GetParameter("x", 0.f), + event.GetParameter("y", 0.f), + }; +} + +Rml::Vector2f mouse_event_position(const Rml::Event& event) noexcept { + return { + event.GetParameter("mouse_x", 0.f), + event.GetParameter("mouse_y", 0.f), + }; +} + +float touch_dp_scale(Rml::Context* context) noexcept { + if (context == nullptr) { + context = aurora::rmlui::get_context(); + } + if (context == nullptr) { + return 1.f; + } + return std::max(context->GetDensityIndependentPixelRatio(), 1.f); +} + +ControlLayoutSize touch_document_size_dp(Rml::Context* context) noexcept { + if (context == nullptr) { + return {}; + } + + const auto dimensions = context->GetDimensions(); + const float scale = touch_dp_scale(context); + return { + .w = static_cast(dimensions.x) / scale, + .h = static_cast(dimensions.y) / scale, + }; +} + +ControlAnchor touch_control_dock_anchor(ControlRect visual, ControlLayoutSize docSize) noexcept { + if (docSize.w <= 0.f || docSize.h <= 0.f || visual.w <= 0.f || visual.h <= 0.f) { + return ControlAnchor::None; + } + + const bool top = control_float_near(visual.t, 0.f); + const bool bottom = control_float_near(visual.t + visual.h, docSize.h); + const bool left = control_float_near(visual.l, 0.f); + const bool right = control_float_near(visual.l + visual.w, docSize.w); + + if (top && left && !right) { + return ControlAnchor::TopLeft; + } + if (top && right && !left) { + return ControlAnchor::TopRight; + } + if (bottom && left && !right) { + return ControlAnchor::BottomLeft; + } + if (bottom && right && !left) { + return ControlAnchor::BottomRight; + } + if (top) { + return ControlAnchor::Top; + } + if (bottom) { + return ControlAnchor::Bottom; + } + if (left) { + return ControlAnchor::Left; + } + if (right) { + return ControlAnchor::Right; + } + return ControlAnchor::None; +} + +bool control_float_near(float a, float b) noexcept { + return std::abs(a - b) <= 0.01f; +} + +bool control_rect_near(ControlRect a, ControlRect b) noexcept { + return control_float_near(a.l, b.l) && control_float_near(a.t, b.t) && + control_float_near(a.w, b.w) && control_float_near(a.h, b.h); +} + +void apply_control_box_if_changed( + Rml::Element* element, std::optional& appliedBox, ControlRect box) noexcept { + if (element == nullptr || (appliedBox && control_rect_near(*appliedBox, box))) { + return; + } + + element->SetProperty(Rml::PropertyId::Left, Rml::Property(box.l, Rml::Unit::DP)); + element->SetProperty(Rml::PropertyId::Top, Rml::Property(box.t, Rml::Unit::DP)); + element->SetProperty(Rml::PropertyId::Width, Rml::Property(box.w, Rml::Unit::DP)); + element->SetProperty(Rml::PropertyId::Height, Rml::Property(box.h, Rml::Unit::DP)); + appliedBox = box; +} + +void apply_control_transform_if_changed( + Rml::Element* element, std::optional& appliedTransform, float scale) noexcept { + if (element == nullptr || (appliedTransform && control_float_near(*appliedTransform, scale))) { + return; + } + + element->SetProperty(Rml::PropertyId::Transform, + Rml::Transform::MakeProperty({Rml::Transforms::Scale2D{scale}})); + appliedTransform = scale; +} + +void apply_control_dock_classes(Rml::Element* element, ControlAnchor anchor) noexcept { + if (element == nullptr) { + return; + } + + bool top = false; + bool bottom = false; + bool left = false; + bool right = false; + + switch (anchor) { + case ControlAnchor::Top: + top = true; + break; + case ControlAnchor::Bottom: + bottom = true; + break; + case ControlAnchor::Left: + left = true; + break; + case ControlAnchor::Right: + right = true; + break; + case ControlAnchor::TopLeft: + top = true; + left = true; + break; + case ControlAnchor::TopRight: + top = true; + right = true; + break; + case ControlAnchor::BottomLeft: + bottom = true; + left = true; + break; + case ControlAnchor::BottomRight: + bottom = true; + right = true; + break; + case ControlAnchor::None: + break; + } + + element->SetClass("docked", top || bottom || left || right); + element->SetClass("docked-top", top); + element->SetClass("docked-bottom", bottom); + element->SetClass("docked-left", left); + element->SetClass("docked-right", right); +} + +} // namespace dusk::ui diff --git a/src/dusk/ui/touch_controls_common.hpp b/src/dusk/ui/touch_controls_common.hpp new file mode 100644 index 0000000000..30445479ff --- /dev/null +++ b/src/dusk/ui/touch_controls_common.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "controls.hpp" + +#include +#include + +#include +#include +#include +#include + +namespace dusk::ui { + +constexpr std::size_t kTouchLayoutControlCount = 9; + +struct TouchLayoutControlInfo { + std::string_view layoutId; + const char* elementId = nullptr; + ControlProps props; + Control control = Control::COUNT; + bool hasControl = false; +}; + +std::string_view touch_controls_rml_fragment() noexcept; +std::span touch_layout_controls() noexcept; +const TouchLayoutControlInfo* find_touch_layout_control(std::string_view layoutId) noexcept; +const TouchLayoutControlInfo* find_touch_layout_control(Control control) noexcept; + +SDL_FingerID touch_event_id(const Rml::Event& event) noexcept; +Rml::Vector2f touch_event_position(const Rml::Event& event) noexcept; +Rml::Vector2f mouse_event_position(const Rml::Event& event) noexcept; +float touch_dp_scale(Rml::Context* context = nullptr) noexcept; +ControlLayoutSize touch_document_size_dp(Rml::Context* context) noexcept; +ControlAnchor touch_control_dock_anchor(ControlRect visual, ControlLayoutSize docSize) noexcept; + +bool control_float_near(float a, float b) noexcept; +bool control_rect_near(ControlRect a, ControlRect b) noexcept; +void apply_control_box_if_changed( + Rml::Element* element, std::optional& appliedBox, ControlRect box) noexcept; +void apply_control_transform_if_changed( + Rml::Element* element, std::optional& appliedTransform, float scale) noexcept; +void apply_control_dock_classes(Rml::Element* element, ControlAnchor anchor) noexcept; + +} // namespace dusk::ui diff --git a/src/dusk/ui/touch_controls_editor.cpp b/src/dusk/ui/touch_controls_editor.cpp new file mode 100644 index 0000000000..6f4f70de21 --- /dev/null +++ b/src/dusk/ui/touch_controls_editor.cpp @@ -0,0 +1,630 @@ +#include "touch_controls_editor.hpp" + +#include "modal.hpp" + +#include "Z2AudioLib/Z2SeMgr.h" +#include "dusk/config.hpp" +#include "dusk/settings.h" +#include "m_Do/m_Do_audio.h" + +#include + +#include +#include +#include +#include + +namespace dusk::ui { +namespace { + +constexpr float kDragThresholdDp = 6.f; +constexpr float kMinControlDp = 36.f; +constexpr float kMinTriggerWidthDp = 44.f; +constexpr float kMinTriggerHeightDp = 32.f; +constexpr float kMinActionBarWidthDp = 112.f; +constexpr float kMinActionBarHeightDp = 36.f; +constexpr float kMinScale = 0.25f; + +struct HandleBinding { + const char* id = nullptr; + TouchControlsEditor::EditHandle handle = TouchControlsEditor::EditHandle::Move; +}; + +constexpr std::array kHandleBindings = { + HandleBinding{"editor-handle-left", TouchControlsEditor::EditHandle::Left}, + HandleBinding{"editor-handle-right", TouchControlsEditor::EditHandle::Right}, + HandleBinding{"editor-handle-top", TouchControlsEditor::EditHandle::Top}, + HandleBinding{"editor-handle-bottom", TouchControlsEditor::EditHandle::Bottom}, + HandleBinding{"editor-handle-top-left", TouchControlsEditor::EditHandle::TopLeft}, + HandleBinding{"editor-handle-top-right", TouchControlsEditor::EditHandle::TopRight}, + HandleBinding{"editor-handle-bottom-left", TouchControlsEditor::EditHandle::BottomLeft}, + HandleBinding{"editor-handle-bottom-right", TouchControlsEditor::EditHandle::BottomRight}, +}; + +Rml::String touch_controls_editor_document_source() { + const auto fragment = touch_controls_rml_fragment(); + return Rml::String{R"RML( + + + + + + +)RML"} + Rml::String{fragment.data(), fragment.size()} + Rml::String{R"RML( + + + + + + + + + + + + + + + + + +)RML"}; +} + +bool is_corner(TouchControlsEditor::EditHandle handle) noexcept { + using EditHandle = TouchControlsEditor::EditHandle; + return handle == EditHandle::TopLeft || handle == EditHandle::TopRight || + handle == EditHandle::BottomLeft || handle == EditHandle::BottomRight; +} + +bool is_horizontal_edge(TouchControlsEditor::EditHandle handle) noexcept { + using EditHandle = TouchControlsEditor::EditHandle; + return handle == EditHandle::Left || handle == EditHandle::Right; +} + +bool is_vertical_edge(TouchControlsEditor::EditHandle handle) noexcept { + using EditHandle = TouchControlsEditor::EditHandle; + return handle == EditHandle::Top || handle == EditHandle::Bottom; +} + +bool control_valid(std::size_t index) noexcept { + return index < touch_layout_controls().size(); +} + +float squared_distance(Rml::Vector2f a, Rml::Vector2f b) noexcept { + const auto delta = a - b; + return delta.x * delta.x + delta.y * delta.y; +} + +} // namespace + +TouchControlsEditor::TouchControlsEditor() + : Document(touch_controls_editor_document_source(), false, DocumentScope::TouchControls), + mRoot(mDocument != nullptr ? mDocument->GetElementById("root") : nullptr), + mSelectionFrame( + mDocument != nullptr ? mDocument->GetElementById("editor-selection-frame") : nullptr), + mSaveButton(mDocument != nullptr ? mDocument->GetElementById("editor-save") : nullptr), + mResetButton(mDocument != nullptr ? mDocument->GetElementById("editor-reset") : nullptr), + mCancelButton(mDocument != nullptr ? mDocument->GetElementById("editor-cancel") : nullptr), + mWorkingLayout(getSettings().game.touchControlsLayout.getValue()) { + mWorkingLayout.version = ControlLayout::Version; + + const auto controls = touch_layout_controls(); + for (std::size_t i = 0; i < controls.size() && i < mElements.size(); ++i) { + mElements[i].root = + mDocument != nullptr ? mDocument->GetElementById(controls[i].elementId) : nullptr; + } + + bind_control_events(); + bind_handle_events(); + bind_toolbar_events(); + + listen(mRoot, aurora::rmlui::TouchStartEvent, [this](Rml::Event& event) { + if (event.GetTargetElement() != mRoot) { + return; + } + clear_selected_control(); + event.StopPropagation(); + }); + listen(mRoot, Rml::EventId::Mousedown, [this](Rml::Event& event) { + const s32 button = event.GetParameter("button", -1); + if (button != 0 || event.GetTargetElement() != mRoot) { + return; + } + clear_selected_control(); + event.StopPropagation(); + }); + listen(mRoot, aurora::rmlui::TouchMoveEvent, [this](Rml::Event& event) { + if (continue_edit(touch_event_position(event))) { + event.StopPropagation(); + } + }); + listen(mRoot, aurora::rmlui::TouchEndEvent, [this](Rml::Event& event) { + if (end_edit(true, touch_event_id(event), false)) { + event.StopPropagation(); + } + }); + listen(mRoot, aurora::rmlui::TouchCancelEvent, [this](Rml::Event& event) { + if (end_edit(true, touch_event_id(event), true)) { + event.StopPropagation(); + } + }); + listen(mRoot, Rml::EventId::Mousemove, [this](Rml::Event& event) { + if (continue_edit(mouse_event_position(event))) { + event.StopPropagation(); + } + }); + listen(mRoot, Rml::EventId::Mouseup, [this](Rml::Event& event) { + if (end_edit(false, 0, false)) { + event.StopPropagation(); + } + }); + listen(mRoot, Rml::EventId::Transitionend, [this](Rml::Event& event) { + if (event.GetTargetElement() == mRoot && !mRoot->HasAttribute("open") && + Document::visible()) + { + Document::hide(mPendingClose); + } + }); +} + +void TouchControlsEditor::show() { + Document::show(); + if (mRoot != nullptr) { + mRoot->SetAttribute("open", ""); + } +} + +void TouchControlsEditor::hide(bool close) { + if (mRoot != nullptr) { + mRoot->RemoveAttribute("open"); + mPendingClose = close; + } else { + Document::hide(close); + } +} + +void TouchControlsEditor::update() { + sync_control_layouts(); + sync_selection_frame(); + Document::update(); +} + +bool TouchControlsEditor::focus() { + return mSaveButton != nullptr && mSaveButton->Focus(true); +} + +void TouchControlsEditor::bind_control_events() noexcept { + const auto controls = touch_layout_controls(); + for (std::size_t i = 0; i < controls.size() && i < mElements.size(); ++i) { + auto* element = mElements[i].root; + if (element == nullptr) { + continue; + } + + listen(element, aurora::rmlui::TouchStartEvent, [this, i](Rml::Event& event) { + if (begin_edit(i, EditHandle::Move, touch_event_position(event), true, + touch_event_id(event))) + { + event.StopPropagation(); + } + }); + listen(element, Rml::EventId::Mousedown, [this, i](Rml::Event& event) { + const s32 button = event.GetParameter("button", -1); + if (button != 0) { + return; + } + if (begin_edit(i, EditHandle::Move, mouse_event_position(event), false)) { + event.StopPropagation(); + } + }); + } +} + +void TouchControlsEditor::bind_handle_events() noexcept { + for (const auto& binding : kHandleBindings) { + auto* element = mDocument != nullptr ? mDocument->GetElementById(binding.id) : nullptr; + if (element == nullptr) { + continue; + } + + listen(element, aurora::rmlui::TouchStartEvent, [this, handle = binding.handle]( + Rml::Event& event) { + if (!control_valid(mSelectedIndex)) { + return; + } + if (begin_edit(mSelectedIndex, handle, touch_event_position(event), true, + touch_event_id(event))) + { + event.StopPropagation(); + } + }); + listen(element, Rml::EventId::Mousedown, [this, handle = binding.handle](Rml::Event& event) { + const s32 button = event.GetParameter("button", -1); + if (button != 0 || !control_valid(mSelectedIndex)) { + return; + } + if (begin_edit(mSelectedIndex, handle, mouse_event_position(event), false)) { + event.StopPropagation(); + } + }); + } +} + +void TouchControlsEditor::bind_toolbar_events() noexcept { + bind_button_command(mSaveButton, &TouchControlsEditor::save_layout); + bind_button_command(mResetButton, &TouchControlsEditor::request_reset); + bind_button_command(mCancelButton, &TouchControlsEditor::cancel_edit); +} + +void TouchControlsEditor::bind_button_command( + Rml::Element* element, void (TouchControlsEditor::*callback)()) noexcept { + if (element == nullptr) { + return; + } + + listen(element, Rml::EventId::Click, [this, callback](Rml::Event& event) { + (this->*callback)(); + event.StopPropagation(); + }); + listen(element, Rml::EventId::Keydown, [this, callback](Rml::Event& event) { + if (map_nav_event(event) != NavCommand::Confirm) { + return; + } + (this->*callback)(); + event.StopPropagation(); + }); +} + +void TouchControlsEditor::sync_control_layouts() noexcept { + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + const auto docSize = touch_document_size_dp(context); + if (docSize.w <= 0.f || docSize.h <= 0.f || context == nullptr) { + return; + } + + const auto controls = touch_layout_controls(); + for (std::size_t i = 0; i < controls.size() && i < mElements.size(); ++i) { + const auto layout = resolve_control_layout(props_for(i), docSize); + auto& element = mElements[i]; + element.layout.visualRect = layout.visual; + element.layout.layoutScale = layout.scale; + if (element.root != nullptr) { + element.root->SetPseudoClass("hidden", false); + } + apply_control_box_if_changed(element.root, element.layout.appliedBox, layout.box); + apply_control_dock_classes( + element.root, touch_control_dock_anchor(layout.visual, docSize)); + apply_control_transform_if_changed( + element.root, element.layout.appliedTransform, element.layout.layoutScale); + } +} + +void TouchControlsEditor::sync_selection_frame() noexcept { + const bool hasSelection = + control_valid(mSelectedIndex) && mElements[mSelectedIndex].layout.visualRect; + if (mSelectionFrame == nullptr) { + return; + } + + mSelectionFrame->SetClass("visible", hasSelection); + for (std::size_t i = 0; i < mElements.size(); ++i) { + if (mElements[i].root != nullptr) { + mElements[i].root->SetClass("editor-selected", hasSelection && i == mSelectedIndex); + } + } + if (!hasSelection) { + mAppliedSelectionFrame = std::nullopt; + return; + } + + apply_control_box_if_changed( + mSelectionFrame, mAppliedSelectionFrame, *mElements[mSelectedIndex].layout.visualRect); +} + +void TouchControlsEditor::set_selected_control(std::size_t index) noexcept { + if (!control_valid(index)) { + clear_selected_control(); + return; + } + mSelectedIndex = index; + sync_selection_frame(); +} + +void TouchControlsEditor::clear_selected_control() noexcept { + mSelectedIndex = kTouchLayoutControlCount; + sync_selection_frame(); +} + +ControlProps TouchControlsEditor::props_for(std::size_t index) const { + const auto controls = touch_layout_controls(); + if (!control_valid(index)) { + return {}; + } + + const auto& info = controls[index]; + if (const auto iter = mWorkingLayout.controls.find(info.layoutId); + iter != mWorkingLayout.controls.end()) + { + return iter->second; + } + return info.props; +} + +void TouchControlsEditor::store_props( + std::size_t index, ControlRect visual, ControlProps props) noexcept { + if (!control_valid(index)) { + return; + } + + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + const auto docSize = touch_document_size_dp(context); + if (docSize.w <= 0.f || docSize.h <= 0.f) { + return; + } + + props.w = std::max(props.w, 1.f); + props.h = std::max(props.h, 1.f); + props.scale = std::max(props.scale, kMinScale); + props = encode_control_props(visual, docSize, props, touch_control_dock_anchor(visual, docSize)); + mWorkingLayout.version = ControlLayout::Version; + mWorkingLayout.controls[std::string{touch_layout_controls()[index].layoutId}] = props; + sync_control_layouts(); + sync_selection_frame(); +} + +void TouchControlsEditor::restore_active_control() noexcept { + if (!control_valid(mPointerEdit.index)) { + return; + } + + auto& controls = mWorkingLayout.controls; + const auto key = std::string{touch_layout_controls()[mPointerEdit.index].layoutId}; + if (mPointerEdit.storedProps) { + controls[key] = *mPointerEdit.storedProps; + } else { + controls.erase(key); + } + sync_control_layouts(); + sync_selection_frame(); +} + +bool TouchControlsEditor::begin_edit( + std::size_t index, EditHandle handle, Rml::Vector2f positionPx, bool touch, + SDL_FingerID touchId) noexcept { + if (!control_valid(index) || mPointerEdit.active) { + return false; + } + + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + const auto docSize = touch_document_size_dp(context); + if (docSize.w <= 0.f || docSize.h <= 0.f) { + return false; + } + + const auto props = props_for(index); + const auto layout = resolve_control_layout(props, docSize); + std::optional storedProps; + if (const auto iter = mWorkingLayout.controls.find(touch_layout_controls()[index].layoutId); + iter != mWorkingLayout.controls.end()) + { + storedProps = iter->second; + } + + mPointerEdit = { + .index = index, + .touchId = touchId, + .startPointerDp = pointer_position_dp(positionPx), + .startVisual = layout.visual, + .startProps = props, + .storedProps = storedProps, + .handle = handle, + .active = true, + .touch = touch, + }; + set_selected_control(index); + return true; +} + +bool TouchControlsEditor::continue_edit(Rml::Vector2f positionPx) noexcept { + if (!mPointerEdit.active) { + return false; + } + + const auto pointerDp = pointer_position_dp(positionPx); + if (!mPointerEdit.dragging) { + if (squared_distance(pointerDp, mPointerEdit.startPointerDp) < + kDragThresholdDp * kDragThresholdDp) + { + return true; + } + mPointerEdit.dragging = true; + } + + auto props = mPointerEdit.startProps; + auto rect = rect_for_edit(pointerDp, props); + rect = clamp_visual_rect(mPointerEdit.index, rect); + if (is_corner(mPointerEdit.handle)) { + props.scale = std::max(rect.w / std::max(mPointerEdit.startProps.w, 1.f), kMinScale); + } else if (is_horizontal_edge(mPointerEdit.handle)) { + props.w = rect.w / std::max(props.scale, kMinScale); + } else if (is_vertical_edge(mPointerEdit.handle)) { + props.h = rect.h / std::max(props.scale, kMinScale); + } + store_props(mPointerEdit.index, rect, props); + return true; +} + +bool TouchControlsEditor::end_edit(bool touch, SDL_FingerID touchId, bool cancelled) noexcept { + if (!mPointerEdit.active || mPointerEdit.touch != touch || + (touch && mPointerEdit.touchId != touchId)) + { + return false; + } + + if (cancelled && mPointerEdit.dragging) { + restore_active_control(); + } + mPointerEdit = {}; + return true; +} + +Rml::Vector2f TouchControlsEditor::pointer_position_dp(Rml::Vector2f positionPx) const noexcept { + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + return positionPx / touch_dp_scale(context); +} + +ControlRect TouchControlsEditor::rect_for_edit( + Rml::Vector2f pointerDp, ControlProps& props) const noexcept { + const auto& edit = mPointerEdit; + auto rect = edit.startVisual; + const auto delta = pointerDp - edit.startPointerDp; + + switch (edit.handle) { + case EditHandle::Move: + rect.l += delta.x; + rect.t += delta.y; + return rect; + case EditHandle::Left: { + const float right = edit.startVisual.l + edit.startVisual.w; + rect.l = pointerDp.x; + rect.w = right - rect.l; + return rect; + } + case EditHandle::Right: + rect.w = pointerDp.x - edit.startVisual.l; + return rect; + case EditHandle::Top: { + const float bottom = edit.startVisual.t + edit.startVisual.h; + rect.t = pointerDp.y; + rect.h = bottom - rect.t; + return rect; + } + case EditHandle::Bottom: + rect.h = pointerDp.y - edit.startVisual.t; + return rect; + case EditHandle::TopLeft: + case EditHandle::TopRight: + case EditHandle::BottomLeft: + case EditHandle::BottomRight: + break; + } + + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + const auto docSize = touch_document_size_dp(context); + const bool left = edit.handle == EditHandle::TopLeft || edit.handle == EditHandle::BottomLeft; + const bool top = edit.handle == EditHandle::TopLeft || edit.handle == EditHandle::TopRight; + const Rml::Vector2f fixed{ + left ? edit.startVisual.l + edit.startVisual.w : edit.startVisual.l, + top ? edit.startVisual.t + edit.startVisual.h : edit.startVisual.t, + }; + const float desiredW = left ? fixed.x - pointerDp.x : pointerDp.x - fixed.x; + const float desiredH = top ? fixed.y - pointerDp.y : pointerDp.y - fixed.y; + const auto minSize = min_visual_size(edit.index); + const float minRatio = + std::max(minSize.x / std::max(edit.startVisual.w, 1.f), + minSize.y / std::max(edit.startVisual.h, 1.f)); + const float maxW = left ? fixed.x : docSize.w - fixed.x; + const float maxH = top ? fixed.y : docSize.h - fixed.y; + const float maxRatio = + std::max(minRatio, std::min(maxW / std::max(edit.startVisual.w, 1.f), + maxH / std::max(edit.startVisual.h, 1.f))); + const float ratio = + std::clamp(std::max(desiredW / std::max(edit.startVisual.w, 1.f), + desiredH / std::max(edit.startVisual.h, 1.f)), + minRatio, maxRatio); + + rect.w = edit.startVisual.w * ratio; + rect.h = edit.startVisual.h * ratio; + rect.l = left ? fixed.x - rect.w : fixed.x; + rect.t = top ? fixed.y - rect.h : fixed.y; + props.scale = std::max(edit.startProps.scale * ratio, kMinScale); + return rect; +} + +ControlRect TouchControlsEditor::clamp_visual_rect(std::size_t index, ControlRect rect) const noexcept { + auto* context = mDocument != nullptr ? mDocument->GetContext() : nullptr; + const auto docSize = touch_document_size_dp(context); + if (docSize.w <= 0.f || docSize.h <= 0.f || !control_valid(index)) { + return rect; + } + + const auto minSize = min_visual_size(index); + const float minW = std::min(minSize.x, docSize.w); + const float minH = std::min(minSize.y, docSize.h); + rect.w = std::clamp(rect.w, minW, docSize.w); + rect.h = std::clamp(rect.h, minH, docSize.h); + rect.l = std::clamp(rect.l, 0.f, std::max(0.f, docSize.w - rect.w)); + rect.t = std::clamp(rect.t, 0.f, std::max(0.f, docSize.h - rect.h)); + return rect; +} + +Rml::Vector2f TouchControlsEditor::min_visual_size(std::size_t index) const noexcept { + if (!control_valid(index)) { + return {kMinControlDp, kMinControlDp}; + } + + const auto id = touch_layout_controls()[index].layoutId; + if (id == "actionBar") { + return {kMinActionBarWidthDp, kMinActionBarHeightDp}; + } + if (id == "triggerL" || id == "triggerR" || id == "buttonZ" || id == "skip") { + return {kMinTriggerWidthDp, kMinTriggerHeightDp}; + } + return {kMinControlDp, kMinControlDp}; +} + +bool TouchControlsEditor::handle_nav_command(Rml::Event& event, NavCommand cmd) { + if (cmd == NavCommand::Cancel || cmd == NavCommand::Menu) { + cancel_edit(); + return true; + } + return Document::handle_nav_command(event, cmd); +} + +void TouchControlsEditor::save_layout() { + mWorkingLayout.version = ControlLayout::Version; + getSettings().game.touchControlsLayout.setValue(mWorkingLayout); + config::save(); + mDoAud_seStartMenu(kSoundItemChange); + pop(); +} + +void TouchControlsEditor::request_reset() { + auto dismiss = [](Modal& modal) { modal.pop(); }; + push(std::make_unique(Modal::Props{ + .title = "Reset Touch Layout?", + .bodyRml = "Reset controls to their default layout. This will not be saved until you press Save.", + .actions = + { + ModalAction{ + .label = "Reset", + .onPressed = + [this, dismiss](Modal& modal) { + reset_working_layout(); + mDoAud_seStartMenu(kSoundItemChange); + dismiss(modal); + }, + }, + ModalAction{ + .label = "Cancel", + .onPressed = dismiss, + }, + }, + })); +} + +void TouchControlsEditor::reset_working_layout() noexcept { + mWorkingLayout = ControlLayout{}; + mWorkingLayout.version = ControlLayout::Version; + mPointerEdit = {}; + sync_control_layouts(); + sync_selection_frame(); +} + +void TouchControlsEditor::cancel_edit() { + mDoAud_seStartMenu(kSoundWindowClose); + pop(); +} + +} // namespace dusk::ui diff --git a/src/dusk/ui/touch_controls_editor.hpp b/src/dusk/ui/touch_controls_editor.hpp new file mode 100644 index 0000000000..4af33d8fbc --- /dev/null +++ b/src/dusk/ui/touch_controls_editor.hpp @@ -0,0 +1,98 @@ +#pragma once + +#include "controls.hpp" +#include "document.hpp" +#include "touch_controls_common.hpp" + +#include +#include +#include + +namespace dusk::ui { + +class TouchControlsEditor final : public Document { +public: + TouchControlsEditor(); + + void show() override; + void hide(bool close) override; + void update() override; + bool focus() override; + + enum class EditHandle { + Move, + Left, + Right, + Top, + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight, + }; + +private: + struct LayoutState { + std::optional visualRect; + std::optional appliedBox; + float layoutScale = 1.0f; + std::optional appliedTransform; + }; + + struct EditElement { + Rml::Element* root = nullptr; + LayoutState layout; + }; + + struct PointerEdit { + std::size_t index = kTouchLayoutControlCount; + SDL_FingerID touchId = 0; + Rml::Vector2f startPointerDp; + ControlRect startVisual; + ControlProps startProps; + std::optional storedProps; + EditHandle handle = EditHandle::Move; + bool active = false; + bool touch = false; + bool dragging = false; + }; + + void bind_control_events() noexcept; + void bind_handle_events() noexcept; + void bind_toolbar_events() noexcept; + void bind_button_command( + Rml::Element* element, void (TouchControlsEditor::*callback)()) noexcept; + void sync_control_layouts() noexcept; + void sync_selection_frame() noexcept; + void set_selected_control(std::size_t index) noexcept; + void clear_selected_control() noexcept; + ControlProps props_for(std::size_t index) const; + void store_props(std::size_t index, ControlRect visual, ControlProps props) noexcept; + void restore_active_control() noexcept; + bool begin_edit(std::size_t index, EditHandle handle, Rml::Vector2f positionPx, bool touch, + SDL_FingerID touchId = 0) noexcept; + bool continue_edit(Rml::Vector2f positionPx) noexcept; + bool end_edit(bool touch, SDL_FingerID touchId, bool cancelled) noexcept; + Rml::Vector2f pointer_position_dp(Rml::Vector2f positionPx) const noexcept; + ControlRect rect_for_edit(Rml::Vector2f pointerDp, ControlProps& props) const noexcept; + ControlRect clamp_visual_rect(std::size_t index, ControlRect rect) const noexcept; + Rml::Vector2f min_visual_size(std::size_t index) const noexcept; + bool handle_nav_command(Rml::Event& event, NavCommand cmd) override; + void save_layout(); + void request_reset(); + void reset_working_layout() noexcept; + void cancel_edit(); + + Rml::Element* mRoot = nullptr; + Rml::Element* mSelectionFrame = nullptr; + Rml::Element* mSaveButton = nullptr; + Rml::Element* mResetButton = nullptr; + Rml::Element* mCancelButton = nullptr; + std::array mElements{}; + ControlLayout mWorkingLayout; + PointerEdit mPointerEdit; + std::optional mAppliedSelectionFrame; + std::size_t mSelectedIndex = kTouchLayoutControlCount; +}; + +} // namespace dusk::ui diff --git a/src/dusk/ui/ui.cpp b/src/dusk/ui/ui.cpp index 3e70604b8b..a60acb5ae9 100644 --- a/src/dusk/ui/ui.cpp +++ b/src/dusk/ui/ui.cpp @@ -1,7 +1,11 @@ #include "ui.hpp" #include -#include +#include +#include +#include +#include +#include #include #include #include @@ -11,24 +15,58 @@ #include #include "aurora/lib/window.hpp" -#include "command_console.hpp" +#include "dusk/config.hpp" #include "dusk/io.hpp" +#include +#include "command_console.hpp" +#include "icon_provider.hpp" #include "input.hpp" +#include "mod_texture_provider.hpp" #include "prelaunch.hpp" #include "window.hpp" -#include "dusk/config.hpp" namespace dusk::ui { namespace { void load_font(const char* filename, bool fallback = false) { - Rml::LoadFontFace(io::fs_path_to_string(resource_path(filename)), fallback); + Rml::LoadFontFace(borealis::io::fs_path_to_string(resource_path(filename)), fallback); } bool sInitialized = false; -std::vector > sDocumentStack; +std::vector> sDocumentStack; // Documents that don't participate in the focus stack -std::vector > sPassiveDocuments; +std::vector> sPassiveDocuments; + +struct ScopedStyles { + DocumentScope scope; + std::string id; + Rml::SharedPtr sheet; +}; +std::vector sScopedStyles; + +std::vector scoped_sheets(DocumentScope scope) { + std::vector sheets; + for (const auto& entry : sScopedStyles) { + if (entry.scope == scope) { + sheets.push_back(entry.sheet.get()); + } + } + return sheets; +} + +void restyle_scope(DocumentScope scope) { + const auto sheets = scoped_sheets(scope); + const auto restyle_documents = [&sheets, scope](auto& documents) { + for (auto& doc : documents) { + if (doc != nullptr && doc->scope() == scope && !doc->closed()) { + doc->restyle(sheets); + } + } + }; + restyle_documents(sDocumentStack); + restyle_documents(sPassiveDocuments); +} + std::deque sToasts; bool sMenuNotificationRequested = false; @@ -57,11 +95,15 @@ bool initialize() noexcept { load_font("MaterialSymbolsRounded-Regular.ttf"); load_font("NotoMono-Regular.ttf"); + register_icon_texture_provider(); + register_mod_texture_provider(); sInitialized = true; return true; } void shutdown() noexcept { + unregister_mod_texture_provider(); + unregister_icon_texture_provider(); sDocumentStack.clear(); sPassiveDocuments.clear(); sConnectedGamepads.clear(); @@ -133,10 +175,12 @@ void handle_event(const SDL_Event& event) noexcept { const char* name = SDL_GetGamepadName(gamepad); Rml::String content = fmt::format("{}", name ? name : "[Unknown]"); Rml::String title = "Device Connected"; - if (const char* icon = connection_state_icon(SDL_GetGamepadConnectionState(gamepad))) { + if (const char* icon = + connection_state_icon(SDL_GetGamepadConnectionState(gamepad))) + { title = fmt::format( - "{} &#x{};", title, - icon); + "{} &#x{};", + title, icon); } int batteryLevel = -1; const auto powerState = SDL_GetGamepadPowerInfo(gamepad, &batteryLevel); @@ -188,6 +232,34 @@ void handle_event(const SDL_Event& event) noexcept { } } +bool register_scoped_styles(DocumentScope scope, std::string id, const std::string& rcss) noexcept { + auto sheet = Rml::Factory::InstanceStyleSheetString(rcss); + if (sheet == nullptr) { + return false; + } + const auto it = std::ranges::find_if(sScopedStyles, + [scope, &id](const ScopedStyles& entry) { return entry.scope == scope && entry.id == id; }); + if (it != sScopedStyles.end()) { + it->sheet = std::move(sheet); + } else { + sScopedStyles.push_back({scope, std::move(id), std::move(sheet)}); + } + restyle_scope(scope); + return true; +} + +void unregister_scoped_styles(DocumentScope scope, std::string_view id) noexcept { + const auto erased = std::erase_if(sScopedStyles, + [scope, id](const ScopedStyles& entry) { return entry.scope == scope && entry.id == id; }); + if (erased != 0) { + restyle_scope(scope); + } +} + +void apply_scoped_styles(Document& doc) noexcept { + doc.restyle(scoped_sheets(doc.scope())); +} + Document& push_document(std::unique_ptr doc, bool show, bool passive) noexcept { Document& ret = *doc; if (passive) { @@ -202,9 +274,9 @@ Document& push_document(std::unique_ptr doc, bool show, bool passive) return ret; } -void show_top_document() noexcept { +void uncover_top_document() noexcept { if (auto* doc = top_document()) { - doc->show(); + doc->uncover(); } input::sync_input_block(); } @@ -217,13 +289,25 @@ bool any_document_visible() noexcept { bool is_prelaunch_open() noexcept { return std::any_of(sDocumentStack.begin(), sDocumentStack.end(), [](const auto& doc) { const auto* prelaunch = dynamic_cast(doc.get()); - return prelaunch != nullptr && !prelaunch->pending_close() && !prelaunch->closed(); + return prelaunch != nullptr && prelaunch->active(); }); } +bool game_obscured_below(const Document& doc) noexcept { + for (const auto& entry : sDocumentStack) { + if (entry.get() == &doc) { + break; + } + if (entry->active() && entry->obscures_game()) { + return true; + } + } + return false; +} + Document* top_document() noexcept { for (auto& doc : std::views::reverse(sDocumentStack)) { - if (!doc->closed() && !doc->pending_close()) { + if (doc->active()) { return doc.get(); } } @@ -266,7 +350,7 @@ void update() noexcept { context->GetFocusElement() == context->GetRootElement())) { for (auto& doc : std::views::reverse(sDocumentStack)) { - if (!doc->closed() && !doc->pending_close() && doc->focus()) { + if (doc->active() && doc->focus()) { break; } } @@ -315,6 +399,17 @@ Rml::Element* append(Rml::Element* parent, const Rml::String& tag) noexcept { return parent->AppendChild(doc->CreateElement(tag)); } +Rml::Element* append_text(Rml::Element* parent, const Rml::String& text) noexcept { + if (parent == nullptr) { + return nullptr; + } + auto* doc = parent->GetOwnerDocument(); + if (doc == nullptr) { + return nullptr; + } + return parent->AppendChild(doc->CreateTextNode(text)); +} + NavCommand map_nav_event(const Rml::Event& event) noexcept { const auto key = static_cast( event.GetParameter("key_identifier", Rml::Input::KI_UNKNOWN)); @@ -381,7 +476,7 @@ void push_toast(Toast toast) noexcept { sToasts.push_back(std::move(toast)); } -std::vector >& get_document_stack() noexcept { +std::vector>& get_document_stack() noexcept { return sDocumentStack; } diff --git a/src/dusk/ui/ui.hpp b/src/dusk/ui/ui.hpp index cbfe3dcc9d..d5db990570 100644 --- a/src/dusk/ui/ui.hpp +++ b/src/dusk/ui/ui.hpp @@ -15,11 +15,22 @@ class Document; using clock = std::chrono::steady_clock; +enum class DocumentScope : u8 { + None, + Prelaunch, + Window, + MenuBar, + Overlay, + TouchControls, + GraphicsTuner, +}; + struct Toast { Rml::String type; Rml::String title; Rml::String content; clock::duration duration; + Rml::String modId; }; // Button clicked/pressed @@ -74,19 +85,24 @@ void update() noexcept; Document& push_document( std::unique_ptr doc, bool show = true, bool passive = false) noexcept; -void show_top_document() noexcept; +bool register_scoped_styles(DocumentScope scope, std::string id, const std::string& rcss) noexcept; +void unregister_scoped_styles(DocumentScope scope, std::string_view id) noexcept; +void apply_scoped_styles(Document& doc) noexcept; +void uncover_top_document() noexcept; bool any_document_visible() noexcept; bool is_prelaunch_open() noexcept; +bool game_obscured_below(const Document& doc) noexcept; Document* top_document() noexcept; std::filesystem::path resource_path(const std::filesystem::path& filename) noexcept; std::string escape(std::string_view str) noexcept; Rml::Element* append(Rml::Element* parent, const Rml::String& tag) noexcept; +Rml::Element* append_text(Rml::Element* parent, const Rml::String& text) noexcept; NavCommand map_nav_event(const Rml::Event& event) noexcept; Insets safe_area_insets(Rml::Context* context) noexcept; -std::vector >& get_document_stack() noexcept; +std::vector>& get_document_stack() noexcept; void push_toast(Toast toast) noexcept; std::deque& get_toasts() noexcept; diff --git a/src/dusk/ui/window.cpp b/src/dusk/ui/window.cpp index 41080ff287..f1162a09b6 100644 --- a/src/dusk/ui/window.cpp +++ b/src/dusk/ui/window.cpp @@ -2,6 +2,7 @@ #include "aurora/lib/window.hpp" #include "aurora/rmlui.hpp" +#include "fmt/format.h" #include "magic_enum.hpp" #include "pane.hpp" #include "ui.hpp" @@ -24,17 +25,24 @@ float base_body_padding(Rml::Context* context) noexcept { return 64.0f * dpRatio; } -const Rml::String kDocumentSource = R"RML( +Rml::String window_document_source(const std::vector& styleSheets) { + Rml::String links; + for (const auto& sheet : styleSheets) { + links += fmt::format(" \n", sheet); + } + return fmt::format(R"RML( - +{} -)RML"; +)RML", + links); +} const Rml::String kDocumentSourceSmall = R"RML( @@ -51,12 +59,25 @@ const Rml::String kDocumentSourceSmall = R"RML( } // namespace -Window::Window() : Document(kDocumentSource), mRoot(mDocument->GetElementById("window")) { - mTabBar = std::make_unique(mRoot, TabBar::Props{ - .onClose = [this] { request_close(); }, - .selectedTabIndex = 0, - .autoSelect = true, - }); +Window::Window(Props props) + : Document(window_document_source(props.styleSheets), false, DocumentScope::Window), + mRoot(mDocument->GetElementById("window")) { + if (props.tabBar) { + mTabBar = std::make_unique(mRoot, TabBar::Props{ + .onClose = [this] { request_close(); }, + .selectedTabIndex = 0, + .autoSelect = true, + }); + } else { + mCloseButton = std::make_unique