diff --git a/.gitmodules b/.gitmodules index f05842fa7b..881f8f524b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,9 @@ [submodule "extern/borealis"] path = extern/borealis url = https://github.com/encounter/borealis.git +[submodule "mods/randomizer"] + path = mods/randomizer + url = https://github.com/TwilitRealm/dusklight-randomizer.git +[submodule "mods/cosmetics"] + path = mods/cosmetics + url = https://github.com/TwilitRealm/dusklight-cosmetics diff --git a/CMakeLists.txt b/CMakeLists.txt index dcd53086fe..834713ed00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Linux) endif () set(AURORA_ENABLE_DVD ON CACHE BOOL "Enable DVD API support" FORCE) set(AURORA_ENABLE_CARD ON CACHE BOOL "Enable CARD API support" FORCE) +set(AURORA_ENABLE_THP ON CACHE BOOL "Enable THP decoder" FORCE) set(AURORA_ENABLE_RMLUI ON CACHE BOOL "Enable RmlUi UI support" FORCE) add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) target_compile_definitions(aurora_mtx PRIVATE MTX_USE_PS=1) @@ -88,7 +89,6 @@ 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_PACKAGE_INSTALL "Install Dusklight with a Linux-native file structure" OFF) option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) option(DUSK_ENABLE_CODE_MODS "Enable code mods" ON) @@ -133,69 +133,6 @@ if (MSVC) endif () endif () -if (DUSK_MOVIE_SUPPORT) - find_package(libjpeg-turbo 3.0 CONFIG QUIET) - if (libjpeg-turbo_FOUND) - message(STATUS "dusklight: Using system libjpeg-turbo") - else () - message(STATUS "dusklight: Fetching libjpeg-turbo") - include(ExternalProject) - set(_jpeg_install_dir ${CMAKE_BINARY_DIR}/libjpeg-turbo-install) - if (WIN32) - set(_jpeg_lib ${_jpeg_install_dir}/lib/turbojpeg-static.lib) - else () - set(_jpeg_lib ${_jpeg_install_dir}/lib/libturbojpeg.a) - endif () - set(_jpeg_cmake_args - -DCMAKE_INSTALL_PREFIX=${_jpeg_install_dir} - -DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsTargetProcessor.cmake - -DENABLE_SHARED=OFF - -DWITH_TURBOJPEG=ON - -DWITH_JAVA=OFF - -DCMAKE_INSTALL_LIBDIR=lib - ) - if (CMAKE_TOOLCHAIN_FILE) - get_filename_component(_jpeg_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") - list(APPEND _jpeg_cmake_args -DCMAKE_TOOLCHAIN_FILE=${_jpeg_toolchain_file}) - endif () - set(_jpeg_passthrough_vars - ANDROID_ABI - ANDROID_PLATFORM - CMAKE_BUILD_TYPE - CMAKE_C_COMPILER - CMAKE_C_COMPILER_LAUNCHER - CMAKE_MAKE_PROGRAM - CMAKE_MSVC_RUNTIME_LIBRARY - CMAKE_MSVC_DEBUG_INFORMATION_FORMAT - CMAKE_OSX_ARCHITECTURES - CMAKE_OSX_DEPLOYMENT_TARGET - CMAKE_OSX_SYSROOT - DEPLOYMENT_TARGET - ENABLE_ARC - ENABLE_BITCODE - PLATFORM - ) - foreach(_var IN LISTS _jpeg_passthrough_vars) - if (DEFINED ${_var}) - list(APPEND _jpeg_cmake_args -D${_var}=${${_var}}) - endif () - endforeach () - ExternalProject_Add(libjpeg-turbo-ext - URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/3.1.0.tar.gz - URL_HASH SHA256=35fec2e1ddfb05ecf6d93e50bc57c1e54bc81c16d611ddf6eff73fff266d8285 - CMAKE_ARGS ${_jpeg_cmake_args} - BUILD_BYPRODUCTS ${_jpeg_lib} - ) - file(MAKE_DIRECTORY ${_jpeg_install_dir}/include) - add_library(libjpeg-turbo::turbojpeg-static STATIC IMPORTED GLOBAL) - set_target_properties(libjpeg-turbo::turbojpeg-static PROPERTIES - IMPORTED_LOCATION ${_jpeg_lib} - INTERFACE_INCLUDE_DIRECTORIES ${_jpeg_install_dir}/include - ) - add_dependencies(libjpeg-turbo::turbojpeg-static libjpeg-turbo-ext) - endif () -endif () - if (CMAKE_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. @@ -303,8 +240,8 @@ 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 borealis::cli borealis::crash borealis::data borealis::disc borealis::discord borealis::file_select borealis::io borealis::log borealis::presentation borealis::sentry borealis::update freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt +set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd aurora::thp + aurora::card borealis::cli borealis::crash borealis::data borealis::disc borealis::discord borealis::file_select borealis::io borealis::log borealis::net borealis::presentation borealis::sentry borealis::update borealis::ws freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt Threads::Threads zstd::libzstd dusklight_game_headers) if (DUSK_HAS_FUNCHOOK) list(APPEND GAME_LIBS funchook-static) @@ -314,15 +251,6 @@ if (WIN32) list(APPEND GAME_LIBS Ws2_32) endif () -if (DUSK_MOVIE_SUPPORT) - if (TARGET libjpeg-turbo::turbojpeg-static) - list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg-static) - else () - list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg) - endif () - list(APPEND GAME_COMPILE_DEFS MOVIE_SUPPORT=1) -endif () - if (DUSK_ENABLE_CODE_MODS) list(APPEND GAME_COMPILE_DEFS DUSK_CODE_MODS=1) endif () @@ -565,12 +493,15 @@ include(cmake/ModSDK.cmake) if (DUSK_ENABLE_CODE_MODS AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) add_custom_target(dusklight_mods) # Aggregate target for all in-tree mods + add_subdirectory(mods/luau_runtime) add_subdirectory(mods/template_mod) add_subdirectory(mods/ao_mod) add_subdirectory(mods/shadow_mod) add_subdirectory(mods/window_demo) add_subdirectory(mods/flow_demo) - add_subdirectory(mods/basic_cosmetics_mod) + add_subdirectory(mods/custom_actor_demo) + add_subdirectory(mods/cosmetics) + add_subdirectory(mods/randomizer) endif () if (APPLE) diff --git a/cmake/ModSDK.cmake b/cmake/ModSDK.cmake index 53c903b627..db3ca231d0 100644 --- a/cmake/ModSDK.cmake +++ b/cmake/ModSDK.cmake @@ -296,8 +296,6 @@ function(add_mod target_name) 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) @@ -316,6 +314,7 @@ function(add_mod target_name) set(_package_inputs "${_mod_json}") set(_extra_cmds "") set(_lib_copy_cmd "") + set(_lib_strip_cmd "") set(_target_depend "") if (_has_lib) list(APPEND _zip_args lib) @@ -323,6 +322,10 @@ function(add_mod target_name) COMMAND ${CMAKE_COMMAND} -E make_directory "${_stage}/lib/${_lib_platform}" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${_stage}/lib/${_lib_platform}/${_lib_name}") + if (UNIX AND NOT APPLE) + set(_lib_strip_cmd COMMAND "${CMAKE_STRIP}" --strip-unneeded + "${_stage}/lib/${_lib_platform}/${_lib_name}") + endif () set(_target_depend ${target_name}) endif () string(TOLOWER "${_lib_name}" _lib_name_key) @@ -399,6 +402,7 @@ function(add_mod target_name) COMMAND ${CMAKE_COMMAND} -E rm -rf "${_stage}" COMMAND ${CMAKE_COMMAND} -E make_directory "${_stage}" "${_output_dir}" ${_lib_copy_cmd} + ${_lib_strip_cmd} COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_mod_json}" "${_stage}/mod.json" ${_extra_cmds} COMMAND ${CMAKE_COMMAND} -E chdir "${_stage}" ${CMAKE_COMMAND} -E tar cvf "${_out}" --format=zip ${_zip_args} diff --git a/docs/modding.md b/docs/modding.md index 4ad29aa8da..7d7fa142a0 100644 --- a/docs/modding.md +++ b/docs/modding.md @@ -1,35 +1,137 @@ # Dusklight Mod API -Mods are `.dusk` bundles: zip archives that can contain code (in the form of native libraries), resources, DVD overlay +Mods are `.dusk` bundles: zip archives that can contain code (native libraries or scripts), resources, DVD overlay files, and texture replacements. Mods may be enabled, disabled and reloaded at runtime. -When code mods are loaded, they get dynamically linked by the operating system to the running game process. The mod +There are three types of mods: + +- **Asset-only mods**: Mods that contain no code, and may replace files on the game disc ("overlays") and provide + replacement textures (texture packs). +- **Native mods (C++)**: Fully-featured, with the ability to interop with game code and hook functions. Must be compiled + for every supported platform. (See [mod-template](https://github.com/TwilitRealm/mod-template)) +- **Script mods (Luau)**: Simple, widely-compatible, but can only access provided services. + +## Table of Contents + +1. [mod.json](#modjson) +2. [Asset-only Mods](#asset-only-mods) +3. [Native Mods (C++)](#native-mods) +4. [Script Mods (Luau)](#script-mods) +5. [Services](#services) +6. [Built-in Services](#built-in-services) +7. [Hooking Game Functions](#hooking-game-functions) +8. [Asset Overlays](#asset-overlays) +9. [Runtime Lifecycle](#runtime-lifecycle) +10. [Error Handling](#error-handling) +11. [Advanced](#advanced) + +--- + +## mod.json + +Every mod starts with a single file, a `mod.json`: + +```json +{ + "id": "com.example.my_mod", + "name": "My Mod", + "version": "1.0.0", + "author": "Your Name", + "description": "A short description shown in the mod manager.", + "icon": "res/icon.png", + "banner": "res/banner.png" +} +``` + +`id` is required: a unique, stable identifier (reverse-DNS style; periods, underscores, and lowercase alphanumerics). +Everything else is optional but recommended. + +`icon` and `banner` are bundle paths to PNG images that display in the in-game mod manager and mod website. A square +icon (1:1), and a banner (~3.5:1, minimum 800px width). If omitted, `res/icon.png` and `res/banner.png` are used +automatically when present. + +Simply create a zip file with a `mod.json`, and rename it to `.dusk`. That's it! + +--- + +## Asset-only Mods + +``` +my_mod.dusk +├── mod.json +├── res/ (optional bundled resources) +├── overlay/ (optional game file overrides) +└── textures/ (optional texture replacements) +``` + +Place files in `overlay/` to replace the disc version of that file. Examples: + +- `overlay/Movie/demo_movie98_00.thp`: Replaces `Movie/demo_movie98_00.thp` on disc. +- `overlay/res/Object/Kmdl/archive/bmwr/al.bmd`: Replaces `archive/bmwr/al.bmd` _within_ `res/Object/Kmdl.arc` without + overwriting the entire `.arc`. + +Place textures in `textures/` to automatically register them as texture replacements when active. These follow the same +[Dolphin-compatible naming scheme](#textureservice-modssvctextureh) as the user `/texture_replacements/` +directory. Directories are scanned recursively. Examples: + +- `textures/tex1_256x128_e6a4c7be9bf48305_14.dds`: Replaces the Hero's Clothes texture. + +Simply zip the `mod.json` and adjacent folders, then rename to `.dusk`. Then, copy the `.dusk` into the user mods +folder: + +- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` +- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` +- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` + +--- + +## Native Mods + +Mods built with [mod-template](https://github.com/TwilitRealm/mod-template) are native C++ mods. Native mods are very +powerful and can interact with and [hook](#hooking-game-functions) game code directly. All features are available to +native mods. + +Example C++ mod: + +```cpp +#include "mods/service.hpp" +#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; +} + +} +``` + +When native mods are loaded, they get dynamically linked by the operating system to the running game process. The mod exports lifecycle functions that Dusklight calls into (`mod_initialize`, `mod_update`, `mod_shutdown`), and the mod communicates with the host via **services**: plain C APIs, individually versioned. Dusklight exports several built-in services, and mods may export services of their own, permitting framework mods and cross-mod integration. -Beyond services, 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. +Beyond services, native mods have full access to the original game's code: include game headers, call directly into any +public function, read and write data fields, and hook the vast majority of game functions. -## Table of Contents +### Quick Start (Native Mods) -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. +Create a repository from +the [mod-template](https://github.com/new?template_name=mod-template&template_owner=TwilitRealm), +a self-contained CMake project that uses the Dusklight mod SDK. It includes a GitHub Actions CI workflow that builds the +mod for every supported platform. ``` my_mod/ @@ -65,10 +167,12 @@ add_mod(my_mod Available features: -- `fmt`: Provides the header-only `{fmt}` library and the formatted logging helpers in `mods/svc/log.hpp`. +- `fmt`: Provides the header-only `{fmt}` library and the formatted logging helpers in + [`mods/svc/log.hpp`](../sdk/include/mods/svc/log.hpp). - `game`: Allows calling into and hooking game code. Mods that **only** use services may omit it, providing a wider range of compatibility with Dusklight versions and a slightly faster build process. -- `webgpu`: Allows importing the WebGPU API (`webgpu/webgpu.h`). Must be enabled when using +- `webgpu`: Allows importing the WebGPU API + ([`webgpu/webgpu.h`](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)). Must be enabled when using [GfxService](#gfxservice-modssvcgfxh). Building produces `my_mod.dusk` in `build/mods/`. Copy the `.dusk` into the user mods folder: @@ -81,63 +185,101 @@ Passing `--mods ` on the command line replaces the user directory with one --- -## mod.json +## Script Mods + +For simpler use cases where direct game code access and hooks aren't necessary, Luau mods are also supported. +Luau mods do not need to be compiled, and are always supported on all platforms. However, they can only use services +that are provided as Luau modules. + +Mods can utilize Luau to add UI elements to their mod panel, use configuration variables, and dynamically swap out +models/textures at runtime (e.g. to switch model variants or disable certain replacements) while remaining widely +compatible. + +Example mod structure: + +``` +my_luau_mod.dusk +├── mod.json +└── res/ + ├── main.luau + └── lib/util.luau +``` + +Set the `runtime` to `dev.twilitrealm.luau@1.0` in `mod.json`: ```json { - "id": "com.example.my_mod", - "name": "My Mod", + "id": "com.example.my_luau_mod", + "name": "My Script 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" + "runtime": "dev.twilitrealm.luau@1.0" } ``` -`id` is required: a unique, stable identifier (reverse-DNS style; periods, underscores, and alphanumerics). Everything -else is optional but recommended. +`res/main.luau` runs once when the mod activates. Register optional update and shutdown callbacks through +`dusklight.host`: -`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; -} -} +```lua +local host = require("dusklight.host") +host.on_update(function() + -- Runs every frame +end) +host.on_shutdown(function() + -- Runs on mod deactivation +end) ``` -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. +Require script modules with `./` or `../` paths relative to the requiring file. The runtime appends `.luau` and rejects +paths that escape `res/`. + +The runtime provides these modules: + +- `dusklight.log`: `write`, `trace`, `debug`, `info`, `warn`, and `error`. +- `dusklight.host`: host `version`, mod metadata and directories, lifecycle callbacks, and `fail`. +- `dusklight.config`: bool, integer, float, and string variables with `get`, `set`, and subscriptions. +- `dusklight.resource`: binary-safe reads from the mod's `res/` tree. +- `dusklight.overlay`: file and copied-buffer overlays with removable handles. +- `dusklight.texture`: encoded-file and raw-data replacements with unregisterable handles. +- `dusklight.ui`: Mods panels, controls, lists, windows, dialogs, styles, menu tabs, toasts, and clipboard access. + +For completion and type checking, add `sdk/luau/dusklight.d.luau` to the `luau-lsp.types.definitionFiles` setting. + +Configurable overlay example: + +```lua +local config = require("dusklight.config") +local overlay = require("dusklight.overlay") + +local hood = config.register({ name = "hood", type = "bool", default = true }) +local current + +local function apply(enabled) + if current then current:remove() end + current = overlay.add_file("/res/Object/Alink.arc", + enabled and "res/alink_hood.arc" or "res/alink_nohood.arc") +end + +hood:subscribe(apply) +apply(hood:get()) +``` + +To create a script mod, copy `sdk/luau/template`, edit its manifest and source, then zip the `mod.json` and adjacent +folders and rename to `.dusk`. Copy the `.dusk` into the user mods folder: + +- Windows: `%APPDATA%\TwilitRealm\Dusklight\mods` +- Linux: `~/.local/share/TwilitRealm/Dusklight/mods` +- macOS: `~/Library/Application Support/TwilitRealm/Dusklight/mods` + +**Restrictions:** The Luau VM has no raw filesystem, network, or game-code access. Each script mod has a 64 MiB memory +limit. Calls are interrupted after 250 ms for updates and UI callbacks or 5 seconds for lifecycle calls. An uncaught +error, timeout, or memory exhaustion fails and disables the mod. --- ## Services -A service is a struct of C function pointers with a version header. You declare what you use at file scope, and the -loader resolves it before your mod initializes: +A service is a struct of C function pointers with a version header. Import services at file scope, and the loader +resolves them before initializing the mod: ```cpp IMPORT_SERVICE(LogService, svc_log); // required, latest minor version @@ -145,7 +287,7 @@ IMPORT_SERVICE_VERSION(LogService, svc_log, 0); // required, minimum minor ver 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 +A service should be imported in only **one** file (usually your `mod.cpp`). Other files may simply use `svc_log` or `mods::log::` after including the appropriate header. Each service is individually versioned, and there may be multiple major versions of a service provided at once, @@ -153,26 +295,19 @@ allowing backwards compatibility with older mods while still changing services f 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. +`IMPORT_SERVICE` and `IMPORT_OPTIONAL_SERVICE` require the latest minor version compiled against, guaranteeing that +every function is present. If a mod doesn't use (or may operate without) functions added in later minor versions, and +wants to remain compatible with older Dusklight versions, it may use `IMPORT_SERVICE_VERSION` or +`IMPORT_OPTIONAL_SERVICE_VERSION` to require an older minor version. It can then check `SERVICE_HAS` at runtime to see +if a newer function is present (i.e. running on a new enough Dusklight version). --- ## Built-in Services -### LogService (`mods/svc/log.h`) +### LogService ([`mods/svc/log.h`](../sdk/include/mods/svc/log.h)) + +**C++** ```cpp IMPORT_SERVICE(LogService, svc_log); @@ -183,9 +318,16 @@ svc_log->error(mod_ctx, "very bad"); svc_log->write(mod_ctx, LOG_LEVEL_DEBUG, "verbose details"); ``` +**Luau** + +```lua +local log = require("dusklight.log") +log.info("spawned the thing") +``` + Messages appear in the console prefixed with your mod ID. Messages are plain UTF-8 strings and are copied before the call returns. C++ mods can enable `add_mod(... FEATURES fmt)` and use the formatted logging helpers in -`mods/svc/log.hpp`: +[`mods/svc/log.hpp`](../sdk/include/mods/svc/log.hpp): ```cpp #include @@ -194,11 +336,13 @@ mods::log::info("spawned actor {} at ({}, {})", actorName, x, y); mods::log::warn("health is down to {:.1f}%", healthPercent); ``` -### ResourceService (`mods/svc/resource.h`) +### ResourceService ([`mods/svc/resource.h`](../sdk/include/mods/svc/resource.h)) Loads files from the `res/` tree of your `.dusk` archive. Paths are relative to `res/` (pass `"config.txt"`, not `"res/config.txt"`); absolute paths and `..` are rejected. +**C++** + ```cpp IMPORT_SERVICE(ResourceService, svc_resource); @@ -209,10 +353,17 @@ if (svc_resource->load(mod_ctx, "config.txt", &buf) == MOD_OK) { } ``` +**Luau** + +```lua +local resource = require("dusklight.resource") +local contents = resource.load("config.txt") +``` + Missing files return `MOD_UNAVAILABLE`. Always `free` what you `load`. The bundle is read-only; use `HostService::data_dir` for persistent storage. -### FileService (`mods/svc/file.h`) +### FileService ([`mods/svc/file.h`](../sdk/include/mods/svc/file.h)) Provides file and folder pickers, file I/O, exports and folder enumeration. @@ -257,9 +408,10 @@ mods::file::export_file(location, "report.txt", [](mods::file::PickResult result `export_file` copies an existing file to a user-selected destination and returns the destination location in its callback. Mod-owned persistent files belong in `HostService::data_dir`. -### HttpService (`mods/svc/http.h`) +### HttpService ([`mods/svc/http.h`](../sdk/include/mods/svc/http.h)) -Asynchronous HTTPS requests supporting HTTP/2 and TLS 1.2+. C++ mods should use the helpers in `mods/svc/http.hpp`: +Asynchronous HTTPS requests supporting HTTP/2 and TLS 1.2+. C++ mods should use the helpers in +[`mods/svc/http.hpp`](../sdk/include/mods/svc/http.hpp): ```cpp #include "mods/svc/http.hpp" @@ -299,9 +451,87 @@ For large responses, set `downloadPath` to an absolute path in the calling mod's an empty `body` and the final path in `downloadPath`. Check `Response::ok()` before using the file. `Pending::progress()` reports download progress when the server provides a total size. -### HostService (`mods/svc/host.h`) +### WebSocketService ([`mods/svc/websocket.h`](../sdk/include/mods/svc/websocket.h)) -Mod metadata and runtime interaction with the loader: +WebSocket client connections with text or binary messages. Secure `wss://` URLs are supported everywhere. Insecure +`ws://` is limited to `localhost`, `127.0.0.1`, and `[::1]`. + +```cpp +#include "mods/svc/websocket.hpp" + +IMPORT_SERVICE(WebSocketService, svc_websocket); + +mods::ws::Connection connection; + +MOD_EXPORT ModResult mod_initialize(ModError*) { + connection = mods::ws::connect({.url = "wss://example.com/events"}); + return connection ? MOD_OK : connection.result(); +} + +MOD_EXPORT ModResult mod_update(ModError*) { + mods::ws::Event event; + while (mods::ws::poll(event)) { + if (event.type == WEBSOCKET_EVENT_MESSAGE) { + consume(event.data); + } else if (event.type == WEBSOCKET_EVENT_CLOSED) { + schedule_reconnect(event.error); + } + } + return MOD_OK; +} +``` + +Keep the `Connection` alive and drain `mods::ws::poll()` regularly, usually on every `mod_update` tick. A connection +emits an (optional) `OPEN` event, zero to many `MESSAGE` events, and exactly one `CLOSED` event. + +**Restrictions:** A mod may only open four connections at once. Messages have a 1 MiB limit by default, and may request +up to 16 MiB. Unread data is limited to 16 MiB and the outbound queue to 4 MiB. `send` returns `MOD_CONFLICT` when the +outbound queue is full. Dropping the `Connection` or deactivating the mod attempts to gracefully close with code 1001, +until the close deadline expires. + +### NetService ([`mods/svc/net.h`](../sdk/include/mods/svc/net.h)) + +Asynchronous raw TCP and UDP networking. Endpoints can be `tcp://host:port` or `udp://host:port`. TCP connections and +`resolve` accept hostnames. Listeners and UDP endpoints require IP literals. + +```cpp +#include "mods/svc/net.hpp" + +IMPORT_SERVICE(NetService, svc_net); + +mods::net::BindOutcome bound; +mods::net::Socket listener; +mods::net::Socket client; + +MOD_EXPORT ModResult mod_initialize(ModError*) { + listener = mods::net::listen("tcp://127.0.0.1:0", &bound); + client = mods::net::connect(bound.local); + return listener && client ? MOD_OK : MOD_ERROR; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + mods::net::Event event; + while (mods::net::poll(event)) { + if (event.type == NET_EVENT_ACCEPTED) { + remember_client(mods::net::adopt(event.accepted)); + } else if (event.type == NET_EVENT_STREAM_DATA) { + consume(event.data); + } + } + return MOD_OK; +} +``` + +`send` and `send_to` copy the payload and return `MOD_CONFLICT` when the socket's outbound queue is full. `stats` +reports queued bytes, traffic, dropped inbound datagrams, and asynchronous UDP send failures. + +**Restrictions:** A mod may only have 32 streams, 4 listeners, 4 UDP sockets, and 8 DNS resolutions active at once. + +### HostService ([`mods/svc/host.h`](../sdk/include/mods/svc/host.h)) + +Mod metadata and runtime interaction with the loader. + +**C++** ```cpp IMPORT_SERVICE(HostService, svc_host); @@ -319,6 +549,20 @@ if (svc_host->data_dir(mod_ctx, &dataDir) == MOD_OK) { svc_host->fail(mod_ctx, MOD_ERROR, "something unrecoverable happened"); ``` +**Luau** + +```lua +local host = require("dusklight.host") +local dataDir = host.data_dir() +host.on_update(function() + -- Runs every frame +end) +host.on_shutdown(function() + -- Runs on mod deactivation +end) +host.fail("something unrecoverable happened") +``` + `get_service`/`publish_service` provide dynamic service lookup; see [Exporting Services](#exporting-services). **Lifecycle watches.** If your mod provides a service that hands out per-caller state (registrations, callbacks, @@ -341,17 +585,19 @@ svc_host->watch_mod_lifecycle(mod_ctx, on_mod_lifecycle, nullptr, &watch); `MOD_LIFECYCLE_DETACHED` fires on the game thread at a lifecycle safe point, after the subject's `mod_shutdown` ran and every service dropped its state. For your own mod's teardown, use `mod_shutdown` instead. -### HookService (`mods/svc/hook.h`) +### HookService ([`mods/svc/hook.h`](../sdk/include/mods/svc/hook.h)) Installs hooks on game functions and resolves symbols by name. You'll rarely call it directly; use the typed helpers in -`mods/svc/hook.hpp` described in [Hooking Game Functions](#hooking-game-functions). +[`mods/svc/hook.hpp`](../sdk/include/mods/svc/hook.hpp) described in +[Hooking Game Functions](#hooking-game-functions). -### OverlayService (`mods/svc/overlay.h`) +### OverlayService ([`mods/svc/overlay.h`](../sdk/include/mods/svc/overlay.h)) Registers DVD file overlays at runtime: the dynamic counterpart to the static `overlay/` directory (see [Asset Overlays](#asset-overlays)). Overlay a disc path with a file from your bundle, a file within an archive, -or with a caller-owned buffer -(copied on registration): +or with a caller-owned buffer (copied on registration). + +**C++** ```cpp IMPORT_SERVICE(OverlayService, svc_overlay); @@ -363,6 +609,14 @@ svc_overlay->add_buffer(mod_ctx, "/generated.txt", data, size, nullptr); svc_overlay->remove(mod_ctx, handle); ``` +**Luau** + +```lua +local overlay = require("dusklight.overlay") +local replacement = overlay.add_file("/Movie/demo_movie98_00.thp", "res/replacement.thp") +replacement:remove() +``` + `disc_path` must be absolute (leading `/`) and is matched against the disc case-insensitively. Paths that don't exist on the disc are added as new files. Changes are applied at the next frame boundary, and data the game already read stays in memory until the file is re-read: sometimes a scene reload, and in the worst case, a full restart. @@ -372,11 +626,13 @@ data get refreshed without a full restart. See [Asset Overlays](#asset-overlays) for priority and conflict handling. -### TextureService (`mods/svc/texture.h`) +### TextureService ([`mods/svc/texture.h`](../sdk/include/mods/svc/texture.h)) Registers texture replacements at runtime: the dynamic counterpart to the static `textures/` directory (see [Asset Overlays](#asset-overlays)). Two forms: raw texel data with an explicit key, or an encoded `.dds`/`.png` from -your bundle whose filename encodes the key: +your bundle whose filename encodes the key. + +**C++** ```cpp IMPORT_SERVICE(TextureService, svc_texture); @@ -397,6 +653,14 @@ svc_texture->register_data(mod_ctx, &key, &data, nullptr); svc_texture->unregister(mod_ctx, handle); ``` +**Luau** + +```lua +local texture = require("dusklight.texture") +local replacement = texture.register_file("res/tex1_32x32_$_6.png") +replacement:unregister() +``` + Filenames use the same Dolphin-style convention as the user's `texture_replacements` directory: `tex1_{w}x{h}_{texhash}[_{tluthash}]_{fmt}.dds|.png`, where hashes may be `$` (wildcard). `_mipN` sidecar files next to a registered file are picked up automatically. Files are decoded lazily on first use by the renderer; raw data is copied @@ -404,11 +668,13 @@ at registration. Registrations follow your mod's lifecycle. See [Asset Overlays](#asset-overlays) for priority and conflict handling. -### ConfigService (`mods/svc/config.h`) +### ConfigService ([`mods/svc/config.h`](../sdk/include/mods/svc/config.h)) Persistent, mod-scoped configuration variables. Each var is stored in the user's `config.json` under `mod..` (escaping: `.` → `_`, `_` → `__`, so `com.example.my_mod` becomes `com_example_my__mod`), -next to the host's own settings: +next to the host's own settings. + +**C++** ```cpp IMPORT_SERVICE(ConfigService, svc_config); @@ -432,6 +698,17 @@ void on_speed_changed(ModContext* ctx, ConfigVarHandle var, const ConfigVarValue svc_config->subscribe(mod_ctx, var, on_speed_changed, nullptr, nullptr); ``` +**Luau** + +```lua +local config = require("dusklight.config") +local speed = config.register({ name = "speedMultiplier", type = "float", default = 1.0 }) +speed:subscribe(function(value, previous) + -- React to the new value. +end) +speed:set(2.0) +``` + Types: `CONFIG_VAR_BOOL` (`bool`), `CONFIG_VAR_INT` (`int64_t`), `CONFIG_VAR_FLOAT` (`double`), `CONFIG_VAR_STRING` (UTF-8; `get_string` copies into a caller buffer, pass a `NULL` buffer with size 0 to query the length). Accessors are typed and must match the registration. @@ -440,7 +717,7 @@ Change callbacks fire on the game thread whenever the value changes at runtime ( Writes that store the same value are silent. Values applied from `config.json` or `--cvar` at registration do **not** fire callbacks; read the value after `register_var` for the starting state. -### SaveService (`mods/svc/save.h`) +### SaveService ([`mods/svc/save.h`](../sdk/include/mods/svc/save.h)) Stores named binary blobs for each save slot. Blob names are scoped to the calling mod, and each mod may store up to `SAVE_BLOB_BUDGET_BYTES` per slot. The service copies data passed to `set_blob`. @@ -473,7 +750,7 @@ buffer contract as `get_blob`. Pass a `NULL` buffer to either read function to q 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`) +### StageService ([`mods/svc/stage.h`](../sdk/include/mods/svc/stage.h)) Allows making changes to a stage's "stage info" (contents of .dzs/.dzr files). (Currently only supports editing actor nodes.) @@ -522,7 +799,7 @@ Stage names may contain up to 8 characters. For patches and deletions, room `0xf 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`) +### UiService ([`mods/svc/ui.h`](../sdk/include/mods/svc/ui.h)) Integrate seamlessly with Dusklight's UI system: add controls and buttons to your mod's detail pane in the Mods window, create custom windows and modal dialogs, apply custom RCSS stylesheets (anywhere!), and add menu bar tabs. @@ -532,6 +809,8 @@ content is rebuilt, and `update` runs every frame while that mod is selected. Wh pane carries your mod's id as a `mod-id` attribute (like custom window roots), so scoped RCSS can target it (e.g. `[mod-id="com.example.mod"]`). +**C++** + ```cpp IMPORT_SERVICE(UiService, svc_ui); @@ -555,6 +834,18 @@ panel.update = update; svc_ui->register_mods_panel(mod_ctx, &panel); ``` +**Luau** + +```lua +local ui = require("dusklight.ui") +ui.register_mods_panel({ + build = function(panel) + panel:add_section("Status") + panel:add_text("running") + end, +}) +``` + Element setters must match the element kind: `elem_set_text`/`elem_set_rml` on text rows, and `elem_set_progress` on progress bars. `elem_set_class` sets or clears an RCSS class on any element handle, for styling via scoped or per-window RCSS. A non-`MOD_OK` result from `build`/`update` fails your mod, as do exceptions thrown from any UI @@ -704,7 +995,7 @@ existing documents restyle immediately, and future ones pick it up when created. host styles and may override them. Scope selectors tightly (use `[mod-id="..."]`!), especially for `UI_SCOPE_WINDOW`, unless changing host UI is intentional. -### WindowService (`mods/svc/window.h`) +### WindowService ([`mods/svc/window.h`](../sdk/include/mods/svc/window.h)) Allows creating new windows that can be rendered to via `GfxService`. @@ -724,12 +1015,13 @@ 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`) +### GfxService ([`mods/svc/gfx.h`](../sdk/include/mods/svc/gfx.h)) **Requires `add_mod(... FEATURES webgpu)`** -Direct WebGPU access at various stages of the rendering pipeline. Mods use the `wgpu*` C API (via `webgpu/webgpu.h`) for -custom draws and compute dispatches. Mods must manage their own WebGPU state, including pipelines and bind groups. +Direct WebGPU access at various stages of the rendering pipeline. Mods use the `wgpu*` C API (via +[`webgpu/webgpu.h`](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)) for custom draws and compute +dispatches. Mods must manage their own WebGPU state, including pipelines and bind groups. ```cpp IMPORT_SERVICE(GfxService, svc_gfx); @@ -779,7 +1071,7 @@ To create a `WGPUSurface` manually, `GfxDeviceInfo` holds the `WGPUInstance` and `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`) +### CameraService ([`mods/svc/camera.h`](../sdk/include/mods/svc/camera.h)) Converts a game view provided by a render callback into WebGPU-convention camera data. Matrix fields are column-major `float[16]` values using the matrix * column-vector convention (transpose of the game's row-major `Mtx`/`Mtx44` layout), @@ -801,7 +1093,7 @@ first in-game frame. Projection matrices match the renderer's WebGPU clip conven Camera operators allow overriding the main camera. When an operator callback returns true, its values replace the camera state for the current frame. Register and unregister using `register_camera_operator` / `unregister_camera_operator`. -### GameModeService (`mods/svc/game_mode.h`) +### GameModeService ([`mods/svc/game_mode.h`](../sdk/include/mods/svc/game_mode.h)) Allows a mod to register a game mode with callbacks for key gameplay and save lifecycle events. Registered game modes appear in the prelaunch menu. Game modes may use a unique set of saves by configuring `save_name`; leave it empty to use @@ -920,6 +1212,82 @@ svc_game_mode->register_game_mode(mod_ctx, &gameModeDesc); ``` +### ActorService (`mods/svc/actor.h`) + +A service that manages registering and creating custom actors. These actors will be run by the game as if they are part of the engine. These actors can be created by the game either by its 16-bit actor name, or a 7-character long name that can +be loaded by a stage. + +```cpp +#include "mods/svc/actor.h" +IMPORT_SERVICE(ActorService, svc_actor); + +class myActor_c : public fopAc_ac_c {}; + +int myActor_Create(void* i_this) { + // Ran several times, until it returns cPhs_COMPLEATE_e to allow for async loading + return cPhs_COMPLEATE_e; +} + +int myActor_Delete(void* i_this) { + // Free resources here + return 1; +} + +int myActor_Execute(void* i_this) { + // Ran once per game tick + return 1; +} + +int myActor_IsDelete(void* i_this) { + // Returns 1 when the actor can be deleted + return 1; +} + +int myActor_Draw(void* i_this) { + // Code to draw the actor + return 1; +} + +s16 actor_name; // The process name that can be used by the game to load the actor +ActorHandle actor_handle; +ActorProfileDesc profDesc = { + .name = "AUnique", // The name used by the stage loader to load the actor with. + // It has a character limit of 7 and must be unique among active + // mod actors. Matching a game actor name overrides stage lookup. + .priority_group = 7, // When, relative to other actors _Execute should run + // See: mods/svc/actor.h + .process_size = sizeof(myActor_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // Defines when the actor should be drawn relative + // to other actors (see f_pc_draw_priority.h) + .status = fopAcStts_CULL_e | fopAcStts_UNK_0x4000_e | fopAcStts_UNK_0x40000_e, + .group = fopAc_ACTOR_e, // Can be fopAc_ACTOR_e, fopAc_PLAYER_e, fopAc_ENEMY_e, or fopAc_NPC_e + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = myActor_Create, + .delete_function = myActor_Delete, + .execute_function = myActor_Execute, + .is_delete_function = myActor_IsDelete, + .draw_function = myActor_Draw, +}; +svc_actor->register_actor(mod_ctx, &profDesc, &actor_name, &actor_handle); + +// Spawn the actor at the player's position +fopAc_ac_c* plr = dComIfGp_getPlayer(0); +if (plr) { + ActorSpawnParams spawnParams = { + .parameters = 0, + .argument = 0, + .room_num = fopAcM_GetRoomNo(plr), + .position = {plr->current.pos.x, plr->current.pos.y, plr->current.pos.z}, + .angle = {plr->current.angle.x, plr->current.angle.y, plr->current.angle.z}, + .scale = {1.0f, 1.0f, 1.0f} + }; + ActorId created_actor_id; + svc_actor->create_actor(mod_ctx, actor_name, &spawnParams, &created_actor_id); +} +``` + +See `mods/custom_actor_demo` for a more complete example. + --- ## Hooking Game Functions @@ -927,7 +1295,7 @@ svc_game_mode->register_game_mode(mod_ctx, &gameModeDesc); **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: +[`mods/svc/hook.hpp`](../sdk/include/mods/svc/hook.hpp) provides typed helpers over the hook service: ```cpp #include "mods/svc/hook.hpp" diff --git a/extern/aurora b/extern/aurora index f8573d34e6..749d6ee7a2 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit f8573d34e632aea81039526a728b34f373d247ef +Subproject commit 749d6ee7a22bdfab78c8ece9047bca5d79aa72ca diff --git a/extern/borealis b/extern/borealis index 4b76f9ea35..f55910bd79 160000 --- a/extern/borealis +++ b/extern/borealis @@ -1 +1 @@ -Subproject commit 4b76f9ea35eaa116a57fd732b1c4954b6f4d0316 +Subproject commit f55910bd79248db250ebd9debb6624d78538c21c diff --git a/files.cmake b/files.cmake index 7cde5bfb2f..5c7a9223a2 100644 --- a/files.cmake +++ b/files.cmake @@ -1432,7 +1432,6 @@ set(DUSK_FILES src/dusk/dvd_asset.cpp src/dusk/dvd_asset.hpp src/dusk/extras.c - src/dusk/frame_interpolation.cpp src/dusk/commands.cpp src/dusk/commands.hpp src/dusk/game_clock.cpp @@ -1462,6 +1461,10 @@ set(DUSK_FILES src/dusk/imgui/ImGuiStateShare.cpp src/dusk/imgui/ImGuiStateShare.hpp src/dusk/imgui/ImGuiStubLog.cpp + src/dusk/interp/camera.cpp + src/dusk/interp/dual_buffer.cpp + src/dusk/interp/frame_interpolation.cpp + src/dusk/interp/line.cpp src/dusk/io.cpp src/dusk/iso_validate.cpp src/dusk/language.cpp @@ -1483,12 +1486,14 @@ set(DUSK_FILES src/dusk/mods/loader/prepatch.cpp src/dusk/mods/loader/prepatch.hpp src/dusk/mods/item.hpp + src/dusk/mods/item_actor.cpp src/dusk/mods/item_checks.cpp src/dusk/mods/item_gives.cpp src/dusk/mods/log_buffer.cpp src/dusk/mods/log_buffer.hpp src/dusk/mods/manifest.cpp src/dusk/mods/manifest.hpp + src/dusk/mods/svc/actor.cpp src/dusk/mods/svc/camera.cpp src/dusk/mods/svc/config.cpp src/dusk/mods/svc/config.hpp @@ -1499,6 +1504,9 @@ set(DUSK_FILES src/dusk/mods/svc/hook.cpp src/dusk/mods/svc/host.cpp src/dusk/mods/svc/http.cpp + src/dusk/mods/svc/net.cpp + src/dusk/mods/svc/net.hpp + src/dusk/mods/svc/websocket.cpp src/dusk/mods/svc/item.cpp src/dusk/mods/svc/item.hpp src/dusk/mods/svc/log.cpp diff --git a/include/SSystem/SComponent/c_bg_s_chk.h b/include/SSystem/SComponent/c_bg_s_chk.h index 6908ef80ed..badc04679a 100644 --- a/include/SSystem/SComponent/c_bg_s_chk.h +++ b/include/SSystem/SComponent/c_bg_s_chk.h @@ -5,7 +5,6 @@ #include "f_pc/f_pc_base.h" #include "SSystem/SComponent/c_bg_s_grp_pass_chk.h" #include "SSystem/SComponent/c_bg_s_poly_pass_chk.h" -#include "helpers/endian.h" struct cBgD_Vtx_t : public Vec {}; diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index 9947616d54..cd535d66c3 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -2,7 +2,6 @@ #define C_M3D_G_TRI_H_ #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "helpers/endian.h" class cM3dGCyl; diff --git a/include/Z2AudioCS/SpkMixingBuffer.h b/include/Z2AudioCS/SpkMixingBuffer.h index ccdb8902b0..5cdfcd74bb 100644 --- a/include/Z2AudioCS/SpkMixingBuffer.h +++ b/include/Z2AudioCS/SpkMixingBuffer.h @@ -13,7 +13,6 @@ public: bool update(s32 chan); void bzeroBuffer(s32 chan); -private: /* 0x00 */ s16* mBuffer[4]; }; diff --git a/include/Z2AudioCS/SpkSpeakerCtrl.h b/include/Z2AudioCS/SpkSpeakerCtrl.h index 7216eed07d..372d5b1835 100644 --- a/include/Z2AudioCS/SpkSpeakerCtrl.h +++ b/include/Z2AudioCS/SpkSpeakerCtrl.h @@ -41,7 +41,6 @@ public: static bool checkRadioSensitivity(s32 chan); static bool isSubmitPlayByRadioSensitivity(s32 chan); -private: }; #endif /* Z2AUDIOCS_SPKSPEAKERCTRL_H */ diff --git a/include/Z2AudioCS/SpkSystem.h b/include/Z2AudioCS/SpkSystem.h index 05541c72e5..03b30cda6e 100644 --- a/include/Z2AudioCS/SpkSystem.h +++ b/include/Z2AudioCS/SpkSystem.h @@ -28,7 +28,6 @@ public: inline SpkData* getData(void) const { return mData; } inline SpkMixingBuffer* getMixingBuffer(void) const { return mMixingBuffer; } -private: /* 0x00 */ JKRHeap* mHeap; /* 0x04 */ SpkData* mData; /* 0x08 */ SpkMixingBuffer* mMixingBuffer; diff --git a/include/Z2AudioCS/SpkTable.h b/include/Z2AudioCS/SpkTable.h index 862fdba3c1..f2234f5a06 100644 --- a/include/Z2AudioCS/SpkTable.h +++ b/include/Z2AudioCS/SpkTable.h @@ -31,7 +31,6 @@ public: return (SpkTableParams*)mEntryOffset + num; } - // private: /* 0x00 */ bool mIsInitialized; /* 0x04 */ s32 mNumOfSound; /* 0x08 */ u32 mEntryOffset; diff --git a/include/Z2AudioCS/SpkWave.h b/include/Z2AudioCS/SpkWave.h index 6a604d8a50..72cde1c0a0 100644 --- a/include/Z2AudioCS/SpkWave.h +++ b/include/Z2AudioCS/SpkWave.h @@ -25,7 +25,6 @@ public: inline const void* getResource(void) const { return mWaveData; } inline void* getResource(void) { return mWaveData; } -private: /* 0x00 */ void* mWaveData; }; diff --git a/include/Z2AudioLib/Z2Creature.h b/include/Z2AudioLib/Z2Creature.h index c4f96ca742..c17394b75f 100644 --- a/include/Z2AudioLib/Z2Creature.h +++ b/include/Z2AudioLib/Z2Creature.h @@ -67,7 +67,6 @@ public: void playVoice(int); virtual Z2SoundHandlePool* startCreatureVoice(JAISoundID soundID, s8 reverb); -private: /* 0xA0 */ s8 mCitizenID; /* 0xA1 */ s8 field_0xa1; /* 0xA2 */ bool mLinkSearch; diff --git a/include/Z2AudioLib/Z2LinkMgr.h b/include/Z2AudioLib/Z2LinkMgr.h index 705394df5e..e64c1729eb 100644 --- a/include/Z2AudioLib/Z2LinkMgr.h +++ b/include/Z2AudioLib/Z2LinkMgr.h @@ -63,7 +63,6 @@ public: friend class Z2LinkSoundStarter; friend struct Z2RideSoundStarter; -private: /* 0x90 Z2LinkSoundStarter */ /* 0x94 */ Z2SoundObjSimple mKantera; /* 0xB4 */ Vec field_0xb4; @@ -123,7 +122,6 @@ public: virtual void deleteObject(); -private: /* 0x90 */ // Z2RideSoundStarter mSoundStarter; /* 0x98 */ bool mLinkRiding; }; // Size: 0x9C @@ -136,7 +134,6 @@ public: Z2SoundHandlePool* startFireSound(u16); Z2SoundHandlePool* startSound(JAISoundID soundID, u32 mapinfo, s8 reverb); -private: /* 0x20 */ f32 field_0x20; }; diff --git a/include/Z2AudioLib/Z2SceneMgr.h b/include/Z2AudioLib/Z2SceneMgr.h index 1b3ef2cc0b..739c53bb10 100644 --- a/include/Z2AudioLib/Z2SceneMgr.h +++ b/include/Z2AudioLib/Z2SceneMgr.h @@ -47,7 +47,6 @@ public: s32 getBgmLoadStatus(u32 wave) { return getWaveLoadStatus(wave, 1); } u8 getDemoSeWaveNum() { return loadedDemoWave; } -private: /* 0x00 */ JAISoundID BGM_ID; /* 0x04 */ int sceneNum; /* 0x08 */ int timer; diff --git a/include/Z2AudioLib/Z2SeMgr.h b/include/Z2AudioLib/Z2SeMgr.h index 3f8ca03eb3..7075308ef7 100644 --- a/include/Z2AudioLib/Z2SeMgr.h +++ b/include/Z2AudioLib/Z2SeMgr.h @@ -84,7 +84,6 @@ public: void homeMenuSeCallback(s32); #endif -private: /* 0x000 */ JAISoundHandle mSoundHandle[24]; /* 0x060 */ JAISoundHandles mSoundHandles; #if VERSION >= VERSION_WII_USA_R0 diff --git a/include/Z2AudioLib/Z2SoundHandles.h b/include/Z2AudioLib/Z2SoundHandles.h index 5915e5967b..1ad344c796 100644 --- a/include/Z2AudioLib/Z2SoundHandles.h +++ b/include/Z2AudioLib/Z2SoundHandles.h @@ -44,7 +44,6 @@ public: return (Z2SoundHandlePool*)getNth(index); } -private: /* 0xC */ u8 handleNum_; }; diff --git a/include/Z2AudioLib/Z2SoundMgr.h b/include/Z2AudioLib/Z2SoundMgr.h index cd6341b2cb..eabf9d2614 100644 --- a/include/Z2AudioLib/Z2SoundMgr.h +++ b/include/Z2AudioLib/Z2SoundMgr.h @@ -38,7 +38,6 @@ public: const JAISeqMgr* getSeqMgr() const { return &seqMgr_; } JAIStreamMgr* getStreamMgr() { return &streamMgr_; } -private: /* 0x004 */ JAISeMgr seMgr_; /* 0x728 */ JAISeqMgr seqMgr_; /* 0x79C */ JAIStreamMgr streamMgr_; diff --git a/include/Z2AudioLib/Z2SoundObjMgr.h b/include/Z2AudioLib/Z2SoundObjMgr.h index 687f9eaf0a..64bf058ba1 100644 --- a/include/Z2AudioLib/Z2SoundObjMgr.h +++ b/include/Z2AudioLib/Z2SoundObjMgr.h @@ -104,7 +104,6 @@ public: JSUList* getAllList() { return &allList_; } #endif -private: /* 0x00 */ JSUList field_0x0; #if PARTIAL_DEBUG || DEBUG /* 0x0C */ JSUList allList_; diff --git a/include/Z2AudioLib/Z2WolfHowlMgr.h b/include/Z2AudioLib/Z2WolfHowlMgr.h index 10b746a4c1..5376499715 100644 --- a/include/Z2AudioLib/Z2WolfHowlMgr.h +++ b/include/Z2AudioLib/Z2WolfHowlMgr.h @@ -70,7 +70,6 @@ public: u8 getReleaseTimer() { return mReleaseTimer; } u8 getCorrectCurveID() { return mCorrectCurveID; } -private: /* 0x00 */ JAISoundHandle mWolfHowlHandle; /* 0x04 */ JAISoundHandle mWindStoneHandle; /* 0x08 */ JAISoundHandle mGuideHandle; diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index 384891c8d5..a0b70747bc 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -77,7 +77,6 @@ public: virtual void draw(); virtual ~daAlink_blur_c() {} - // private: /* 0x010 */ ResTIMG* m_blurTex; /* 0x014 */ int field_0x14; /* 0x018 */ u8 field_0x18[4]; @@ -113,7 +112,6 @@ public: void onAppearFlg() { mAppearFlg = true; } -private: /* 0x04 */ s16 mHitFlg; /* 0x06 */ s16 mAppearFlg; /* 0x08 */ f32 mKeepMinY; @@ -4558,30 +4556,8 @@ public: bool checkAimContext(); bool checkAimInputContext(); - void onIronBallChainInterpCallback(); - - static const int IRON_BALL_CHAIN_COUNT = 102; - cXyz mIBChainInterpPrevPos[IRON_BALL_CHAIN_COUNT]; - cXyz mIBChainInterpCurrPos[IRON_BALL_CHAIN_COUNT]; - csXyz mIBChainInterpPrevAngle[IRON_BALL_CHAIN_COUNT]; - csXyz mIBChainInterpCurrAngle[IRON_BALL_CHAIN_COUNT]; - cXyz mIBChainInterpPrevHandRoot; - cXyz mIBChainInterpCurrHandRoot; - bool mIBChainInterpPrevValid; - bool mIBChainInterpCurrValid; - - cXyz mHsChainInterpPrevTop; - cXyz mHsChainInterpCurrTop; - cXyz mHsChainInterpPrevRoot; - cXyz mHsChainInterpCurrRoot; - cXyz mHsChainInterpPrevSubRoot; - cXyz mHsChainInterpCurrSubRoot; - cXyz mHsChainInterpPrevSubTop; - cXyz mHsChainInterpCurrSubTop; - bool mHsChainInterpPrevValid; - bool mHsChainInterpCurrValid; - bool mIsRollstab = false; + void* mAnmBuffers[3] = {}; #endif }; // Size: 0x385C diff --git a/include/d/actor/d_a_arrow.h b/include/d/actor/d_a_arrow.h index 47f86eeb50..f15cf1aca8 100644 --- a/include/d/actor/d_a_arrow.h +++ b/include/d/actor/d_a_arrow.h @@ -110,7 +110,6 @@ public: void setModelMatrix(MtxP mtx) { mpModel->setBaseTRMtx(mtx); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ dBgS_ArrowLinChk field_0x56c; /* 0x5DC */ dBgS_ObjLinChk field_0x5dc; diff --git a/include/d/actor/d_a_b_dr.h b/include/d/actor/d_a_b_dr.h index e15a6e7ca5..d9f72089f4 100644 --- a/include/d/actor/d_a_b_dr.h +++ b/include/d/actor/d_a_b_dr.h @@ -82,7 +82,6 @@ public: u8 onTarget() { return mTarget = true; } u8 isBack() { return arg0; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x05B8 */ J3DModel* mpPartModel; diff --git a/include/d/actor/d_a_b_ds.h b/include/d/actor/d_a_b_ds.h index ee737a955a..7013465e93 100644 --- a/include/d/actor/d_a_b_ds.h +++ b/include/d/actor/d_a_b_ds.h @@ -189,7 +189,6 @@ public: void onDemo() { mIsDemo = true; } void offDemo() { mIsDemo = false; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x05B8 */ mDoExt_McaMorfSO* mpSwordMorf; diff --git a/include/d/actor/d_a_b_gnd.h b/include/d/actor/d_a_b_gnd.h index 0827102eec..dcf6c94905 100644 --- a/include/d/actor/d_a_b_gnd.h +++ b/include/d/actor/d_a_b_gnd.h @@ -189,12 +189,6 @@ public: /* 0x2740 */ u8 field_0x2740; /* 0x2744 */ dMsgFlow_c mMsgFlow; #if TARGET_PC - cXyz mReinsInterpPrev[2][16]; - cXyz mReinsInterpCurr[2][16]; - cXyz mReinsTexInterpPrev[2]; - cXyz mReinsTexInterpCurr[2]; - bool mReinsInterpPrevValid; - bool mReinsInterpCurrValid; s8 mDemoCamSyncTicks; #endif }; diff --git a/include/d/actor/d_a_b_mgn.h b/include/d/actor/d_a_b_mgn.h index 272d02b1ef..1ad1dd5cf7 100644 --- a/include/d/actor/d_a_b_mgn.h +++ b/include/d/actor/d_a_b_mgn.h @@ -92,7 +92,6 @@ public: bool isDown() { return mDownFlag != 0; } bool isAppear() { return mAppearFlag != 0; } -private: /* 0x05AC */ request_of_phase_process_class mMgnPhase; /* 0x05B4 */ request_of_phase_process_class mMgnePhase; /* 0x05BC */ mDoExt_McaMorfSO* mpMgnModelMorf; diff --git a/include/d/actor/d_a_b_tn.h b/include/d/actor/d_a_b_tn.h index 7de1007d28..87b9cd2fae 100644 --- a/include/d/actor/d_a_b_tn.h +++ b/include/d/actor/d_a_b_tn.h @@ -131,7 +131,6 @@ public: int CreateHeap(); int create(); -private: /* 0x05AC */ request_of_phase_process_class mPhaseReq1; /* 0x05B4 */ request_of_phase_process_class mPhaseReq2; /* 0x05BC */ J3DModel* mpPartModels[16]; diff --git a/include/d/actor/d_a_b_yo.h b/include/d/actor/d_a_b_yo.h index a133d364d6..3550b95a1c 100644 --- a/include/d/actor/d_a_b_yo.h +++ b/include/d/actor/d_a_b_yo.h @@ -80,7 +80,6 @@ public: void setDrawOff() { mIsInactive = 1; } bool isEnemyDemoEnd() { return (u8)mIsEnemyDemoEnd != 0; } -private: /* 0x05AC */ request_of_phase_process_class mPhase1; /* 0x05B4 */ request_of_phase_process_class mPhase2; /* 0x05BC */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_b_yo_ice.h b/include/d/actor/d_a_b_yo_ice.h index 2ad2e5388d..e0f064fa9d 100644 --- a/include/d/actor/d_a_b_yo_ice.h +++ b/include/d/actor/d_a_b_yo_ice.h @@ -51,7 +51,6 @@ public: void setSubNumber(int i_subNumber) { mSubNumber = i_subNumber; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ J3DModel* mpModel; /* 0x5B8 */ Z2Creature mCreatureSound; diff --git a/include/d/actor/d_a_b_zant_magic.h b/include/d/actor/d_a_b_zant_magic.h index 0d05f9bd41..e37b055bfd 100644 --- a/include/d/actor/d_a_b_zant_magic.h +++ b/include/d/actor/d_a_b_zant_magic.h @@ -24,7 +24,6 @@ public: int _delete(); int create(); -private: /* 0x5AC */ Mtx field_0x5ac; /* 0x5DC */ cXyz field_0x5dc; /* 0x5E8 */ f32 field_0x5e8; diff --git a/include/d/actor/d_a_b_zant_mobile.h b/include/d/actor/d_a_b_zant_mobile.h index 3af85c56b1..18dcdbabc1 100644 --- a/include/d/actor/d_a_b_zant_mobile.h +++ b/include/d/actor/d_a_b_zant_mobile.h @@ -33,7 +33,6 @@ public: bool isSearchContinue() { return mSearchContinue != false; } void offSearchContinue() { mSearchContinue = false; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_brkAnm* mpBrk; diff --git a/include/d/actor/d_a_bg.h b/include/d/actor/d_a_bg.h index 0a9859198b..51407a06c8 100644 --- a/include/d/actor/d_a_bg.h +++ b/include/d/actor/d_a_bg.h @@ -57,7 +57,6 @@ public: inline int execute(); inline int isDelete(); -private: /* 0x568 */ u8 field_0x568[0x570 - 0x568]; /* 0x570 */ daBg_Part mBgParts[6]; /* 0x5E8 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_boomerang.h b/include/d/actor/d_a_boomerang.h index fe39f226b7..2b527afe45 100644 --- a/include/d/actor/d_a_boomerang.h +++ b/include/d/actor/d_a_boomerang.h @@ -25,7 +25,6 @@ public: void onReserve() { mReserve = 1; } void offReserve() { mReserve = 0; } -private: /* 0x04 */ J2DScreen* m_cursorYellowScrn; /* 0x08 */ J2DPane* m_cursorYellowAllPane; /* 0x0C */ J2DPane* m_cursorYellow0Pane; @@ -126,7 +125,6 @@ public: bool getLockCntMax() { return m_lockCnt >= BOOMERANG_LOCK_MAX; } void onLockDistanceCancel() { onStateFlg0(FLG0_LOCK_DIST_CANCEL); } -private: /* 0x568 */ J3DModel* mp_boomModel; /* 0x56C */ J3DModel* mp_shippuModel; /* 0x570 */ J3DAnmTextureSRTKey* m_windBtk; diff --git a/include/d/actor/d_a_canoe.h b/include/d/actor/d_a_canoe.h index bf34a5eee7..bcd7615e18 100644 --- a/include/d/actor/d_a_canoe.h +++ b/include/d/actor/d_a_canoe.h @@ -65,7 +65,6 @@ public: field_0x1456 = 15; } -private: /* 0x0568 */ request_of_phase_process_class mPhaseReq; /* 0x0570 */ J3DModel* mpModel; /* 0x0574 */ J3DModel* mpPaddleModel; diff --git a/include/d/actor/d_a_coach_fire.h b/include/d/actor/d_a_coach_fire.h index f669525e9c..1e8aa2d661 100644 --- a/include/d/actor/d_a_coach_fire.h +++ b/include/d/actor/d_a_coach_fire.h @@ -42,7 +42,6 @@ public: void setNoHitTimer() { noHitTimer = 20; } inline int execute(); -private: /* 0x568 */ LIGHT_INFLUENCE mLightInfluence; /* 0x588 */ dCcD_Stts mStts; /* 0x5C4 */ dCcD_Sph mSph; diff --git a/include/d/actor/d_a_cow.h b/include/d/actor/d_a_cow.h index 403dc2aef6..e215256b91 100644 --- a/include/d/actor/d_a_cow.h +++ b/include/d/actor/d_a_cow.h @@ -208,7 +208,6 @@ public: u8 getCowIn() { return mCowIn; } u8 getNoNearCheckTimer() { return mNoNearCheckTimer; } -private: /* 0x568 */ u16 mFlags; /* 0x56c */ request_of_phase_process_class mPhase; /* 0x574 */ mDoExt_McaMorfSO* mpMorf; diff --git a/include/d/actor/d_a_crod.h b/include/d/actor/d_a_crod.h index 84938d454a..02311fbeb5 100644 --- a/include/d/actor/d_a_crod.h +++ b/include/d/actor/d_a_crod.h @@ -48,7 +48,6 @@ public: static f32 getFlyInitY() { return 40.0f; } static f32 getFlyInitZ() { return 50.0f; } -private: /* 0x568 */ J3DModel* mpBallModel; /* 0x56C */ mDoExt_bckAnm mBck; /* 0x588 */ J3DAnmTevRegKey* mpBallBrk; diff --git a/include/d/actor/d_a_cstaF.h b/include/d/actor/d_a_cstaF.h index 9cb9e06ff7..982aa061a8 100644 --- a/include/d/actor/d_a_cstaF.h +++ b/include/d/actor/d_a_cstaF.h @@ -40,7 +40,6 @@ public: }; static DUSK_GAME_DATA const BckTbl m_bckIdxTable[]; -private: /* 0x5A0 */ const char* m_arcName; /* 0x5A4 */ request_of_phase_process_class m_phase; /* 0x5AC */ J3DModel* mp_model; diff --git a/include/d/actor/d_a_cstatue.h b/include/d/actor/d_a_cstatue.h index ca0b3ca616..2b74240fb2 100644 --- a/include/d/actor/d_a_cstatue.h +++ b/include/d/actor/d_a_cstatue.h @@ -101,7 +101,6 @@ public: static DUSK_GAME_DATA u16 const m_bckIdxTable[daCstatueType_N][7]; -private: /* 0x568 */ const char* mResName; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_demo_item.h b/include/d/actor/d_a_demo_item.h index ed6d195f5e..62780f572f 100644 --- a/include/d/actor/d_a_demo_item.h +++ b/include/d/actor/d_a_demo_item.h @@ -55,7 +55,6 @@ public: void setOffsetPos(cXyz i_pos) { mOffsetPos = i_pos; } void setMaxScale(f32 i_scale) { mMaxScale = i_scale; } -private: /* 0x92C */ cXyz mOffsetPos; /* 0x938 */ f32 mMaxScale; /* 0x93C */ u8 field_0x93c; diff --git a/include/d/actor/d_a_door_boss.h b/include/d/actor/d_a_door_boss.h index afd7984bf1..722afc0a84 100644 --- a/include/d/actor/d_a_door_boss.h +++ b/include/d/actor/d_a_door_boss.h @@ -50,7 +50,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpDoorModel; /* 0x574 */ J3DModel* mpLockModel; diff --git a/include/d/actor/d_a_door_bossL1.h b/include/d/actor/d_a_door_bossL1.h index 7e14025cd2..c0b8f2b44a 100644 --- a/include/d/actor/d_a_door_bossL1.h +++ b/include/d/actor/d_a_door_bossL1.h @@ -76,7 +76,6 @@ public: void setAction(u8 action) { mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_bossL5.h b/include/d/actor/d_a_door_bossL5.h index 832f575ac1..d876bab9c8 100644 --- a/include/d/actor/d_a_door_bossL5.h +++ b/include/d/actor/d_a_door_bossL5.h @@ -72,7 +72,6 @@ public: return 1; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_dbdoor00.h b/include/d/actor/d_a_door_dbdoor00.h index 9b2f65e756..ec976c7f6b 100644 --- a/include/d/actor/d_a_door_dbdoor00.h +++ b/include/d/actor/d_a_door_dbdoor00.h @@ -41,7 +41,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } -// private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ request_of_phase_process_class mPhaseReq2; /* 0x578 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_door_knob00.h b/include/d/actor/d_a_door_knob00.h index 577b26b58e..742b8921c9 100644 --- a/include/d/actor/d_a_door_knob00.h +++ b/include/d/actor/d_a_door_knob00.h @@ -73,7 +73,6 @@ public: void onFlag(u16 flag) { field_0x60c |= flag; } int checkFlag(u16 flag) { return field_0x60c & flag; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ J3DModel* mModel1; diff --git a/include/d/actor/d_a_door_mbossL1.h b/include/d/actor/d_a_door_mbossL1.h index 2bd95d920b..7b76f903bc 100644 --- a/include/d/actor/d_a_door_mbossL1.h +++ b/include/d/actor/d_a_door_mbossL1.h @@ -121,7 +121,6 @@ public: mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhase1; /* 0x570 */ request_of_phase_process_class mPhase2; /* 0x578 */ request_of_phase_process_class mPhase3; diff --git a/include/d/actor/d_a_door_push.h b/include/d/actor/d_a_door_push.h index 5beb3aa564..f648ef208b 100644 --- a/include/d/actor/d_a_door_push.h +++ b/include/d/actor/d_a_door_push.h @@ -49,7 +49,6 @@ public: void setAction(u8 i_action) { mAction = i_action; } u32 getSceneNo() { return fopAcM_GetParamBit(this, 4, 6); } -// private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ dBgW* mpDoorBgW; diff --git a/include/d/actor/d_a_door_shutter.h b/include/d/actor/d_a_door_shutter.h index a8e99f1295..c3b134ddb8 100644 --- a/include/d/actor/d_a_door_shutter.h +++ b/include/d/actor/d_a_door_shutter.h @@ -123,7 +123,6 @@ public: bool checkFlag(u16 flag) { return field_0x68e & flag; } void setAction(u8 action) { mAction = action; } -private: /* 0x56C */ request_of_phase_process_class mPhase1; /* 0x574 */ request_of_phase_process_class mPhase2; /* 0x57C */ J3DModel* mModel1; diff --git a/include/d/actor/d_a_e_ai.h b/include/d/actor/d_a_e_ai.h index d2f1b6ec06..78c4174338 100644 --- a/include/d/actor/d_a_e_ai.h +++ b/include/d/actor/d_a_e_ai.h @@ -48,7 +48,6 @@ public: int CreateHeap(); int Create(); -private: /* 0x5AC */ JPABaseEmitter* mpEmitter; /* 0x5B0 */ request_of_phase_process_class m_phase; /* 0x5B8 */ u8 field_0x5b8; diff --git a/include/d/actor/d_a_e_bg.h b/include/d/actor/d_a_e_bg.h index c14b0cf533..b3b0e1d8bf 100644 --- a/include/d/actor/d_a_e_bg.h +++ b/include/d/actor/d_a_e_bg.h @@ -45,7 +45,6 @@ public: void setBgId(unsigned int i_bgId) { mBgId = i_bgId; } bool isBomb() { return mIsBomb; } -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ mDoExt_brkAnm* mpBrkAnm; diff --git a/include/d/actor/d_a_e_db.h b/include/d/actor/d_a_e_db.h index 4f10715443..a95722a6d1 100644 --- a/include/d/actor/d_a_e_db.h +++ b/include/d/actor/d_a_e_db.h @@ -80,12 +80,6 @@ public: /* 0x125C */ u32 field_0x125c; /* 0x1260 */ u8 field_0x1260[0x126C - 0x1260]; /* 0x126C */ u8 HIOInit; -#if TARGET_PC - cXyz mStalkLineInterpPrev[12]; - cXyz mStalkLineInterpCurr[12]; - bool mStalkLineInterpPrevValid; - bool mStalkLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_db_class) == 0x1270); diff --git a/include/d/actor/d_a_e_dk.h b/include/d/actor/d_a_e_dk.h index 381f8e1a62..2c7d46b84f 100644 --- a/include/d/actor/d_a_e_dk.h +++ b/include/d/actor/d_a_e_dk.h @@ -45,7 +45,6 @@ public: int create(); daE_DK_c(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ mDoExt_McaMorfSO* mpCoreMorfSO; diff --git a/include/d/actor/d_a_e_dt.h b/include/d/actor/d_a_e_dt.h index c5c83c76e0..0fdb13f4e5 100644 --- a/include/d/actor/d_a_e_dt.h +++ b/include/d/actor/d_a_e_dt.h @@ -83,7 +83,6 @@ public: MtxP getBackMtx() { return mpMorf->getModel()->getAnmMtx(1); } fpc_ProcID getDemoId() { return mDemoID; } -private: /* 0x05AC */ request_of_phase_process_class mPhase[3]; /* 0x05C4 */ J3DModel* mpChestModel; /* 0x05C8 */ J3DModel* mpSpitModel; diff --git a/include/d/actor/d_a_e_fb.h b/include/d/actor/d_a_e_fb.h index a4494c5e7a..ae48f77ea6 100644 --- a/include/d/actor/d_a_e_fb.h +++ b/include/d/actor/d_a_e_fb.h @@ -40,7 +40,6 @@ public: cPhs_Step create(); daE_FB_c(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_invisibleModel mInvisibleModel; diff --git a/include/d/actor/d_a_e_fk.h b/include/d/actor/d_a_e_fk.h index 390e4e3420..fb18f74792 100644 --- a/include/d/actor/d_a_e_fk.h +++ b/include/d/actor/d_a_e_fk.h @@ -52,7 +52,6 @@ public: void CreateChk(); int Create(); -private: /* 0x5AC */ u8 field_0x5AC[0x5B1 - 0x5AC]; /* 0x5B1 */ u8 mUpDownMode; /* 0x5B2 */ u8 field_0x5B2[0x5B6 - 0x5B2]; diff --git a/include/d/actor/d_a_e_fz.h b/include/d/actor/d_a_e_fz.h index e0b838aa51..e40232b74f 100644 --- a/include/d/actor/d_a_e_fz.h +++ b/include/d/actor/d_a_e_fz.h @@ -63,7 +63,6 @@ public: s32 CreateHeap(); s32 create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /**< Phase request used when creating the actor. */ /* 0x5B4 */ J3DModel* mpModel; /**< Pointer to the Mini Freezard's model. */ /* 0x5B8 */ mDoExt_invisibleModel mInvisibleModel; /**< Invisible model used for the Mini Freezard. */ diff --git a/include/d/actor/d_a_e_ge.h b/include/d/actor/d_a_e_ge.h index 527e5bb5fa..3c4d4ffbee 100644 --- a/include/d/actor/d_a_e_ge.h +++ b/include/d/actor/d_a_e_ge.h @@ -61,7 +61,6 @@ public: u8 getGroupNo() { return mGroupNo; } -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x5B8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_e_gi.h b/include/d/actor/d_a_e_gi.h index adadfd03b8..a731797f32 100644 --- a/include/d/actor/d_a_e_gi.h +++ b/include/d/actor/d_a_e_gi.h @@ -47,7 +47,6 @@ public: bool isBattleOn() { return mIsBattleOn; } bool isAttackStart() { return mIsAttackStart; } -private: /* 0x05AC */ request_of_phase_process_class mPhase; /* 0x05B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x05B8 */ J3DModel* mpSwordModel; diff --git a/include/d/actor/d_a_e_gm.h b/include/d/actor/d_a_e_gm.h index 370dea9150..de8c0d6acc 100644 --- a/include/d/actor/d_a_e_gm.h +++ b/include/d/actor/d_a_e_gm.h @@ -62,7 +62,6 @@ public: BOOL checkAction(actionFunc action) { return mAction == action; } BOOL checkOldAction(actionFunc action) { return mOldAction == action; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ dBgS_AcchCir mAcchCir; /* 0x5F4 */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_e_hb.h b/include/d/actor/d_a_e_hb.h index 3069bcd325..a7e0241007 100644 --- a/include/d/actor/d_a_e_hb.h +++ b/include/d/actor/d_a_e_hb.h @@ -73,12 +73,6 @@ public: /* 0x124C */ f32 field_0x124c; /* 0x1250 */ u8 field_0x1250[0x1264 - 0x1250]; /* 0x1264 */ u8 HIOInit; -#if TARGET_PC - cXyz mStalkLineInterpPrev[12]; - cXyz mStalkLineInterpCurr[12]; - bool mStalkLineInterpPrevValid; - bool mStalkLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_hb_class) == 0x1268); diff --git a/include/d/actor/d_a_e_hm.h b/include/d/actor/d_a_e_hm.h index 85f6e5422c..9be48a53f3 100644 --- a/include/d/actor/d_a_e_hm.h +++ b/include/d/actor/d_a_e_hm.h @@ -65,7 +65,6 @@ public: void CheckWall(); void CreateStyle(); int Create(); -private: /* 0x5AC */ u8 field_0x5ac; /* 0x5AD */ u8 field_0x5ad; /* 0x5AE */ u8 field_0x5ae; diff --git a/include/d/actor/d_a_e_hz.h b/include/d/actor/d_a_e_hz.h index 539d808cf5..e48a72ee69 100644 --- a/include/d/actor/d_a_e_hz.h +++ b/include/d/actor/d_a_e_hz.h @@ -64,7 +64,6 @@ public: void setInitPos(); int create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ request_of_phase_process_class mPhaseReq2; /* 0x5BC */ mDoExt_McaMorfSO* mpMorfSO; diff --git a/include/d/actor/d_a_e_kk.h b/include/d/actor/d_a_e_kk.h index 890da0eba2..a249cafc74 100644 --- a/include/d/actor/d_a_e_kk.h +++ b/include/d/actor/d_a_e_kk.h @@ -49,7 +49,6 @@ public: int CreateHeap(); int create(); -private: /* 0x05AC */ request_of_phase_process_class mPhaseReq; /* 0x05B4 */ mDoExt_McaMorfSO* mpMorfSO; /* 0x05B8 */ mDoExt_McaMorfSO* mpWeaponMorfSO; diff --git a/include/d/actor/d_a_e_mb.h b/include/d/actor/d_a_e_mb.h index 527cf30eac..f36c744879 100644 --- a/include/d/actor/d_a_e_mb.h +++ b/include/d/actor/d_a_e_mb.h @@ -44,12 +44,6 @@ public: /* 0x88C */ u8 field_0x88C[0x8C8 - 0x88C]; /* 0x8C8 */ s8 field_0x8c8; /* 0x8C9 */ u8 mInitHIO; -#if TARGET_PC - cXyz mRopeInterpPrev[16]; - cXyz mRopeInterpCurr[16]; - bool mRopeInterpPrevValid; - bool mRopeInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_mb_class) == 0x8cc); diff --git a/include/d/actor/d_a_e_oc.h b/include/d/actor/d_a_e_oc.h index 7f60afa878..2d40d9bcbc 100644 --- a/include/d/actor/d_a_e_oc.h +++ b/include/d/actor/d_a_e_oc.h @@ -87,7 +87,6 @@ public: daE_OC_c* getTalkOc() { return mpTalk; } J3DModel* getOcModel() { return mpMorf->getModel(); } -private: /* 0x5a0 */ request_of_phase_process_class mPhaseReqs[2]; /* 0x5bc */ mDoExt_McaMorfSO* mpMorf; /* 0x5c0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_e_oct_bg.h b/include/d/actor/d_a_e_oct_bg.h index cd5b6b27cd..9033e03736 100644 --- a/include/d/actor/d_a_e_oct_bg.h +++ b/include/d/actor/d_a_e_oct_bg.h @@ -54,7 +54,6 @@ public: u32 checkAction(actionFunc func) { return field_0xb58 == func; } bool checkNormalAttk() { return checkAction(&daE_OctBg_c::normal_attack); } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* field_0x5b4; /* 0x5B8 */ mDoExt_brkAnm* field_0x5b8; diff --git a/include/d/actor/d_a_e_ot.h b/include/d/actor/d_a_e_ot.h index 54e8399b7b..3505062e3c 100644 --- a/include/d/actor/d_a_e_ot.h +++ b/include/d/actor/d_a_e_ot.h @@ -54,7 +54,6 @@ public: /* 0x4 */ ACT_DAMAGE, }; -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ J3DModel* mpEggModel; diff --git a/include/d/actor/d_a_e_pm.h b/include/d/actor/d_a_e_pm.h index edec93c6a2..35368eff61 100644 --- a/include/d/actor/d_a_e_pm.h +++ b/include/d/actor/d_a_e_pm.h @@ -84,7 +84,6 @@ public: u8 SwitchChk() { return mStage; } u8 DoorChk() { return mDoorAction; } -private: /* 0x5AC */ fpc_ProcID mPuppetID[4]; /* 0x5BC */ u8 field_0x5bc[0x5DC - 0x5BC]; /* 0x5DC */ u8 mDoorAction; diff --git a/include/d/actor/d_a_e_s1.h b/include/d/actor/d_a_e_s1.h index 5cbae84696..a631ba47ac 100644 --- a/include/d/actor/d_a_e_s1.h +++ b/include/d/actor/d_a_e_s1.h @@ -81,15 +81,6 @@ public: /* 0x306D */ u8 field_0x306D[0x307C - 0x306D]; /* 0x307C */ u32 mBodyEffEmtrID; /* 0x3080 */ u8 mInitHIO; - -#if TARGET_PC - static const int HAIR_STRAND_COUNT = 22; - static const int HAIR_SEGMENT_COUNT = 16; - cXyz mHairInterpPrev[HAIR_STRAND_COUNT * HAIR_SEGMENT_COUNT]; - cXyz mHairInterpCurr[HAIR_STRAND_COUNT * HAIR_SEGMENT_COUNT]; - bool mHairInterpPrevValid; - bool mHairInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_s1_class) == 0x3084); diff --git a/include/d/actor/d_a_e_sb.h b/include/d/actor/d_a_e_sb.h index e015ecc5bc..bd7d8c9bdc 100644 --- a/include/d/actor/d_a_e_sb.h +++ b/include/d/actor/d_a_e_sb.h @@ -57,7 +57,6 @@ public: int Delete(); void setBaseMtx(); cPhs_Step Create(); -private: /* 0x5AC */ int field_0x5ac; /* 0x5B0 */ int field_0x5b0; /* 0x5B4 */ int field_0x5b4; @@ -78,7 +77,6 @@ private: public: /* 0x5EC */ cXyz* field_0x5ec; /* 0x5F0 */ f32 field_0x5f0; -private: /* 0x5F4 */ cXyz field_0x5f4; /* 0x600 */ s16 field_0x600; /* 0x602 */ u8 field_0x602; diff --git a/include/d/actor/d_a_e_sw.h b/include/d/actor/d_a_e_sw.h index b073dae952..6f6a71f16d 100644 --- a/include/d/actor/d_a_e_sw.h +++ b/include/d/actor/d_a_e_sw.h @@ -82,7 +82,6 @@ public: bool d_checkOldAction(void (daE_SW_c::*action)()) { return field_0xb0c == action; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x5B8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_e_tt.h b/include/d/actor/d_a_e_tt.h index f3b79a69b3..38dc53ac3f 100644 --- a/include/d/actor/d_a_e_tt.h +++ b/include/d/actor/d_a_e_tt.h @@ -47,7 +47,6 @@ public: int CreateHeap(); int create(); -private: /* 0x5AC */ request_of_phase_process_class mPhaseReq; /* 0x5B4 */ request_of_phase_process_class mPhaseReq2; /* 0x5BC */ mDoExt_McaMorfSO* mpMorfSO; diff --git a/include/d/actor/d_a_e_vt.h b/include/d/actor/d_a_e_vt.h index 4b6082adae..b55bb4891a 100644 --- a/include/d/actor/d_a_e_vt.h +++ b/include/d/actor/d_a_e_vt.h @@ -146,7 +146,6 @@ public: int create(); daE_VA_c(); -private: /* 0x005AC */ request_of_phase_process_class mPhase; /* 0x005B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x005B8 */ mDoExt_McaMorfSO* mpEndEfMorf; diff --git a/include/d/actor/d_a_e_wb.h b/include/d/actor/d_a_e_wb.h index aecbac96a1..770e537f2e 100644 --- a/include/d/actor/d_a_e_wb.h +++ b/include/d/actor/d_a_e_wb.h @@ -221,12 +221,6 @@ public: /* 0x17E4 */ u8 field_0x17e4[0x17e8 - 0x17e4]; /* 0x17E8 */ f32 ride_speed_max; ///< @brief Speed rate for riding calculations. #if TARGET_PC - cXyz himo_mat_interp_prev[2][16]; - cXyz himo_mat_interp_curr[2][16]; - cXyz himo_tex_interp_prev[2]; - cXyz himo_tex_interp_curr[2]; - bool himo_interp_prev_valid; - bool himo_interp_curr_valid; s8 demo_cam_sync_ticks; #endif }; diff --git a/include/d/actor/d_a_e_ww.h b/include/d/actor/d_a_e_ww.h index fc1083c34e..f1ebac248a 100644 --- a/include/d/actor/d_a_e_ww.h +++ b/include/d/actor/d_a_e_ww.h @@ -59,7 +59,6 @@ public: void setAttack() { mActionMode = 10; } f32 const getSpeedF() { return speedF; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpModelMorf; /* 0x5B8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_e_yd.h b/include/d/actor/d_a_e_yd.h index 44d6036600..188e435ba5 100644 --- a/include/d/actor/d_a_e_yd.h +++ b/include/d/actor/d_a_e_yd.h @@ -74,12 +74,6 @@ public: /* 0x1250 */ f32 field_0x1250; /* 0x1254 */ u8 field_0x1254[0x1268 - 0x1254]; /* 0x1268 */ u8 field_0x1268; -#if TARGET_PC - cXyz mLineMatInterpPrev[12]; - cXyz mLineMatInterpCurr[12]; - bool mLineMatInterpPrevValid; - bool mLineMatInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yd_class) == 0x126c); diff --git a/include/d/actor/d_a_e_yg.h b/include/d/actor/d_a_e_yg.h index 6be19933cb..69a85430a8 100644 --- a/include/d/actor/d_a_e_yg.h +++ b/include/d/actor/d_a_e_yg.h @@ -63,15 +63,6 @@ public: /* 0x0BB4 */ yg_ke_s mYgKes[13]; /* 0x1880 */ mDoExt_3DlineMat0_c mLineMat; /* 0x189C */ u8 mIsFirstSpawn; - -#if TARGET_PC - static const int TENTACLE_STRAND_COUNT = 13; - static const int TENTACLE_SEGMENT_COUNT = 10; - cXyz mTentacleInterpPrev[TENTACLE_STRAND_COUNT * TENTACLE_SEGMENT_COUNT]; - cXyz mTentacleInterpCurr[TENTACLE_STRAND_COUNT * TENTACLE_SEGMENT_COUNT]; - bool mTentacleInterpPrevValid; - bool mTentacleInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yg_class) == 0x18a0); diff --git a/include/d/actor/d_a_e_yh.h b/include/d/actor/d_a_e_yh.h index 63e8ac1882..519e5e2779 100644 --- a/include/d/actor/d_a_e_yh.h +++ b/include/d/actor/d_a_e_yh.h @@ -77,12 +77,6 @@ public: /* 0x1260 */ u32 field_0x1260; /* 0x1260 */ u8 field_0x1264[0x1270 - 0x1264]; /* 0x1270 */ bool mIsHIOOwner; -#if TARGET_PC - cXyz mLineInterpPrev[12]; - cXyz mLineInterpCurr[12]; - bool mLineInterpPrevValid; - bool mLineInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(e_yh_class) == 0x1274); diff --git a/include/d/actor/d_a_e_ym.h b/include/d/actor/d_a_e_ym.h index 9638736b46..699d14d98f 100644 --- a/include/d/actor/d_a_e_ym.h +++ b/include/d/actor/d_a_e_ym.h @@ -122,7 +122,6 @@ public: u8 getSwitchBit() { return mSwitchBit; } u8 isHide() { return mIsHide; } -private: /* 0x5AC */ request_of_phase_process_class mPhase; /* 0x5B4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5B8 */ mDoExt_brkAnm* mpBrk; diff --git a/include/d/actor/d_a_e_zs.h b/include/d/actor/d_a_e_zs.h index d15b384650..93dbd82d89 100644 --- a/include/d/actor/d_a_e_zs.h +++ b/include/d/actor/d_a_e_zs.h @@ -39,7 +39,6 @@ public: int CreateHeap(); int create(); -private: /* 0x5ac */ request_of_phase_process_class mPhase; /* 0x5b4 */ mDoExt_McaMorfSO* mpMorf; /* 0x5b8 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_horse.h b/include/d/actor/d_a_horse.h index bb7ce7ccb1..2074570517 100644 --- a/include/d/actor/d_a_horse.h +++ b/include/d/actor/d_a_horse.h @@ -196,9 +196,6 @@ public: void copyReinPos(); void setReinPosHandSubstance(int); void setReinPosNormalSubstance(); -#if TARGET_PC - void lerpControlPoints(f32 alpha); -#endif void bgCheck(); bool checkSpecialWallHitSubstance(cXyz const&) const; void setServiceWaitTimer(); diff --git a/include/d/actor/d_a_kago.h b/include/d/actor/d_a_kago.h index 33ec51672f..ba0e77a37c 100644 --- a/include/d/actor/d_a_kago.h +++ b/include/d/actor/d_a_kago.h @@ -140,7 +140,6 @@ public: void setEatYm() { field_0x6d8 |= (u8) 4; } MtxP getMouthMtx() { return mAnm_p->getModel()->getAnmMtx(7); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ mDoExt_McaMorfSO* mAnm_p; /* 0x574 */ Z2CreatureEnemy mSound; diff --git a/include/d/actor/d_a_mant.h b/include/d/actor/d_a_mant.h index 6d5b173d1a..e6f3d71a9c 100644 --- a/include/d/actor/d_a_mant.h +++ b/include/d/actor/d_a_mant.h @@ -92,10 +92,7 @@ public: /* 0x39A4 */ cM_rnd_c mMantRng; #endif }; -#if TARGET_PC -STATIC_ASSERT(sizeof(mant_class) == 0x39ac); -#else + STATIC_ASSERT(sizeof(mant_class) == 0x39a4); -#endif #endif /* D_A_MANT_H */ diff --git a/include/d/actor/d_a_mg_rod.h b/include/d/actor/d_a_mg_rod.h index 97a0bb1c72..76863f33d5 100644 --- a/include/d/actor/d_a_mg_rod.h +++ b/include/d/actor/d_a_mg_rod.h @@ -299,13 +299,6 @@ public: /* 0x168C */ u8 field_0x168c; /* 0x168D */ u8 field_0x168d; /* 0x168E */ u8 HIOInit; - -#if TARGET_PC - cXyz mLineInterpPrev[MG_ROD_LURE_LINE_LEN]; - cXyz mLineInterpCurr[MG_ROD_LURE_LINE_LEN]; - bool mLineInterpPrevValid; - bool mLineInterpCurrValid; -#endif }; #endif /* D_A_MG_ROD_H */ diff --git a/include/d/actor/d_a_midna.h b/include/d/actor/d_a_midna.h index 2b07386ca7..1371dce12c 100644 --- a/include/d/actor/d_a_midna.h +++ b/include/d/actor/d_a_midna.h @@ -423,7 +423,6 @@ public: static DUSK_GAME_DATA daMidna_texData_s const m_texDataTable[21]; static DUSK_GAME_DATA daMidna_anmData_s const m_anmDataTable[53]; -// private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModel* mpShadowModel; diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index fbd8784d40..785f9458ab 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -4,6 +4,7 @@ #if !TARGET_PC #include #else +#include #include #include #endif @@ -17,29 +18,6 @@ struct daMP_THPReadBuffer { }; #if TARGET_PC -// Copying here because thp.h is probably erroneous in the dolphin lib, -// and it's kind of a problem being there (Aurora owns the headers). -// TODO: Move this stuff in decomp? -typedef struct THPAudioRecordHeader { - BE(u32) offsetNextChannel; - BE(u32) sampleSize; - BE(s16) lCoef[8][2]; - BE(s16) rCoef[8][2]; - BE(s16) lYn1; - BE(s16) lYn2; - BE(s16) rYn1; - BE(s16) rYn2; -} THPAudioRecordHeader; - -typedef struct THPAudioDecodeInfo { - u8* encodeData; - u32 offsetNibbles; - u8 predictor; - u8 scale; - s16 yn1; - s16 yn2; -} THPAudioDecodeInfo; - typedef struct THPTextureSet { u8* ytexture; u8* utexture; @@ -86,10 +64,6 @@ typedef struct THPHeader { /* 0x2C */ BE(u32) finalFrameDataOffsets; } THPHeader; -static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); -static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); -static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); - #define THP_AUDIO_BUFFER_COUNT 3 #define THP_READ_BUFFER_COUNT 10 #define THP_TEXTURE_SET_COUNT 3 @@ -166,7 +140,6 @@ public: static DUSK_GAME_DATA daMP_c* m_myObj; -private: /* 0x568 */ u32 (*mpGetMovieRestFrame)(void); /* 0x56C */ void (*mpSetPercentMovieVol)(f32); /* 0x570 */ u32 (*mpTHPGetTotalFrame)(void); diff --git a/include/d/actor/d_a_npc.h b/include/d/actor/d_a_npc.h index 7b99f1e2fe..51425bb912 100644 --- a/include/d/actor/d_a_npc.h +++ b/include/d/actor/d_a_npc.h @@ -29,7 +29,7 @@ struct daNpc_GetParam3 { // name unknown }; class daNpcT_ActorMngr_c { -private: +public: /* 0x0 */ fpc_ProcID mActorID; public: @@ -44,7 +44,7 @@ public: }; class daNpcT_MatAnm_c : public J3DMaterialAnm { -private: +public: /* 0x0F4 */ mutable f32 field_0xF4; /* 0x0F8 */ mutable f32 field_0xF8; /* 0x0FC */ f32 mNowOffsetX; @@ -102,7 +102,6 @@ public: } void setOffset(int i_offset) { mOffset = i_offset; } -private: /* 0x00 */ sequenceStepData_c const* mpSeqData; /* 0x04 */ int mStepNum; /* 0x08 */ int mNo; @@ -217,7 +216,7 @@ public: }; class daNpcT_JntAnm_c { -private: +public: /* 0x000 */ daNpcT_ActorMngr_c mActrMngr; /* 0x008 */ cXyz mPos; /* 0x014 */ cXyz mAttnPos; diff --git a/include/d/actor/d_a_npc2.h b/include/d/actor/d_a_npc2.h index 0f8ab6ba20..2453ba1f30 100644 --- a/include/d/actor/d_a_npc2.h +++ b/include/d/actor/d_a_npc2.h @@ -15,7 +15,6 @@ public: fopAc_ac_c* getActor(); virtual ~daBaseNpc_acMngr_c() {} -private: /* 0x04 */ fpc_ProcID mActorId; }; diff --git a/include/d/actor/d_a_npc4.h b/include/d/actor/d_a_npc4.h index d195eb9669..1bf39f54ec 100644 --- a/include/d/actor/d_a_npc4.h +++ b/include/d/actor/d_a_npc4.h @@ -12,7 +12,7 @@ #include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" class daNpcF_ActorMngr_c { -private: +public: /* 0x0 */ fpc_ProcID mActorID; public: @@ -52,7 +52,7 @@ BOOL daNpcF_chkPassed(cXyz i_pos, dPnt* i_points, u16 i_idx, u16 i_num, BOOL i_i BOOL daNpcF_chkDoBtnEqSpeak(fopAc_ac_c* i_actor_p); class daNpcF_SPCurve_c { -private: +public: /* 0x00 */ u16 mNurbs; /* 0x02 */ u16 field_0x02; /* 0x04 */ u8 mIsReversed; @@ -119,7 +119,7 @@ public: }; // Size: 0x630 class daNpcF_MatAnm_c : public J3DMaterialAnm { -private: +public: /* 0x0F4 */ mutable f32 field_0xF4; /* 0x0F8 */ mutable f32 field_0xF8; /* 0x0FC */ f32 mNowOffsetX; @@ -138,7 +138,7 @@ public: }; class daNpcF_Lookat_c { -private: +public: /* 0x00 */ cXyz mJointPos[4]; /* 0x30 */ cXyz* mAttnPos_p; /* 0x34 */ csXyz mAngularMoveDis[4]; @@ -406,7 +406,6 @@ public: STATIC_ASSERT(sizeof(daNpcF_c) == 0xB48); class daNpcF_MoveBgActor_c : public daNpcF_c { -private: public: // these functions are inferred based on daBaseNpc_moveBgActor_c - // defining them in this order fixes weak function order for this class in d_a_npc diff --git a/include/d/actor/d_a_npc_aru.h b/include/d/actor/d_a_npc_aru.h index e822850a7e..a41e45acba 100644 --- a/include/d/actor/d_a_npc_aru.h +++ b/include/d/actor/d_a_npc_aru.h @@ -174,7 +174,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0xE40 */ NPC_ARU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_ash.h b/include/d/actor/d_a_npc_ash.h index 46c850a372..e9f6e3427a 100644 --- a/include/d/actor/d_a_npc_ash.h +++ b/include/d/actor/d_a_npc_ash.h @@ -145,7 +145,6 @@ public: static DUSK_GAME_DATA EventFn mEvtSeqList[6]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ J3DModel* mModelBow; /* 0xBDC */ J3DModel* mModelQuiver; diff --git a/include/d/actor/d_a_npc_ashB.h b/include/d/actor/d_a_npc_ashB.h index e257db2402..9b158acf2d 100644 --- a/include/d/actor/d_a_npc_ashB.h +++ b/include/d/actor/d_a_npc_ashB.h @@ -137,7 +137,6 @@ public: static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[2]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_npc_besu.h b/include/d/actor/d_a_npc_besu.h index 646c4860bd..04579f595b 100644 --- a/include/d/actor/d_a_npc_besu.h +++ b/include/d/actor/d_a_npc_besu.h @@ -143,7 +143,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[15]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[15]; -private: /* 0x0E40 */ mDoExt_McaMorfSO* mpCupModelMorf; /* 0x0E44 */ NPC_BESU_HIO_CLASS* mpHIO; /* 0x0E48 */ J3DModel* mpClothModel[1]; diff --git a/include/d/actor/d_a_npc_bou.h b/include/d/actor/d_a_npc_bou.h index d2c1c0ef2f..d0379b9a1b 100644 --- a/include/d/actor/d_a_npc_bou.h +++ b/include/d/actor/d_a_npc_bou.h @@ -168,7 +168,6 @@ public: return 0; } -private: /* 0xE40 */ NPC_BOU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl1; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_bouS.h b/include/d/actor/d_a_npc_bouS.h index a3431cfec7..7d6f48fb53 100644 --- a/include/d/actor/d_a_npc_bouS.h +++ b/include/d/actor/d_a_npc_bouS.h @@ -130,7 +130,6 @@ public: static DUSK_GAME_DATA eventFunc mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_chat.h b/include/d/actor/d_a_npc_chat.h index 5bdbee8869..88ddc9a8b3 100644 --- a/include/d/actor/d_a_npc_chat.h +++ b/include/d/actor/d_a_npc_chat.h @@ -104,7 +104,6 @@ public: static DUSK_GAME_DATA eventFunc DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0xBF0 */ J3DModel* mObjModel; diff --git a/include/d/actor/d_a_npc_clerka.h b/include/d/actor/d_a_npc_clerka.h index 12ef5a3b97..6479bae503 100644 --- a/include/d/actor/d_a_npc_clerka.h +++ b/include/d/actor/d_a_npc_clerka.h @@ -127,7 +127,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_CLERKA_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_clerkb.h b/include/d/actor/d_a_npc_clerkb.h index c6c2ef83fb..9bc2a39a3a 100644 --- a/include/d/actor/d_a_npc_clerkb.h +++ b/include/d/actor/d_a_npc_clerkb.h @@ -140,7 +140,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ mDoExt_bpkAnm mBpkAnm2; /* 0x0F7C */ NPC_CLERKB_HIO_CLASS* mpHIO; /* 0x0F98 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_clerkt.h b/include/d/actor/d_a_npc_clerkt.h index 6acfb8970f..a476f83449 100644 --- a/include/d/actor/d_a_npc_clerkt.h +++ b/include/d/actor/d_a_npc_clerkt.h @@ -128,7 +128,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_CLERKT_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_coach.h b/include/d/actor/d_a_npc_coach.h index f50cbd87a5..e0ecd63fc2 100644 --- a/include/d/actor/d_a_npc_coach.h +++ b/include/d/actor/d_a_npc_coach.h @@ -297,7 +297,6 @@ public: static DUSK_GAME_DATA daNpcCoach_Attr_c const M_attr; static u16 const ParticleName[10]; -private: /* 0x0568 */ daNpcChHorse_c mChHorse; /* 0x0E7C */ daNpcChHarness_c mChHarness; /* 0x15D0 */ daNpcChCoach_c mChCoach; diff --git a/include/d/actor/d_a_npc_doc.h b/include/d/actor/d_a_npc_doc.h index 417251e10b..191a2e5bf2 100644 --- a/include/d/actor/d_a_npc_doc.h +++ b/include/d/actor/d_a_npc_doc.h @@ -136,7 +136,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_DOC_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_doorboy.h b/include/d/actor/d_a_npc_doorboy.h index 31568dd2f6..3fd6ef1ce8 100644 --- a/include/d/actor/d_a_npc_doorboy.h +++ b/include/d/actor/d_a_npc_doorboy.h @@ -80,7 +80,6 @@ public: static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0xBF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_fairy.h b/include/d/actor/d_a_npc_fairy.h index efa9d760c1..ff2df4260b 100644 --- a/include/d/actor/d_a_npc_fairy.h +++ b/include/d/actor/d_a_npc_fairy.h @@ -296,7 +296,6 @@ public: 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; /* 0x0F80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_fairy_seirei.h b/include/d/actor/d_a_npc_fairy_seirei.h index a0ad9342ed..d47b2a17eb 100644 --- a/include/d/actor/d_a_npc_fairy_seirei.h +++ b/include/d/actor/d_a_npc_fairy_seirei.h @@ -93,7 +93,6 @@ public: static DUSK_GAME_DATA DUSK_CONST char* mCutNameList[1]; static DUSK_GAME_DATA DUSK_CONST cutFunc mCutList[1]; -private: /* 0xE40 */ NPC_FAIRY_SEIREI_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_gnd.h b/include/d/actor/d_a_npc_gnd.h index f61d7e0214..cb0289055e 100644 --- a/include/d/actor/d_a_npc_gnd.h +++ b/include/d/actor/d_a_npc_gnd.h @@ -99,7 +99,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_GND_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl1; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_gra.h b/include/d/actor/d_a_npc_gra.h index 333cf5d299..f16b445195 100644 --- a/include/d/actor/d_a_npc_gra.h +++ b/include/d/actor/d_a_npc_gra.h @@ -142,7 +142,6 @@ public: typedef BOOL (daNpc_grA_c::*cut_type)(int); static DUSK_GAME_DATA cut_type DUSK_CONST mEvtCutList[]; -private: typedef BOOL (daNpc_grA_c::*daNpc_grA_c_Action)(void*); /* 0x0B48 */ Z2Creature mCreature; diff --git a/include/d/actor/d_a_npc_grc.h b/include/d/actor/d_a_npc_grc.h index ac7dfa9869..53a483b51d 100644 --- a/include/d/actor/d_a_npc_grc.h +++ b/include/d/actor/d_a_npc_grc.h @@ -92,7 +92,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList; static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ int field_0xbd8; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grd.h b/include/d/actor/d_a_npc_grd.h index 24871ab24c..64afa3ef2c 100644 --- a/include/d/actor/d_a_npc_grd.h +++ b/include/d/actor/d_a_npc_grd.h @@ -84,7 +84,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grm.h b/include/d/actor/d_a_npc_grm.h index d7c30ba90f..c820eabbc3 100644 --- a/include/d/actor/d_a_npc_grm.h +++ b/include/d/actor/d_a_npc_grm.h @@ -134,7 +134,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0F7C */ NPC_GRM_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_grmc.h b/include/d/actor/d_a_npc_grmc.h index 1761c82869..1d87c39a4d 100644 --- a/include/d/actor/d_a_npc_grmc.h +++ b/include/d/actor/d_a_npc_grmc.h @@ -127,7 +127,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ NPC_GRMC_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl; /* 0x10BC */ u8 mType; diff --git a/include/d/actor/d_a_npc_gro.h b/include/d/actor/d_a_npc_gro.h index b2a5595bd9..8bc6c8c93e 100644 --- a/include/d/actor/d_a_npc_gro.h +++ b/include/d/actor/d_a_npc_gro.h @@ -88,7 +88,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[3]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpOtherModel[1]; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_grr.h b/include/d/actor/d_a_npc_grr.h index 6dfa8512bc..4caf927d75 100644 --- a/include/d/actor/d_a_npc_grr.h +++ b/include/d/actor/d_a_npc_grr.h @@ -86,7 +86,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_grs.h b/include/d/actor/d_a_npc_grs.h index 5ec4354dd1..9c1ac788dc 100644 --- a/include/d/actor/d_a_npc_grs.h +++ b/include/d/actor/d_a_npc_grs.h @@ -87,7 +87,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_npc_grz.h b/include/d/actor/d_a_npc_grz.h index f49c878ff7..249720276f 100644 --- a/include/d/actor/d_a_npc_grz.h +++ b/include/d/actor/d_a_npc_grz.h @@ -119,7 +119,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[7]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[7]; -private: /* 0x0B48 */ Z2Creature mSound; /* 0x0BD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0x0BDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_guard.h b/include/d/actor/d_a_npc_guard.h index bceab108e5..59a6719c9d 100644 --- a/include/d/actor/d_a_npc_guard.h +++ b/include/d/actor/d_a_npc_guard.h @@ -62,7 +62,6 @@ public: static DUSK_GAME_DATA actionFunc ActionTable[7][2]; -private: /* 0xAC8 */ J3DModel* mpModel; /* 0xACC */ J3DModel* mpModel2; /* 0xAD0 */ J3DAnmTransformKey* mpAnmKey; diff --git a/include/d/actor/d_a_npc_gwolf.h b/include/d/actor/d_a_npc_gwolf.h index bd577e18e7..f7f4bc5a8e 100644 --- a/include/d/actor/d_a_npc_gwolf.h +++ b/include/d/actor/d_a_npc_gwolf.h @@ -107,7 +107,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[5]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[5]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_hanjo.h b/include/d/actor/d_a_npc_hanjo.h index e9daf3bb0e..76d354b743 100644 --- a/include/d/actor/d_a_npc_hanjo.h +++ b/include/d/actor/d_a_npc_hanjo.h @@ -221,7 +221,6 @@ public: 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; /* 0x0E48 */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_npc_henna0.h b/include/d/actor/d_a_npc_henna0.h index 112904d144..63da974cde 100644 --- a/include/d/actor/d_a_npc_henna0.h +++ b/include/d/actor/d_a_npc_henna0.h @@ -12,7 +12,7 @@ * */ class d_a_npc_henna0 : public fopAc_ac_c { - private: + public: /* 0x568 */ u8 field_0x568[0x828 - 0x568]; }; diff --git a/include/d/actor/d_a_npc_hoz.h b/include/d/actor/d_a_npc_hoz.h index aec84cf761..57a2169c78 100644 --- a/include/d/actor/d_a_npc_hoz.h +++ b/include/d/actor/d_a_npc_hoz.h @@ -128,7 +128,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[8]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[]; -private: /* 0xE40 */ NPC_HOZ_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_impal.h b/include/d/actor/d_a_npc_impal.h index f0102ab698..f6753be0e2 100644 --- a/include/d/actor/d_a_npc_impal.h +++ b/include/d/actor/d_a_npc_impal.h @@ -123,7 +123,6 @@ public: static DUSK_GAME_DATA EventFn mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_ins.h b/include/d/actor/d_a_npc_ins.h index 620358a297..fd133a7a79 100644 --- a/include/d/actor/d_a_npc_ins.h +++ b/include/d/actor/d_a_npc_ins.h @@ -121,7 +121,6 @@ public: static DUSK_GAME_DATA eventFunc mEvtSeqList[1]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpUmbrellaModel; /* 0xBDC */ J3DModel* mpKagoModel; diff --git a/include/d/actor/d_a_npc_jagar.h b/include/d/actor/d_a_npc_jagar.h index 13147762dd..e933d28bf4 100644 --- a/include/d/actor/d_a_npc_jagar.h +++ b/include/d/actor/d_a_npc_jagar.h @@ -225,7 +225,6 @@ public: 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; /* 0x0F80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_kakashi.h b/include/d/actor/d_a_npc_kakashi.h index c3f57b383a..a21117376d 100644 --- a/include/d/actor/d_a_npc_kakashi.h +++ b/include/d/actor/d_a_npc_kakashi.h @@ -116,7 +116,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[4]; static DUSK_GAME_DATA int (daNpc_Kakashi_c::* DUSK_CONST mCutList[])(int); -private: /* 0x0E40 */ NPC_KAKASHI_HIO_CLASS* mpHIO; /* 0x0E44 */ Z2SoundObjSimple mSound; /* 0x0E64 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_npc_kasi_hana.h b/include/d/actor/d_a_npc_kasi_hana.h index 625cb31845..302c3d84ab 100644 --- a/include/d/actor/d_a_npc_kasi_hana.h +++ b/include/d/actor/d_a_npc_kasi_hana.h @@ -206,7 +206,6 @@ public: static DUSK_GAME_DATA f32 mTargetTagDist; static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kasi_kyu.h b/include/d/actor/d_a_npc_kasi_kyu.h index 962a2e04cc..8ba34391c7 100644 --- a/include/d/actor/d_a_npc_kasi_kyu.h +++ b/include/d/actor/d_a_npc_kasi_kyu.h @@ -125,7 +125,6 @@ public: static DUSK_GAME_DATA f32 mTargetTagDist; static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kasi_mich.h b/include/d/actor/d_a_npc_kasi_mich.h index efa1a221c6..08361fe134 100644 --- a/include/d/actor/d_a_npc_kasi_mich.h +++ b/include/d/actor/d_a_npc_kasi_mich.h @@ -126,7 +126,6 @@ public: static DUSK_GAME_DATA f32 mTargetTagDist; static DUSK_GAME_DATA s16 mWolfAngle; -private: /* 0x0B48 */ Z2CreatureCitizen mSound; /* 0x0BEC */ u8 field_0xbec[0xbf0 - 0xbec]; /* 0x0BF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_kdk.h b/include/d/actor/d_a_npc_kdk.h index 6f701e33af..a647cc706d 100644 --- a/include/d/actor/d_a_npc_kdk.h +++ b/include/d/actor/d_a_npc_kdk.h @@ -12,7 +12,7 @@ * */ class daNpcKdk_c : public fopAc_ac_c { -private: +public: /* 0x568 */ u8 field_0x568[0xFA0 - 0x568]; }; diff --git a/include/d/actor/d_a_npc_kkri.h b/include/d/actor/d_a_npc_kkri.h index c6e173480d..1265f6e27f 100644 --- a/include/d/actor/d_a_npc_kkri.h +++ b/include/d/actor/d_a_npc_kkri.h @@ -121,7 +121,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[3]; static DUSK_GAME_DATA int (daNpc_Kkri_c::* DUSK_CONST mCutList[])(int); -private: /* 0xE40 */ NPC_KKRI_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_kn.h b/include/d/actor/d_a_npc_kn.h index 9e1794db97..7df2cfa247 100644 --- a/include/d/actor/d_a_npc_kn.h +++ b/include/d/actor/d_a_npc_kn.h @@ -421,7 +421,6 @@ public: static DUSK_GAME_DATA fopAc_ac_c* mFindActorPtrs[50]; static DUSK_GAME_DATA int mFindCount; -private: /* 0x0E44 */ J3DModel* mpPodModel; /* 0x0E48 */ mDoExt_invisibleModel mInvisModel; /* 0x0E50 */ dKy_tevstr_c mTevStr; diff --git a/include/d/actor/d_a_npc_knj.h b/include/d/actor/d_a_npc_knj.h index f8db1cdedb..7738d231b2 100644 --- a/include/d/actor/d_a_npc_knj.h +++ b/include/d/actor/d_a_npc_knj.h @@ -83,7 +83,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_KNJ_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mNextAction; diff --git a/include/d/actor/d_a_npc_kolin.h b/include/d/actor/d_a_npc_kolin.h index 28f455be35..860ae1b942 100644 --- a/include/d/actor/d_a_npc_kolin.h +++ b/include/d/actor/d_a_npc_kolin.h @@ -161,7 +161,6 @@ public: return 0; } -private: /* 0x0E40 */ NPC_KOLIN_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpClothModel; /* 0x0E48 */ dCcD_Cyl field_0xe48; diff --git a/include/d/actor/d_a_npc_kolinb.h b/include/d/actor/d_a_npc_kolinb.h index bf4392a697..4655234347 100644 --- a/include/d/actor/d_a_npc_kolinb.h +++ b/include/d/actor/d_a_npc_kolinb.h @@ -166,7 +166,6 @@ public: u32 getModelType() { return fopAcM_GetParam(this) >> 28; } -private: /* 0xE40 */ NPC_KOLINB_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ Mtx mMtx; diff --git a/include/d/actor/d_a_npc_kyury.h b/include/d/actor/d_a_npc_kyury.h index 8469dd3528..7322dfd905 100644 --- a/include/d/actor/d_a_npc_kyury.h +++ b/include/d/actor/d_a_npc_kyury.h @@ -126,7 +126,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_KYURY_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpModel[2]; /* 0xE4C */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_len.h b/include/d/actor/d_a_npc_len.h index 13b959c3b7..b22a0059e0 100644 --- a/include/d/actor/d_a_npc_len.h +++ b/include/d/actor/d_a_npc_len.h @@ -113,7 +113,6 @@ public: u8 getPathID() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u8 getBitSW() { return (fopAcM_GetParam(this) & 0xff0000) >> 16; } -private: /* 0xE40 */ NPC_LEN_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_lud.h b/include/d/actor/d_a_npc_lud.h index afecfdc0c7..a2be5fa65d 100644 --- a/include/d/actor/d_a_npc_lud.h +++ b/include/d/actor/d_a_npc_lud.h @@ -114,7 +114,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[8]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[8]; -private: /* 0xE40 */ mDoExt_McaMorfSO* mpBowlMorf; /* 0xE44 */ NPC_LUD_HIO_CLASS* mpHIO; /* 0xE48 */ J3DModel* mpModel[2]; diff --git a/include/d/actor/d_a_npc_maro.h b/include/d/actor/d_a_npc_maro.h index 1c51a63b44..8acd11e43c 100644 --- a/include/d/actor/d_a_npc_maro.h +++ b/include/d/actor/d_a_npc_maro.h @@ -187,7 +187,6 @@ public: return (fopAcM_GetParam(this) & 0xF000000) >> 24; } -private: /* 0x0F7C */ NPC_MARO_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl1; /* 0x10BC */ int field_0x10bc; diff --git a/include/d/actor/d_a_npc_midp.h b/include/d/actor/d_a_npc_midp.h index 60efbbac80..3021051d77 100644 --- a/include/d/actor/d_a_npc_midp.h +++ b/include/d/actor/d_a_npc_midp.h @@ -151,7 +151,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_MIDP_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_moi.h b/include/d/actor/d_a_npc_moi.h index 547c3a1dcd..94e1ef8861 100644 --- a/include/d/actor/d_a_npc_moi.h +++ b/include/d/actor/d_a_npc_moi.h @@ -161,7 +161,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[5]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[5]; -private: /* 0x0E40 */ NPC_MOI_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModel[6]; /* 0x0E5C */ dCcD_Cyl mCyl[4]; diff --git a/include/d/actor/d_a_npc_moir.h b/include/d/actor/d_a_npc_moir.h index f9aa841a60..f217ab7698 100644 --- a/include/d/actor/d_a_npc_moir.h +++ b/include/d/actor/d_a_npc_moir.h @@ -214,7 +214,6 @@ public: static DUSK_GAME_DATA EventFn mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpHeadgearModel; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_pachi_besu.h b/include/d/actor/d_a_npc_pachi_besu.h index 7fa17d8b2d..2cc79d2364 100644 --- a/include/d/actor/d_a_npc_pachi_besu.h +++ b/include/d/actor/d_a_npc_pachi_besu.h @@ -147,7 +147,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0xE40 */ NPC_PACHI_BESU_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_pachi_maro.h b/include/d/actor/d_a_npc_pachi_maro.h index 379c2c204b..be398f85e0 100644 --- a/include/d/actor/d_a_npc_pachi_maro.h +++ b/include/d/actor/d_a_npc_pachi_maro.h @@ -187,7 +187,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0xE40 */ NPC_PACHI_MARO_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_pachi_taro.h b/include/d/actor/d_a_npc_pachi_taro.h index 12de6aedf4..e424292f6c 100644 --- a/include/d/actor/d_a_npc_pachi_taro.h +++ b/include/d/actor/d_a_npc_pachi_taro.h @@ -199,7 +199,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[11]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[11]; -private: /* 0x0E40 */ NPC_PACHI_TARO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModels[2]; /* 0x0E4C */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_passer.h b/include/d/actor/d_a_npc_passer.h index d2f6f0b764..e166e635b9 100644 --- a/include/d/actor/d_a_npc_passer.h +++ b/include/d/actor/d_a_npc_passer.h @@ -123,7 +123,6 @@ public: static DUSK_GAME_DATA seqFunc m_seq26_funcTbl[3]; static DUSK_GAME_DATA seqFunc m_seq27_funcTbl[1]; -private: /* 0xAC8 */ J3DModel* mpModel; /* 0xACC */ PathTrace_c m_path; /* 0xAF4 */ daNpcPasser_c::actionFunc* mAction; diff --git a/include/d/actor/d_a_npc_passer2.h b/include/d/actor/d_a_npc_passer2.h index 792bbfd329..148a3b2981 100644 --- a/include/d/actor/d_a_npc_passer2.h +++ b/include/d/actor/d_a_npc_passer2.h @@ -53,7 +53,6 @@ public: static DUSK_GAME_DATA actionFunc ActionTable[1][2]; -private: /* 0x9EC */ J3DModel* mpModel; /* 0x9F0 */ PathTrace_c m_path; /* 0xA18 */ actionFunc* mAction; diff --git a/include/d/actor/d_a_npc_post.h b/include/d/actor/d_a_npc_post.h index 7b31506513..ef44f7ee1e 100644 --- a/include/d/actor/d_a_npc_post.h +++ b/include/d/actor/d_a_npc_post.h @@ -156,7 +156,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0E40 */ mDoExt_McaMorfSO* mpFlagModelMorf; /* 0x0E44 */ NPC_POST_HIO_CLASS* mHIO; /* 0x0E48 */ J3DModel* mpLetterModels[2]; diff --git a/include/d/actor/d_a_npc_pouya.h b/include/d/actor/d_a_npc_pouya.h index c30b0e0199..4af1d1ce68 100644 --- a/include/d/actor/d_a_npc_pouya.h +++ b/include/d/actor/d_a_npc_pouya.h @@ -149,7 +149,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[3]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[3]; -private: /* 0xE40 */ NPC_POUYA_HIO_CLASS* mpHIO; /* 0xE44 */ J3DModel* mpModel[1]; /* 0xE48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_prayer.h b/include/d/actor/d_a_npc_prayer.h index bc2735a43f..438bc784f9 100644 --- a/include/d/actor/d_a_npc_prayer.h +++ b/include/d/actor/d_a_npc_prayer.h @@ -79,7 +79,6 @@ public: static DUSK_GAME_DATA EvtSeq DUSK_CONST mEvtSeqList[]; -private: /* 0xB48 */ Z2CreatureCitizen mSound; /* 0xBEC */ u8 field_0xBEC[0xBF0 - 0xBEC]; /* 0xBF0 */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_raca.h b/include/d/actor/d_a_npc_raca.h index 9cd1849880..187ca700c7 100644 --- a/include/d/actor/d_a_npc_raca.h +++ b/include/d/actor/d_a_npc_raca.h @@ -148,7 +148,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_RACA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_rafrel.h b/include/d/actor/d_a_npc_rafrel.h index 3b3ac191bd..0bb9e76194 100644 --- a/include/d/actor/d_a_npc_rafrel.h +++ b/include/d/actor/d_a_npc_rafrel.h @@ -107,7 +107,6 @@ public: static DUSK_GAME_DATA int (daNpcRafrel_c::*mEvtSeqList[])(int); -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mpItemModel; /* 0xBDC */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_saru.h b/include/d/actor/d_a_npc_saru.h index 7f04c509e2..dce1d7b4a3 100644 --- a/include/d/actor/d_a_npc_saru.h +++ b/include/d/actor/d_a_npc_saru.h @@ -135,7 +135,6 @@ public: 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]; /* 0xE4C */ dCcD_Cyl field_0xe4c; diff --git a/include/d/actor/d_a_npc_seib.h b/include/d/actor/d_a_npc_seib.h index f2d0e04820..855be4ac41 100644 --- a/include/d/actor/d_a_npc_seib.h +++ b/include/d/actor/d_a_npc_seib.h @@ -87,7 +87,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEIB_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mActionFunc1; diff --git a/include/d/actor/d_a_npc_seic.h b/include/d/actor/d_a_npc_seic.h index 526331f05e..609d38588b 100644 --- a/include/d/actor/d_a_npc_seic.h +++ b/include/d/actor/d_a_npc_seic.h @@ -90,7 +90,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEIC_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE45 */ u8 field_0xe45[0xe48 - 0xe45]; diff --git a/include/d/actor/d_a_npc_seid.h b/include/d/actor/d_a_npc_seid.h index 37cc6302d6..91a1920598 100644 --- a/include/d/actor/d_a_npc_seid.h +++ b/include/d/actor/d_a_npc_seid.h @@ -89,7 +89,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SEID_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE48 */ actionFunc mAction; diff --git a/include/d/actor/d_a_npc_seira.h b/include/d/actor/d_a_npc_seira.h index d750c70711..c4f2ef1a96 100644 --- a/include/d/actor/d_a_npc_seira.h +++ b/include/d/actor/d_a_npc_seira.h @@ -117,7 +117,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0x0F7C */ mDoExt_McaMorfSO* mpSeiraMorf; /* 0x0F80 */ NPC_SEIRA_HIO_CLASS* mpHIO; /* 0x0F80 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_seira2.h b/include/d/actor/d_a_npc_seira2.h index 496357af4e..13aeb71e65 100644 --- a/include/d/actor/d_a_npc_seira2.h +++ b/include/d/actor/d_a_npc_seira2.h @@ -109,7 +109,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0x0F7C */ mDoExt_McaMorfSO* mpSeiraMorf; /* 0x0F80 */ NPC_SEIRA2_HIO_CLASS* mpHIO; /* 0x0F84 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_seirei.h b/include/d/actor/d_a_npc_seirei.h index a25c9671ae..b27f6084fc 100644 --- a/include/d/actor/d_a_npc_seirei.h +++ b/include/d/actor/d_a_npc_seirei.h @@ -102,7 +102,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_SEIREI_HIO_CLASS* mpHIO; /* 0xE44 */ u8 mType; /* 0xE45 */ u8 arg0; diff --git a/include/d/actor/d_a_npc_shad.h b/include/d/actor/d_a_npc_shad.h index 7f4490c183..59f1901059 100644 --- a/include/d/actor/d_a_npc_shad.h +++ b/include/d/actor/d_a_npc_shad.h @@ -237,7 +237,6 @@ public: } } -private: /* 0xB48 */ J3DModel* mBookKnifeModel; /* 0xB4C */ J3DModel* mKomonshoModel; /* 0xB50 */ Z2Creature mSound; diff --git a/include/d/actor/d_a_npc_shaman.h b/include/d/actor/d_a_npc_shaman.h index cdb7f7d7e9..1a462a7d00 100644 --- a/include/d/actor/d_a_npc_shaman.h +++ b/include/d/actor/d_a_npc_shaman.h @@ -117,7 +117,6 @@ public: static DUSK_GAME_DATA const int mSceneChangeNoTable[48]; static DUSK_GAME_DATA queryFunc mQueries[48]; -private: /* 0xE40 */ NPC_SHA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_shoe.h b/include/d/actor/d_a_npc_shoe.h index f9bee53132..b93259b60f 100644 --- a/include/d/actor/d_a_npc_shoe.h +++ b/include/d/actor/d_a_npc_shoe.h @@ -112,7 +112,6 @@ public: static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[1]; -private: /* 0xB48 */ J3DModel* mpModel1; /* 0xB4C */ J3DModel* mpModel2; /* 0xB50 */ Z2CreatureCitizen mCreature; diff --git a/include/d/actor/d_a_npc_sola.h b/include/d/actor/d_a_npc_sola.h index bfeb993cc7..b7fff5b57b 100644 --- a/include/d/actor/d_a_npc_sola.h +++ b/include/d/actor/d_a_npc_sola.h @@ -114,7 +114,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_SOLA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 field_0xf80; diff --git a/include/d/actor/d_a_npc_soldierA.h b/include/d/actor/d_a_npc_soldierA.h index dfc114d97e..aaca72ec8b 100644 --- a/include/d/actor/d_a_npc_soldierA.h +++ b/include/d/actor/d_a_npc_soldierA.h @@ -82,7 +82,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[3]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[3]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mSpearModel; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_soldierB.h b/include/d/actor/d_a_npc_soldierB.h index 66813628f9..d39f54edc5 100644 --- a/include/d/actor/d_a_npc_soldierB.h +++ b/include/d/actor/d_a_npc_soldierB.h @@ -78,7 +78,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ J3DModel* mSpearModel; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_taro.h b/include/d/actor/d_a_npc_taro.h index 1d0fa6274b..83ff47fc07 100644 --- a/include/d/actor/d_a_npc_taro.h +++ b/include/d/actor/d_a_npc_taro.h @@ -159,7 +159,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[17]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[17]; -private: /* 0x0E40 */ NPC_TARO_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mModels[2]; /* 0x0E4C */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_the.h b/include/d/actor/d_a_npc_the.h index fba5678e01..2a230afb8e 100644 --- a/include/d/actor/d_a_npc_the.h +++ b/include/d/actor/d_a_npc_the.h @@ -208,7 +208,6 @@ public: } } -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_theB.h b/include/d/actor/d_a_npc_theB.h index 92e0b0b3f0..e2bc9d410d 100644 --- a/include/d/actor/d_a_npc_theB.h +++ b/include/d/actor/d_a_npc_theB.h @@ -151,7 +151,6 @@ public: static DUSK_GAME_DATA cutFunc mEvtSeqList[6]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_tkc.h b/include/d/actor/d_a_npc_tkc.h index 3148354b36..6ec0150e5c 100644 --- a/include/d/actor/d_a_npc_tkc.h +++ b/include/d/actor/d_a_npc_tkc.h @@ -108,7 +108,6 @@ public: static DUSK_GAME_DATA evtFunc mEvtSeqList[4]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_ActorMngr_c mActorMngr[1]; diff --git a/include/d/actor/d_a_npc_tkj.h b/include/d/actor/d_a_npc_tkj.h index 8e7e2567b1..3191f1ee3b 100644 --- a/include/d/actor/d_a_npc_tkj.h +++ b/include/d/actor/d_a_npc_tkj.h @@ -97,7 +97,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA int (daNpcTkj_c::* DUSK_CONST mCutList[])(int); -private: /* 0xE40 */ NPC_TKJ_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCcCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_tks.h b/include/d/actor/d_a_npc_tks.h index 0342a378fe..837a0c89ec 100644 --- a/include/d/actor/d_a_npc_tks.h +++ b/include/d/actor/d_a_npc_tks.h @@ -134,7 +134,6 @@ public: inline void playTsuboAnm(); inline int getPlayerArea(); -private: /* 0x0B48 */ Z2Creature mSound; /* 0x0BD8 */ daNpcTksTsubo_c mTksTsubo; /* 0x1160 */ daNpcF_MatAnm_c* mpMatAnm; diff --git a/include/d/actor/d_a_npc_toby.h b/include/d/actor/d_a_npc_toby.h index 4f53117112..9abb7c032f 100644 --- a/include/d/actor/d_a_npc_toby.h +++ b/include/d/actor/d_a_npc_toby.h @@ -132,7 +132,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[7]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0x0E40 */ NPC_TOBY_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpTobyModels[1]; /* 0x0E48 */ dCcD_Cyl mCyl1; diff --git a/include/d/actor/d_a_npc_uri.h b/include/d/actor/d_a_npc_uri.h index 78a327592a..2650de4d64 100644 --- a/include/d/actor/d_a_npc_uri.h +++ b/include/d/actor/d_a_npc_uri.h @@ -139,7 +139,6 @@ public: static DUSK_GAME_DATA const char* mCutNameList[7]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[7]; -private: /* 0x0E40 */ NPC_URI_HIO_CLASS* mpHIO; /* 0x0E44 */ J3DModel* mpModel[1]; /* 0x0E48 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_npc_wrestler.h b/include/d/actor/d_a_npc_wrestler.h index b910ed50f9..c840259074 100644 --- a/include/d/actor/d_a_npc_wrestler.h +++ b/include/d/actor/d_a_npc_wrestler.h @@ -232,7 +232,6 @@ public: static DUSK_GAME_DATA EventFn DUSK_CONST mEvtSeqList[7]; -private: /* 0xB48 */ Z2Creature mSound; /* 0xBD8 */ daNpcWrestler_HIOParam* field_0xbd8; /* 0xBDC */ daNpcWrestler_HIOParamSub* field_0xbdc; diff --git a/include/d/actor/d_a_npc_yamid.h b/include/d/actor/d_a_npc_yamid.h index b175aa7a53..b9bb6bb288 100644 --- a/include/d/actor/d_a_npc_yamid.h +++ b/include/d/actor/d_a_npc_yamid.h @@ -132,7 +132,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMID_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yamis.h b/include/d/actor/d_a_npc_yamis.h index 4c23311c5e..272b0d5b72 100644 --- a/include/d/actor/d_a_npc_yamis.h +++ b/include/d/actor/d_a_npc_yamis.h @@ -127,7 +127,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMIS_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yamit.h b/include/d/actor/d_a_npc_yamit.h index a59b6a841f..0a12c2875d 100644 --- a/include/d/actor/d_a_npc_yamit.h +++ b/include/d/actor/d_a_npc_yamit.h @@ -126,7 +126,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[2]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[2]; -private: /* 0xE40 */ NPC_YAMIT_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl field_0xe44; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_yelia.h b/include/d/actor/d_a_npc_yelia.h index 737a3b4e28..c86d8e6ac6 100644 --- a/include/d/actor/d_a_npc_yelia.h +++ b/include/d/actor/d_a_npc_yelia.h @@ -104,7 +104,6 @@ public: 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; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_ykm.h b/include/d/actor/d_a_npc_ykm.h index d486d6fe6a..5bbb5077f6 100644 --- a/include/d/actor/d_a_npc_ykm.h +++ b/include/d/actor/d_a_npc_ykm.h @@ -287,7 +287,6 @@ public: 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; /* 0x0E48 */ NPC_YKM_HIO_CLASS* mpHIO; diff --git a/include/d/actor/d_a_npc_zanb.h b/include/d/actor/d_a_npc_zanb.h index 51d99c8253..78c37f6c76 100644 --- a/include/d/actor/d_a_npc_zanb.h +++ b/include/d/actor/d_a_npc_zanb.h @@ -102,7 +102,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[1]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZANB_HIO_CLASS* mHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zant.h b/include/d/actor/d_a_npc_zant.h index cbd33863d2..f9cd1c5b9b 100644 --- a/include/d/actor/d_a_npc_zant.h +++ b/include/d/actor/d_a_npc_zant.h @@ -86,7 +86,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZANT_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelR.h b/include/d/actor/d_a_npc_zelR.h index e7810c850c..bfe7d963a0 100644 --- a/include/d/actor/d_a_npc_zelR.h +++ b/include/d/actor/d_a_npc_zelR.h @@ -96,7 +96,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA EventFn mCutList[1]; -private: /* 0xE40 */ NPC_ZELR_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelRo.h b/include/d/actor/d_a_npc_zelRo.h index b3e2533999..a57235bff9 100644 --- a/include/d/actor/d_a_npc_zelRo.h +++ b/include/d/actor/d_a_npc_zelRo.h @@ -150,7 +150,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZELRO_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_zelda.h b/include/d/actor/d_a_npc_zelda.h index 6c3da5a2b3..e4be31296e 100644 --- a/include/d/actor/d_a_npc_zelda.h +++ b/include/d/actor/d_a_npc_zelda.h @@ -103,7 +103,6 @@ public: static DUSK_GAME_DATA const char* mCutNameList; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[1]; -private: /* 0xE40 */ NPC_ZELDA_HIO_CLASS* mpHIO; /* 0xE44 */ dCcD_Cyl mCyl; /* 0xF80 */ u8 field_0xf80; diff --git a/include/d/actor/d_a_npc_zra.h b/include/d/actor/d_a_npc_zra.h index ee786522f9..825076e192 100644 --- a/include/d/actor/d_a_npc_zra.h +++ b/include/d/actor/d_a_npc_zra.h @@ -370,6 +370,9 @@ public: u32 getAngleNoFromParam() { return (u8)(fopAcM_GetParam(this) >> 8); } void setBlastFlag(u8 i_flag) { mBlastFlag = i_flag; } MtxP getHeadMtx() { return mAnm_p->getModel()->getAnmMtx(4); } +#if TARGET_PC + friend void daNpc_zrA_interp_callback(void* pUserWork); +#endif /* 0x0B48 */ Z2Creature mCreatureSound; /* 0x0BD8 */ J3DModel* mpObjectModel[3]; diff --git a/include/d/actor/d_a_npc_zrc.h b/include/d/actor/d_a_npc_zrc.h index f4aeee6ac9..e9992ae157 100644 --- a/include/d/actor/d_a_npc_zrc.h +++ b/include/d/actor/d_a_npc_zrc.h @@ -96,7 +96,6 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mEvtCutNameList[2]; static DUSK_GAME_DATA EventFn DUSK_CONST mEvtCutList[2]; -private: /* 0xB48 */ Z2Creature mCreatureSound; /* 0xBD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0xBDC */ daNpcF_Lookat_c mLookat; diff --git a/include/d/actor/d_a_npc_zrz.h b/include/d/actor/d_a_npc_zrz.h index 76c782b7d3..a02ebb8227 100644 --- a/include/d/actor/d_a_npc_zrz.h +++ b/include/d/actor/d_a_npc_zrz.h @@ -114,7 +114,6 @@ public: void himoCalc(); void adjustShapeAngle() {} -private: /* 0x0B48 */ Z2Creature mCreatureSound; /* 0x0BD8 */ daNpcF_MatAnm_c* mpMatAnm; /* 0x0BDC */ mDoExt_invisibleModel mInvisibleModel; diff --git a/include/d/actor/d_a_obj_Lv5Key.h b/include/d/actor/d_a_obj_Lv5Key.h index 6e0251b151..11e2bd3019 100644 --- a/include/d/actor/d_a_obj_Lv5Key.h +++ b/include/d/actor/d_a_obj_Lv5Key.h @@ -65,7 +65,6 @@ public: cXyz& getLocalOffset() { return mLocalOffset; } -private: /* 0x568 */ u8 field_0x568[0x56C - 0x568]; /* 0x56C */ Z2SoundObjSimple mSound; /* 0x58C */ u8 field_0x58C[0x590 - 0x58C]; diff --git a/include/d/actor/d_a_obj_Turara.h b/include/d/actor/d_a_obj_Turara.h index 99d5a3a245..16f27d8550 100644 --- a/include/d/actor/d_a_obj_Turara.h +++ b/include/d/actor/d_a_obj_Turara.h @@ -56,7 +56,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5b8 */ request_of_phase_process_class mPhaseReq; /* 0x5c0 */ J3DModel* mpModel[2]; /* 0x5c8 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_TvCdlst.h b/include/d/actor/d_a_obj_TvCdlst.h index afe204bc03..5329727f6a 100644 --- a/include/d/actor/d_a_obj_TvCdlst.h +++ b/include/d/actor/d_a_obj_TvCdlst.h @@ -33,7 +33,6 @@ public: u8 getOnSw() { return fopAcM_GetParamBit(this,0,8); } u8 getOffSw() { return fopAcM_GetParamBit(this,0x10,8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_Y_taihou.h b/include/d/actor/d_a_obj_Y_taihou.h index 0e96cf62ed..002b85d853 100644 --- a/include/d/actor/d_a_obj_Y_taihou.h +++ b/include/d/actor/d_a_obj_Y_taihou.h @@ -37,7 +37,6 @@ public: s32 getIronBallId() { return mIronBallId; } void startBomb() { mStartBomb = 0xffff; } -private: /* 0x5b8 */ Mtx mMtx; /* 0x5e8 */ J3DModel* mpModel; /* 0x5ec */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_amiShutter.h b/include/d/actor/d_a_obj_amiShutter.h index b0e881c4c0..9fabc75220 100644 --- a/include/d/actor/d_a_obj_amiShutter.h +++ b/include/d/actor/d_a_obj_amiShutter.h @@ -62,7 +62,6 @@ public: bool isShutterOpen() { return mOpen; } -private: /* 0x5b8 */ request_of_phase_process_class mPhaseReq; /* 0x5c0 */ J3DModel* mpModel; /* 0x5c4 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_ari.h b/include/d/actor/d_a_obj_ari.h index a771b054f1..03b80016bd 100644 --- a/include/d/actor/d_a_obj_ari.h +++ b/include/d/actor/d_a_obj_ari.h @@ -40,7 +40,6 @@ public: bool CreateChk(); cPhs_Step create(); -private: /* 0x590 */ dBgS_GndChk mGndChk; /* 0x5E4 */ u8 field_0x5e4[4]; /* 0x5E8 */ u8 mAction; diff --git a/include/d/actor/d_a_obj_automata.h b/include/d/actor/d_a_obj_automata.h index 95fec65cff..17e470af99 100644 --- a/include/d/actor/d_a_obj_automata.h +++ b/include/d/actor/d_a_obj_automata.h @@ -44,7 +44,7 @@ public: * */ class daObj_AutoMata_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_AUTOMATA_HIO_CLASS* mpHIO; /* 0x56C */ mDoExt_McaMorfSO* mpMorf; /* 0x570 */ Z2Creature mCreature; diff --git a/include/d/actor/d_a_obj_avalanche.h b/include/d/actor/d_a_obj_avalanche.h index 89de60d2e8..ef72babdef 100644 --- a/include/d/actor/d_a_obj_avalanche.h +++ b/include/d/actor/d_a_obj_avalanche.h @@ -46,7 +46,6 @@ public: u8 getEvId() { return fopAcM_GetParamBit(this, 8, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ mDoExt_bckAnm* mBckAnm; diff --git a/include/d/actor/d_a_obj_batta.h b/include/d/actor/d_a_obj_batta.h index fca663390b..a1eaefc45e 100644 --- a/include/d/actor/d_a_obj_batta.h +++ b/include/d/actor/d_a_obj_batta.h @@ -43,7 +43,6 @@ public: return mActionFunc == i_func; } -private: /* 0x590 */ Z2Creature mCreature; /* 0x620 */ mDoExt_McaMorfSO* mpMorf; /* 0x624 */ mDoExt_brkAnm* mBrk; diff --git a/include/d/actor/d_a_obj_bbox.h b/include/d/actor/d_a_obj_bbox.h index 7ee461b557..1f7c2eef60 100644 --- a/include/d/actor/d_a_obj_bbox.h +++ b/include/d/actor/d_a_obj_bbox.h @@ -26,7 +26,6 @@ public: u32 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_bemos.h b/include/d/actor/d_a_obj_bemos.h index 38501b708b..3d0c10790d 100644 --- a/include/d/actor/d_a_obj_bemos.h +++ b/include/d/actor/d_a_obj_bemos.h @@ -131,7 +131,6 @@ public: int Delete(); static DUSK_GAME_DATA s16 const M_dir_base[4]; - // private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ mDoExt_brkAnm* mSerchBrk; diff --git a/include/d/actor/d_a_obj_bhashi.h b/include/d/actor/d_a_obj_bhashi.h index 7600d73f67..7ce2cd1c23 100644 --- a/include/d/actor/d_a_obj_bhashi.h +++ b/include/d/actor/d_a_obj_bhashi.h @@ -50,7 +50,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x05A0 */ u8 field_0x5A0[0x05A4 - 0x05A0]; /* 0x05A4 */ int mMode; /* 0x05A8 */ s16 field_0x5a8; diff --git a/include/d/actor/d_a_obj_bkdoor.h b/include/d/actor/d_a_obj_bkdoor.h index 69d3191028..793d86f09c 100644 --- a/include/d/actor/d_a_obj_bkdoor.h +++ b/include/d/actor/d_a_obj_bkdoor.h @@ -26,7 +26,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ csXyz mRotation; diff --git a/include/d/actor/d_a_obj_bky_rock.h b/include/d/actor/d_a_obj_bky_rock.h index 1f5952c35e..1214a610c9 100644 --- a/include/d/actor/d_a_obj_bky_rock.h +++ b/include/d/actor/d_a_obj_bky_rock.h @@ -63,7 +63,6 @@ public: static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; static DUSK_GAME_DATA exeProc s_exeProc[3]; -private: /* 0x568 */ int mVibrationTimer; /* 0x578 */ u8 mMode; /* 0x579 */ bool field_0x579; diff --git a/include/d/actor/d_a_obj_bmWindow.h b/include/d/actor/d_a_obj_bmWindow.h index 161f4768a9..a3d71fa9c2 100644 --- a/include/d/actor/d_a_obj_bmWindow.h +++ b/include/d/actor/d_a_obj_bmWindow.h @@ -39,7 +39,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_bmshutter.h b/include/d/actor/d_a_obj_bmshutter.h index c114421fe8..6ca4c05fe9 100644 --- a/include/d/actor/d_a_obj_bmshutter.h +++ b/include/d/actor/d_a_obj_bmshutter.h @@ -46,7 +46,6 @@ public: void setAction(u8 action) { mAction = action; } void setMoveMode(u8 mode) { mMoveMode = mode; } -private: /* 0x5a0 */ request_of_phase_process_class mPhase; /* 0x5a8 */ J3DModel* mModel; /* 0x5ac */ s16 mEventIdx; diff --git a/include/d/actor/d_a_obj_bombf.h b/include/d/actor/d_a_obj_bombf.h index 1d175caa94..661450e397 100644 --- a/include/d/actor/d_a_obj_bombf.h +++ b/include/d/actor/d_a_obj_bombf.h @@ -21,7 +21,6 @@ public: int execute(); int draw(); -private: /* 0x568 */ request_of_phase_process_class field_0x568; /* 0x570 */ J3DModel* field_0x570; /* 0x574 */ u32 field_0x574; diff --git a/include/d/actor/d_a_obj_bosswarp.h b/include/d/actor/d_a_obj_bosswarp.h index 9b62f1a0f6..4f6c6e4282 100644 --- a/include/d/actor/d_a_obj_bosswarp.h +++ b/include/d/actor/d_a_obj_bosswarp.h @@ -60,7 +60,6 @@ public: bool isFirst() { return fopAcM_GetParamBit(this, 0x1b, 1); } void setAction(u8 action) { mAction = action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtkAnm[2]; diff --git a/include/d/actor/d_a_obj_boumato.h b/include/d/actor/d_a_obj_boumato.h index 4852aee6f9..6a0266e548 100644 --- a/include/d/actor/d_a_obj_boumato.h +++ b/include/d/actor/d_a_obj_boumato.h @@ -50,7 +50,7 @@ public: * */ class daObj_BouMato_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_BOUMATO_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_bsGate.h b/include/d/actor/d_a_obj_bsGate.h index b40c5dcf6d..0c9730d63d 100644 --- a/include/d/actor/d_a_obj_bsGate.h +++ b/include/d/actor/d_a_obj_bsGate.h @@ -35,7 +35,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_bubblePilar.h b/include/d/actor/d_a_obj_bubblePilar.h index 7fb8009564..e19cbbae2f 100644 --- a/include/d/actor/d_a_obj_bubblePilar.h +++ b/include/d/actor/d_a_obj_bubblePilar.h @@ -39,7 +39,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModels[2]; /* 0x5B0 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_burnbox.h b/include/d/actor/d_a_obj_burnbox.h index f87678dccc..dc4634ea85 100644 --- a/include/d/actor/d_a_obj_burnbox.h +++ b/include/d/actor/d_a_obj_burnbox.h @@ -28,7 +28,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpBoxModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_carry.h b/include/d/actor/d_a_obj_carry.h index 8147cbfb60..54c8c73043 100644 --- a/include/d/actor/d_a_obj_carry.h +++ b/include/d/actor/d_a_obj_carry.h @@ -407,7 +407,6 @@ public: /* 0xE26 */ u8 field_0xe26; /* 0xE27 */ u8 field_0xe27; -private: u16 getType_private() { return field_0xd18 >> 1 & 0x1f; } }; diff --git a/include/d/actor/d_a_obj_catdoor.h b/include/d/actor/d_a_obj_catdoor.h index b7ed95bd14..c352c25806 100644 --- a/include/d/actor/d_a_obj_catdoor.h +++ b/include/d/actor/d_a_obj_catdoor.h @@ -80,7 +80,6 @@ public: Z2GetAudioMgr()->seStart(Z2SE_OBJ_GZ_NE_DOOR_OP, ¤t.pos, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ daObjCatDoor_Door_c mDoor1; /* 0x660 */ daObjCatDoor_Door_c mDoor2; diff --git a/include/d/actor/d_a_obj_cblock.h b/include/d/actor/d_a_obj_cblock.h index 04881776ec..75454ebb5d 100644 --- a/include/d/actor/d_a_obj_cblock.h +++ b/include/d/actor/d_a_obj_cblock.h @@ -49,7 +49,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 16, 8); } u8 getPathID() { return fopAcM_GetParamBit(this, 24, 8); } -private: /* 0x5A0 */ request_of_phase_process_class phase; /* 0x5A8 */ J3DModel* model1; /* 0x5AC */ J3DModel* model2; diff --git a/include/d/actor/d_a_obj_cboard.h b/include/d/actor/d_a_obj_cboard.h index 52a5f753e4..9bcdb51ed5 100644 --- a/include/d/actor/d_a_obj_cboard.h +++ b/include/d/actor/d_a_obj_cboard.h @@ -28,7 +28,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this, 4, 4); } u8 getSwNo() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ Mtx field_0x5a8; }; diff --git a/include/d/actor/d_a_obj_cdoor.h b/include/d/actor/d_a_obj_cdoor.h index ee06fd790c..60d54539e9 100644 --- a/include/d/actor/d_a_obj_cdoor.h +++ b/include/d/actor/d_a_obj_cdoor.h @@ -51,7 +51,6 @@ public: int getSwitchNum() { return mSw; } void setChainID(u32 i_id) { mChainID = i_id; } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ bool mEnd; diff --git a/include/d/actor/d_a_obj_chandelier.h b/include/d/actor/d_a_obj_chandelier.h index 45158dea34..a0592f4374 100644 --- a/include/d/actor/d_a_obj_chandelier.h +++ b/include/d/actor/d_a_obj_chandelier.h @@ -49,7 +49,6 @@ public: void moveHookOn() { field_0x60a = 1; } -private: /* 0x5A8 */ cXyz field_0x5a8; /* 0x5B4 */ Mtx mMtx; /* 0x5E4 */ u8 field_0x5e4[4]; diff --git a/include/d/actor/d_a_obj_chest.h b/include/d/actor/d_a_obj_chest.h index a5caedae86..e225c4a254 100644 --- a/include/d/actor/d_a_obj_chest.h +++ b/include/d/actor/d_a_obj_chest.h @@ -39,7 +39,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } u32 getArg0() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_obj_cho.h b/include/d/actor/d_a_obj_cho.h index 49dd5332b1..adb3faef58 100644 --- a/include/d/actor/d_a_obj_cho.h +++ b/include/d/actor/d_a_obj_cho.h @@ -46,7 +46,6 @@ public: cPhs_Step create(); inline int Draw(); -private: /* 0x590 */ dBgS_AcchCir mAcchCir; /* 0x5D0 */ dBgS_ObjAcch mAcch; /* 0x7A8 */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_cowdoor.h b/include/d/actor/d_a_obj_cowdoor.h index 1ed34370d8..a084ca0188 100644 --- a/include/d/actor/d_a_obj_cowdoor.h +++ b/include/d/actor/d_a_obj_cowdoor.h @@ -22,7 +22,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class field_0x5a0; /* 0x5A8 */ J3DModel* field_0x5a8; }; diff --git a/include/d/actor/d_a_obj_crope.h b/include/d/actor/d_a_obj_crope.h index bde25e379c..e0f0220000 100644 --- a/include/d/actor/d_a_obj_crope.h +++ b/include/d/actor/d_a_obj_crope.h @@ -52,7 +52,6 @@ public: mCoCancelTimer = 30; } -private: /* 0x0568 */ request_of_phase_process_class mPhase; /* 0x0570 */ dCcD_Stts mCcStts; /* 0x05AC */ dCcD_Sph mCollider; diff --git a/include/d/actor/d_a_obj_crvfence.h b/include/d/actor/d_a_obj_crvfence.h index dd760bb43f..9b6298553f 100644 --- a/include/d/actor/d_a_obj_crvfence.h +++ b/include/d/actor/d_a_obj_crvfence.h @@ -34,7 +34,6 @@ public: int Draw(); int Delete(); -private: /* 0x05A0 */ int field_0x5a0; /* 0x05A4 */ int mAction; /* 0x05A8 */ u8 field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvgate.h b/include/d/actor/d_a_obj_crvgate.h index 1fb4d1a12b..fed7868085 100644 --- a/include/d/actor/d_a_obj_crvgate.h +++ b/include/d/actor/d_a_obj_crvgate.h @@ -50,7 +50,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ s32 mEventID; /* 0x5A4 */ bool mFlagGateClosed; /* 0x5A5 */ bool field_0x5a5; diff --git a/include/d/actor/d_a_obj_crvlh_down.h b/include/d/actor/d_a_obj_crvlh_down.h index ce1c31bfa8..06ad6c89f0 100644 --- a/include/d/actor/d_a_obj_crvlh_down.h +++ b/include/d/actor/d_a_obj_crvlh_down.h @@ -28,7 +28,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ fpc_ProcID field_0x5a0; /* 0x5A4 */ fpc_ProcID field_0x5a4; /* 0x5A8 */ cXyz field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvlh_up.h b/include/d/actor/d_a_obj_crvlh_up.h index 7f24ba03a6..950018311a 100644 --- a/include/d/actor/d_a_obj_crvlh_up.h +++ b/include/d/actor/d_a_obj_crvlh_up.h @@ -26,7 +26,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x568 */ u8 field_0x568[0x5a4 - 0x5a0]; /* 0x5A4 */ fpc_ProcID field_0x5a4; /* 0x5A8 */ fpc_ProcID field_0x5a8; diff --git a/include/d/actor/d_a_obj_crvsteel.h b/include/d/actor/d_a_obj_crvsteel.h index a8d6305495..09ddc5be2a 100644 --- a/include/d/actor/d_a_obj_crvsteel.h +++ b/include/d/actor/d_a_obj_crvsteel.h @@ -29,7 +29,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ u32 mSmokeParticle1; /* 0x5A4 */ u32 mSmokeParticle2; /* 0x5A8 */ s16 mAction; diff --git a/include/d/actor/d_a_obj_crystal.h b/include/d/actor/d_a_obj_crystal.h index 0d6fcc1fc6..3c2fbfb110 100644 --- a/include/d/actor/d_a_obj_crystal.h +++ b/include/d/actor/d_a_obj_crystal.h @@ -22,7 +22,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel[2]; /* 0x578 */ JPABaseEmitter* mpEmitter; diff --git a/include/d/actor/d_a_obj_cwall.h b/include/d/actor/d_a_obj_cwall.h index 396729be80..66d760a337 100644 --- a/include/d/actor/d_a_obj_cwall.h +++ b/include/d/actor/d_a_obj_cwall.h @@ -61,7 +61,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 4, 4); } u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mWallModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_damCps.h b/include/d/actor/d_a_obj_damCps.h index 1ce75cc663..d92a38184c 100644 --- a/include/d/actor/d_a_obj_damCps.h +++ b/include/d/actor/d_a_obj_damCps.h @@ -26,7 +26,6 @@ public: int _delete(); u8 getSwNo(); -private: /* 0x0570 */ dCcD_Stts mStts; /* 0x05AC */ dCcD_Cps mCps; /* 0x06F0 */ cM3dGCpsS mCapsule; diff --git a/include/d/actor/d_a_obj_dan.h b/include/d/actor/d_a_obj_dan.h index 15caef361a..3e3b62fc9b 100644 --- a/include/d/actor/d_a_obj_dan.h +++ b/include/d/actor/d_a_obj_dan.h @@ -39,7 +39,6 @@ public: bool CreateChk(); cPhs_Step create(); -private: /* 0x590 */ dCcD_Stts mCcStts; /* 0x5CC */ dCcD_Sph mCcSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_digholl.h b/include/d/actor/d_a_obj_digholl.h index 33f078a1ea..f985bbe165 100644 --- a/include/d/actor/d_a_obj_digholl.h +++ b/include/d/actor/d_a_obj_digholl.h @@ -21,7 +21,6 @@ public: void onDigStart() { field_0x568 = 1; } s16 getSceneNum() const { return field_0x56c; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_obj_digplace.h b/include/d/actor/d_a_obj_digplace.h index 404b35aff4..0b29ff11f6 100644 --- a/include/d/actor/d_a_obj_digplace.h +++ b/include/d/actor/d_a_obj_digplace.h @@ -17,7 +17,6 @@ public: int create(); int execute(); -private: /* 0x568 */ u8 mType; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 mDigFlg; diff --git a/include/d/actor/d_a_obj_digsnow.h b/include/d/actor/d_a_obj_digsnow.h index 09af66d091..4ef3de5958 100644 --- a/include/d/actor/d_a_obj_digsnow.h +++ b/include/d/actor/d_a_obj_digsnow.h @@ -50,7 +50,6 @@ public: void startDig() { mMode = ACTION_DIG_e; } void endDig() { mMode = ACTION_END_e; } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_enemy_create.h b/include/d/actor/d_a_obj_enemy_create.h index 3b29caddab..64da7b5203 100644 --- a/include/d/actor/d_a_obj_enemy_create.h +++ b/include/d/actor/d_a_obj_enemy_create.h @@ -22,7 +22,6 @@ public: void NameChk(); int create(); -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mEnemyNum; /* 0x56A */ u8 mActivateSw; diff --git a/include/d/actor/d_a_obj_fallobj.h b/include/d/actor/d_a_obj_fallobj.h index 0c4efed3f3..f59a58991a 100644 --- a/include/d/actor/d_a_obj_fallobj.h +++ b/include/d/actor/d_a_obj_fallobj.h @@ -50,7 +50,6 @@ public: return this->speed.y != 0.0f; }; -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ Mtx mMtx; /* 0x5D8 */ u8 field_0x5d8; diff --git a/include/d/actor/d_a_obj_fan.h b/include/d/actor/d_a_obj_fan.h index 1ababac7a6..a4907c01a1 100644 --- a/include/d/actor/d_a_obj_fan.h +++ b/include/d/actor/d_a_obj_fan.h @@ -29,7 +29,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this,0,4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ dBgW* field_0x5ac; diff --git a/include/d/actor/d_a_obj_fchain.h b/include/d/actor/d_a_obj_fchain.h index 7c4ae74faf..e9250fbe24 100644 --- a/include/d/actor/d_a_obj_fchain.h +++ b/include/d/actor/d_a_obj_fchain.h @@ -31,11 +31,6 @@ public: csXyz* getAngle() { return field_0x8a4; } J3DModelData* getModelData() { return mModelData; } -#if TARGET_PC - void onInterpCallback(); -#endif - -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModelData* mModelData; /* 0x574 */ daObjFchain_shape_c mShape; @@ -46,14 +41,6 @@ private: /* 0x694 */ cXyz field_0x694[22]; /* 0x79C */ cXyz field_0x79c[22]; /* 0x8A4 */ csXyz field_0x8a4[22]; - -#if TARGET_PC - static const int CHAIN_COUNT = 22; - cXyz mChainInterpPrev[CHAIN_COUNT]; - cXyz mChainInterpCurr[CHAIN_COUNT]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif }; STATIC_ASSERT(sizeof(daObjFchain_c) == 0x928); diff --git a/include/d/actor/d_a_obj_fireWood.h b/include/d/actor/d_a_obj_fireWood.h index 07a5d5334b..5ce85234de 100644 --- a/include/d/actor/d_a_obj_fireWood.h +++ b/include/d/actor/d_a_obj_fireWood.h @@ -27,7 +27,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ dCcD_Stts mCcStts; /* 0x5B0 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_obj_fireWood2.h b/include/d/actor/d_a_obj_fireWood2.h index bcb1bee95d..209ccf8ffd 100644 --- a/include/d/actor/d_a_obj_fireWood2.h +++ b/include/d/actor/d_a_obj_fireWood2.h @@ -28,7 +28,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ dCcD_Stts mCcStts; /* 0x5B0 */ dCcD_Cyl mCcCyl; diff --git a/include/d/actor/d_a_obj_firepillar.h b/include/d/actor/d_a_obj_firepillar.h index 620373422a..8490a1c488 100644 --- a/include/d/actor/d_a_obj_firepillar.h +++ b/include/d/actor/d_a_obj_firepillar.h @@ -47,7 +47,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ int field_0x570; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_firepillar2.h b/include/d/actor/d_a_obj_firepillar2.h index 359cbf6bb3..579342b8dc 100644 --- a/include/d/actor/d_a_obj_firepillar2.h +++ b/include/d/actor/d_a_obj_firepillar2.h @@ -51,7 +51,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this,8,8); } u8 getSwNo() { return fopAcM_GetParamBit(this,0,8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mModel; /* 0x574 */ mDoExt_bckAnm* mBck; diff --git a/include/d/actor/d_a_obj_flag.h b/include/d/actor/d_a_obj_flag.h index 8187fe33b2..8ac8662fb9 100644 --- a/include/d/actor/d_a_obj_flag.h +++ b/include/d/actor/d_a_obj_flag.h @@ -28,7 +28,7 @@ public: * */ class daObjFlag_c : public fopAc_ac_c { -private: +public: /* 0x568 */ J3DModel* mpModel1; /* 0x56c */ J3DModel* mpModel2; /* 0x570 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_flag2.h b/include/d/actor/d_a_obj_flag2.h index c9ef033190..676da2141d 100644 --- a/include/d/actor/d_a_obj_flag2.h +++ b/include/d/actor/d_a_obj_flag2.h @@ -83,7 +83,6 @@ public: static DUSK_GAME_DATA daObjFlag2_Attr_c const M_attr; -private: /* 0x0568 */ J3DModel* mModel; /* 0x056C */ request_of_phase_process_class mFlagPhase; /* 0x0574 */ request_of_phase_process_class mArcPhase; diff --git a/include/d/actor/d_a_obj_flag3.h b/include/d/actor/d_a_obj_flag3.h index b93394ce15..26bfd5b506 100644 --- a/include/d/actor/d_a_obj_flag3.h +++ b/include/d/actor/d_a_obj_flag3.h @@ -96,7 +96,6 @@ public: static DUSK_GAME_DATA daObjFlag3_Attr_c const M_attr; const daObjFlag3_Attr_c& attr() const { return M_attr; } -private: /* 0x0568 */ J3DModel* mModel; /* 0x056C */ request_of_phase_process_class mFlagPhase; /* 0x0574 */ request_of_phase_process_class mArcPhase; diff --git a/include/d/actor/d_a_obj_gadget.h b/include/d/actor/d_a_obj_gadget.h index cb2c99af97..a52f9ab27b 100644 --- a/include/d/actor/d_a_obj_gadget.h +++ b/include/d/actor/d_a_obj_gadget.h @@ -17,7 +17,7 @@ class daObj_Gadget_HIO_c; * */ class daObj_Gadget_c : public fopAc_ac_c { -private: +public: /* 0x568 */ daObj_Gadget_HIO_c* field_0x568; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_ganonwall.h b/include/d/actor/d_a_obj_ganonwall.h index 02d0cd1d99..c5e6f7d06a 100644 --- a/include/d/actor/d_a_obj_ganonwall.h +++ b/include/d/actor/d_a_obj_ganonwall.h @@ -26,7 +26,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } u32 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtkAnm; diff --git a/include/d/actor/d_a_obj_ganonwall2.h b/include/d/actor/d_a_obj_ganonwall2.h index a938a32141..0026094a8d 100644 --- a/include/d/actor/d_a_obj_ganonwall2.h +++ b/include/d/actor/d_a_obj_ganonwall2.h @@ -25,7 +25,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm* mpBtkAnm; diff --git a/include/d/actor/d_a_obj_gb.h b/include/d/actor/d_a_obj_gb.h index 3f5a354f5e..2bc435b2df 100644 --- a/include/d/actor/d_a_obj_gb.h +++ b/include/d/actor/d_a_obj_gb.h @@ -36,5 +36,4 @@ public: STATIC_ASSERT(sizeof(obj_gb_class) == 0x6bc); - #endif /* D_A_OBJ_GB_H */ diff --git a/include/d/actor/d_a_obj_geyser.h b/include/d/actor/d_a_obj_geyser.h index 54a7f3bcb8..244d3b1fcf 100644 --- a/include/d/actor/d_a_obj_geyser.h +++ b/include/d/actor/d_a_obj_geyser.h @@ -62,7 +62,6 @@ public: u8 getArg3() { return fopAcM_GetParamBit(this, 24, 8); } u8 getSwNo() { return 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_glowSphere.h b/include/d/actor/d_a_obj_glowSphere.h index c6c2ee220e..062a9ce7d5 100644 --- a/include/d/actor/d_a_obj_glowSphere.h +++ b/include/d/actor/d_a_obj_glowSphere.h @@ -30,7 +30,6 @@ public: bool isSet() { return mIsSet; } daGlwSph_c* getpSph() { return mpSph; } -private: /* 0x0 */ daGlwSph_c* mpSph; /* 0x4 */ s8 mIsSet; }; diff --git a/include/d/actor/d_a_obj_goGate.h b/include/d/actor/d_a_obj_goGate.h index a0a66c7f32..8ed98a43e6 100644 --- a/include/d/actor/d_a_obj_goGate.h +++ b/include/d/actor/d_a_obj_goGate.h @@ -40,7 +40,6 @@ public: u32 getLR() { return fopAcM_GetParamBit(this, 8, 8); } u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_gomikabe.h b/include/d/actor/d_a_obj_gomikabe.h index 441fff371f..a0a01c4e20 100644 --- a/include/d/actor/d_a_obj_gomikabe.h +++ b/include/d/actor/d_a_obj_gomikabe.h @@ -41,7 +41,6 @@ public: int Draw(); int Delete(); -private: /* 0x05A0 */ u8 mSwBit; /* 0x05A1 */ u8 mAction; /* 0x05A2 */ u8 field_0x5a2; diff --git a/include/d/actor/d_a_obj_gpTaru.h b/include/d/actor/d_a_obj_gpTaru.h index b3b31a5c9d..1ab93b2586 100644 --- a/include/d/actor/d_a_obj_gpTaru.h +++ b/include/d/actor/d_a_obj_gpTaru.h @@ -46,7 +46,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; /* 0x578 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_gra2.h b/include/d/actor/d_a_obj_gra2.h index 3cf17e090c..4add220bcd 100644 --- a/include/d/actor/d_a_obj_gra2.h +++ b/include/d/actor/d_a_obj_gra2.h @@ -243,7 +243,6 @@ public: void setDemoMode(s16 mDemoMode) { mDemoCamMode = mDemoMode; } s16 getDemoMode() { return mDemoCamMode; } -private: /* 0x0A48 */ u16 field_0xa48; /* 0x0A4C */ OBJ_GRA_HIO_CLASS* mpHIO; /* 0x0A50 */ Process field_0xa50; diff --git a/include/d/actor/d_a_obj_graWall.h b/include/d/actor/d_a_obj_graWall.h index ebcd1cdb58..037767547a 100644 --- a/include/d/actor/d_a_obj_graWall.h +++ b/include/d/actor/d_a_obj_graWall.h @@ -20,7 +20,6 @@ public: void col_init(); void col_set(); -private: /* 0x568 */ dCcD_Stts mStts; /* 0x5A4 */ dCcD_Cyl mCyl; /* 0x6E0 */ u8 field_0x6e0; diff --git a/include/d/actor/d_a_obj_gra_rock.h b/include/d/actor/d_a_obj_gra_rock.h index 24e816a829..21ec800563 100644 --- a/include/d/actor/d_a_obj_gra_rock.h +++ b/include/d/actor/d_a_obj_gra_rock.h @@ -33,7 +33,6 @@ public: static DUSK_GAME_DATA dCcD_SrcCyl const mCcDCyl; -private: /* 0x5A0 */ request_of_phase_process_class mPhases[5]; /* 0x5C8 */ J3DModel* mModel; /* 0x5CC */ mDoExt_btpAnm mBtp; diff --git a/include/d/actor/d_a_obj_grave_stone.h b/include/d/actor/d_a_obj_grave_stone.h index d41d58348a..9155a2f54c 100644 --- a/include/d/actor/d_a_obj_grave_stone.h +++ b/include/d/actor/d_a_obj_grave_stone.h @@ -36,7 +36,6 @@ public: int Draw(); int Delete(); -private: friend class daNpc_zrZ_c; /* 0x5A0 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_groundwater.h b/include/d/actor/d_a_obj_groundwater.h index 5e9061d89c..1fc0f0ef37 100644 --- a/include/d/actor/d_a_obj_groundwater.h +++ b/include/d/actor/d_a_obj_groundwater.h @@ -47,7 +47,6 @@ public: u8 getSw() { return fopAcM_GetParamBit(this, 8, 8); } u8 getSw2() { return fopAcM_GetParamBit(this, 16, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_obj_grz_rock.h b/include/d/actor/d_a_obj_grz_rock.h index cd65d2e906..4c8f382071 100644 --- a/include/d/actor/d_a_obj_grz_rock.h +++ b/include/d/actor/d_a_obj_grz_rock.h @@ -28,7 +28,6 @@ public: void setSmashFlag(u8 i_smashFlag) { mSmashFlag = i_smashFlag; } -private: /* 0x568 */ request_of_phase_process_class mPhase[1]; /* 0x5A0 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mBgc; diff --git a/include/d/actor/d_a_obj_hakai_brl.h b/include/d/actor/d_a_obj_hakai_brl.h index dba4b3cd3f..9bd109da7c 100644 --- a/include/d/actor/d_a_obj_hakai_brl.h +++ b/include/d/actor/d_a_obj_hakai_brl.h @@ -34,7 +34,6 @@ public: static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ dCcD_Stts mStts; /* 0x5B4 */ dCcD_Cyl mCyl; diff --git a/include/d/actor/d_a_obj_hakai_ftr.h b/include/d/actor/d_a_obj_hakai_ftr.h index 45c815c5f9..ac7f749860 100644 --- a/include/d/actor/d_a_obj_hakai_ftr.h +++ b/include/d/actor/d_a_obj_hakai_ftr.h @@ -31,7 +31,6 @@ public: static DUSK_GAME_DATA dCcD_SrcCyl const s_CcDCyl; -private: /* 0x574 */ Mtx mMtx; /* 0x5A4 */ dBgW* field_0x5a4; /* 0x5A8 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_hasu2.h b/include/d/actor/d_a_obj_hasu2.h index 9c36c0d180..203b4ff159 100644 --- a/include/d/actor/d_a_obj_hasu2.h +++ b/include/d/actor/d_a_obj_hasu2.h @@ -29,7 +29,6 @@ public: virtual ~daObjMHasu_c() {}; void setRideFlag(bool i_ride) { mRideFlag = i_ride; } -private: /* 0x5A8 */ Mtx mMtx; /* 0x5D8 */ Mtx mMtx2; /* 0x608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_hbombkoya.h b/include/d/actor/d_a_obj_hbombkoya.h index 9f9c0a5149..b1d76f819b 100644 --- a/include/d/actor/d_a_obj_hbombkoya.h +++ b/include/d/actor/d_a_obj_hbombkoya.h @@ -39,7 +39,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } int getSw2No() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A8 */ // dEvLib_callback_c /* 0x5B8 */ Mtx mBgMtx; /* 0x5E8 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_hfuta.h b/include/d/actor/d_a_obj_hfuta.h index 77015715d0..4f4ee44eeb 100644 --- a/include/d/actor/d_a_obj_hfuta.h +++ b/include/d/actor/d_a_obj_hfuta.h @@ -37,7 +37,6 @@ public: void setMode(u8 mode) { mMode = mode; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ cXyz mTransM; diff --git a/include/d/actor/d_a_obj_hsTarget.h b/include/d/actor/d_a_obj_hsTarget.h index 1e0e775e12..50a497eb8e 100644 --- a/include/d/actor/d_a_obj_hsTarget.h +++ b/include/d/actor/d_a_obj_hsTarget.h @@ -23,7 +23,6 @@ public: u8 getModelType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mIndex; diff --git a/include/d/actor/d_a_obj_iceleaf.h b/include/d/actor/d_a_obj_iceleaf.h index da79be5bc5..42ad6237e7 100644 --- a/include/d/actor/d_a_obj_iceleaf.h +++ b/include/d/actor/d_a_obj_iceleaf.h @@ -61,7 +61,6 @@ public: u8 checkRideStatus() { return fopAcM_GetParamBit(this, 0x10, 8); } u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_itamato.h b/include/d/actor/d_a_obj_itamato.h index 10c6459887..b9080f7db7 100644 --- a/include/d/actor/d_a_obj_itamato.h +++ b/include/d/actor/d_a_obj_itamato.h @@ -46,7 +46,7 @@ public: #endif class daObj_ItaMato_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_ITAMATO_HIO_CLASS* mHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModels[2]; diff --git a/include/d/actor/d_a_obj_kabuto.h b/include/d/actor/d_a_obj_kabuto.h index 9738147885..2b9d6255ee 100644 --- a/include/d/actor/d_a_obj_kabuto.h +++ b/include/d/actor/d_a_obj_kabuto.h @@ -47,7 +47,6 @@ public: cPhs_Step create(); inline int Draw(); -private: /* 0x590 */ dCcD_Stts mCcStts; /* 0x5CC */ dCcD_Sph mCcSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kag.h b/include/d/actor/d_a_obj_kag.h index 58692d7a8c..09c9a088a0 100644 --- a/include/d/actor/d_a_obj_kag.h +++ b/include/d/actor/d_a_obj_kag.h @@ -39,7 +39,6 @@ public: void kag_setParticle(); inline int CreateHeap(); inline int draw(); -private: /* 0x590 */ request_of_phase_process_class mPhase; /* 0x598 */ Z2Creature mSound; /* 0x628 */ mDoExt_McaMorfSO* mpModelMorf; diff --git a/include/d/actor/d_a_obj_kago.h b/include/d/actor/d_a_obj_kago.h index 265db41c57..4a6ed74730 100644 --- a/include/d/actor/d_a_obj_kago.h +++ b/include/d/actor/d_a_obj_kago.h @@ -125,7 +125,6 @@ public: field_0xb68 = 0.0f; } -private: /* 0x568 */ OBJ_KAGO_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* field_0x574; diff --git a/include/d/actor/d_a_obj_kaisou.h b/include/d/actor/d_a_obj_kaisou.h index 3398c24884..36d6f568df 100644 --- a/include/d/actor/d_a_obj_kaisou.h +++ b/include/d/actor/d_a_obj_kaisou.h @@ -28,7 +28,6 @@ public: inline int CreateHeap(); inline int Draw(); -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 field_0x56a[0x56e - 0x56a]; diff --git a/include/d/actor/d_a_obj_kamakiri.h b/include/d/actor/d_a_obj_kamakiri.h index 3b2d56e533..52b648ea48 100644 --- a/include/d/actor/d_a_obj_kamakiri.h +++ b/include/d/actor/d_a_obj_kamakiri.h @@ -56,7 +56,6 @@ public: u8 CreateChk(); int create(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSphere; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kantera.h b/include/d/actor/d_a_obj_kantera.h index 0228b51fd5..fbe230ed16 100644 --- a/include/d/actor/d_a_obj_kantera.h +++ b/include/d/actor/d_a_obj_kantera.h @@ -33,7 +33,6 @@ public: void setStatus(u8 i_status) { mStatus = i_status; } -private: /* 0x92C */ u32 field_0x92c; /* 0x930 */ s32 field_0x930; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_katatsumuri.h b/include/d/actor/d_a_obj_katatsumuri.h index e481d3eb3a..93b9368fb5 100644 --- a/include/d/actor/d_a_obj_katatsumuri.h +++ b/include/d/actor/d_a_obj_katatsumuri.h @@ -55,7 +55,6 @@ public: bool CreateChk(); int create(); -private: /* 0x590 */ dBgS_ObjAcch mAcch; /* 0x768 */ dBgS_GndChk mGndChk; /* 0x7BC */ u8 field_0x7bc[0x7c0 - 0x7bc]; diff --git a/include/d/actor/d_a_obj_kazeneko.h b/include/d/actor/d_a_obj_kazeneko.h index 73147b6fbe..164612ecfc 100644 --- a/include/d/actor/d_a_obj_kazeneko.h +++ b/include/d/actor/d_a_obj_kazeneko.h @@ -46,7 +46,6 @@ public: const KazoNekoAttr& attr() { return M_attr; } static DUSK_GAME_DATA KazoNekoAttr const M_attr; -private: /* 0x568 */ J3DModel* mModel; /* 0x56C */ J3DModel* mArmModels[4]; /* 0x57C */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_keyhole.h b/include/d/actor/d_a_obj_keyhole.h index b8a813776d..fd39641ad8 100644 --- a/include/d/actor/d_a_obj_keyhole.h +++ b/include/d/actor/d_a_obj_keyhole.h @@ -66,18 +66,9 @@ public: /* 0x2CA7 */ s8 hide_lock; /* 0x2CA8 */ cXyz field_0x2ca8; /* 0x2CB4 */ u8 field_0x2cb4; - -#if TARGET_PC - Mtx mChainInterpPrev[6][16]; - Mtx mChainInterpCurr[6][16]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif }; -#if !TARGET_PC STATIC_ASSERT(sizeof(obj_keyhole_class) == 0x2CB8); -#endif class daObj_Keyhole_HIO_c : public JORReflexible { public: diff --git a/include/d/actor/d_a_obj_kgate.h b/include/d/actor/d_a_obj_kgate.h index 96798028b2..f7fe72767c 100644 --- a/include/d/actor/d_a_obj_kgate.h +++ b/include/d/actor/d_a_obj_kgate.h @@ -46,7 +46,6 @@ public: u8 getEventID() { return fopAcM_GetParamBit(this, 0x14, 8); } u8 getNameArg() { return fopAcM_GetParamBit(this, 0x10, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpGateModel; /* 0x5AC */ J3DModel* mpGateModel2; diff --git a/include/d/actor/d_a_obj_kiPot.h b/include/d/actor/d_a_obj_kiPot.h index 01d7cf76c0..248daa2d46 100644 --- a/include/d/actor/d_a_obj_kiPot.h +++ b/include/d/actor/d_a_obj_kiPot.h @@ -23,7 +23,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ u8 field_0x568[0x574 - 0x568]; /* 0x574 */ u8 mMode; /* 0x575 */ u8 field_0x575; diff --git a/include/d/actor/d_a_obj_kita.h b/include/d/actor/d_a_obj_kita.h index 1e343c78ce..09eff51298 100644 --- a/include/d/actor/d_a_obj_kita.h +++ b/include/d/actor/d_a_obj_kita.h @@ -17,7 +17,6 @@ public: STATIC_ASSERT(sizeof(kita_s) == 0x60); - /** * @ingroup actors-objects * @class obj_kita_class diff --git a/include/d/actor/d_a_obj_kjgjs.h b/include/d/actor/d_a_obj_kjgjs.h index 495750bd89..189c672c7d 100644 --- a/include/d/actor/d_a_obj_kjgjs.h +++ b/include/d/actor/d_a_obj_kjgjs.h @@ -25,7 +25,6 @@ public: u32 getType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A8 */ Mtx mMtx[2]; /* 0x608 */ J3DModel* mpModel; /* 0x60C */ s32 field_0x60c; diff --git a/include/d/actor/d_a_obj_klift00.h b/include/d/actor/d_a_obj_klift00.h index ab5403d51b..a41c5c7b5c 100644 --- a/include/d/actor/d_a_obj_klift00.h +++ b/include/d/actor/d_a_obj_klift00.h @@ -26,14 +26,13 @@ public: int Delete(); #if TARGET_PC - void onInterpCallback(); + void onInterpPresentation(); #endif enum Param_e { LOCK_e = (1 << 6), NO_BASE_DISP = (1 << 7) }; -private: struct ChainPos { cXyz mDeltaPosVector; cXyz mCurrentPos; @@ -54,13 +53,6 @@ private: /* 0x1020 */ dCcD_Cyl mCylinderCollider; /* 0x115C */ s32 mStopSwingingFrames; -#if TARGET_PC - cXyz mChainInterpPrev[64]; - cXyz mChainInterpCurr[64]; - bool mChainInterpPrevValid; - bool mChainInterpCurrValid; -#endif - // Number of chain models u32 getArg0() { return fopAcM_GetParamBit(this, 0, 6); diff --git a/include/d/actor/d_a_obj_knBullet.h b/include/d/actor/d_a_obj_knBullet.h index e8056fbb25..fa2d5397a2 100644 --- a/include/d/actor/d_a_obj_knBullet.h +++ b/include/d/actor/d_a_obj_knBullet.h @@ -26,7 +26,6 @@ public: u8 getActionMode() { return mActionMode; } void setActionMode(u8 i_action) { mActionMode = i_action; } -private: /* 0x568 */ Mtx mMtx; /* 0x598 */ dCcD_Stts mCcStts; /* 0x5D4 */ dCcD_Sph mCcSph; diff --git a/include/d/actor/d_a_obj_kshutter.h b/include/d/actor/d_a_obj_kshutter.h index b217adef2d..a0a2204c0d 100644 --- a/include/d/actor/d_a_obj_kshutter.h +++ b/include/d/actor/d_a_obj_kshutter.h @@ -64,7 +64,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 8, 8); } u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase1; /* 0x5A8 */ request_of_phase_process_class mPhase2; /* 0x5B0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_ktOnFire.h b/include/d/actor/d_a_obj_ktOnFire.h index 39875e122e..7d292bf286 100644 --- a/include/d/actor/d_a_obj_ktOnFire.h +++ b/include/d/actor/d_a_obj_ktOnFire.h @@ -26,7 +26,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x568 */ dCcD_Stts mCcStts; /* 0x5A4 */ dCcD_Cyl mCcCyl; /* 0x6E0 */ u8 mWaitTime; diff --git a/include/d/actor/d_a_obj_kuwagata.h b/include/d/actor/d_a_obj_kuwagata.h index 9df3f0bc35..a14b0544bc 100644 --- a/include/d/actor/d_a_obj_kuwagata.h +++ b/include/d/actor/d_a_obj_kuwagata.h @@ -47,7 +47,6 @@ public: int create(); inline int Draw(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_kwheel00.h b/include/d/actor/d_a_obj_kwheel00.h index ceaf132fd6..2d58cb32f1 100644 --- a/include/d/actor/d_a_obj_kwheel00.h +++ b/include/d/actor/d_a_obj_kwheel00.h @@ -41,7 +41,6 @@ public: enum Type_e { TYPE_LARGE_GOLD, TYPE_SMALL_PLATINUM }; -private: enum QuadrantalAngle_e { DEG_INVALID = -1, DEG_0, DEG_90, DEG_180, DEG_270, DEG_MAX}; /* 0x5B8 */ Mtx mNewBgMtx; diff --git a/include/d/actor/d_a_obj_kwheel01.h b/include/d/actor/d_a_obj_kwheel01.h index 40bc025db4..9c6fa31075 100644 --- a/include/d/actor/d_a_obj_kwheel01.h +++ b/include/d/actor/d_a_obj_kwheel01.h @@ -27,7 +27,6 @@ public: int Delete(); bool eventStart(); -private: /* 0x5B8 */ Mtx mNewBgMtx; /* 0x5E8 */ Mtx mTransformMtx; /* 0x618 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_kznkarm.h b/include/d/actor/d_a_obj_kznkarm.h index c70908fcb8..3838d1f9ff 100644 --- a/include/d/actor/d_a_obj_kznkarm.h +++ b/include/d/actor/d_a_obj_kznkarm.h @@ -63,7 +63,6 @@ public: static DUSK_GAME_DATA daObjKznkarm_Attr_c const M_attr; static DUSK_GAME_DATA actionFunc ActionTable[4][2]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ dBgS_AcchCir mAcchCir; diff --git a/include/d/actor/d_a_obj_ladder.h b/include/d/actor/d_a_obj_ladder.h index 72f6fce4d2..b46bf99603 100644 --- a/include/d/actor/d_a_obj_ladder.h +++ b/include/d/actor/d_a_obj_ladder.h @@ -76,7 +76,6 @@ namespace daObjLadder { 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; /* 0x5AC */ Type_e mType; diff --git a/include/d/actor/d_a_obj_laundry.h b/include/d/actor/d_a_obj_laundry.h index cc79bc4e05..3dd76c6a39 100644 --- a/include/d/actor/d_a_obj_laundry.h +++ b/include/d/actor/d_a_obj_laundry.h @@ -56,7 +56,6 @@ public: inline int daObjLdy_Draw(); inline int daObjLdy_Execute(); -private: static DUSK_GAME_DATA const daObjLdy_Attr_c mAttr; /* 0x568 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_laundry_rope.h b/include/d/actor/d_a_obj_laundry_rope.h index 3ecab164b2..85d76cbe8d 100644 --- a/include/d/actor/d_a_obj_laundry_rope.h +++ b/include/d/actor/d_a_obj_laundry_rope.h @@ -58,7 +58,6 @@ public: static DUSK_GAME_DATA const daObjLndRope_Attr_c mAttr; static const daObjLndRope_Hio_c M_Hio; -private: /* 0x0568 */ mDoExt_3DlineMat1_c mRopeMat; /* 0x05a4 */ request_of_phase_process_class mPhase; /* 0x05ac */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_life_container.h b/include/d/actor/d_a_obj_life_container.h index d832c63843..a7b209cb94 100644 --- a/include/d/actor/d_a_obj_life_container.h +++ b/include/d/actor/d_a_obj_life_container.h @@ -64,7 +64,6 @@ public: current.pos = new_pos; } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int mCounter; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_lv1Candle00.h b/include/d/actor/d_a_obj_lv1Candle00.h index e9e62da388..c70d484930 100644 --- a/include/d/actor/d_a_obj_lv1Candle00.h +++ b/include/d/actor/d_a_obj_lv1Candle00.h @@ -30,7 +30,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_lv1Candle01.h b/include/d/actor/d_a_obj_lv1Candle01.h index 632c117f10..1f1dbe4ee4 100644 --- a/include/d/actor/d_a_obj_lv1Candle01.h +++ b/include/d/actor/d_a_obj_lv1Candle01.h @@ -27,7 +27,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_lv2Candle.h b/include/d/actor/d_a_obj_lv2Candle.h index 19be29a16e..424dd844fd 100644 --- a/include/d/actor/d_a_obj_lv2Candle.h +++ b/include/d/actor/d_a_obj_lv2Candle.h @@ -37,7 +37,6 @@ public: u8 getSwType() { return fopAcM_GetParamBit(this, 8, 4); } u8 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_lv3Candle.h b/include/d/actor/d_a_obj_lv3Candle.h index 7b9765136d..76edaaac77 100644 --- a/include/d/actor/d_a_obj_lv3Candle.h +++ b/include/d/actor/d_a_obj_lv3Candle.h @@ -29,7 +29,6 @@ public: int getSwBit() { return fopAcM_GetParamBit(this, 0, 8); } int getType() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u8 mType; diff --git a/include/d/actor/d_a_obj_lv3Water.h b/include/d/actor/d_a_obj_lv3Water.h index de4ff03356..82f5be1661 100644 --- a/include/d/actor/d_a_obj_lv3Water.h +++ b/include/d/actor/d_a_obj_lv3Water.h @@ -45,7 +45,6 @@ public: int getParamType() { return (shape_angle.x & 0xFF00) >> 8; } u8 getType() { return mType; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel1; /* 0x5C4 */ J3DModel* mpModel2; diff --git a/include/d/actor/d_a_obj_lv3Water2.h b/include/d/actor/d_a_obj_lv3Water2.h index be13ef4819..4227e8bcb0 100644 --- a/include/d/actor/d_a_obj_lv3Water2.h +++ b/include/d/actor/d_a_obj_lv3Water2.h @@ -29,7 +29,6 @@ public: int Delete(); bool eventStart(); -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ mDoExt_btkAnm mRefractionAnm; // Applied to water surface diff --git a/include/d/actor/d_a_obj_lv3saka00.h b/include/d/actor/d_a_obj_lv3saka00.h index f08f4a5d19..5207e74de8 100644 --- a/include/d/actor/d_a_obj_lv3saka00.h +++ b/include/d/actor/d_a_obj_lv3saka00.h @@ -28,7 +28,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } u8 getType() { return fopAcM_GetParamBit(this, 28, 4) & 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ dBgW* mpBgW2; }; diff --git a/include/d/actor/d_a_obj_lv3waterEff.h b/include/d/actor/d_a_obj_lv3waterEff.h index fdf7b204dc..a612168fac 100644 --- a/include/d/actor/d_a_obj_lv3waterEff.h +++ b/include/d/actor/d_a_obj_lv3waterEff.h @@ -18,7 +18,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ cXyz mSePositions[2]; /* 0x580 */ JPABaseEmitter* mParticles[4]; /* 0x590 */ u8 unused_0x590[0x594 - 0x590]; diff --git a/include/d/actor/d_a_obj_lv4CandleDemoTag.h b/include/d/actor/d_a_obj_lv4CandleDemoTag.h index 58378ecd4e..4ac8618776 100644 --- a/include/d/actor/d_a_obj_lv4CandleDemoTag.h +++ b/include/d/actor/d_a_obj_lv4CandleDemoTag.h @@ -43,7 +43,6 @@ public: virtual ~dalv4CandleDemoTag_c() {} virtual bool eventStart(); -private: /* 0x584 */ u8 mMode; /* 0x585 */ u8 mPathID; /* 0x586 */ u8 mSwNG; diff --git a/include/d/actor/d_a_obj_lv4EdShutter.h b/include/d/actor/d_a_obj_lv4EdShutter.h index a19de47873..992431c64d 100644 --- a/include/d/actor/d_a_obj_lv4EdShutter.h +++ b/include/d/actor/d_a_obj_lv4EdShutter.h @@ -45,7 +45,6 @@ public: u8 getZenmetuSw() { return shape_angle.z & 0xFF; } u8 getStatus() { return mStatus; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4HsTarget.h b/include/d/actor/d_a_obj_lv4HsTarget.h index fbb1c8862a..c618aec40e 100644 --- a/include/d/actor/d_a_obj_lv4HsTarget.h +++ b/include/d/actor/d_a_obj_lv4HsTarget.h @@ -23,7 +23,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; }; diff --git a/include/d/actor/d_a_obj_lv4PoGate.h b/include/d/actor/d_a_obj_lv4PoGate.h index 480885fa0a..bd46dd30c4 100644 --- a/include/d/actor/d_a_obj_lv4PoGate.h +++ b/include/d/actor/d_a_obj_lv4PoGate.h @@ -52,7 +52,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4RailWall.h b/include/d/actor/d_a_obj_lv4RailWall.h index 7cffceedc0..39858be708 100644 --- a/include/d/actor/d_a_obj_lv4RailWall.h +++ b/include/d/actor/d_a_obj_lv4RailWall.h @@ -50,7 +50,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ dBgS_ObjAcch field_0x5bc; diff --git a/include/d/actor/d_a_obj_lv4SlideWall.h b/include/d/actor/d_a_obj_lv4SlideWall.h index fcafa19dfc..1e08e68206 100644 --- a/include/d/actor/d_a_obj_lv4SlideWall.h +++ b/include/d/actor/d_a_obj_lv4SlideWall.h @@ -32,7 +32,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv4chandelier.h b/include/d/actor/d_a_obj_lv4chandelier.h index d0e7c53515..2b965d5831 100644 --- a/include/d/actor/d_a_obj_lv4chandelier.h +++ b/include/d/actor/d_a_obj_lv4chandelier.h @@ -43,7 +43,6 @@ public: int getAddChain2() { return fopAcM_GetParamBit(this, 12, 4); } int getSw() { return fopAcM_GetParamBit(this, 16, 8); } -private: /* 0x05A8 */ Mtx field_0x5a8; /* 0x05D8 */ Mtx field_0x5d8; /* 0x0608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_lv4floor.h b/include/d/actor/d_a_obj_lv4floor.h index 7b6681419d..704ccece93 100644 --- a/include/d/actor/d_a_obj_lv4floor.h +++ b/include/d/actor/d_a_obj_lv4floor.h @@ -38,7 +38,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ f32 mMoveYPos; diff --git a/include/d/actor/d_a_obj_lv4gear.h b/include/d/actor/d_a_obj_lv4gear.h index 5e649c0722..9c3d4920c1 100644 --- a/include/d/actor/d_a_obj_lv4gear.h +++ b/include/d/actor/d_a_obj_lv4gear.h @@ -31,7 +31,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 8, 4); } u8 checkSE() { return fopAcM_GetParamBit(this, 12, 4); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ s16 mTarget; diff --git a/include/d/actor/d_a_obj_lv4prelvtr.h b/include/d/actor/d_a_obj_lv4prelvtr.h index 2fd50068ac..9e4846671c 100644 --- a/include/d/actor/d_a_obj_lv4prelvtr.h +++ b/include/d/actor/d_a_obj_lv4prelvtr.h @@ -26,7 +26,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A8 */ Mtx mMtx1; /* 0x5D8 */ Mtx mMtx2; /* 0x608 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_lv4sand.h b/include/d/actor/d_a_obj_lv4sand.h index 0ff6420e27..1b6272440b 100644 --- a/include/d/actor/d_a_obj_lv4sand.h +++ b/include/d/actor/d_a_obj_lv4sand.h @@ -46,7 +46,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_lv5FloorBoard.h b/include/d/actor/d_a_obj_lv5FloorBoard.h index 1dcba0ade2..e8ae0d18b2 100644 --- a/include/d/actor/d_a_obj_lv5FloorBoard.h +++ b/include/d/actor/d_a_obj_lv5FloorBoard.h @@ -38,7 +38,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5IceWall.h b/include/d/actor/d_a_obj_lv5IceWall.h index c9f459e75d..e04d413249 100644 --- a/include/d/actor/d_a_obj_lv5IceWall.h +++ b/include/d/actor/d_a_obj_lv5IceWall.h @@ -42,7 +42,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl[2]; /* 0x854 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5SwIce.h b/include/d/actor/d_a_obj_lv5SwIce.h index 8adc14f2af..9e990e3da7 100644 --- a/include/d/actor/d_a_obj_lv5SwIce.h +++ b/include/d/actor/d_a_obj_lv5SwIce.h @@ -38,7 +38,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mCcStts; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv5ychndlr.h b/include/d/actor/d_a_obj_lv5ychndlr.h index 8db78c0afa..dc3a8f1ce2 100644 --- a/include/d/actor/d_a_obj_lv5ychndlr.h +++ b/include/d/actor/d_a_obj_lv5ychndlr.h @@ -26,7 +26,6 @@ public: virtual int Delete(); virtual ~daObjYchndlr_c() {} -private: /* 0x5A8 */ Mtx field_0x5a8; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mpChandlierModel; diff --git a/include/d/actor/d_a_obj_lv6FurikoTrap.h b/include/d/actor/d_a_obj_lv6FurikoTrap.h index 8a5f17336d..5257bc540a 100644 --- a/include/d/actor/d_a_obj_lv6FurikoTrap.h +++ b/include/d/actor/d_a_obj_lv6FurikoTrap.h @@ -28,7 +28,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv6Lblock.h b/include/d/actor/d_a_obj_lv6Lblock.h index 0dbe6a330a..80080c702b 100644 --- a/include/d/actor/d_a_obj_lv6Lblock.h +++ b/include/d/actor/d_a_obj_lv6Lblock.h @@ -34,7 +34,6 @@ public: int getUpMax() { return fopAcM_GetParamBit(this, 8, 4); } int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_lv6SwGate.h b/include/d/actor/d_a_obj_lv6SwGate.h index 331e7ae07d..e2844e06ee 100644 --- a/include/d/actor/d_a_obj_lv6SwGate.h +++ b/include/d/actor/d_a_obj_lv6SwGate.h @@ -38,7 +38,6 @@ public: 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]; /* 0x14AC */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_lv6SzGate.h b/include/d/actor/d_a_obj_lv6SzGate.h index 80601341ec..db3ec0ccce 100644 --- a/include/d/actor/d_a_obj_lv6SzGate.h +++ b/include/d/actor/d_a_obj_lv6SzGate.h @@ -45,7 +45,6 @@ public: u32 getWaitTime() { return fopAcM_GetParamBit(this, 8, 8); } u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* field_0x5a8; /* 0x5AC */ J3DModel* field_0x5ac; diff --git a/include/d/actor/d_a_obj_lv6Tenbin.h b/include/d/actor/d_a_obj_lv6Tenbin.h index 6cdd8e3538..429ecb58be 100644 --- a/include/d/actor/d_a_obj_lv6Tenbin.h +++ b/include/d/actor/d_a_obj_lv6Tenbin.h @@ -27,7 +27,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ J3DModel* mModel2; diff --git a/include/d/actor/d_a_obj_lv6TogeRoll.h b/include/d/actor/d_a_obj_lv6TogeRoll.h index 9fedcd5932..4fc557b8b4 100644 --- a/include/d/actor/d_a_obj_lv6TogeRoll.h +++ b/include/d/actor/d_a_obj_lv6TogeRoll.h @@ -66,7 +66,6 @@ public: static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; static DUSK_GAME_DATA dCcD_SrcCps mCcDCps; -private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ u8 mPathID; diff --git a/include/d/actor/d_a_obj_lv6elevta.h b/include/d/actor/d_a_obj_lv6elevta.h index b98ff06f58..192c568552 100644 --- a/include/d/actor/d_a_obj_lv6elevta.h +++ b/include/d/actor/d_a_obj_lv6elevta.h @@ -33,7 +33,6 @@ public: int getSw2No() { return fopAcM_GetParamBit(this, 8, 8); }; int getEvent() { return fopAcM_GetParamBit(this, 0x10, 8); }; -private: /* 0x5B8 */ Mtx mMtx1; /* 0x5E8 */ Mtx mMtx2; /* 0x618 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_lv7bridge.h b/include/d/actor/d_a_obj_lv7bridge.h index 938b87e08f..f53b24e708 100644 --- a/include/d/actor/d_a_obj_lv7bridge.h +++ b/include/d/actor/d_a_obj_lv7bridge.h @@ -45,7 +45,6 @@ public: void setDestroyAnmA() { field_0xa94 = 0; } void setDestroyAnmB() { field_0xa94 = 1; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_lv8KekkaiTrap.h b/include/d/actor/d_a_obj_lv8KekkaiTrap.h index aa68df0114..423e59a500 100644 --- a/include/d/actor/d_a_obj_lv8KekkaiTrap.h +++ b/include/d/actor/d_a_obj_lv8KekkaiTrap.h @@ -32,7 +32,6 @@ public: int getType() { return fopAcM_GetParamBit(this, 0, 4); } int getSwBit() { return fopAcM_GetParamBit(this, 4, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mIsSwitch; diff --git a/include/d/actor/d_a_obj_lv8Lift.h b/include/d/actor/d_a_obj_lv8Lift.h index 0b39e25e89..4f243d0906 100644 --- a/include/d/actor/d_a_obj_lv8Lift.h +++ b/include/d/actor/d_a_obj_lv8Lift.h @@ -59,7 +59,7 @@ public: int Draw(); int Delete(); #if TARGET_PC - friend void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork); + friend void daL8Lift_interp_callback(void* pUserWork); #endif u8 getPthID() { return fopAcM_GetParamBit(this, 0, 8); } @@ -68,7 +68,6 @@ public: static DUSK_GAME_DATA f32 const mSpeed[16]; -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_lv9SwShutter.h b/include/d/actor/d_a_obj_lv9SwShutter.h index 06607f5c1c..44e0eef556 100644 --- a/include/d/actor/d_a_obj_lv9SwShutter.h +++ b/include/d/actor/d_a_obj_lv9SwShutter.h @@ -31,7 +31,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_magLift.h b/include/d/actor/d_a_obj_magLift.h index a8f597bfef..7c15edb05e 100644 --- a/include/d/actor/d_a_obj_magLift.h +++ b/include/d/actor/d_a_obj_magLift.h @@ -49,7 +49,6 @@ public: static DUSK_GAME_DATA f32 const mSpeed[16]; -private: /* 0x5a0 */ request_of_phase_process_class mPhaseReq; /* 0x5a8 */ J3DModel* mpModel; /* 0x5ac */ u8 field_0x5ac [0x5ae - 0x5ac]; diff --git a/include/d/actor/d_a_obj_magLiftRot.h b/include/d/actor/d_a_obj_magLiftRot.h index 647fcee80a..04621f7ddc 100644 --- a/include/d/actor/d_a_obj_magLiftRot.h +++ b/include/d/actor/d_a_obj_magLiftRot.h @@ -29,7 +29,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_master_sword.h b/include/d/actor/d_a_obj_master_sword.h index a971aa335c..e462e61481 100644 --- a/include/d/actor/d_a_obj_master_sword.h +++ b/include/d/actor/d_a_obj_master_sword.h @@ -51,7 +51,6 @@ public: static DUSK_GAME_DATA daObjMasterSword_Attr_c const mAttr; static DUSK_GAME_DATA actionFunc ActionTable[]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_metalbox.h b/include/d/actor/d_a_obj_metalbox.h index b7f2fb10cd..10c6462547 100644 --- a/include/d/actor/d_a_obj_metalbox.h +++ b/include/d/actor/d_a_obj_metalbox.h @@ -15,7 +15,7 @@ * */ class daObjMBox_c : public dBgS_MoveBgActor { -private: +public: /* 0x5a0 */ request_of_phase_process_class mPhase; /* 0x5a8 */ J3DModel* mpModel; /* 0x5ac */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_mgate.h b/include/d/actor/d_a_obj_mgate.h index 5b86c8aa17..9dc0d63114 100644 --- a/include/d/actor/d_a_obj_mgate.h +++ b/include/d/actor/d_a_obj_mgate.h @@ -39,7 +39,6 @@ public: bool checkLock() { return fopAcM_GetParamBit(this, 5, 1); } u8 checkOpen() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ request_of_phase_process_class mKeyPhase; /* 0x5B0 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_mhole.h b/include/d/actor/d_a_obj_mhole.h index aa692338d2..c9818708fd 100644 --- a/include/d/actor/d_a_obj_mhole.h +++ b/include/d/actor/d_a_obj_mhole.h @@ -36,7 +36,6 @@ public: u8 getKind() { return fopAcM_GetParamBit(this, 12, 4); } u8 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_brkAnm* mpBrkAnm; diff --git a/include/d/actor/d_a_obj_mie.h b/include/d/actor/d_a_obj_mie.h index 6c95ed7f84..faa413e204 100644 --- a/include/d/actor/d_a_obj_mie.h +++ b/include/d/actor/d_a_obj_mie.h @@ -54,7 +54,7 @@ public: * */ class daObj_Mie_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_MIE_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_mirror_6pole.h b/include/d/actor/d_a_obj_mirror_6pole.h index 17cf211be3..1a53d23399 100644 --- a/include/d/actor/d_a_obj_mirror_6pole.h +++ b/include/d/actor/d_a_obj_mirror_6pole.h @@ -56,7 +56,6 @@ public: static DUSK_GAME_DATA const actionFunc ActionTable[][2]; -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm* mpBck; /* 0x570 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_mirror_chain.h b/include/d/actor/d_a_obj_mirror_chain.h index 106272f116..e04ab228d5 100644 --- a/include/d/actor/d_a_obj_mirror_chain.h +++ b/include/d/actor/d_a_obj_mirror_chain.h @@ -47,7 +47,6 @@ public: u8 getSwitchNo() { return (fopAcM_GetParam(this) >> 8) & 0xff; } void setAnmSpeed(f32 speed) { mpBckAnm->setPlaySpeed(speed); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ J3DModel* mpPortalModel; /* 0x570 */ mDoExt_bckAnm* mpBckAnm; diff --git a/include/d/actor/d_a_obj_mirror_sand.h b/include/d/actor/d_a_obj_mirror_sand.h index db27ccfaeb..ea7a8a6f30 100644 --- a/include/d/actor/d_a_obj_mirror_sand.h +++ b/include/d/actor/d_a_obj_mirror_sand.h @@ -37,7 +37,6 @@ public: dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[354]); } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm* mpBck; /* 0x570 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_mirror_screw.h b/include/d/actor/d_a_obj_mirror_screw.h index 482506ffc0..7cdf294f9b 100644 --- a/include/d/actor/d_a_obj_mirror_screw.h +++ b/include/d/actor/d_a_obj_mirror_screw.h @@ -65,7 +65,6 @@ public: (this->*mpActionFunc[1])(); } -private: /* 0x5A0 */ J3DModel* mpModel; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ daObjMirrorScrew_actionFunc* mpActionFunc; diff --git a/include/d/actor/d_a_obj_nameplate.h b/include/d/actor/d_a_obj_nameplate.h index d6aa6356bb..7d5140838a 100644 --- a/include/d/actor/d_a_obj_nameplate.h +++ b/include/d/actor/d_a_obj_nameplate.h @@ -51,7 +51,6 @@ public: inline int draw(); inline int createHeap(); -private: /* 0x568 */ J3DModel* model; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_nan.h b/include/d/actor/d_a_obj_nan.h index 708d75199e..f1c9881764 100644 --- a/include/d/actor/d_a_obj_nan.h +++ b/include/d/actor/d_a_obj_nan.h @@ -42,7 +42,6 @@ public: inline int CreateHeap(); inline int draw(); -private: /* 0x590 */ request_of_phase_process_class mPhase; /* 0x598 */ Z2Creature mCreatureSound; /* 0x628 */ mDoExt_McaMorfSO* mMorf; diff --git a/include/d/actor/d_a_obj_octhashi.h b/include/d/actor/d_a_obj_octhashi.h index 4b5ef5459a..9bb21ce9a4 100644 --- a/include/d/actor/d_a_obj_octhashi.h +++ b/include/d/actor/d_a_obj_octhashi.h @@ -33,7 +33,6 @@ public: int Draw(); int Delete(); -private: /* 0x5a0 */ cXyz field_0x5a0[8]; /* 0x600 */ cXyz field_0x600[8]; /* 0x660 */ csXyz field_0x660[8]; @@ -53,7 +52,6 @@ private: public: /* 0x6e8 */ s16 field_0x6e8; /* 0x6ec */ Z2Creature mSound; -private: /* 0x077c */ u8 field_0x77c[4]; /* 0x0780 */ J3DModel* mpModel[8]; /* 0x07a0 */ u8 field_0x7a0[0x7a4 - 0x7a0]; diff --git a/include/d/actor/d_a_obj_oiltubo.h b/include/d/actor/d_a_obj_oiltubo.h index b4ee8612bc..58aeba161d 100644 --- a/include/d/actor/d_a_obj_oiltubo.h +++ b/include/d/actor/d_a_obj_oiltubo.h @@ -36,7 +36,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModel* mpBModel; diff --git a/include/d/actor/d_a_obj_onsen.h b/include/d/actor/d_a_obj_onsen.h index 64af56f1d5..43ba02bc25 100644 --- a/include/d/actor/d_a_obj_onsen.h +++ b/include/d/actor/d_a_obj_onsen.h @@ -25,7 +25,6 @@ public: u32 getType() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_pdtile.h b/include/d/actor/d_a_obj_pdtile.h index 1dcb327acc..05e04063aa 100644 --- a/include/d/actor/d_a_obj_pdtile.h +++ b/include/d/actor/d_a_obj_pdtile.h @@ -35,7 +35,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x5A8 */ Mtx mBgMtx; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mModel; diff --git a/include/d/actor/d_a_obj_pdwall.h b/include/d/actor/d_a_obj_pdwall.h index 45e8213f39..698ac6a6bb 100644 --- a/include/d/actor/d_a_obj_pdwall.h +++ b/include/d/actor/d_a_obj_pdwall.h @@ -26,7 +26,6 @@ public: int getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A8 */ Mtx field_0x5a8; /* 0x5D8 */ J3DModel* mpModels[10]; /* 0x600 */ Mtx field_0x600[10]; diff --git a/include/d/actor/d_a_obj_picture.h b/include/d/actor/d_a_obj_picture.h index 50d44d808b..af175f93e9 100644 --- a/include/d/actor/d_a_obj_picture.h +++ b/include/d/actor/d_a_obj_picture.h @@ -45,7 +45,6 @@ public: #endif static DUSK_GAME_DATA dCcD_SrcCyl s_CcDCyl_pic_at; -private: /* 0x574 */ dCcD_Stts field_0x574; /* 0x5B0 */ dCcD_Stts field_0x5b0; /* 0x5EC */ dCcD_Stts field_0x5ec; diff --git a/include/d/actor/d_a_obj_pleaf.h b/include/d/actor/d_a_obj_pleaf.h index 5e7a5cde1c..12f14a2bad 100644 --- a/include/d/actor/d_a_obj_pleaf.h +++ b/include/d/actor/d_a_obj_pleaf.h @@ -44,7 +44,7 @@ public: * */ class daObj_Pleaf_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_PLEAF_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_poCandle.h b/include/d/actor/d_a_obj_poCandle.h index defcdb7858..c76356d2df 100644 --- a/include/d/actor/d_a_obj_poCandle.h +++ b/include/d/actor/d_a_obj_poCandle.h @@ -48,7 +48,6 @@ public: u8 getIDNum() { return mIDNum; } void setFireFlag(u8 flag) { mFireFlag = flag; } -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModel; /* 0x5C4 */ cXyz mFirePos; diff --git a/include/d/actor/d_a_obj_poFire.h b/include/d/actor/d_a_obj_poFire.h index b8c9198b7c..10a91cbf34 100644 --- a/include/d/actor/d_a_obj_poFire.h +++ b/include/d/actor/d_a_obj_poFire.h @@ -68,7 +68,6 @@ public: u8 getMoveEnd() { return mMoveEnd; } u32 getID() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x584 */ request_of_phase_process_class mPhase; /* 0x58C */ int mStaffID; /* 0x590 */ s16 unk590; diff --git a/include/d/actor/d_a_obj_poTbox.h b/include/d/actor/d_a_obj_poTbox.h index 714f7338d3..44b18117e6 100644 --- a/include/d/actor/d_a_obj_poTbox.h +++ b/include/d/actor/d_a_obj_poTbox.h @@ -33,7 +33,6 @@ public: int getSw() { return fopAcM_GetParamBit(this, 0, 8); } int getStat() { return fopAcM_GetParamBit(this, 8, 4); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpBoxModel; /* 0x5AC */ J3DModel* mpAnimModel; diff --git a/include/d/actor/d_a_obj_prop.h b/include/d/actor/d_a_obj_prop.h index d61025630b..157f8dde6b 100644 --- a/include/d/actor/d_a_obj_prop.h +++ b/include/d/actor/d_a_obj_prop.h @@ -26,7 +26,6 @@ public: u32 getNameArg_0() { return fopAcM_GetParamBit(this, 0, 4); } u32 getArg_0() { return fopAcM_GetParamBit(this, 4, 4); } -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ u8 mArg; }; diff --git a/include/d/actor/d_a_obj_pumpkin.h b/include/d/actor/d_a_obj_pumpkin.h index 9dd015c00e..74ba8f3026 100644 --- a/include/d/actor/d_a_obj_pumpkin.h +++ b/include/d/actor/d_a_obj_pumpkin.h @@ -56,7 +56,7 @@ public: * */ class daObj_Pumpkin_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_PUMPKIN_HIO_CLASS* mpHIO; /* 0x56C */ request_of_phase_process_class mPhaseReq; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_rcircle.h b/include/d/actor/d_a_obj_rcircle.h index 43811a0702..5ef1324f2c 100644 --- a/include/d/actor/d_a_obj_rcircle.h +++ b/include/d/actor/d_a_obj_rcircle.h @@ -25,7 +25,6 @@ public: int getSwBit() { return fopAcM_GetParamBit(this, 0, 8) & 0xFF; } -private: /* 0x574 */ mDoExt_brkAnm mBrk; /* 0x58C */ mDoExt_btkAnm mBtk; /* 0x5A4 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_rfHole.h b/include/d/actor/d_a_obj_rfHole.h index d053d6800c..00a873229c 100644 --- a/include/d/actor/d_a_obj_rfHole.h +++ b/include/d/actor/d_a_obj_rfHole.h @@ -42,7 +42,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_rope_bridge.h b/include/d/actor/d_a_obj_rope_bridge.h index 90532c9ba7..8eababd778 100644 --- a/include/d/actor/d_a_obj_rope_bridge.h +++ b/include/d/actor/d_a_obj_rope_bridge.h @@ -44,7 +44,6 @@ public: u8 getSwbit2() { return fopAcM_GetParamBit(this, 24, 8); } u8 getType() { return fopAcM_GetParamBit(this, 16, 2); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ request_of_phase_process_class mRopePhase; /* 0x5B0 */ J3DModel* mpBrgModel; diff --git a/include/d/actor/d_a_obj_rotTrap.h b/include/d/actor/d_a_obj_rotTrap.h index 9534358f4a..069bfe285c 100644 --- a/include/d/actor/d_a_obj_rotTrap.h +++ b/include/d/actor/d_a_obj_rotTrap.h @@ -37,7 +37,6 @@ public: static DUSK_GAME_DATA const dCcD_SrcGObjInf mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x05A0 */ request_of_phase_process_class mPhase; /* 0x05A8 */ J3DModel* mpModel; /* 0x05AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_roten.h b/include/d/actor/d_a_obj_roten.h index 9b4b17a19d..ea78731b77 100644 --- a/include/d/actor/d_a_obj_roten.h +++ b/include/d/actor/d_a_obj_roten.h @@ -25,7 +25,6 @@ public: char DUSK_CONST* getResName(); virtual ~daObj_Roten_c(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ JPABaseEmitter* mEmitters[2]; diff --git a/include/d/actor/d_a_obj_rstair.h b/include/d/actor/d_a_obj_rstair.h index 053692ba9e..6c31ff4648 100644 --- a/include/d/actor/d_a_obj_rstair.h +++ b/include/d/actor/d_a_obj_rstair.h @@ -58,7 +58,6 @@ public: u8 getEventID() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 action) { mAction = action; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ J3DModel* mWaterModels[2]; diff --git a/include/d/actor/d_a_obj_saidan.h b/include/d/actor/d_a_obj_saidan.h index ef38588f00..f421cf55ad 100644 --- a/include/d/actor/d_a_obj_saidan.h +++ b/include/d/actor/d_a_obj_saidan.h @@ -35,7 +35,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_sakuita.h b/include/d/actor/d_a_obj_sakuita.h index e9e4e82120..621084a592 100644 --- a/include/d/actor/d_a_obj_sakuita.h +++ b/include/d/actor/d_a_obj_sakuita.h @@ -45,7 +45,6 @@ public: static DUSK_GAME_DATA daObjSakuita_Attr_c const M_attr; -private: /* 0x568 */ J3DModel* mModel; /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_sakuita_rope.h b/include/d/actor/d_a_obj_sakuita_rope.h index dfbed5af0e..37df115ea9 100644 --- a/include/d/actor/d_a_obj_sakuita_rope.h +++ b/include/d/actor/d_a_obj_sakuita_rope.h @@ -82,7 +82,6 @@ public: static DUSK_GAME_DATA daObjItaRope_Attr_c const M_attr; -private: /* 0x570 */ mDoExt_3DlineMat1_c mLineMat; /* 0x5A4 */ request_of_phase_process_class mPhase; /* 0x5AC */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_scannon.h b/include/d/actor/d_a_obj_scannon.h index 0b1a79e18f..e376f55d40 100644 --- a/include/d/actor/d_a_obj_scannon.h +++ b/include/d/actor/d_a_obj_scannon.h @@ -83,7 +83,6 @@ public: static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireFirst[][2])(); static DUSK_GAME_DATA void (daSCannon_c::*DUSK_CONST s_demoExeProc_FireSecond[][2])(); -private: /* 0x574 */ request_of_phase_process_class mZevPhase; /* 0x57C */ request_of_phase_process_class mPtlPhase; /* 0x584 */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_obj_scannon_crs.h b/include/d/actor/d_a_obj_scannon_crs.h index d7eb7c8121..12369f58fd 100644 --- a/include/d/actor/d_a_obj_scannon_crs.h +++ b/include/d/actor/d_a_obj_scannon_crs.h @@ -51,7 +51,6 @@ public: static DUSK_GAME_DATA void (daSCannonCrs_c::*s_exeProc[])(daMidna_c*); -private: /* 0x574 */ cXyz mPortalWaitPos; /* 0x580 */ dMsgFlow_c mMsgFlow; /* 0x5CC */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_obj_scannon_ten.h b/include/d/actor/d_a_obj_scannon_ten.h index 7bc5b24ed8..ce6c840cfe 100644 --- a/include/d/actor/d_a_obj_scannon_ten.h +++ b/include/d/actor/d_a_obj_scannon_ten.h @@ -60,7 +60,6 @@ public: static DUSK_GAME_DATA const ExeProc s_exeProc[]; static DUSK_GAME_DATA const ExeProc s_demoExeProc[][2]; -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ mDoExt_bckAnm mBck; /* 0x594 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_sekidoor.h b/include/d/actor/d_a_obj_sekidoor.h index 46da5cb8a9..8f2791a673 100644 --- a/include/d/actor/d_a_obj_sekidoor.h +++ b/include/d/actor/d_a_obj_sekidoor.h @@ -59,7 +59,6 @@ public: void open() { mOpening = true; } bool chkDestroy() { return (mDestroyed == true); } -private: /* 0x5A0 */ OBJ_SEKIDOOR_HIO_CLASS* mpHIO; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_sekizo.h b/include/d/actor/d_a_obj_sekizo.h index 0f0847dc24..2011417a96 100644 --- a/include/d/actor/d_a_obj_sekizo.h +++ b/include/d/actor/d_a_obj_sekizo.h @@ -50,7 +50,6 @@ public: void initBaseMtx(); void setBaseMtx(); -private: /* 0x5A0 */ OBJ_SEKIZO_HIO_CLASS* mpHIO; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_shield.h b/include/d/actor/d_a_obj_shield.h index 11b4a2668d..248c26be5b 100644 --- a/include/d/actor/d_a_obj_shield.h +++ b/include/d/actor/d_a_obj_shield.h @@ -59,7 +59,6 @@ public: void setStatus(u8 status) { mStatus = status; } void setAction(u8 action) { mAction = action; } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int mRotAngleCoeff; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_sm_door.h b/include/d/actor/d_a_obj_sm_door.h index bec15a0ae8..bd6553c0d2 100644 --- a/include/d/actor/d_a_obj_sm_door.h +++ b/include/d/actor/d_a_obj_sm_door.h @@ -31,7 +31,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ bool mUseAlphaModel; /* 0x5A1 */ u8 field_0x5a1[0x5AC - 0x5A1]; /* 0x5AC */ s16 mMode; @@ -54,5 +53,4 @@ private: STATIC_ASSERT(sizeof(daObjSM_DOOR_c) == 0x858); - #endif /* D_A_OBJ_SM_DOOR_H */ diff --git a/include/d/actor/d_a_obj_smallkey.h b/include/d/actor/d_a_obj_smallkey.h index 2becc9bae2..7bf38de4af 100644 --- a/include/d/actor/d_a_obj_smallkey.h +++ b/include/d/actor/d_a_obj_smallkey.h @@ -14,7 +14,7 @@ * */ class daKey_c : public daItemBase_c { -private: +public: void seStartTwinkle_private(u32); public: diff --git a/include/d/actor/d_a_obj_smgdoor.h b/include/d/actor/d_a_obj_smgdoor.h index aad2800ece..b22734b3e3 100644 --- a/include/d/actor/d_a_obj_smgdoor.h +++ b/include/d/actor/d_a_obj_smgdoor.h @@ -53,7 +53,6 @@ public: virtual int Draw(); virtual int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel[2]; /* 0x5B0 */ s16 field_0x5b0; diff --git a/include/d/actor/d_a_obj_smoke.h b/include/d/actor/d_a_obj_smoke.h index 61a3b56a51..abd172afbe 100644 --- a/include/d/actor/d_a_obj_smoke.h +++ b/include/d/actor/d_a_obj_smoke.h @@ -24,7 +24,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ JPABaseEmitter* mParticle; }; diff --git a/include/d/actor/d_a_obj_smtile.h b/include/d/actor/d_a_obj_smtile.h index 735914f0a0..c85000e7b8 100644 --- a/include/d/actor/d_a_obj_smtile.h +++ b/include/d/actor/d_a_obj_smtile.h @@ -41,7 +41,7 @@ public: * */ class daObj_SMTile_c : public fopAc_ac_c { -private: +public: /* 0x568 */ mDoExt_brkAnm mBrk; /* 0x580 */ OBJ_SMTILE_HIO_CLASS* mpHIO; /* 0x584 */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_smw_stone.h b/include/d/actor/d_a_obj_smw_stone.h index 02f58284ff..05913cd339 100644 --- a/include/d/actor/d_a_obj_smw_stone.h +++ b/include/d/actor/d_a_obj_smw_stone.h @@ -29,7 +29,6 @@ public: u8 getSwBit0() { return fopAcM_GetParamBit(this, 0, 8); } void deleteStone() { mDelete = true; } -private: /* 0x574 */ cBgS_PolyInfo mPolyInfo; /* 0x584 */ J3DModel* mpModel; /* 0x588 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_snowEffTag.h b/include/d/actor/d_a_obj_snowEffTag.h index 748106cc81..bc995c749c 100644 --- a/include/d/actor/d_a_obj_snowEffTag.h +++ b/include/d/actor/d_a_obj_snowEffTag.h @@ -23,7 +23,6 @@ public: int getArg0() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ bool mPlayedSound; /* 0x56C */ f32 mMaxSize; diff --git a/include/d/actor/d_a_obj_snow_soup.h b/include/d/actor/d_a_obj_snow_soup.h index 91c23c8f85..3b96cd566f 100644 --- a/include/d/actor/d_a_obj_snow_soup.h +++ b/include/d/actor/d_a_obj_snow_soup.h @@ -28,7 +28,6 @@ public: void createSmkEmtChange(int); void deleteSmkEmtChange(int); -private: /* 0x574 */ cXyz mFirewoodPos; /* 0x580 */ cXyz mBubblePos; /* 0x58C */ JPABaseEmitter* mpSmkEmtCommon[4]; diff --git a/include/d/actor/d_a_obj_spinLift.h b/include/d/actor/d_a_obj_spinLift.h index 548df3f910..d2f0a50b03 100644 --- a/include/d/actor/d_a_obj_spinLift.h +++ b/include/d/actor/d_a_obj_spinLift.h @@ -40,7 +40,6 @@ public: u8 getTimer() { return (current.angle.x & 0xff00) >> 8; } int getEndSw() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 field_0x5ac; diff --git a/include/d/actor/d_a_obj_ss_base.h b/include/d/actor/d_a_obj_ss_base.h index 4d275a43cd..2101dd3237 100644 --- a/include/d/actor/d_a_obj_ss_base.h +++ b/include/d/actor/d_a_obj_ss_base.h @@ -18,7 +18,6 @@ public: u16 getValueNumber() { return mValueNum; } void setValueNumber(u16 valueNum) { mValueNum = valueNum; } -private: /* 0x56C */ void* mpParentPtr; /* 0x570 */ u16 field_0x570; /* 0x572 */ u16 mFlowNodeNum; diff --git a/include/d/actor/d_a_obj_ss_drink.h b/include/d/actor/d_a_obj_ss_drink.h index e49644f6b6..c4c0a1a72b 100644 --- a/include/d/actor/d_a_obj_ss_drink.h +++ b/include/d/actor/d_a_obj_ss_drink.h @@ -50,7 +50,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x578 */ mDoExt_btpAnm* mpBtpAnm; /* 0x57C */ mDoExt_brkAnm* mpBrkAnm; /* 0x580 */ u8 field_0x580; diff --git a/include/d/actor/d_a_obj_ss_item.h b/include/d/actor/d_a_obj_ss_item.h index cd219a1832..59f8f56407 100644 --- a/include/d/actor/d_a_obj_ss_item.h +++ b/include/d/actor/d_a_obj_ss_item.h @@ -49,7 +49,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl DUSK_CONST mCcDCyl; -private: /* 0x578 */ request_of_phase_process_class mPhase; /* 0x580 */ J3DModel* mpModel; /* 0x584 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_stairBlock.h b/include/d/actor/d_a_obj_stairBlock.h index 3d3b8d5283..1b04d0bcc1 100644 --- a/include/d/actor/d_a_obj_stairBlock.h +++ b/include/d/actor/d_a_obj_stairBlock.h @@ -26,7 +26,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x056C */ request_of_phase_process_class mPhaseReq; /* 0x0574 */ J3DModel* mpModel[10]; /* 0x059C */ mDoExt_bckAnm mBckAnm[10]; diff --git a/include/d/actor/d_a_obj_stick.h b/include/d/actor/d_a_obj_stick.h index ebc08e08b8..ce72273254 100644 --- a/include/d/actor/d_a_obj_stick.h +++ b/include/d/actor/d_a_obj_stick.h @@ -45,7 +45,7 @@ public: * */ class daObj_Stick_c : public fopAc_ac_c { -private: +public: /* 0x568 */ OBJ_STICK_HIO_CLASS* mpHIO; /* 0x56c */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_stone.h b/include/d/actor/d_a_obj_stone.h index b5f4da8c39..dfeb11f539 100644 --- a/include/d/actor/d_a_obj_stone.h +++ b/include/d/actor/d_a_obj_stone.h @@ -56,7 +56,6 @@ public: int draw(); int _delete(); -private: /* 0x0568 */ request_of_phase_process_class mPhase; /* 0x0570 */ J3DModel* mpModel; /* 0x0574 */ dBgS_ObjAcch mChkObj; diff --git a/include/d/actor/d_a_obj_stoneMark.h b/include/d/actor/d_a_obj_stoneMark.h index fbe56ce31d..04540fd9c7 100644 --- a/include/d/actor/d_a_obj_stoneMark.h +++ b/include/d/actor/d_a_obj_stoneMark.h @@ -23,7 +23,6 @@ public: int draw(); int _delete(); -private: /* 0x0568 */ request_of_phase_process_class mpPhase; /* 0x0570 */ TGXTexObj mTexObj; /* 0x0590 */ dBgS_ObjAcch mObjAcch; diff --git a/include/d/actor/d_a_obj_stopper.h b/include/d/actor/d_a_obj_stopper.h index 9a100c754b..62eda0ae39 100644 --- a/include/d/actor/d_a_obj_stopper.h +++ b/include/d/actor/d_a_obj_stopper.h @@ -59,7 +59,6 @@ public: u8 getSwNo() { return fopAcM_GetParamBit(this, 0, 8); } u8 getSwNo2() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ u8 field_0x5a0[8]; // unused /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_stopper2.h b/include/d/actor/d_a_obj_stopper2.h index 7ec86cb818..ccae3af298 100644 --- a/include/d/actor/d_a_obj_stopper2.h +++ b/include/d/actor/d_a_obj_stopper2.h @@ -35,7 +35,6 @@ public: u32 getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } void setAction(u8 i_action) { mAction = i_action; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ f32 mOffsetY; diff --git a/include/d/actor/d_a_obj_suisya.h b/include/d/actor/d_a_obj_suisya.h index c92146f5af..59067d84a4 100644 --- a/include/d/actor/d_a_obj_suisya.h +++ b/include/d/actor/d_a_obj_suisya.h @@ -20,7 +20,6 @@ public: int CreateHeap(); int create(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u32 mShadowKey; diff --git a/include/d/actor/d_a_obj_swBallA.h b/include/d/actor/d_a_obj_swBallA.h index 1785565a4e..910c031050 100644 --- a/include/d/actor/d_a_obj_swBallA.h +++ b/include/d/actor/d_a_obj_swBallA.h @@ -41,7 +41,6 @@ public: void onFlag(u8 idx, u8 val) { field_0x5af[idx] |= val; } u8 checkFlag(u8 idx, u8 val) { return field_0x5af[idx] & val; } -private: /* 0x57C */ request_of_phase_process_class field_0x57c; /* 0x584 */ J3DModel* mModel; /* 0x588 */ mDoExt_btkAnm* field_0x588; diff --git a/include/d/actor/d_a_obj_swBallB.h b/include/d/actor/d_a_obj_swBallB.h index 31a7971232..31a8f4210e 100644 --- a/include/d/actor/d_a_obj_swBallB.h +++ b/include/d/actor/d_a_obj_swBallB.h @@ -44,7 +44,6 @@ public: void setLightOn() { field_0x5ac = 1; } void setLightOff() { field_0x5ad = 1; } -private: /* 0x57C */ request_of_phase_process_class field_0x57c; /* 0x584 */ J3DModel* mModel; /* 0x588 */ mDoExt_btkAnm* field_0x588; diff --git a/include/d/actor/d_a_obj_swLight.h b/include/d/actor/d_a_obj_swLight.h index 1a9fc50cca..9d84030e96 100644 --- a/include/d/actor/d_a_obj_swLight.h +++ b/include/d/actor/d_a_obj_swLight.h @@ -47,7 +47,6 @@ public: u8 getOnTime() { return fopAcM_GetParamBit(this, 16, 8); } u8 getEvent() { return (u8)field_0xb22; } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x6F4 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_swchain.h b/include/d/actor/d_a_obj_swchain.h index 270fb8f5ab..8bd68b4478 100644 --- a/include/d/actor/d_a_obj_swchain.h +++ b/include/d/actor/d_a_obj_swchain.h @@ -80,7 +80,6 @@ public: return FALSE; } -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ J3DModelData* mChainModelData; diff --git a/include/d/actor/d_a_obj_swhang.h b/include/d/actor/d_a_obj_swhang.h index 097da890b3..37ddbb3ea2 100644 --- a/include/d/actor/d_a_obj_swhang.h +++ b/include/d/actor/d_a_obj_swhang.h @@ -78,7 +78,6 @@ public: u16 checkFlag(u16 flag) { return mFlags & flag; } s16 getAngleY() { return shape_angle.y; } -private: /* 0x5B0 */ request_of_phase_process_class mPhase; /* 0x5B8 */ J3DModel* mpModel; /* 0x5BC */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_sword.h b/include/d/actor/d_a_obj_sword.h index 163175ddec..63bc7d576a 100644 --- a/include/d/actor/d_a_obj_sword.h +++ b/include/d/actor/d_a_obj_sword.h @@ -31,7 +31,6 @@ public: u8 getSwbit() { return fopAcM_GetParamBit(this, 8, 8); } void setStatus(u8 status) { mStatus = status; } -private: /* 0x92c */ u32 field_0x92c; /* 0x930 */ fpc_ProcID mProcID; /* 0x934 */ u8 mStatus; diff --git a/include/d/actor/d_a_obj_syRock.h b/include/d/actor/d_a_obj_syRock.h index 2c881585ed..3fa10456f8 100644 --- a/include/d/actor/d_a_obj_syRock.h +++ b/include/d/actor/d_a_obj_syRock.h @@ -46,7 +46,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5B8 */ request_of_phase_process_class mPhase; /* 0x5C0 */ J3DModel* mpModels[2]; /* 0x5C8 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_szbridge.h b/include/d/actor/d_a_obj_szbridge.h index eff6a17a9c..8702506280 100644 --- a/include/d/actor/d_a_obj_szbridge.h +++ b/include/d/actor/d_a_obj_szbridge.h @@ -25,7 +25,6 @@ public: int Delete(); virtual ~daObjSZbridge_c() {} -private: /* 0x5A8 */ Mtx mBgMtx; /* 0x5D8 */ Mtx field_0x5d8; /* 0x608 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_obj_table.h b/include/d/actor/d_a_obj_table.h index cea036783c..44de1d1a47 100644 --- a/include/d/actor/d_a_obj_table.h +++ b/include/d/actor/d_a_obj_table.h @@ -27,7 +27,6 @@ public: s16 getMessageNo() { return fopAcM_GetParam(this) & 0xFFFF; } -private: /* 0x5A0 */ J3DModel* mpModel; /* 0x5A4 */ request_of_phase_process_class mPhaseReq; /* 0x5AC */ dMsgFlow_c mMsgFlow; diff --git a/include/d/actor/d_a_obj_takaraDai.h b/include/d/actor/d_a_obj_takaraDai.h index b745683dd6..657e032bcc 100644 --- a/include/d/actor/d_a_obj_takaraDai.h +++ b/include/d/actor/d_a_obj_takaraDai.h @@ -26,7 +26,6 @@ public: u32 getSwBit() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpBaseModel; /* 0x5AC */ J3DModel* mpTopModel; diff --git a/include/d/actor/d_a_obj_tgake.h b/include/d/actor/d_a_obj_tgake.h index 1871794df9..6862ad4979 100644 --- a/include/d/actor/d_a_obj_tgake.h +++ b/include/d/actor/d_a_obj_tgake.h @@ -28,7 +28,6 @@ public: u16 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } u8 getType() { return fopAcM_GetParamBit(this, 0x14, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u16 mEventBit1; diff --git a/include/d/actor/d_a_obj_thashi.h b/include/d/actor/d_a_obj_thashi.h index 3796ee0629..1934b57c56 100644 --- a/include/d/actor/d_a_obj_thashi.h +++ b/include/d/actor/d_a_obj_thashi.h @@ -25,8 +25,6 @@ public: int Draw(); int Delete(); -// private: - /* 0x5A0 */ dBgW* unk5A0; /* 0x5A4 */ u32 unk5A4; /* 0x5A8 */ u32 unk5A8; diff --git a/include/d/actor/d_a_obj_timeFire.h b/include/d/actor/d_a_obj_timeFire.h index 62fb3460d9..0b7a5ab5ec 100644 --- a/include/d/actor/d_a_obj_timeFire.h +++ b/include/d/actor/d_a_obj_timeFire.h @@ -28,7 +28,6 @@ public: u8 getEndTime() { return fopAcM_GetParamBit(this, 16, 8); } u8 getScale() { return fopAcM_GetParamBit(this, 24, 8); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 mStartTime; diff --git a/include/d/actor/d_a_obj_timer.h b/include/d/actor/d_a_obj_timer.h index 120a23b3a9..5778bf5ca1 100644 --- a/include/d/actor/d_a_obj_timer.h +++ b/include/d/actor/d_a_obj_timer.h @@ -54,7 +54,6 @@ class Act_c : public fopAc_ac_c { return daObj::PrmAbstract(this, PRM_2, PRM_24); } - private: /* 0x568 */ int field_0x568; /* 0x56C */ int field_0x56c; /* 0x570 */ u8 field_0x570; diff --git a/include/d/actor/d_a_obj_tmoon.h b/include/d/actor/d_a_obj_tmoon.h index 4bf3c3620c..2992316782 100644 --- a/include/d/actor/d_a_obj_tmoon.h +++ b/include/d/actor/d_a_obj_tmoon.h @@ -25,7 +25,6 @@ public: u32 getEventBit1() { return fopAcM_GetParamBit(this, 0, 10); } u32 getEventBit2() { return fopAcM_GetParamBit(this, 10, 10); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ u16 field_0x574; diff --git a/include/d/actor/d_a_obj_toaru_maki.h b/include/d/actor/d_a_obj_toaru_maki.h index 4f7e8d2645..d980f9410f 100644 --- a/include/d/actor/d_a_obj_toaru_maki.h +++ b/include/d/actor/d_a_obj_toaru_maki.h @@ -25,7 +25,6 @@ public: u32 getNameArg_0() { return fopAcM_GetParamBit(this, 0, 4); } -private: /* 0x574 */ J3DModel* mpModel; /* 0x578 */ dBgW* mpBgW; /* 0x57C */ Mtx mMtx; diff --git a/include/d/actor/d_a_obj_togeTrap.h b/include/d/actor/d_a_obj_togeTrap.h index 4055d6a42e..a67451ea0a 100644 --- a/include/d/actor/d_a_obj_togeTrap.h +++ b/include/d/actor/d_a_obj_togeTrap.h @@ -47,7 +47,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcCyl mCcDCyl; -private: /* 0x5A0 */ dCcD_Stts mStts; /* 0x5DC */ dCcD_Cyl mCyls[4]; /* 0xACC */ request_of_phase_process_class mPhase; diff --git a/include/d/actor/d_a_obj_tombo.h b/include/d/actor/d_a_obj_tombo.h index 5dfdcb6451..288d35611e 100644 --- a/include/d/actor/d_a_obj_tombo.h +++ b/include/d/actor/d_a_obj_tombo.h @@ -48,7 +48,6 @@ public: inline int Draw(); -private: /* 0x590 */ dCcD_Stts mStts; /* 0x5CC */ dCcD_Sph mSph; /* 0x704 */ daPy_boomerangMove_c mBoomerangMove; diff --git a/include/d/actor/d_a_obj_tornado.h b/include/d/actor/d_a_obj_tornado.h index 30e8e2c1e3..c3330d73f9 100644 --- a/include/d/actor/d_a_obj_tornado.h +++ b/include/d/actor/d_a_obj_tornado.h @@ -30,7 +30,6 @@ public: u8 getTimer() { return fopAcM_GetParamBit(this, 0, 8); } u8 getSwbit() { return fopAcM_GetParamBit(this, 0x18, 8); } -private: /* 0x568 */ dCcD_Stts mStts; /* 0x5A4 */ dCcD_Cps mCps; /* 0x6E8 */ cM3dGCpsS mWindCps; diff --git a/include/d/actor/d_a_obj_twGate.h b/include/d/actor/d_a_obj_twGate.h index 683a7f18fb..0a00c2b834 100644 --- a/include/d/actor/d_a_obj_twGate.h +++ b/include/d/actor/d_a_obj_twGate.h @@ -23,7 +23,6 @@ public: int getGateType() { return fopAcM_GetParamBit(this, 4, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel; /* 0x5AC */ mDoExt_btkAnm mBtk; diff --git a/include/d/actor/d_a_obj_vground.h b/include/d/actor/d_a_obj_vground.h index fed893aef1..bd9e266ebf 100644 --- a/include/d/actor/d_a_obj_vground.h +++ b/include/d/actor/d_a_obj_vground.h @@ -24,7 +24,6 @@ public: u32 getSwbit() { return (u8) fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ mDoExt_btkAnm* mpBtk; diff --git a/include/d/actor/d_a_obj_volcball.h b/include/d/actor/d_a_obj_volcball.h index ddd299a26e..cb1e895e8f 100644 --- a/include/d/actor/d_a_obj_volcball.h +++ b/include/d/actor/d_a_obj_volcball.h @@ -113,7 +113,6 @@ public: void setAction(u8 i_action) { mMode = i_action; } -private: /* 0x057C */ request_of_phase_process_class mPhase; /* 0x0584 */ dBgS_AcchCir mAcchCir; /* 0x05C4 */ dCcD_Stts mCcStts; diff --git a/include/d/actor/d_a_obj_volcbom.h b/include/d/actor/d_a_obj_volcbom.h index 17f9db911d..60401dca2d 100644 --- a/include/d/actor/d_a_obj_volcbom.h +++ b/include/d/actor/d_a_obj_volcbom.h @@ -84,7 +84,6 @@ public: u8 getArg0() { return fopAcM_GetParamBit(this, 16, 8); } u16 getMsgID() { return mMsgID; } -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mModel1; /* 0x5AC */ mDoExt_btkAnm* mBtk1; diff --git a/include/d/actor/d_a_obj_waterGate.h b/include/d/actor/d_a_obj_waterGate.h index 66a076be78..ae81773aec 100644 --- a/include/d/actor/d_a_obj_waterGate.h +++ b/include/d/actor/d_a_obj_waterGate.h @@ -33,7 +33,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ request_of_phase_process_class mPhase; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 mMode; diff --git a/include/d/actor/d_a_obj_waterPillar.h b/include/d/actor/d_a_obj_waterPillar.h index 19b55971e8..987abc3923 100644 --- a/include/d/actor/d_a_obj_waterPillar.h +++ b/include/d/actor/d_a_obj_waterPillar.h @@ -76,7 +76,6 @@ public: mStartStalactiteShake = false; } -private: /* 0x584 */ request_of_phase_process_class mPhase; /* 0x58C */ J3DModel* mpModel; /* 0x590 */ mDoExt_btkAnm mVTexScrollAnm; diff --git a/include/d/actor/d_a_obj_waterfall.h b/include/d/actor/d_a_obj_waterfall.h index e7c143910d..7a69938455 100644 --- a/include/d/actor/d_a_obj_waterfall.h +++ b/include/d/actor/d_a_obj_waterfall.h @@ -24,7 +24,6 @@ public: void push_player(); int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ u8 pad[4]; /* 0x574 */ dCcD_Stts mCylColliderStts; diff --git a/include/d/actor/d_a_obj_wchain.h b/include/d/actor/d_a_obj_wchain.h index b9f791d058..d9377d327a 100644 --- a/include/d/actor/d_a_obj_wchain.h +++ b/include/d/actor/d_a_obj_wchain.h @@ -57,7 +57,6 @@ public: mDown = true; } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpHandleModel; /* 0x574 */ J3DModelData* mpChainModelData; diff --git a/include/d/actor/d_a_obj_wdStick.h b/include/d/actor/d_a_obj_wdStick.h index 08bc2a1faf..e68f5a4a8e 100644 --- a/include/d/actor/d_a_obj_wdStick.h +++ b/include/d/actor/d_a_obj_wdStick.h @@ -53,7 +53,6 @@ public: static DUSK_GAME_DATA dCcD_SrcGObjInf const mCcDObjInfo; static DUSK_GAME_DATA dCcD_SrcSph mCcDSph; -private: /* 0x56C */ request_of_phase_process_class mPhase; /* 0x574 */ J3DModel* mModel; /* 0x578 */ u8 mMode; diff --git a/include/d/actor/d_a_obj_well_cover.h b/include/d/actor/d_a_obj_well_cover.h index b25ad59abe..f4fb2250d0 100644 --- a/include/d/actor/d_a_obj_well_cover.h +++ b/include/d/actor/d_a_obj_well_cover.h @@ -29,7 +29,6 @@ public: u8 getSwNo() { return fopAcM_GetParam(this); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ u8 field_0x5AC[0x5B0 - 0x5AC]; diff --git a/include/d/actor/d_a_obj_wind_stone.h b/include/d/actor/d_a_obj_wind_stone.h index f5e52dfc94..107cecc92c 100644 --- a/include/d/actor/d_a_obj_wind_stone.h +++ b/include/d/actor/d_a_obj_wind_stone.h @@ -36,7 +36,6 @@ public: u32 getSwBit2() { return fopAcM_GetParamBit(this, 8, 8); } u32 getDelEveFlgId() { return fopAcM_GetParamBit(this, 0x10, 0x10); } -private: /* 0x574 */ cBgS_PolyInfo mPolyInfo; /* 0x584 */ J3DModel* mpModel; /* 0x588 */ dBgW* mpBgW; diff --git a/include/d/actor/d_a_obj_window.h b/include/d/actor/d_a_obj_window.h index 83b62740a4..8d1b0412d7 100644 --- a/include/d/actor/d_a_obj_window.h +++ b/include/d/actor/d_a_obj_window.h @@ -27,7 +27,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 0, 8); } u8 getLightInf() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x5A0 */ request_of_phase_process_class mPhaseReq; /* 0x5A8 */ J3DModel* mpModel; /* 0x5AC */ mDoExt_bckAnm* mpBckAnm; diff --git a/include/d/actor/d_a_obj_wood_pendulum.h b/include/d/actor/d_a_obj_wood_pendulum.h index 1a1ee024b3..9ee5126ad8 100644 --- a/include/d/actor/d_a_obj_wood_pendulum.h +++ b/include/d/actor/d_a_obj_wood_pendulum.h @@ -26,7 +26,6 @@ public: u32 getArg0() { return fopAcM_GetParamBit(this, 0, 8); } u32 getArg1() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dCcD_Stts mStts; diff --git a/include/d/actor/d_a_obj_wood_statue.h b/include/d/actor/d_a_obj_wood_statue.h index c0214679db..3ddd94bc62 100644 --- a/include/d/actor/d_a_obj_wood_statue.h +++ b/include/d/actor/d_a_obj_wood_statue.h @@ -52,7 +52,6 @@ public: void setStatus(u8 status) { mStatus = status; } u8 getSwbit2() { return fopAcM_GetParamBit(this, 8, 8); } -private: /* 0x92C */ fpc_ProcID mItemId; /* 0x930 */ int field_0x930; /* 0x934 */ int mStaffIdx; diff --git a/include/d/actor/d_a_obj_wsword.h b/include/d/actor/d_a_obj_wsword.h index aa611af336..2860313c19 100644 --- a/include/d/actor/d_a_obj_wsword.h +++ b/include/d/actor/d_a_obj_wsword.h @@ -25,7 +25,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ J3DModel* mpModel; /* 0x574 */ dBgS_ObjAcch mAcch; diff --git a/include/d/actor/d_a_obj_yel_bag.h b/include/d/actor/d_a_obj_yel_bag.h index caeba24ae5..9c3f452a11 100644 --- a/include/d/actor/d_a_obj_yel_bag.h +++ b/include/d/actor/d_a_obj_yel_bag.h @@ -53,7 +53,7 @@ public: * */ class daObj_YBag_c : public fopAc_ac_c { -private: +public: /* 0x568 */ request_of_phase_process_class mPhases[3]; /* 0x580 */ J3DModel* mModel; /* 0x584 */ OBJ_YBAG_HIO_CLASS* mpHIO; diff --git a/include/d/actor/d_a_obj_yobikusa.h b/include/d/actor/d_a_obj_yobikusa.h index a3dfa944fa..ed1019c7ad 100644 --- a/include/d/actor/d_a_obj_yobikusa.h +++ b/include/d/actor/d_a_obj_yobikusa.h @@ -87,7 +87,6 @@ public: return var_r31 > 0; } -private: /* 0x568 */ J3DModel* mpActiveModel; /* 0x56C */ J3DModel* mpModelTypeA; /* 0x570 */ J3DModel* mpModelTypeB; diff --git a/include/d/actor/d_a_obj_zrTurara.h b/include/d/actor/d_a_obj_zrTurara.h index 679ae20635..c52a21f2cc 100644 --- a/include/d/actor/d_a_obj_zrTurara.h +++ b/include/d/actor/d_a_obj_zrTurara.h @@ -29,7 +29,6 @@ public: int Draw(); int Delete(); -private: /* 0x5A0 */ dCcD_Stts mCcStatus; /* 0x5DC */ dCcD_Cyl mCcCyl; /* 0x718 */ request_of_phase_process_class mPhaseReq; diff --git a/include/d/actor/d_a_obj_zrTuraraRock.h b/include/d/actor/d_a_obj_zrTuraraRock.h index 1f92de6e82..922948ee9c 100644 --- a/include/d/actor/d_a_obj_zrTuraraRock.h +++ b/include/d/actor/d_a_obj_zrTuraraRock.h @@ -30,7 +30,6 @@ public: int Draw(); int Delete(); -private: /* 0x568 */ dCcD_Stts mCcStatus; /* 0x5A4 */ dCcD_Sph mCcSph; /* 0x6DC */ request_of_phase_process_class mPhaseReq; diff --git a/include/d/actor/d_a_obj_zra_rock.h b/include/d/actor/d_a_obj_zra_rock.h index 586fc176c5..925c49a5ee 100644 --- a/include/d/actor/d_a_obj_zra_rock.h +++ b/include/d/actor/d_a_obj_zra_rock.h @@ -28,7 +28,6 @@ public: void setDemoStart() { mDemoStart = 1; } -private: friend class daNpc_zrZ_c; /* 0x5A0 */ request_of_phase_process_class mPhaseReq; diff --git a/include/d/actor/d_a_passer_mng.h b/include/d/actor/d_a_passer_mng.h index ced02d9d1d..a3aa50db35 100644 --- a/include/d/actor/d_a_passer_mng.h +++ b/include/d/actor/d_a_passer_mng.h @@ -259,7 +259,6 @@ public: static DUSK_GAME_DATA const Group* mGroupTbl[4]; -private: /* 0x568 */ fpc_ProcID* childProcIds; /* 0x56C */ dPath* mPath; /* 0x570 */ int startTime; diff --git a/include/d/actor/d_a_peru.h b/include/d/actor/d_a_peru.h index 771e879b10..8a997b7a85 100644 --- a/include/d/actor/d_a_peru.h +++ b/include/d/actor/d_a_peru.h @@ -189,7 +189,6 @@ public: static DUSK_GAME_DATA const char* mCutNameList[3]; static DUSK_GAME_DATA cutAppearFunc mCutList[3]; -private: /* 0x0E40 */ daNpcT_ActorMngr_c mActors[3]; /* 0x0E58 */ int field_0xe58; /* 0x0E5C */ actionFunc mActionFunc; diff --git a/include/d/actor/d_a_player.h b/include/d/actor/d_a_player.h index ce6158fcf7..ff8a165ef8 100644 --- a/include/d/actor/d_a_player.h +++ b/include/d/actor/d_a_player.h @@ -25,7 +25,6 @@ public: mNowSetFlg = 0; } -private: /* 0x14 */ u16 mEndFlg; /* 0x16 */ u16 mNowSetFlg; }; @@ -70,7 +69,6 @@ public: static DUSK_GAME_DATA s16 m_dropAngleY; static DUSK_GAME_DATA s16 m_eventKeepFlg; -private: /* 0x0 */ u8 field_0x0; /* 0x2 */ s16 field_0x2; /* 0x4 */ f32 m_offsetY; @@ -91,6 +89,14 @@ private: #define PLAYER_CREATE_ANM_HEAP(heap, type, name) (heap).createHeap(type) #endif +#if TARGET_PC +inline u32 daPy_getAnmResourceSize(u16 i_resId, u32 i_minSize) { + JKRArchive* archive = dComIfGp_getAnmArchive(); + u32 size = archive->getFileSize(archive->findIdxResource(i_resId)); + return size > i_minSize ? size : i_minSize; +} +#endif + class daPy_anmHeap_c { public: enum daAlinkHEAP_TYPE { @@ -107,6 +113,9 @@ public: void* mallocBuffer(); #if TARGET_PC void createHeap(daAlinkHEAP_TYPE i_heapType, const char* name); + void reserveBuffer(u16 i_resId); + void* allocTempBuffer(u16 i_resId, u32* io_size); + void freeTempBuffers(); #else void createHeap(daAlinkHEAP_TYPE i_heapType); #endif @@ -136,6 +145,10 @@ public: /* 0x08 */ u32 mBufferSize; /* 0x0C */ u8* mBuffer; /* 0x10 */ JKRSolidHeap* mAnimeHeap; +#if TARGET_PC + u8* mOwnedBuffer = NULL; + void** mTempBuffers = NULL; +#endif }; // Size = 0x14 class daPy_actorKeep_c { @@ -151,7 +164,6 @@ public: fopAc_ac_c* getActor() const { return mActor; } fopAc_ac_c* getActorConst() const { return mActor; } -private: /* 0x0 */ fpc_ProcID mID; /* 0x4 */ fopAc_ac_c* mActor; }; // Size: 0x8 @@ -296,7 +308,6 @@ public: void resetDemoType() { setDemoType(0); } void setStartDemoType() { setDemoType(DEMO_TYPE_START_e); } -private: /* 0x00 */ u16 mDemoType; /* 0x02 */ s16 mDemoMoveAngle; /* 0x04 */ s16 mTimer; diff --git a/include/d/actor/d_a_ppolamp.h b/include/d/actor/d_a_ppolamp.h index f1e1a9f26d..d55754d97b 100644 --- a/include/d/actor/d_a_ppolamp.h +++ b/include/d/actor/d_a_ppolamp.h @@ -25,7 +25,6 @@ public: void moveSwing(); void initParam(); -private: /* 0x574 */ J3DModel* mModel1; /* 0x578 */ J3DModel* mModel2; /* 0x57C */ mDoExt_bckAnm mBck; diff --git a/include/d/actor/d_a_spinner.h b/include/d/actor/d_a_spinner.h index 1dac4594a3..0ef81f3947 100644 --- a/include/d/actor/d_a_spinner.h +++ b/include/d/actor/d_a_spinner.h @@ -99,7 +99,6 @@ public: void forceDelete() { mDeleteFlg = true; } -private: /* 0x568 */ J3DModel* mpModel; /* 0x56C */ mDoExt_bckAnm mBck; /* 0x588 */ J3DAnmTransform* mpSpoutBck; diff --git a/include/d/actor/d_a_swBall.h b/include/d/actor/d_a_swBall.h index 74bfa90593..df4877e04b 100644 --- a/include/d/actor/d_a_swBall.h +++ b/include/d/actor/d_a_swBall.h @@ -30,7 +30,6 @@ public: u8 getType() { return fopAcM_GetParamBit(this, 24, 4); } bool checkPullLBall() { return fopAcM_GetParamBit(this, 28, 2) == 0; } -private: /* 0x568 */ fpc_ProcID mBallIDs[8]; /* 0x588 */ u8 mTimer; /* 0x589 */ u8 mAction; diff --git a/include/d/actor/d_a_swLBall.h b/include/d/actor/d_a_swLBall.h index 0a633fcb5b..c3d132a40f 100644 --- a/include/d/actor/d_a_swLBall.h +++ b/include/d/actor/d_a_swLBall.h @@ -42,7 +42,6 @@ public: return fopAcM_GetParamBit(this,28,2) == 0; } -private: /* 0x568 */ fpc_ProcID mProcIds[2]; /* 0x570 */ u8 mRunTimer; /* 0x571 */ u8 mAction; diff --git a/include/d/actor/d_a_swTime.h b/include/d/actor/d_a_swTime.h index b3b96fa104..f61d5a5e7f 100644 --- a/include/d/actor/d_a_swTime.h +++ b/include/d/actor/d_a_swTime.h @@ -30,7 +30,6 @@ public: int execute(); int _delete(); -private: /* 0x568 */ u8 mTime; /* 0x569 */ u8 mSwbit; /* 0x56A */ u8 mSwbit2; diff --git a/include/d/actor/d_a_tag_CstaSw.h b/include/d/actor/d_a_tag_CstaSw.h index b40a9d178e..e73fd18662 100644 --- a/include/d/actor/d_a_tag_CstaSw.h +++ b/include/d/actor/d_a_tag_CstaSw.h @@ -16,7 +16,6 @@ public: u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 mSwitch; /* 0x569 */ u8 unused[0x570 - 0x569]; diff --git a/include/d/actor/d_a_tag_TWgate.h b/include/d/actor/d_a_tag_TWgate.h index 1886690db2..683d01449b 100644 --- a/include/d/actor/d_a_tag_TWgate.h +++ b/include/d/actor/d_a_tag_TWgate.h @@ -118,7 +118,6 @@ public: #endif static DUSK_GAME_DATA const actionFunc ActionTable[][2]; -private: /* 0x568 */ mDoExt_McaMorfSO* mpMorf; /* 0x56C */ request_of_phase_process_class mPhaseZevArc; /* 0x574 */ request_of_phase_process_class mPhaseMdRes; diff --git a/include/d/actor/d_a_tag_bottle_item.h b/include/d/actor/d_a_tag_bottle_item.h index cd122c8cad..3cc2a274d4 100644 --- a/include/d/actor/d_a_tag_bottle_item.h +++ b/include/d/actor/d_a_tag_bottle_item.h @@ -8,7 +8,7 @@ class daTag_BottleItem_c; typedef int (daTag_BottleItem_c::*ProcessFunc)(void*); class daTag_BottleItem_c : public fopAc_ac_c { -private: +public: /* 0x0568 */ ProcessFunc mProcessFunc; /* 0x056C */ u16 mEventType; /* 0x0576 */ u8 mBottleItemType; diff --git a/include/d/actor/d_a_tag_chkpoint.h b/include/d/actor/d_a_tag_chkpoint.h index 4871ec3946..51fa95e17d 100644 --- a/include/d/actor/d_a_tag_chkpoint.h +++ b/include/d/actor/d_a_tag_chkpoint.h @@ -45,7 +45,6 @@ public: return cPhs_COMPLEATE_e; } -private: /* 0x568 */ u8 field_0x568[8]; /* 0x570 */ cXyz mVtxA; /* 0x57C */ cXyz mVtxB; diff --git a/include/d/actor/d_a_tag_evtarea.h b/include/d/actor/d_a_tag_evtarea.h index 4bf0ec404e..f83e034aa1 100644 --- a/include/d/actor/d_a_tag_evtarea.h +++ b/include/d/actor/d_a_tag_evtarea.h @@ -45,7 +45,6 @@ public: void noEffect() { field_0x56c = 1; } -private: /* 0x568 vtable */ /* 0x56C */ u8 field_0x56c; }; diff --git a/include/d/actor/d_a_tag_lv6CstaSw.h b/include/d/actor/d_a_tag_lv6CstaSw.h index 17b58e4b28..384d9bd6d9 100644 --- a/include/d/actor/d_a_tag_lv6CstaSw.h +++ b/include/d/actor/d_a_tag_lv6CstaSw.h @@ -16,7 +16,6 @@ public: u32 getSw() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x568 */ u8 mSwitch; /* 0x569 */ u8 unused[0x570 - 0x569]; }; diff --git a/include/d/actor/d_a_tag_mhint.h b/include/d/actor/d_a_tag_mhint.h index e4c5260079..c573467ae0 100644 --- a/include/d/actor/d_a_tag_mhint.h +++ b/include/d/actor/d_a_tag_mhint.h @@ -26,7 +26,6 @@ public: NULL); } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_tag_mmsg.h b/include/d/actor/d_a_tag_mmsg.h index 9fdd0b3c66..bcafa0c37d 100644 --- a/include/d/actor/d_a_tag_mmsg.h +++ b/include/d/actor/d_a_tag_mmsg.h @@ -14,7 +14,6 @@ public: void onUseFlg() { mUseFlg = true; } bool checkNoAttention() const { return mAttention == 0xFF; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 field_0x569; /* 0x56A */ u8 mAttention; diff --git a/include/d/actor/d_a_tag_mstop.h b/include/d/actor/d_a_tag_mstop.h index dd27dbb005..774af17007 100644 --- a/include/d/actor/d_a_tag_mstop.h +++ b/include/d/actor/d_a_tag_mstop.h @@ -17,7 +17,6 @@ public: int execute(); bool checkNoAttention() const { return field_0x56b == 0xFF; } -private: /* 0x568 */ u8 field_0x568; /* 0x569 */ u8 mSwitch; /* 0x56A */ u8 field_0x56a; diff --git a/include/d/actor/d_a_tag_myna2.h b/include/d/actor/d_a_tag_myna2.h index 7eecb0c1d7..70605612e3 100644 --- a/include/d/actor/d_a_tag_myna2.h +++ b/include/d/actor/d_a_tag_myna2.h @@ -12,7 +12,6 @@ public: int getMode() { return fopAcM_GetParam(this) & 0xFF; } f32 getExtent() { return scale.x * 100.0f;} -private: /* 0x568 */ u32 mSwitchNo; /* 0x56C */ u32 mMode; /* 0x570 */ s16 mTimer; diff --git a/include/d/actor/d_a_tag_setBall.h b/include/d/actor/d_a_tag_setBall.h index 6e75928c6b..0619e2a677 100644 --- a/include/d/actor/d_a_tag_setBall.h +++ b/include/d/actor/d_a_tag_setBall.h @@ -16,7 +16,6 @@ public: s32 getType() { return mType; } -private: u8 getType_private() { return fopAcM_GetParamBit(this, 8, 4); } /* 0x568 */ u8 mType; diff --git a/include/d/actor/d_a_tag_statue_evt.h b/include/d/actor/d_a_tag_statue_evt.h index 1bdc0d4f52..59237c09eb 100644 --- a/include/d/actor/d_a_tag_statue_evt.h +++ b/include/d/actor/d_a_tag_statue_evt.h @@ -25,7 +25,6 @@ public: int draw(); int _delete(); -private: /* 0x568 */ request_of_phase_process_class mArcPhase; /* 0x570 */ request_of_phase_process_class mEvArcPhase; /* 0x578 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_tag_telop.h b/include/d/actor/d_a_tag_telop.h index 6e28231138..0d6fbeb7a1 100644 --- a/include/d/actor/d_a_tag_telop.h +++ b/include/d/actor/d_a_tag_telop.h @@ -13,7 +13,6 @@ public: u16 getMessageNo() { return home.angle.z; } -private: /* 0x568 */ u16 mMessageNo; /* 0x56C */ int mMessageStatus; }; diff --git a/include/d/actor/d_a_tag_waterfall.h b/include/d/actor/d_a_tag_waterfall.h index 80ffe7bec2..6076e53042 100644 --- a/include/d/actor/d_a_tag_waterfall.h +++ b/include/d/actor/d_a_tag_waterfall.h @@ -22,7 +22,6 @@ public: int _delete(); cPhs_Step create(); -private: /* 0x568 */ f32 mCylinderRadiusA; /* 0x56C */ f32 mCylinderRadiusB; /* 0x570 */ f32 mCylinderHeight; diff --git a/include/d/actor/d_a_tag_yami.h b/include/d/actor/d_a_tag_yami.h index 8410899186..fc17586688 100644 --- a/include/d/actor/d_a_tag_yami.h +++ b/include/d/actor/d_a_tag_yami.h @@ -36,7 +36,6 @@ public: void setCoR(f32 i_value) { mCoR = i_value; } void setCoH(f32 i_value) { mCoH = i_value; } -private: /* 0x568 */ dCcD_Cyl mCyl; /* 0x6A4 */ dCcD_Stts mStts; /* 0x6E0 */ u8 mCoHitValid; diff --git a/include/d/actor/d_a_talk.h b/include/d/actor/d_a_talk.h index 9c86f88610..b7715d88cd 100644 --- a/include/d/actor/d_a_talk.h +++ b/include/d/actor/d_a_talk.h @@ -22,7 +22,6 @@ public: u16 getStatus(); u32 messageSet(); -private: /* 0x568 */ dMsgFlow_c mMsgFlow; /* 0x5B4 */ u32 mMessageID; }; diff --git a/include/d/actor/d_a_tbox.h b/include/d/actor/d_a_tbox.h index 6d0528d29d..6b07594577 100644 --- a/include/d/actor/d_a_tbox.h +++ b/include/d/actor/d_a_tbox.h @@ -148,7 +148,6 @@ public: field_0x9fc = 1; } -private: /* 0x718 */ u8 field_0x718; /* 0x71C */ request_of_phase_process_class mPhase; /* 0x724 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_tbox2.h b/include/d/actor/d_a_tbox2.h index 9b06e685a3..29df2d8389 100644 --- a/include/d/actor/d_a_tbox2.h +++ b/include/d/actor/d_a_tbox2.h @@ -67,7 +67,6 @@ public: u8 getModelType() { return fopAcM_GetParamBit(this, 8, 4); } u8 getItemNo() { return fopAcM_GetParamBit(this, 0, 8); } -private: /* 0x718 */ u8 mReturnRupee; /* 0x71C */ request_of_phase_process_class mPhase; /* 0x724 */ J3DModel* mpModel; diff --git a/include/d/actor/d_a_title.h b/include/d/actor/d_a_title.h index 465fe689c1..691e2df3e3 100644 --- a/include/d/actor/d_a_title.h +++ b/include/d/actor/d_a_title.h @@ -50,7 +50,6 @@ public: void KeyWaitPosMove(); #endif -private: /* 0x568 */ request_of_phase_process_class mPhaseReq; /* 0x570 */ JKRHeap* mpHeap; /* 0x574 */ J3DModel* mpModel; diff --git a/include/d/d_a_shop_item_static.h b/include/d/d_a_shop_item_static.h index 7126578092..e79973fc65 100644 --- a/include/d/d_a_shop_item_static.h +++ b/include/d/d_a_shop_item_static.h @@ -107,7 +107,6 @@ public: SHOP_ITEMNO_MAX, }; -private: /* 0x92C */ Mtx mMtx; /* 0x95C */ int field_0x95c; /* 0x960 */ s16 mAngleX; diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 8e3b8be1f5..b1c269651f 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -18,7 +18,6 @@ public: fopAc_ac_c* getZHintTarget() { return convPId(field_0x8); } -private: /* 0x0 */ fpc_ProcID mHintActorID; /* 0x4 */ int mPriority; /* 0x8 */ fpc_ProcID field_0x8; @@ -34,7 +33,6 @@ public: fopAc_ac_c* getCatghTarget() { return convPId(mCatghTargetID); } u8 getChangeItem() { return mChangeItem; } -private: /* 0x00 */ fpc_ProcID mRequestActorID; /* 0x04 */ int field_0x4; /* 0x08 */ f32 mDistance; @@ -120,7 +118,6 @@ public: fopAc_ac_c* getLookTarget() { return convPId(mLookTargetID); } -private: fpc_ProcID mRequestActorID; int field_0x4; f32 mDistance; diff --git a/include/d/d_bg_plc.h b/include/d/d_bg_plc.h index da360fd0e4..f5361ff883 100644 --- a/include/d/d_bg_plc.h +++ b/include/d/d_bg_plc.h @@ -20,7 +20,6 @@ public: static const int ZELDA_CODE_SIZE = sizeof(sBgPc); -private: /* 0x00 */ sBgPlc* m_base; }; diff --git a/include/d/d_bg_s_acch.h b/include/d/d_bg_s_acch.h index 04a388c61b..a1a1517cc4 100644 --- a/include/d/d_bg_s_acch.h +++ b/include/d/d_bg_s_acch.h @@ -13,7 +13,7 @@ class fopAc_ac_c; class dBgS_AcchCir : public cBgS_PolyInfo { -private: +public: /* 0x10 */ u32 m_flags; /* 0x14 */ cM3dGCir m_cir; /* 0x28 */ f32 m_wall_rr; @@ -197,7 +197,6 @@ public: f32 GetCx() const { return pm_pos->x; } f32 GetCz() const { return pm_pos->z; } -private: /* 0x02C */ u32 m_flags; /* 0x030 */ cXyz* pm_pos; /* 0x034 */ cXyz* pm_old_pos; @@ -237,7 +236,6 @@ public: /* 0x0DC */ dBgS_GndChk m_gnd; /* 0x130 */ dBgS_RoofChk m_roof; /* 0x180 */ dBgS_WtrChk m_wtr; -private: /* 0x1D4 */ u8 m_wtr_mode; }; // Size: 0x1D8 diff --git a/include/d/d_bg_s_grp_pass_chk.h b/include/d/d_bg_s_grp_pass_chk.h index eea3414b98..6253f67f18 100644 --- a/include/d/d_bg_s_grp_pass_chk.h +++ b/include/d/d_bg_s_grp_pass_chk.h @@ -25,7 +25,6 @@ public: void OnAll() { mGrp |= FULL_GRP; } u32 MaskNormalGrp() { return mGrp & NORMAL_GRP; } u32 MaskWaterGrp() { return mGrp & WATER_GRP; } -private: /* 0x4 */ u32 mGrp; }; diff --git a/include/d/d_bg_s_poly_pass_chk.h b/include/d/d_bg_s_poly_pass_chk.h index 6f7778189a..759321c6da 100644 --- a/include/d/d_bg_s_poly_pass_chk.h +++ b/include/d/d_bg_s_poly_pass_chk.h @@ -42,7 +42,6 @@ public: void SetStatue(); void SetUnderwaterRoof(); -private: /* 0x4 */ bool mObject; /* 0x5 */ bool mCamera; /* 0x6 */ bool mLink; diff --git a/include/d/d_bg_s_roof_chk.h b/include/d/d_bg_s_roof_chk.h index 387c05fff2..e404eef0c4 100644 --- a/include/d/d_bg_s_roof_chk.h +++ b/include/d/d_bg_s_roof_chk.h @@ -17,7 +17,6 @@ public: f32 GetNowY() { return mNowY; } cXyz* GetPosP() { return &m_pos; } -private: /* 0x3C */ cXyz m_pos; /* 0x48 */ int field_0x48; /* 0x4C */ f32 mNowY; diff --git a/include/d/d_bg_s_spl_grp_chk.h b/include/d/d_bg_s_spl_grp_chk.h index 447bbf4d73..46df7df35a 100644 --- a/include/d/d_bg_s_spl_grp_chk.h +++ b/include/d/d_bg_s_spl_grp_chk.h @@ -30,7 +30,6 @@ public: cXyz& GetPosP() { return m_ground; } f32 GetRoof() { return m_roof; } -private: /* 0x3C */ cXyz m_ground; /* 0x48 */ f32 m_roof; /* 0x4C */ f32 m_height; diff --git a/include/d/d_bg_w.h b/include/d/d_bg_w.h index ae37d1c6d9..c9692a7c61 100644 --- a/include/d/d_bg_w.h +++ b/include/d/d_bg_w.h @@ -6,9 +6,12 @@ #include "d/d_bg_w_base.h" #include #include -#include "helpers/offset_ptr.h" + +#if TARGET_PC #include "helpers/endian.h" #include "helpers/endian_ssystem.h" +#include "helpers/offset_ptr.h" +#endif class cBgS_GrpPassChk; class cBgS_PolyPassChk; @@ -346,7 +349,6 @@ public: void SetArrowStickCallback(dBgW_ArrowStickCallback func) { m_arrow_stick_callback = func; } void OnMoveFlag() { m_flags |= (u8)1; } -private: /* 0xB0 */ dBgW_CrrFunc m_crr_func; /* 0xB4 */ dBgW_RideCallback m_ride_callback; /* 0xB8 */ dBgW_ArrowStickCallback m_arrow_stick_callback; diff --git a/include/d/d_bg_w_base.h b/include/d/d_bg_w_base.h index 6940df06fa..f30604d2d3 100644 --- a/include/d/d_bg_w_base.h +++ b/include/d/d_bg_w_base.h @@ -124,7 +124,6 @@ public: void OnPushPullOk() { m_pushPull_Ok = true; } void OffPushPullOk() { m_pushPull_Ok = false; } -private: /* 0x08 */ u8 m_priority; /* 0x09 */ u8 m_roomId; /* 0x0A */ u8 field_0xa; diff --git a/include/d/d_bg_w_kcol.h b/include/d/d_bg_w_kcol.h index 84b0da03f2..b0abe32102 100644 --- a/include/d/d_bg_w_kcol.h +++ b/include/d/d_bg_w_kcol.h @@ -6,7 +6,10 @@ #include "d/d_bg_plc.h" #include "d/d_bg_s_sph_chk.h" #include "d/d_bg_w_base.h" + +#if TARGET_PC #include "helpers/offset_ptr.h" +#endif class cBgS_GrpPassChk; class cBgS_PolyPassChk; @@ -117,7 +120,6 @@ public: void getTri1Pos(KC_PrismData* pd, Vec** nrm) const { *nrm = &m_pkc_head->m_pos_data[pd->pos_i]; } -private: /* 0x18 */ KC_Header* m_pkc_head; /* 0x1C */ dBgPlc m_code; /* 0x20 */ cM3dGAab m_bnd; diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index 40ffae33da..739abdcaa4 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -179,7 +179,6 @@ public: cXyz* GetHitPosP() { return &mHitPos; } void ClrHit() { dCcD_GAtTgCoCommonBase::ClrActorInfo(); } - // private: /* 0x1C */ u8 mSe; /* 0x1D */ u8 mMtrl; /* 0x1E */ u8 mHitMark; @@ -215,7 +214,6 @@ public: u8 GetSe() { return mSe; } void ClrHit() { dCcD_GAtTgCoCommonBase::ClrActorInfo(); } -private: /* 0x1C */ u8 mSe; /* 0x1D */ u8 mMtrl; /* 0x1E */ u8 mHitMark; @@ -258,7 +256,6 @@ public: void SetTgSpl(dCcG_Tg_Spl spl) { mTg = spl; } void OnNoActor() { field_0x1C |= 1; } - // private: /* 0x04 */ u8 mAt; /* 0x05 */ u8 mTg; /* 0x06 */ u8 mRoomId; diff --git a/include/d/d_cc_mass_s.h b/include/d/d_cc_mass_s.h index 672adb913a..291cb4552c 100644 --- a/include/d/d_cc_mass_s.h +++ b/include/d/d_cc_mass_s.h @@ -6,7 +6,7 @@ typedef void (*dCcMassS_ObjCallback)(fopAc_ac_c*, cXyz*, u32); class dCcMassS_Obj { -private: +public: /* 0x00 */ cCcD_Obj* mpObj; /* 0x04 */ u8 mPriority; /* 0x08 */ dCcMassS_ObjCallback mpAreaCheckFunc; @@ -28,7 +28,7 @@ public: STATIC_ASSERT(0x20 == sizeof(dCcMassS_Obj)); class dCcMassS_HitInf { -private: +public: /* 0x00 */ cCcD_Obj* mpArea; /* 0x04 */ cCcD_Obj* mpAtObj; /* 0x08 */ cCcD_Obj* mpCoObj; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 62b8744b51..dcf681162f 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -249,7 +249,6 @@ public: ~dComIfG_resLoader_c(); int load(char const**, JKRHeap*); -private: /* 0x0 */ const char** mResNameTable; /* 0x4 */ request_of_phase_process_class mPhase; /* 0xC */ u8 mLoadIndex; diff --git a/include/d/d_cursor_mng.h b/include/d/d_cursor_mng.h index 38ba03f214..9837e6f1cb 100644 --- a/include/d/d_cursor_mng.h +++ b/include/d/d_cursor_mng.h @@ -95,7 +95,7 @@ class dCsr_mng_c { BOOL set(mDoGph_gInf_c::csr_c* i_csr, u16, u8, u8); }; -private: +public: dCsr_mng_c() : is_csr_on(true) { } @@ -116,7 +116,6 @@ public: static dCsr_mng_c* m_myObj; -private: /* 0x00 */ list_c m_csr_list; /* 0x08 */ list_c m_obj_list; /* 0x10 */ bool is_csr_on; diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 8eef24d7e3..a35c44e0ed 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -155,7 +155,6 @@ public: f32 getAnmTransition() { return mAnmTransition; } u32 getShapeId() { return mShape; } -private: /* 0x04 */ u16 mFlags; /* 0x08 */ cXyz mTrans; /* 0x14 */ cXyz mScale; @@ -220,7 +219,6 @@ public: f32 getFovy() { return mProjFovy; } f32 getRoll() { return mViewRoll; } -private: /* 0x04 */ u8 mFlags; /* 0x08 */ f32 mProjNear; /* 0x0C */ f32 mProjFar; @@ -247,7 +245,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x05 */ GXColor mColor; }; @@ -275,7 +272,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x08 */ JStage::TELight mLightType; /* 0x0C */ GXDistAttnFn mDistAttenFn; @@ -309,7 +305,6 @@ public: void onEnable(u8 flag) { mFlags |= flag; } -private: /* 0x04 */ u8 mFlags; /* 0x05 */ s8 mFogType; /* 0x08 */ f32 mStartZ; @@ -327,7 +322,6 @@ public: void setObject(dDemo_object_c* i_object) { mpObject = i_object; } -private: /* 0x4 */ dDemo_object_c* mpObject; }; diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 25d92aff54..4baf6ed324 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -5,10 +5,13 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "helpers/gx_helper.h" #include "f_op/f_op_view.h" -#include "global.h" #include "m_Do/m_Do_ext.h" +#include "global.h" + +#if TARGET_PC +#include "helpers/gx_helper.h" +#endif class J3DDrawBuffer; class J3DModel; @@ -107,7 +110,6 @@ public: mRnd.init(r0, r1, r2); } -private: /* 0x04 */ cM_rnd_c mRnd; /* 0x10 */ cXyz field_0x10; /* 0x1C */ GXColor mLineColor; @@ -129,7 +131,6 @@ public: void setAlpha(u8 alpha) { mAlpha = alpha; } J2DPicture* getPicture() { return &mpPicture; } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ J2DPicture mpPicture; /* 0x158 */ s16 mPosX; @@ -271,7 +272,6 @@ public: void setZsortNext(dDlst_shadowReal_c* next) { mZsortNext = next; } void setZsortPre(dDlst_shadowReal_c* pre) { mZsortPre = pre; } -private: /* 0x0000 */ u8 mState; /* 0x0001 */ u8 field_0x1; /* 0x0002 */ u8 mModelNum; @@ -303,7 +303,6 @@ public: static DUSK_GAME_DATA TGXTexObj mSimpleTexObj; -private: /* 0x00000 */ u8 field_0x0; /* 0x00001 */ u8 mRealNum; /* 0x00002 */ u8 mSimpleNum; @@ -332,7 +331,6 @@ public: view_port_class* getViewPort() { return &mViewport; } scissor_class* getScissor() { return &mViewport.scissor; } -private: /* 0x00 */ view_port_class mViewport; /* 0x28 */ s8 mCameraID; /* 0x29 */ u8 mMode; @@ -443,7 +441,7 @@ public: } #if TARGET_PC - void refresh3DlineMats(const cXyz& eye); + void refresh3DlineMats(); #endif void peekZdata() { mPeekZ.peekData(); } @@ -518,7 +516,6 @@ public: static DUSK_GAME_DATA f32 mWipeSpeed; static DUSK_GAME_DATA u8 mWipe; -private: /* 0x00000 */ J3DDrawBuffer* mDrawBuffers[DB_LIST_MAX]; /* 0x00054 */ dDlst_base_c* mpCopy2DDrawLists[4]; /* 0x00064 */ dDlst_base_c** mpCopy2DStart; diff --git a/include/d/d_event_data.h b/include/d/d_event_data.h index eef55b1164..786088250f 100644 --- a/include/d/d_event_data.h +++ b/include/d/d_event_data.h @@ -3,7 +3,10 @@ #include "global.h" #include "f_pc/f_pc_base.h" + +#if TARGET_PC #include "helpers/endian.h" +#endif struct msg_class; @@ -190,7 +193,6 @@ public: int getCurrentCut() { return mCurrentCut; } int getStartCut() { return mStartCut; } - // private: /* 0x00 */ char mName[8]; /* 0x08 */ u8 mWork[0x18]; // PROBLEM: this buffer is now too small for StaffWork to fit in /* 0x20 */ BE(s32) mTagID; @@ -293,7 +295,6 @@ public: static const int FlagMax = 0x2800; -private: u32 mFlags[320]; }; // Size = 0x500 @@ -346,7 +347,6 @@ public: void setIDataP(int* p_idata) { mIDataP = p_idata; } void setSDataP(char* p_sdata) { mSDataP = p_sdata; } - // private: /* 0x00 */ event_binary_data_header* mHeaderP; /* 0x04 */ dEvDtEvent_c* mEventP; /* 0x08 */ dEvDtStaff_c* mStaffP; diff --git a/include/d/d_event_manager.h b/include/d/d_event_manager.h index de046797ff..75aa5a4a03 100644 --- a/include/d/d_event_manager.h +++ b/include/d/d_event_manager.h @@ -112,7 +112,6 @@ public: dEvM_HIO_c& getEventHIO(); #endif -private: /* 0x000 */ dEvDtBase_c mEventList[BASE_MAX]; /* 0x18C */ int mCameraPlay; /* 0x190 */ dEvent_exception_c mException; diff --git a/include/d/d_file_sel_info.h b/include/d/d_file_sel_info.h index 37dadbeb1b..89c4272b22 100644 --- a/include/d/d_file_sel_info.h +++ b/include/d/d_file_sel_info.h @@ -37,7 +37,6 @@ public: CPaneMgrAlpha* getNoDatBase() { return mNoDatBase; } void draw() { _draw(); } -// private: /* 0x04 */ JKRArchive* mArchive; /* 0x08 */ dDlst_FileInfo_c mFileInfo; /* 0x1C */ u8 field_0x1c[4]; diff --git a/include/d/d_file_select.h b/include/d/d_file_select.h index 48d81d9ad5..dd4d5a3aae 100644 --- a/include/d/d_file_select.h +++ b/include/d/d_file_select.h @@ -706,26 +706,23 @@ public: /* 0x2374 */ u8 mFadeFlag; /* 0x2375 */ bool mHasDrawn; - #if PLATFORM_GCN +#if PLATFORM_GCN /* 0x2378 */ J2DPicture* mpFadePict; - #endif -#ifdef TARGET_PC +#endif + +#if PLATFORM_WII || PLATFORM_SHIELD + /* 0x2376 */ u8 field_0x2376[SAVEFILE_SIZE]; + /* 0x4332 */ u8 field_0x4332; + /* 0x4333 */ u8 field_0x4333; +#endif + +#if TARGET_PC dDlst_FileSelFade_c mFadeDlst; bool mGameModeSaveStartBuildUi = true; GameModeNewSaveState mGameModeNewSaveState = GAME_MODE_STATE_PENDING; #endif - - #if PLATFORM_WII || PLATFORM_SHIELD - /* 0x2376 */ u8 field_0x2376[SAVEFILE_SIZE]; - /* 0x4332 */ u8 field_0x4332; - /* 0x4333 */ u8 field_0x4333; - #endif }; -#ifdef TARGET_PC -STATIC_ASSERT(sizeof(dFile_select_c) == 0x237C + sizeof(dDlst_FileSelFade_c)); -#else STATIC_ASSERT(sizeof(dFile_select_c) == 0x237C); -#endif #endif /* D_FILE_D_FILE_SELECT_H */ diff --git a/include/d/d_kantera_icon_meter.h b/include/d/d_kantera_icon_meter.h index 67e2dff278..cf1464e82f 100644 --- a/include/d/d_kantera_icon_meter.h +++ b/include/d/d_kantera_icon_meter.h @@ -13,7 +13,6 @@ public: void setScreen(J2DScreen* screen) { mp_scrn = screen; } J2DScreen* getScreen() { return mp_scrn; } -private: /* 0x04 */ J2DScreen* mp_scrn; }; @@ -30,7 +29,6 @@ public: void drawSelf() { mpKanteraIcon->draw(); } -// private: /* 0x04 */ dDlst_KanteraIcon_c* mpKanteraIcon; /* 0x08 */ CPaneMgr* mpParent; /* 0x0C */ CPaneMgr* mpGauge; diff --git a/include/d/d_ky_thunder.h b/include/d/d_ky_thunder.h index 1e174ad6f8..5a72252a9a 100644 --- a/include/d/d_ky_thunder.h +++ b/include/d/d_ky_thunder.h @@ -25,7 +25,6 @@ public: ~dThunder_c() { mDoExt_destroySolidHeap(mpHeap); } -private: /* 0x0F8 */ JKRSolidHeap* mpHeap; /* 0x0FC */ dThunder_modelInfo_c mModelInfo; /* 0x138 */ cXyz field_0x138; diff --git a/include/d/d_map.h b/include/d/d_map.h index b42def27c7..b70238cc46 100644 --- a/include/d/d_map.h +++ b/include/d/d_map.h @@ -134,7 +134,6 @@ public: static const int PALETTE_NUMBER = 50; #endif -private: /* 0x34 */ s32 m_outSideBlackLineCnt; /* 0x38 */ s32 field_0x38; /* 0x3C */ s32 field_0x3c; @@ -199,7 +198,6 @@ public: static dMap_c* m_mySelfPointer; -private: /* 0x40 */ dMap_prm_res_s* m_res_src; /* 0x44 */ dMap_prm_res_s* m_res; /* 0x48 */ ResTIMG* mResTIMG; diff --git a/include/d/d_menu_collect.h b/include/d/d_menu_collect.h index 0811fb00a6..d2a4028b2e 100644 --- a/include/d/d_menu_collect.h +++ b/include/d/d_menu_collect.h @@ -129,7 +129,6 @@ public: J2DPicture* getBlackTex() { return mpBlackTex; } u8 getSubWindowOpenCheck() { return mSubWindowOpenCheck; } -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRExpHeap* mpSubHeap; /* 0x00C */ void* field_0xc; @@ -225,7 +224,6 @@ public: static DUSK_GAME_DATA f32 mViewOffsetY; -private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRSolidHeap* mpSolidHeap; /* 0x00C */ dMenu_Collect2D_c* mpCollect2D; @@ -260,7 +258,6 @@ public: bool isKeyCheck() { return mpCollect2D->isKeyCheck(); } bool isOutCheck() { return mpCollect2D->isOutCheck(); } -private: /* 0x4 */ dMenu_Collect2D_c* mpCollect2D; /* 0x8 */ dMenu_Collect3D_c* mpCollect3D; }; diff --git a/include/d/d_menu_dmap.h b/include/d/d_menu_dmap.h index 4d1341cc67..039b42aab2 100644 --- a/include/d/d_menu_dmap.h +++ b/include/d/d_menu_dmap.h @@ -255,7 +255,6 @@ public: static DUSK_GAME_DATA dMenu_Dmap_c* myclass; -private: /* 0x004 */ dMenu_DmapMapCtrl_c* mMapCtrl; /* 0x008 */ dMenu_DmapBg_c* mpDrawBg; /* 0x00C */ u8 field_0xc[0x10 - 0xC]; diff --git a/include/d/d_menu_fishing.h b/include/d/d_menu_fishing.h index f2e9419ce3..b3b451c968 100644 --- a/include/d/d_menu_fishing.h +++ b/include/d/d_menu_fishing.h @@ -43,7 +43,6 @@ public: u8 getStatus() { return mStatus; } -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_fmap.h b/include/d/d_menu_fmap.h index 2e5ee95772..3104d7e76b 100644 --- a/include/d/d_menu_fmap.h +++ b/include/d/d_menu_fmap.h @@ -270,7 +270,6 @@ public: static DUSK_GAME_DATA dMenu_Fmap_c* MyClass; -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRExpHeap* mpTalkHeap; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_insect.h b/include/d/d_menu_insect.h index 5e0b453949..43f4af0602 100644 --- a/include/d/d_menu_insect.h +++ b/include/d/d_menu_insect.h @@ -60,7 +60,6 @@ public: u8 getStatus() { return mStatus; } -// private: /* 0x04 */ JKRExpHeap* mpHeap; /* 0x08 */ JKRArchive* mpArchive; /* 0x0C */ STControl* mpStick; diff --git a/include/d/d_menu_item_explain.h b/include/d/d_menu_item_explain.h index 7b79ebbad5..59d212e53f 100644 --- a/include/d/d_menu_item_explain.h +++ b/include/d/d_menu_item_explain.h @@ -51,7 +51,6 @@ public: field_0xd8 = y; } -private: /* 0x04 */ JKRExpHeap* mpHeap; /* 0x08 */ JKRArchive* mpArchive; /* 0x0C */ dMsgString_c* mpInfoString; diff --git a/include/d/d_menu_letter.h b/include/d/d_menu_letter.h index 21747c7e78..8e112f04d2 100644 --- a/include/d/d_menu_letter.h +++ b/include/d/d_menu_letter.h @@ -64,7 +64,6 @@ public: u8 getStatus() { return mStatus; } -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_option.h b/include/d/d_menu_option.h index f158498dd7..ff4b84f5e3 100644 --- a/include/d/d_menu_option.h +++ b/include/d/d_menu_option.h @@ -117,7 +117,6 @@ public: return ((u8)mUseFlag & (u8)i_flag) != 0 ? true : false; } -// private: /* 0x004 */ J2DScreen* mpBackScreen; /* 0x008 */ J2DScreen* mpScreen; /* 0x00C */ J2DScreen* mpClipScreen; diff --git a/include/d/d_menu_ring.h b/include/d/d_menu_ring.h index d0f021339e..fa4f97496f 100644 --- a/include/d/d_menu_ring.h +++ b/include/d/d_menu_ring.h @@ -84,7 +84,6 @@ public: void drawFlag0() { mDrawFlag = 0; } void setStatus(u8 i_status) { mStatus = i_status; } -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ STControl* mpStick; /* 0x00C */ CSTControl* mpCStick; diff --git a/include/d/d_menu_save.h b/include/d/d_menu_save.h index 7e94d1d1c9..a237bbb849 100644 --- a/include/d/d_menu_save.h +++ b/include/d/d_menu_save.h @@ -27,7 +27,6 @@ public: void setScrnExplain(dMsgScrnExplain_c* p_scrn) { mpScrn = p_scrn; } -private: /* 0x4 */ dMsgScrnExplain_c* mpScrn; }; @@ -278,7 +277,6 @@ public: u8 getEndStatus() { return mEndStatus; } void setUseType(u8 type) { mUseType = type; } -// private: /* 0x0004 */ JKRArchive* mpArchive; /* 0x0008 */ mDoDvdThd_mountArchive_c* mpMount; /* 0x000C */ STControl* stick; diff --git a/include/d/d_menu_skill.h b/include/d/d_menu_skill.h index d21332c341..2c2dc445d1 100644 --- a/include/d/d_menu_skill.h +++ b/include/d/d_menu_skill.h @@ -58,7 +58,6 @@ public: u8 getStatus() { return mStatus; } -// private: /* 0x004 */ JKRExpHeap* mpHeap; /* 0x008 */ JKRArchive* mpArchive; /* 0x00C */ STControl* mpStick; diff --git a/include/d/d_menu_window.h b/include/d/d_menu_window.h index 65e415077d..1c5aeadbe5 100644 --- a/include/d/d_menu_window.h +++ b/include/d/d_menu_window.h @@ -193,7 +193,6 @@ public: bool isShowFlag() { return (mShowFlag & 1) != 0; } bool isFadeNowCheck() { return mDoGph_gInf_c::getFader()->getStatus() == 1; } -private: /* 0x0FC */ int field_0xfc; /* 0x100 */ JKRExpHeap* mpHeap; /* 0x104 */ STControl* mpStick; diff --git a/include/d/d_meter2.h b/include/d/d_meter2.h index c8dc17bca8..4246d9249d 100644 --- a/include/d/d_meter2.h +++ b/include/d/d_meter2.h @@ -100,7 +100,6 @@ public: bool isShowFlag(int i_no) { return field_0x1e6 & (1 << i_no); } void onShowFlag(int i_no) { field_0x1e6 |= (1 << i_no); } -private: /* 0x0FC */ int field_0xfc; /* 0x100 */ JKRExpHeap* mpHeap; /* 0x104 */ JKRExpHeap* mpSubHeap; diff --git a/include/d/d_meter2_draw.h b/include/d/d_meter2_draw.h index aaad9dec70..c9dc8217e9 100644 --- a/include/d/d_meter2_draw.h +++ b/include/d/d_meter2_draw.h @@ -154,7 +154,6 @@ public: } #endif -// private: /* 0x004 */ item_params mItemParams[4]; /* 0x074 */ JKRExpHeap* heap; /* 0x078 */ J2DScreen* mpScreen; diff --git a/include/d/d_meter_map.h b/include/d/d_meter_map.h index b17f51846e..648fb5aef5 100644 --- a/include/d/d_meter_map.h +++ b/include/d/d_meter_map.h @@ -102,7 +102,6 @@ public: /* 0x04 */ u8 field_0x4_debug; /* 0x08 */ int field_0x8_debug; #endif -private: /* 0x04 */ J2DPicture* mMapJ2DPicture; /* 0x08 */ dMap_c* mMap; /* 0x0C */ s32 mIsCompass; diff --git a/include/d/d_model.h b/include/d/d_model.h index 72949f5f03..466592d89c 100644 --- a/include/d/d_model.h +++ b/include/d/d_model.h @@ -33,7 +33,6 @@ public: u16 getMaterialId() { return mMaterialId; } dKy_tevstr_c* getTevstr() { return mpTevstr; } -private: /* 0x10 */ J3DModelData* mpModelData; /* 0x14 */ dKy_tevstr_c* mpTevstr; /* 0x18 */ u16 mMaterialId; @@ -55,7 +54,6 @@ public: static DUSK_GAME_DATA dMdl_mng_c* m_myObj; -private: /* 0x00 */ dMdl_c field_0x0[4]; /* 0x80 */ u8 field_0x80; }; diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index c70345ca92..49a99a6ef1 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -4,10 +4,11 @@ #include "JSystem/JMessage/control.h" #include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" + +#if TARGET_PC #include "helpers/endian.h" #include "helpers/string.hpp" -#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 diff --git a/include/d/d_msg_flow.h b/include/d/d_msg_flow.h index cff5857cb7..b7ffb11fc7 100644 --- a/include/d/d_msg_flow.h +++ b/include/d/d_msg_flow.h @@ -2,7 +2,10 @@ #define D_MSG_D_MSG_FLOW_H #include + +#if TARGET_PC #include "helpers/endian.h" +#endif enum { NODETYPE_MESSAGE_e = 1, @@ -188,7 +191,6 @@ public: static DUSK_GAME_DATA queryFunc mQueryList[53]; static DUSK_GAME_DATA eventFunc mEventList[43]; -private: /* 0x04 */ u8* mFlow_p; /* 0x08 */ u8* mLabelInfo_p; /* 0x0C */ union mesg_flow { diff --git a/include/d/d_msg_out_font.h b/include/d/d_msg_out_font.h index c6715757eb..3bd41ca825 100644 --- a/include/d/d_msg_out_font.h +++ b/include/d/d_msg_out_font.h @@ -25,7 +25,6 @@ public: void setTextBoxPtr(J2DTextBox* p_textBox) { mpTextBoxPtr = p_textBox; } void resetType() { mType = 0x47; } -// private: /* 0x04 */ J2DTextBox* mpTextBoxPtr; /* 0x08 */ f32 mPosX; /* 0x0C */ f32 mPosY; @@ -53,7 +52,6 @@ public: void setRupeeColor(u8 color) { mRupeeColor = color; } -// private: /* 0x004 */ COutFontSet_c* mpOfs[35]; /* 0x090 */ J2DPicture* mpPane[70]; /* 0x1A8 */ f32 mAlphaRatio; diff --git a/include/d/d_msg_scrn_3select.h b/include/d/d_msg_scrn_3select.h index 1cb92e5be6..35c831d3c5 100644 --- a/include/d/d_msg_scrn_3select.h +++ b/include/d/d_msg_scrn_3select.h @@ -60,7 +60,6 @@ public: void offAnimeUpdate(int param_0) { field_0x114 &= ~(u8)(1 << param_0); } u8 getDPDPoint() { return mDPDPoint; } -private: /* 0x004 */ J2DScreen* mpScreen; /* 0x008 */ J2DAnmTransform* mpAnmBck; /* 0x00C */ J2DAnmColorKey* mpAnmBpk; diff --git a/include/d/d_msg_scrn_boss.h b/include/d/d_msg_scrn_boss.h index d72c992b39..3adcc57289 100644 --- a/include/d/d_msg_scrn_boss.h +++ b/include/d/d_msg_scrn_boss.h @@ -15,7 +15,6 @@ public: virtual void fontAlpha(f32); virtual void fukiAlpha(f32); -private: /* 0xC4 */ CPaneMgr* mpBaseParent; /* 0xC8 */ CPaneMgr* mpFontParent; }; diff --git a/include/d/d_msg_scrn_explain.h b/include/d/d_msg_scrn_explain.h index 20931ec9ac..1b638f9b83 100644 --- a/include/d/d_msg_scrn_explain.h +++ b/include/d/d_msg_scrn_explain.h @@ -49,7 +49,6 @@ public: void onForceSelect() { mForceSelect = 1; } void setKeyWaitTimer(s16 timer) { mKeyWaitTimer = timer; } -private: /* 0x04 */ dMsgString_c* mpString_c; /* 0x08 */ CPaneMgr* mpTm_c[2]; /* 0x10 */ CPaneMgr* mpTmr_c[2]; diff --git a/include/d/d_msg_string.h b/include/d/d_msg_string.h index 45a148b401..2d92939141 100644 --- a/include/d/d_msg_string.h +++ b/include/d/d_msg_string.h @@ -39,7 +39,6 @@ public: drawOutFontLocal(param_0, param_1); } -private: /* 0x24 */ COutFont_c* mpOutFont; /* 0x28 */ u8 field_0x28; }; diff --git a/include/d/d_msg_string_base.h b/include/d/d_msg_string_base.h index 4624393f06..020c557f85 100644 --- a/include/d/d_msg_string_base.h +++ b/include/d/d_msg_string_base.h @@ -30,7 +30,6 @@ public: virtual void drawOutFontLocal(J2DTextBox*, f32); virtual void drawFontLocal(J2DTextBox*, u8, f32, f32, f32, f32, u32, u8); -private: /* 0x04 */ JMessage::TResourceContainer* mpResCont; /* 0x08 */ jmessage_string_tControl* mpCtrl; /* 0x0C */ jmessage_string_tReference* mpRefer; diff --git a/include/d/d_name.h b/include/d/d_name.h index ddd99127c6..de084defb3 100644 --- a/include/d/d_name.h +++ b/include/d/d_name.h @@ -130,7 +130,6 @@ public: void setNextNameStr(char* i_name) { SAFE_STRCPY(mNextNameStr,i_name); } void draw() { _draw(); } -private: /* 0x004 */ STControl* stick; /* 0x008 */ JKRArchive* archive; /* 0x00C */ dDlst_NameIN_c nameIn; diff --git a/include/d/d_pane_class.h b/include/d/d_pane_class.h index 345cae1274..ffc067e411 100644 --- a/include/d/d_pane_class.h +++ b/include/d/d_pane_class.h @@ -93,7 +93,6 @@ public: JUtility::TColor getInitBlack() { return mInitBlack; } JUtility::TColor getInitWhite() { return mInitWhite; } -private: /* 0x1C */ void* mpFirstStackSize; /* 0x20 */ s16* field_0x20; /* 0x24 */ JGeometry::TVec2 mInitPos; diff --git a/include/d/d_pane_class_alpha.h b/include/d/d_pane_class_alpha.h index 82590e5f02..cf38229b97 100644 --- a/include/d/d_pane_class_alpha.h +++ b/include/d/d_pane_class_alpha.h @@ -54,7 +54,6 @@ public: virtual ~CPaneMgrAlphaMorf(); -private: /* 0x1C */ void* mpFirstSaveAlpha; /* 0x20 */ u8* field_0x20; /* 0x24 */ void* mpFirstGetAlpha; diff --git a/include/d/d_particle.h b/include/d/d_particle.h index 7ae4d12c07..a5849288f3 100644 --- a/include/d/d_particle.h +++ b/include/d/d_particle.h @@ -261,7 +261,6 @@ public: void setRate(f32 rate) { mRate = rate; } void setMaxCnt(int i_maxCnt) { mMaxCnt = i_maxCnt; } -private: /* 0x04 */ f32 mRate; /* 0x08 */ int mMaxCnt; /* 0x0C */ cXyz const* field_0xc; @@ -313,7 +312,6 @@ public: u16 getNameId() { return mNameId; } dPa_levelEcallBack* getCallback() { return mCallback; } - private: /* 0x00 */ u32 mId; /* 0x04 */ u16 mNameId; /* 0x06 */ u8 mStatus; @@ -510,7 +508,6 @@ public: static DUSK_GAME_DATA dPa_particleTracePcallBack_c mParticleTracePCB; static DUSK_GAME_DATA u8 mStatus; -private: /* 0x000 */ JKRSolidHeap* mHeap; /* 0x004 */ JPAResourceManager* mCommonResMng; /* 0x008 */ JKRExpHeap* m_resHeap; diff --git a/include/d/d_resorce.h b/include/d/d_resorce.h index b70d2d5452..3330ff5b3d 100644 --- a/include/d/d_resorce.h +++ b/include/d/d_resorce.h @@ -51,7 +51,6 @@ public: static const int NAME_MAX = 9; #endif -private: /* 0x00 */ char mArchiveName[11]; /* 0x0C */ u16 mCount; /* 0x10 */ mDoDvdThd_mountArchive_c* mDMCommand; diff --git a/include/d/d_s_name.h b/include/d/d_s_name.h index 72a44c02de..c32b4b903c 100644 --- a/include/d/d_s_name.h +++ b/include/d/d_s_name.h @@ -56,7 +56,6 @@ public: void tex_data_set(); #endif -private: #if VERSION == VERSION_GCN_PAL u8 field_0x1c4_pal[0x28]; #endif diff --git a/include/d/d_save.h b/include/d/d_save.h index 06458890e4..ec10360034 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -8,7 +8,10 @@ #include "d/d_item_data.h" #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JHostIO/JORReflexible.h" + +#if TARGET_PC #include "helpers/endian.h" +#endif static const int DEFAULT_SELECT_ITEM_INDEX = 0; static const int MAX_SELECT_ITEM = 4; @@ -594,7 +597,6 @@ public: dSv_player_info_c& getPlayerInfo() { return mPlayerInfo; } dSv_player_config_c& getConfig() { return mConfig; } -private: /* 0x000 */ dSv_player_status_a_c mPlayerStatusA; /* 0x028 */ dSv_player_status_b_c mPlayerStatusB; /* 0x040 */ dSv_horse_place_c mHorsePlace; @@ -892,7 +894,6 @@ public: class dSv_reserve_c { public: -private: u8 unk[80]; }; diff --git a/include/d/d_save_HIO.h b/include/d/d_save_HIO.h index 2ee6e4570b..f7d4770e08 100644 --- a/include/d/d_save_HIO.h +++ b/include/d/d_save_HIO.h @@ -10,7 +10,6 @@ public: virtual ~dSvBit_childTransformHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 WF[4]; /* 0x09 */ u8 field_0x9[4]; @@ -23,7 +22,6 @@ public: virtual ~dSvBit_childDarknessHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 TW[6]; /* 0x0B */ u8 field_0xB[6]; @@ -36,7 +34,6 @@ public: virtual ~dSvBit_childOtherHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 mDropNum; /* 0x06 */ u8 field_0x6; @@ -51,7 +48,6 @@ public: virtual ~dSvBit_childTbPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x40]; /* 0x45 */ u8 field_0x45[0x40]; @@ -64,7 +60,6 @@ public: mPerfectSave.init(); } -private: /* 0x04 */ u8 field_0x4; /* 0x08 */ dSvBit_childTbPerfectionHIO_c mPerfectSave; }; @@ -76,7 +71,6 @@ public: virtual ~dSvBit_childSwZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ bool field_0x5[0x20]; /* 0x25 */ bool field_0x25[0x20]; @@ -89,7 +83,6 @@ public: virtual ~dSvBit_childSwPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x80]; /* 0x85 */ u8 field_0x85[0x80]; @@ -102,7 +95,6 @@ public: virtual ~dSvBit_childSwOneZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ bool field_0x5[0x10]; /* 0x15 */ bool field_0x15[0x10]; @@ -115,7 +107,6 @@ public: virtual ~dSvBit_childSwDungeonHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x40]; /* 0x45 */ u8 field_0x45[0x40]; @@ -131,7 +122,6 @@ public: field_0x1e0.init(); } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ dSvBit_childSwPerfectionHIO_c field_0x8; /* 0x110 */ dSvBit_childSwDungeonHIO_c field_0x110; @@ -146,7 +136,6 @@ public: virtual ~dSvBit_childItZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x20]; /* 0x25 */ u8 field_0x25[0x20]; @@ -159,7 +148,6 @@ public: virtual ~dSvBit_childItPerfectionHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x20]; /* 0x25 */ u8 field_0x25[0x20]; @@ -172,7 +160,6 @@ public: virtual ~dSvBit_childItOneZoneHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x10]; /* 0x15 */ u8 field_0x15[0x10]; @@ -185,7 +172,6 @@ public: virtual ~dSvBit_childItDungeonHIO_c() {} -private: /* 0x04 */ u8 field_0x4; /* 0x05 */ u8 field_0x5[0x80]; /* 0x85 */ u8 field_0x85[0x80]; @@ -201,7 +187,6 @@ public: mOneZoneSave.init(); } -private: /* 0x004 */ u8 field_0x4; /* 0x008 */ dSvBit_childItPerfectionHIO_c mFullSave; /* 0x050 */ dSvBit_childItDungeonHIO_c mDungeonSave; diff --git a/include/d/d_select_cursor.h b/include/d/d_select_cursor.h index e98db19731..766463b5b3 100644 --- a/include/d/d_select_cursor.h +++ b/include/d/d_select_cursor.h @@ -66,7 +66,6 @@ public: void onPlayAllAnime() { field_0xb4 = 0xff; } void offPlayAllAnime() { field_0xb4 = 0; } -private: /* 0x04 */ J2DScreen* mpScreen; /* 0x08 */ J2DPane* mpPane; /* 0x0C */ dSelect_icon_c* mpSelectIcon; diff --git a/include/d/d_shop_item_ctrl.h b/include/d/d_shop_item_ctrl.h index 9016be18ea..61ed325241 100644 --- a/include/d/d_shop_item_ctrl.h +++ b/include/d/d_shop_item_ctrl.h @@ -18,7 +18,6 @@ public: void setMessageIndex(int i, u16 messageIndex) { mMessageIndex[i] = messageIndex; } u16 getMessageIndex(int i) { return mMessageIndex[i]; } -private: /* 0x04 */ u32 mItemIndex[7]; /* 0x20 */ u16 mMessageIndex[7]; }; diff --git a/include/d/d_simple_model.h b/include/d/d_simple_model.h index 25b9e6e2d1..e87462c318 100644 --- a/include/d/d_simple_model.h +++ b/include/d/d_simple_model.h @@ -36,7 +36,6 @@ public: void setIdx(u8 idx) { this->idx = idx; } #endif -private: /* 0x00 */ JKRSolidHeap* mpHeap; /* 0x04 */ J3DModel* mpModel; /* 0x08 */ int mCreateNum; @@ -59,7 +58,6 @@ public: virtual ~dSmplMdl_draw_c(); -private: /* 0x04 */ diff_model_c mModel[8]; /* 0xA4 */ int mListCount; /* 0xA8 */ modelList_c mList[500]; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 487488d7c6..fb8fd3124b 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -4,10 +4,14 @@ #include "SSystem/SComponent/c_lib.h" #include "d/d_kankyo.h" #include "d/d_kankyo_data.h" -#include "helpers/offset_ptr.h" #include "f_op/f_op_actor_mng.h" #include "global.h" + +#if TARGET_PC +#include "helpers/offset_ptr.h" + #include "os_report.h" +#endif enum StageType { /* 0x0 */ ST_FIELD, @@ -547,7 +551,6 @@ public: /* vt[91] */ virtual void setElst(dStage_Elst_c*) = 0; /* vt[92] */ virtual dStage_Elst_c* getElst(void) = 0; -private: /* 0x04 */ s8 mRoomNo; }; @@ -1261,7 +1264,6 @@ public: static u8 mNoArcBank; #endif -private: /* 0x0 */ u8 field_0x0[4]; }; @@ -1276,7 +1278,6 @@ public: s8 getDarkArea() const { return mDarkArea; } void setDarkArea(s8 darkArea) { mDarkArea = darkArea; } -private: /* 0x0 */ char mName[8]; /* 0x8 */ s16 mPoint; /* 0xA */ s8 mRoomNo; @@ -1291,12 +1292,12 @@ public: } void set(const char*, s8, s16, s8, s8, u8); void offEnable() { enabled = 0; } + void onEnable() { enabled = 1; } BOOL isEnable() const { return enabled; } s8 getWipe() const { return wipe; } u8 getWipeSpeed() const { return wipe_speed; } dStage_startStage_c* getStartStage() { return this; } -private: s8 enabled; s8 wipe; u8 wipe_speed; diff --git a/include/d/d_timer.h b/include/d/d_timer.h index 104a4cae9e..de145650ac 100644 --- a/include/d/d_timer.h +++ b/include/d/d_timer.h @@ -77,7 +77,6 @@ public: mTimerTransY = y; } -private: /* 0x004 */ J2DScreen* mpScreen; /* 0x008 */ J2DScreen* mpGetInScreen; /* 0x00C */ J2DAnmTransform* mpGetInBck; @@ -145,7 +144,6 @@ public: u8 isReadyFlag() { return m_is_ready; } -private: /* 0x0FC */ dDlst_TimerScrnDraw_c* mp_tm_scrn; /* 0x100 */ JKRExpHeap* mp_heap; /* 0x104 */ u8 field_0x104[4]; diff --git a/include/d/d_tresure.h b/include/d/d_tresure.h index e043dd94fb..4335a6a215 100644 --- a/include/d/d_tresure.h +++ b/include/d/d_tresure.h @@ -2,7 +2,10 @@ #define D_D_TRESURE_H #include + +#if TARGET_PC #include "helpers/offset_ptr.h" +#endif class dTres_c { public: diff --git a/include/d/d_vibration.h b/include/d/d_vibration.h index b61d0099b4..6e886a314b 100644 --- a/include/d/d_vibration.h +++ b/include/d/d_vibration.h @@ -94,7 +94,6 @@ public: 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 diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 7aa3bf2156..29dfac1389 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -12,9 +12,10 @@ #include "f_pc/f_pc_manager.h" #include "m_Do/m_Do_hostIO.h" #include "SSystem/SComponent/c_phase.h" + +#if TARGET_PC #include "helpers/endian_ssystem.h" -#if !__MWERKS__ // mwerks compiler makes value initialization act like default initialization so we need // to be explicit about default initialization in modern compilers #define fopAcM_ct_placement(ptr, ClassName) JKR_NEW_ARGS (ptr) ClassName @@ -23,13 +24,10 @@ #endif #define fopAcM_ct(ptr, ClassName) \ - if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "UH OH"); } \ if (!fopAcM_CheckCondition(ptr, fopAcCnd_INIT_e)) { \ fopAcM_ct_placement(ptr, ClassName); \ fopAcM_OnCondition(ptr, fopAcCnd_INIT_e); \ - } \ - if ((ptr)->layer_tag.layer == NULL) { OSPanic(__FILE__, __LINE__, "Oh come on"); } - + } #define fopAcM_RegisterDeleteID(i_this, actor_name_str) \ ("Delete -> " actor_name_str "(id=%d)\n", fopAcM_GetID(i_this)) diff --git a/include/f_pc/f_pc_deletor.h b/include/f_pc/f_pc_deletor.h index c0b7da0fc2..1667303fc4 100644 --- a/include/f_pc/f_pc_deletor.h +++ b/include/f_pc/f_pc_deletor.h @@ -7,6 +7,7 @@ typedef struct base_process_class base_process_class; BOOL fpcDt_IsComplete(); +int fpcDt_deleteMethod(base_process_class* i_proc); int fpcDt_ToDeleteQ(base_process_class* i_proc); int fpcDt_ToQueue(base_process_class* i_proc); void fpcDt_Handler(); diff --git a/include/m_Do/m_Do_dvd_thread.h b/include/m_Do/m_Do_dvd_thread.h index ebb4253838..dcb3f2fc65 100644 --- a/include/m_Do/m_Do_dvd_thread.h +++ b/include/m_Do/m_Do_dvd_thread.h @@ -68,7 +68,7 @@ public: JKRMemArchive* getArchive() const { return mArchive; } JKRHeap* getHeap() const { return mHeap; } -// private: +private: /* 0x14 */ u8 mMountDirection; /* 0x18 */ s32 mEntryNumber; /* 0x1C */ JKRMemArchive* mArchive; diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index bd1baac2df..4c1ceeb997 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -542,10 +542,18 @@ public: virtual void setMaterial() = 0; virtual void draw() = 0; #if TARGET_PC - virtual void refreshGeometryForPresentationEye(const cXyz& eye) {} + virtual void captureInterpPoints() {} + virtual void refreshGeometryForPresentation() {} #endif /* 0x4 */ mDoExt_3DlineMat_c* field_0x4; + +#if TARGET_PC +protected: + u8 mInterpKind; + f32 mInterpWidth; + u16 mInterpTaper; +#endif }; class mDoExt_3DlineMat0_c : public mDoExt_3DlineMat_c { @@ -567,6 +575,10 @@ public: virtual int getMaterialID() { return 0; } virtual void setMaterial(); virtual void draw(); +#if TARGET_PC + void captureInterpPoints() override; + void refreshGeometryForPresentation() override; +#endif cXyz* getPos(int param_0) { return field_0x18[param_0].field_0x0; } f32* getSize(int param_0) { return field_0x18[param_0].field_0x4; } @@ -585,18 +597,14 @@ class dKy_tevstr_c; class mDoExt_3DlineMat1_c : public mDoExt_3DlineMat_c { public: int init(u16, u16, ResTIMG*, int); -#if TARGET_PC - void update(int, GXColor&, dKy_tevstr_c*, const cXyz* presentationEye = nullptr); - void update(int, f32, GXColor&, u16, dKy_tevstr_c*, const cXyz* presentationEye = nullptr); -#else void update(int, GXColor&, dKy_tevstr_c*); void update(int, f32, GXColor&, u16, dKy_tevstr_c*); -#endif int getMaterialID() { return 1; } void setMaterial(); void draw(); #if TARGET_PC - void refreshGeometryForPresentationEye(const cXyz& eye) override; + void captureInterpPoints() override; + void refreshGeometryForPresentation() override; #endif cXyz* getPos(int i_idx) { return mpLines[i_idx].field_0x0; } @@ -611,11 +619,6 @@ private: /* 0x34 */ u16 field_0x34; /* 0x36 */ u8 mIsDrawn; /* 0x38 */ mDoExt_3Dline_c* mpLines; -#if TARGET_PC - u8 mInterpLineKind; - f32 mInterpLineF; - u16 mInterpLineU16; -#endif }; class mDoExt_3DlineMat2_c : public mDoExt_3DlineMat1_c { diff --git a/include/m_Do/m_Do_lib.h b/include/m_Do/m_Do_lib.h index 6b85cc0660..9ceaa9c137 100644 --- a/include/m_Do/m_Do_lib.h +++ b/include/m_Do/m_Do_lib.h @@ -2,13 +2,10 @@ #define M_DO_M_DO_LIB_H #include "JSystem/J3DU/J3DUClipper.h" -#include #if TARGET_PC -#include "JSystem/JGeometry.h" -#endif - #include "helpers/gx_helper.h" +#endif typedef struct Vec Vec; struct ResTIMG; diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 89e7e8b7cf..fdf5b66fed 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -5,9 +5,12 @@ #include "SSystem/SComponent/c_xyz.h" #include -#include "JSystem/JMath/JMath.h" +#if TARGET_PC #include "helpers/endian.h" +#include "JSystem/JMath/JMath.h" +#endif + extern u8 g_printCurrentHeapDebug; DUSK_GAME_EXTERN u8 g_printOtherHeapDebug; diff --git a/include/m_Do/m_Do_printf.h b/include/m_Do/m_Do_printf.h index a71669f432..dc30b1c720 100644 --- a/include/m_Do/m_Do_printf.h +++ b/include/m_Do/m_Do_printf.h @@ -2,7 +2,6 @@ #define M_DO_M_DO_PRINTF_H #include -#include "helpers/endian.h" void my_PutString(const char*); void mDoPrintf_vprintf_Interrupt(char const*, va_list); diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h b/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h index 27218d0d0d..3eb1967e2c 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DManage.h @@ -3,6 +3,10 @@ #include +#if TARGET_PC + #include "helpers/endian.h" +#endif + class JSUInputStream; /** diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h index d55bb82465..a7edb19b70 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -79,7 +79,9 @@ public: virtual ~J3DModel() {} #if TARGET_PC - static void interp_callback(bool isSimFrame, void* pUserWork); + static void interp_callback(void* pUserWork); + void calc_presentation_base_mtx(); + void prepare_presentation_view(); #endif J3DModelData* getModelData() { return mModelData; } @@ -133,6 +135,9 @@ public: /* 0xD0 */ J3DVtxColorCalc* mVtxColorCalc; /* 0xD4 */ J3DUnkCalc1* mUnkCalc1; /* 0xD8 */ J3DUnkCalc2* mUnkCalc2; +#if TARGET_PC + Mtx mPresentationBase; +#endif }; #endif /* J3DMODEL_H */ diff --git a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h index ace28de6e3..e23dca3c02 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h @@ -7,6 +7,7 @@ #include #include #include +#include class JKRHeap; typedef void (*JKRErrorHandler)(void*, u32, int); diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp index 51f3951e38..dfb9050cbd 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp @@ -10,7 +10,7 @@ #include "JSystem/JKernel/JKRHeap.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif #define J3D_ASSERTMSG(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) @@ -29,6 +29,7 @@ void J3DModel::initialize() { MTXIdentity(mBaseTransformMtx); MTXIdentity(mInternalView); + IF_DUSK(MTXIdentity(mPresentationBase)); mMtxBuffer = NULL; mMatPacket = NULL; @@ -101,17 +102,32 @@ s32 J3DModel::entryModelData(J3DModelData* pModelData, u32 mdlFlags, u32 mtxNum) } #if TARGET_PC -void J3DModel::interp_callback(bool isSimFrame, void* pUserWork) { +void J3DModel::interp_callback(void* pUserWork) { J3DModel* i_this = static_cast(pUserWork); - if (!isSimFrame) { - i_this->calcMaterial(); - i_this->diff(); - } + i_this->calcMaterial(); + i_this->diff(); } void J3DModel::setAnmMtx(int jointNo, Mtx m) { mMtxBuffer->setAnmMtx(jointNo, m); - dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); + dusk::interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); +} + +void J3DModel::calc_presentation_base_mtx() { + Mtx identity; + MTXIdentity(identity); + J3DCalcViewBaseMtx(identity, mBaseScale, mBaseTransformMtx, mPresentationBase); + dusk::interp::record_final_mtx(mPresentationBase); + prepare_presentation_view(); +} + +void J3DModel::prepare_presentation_view() { + Mtx replacement; + MtxP presentationBase = mPresentationBase; + if (dusk::interp::lookup_replacement(mPresentationBase, replacement)) { + presentationBase = replacement; + } + MTXConcat(j3dSys.getViewMtx(), presentationBase, mInternalView); } #endif @@ -470,11 +486,11 @@ void J3DModel::calc() { #ifdef TARGET_PC for (u16 i = 0; i < mModelData->getJointNum(); ++i) { - dusk::frame_interp::record_final_mtx(getAnmMtx(i)); + dusk::interp::record_final_mtx(getAnmMtx(i)); } for (u16 i = 0; i < mModelData->getWEvlpMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(getWeightAnmMtx(i)); + dusk::interp::record_final_mtx(getWeightAnmMtx(i)); } #endif } @@ -505,8 +521,9 @@ void J3DModel::entry() { } #if TARGET_PC - if (mModelData->needsInterpCallBack()) - dusk::frame_interp::add_interpolation_callback(&J3DModel::interp_callback, this); + if (mModelData->needsInterpCallBack()) { + dusk::interp::add_interpolation_callback(&J3DModel::interp_callback, this); + } #endif } @@ -516,18 +533,20 @@ void J3DModel::viewCalc() { if (getModelData()->checkFlag(0x10)) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (isCpuSkinningOn()) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (checkFlag(J3DMdlFlag_SkinPosCpu)) { @@ -549,15 +568,6 @@ void J3DModel::viewCalc() { DCStoreRange(getNrmMtxPtr(), mModelData->getDrawMtxNum() * sizeof(Mtx33)); } -#ifdef TARGET_PC - Mtx* drawMtx = getDrawMtxPtr(); - if (drawMtx != J3DMtxBuffer::sNoUseDrawMtxPtr) { - for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(drawMtx[i]); - } - } -#endif - prepareShapePackets(); } diff --git a/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp b/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp index 40c523643e..2d175ff871 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DDrawBuffer.cpp @@ -8,7 +8,10 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" #include "JSystem/JKernel/JKRHeap.h" -#include "tracy/Tracy.hpp" + +#if TARGET_PC +#include +#endif void J3DDrawBuffer::calcZRatio() { mZRatio = (mZFar - mZNear) / (f32)mEntryTableSize; diff --git a/libs/JSystem/src/J3DGraphBase/J3DGD.cpp b/libs/JSystem/src/J3DGraphBase/J3DGD.cpp index eb89fc3b81..74e5c2c759 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DGD.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DGD.cpp @@ -6,7 +6,10 @@ #include "JSystem/J3DGraphBase/J3DGD.h" #include "JSystem/J3DGraphBase/J3DFifo.h" -#include + +#if TARGET_PC +#include "dusk/logging.h" +#endif void J3DGDSetGenMode(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm) { diff --git a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp index f87283df47..fb82b8244d 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp @@ -1,15 +1,18 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include -#include +#include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphAnimator/J3DModel.h" #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" -#include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DShapeMtx.h" #include "JSystem/JKernel/JKRHeap.h" +#include +#include #include "global.h" -#include "tracy/Tracy.hpp" + +#if TARGET_PC +#include +#endif J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) { mMaxSize = ALIGN_NEXT(maxSize, 0x20); @@ -339,6 +342,11 @@ int J3DShapePacket::newDifferedDisplayList(u32 diffFlags) { void J3DShapePacket::prepareDraw() const { mpModel->getVertexBuffer()->setArray(); j3dSys.setModel(mpModel); +#if TARGET_PC + if (mpModel->getMtxCalcMode() == 2) { + mpModel->prepare_presentation_view(); + } +#endif j3dSys.setShapePacket((J3DShapePacket*)this); J3DShapeMtx::setLODFlag(mpModel->checkFlag(J3DMdlFlag_EnableLOD) != 0); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp index 22eb76a533..07ed23ed4a 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShape.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShape.cpp @@ -1,15 +1,17 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/J3DGraphBase/J3DShape.h" - -#include -#include -#include -#include "JSystem/J3DGraphBase/J3DFifo.h" #include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DVertex.h" +#include "JSystem/J3DGraphBase/J3DFifo.h" +#include + +#if TARGET_PC #include "JSystem/JKernel/JKRHeap.h" -#include "tracy/Tracy.hpp" + +#include +#include +#endif void J3DGDSetVtxAttrFmtv(GXVtxFmt, GXVtxAttrFmtList const*, bool); void J3DFifoLoadPosMtxImm(Mtx, u32); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp index 41d2e96ef0..ae9021f76c 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp @@ -6,13 +6,16 @@ #include "JSystem/J3DGraphBase/J3DMatBlock.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif DUSK_GAME_DATA u16 J3DShapeMtx::sMtxLoadCache[10]; -#ifdef TARGET_PC +#if TARGET_PC static void J3DFrameInterpConcat(MtxP lhs, MtxP rhs, Mtx out) { - if (!dusk::frame_interp::lookup_concat_replacement(lhs, rhs, out)) { + if (!dusk::interp::lookup_concat_replacement(lhs, rhs, out)) { MTXConcat(lhs, rhs, out); } } diff --git a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp index bdacff4276..0f5beb9db5 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp @@ -1,15 +1,16 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include "JSystem/J3DGraphBase/J3DFifo.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "helpers/gx_helper.h" +#include "JSystem/J3DGraphBase/J3DFifo.h" #include "global.h" -#include "tracy/Tracy.hpp" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" +#include "helpers/gx_helper.h" + +#include #endif DUSK_GAME_DATA J3DSys j3dSys; @@ -378,7 +379,7 @@ void J3DSys::reinitPixelProc() { #if TARGET_PC void J3DSys::setViewMtx(const Mtx m) { Mtx patched; - if (dusk::frame_interp::lookup_replacement(m, patched)) { + if (dusk::interp::lookup_replacement(m, patched)) { m = patched; } MTXCopy(m, mViewMtx); diff --git a/libs/JSystem/src/JAudio2/JASAiCtrl.cpp b/libs/JSystem/src/JAudio2/JASAiCtrl.cpp index 545b0d41dc..e59c9d45fe 100644 --- a/libs/JSystem/src/JAudio2/JASAiCtrl.cpp +++ b/libs/JSystem/src/JAudio2/JASAiCtrl.cpp @@ -18,7 +18,9 @@ #include #include -#include "tracy/Tracy.hpp" +#if TARGET_PC +#include +#endif DUSK_GAME_DATA s16* JASDriver::sDmaDacBuffer[3]; diff --git a/libs/JSystem/src/JFramework/JFWDisplay.cpp b/libs/JSystem/src/JFramework/JFWDisplay.cpp index 466335eae9..0524cb86f7 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -12,17 +12,18 @@ #include "global.h" #include -#ifdef TARGET_PC +#if TARGET_PC #include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/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" +#include "f_op/f_op_overlap_mng.h" + +#include +#include #include #endif @@ -217,8 +218,8 @@ void JFWDisplay::endGX() { if (mFader != NULL) { ortho.setPort(); -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { +#if TARGET_PC + if (dusk::interp::get_ui_tick_pending()) { mFader->advance(); } if (mFader->getStatus() != JUTFader::Wait) { @@ -381,7 +382,7 @@ static void waitForTick(u32 p1, u16 p2) { #if TARGET_PC static Limiter limiter; - if (dusk::frame_interp::is_enabled() || dusk::getTransientSettings().turboMode) { + if (dusk::interp::is_enabled() || dusk::getTransientSettings().turboMode) { limiter.Reset(); dusk::frameUsagePct = 0.f; return; diff --git a/libs/JSystem/src/JKernel/JKRArchivePri.cpp b/libs/JSystem/src/JKernel/JKRArchivePri.cpp index eed317a357..f81082cc2f 100644 --- a/libs/JSystem/src/JKernel/JKRArchivePri.cpp +++ b/libs/JSystem/src/JKernel/JKRArchivePri.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "JSystem/JKernel/JKRDvdRipper.h" #if _WIN32 #include @@ -21,6 +22,8 @@ std::atomic JKRArchive::sArcOverlayGeneration{0}; namespace { +inline constexpr borealis::Log Log{"JKRArchivePri"}; + void* alloc_overlay_buffer(u32 size) { #if _WIN32 return _aligned_malloc(size, alignof(std::max_align_t)); @@ -452,12 +455,18 @@ bool JKRArchive::copyOverlayData(void* buffer, u32 bufferSize, SDIFileEntry* ent return false; } - const u32 copySize = overlaySize < bufferSize ? overlaySize : bufferSize; - if (copySize != 0) { - memcpy(buffer, overlayData, copySize); + if (overlaySize > bufferSize) { + std::string path; + getOverlayPath(entry, path); + Log.error("Overlay %s is %u bytes but the game reserved %u\n", path.c_str(), overlaySize, + bufferSize); + return false; + } + if (overlaySize != 0) { + memcpy(buffer, overlayData, overlaySize); } if (outSize != nullptr) { - *outSize = copySize; + *outSize = overlaySize; } return true; } diff --git a/libs/JSystem/src/JParticle/JPABaseShape.cpp b/libs/JSystem/src/JParticle/JPABaseShape.cpp index c47d978b00..bebf947fec 100644 --- a/libs/JSystem/src/JParticle/JPABaseShape.cpp +++ b/libs/JSystem/src/JParticle/JPABaseShape.cpp @@ -10,9 +10,10 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" + +#include #endif -#include "tracy/Tracy.hpp" #if TARGET_PC #define JPA_DRAW_CTX_PARAM , ParticleDrawCtx* ctx @@ -551,7 +552,7 @@ static void submit_particle_quad( void JPAInterpBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -563,7 +564,7 @@ void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { ptclPosMtx[0][1] = -sinRot; ptclPosMtx[1][0] = sinRot; ptclPosMtx[1][1] = cosRot; - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } #endif @@ -576,7 +577,7 @@ void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C JGeometry::TVec3 pos; #if TARGET_PC Mtx ptclPosMtx; - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); MTXMultVec(work->mPosCamMtx, &pos, &pos); } else @@ -616,7 +617,7 @@ void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA #if TARGET_PC Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); sinRot = ptclPosMtx[1][0]; cosRot = ptclPosMtx[0][0]; @@ -993,7 +994,7 @@ void JPAInterpDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][2] = axisZ.z; posMtx[2][3] = ptcl->mPosition.z; p_plane[work->mPlaneType](posMtx, scaleX, scaleY); - dusk::frame_interp::record_final_mtx(posMtx, ptcl); + dusk::interp::record_final_mtx(posMtx, ptcl); } void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -1036,7 +1037,7 @@ void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { mtx2[2][2] = axisZ.z; mtx2[2][3] = ptcl->mPosition.z; MTXConcat(mtx2, mtx1, mtx1); - dusk::frame_interp::record_final_mtx(mtx1, ptcl); + dusk::interp::record_final_mtx(mtx1, ptcl); } #endif @@ -1049,7 +1050,7 @@ void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C Mtx posMtx; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, posMtx) && + if (!dusk::interp::lookup_replacement(ptcl, posMtx) && !make_direction_mtx(work, ptcl, posMtx)) { return; @@ -1112,7 +1113,7 @@ void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA Mtx mtx1; Mtx mtx2; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, mtx1) && + if (!dusk::interp::lookup_replacement(ptcl, mtx1) && !make_rot_direction_mtx(work, ptcl, mtx1)) { return; diff --git a/libs/JSystem/src/JParticle/JPAEmitterManager.cpp b/libs/JSystem/src/JParticle/JPAEmitterManager.cpp index 3a793000ed..0dcaa3b8b5 100644 --- a/libs/JSystem/src/JParticle/JPAEmitterManager.cpp +++ b/libs/JSystem/src/JParticle/JPAEmitterManager.cpp @@ -8,7 +8,9 @@ #include "JSystem/JUtility/JUTAssert.h" #include +#if TARGET_PC #include "tracy/Tracy.hpp" +#endif JPAEmitterManager::JPAEmitterManager(u32 i_ptclNum, u32 i_emtrNum, JKRHeap* pHeap, u8 i_gidMax, u8 i_ridMax) { diff --git a/libs/JSystem/src/JParticle/JPAParticle.cpp b/libs/JSystem/src/JParticle/JPAParticle.cpp index 99ba95453c..0bb03d607a 100644 --- a/libs/JSystem/src/JParticle/JPAParticle.cpp +++ b/libs/JSystem/src/JParticle/JPAParticle.cpp @@ -8,7 +8,7 @@ #include "JSystem/JParticle/JPAExtraShape.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif JPAParticleCallBack::~JPAParticleCallBack() { @@ -210,7 +210,7 @@ void JPABaseParticle::init_c(JPAEmitterWorkData* work, JPABaseParticle* parent) #if TARGET_PC void JPABaseParticle::interp(JPAEmitterWorkData* work, void const* drawFunc) { - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) return; // don't interpolate the first frame diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index b67ac47489..8a4d931e16 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -1,10 +1,6 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/JParticle/JPAResource.h" - -#include - -#include #include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JParticle/JPABaseShape.h" #include "JSystem/JParticle/JPAChildShape.h" @@ -15,11 +11,13 @@ #include "JSystem/JParticle/JPAKeyBlock.h" #include "JSystem/JParticle/JPAParticle.h" #include "JSystem/JParticle/JPAResourceManager.h" +#include #include "global.h" -#include "tracy/Tracy.hpp" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" + +#include #define JPA_DRAW_CTX_ARG , &ctx #else @@ -841,7 +839,7 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) { #ifdef TARGET_PC if (((pBsp && pBsp->getDirType() == 3) || (pCsp && pCsp->getDirType() == 3)) && - dusk::frame_interp::is_enabled()) + dusk::interp::is_enabled()) { // ensure mGlobalEmtrDir is valid calcWorkData_d(work); diff --git a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp index 2f408d6184..b6f41098e5 100644 --- a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp +++ b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp @@ -4,7 +4,7 @@ #if TARGET_PC #include "dusk/audio.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #endif @@ -655,10 +655,10 @@ value_or_fun: value: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && u <= 5 && + if (dusk::interp::is_enabled() && u <= 5 && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue(control, u, operation, param_2, param_3); @@ -666,11 +666,11 @@ value: value_n: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && + if (dusk::interp::is_enabled() && (pN == TAdaptor_camera::sauVariableValue_3_POSITION_XYZ || pN == TAdaptor_camera::sauVariableValue_3_TARGET_POSITION_XYZ) && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue_n(control, pN, u, operation, param_2, param_3); diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index a8d9fe6028..2e937b176e 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -9,8 +9,9 @@ #include "JSystem/J2DGraph/J2DOrthoGraph.h" #ifdef TARGET_PC +#include "dusk/interp/frame_interpolation.h" + #include -#include "dusk/frame_interpolation.h" #endif JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) @@ -74,8 +75,8 @@ void JUTFader::control() { void JUTFader::draw() { if (mColor.a != 0) { #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled() && mDuration != 0) { - const auto step = dusk::frame_interp::get_interpolation_step(); + if (dusk::interp::is_enabled() && mDuration != 0) { + const auto step = dusk::interp::get_interpolation_step(); const auto progress = static_cast(mTimer) / static_cast(mDuration); const auto timer = mTimer - 1 + step + progress; auto alpha = timer / mDuration; diff --git a/mods/basic_cosmetics_mod/mod.json b/mods/basic_cosmetics_mod/mod.json deleted file mode 100644 index d6c258bfe9..0000000000 --- a/mods/basic_cosmetics_mod/mod.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "dev.twilitrealm.basic_cosmetics", - "name": "Basic Cosmetics", - "version": "1.0.0", - "author": "Twilit Realm", - "description": "Change Basic Cosmetic Colors" -} diff --git a/mods/basic_cosmetics_mod/src/color_utils.cpp b/mods/basic_cosmetics_mod/src/color_utils.cpp deleted file mode 100644 index d1dc2eb096..0000000000 --- a/mods/basic_cosmetics_mod/src/color_utils.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "color_utils.hpp" - -uint8_t desaturate_rgb_565(uint16_t rgb565Val) { - const uint32_t r = (rgb565Val & 0xf800) >> 11; - const uint32_t g = (rgb565Val & 0x7e0) >> 5; - const uint32_t b = rgb565Val & 0x1f; - - // Here we are doing a quicker (0.22 * r + 0.72 * g + 0.06 * b) which - // uses multiplies and shifts rather than division. - const uint32_t combined = 30480413 * r + 49085341 * g + 8312839 * b; - uint8_t shifted = (combined >> 24) & 0xff; - - // Check if should round up shifted value. - if (shifted < 0xff && combined & 0x00800000) { - shifted += 1; - } - - return shifted; -} - -uint16_t blend_overlay_rgb_565(uint8_t grayVal, GXColor color) { - uint32_t rTimes255, gTimes255, bTimes255; - - if (grayVal <= 0x7f) { - const uint32_t grayTimesTwo = 2 * grayVal; - - rTimes255 = grayTimesTwo * color.r; - gTimes255 = grayTimesTwo * color.g; - bTimes255 = grayTimesTwo * color.b; - } else { - const uint32_t multiplier = 2 * (255 - grayVal); - - rTimes255 = 255 * 255 - multiplier * (255 - color.r); - gTimes255 = 255 * 255 - multiplier * (255 - color.g); - bTimes255 = 255 * 255 - multiplier * (255 - color.b); - } - - // Divide each by 255 - const uint32_t r = (rTimes255 + 1 + (rTimes255 >> 8)) >> 8; - const uint32_t g = (gTimes255 + 1 + (gTimes255 >> 8)) >> 8; - const uint32_t b = (bTimes255 + 1 + (bTimes255 >> 8)) >> 8; - - return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); -} - -// Helper function to perform overlay blending on a single 8-bit color channel -uint8_t blend_overlay_channel(uint8_t base, uint8_t blend) { - if (base < 128) { - return static_cast((2 * base * blend) / 255); - } - - return static_cast(255 - (2 * (255 - base) * (255 - blend)) / 255); -} - -bool is_valid_hex_color_str(std::string_view hexStr) { - return hexStr.find_first_not_of("0123456789ABCDEFabcdef") == std::string_view::npos && - hexStr.length() == 6; -} - -GXColor hex_color_str_to_gx_color(const std::string& hexColorStr) { - u8 r = std::stoi(hexColorStr.substr(0, 2), nullptr, 16); - u8 g = std::stoi(hexColorStr.substr(2, 2), nullptr, 16); - u8 b = std::stoi(hexColorStr.substr(4, 2), nullptr, 16); - return GXColor{r, g, b}; -} - -static f32 rainbowPhaseAngle = 0.f; - -GXColor get_rainbow_rgb(f32 amplitude) { - f32 phase_rad = rainbowPhaseAngle * M_PI / 180.0f; - - u8 r_val = (u8)(amplitude * (sinf(phase_rad) + 1.0f) + 0.5f); - u8 g_val = (u8)(amplitude * (sinf(phase_rad + 2.0f * M_PI / 3.0f) + 1.0f) + 0.5f); - u8 b_val = (u8)(amplitude * (sinf(phase_rad + 4.0f * M_PI / 3.0f) + 1.0f)); - GXColor rgbColor; - rgbColor.r = r_val; - rgbColor.g = g_val; - rgbColor.b = b_val; - rgbColor.a = 0xff; - return rgbColor; -} - -void update_rainbow_rgb(f32 increment) { - rainbowPhaseAngle += increment; - if (rainbowPhaseAngle >= 360.0f) { - rainbowPhaseAngle -= 360.0f; - } -} \ No newline at end of file diff --git a/mods/basic_cosmetics_mod/src/color_utils.hpp b/mods/basic_cosmetics_mod/src/color_utils.hpp deleted file mode 100644 index 94e1ce62a8..0000000000 --- a/mods/basic_cosmetics_mod/src/color_utils.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -/** - * File originally copied from console TPR with permission from isaac - * https://github.com/zsrtp/libtp_rel/blob/master/include/util/color_utils.h - */ - -#include - -#include -#include - -// Desaturates an RGB565 color to a u8 gray value (0xFF being white and 0x00 -// being black). -uint8_t desaturate_rgb_565(uint16_t rgb565Val); - -// Performs an "Overlay" blend of a u8 gray value and a pointer to a u8 -// array of {r,g,b}. Returns the result as an RGB565. -uint16_t blend_overlay_rgb_565(uint8_t grayVal, GXColor color); - -// Perform overlay blending on a single 8-bit color channel -uint8_t blend_overlay_channel(uint8_t base, uint8_t blend); - -bool is_valid_hex_color_str(std::string_view hexStr); - -GXColor hex_color_str_to_gx_color(const std::string& hexColorStr); - -GXColor get_rainbow_rgb(f32 amplitude); - -void update_rainbow_rgb(f32 increment); diff --git a/mods/basic_cosmetics_mod/src/hooks.cpp b/mods/basic_cosmetics_mod/src/hooks.cpp deleted file mode 100644 index e90e76d8b3..0000000000 --- a/mods/basic_cosmetics_mod/src/hooks.cpp +++ /dev/null @@ -1,731 +0,0 @@ -#include "hooks.hpp" - -#include "color_utils.hpp" -#include "midna_hair_color.hpp" -#include "mod.hpp" -#include "types.h" - -#include "mods/svc/hook.hpp" -#include "mods/svc/log.hpp" - -#include "SSystem/SComponent/c_phase.h" -#include "d/actor/d_a_alink.h" -#include "d/actor/d_a_midna.h" -#include "d/d_a_item_static.h" -#include "d/d_bright_check.h" -#include "d/d_file_sel_info.h" -#include "d/d_file_select.h" -#include "d/d_kankyo.h" -#include "d/d_kantera_icon_meter.h" -#include "d/d_menu_collect.h" -#include "d/d_menu_fishing.h" -#include "d/d_menu_fmap2D.h" -#include "d/d_menu_insect.h" -#include "d/d_menu_letter.h" -#include "d/d_menu_option.h" -#include "d/d_menu_ring.h" -#include "d/d_menu_save.h" -#include "d/d_menu_skill.h" -#include "d/d_meter2.h" -#include "d/d_meter2_draw.h" -#include "d/d_meter2_info.h" -#include "d/d_meter_button.h" -#include "d/d_meter_hakusha.h" -#include "d/d_msg_object.h" -#include "d/d_msg_out_font.h" -#include "d/d_msg_scrn_base.h" -#include "d/d_pane_class.h" - -// Lantern ambience color -DEFINE_HOOK(&dKy_WolfEyeLight_set, WolfEyeLightSet); -void wolf_eye_light_set_post(ModContext*, void*, void*, void*) { - auto maybeLanternColor = get_config_var_color(get_cvars().lanternGlowColor, true); - if (maybeLanternColor.has_value()) { - auto lanternColor = maybeLanternColor.value(); - - dScnKy_env_light_c* kankyo = dKy_getEnvlight(); - kankyo->field_0x0c18[0].mColor.r = lanternColor.r; - kankyo->field_0x0c18[0].mColor.g = lanternColor.g; - kankyo->field_0x0c18[0].mColor.b = lanternColor.b; - } -} - -// Lantern Sphere color -DEFINE_HOOK(&daAlink_c::preKandelaarDraw, PreKandelaarDraw); -void pre_kandelaar_draw_post(ModContext*, void*, void*, void*) { - auto maybeLanternColor = get_config_var_color(get_cvars().lanternGlowColor, true); - if (maybeLanternColor.has_value()) { - auto lanternColor = maybeLanternColor.value(); - - J3DMaterial* mat_p = daAlink_getAlinkActorClass() - ->mpKanteraGlowModel->getModelData() - ->getMaterialNodePointer(0); - - J3DGXColorS10 color; - color.r = lanternColor.r; - color.g = lanternColor.g; - color.b = lanternColor.b; - color.a = 255; - mat_p->setTevColor(1, &color); - - color.r = lanternColor.r; - color.g = lanternColor.g; - color.b = lanternColor.b; - mat_p->setTevColor(2, &color); - } -} - -// Main Lantern Meter Color -DEFINE_HOOK(&CPaneMgr::setBlackWhite, CPaneMgrSetBlackWhite); -HookAction cpane_mgr_set_black_white_pre(ModContext*, void* args, void*, void*) { - // Check for magic meter - auto pane = mods::arg(args, 0); - if (dMeter2Info_getMeterClass() == NULL || - pane != dMeter2Info_getMeterClass()->getMeterDrawPtr()->mpMagicMeter) - { - return HOOK_CONTINUE; - } - - // If magic meter, check to see we're setting lantern colors - auto& black = mods::arg_ref(args, 1); - auto& white = mods::arg_ref(args, 2); - if (black != JUtility::TColor(255, 255, 140, 255) && - white != JUtility::TColor(230, 170, 0, 255)) - { - return HOOK_CONTINUE; - } - - auto maybeLanternColor = get_config_var_color(get_cvars().lanternGlowColor, true); - if (maybeLanternColor.has_value()) { - auto lanternColor = maybeLanternColor.value(); - black = JUtility::TColor(lanternColor.r, lanternColor.g, lanternColor.b, 255); - white = JUtility::TColor(lanternColor.r, lanternColor.g, lanternColor.b, 255); - } - - return HOOK_CONTINUE; -} - -// Lantern Icon Meter Color -DEFINE_HOOK(&dKantera_icon_c::setNowGauge, KanteraIconSetNowGauge); -void kantera_icon_set_now_gauge_post(ModContext*, void* args, void*, void*) { - auto maybeLanternColor = get_config_var_color(get_cvars().lanternGlowColor, true); - if (maybeLanternColor.has_value()) { - auto lanternColor = maybeLanternColor.value(); - - auto kanteraIcon = mods::arg(args, 0); - kanteraIcon->mpGauge->setBlackWhite( - JUtility::TColor(lanternColor.r, lanternColor.g, lanternColor.b, 255), - JUtility::TColor(lanternColor.r, lanternColor.g, lanternColor.b, 255)); - } -} - -// Light Sword Effect Color -DEFINE_HOOK(&daAlink_c::setLightningSwordEffect, SetLightningSwordEffect); -void set_lightning_sword_effect_post(ModContext*, void* args, void*, void*) { - auto maybeGlowColor = get_config_var_color(get_cvars().lightSwordGlowColor, true); - if (maybeGlowColor.has_value()) { - auto glowColor = maybeGlowColor.value(); - - auto link = mods::arg(args, 0); - // Check copied from inside the hooked function - if (link->mEquipItem == 0x103 && link->checkNoResetFlg3(daPy_py_c::FLG3_UNK_100000)) { - for (size_t i = 0; i < 3; i++) { - auto emitter = dComIfGp_particle_getEmitter(link->field_0x327c[i]); - if (emitter != NULL) { - emitter->setGlobalEnvColor(glowColor.r, glowColor.g, glowColor.b); - emitter->setGlobalPrmColor(glowColor.r, glowColor.g, glowColor.b); - } - } - } - } -} - -void recolor_ui_button(ConfigVarHandle option, u64 tag, J2DScreen* screen) { - auto buttonColorStr = get_str_option(option, ""); - if (is_valid_hex_color_str(buttonColorStr)) { - auto color = hex_color_str_to_gx_color(buttonColorStr); - auto element = static_cast(screen->search(tag)); - if (element != nullptr) { - element->setBlackWhite( - JUtility::TColor(0, 0, 0, 0), JUtility::TColor(color.r, color.g, color.b, 0xFF)); - } - } -} - -// Main gameplay UI. Top left hearts and top right buttons -DEFINE_HOOK(&dMeter2Draw_c::init, dMeter2Init); -void d_meter_2_init_post(ModContext*, void* args, void*, void*) { - auto dMeter2Draw = mods::arg(args, 0); - auto screen = dMeter2Draw->getMainScreenPtr(); - - // Heart tags on main UI - static constexpr std::array kHeartTags = {MULTI_CHAR('hear_00'), MULTI_CHAR('hear_01'), - MULTI_CHAR('hear_02'), MULTI_CHAR('hear_03'), MULTI_CHAR('hear_04'), MULTI_CHAR('hear_05'), - MULTI_CHAR('hear_06'), MULTI_CHAR('hear_07'), MULTI_CHAR('hear_08'), MULTI_CHAR('hear_09'), - MULTI_CHAR('hear_10'), MULTI_CHAR('hear_11'), MULTI_CHAR('hear_12'), MULTI_CHAR('hear_13'), - MULTI_CHAR('hear_14'), MULTI_CHAR('hear_15'), MULTI_CHAR('hear_16'), MULTI_CHAR('hear_17'), - MULTI_CHAR('hear_18'), MULTI_CHAR('hear_19'), MULTI_CHAR('bigh_00'), MULTI_CHAR('bigh_01'), - MULTI_CHAR('bigh_02'), MULTI_CHAR('bigh_03')}; - - auto maybeHeartColor = get_config_var_color(get_cvars().heartColor); - if (maybeHeartColor.has_value()) { - auto heartColor = maybeHeartColor.value(); - for (auto tag : kHeartTags) { - auto element = static_cast(screen->search(tag)); - if (element != nullptr) { - element->setBlackWhite(heartColor, JUtility::TColor(200, 200, 200, 255)); - } - } - } - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); - recolor_ui_button(get_cvars().xButtonColor, MULTI_CHAR('x_btn'), screen); - recolor_ui_button(get_cvars().yButtonColor, MULTI_CHAR('y_btn'), screen); - recolor_ui_button(get_cvars().zButtonColor, MULTI_CHAR('zbtn'), screen); -} - -// Hearts on the file select screen -DEFINE_HOOK(&dFile_info_c::setHeartCnt, FileInfoSetHeartCount); -void file_info_set_heart_count_post(ModContext*, void* args, void*, void*) { - auto fileInfo = mods::arg(args, 0); - - // Heart tags on file select - static constexpr std::array kFileSelectHeartTags{ - MULTI_CHAR('hear_20'), - MULTI_CHAR('hear_21'), - MULTI_CHAR('hear_22'), - MULTI_CHAR('hear_23'), - MULTI_CHAR('hear_24'), - MULTI_CHAR('hear_25'), - MULTI_CHAR('hear_26'), - MULTI_CHAR('hear_27'), - MULTI_CHAR('hear_28'), - MULTI_CHAR('hear_29'), - MULTI_CHAR('hear_30'), - MULTI_CHAR('hear_31'), - MULTI_CHAR('hear_32'), - MULTI_CHAR('hear_33'), - MULTI_CHAR('hear_34'), - MULTI_CHAR('hear_35'), - MULTI_CHAR('hear_36'), - MULTI_CHAR('hear_37'), - MULTI_CHAR('hear_38'), - MULTI_CHAR('hear_39'), - }; - - auto maybeHeartColor = get_config_var_color(get_cvars().heartColor); - if (maybeHeartColor.has_value()) { - auto heartColor = maybeHeartColor.value(); - for (auto tag : kFileSelectHeartTags) { - auto element = static_cast(fileInfo->mFileInfo.Scr->search(tag)); - if (element != nullptr) { - element->setBlackWhite(heartColor, JUtility::TColor(200, 200, 200, 255)); - } - } - } -} - -// Buttons that appear contextually at the bottom of the screen during gameplay -// (Are X, Y ever used there?) -DEFINE_HOOK(&dMeterButton_c::screenInitButton, ScreenInitButton); -void screen_init_button_post(ModContext*, void* args, void*, void*) { - auto meterButton = mods::arg(args, 0); - auto screen = meterButton->mpButtonScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn1'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); - recolor_ui_button(get_cvars().xButtonColor, MULTI_CHAR('x_btn'), screen); - recolor_ui_button(get_cvars().yButtonColor, MULTI_CHAR('y_btn'), screen); - recolor_ui_button(get_cvars().zButtonColor, MULTI_CHAR('zbtn'), screen); -} - -// A and B buttons when saving a file -DEFINE_HOOK(&dMenu_save_c::screenSet, MenuSaveScreenSet); -void menu_save_screen_set_post(ModContext*, void* args, void*, void*) { - auto menuSave = mods::arg(args, 0); - auto screen = menuSave->mSaveSel.Scr; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('wabtn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('wbbtn'), screen); -} - -// A and B buttons when selecting a file -DEFINE_HOOK(&dFile_select_c::screenSet, FileSelectScreenSet); -void file_select_screen_set_post(ModContext*, void* args, void*, void*) { - auto fileSelect = mods::arg(args, 0); - auto screen = fileSelect->fileSel.Scr; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('wabtn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('wbbtn'), screen); -} - -// A button on brightness check screen -DEFINE_HOOK(&dBrightCheck_c::screenSet, BrightCheckScreenSet); -void bright_check_screen_set_post(ModContext*, void* args, void*, void*) { - auto brightCheck = mods::arg(args, 0); - auto screen = brightCheck->mBrightCheck.Scr; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn1'), screen); -} - -// X and Y buttons on the item wheel screen -DEFINE_HOOK(&dMenu_Ring_c::_create, MenuRingCreate); -void menu_ring_create_post(ModContext*, void* args, void*, void*) { - auto menuRing = mods::arg(args, 0); - auto screen = menuRing->mpScreen; - - recolor_ui_button(get_cvars().xButtonColor, MULTI_CHAR('xbtn'), screen); - recolor_ui_button(get_cvars().yButtonColor, MULTI_CHAR('ybtn'), screen); -} - -// A and B buttons on the main pause screen -DEFINE_HOOK(&dMenu_Collect2D_c::_create, MenuCollect2DCreate); -void menu_collect_2D_create_post(ModContext*, void* args, void*, void*) { - auto menuCollect2D = mods::arg(args, 0); - auto screen = menuCollect2D->mpScreenIcon; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); -} - -// A and B buttons on the fishing journal screen -DEFINE_HOOK(&dMenu_Fishing_c::screenSetDoIcon, MenuFishingScreenSetDoIcon); -void menu_fishing_screen_set_do_icon_post(ModContext*, void* args, void*, void*) { - auto menuFishing = mods::arg(args, 0); - auto screen = menuFishing->mpIconScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); -} - -// A and B buttons on the insect collection screen -DEFINE_HOOK(&dMenu_Insect_c::screenSetDoIcon, MenuInsectScreenSetDoIcon); -void menu_insect_screen_set_do_icon_post(ModContext*, void* args, void*, void*) { - auto menuInsect = mods::arg(args, 0); - auto screen = menuInsect->mpIconScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); -} - -// A and B buttons on the letters screen -DEFINE_HOOK(&dMenu_Letter_c::screenSetDoIcon, MenuLetterScreenSetDoIcon); -void menu_letter_screen_set_do_icon_post(ModContext*, void* args, void*, void*) { - auto menuLetter = mods::arg(args, 0); - auto screen = menuLetter->mpIconScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); -} - -// A, B, and Z buttons on option screen -DEFINE_HOOK(&dMenu_Option_c::_create, MenuOptionCreate); -void menu_option_create_post(ModContext*, void* args, void*, void*) { - auto menuOption = mods::arg(args, 0); - auto screen = menuOption->mpScreenIcon; - auto backScreen = menuOption->mpBackScreen; - auto tvScreen = menuOption->mpTVScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); - recolor_ui_button(get_cvars().zButtonColor, MULTI_CHAR('g_zbtn'), backScreen); - - // A Button on option's brightness check screen - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn1'), tvScreen); -} - -// A and B buttons on the hidden skills screen -DEFINE_HOOK(&dMenu_Skill_c::screenSetDoIcon, MenuSkillScreenSetDoIcon); -void menu_skill_screen_set_do_icon_post(ModContext*, void* args, void*, void*) { - auto menuSkill = mods::arg(args, 0); - auto screen = menuSkill->mpIconScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn'), screen); -} - -// A, B, and Z buttons on the map screen -DEFINE_HOOK(&dMenu_Fmap_c::_create, MenuFMapCreate); -void menu_fmap_create_post(ModContext*, void* args, void*, void*) { - auto menuFMap = mods::arg(args, 0); - auto screen = menuFMap->mpDraw2DTop->mpTitleScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn'), screen); - recolor_ui_button(get_cvars().bButtonColor, MULTI_CHAR('b_btn1'), screen); - recolor_ui_button(get_cvars().zButtonColor, MULTI_CHAR('zbtn'), screen); -} - -// A button on the howling screen -DEFINE_HOOK(&dMsgObject_c::talkStartInit, MsgObjectTalkStartInit); -void msg_object_talk_start_init_post(ModContext*, void* args, void*, void*) { - auto msgObject = mods::arg(args, 0); - - // If textbox kind is howling - if (msgObject->mFukiKind == 17) { - auto screen = msgObject->mpScrnDraw->mpScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('abtn'), screen); - } -} - -// A button when on Epona -DEFINE_HOOK(&dMeterHakusha_c::_create, MeterHakushaCreate); -void meter_hakusha_create_post(ModContext*, void* args, void*, void*) { - auto meterHakusha = mods::arg(args, 0); - auto screen = meterHakusha->mpButtonScreen; - - recolor_ui_button(get_cvars().aButtonColor, MULTI_CHAR('a_btn1'), screen); -} - -// A, B, X, and Y button icons in text -DEFINE_HOOK(&COutFont_c::createPane, OutFontCreatePane); -void out_font_create_pane_post(ModContext*, void* args, void*, void*) { - auto outFont = mods::arg(args, 0); - auto paneArr = outFont->mpPane; - - auto maybeAButtonColor = get_config_var_color(get_cvars().aButtonColor); - if (maybeAButtonColor.has_value()) { - auto aButtonColor = maybeAButtonColor.value(); - paneArr[0]->setBlackWhite(JUtility::TColor(255, 255, 255, 0), - JUtility::TColor(aButtonColor.r, aButtonColor.g, aButtonColor.b, 255)); - } - - auto maybeBButtonColor = get_config_var_color(get_cvars().bButtonColor); - if (maybeBButtonColor.has_value()) { - auto bButtonColor = maybeBButtonColor.value(); - paneArr[1]->setBlackWhite(JUtility::TColor(255, 255, 255, 0), - JUtility::TColor(bButtonColor.r, bButtonColor.g, bButtonColor.b, 255)); - } - - // Condition copied from hooked function - auto xyBlack = JUtility::TColor(255, 255, 255, 0); - if (outFont->field_0x242 == 1) { - xyBlack = JUtility::TColor(0, 0, 0, 0); - } - - auto maybeXButtonColor = get_config_var_color(get_cvars().xButtonColor); - if (maybeXButtonColor.has_value()) { - auto xButtonColor = maybeXButtonColor.value(); - paneArr[5]->setBlackWhite( - xyBlack, JUtility::TColor(xButtonColor.r, xButtonColor.g, xButtonColor.b, 255)); - } - - auto maybeYButtonColor = get_config_var_color(get_cvars().yButtonColor); - if (maybeYButtonColor.has_value()) { - auto yButtonColor = maybeYButtonColor.value(); - paneArr[6]->setBlackWhite( - xyBlack, JUtility::TColor(yButtonColor.r, yButtonColor.g, yButtonColor.b, 255)); - } -} - -// Heart icon in text -DEFINE_HOOK(&COutFontSet_c::drawFont, OutFontSetDrawFont); -void out_font_set_draw_font_post(ModContext*, void* args, void*, void*) { - auto outFontSet = mods::arg(args, 0); - - auto maybeHeartColor = get_config_var_color(get_cvars().heartColor); - if (maybeHeartColor.has_value()) { - auto heartColor = maybeHeartColor.value(); - u32 heartColor_u32 = heartColor.r << 24 | heartColor.g << 16 | heartColor.b << 8 | 0xFF; - if (outFontSet->getType() == 0x1B) { // Heart icon type - outFontSet->mColor = heartColor_u32; - } - } -} - -// Heart Drop/Piece of Heart/Heart Container model color -DEFINE_HOOK(&daItemBase_c::CreateItemHeap, ItemBaseCreateItemHeap); -void item_base_create_item_heap_post(ModContext*, void* args, void*, void*) { - auto itemBase = mods::arg(args, 0); - if (itemBase == NULL) { - return; - } - auto itemNo = itemBase->m_itemNo; - if (itemNo == dItemNo_HEART_e || itemNo == dItemNo_UTAWA_HEART_e || - itemNo == dItemNo_KAKERA_HEART_e) - { - auto maybeHeartColor = get_config_var_color(get_cvars().heartColor); - if (maybeHeartColor.has_value()) { - auto heartColor = maybeHeartColor.value(); - auto heartColorS10 = GXColorS10(heartColor.r, heartColor.g, heartColor.b, heartColor.a); - - // Edit inner heart material color for Piece of Heart / Heart Container - if (itemNo == dItemNo_UTAWA_HEART_e || itemNo == dItemNo_KAKERA_HEART_e) { - *itemBase->mpModel->getModelData()->getMaterialNodePointer(3)->getTevKColor(1) = - heartColor; - *itemBase->mpModel->getModelData()->getMaterialNodePointer(3)->getTevColor(1) = - heartColorS10; - } - - const u8 heartColorRGB[3] = {heartColor.r, heartColor.g, heartColor.b}; - u8** cRegTable = - reinterpret_cast(&itemBase->mpBrkAnm->getBrkAnm()->mAnmCRegDataR); - u8** kRegTable = - reinterpret_cast(&itemBase->mpBrkAnm->getBrkAnm()->mAnmKRegDataR); - - for (int i = 0; i < 3; i++) { - u8* cReg = cRegTable[i]; - u8* kReg = kRegTable[i]; - - auto curColor = heartColorRGB[i]; - - // Set heart drop inner heart color - cReg[0x3] = curColor; - cReg[0xB] = curColor; - - // Set heart drop outer heart color - kReg[0x3] = curColor; - kReg[0xB] = curColor; - - if (itemNo == dItemNo_KAKERA_HEART_e) { - cReg[0x13] = curColor; - cReg[0x1B] = curColor; - kReg[0x13] = curColor; - kReg[0x1B] = curColor; - } - if (itemNo == dItemNo_UTAWA_HEART_e) { - cReg[0x13] = curColor; - kReg[0x13] = curColor; - kReg[0x1B] = curColor; - kReg[0x23] = curColor; - kReg[0x2B] = curColor; - } - } - } - } -} - -// Midna Hair Color -DEFINE_HOOK(&daMidna_c::create, MidnaCreate); -void midna_create_post(ModContext*, void* args, void* retval, void*) { - auto step = reinterpret_cast(retval); - // Don't set colors if midna isn't done loading - if (*step != cPhs_COMPLEATE_e) { - return; - } - - auto midna = mods::arg(args, 0); - midna->field_0x6e0 = g_currentMidnaHairColors.normalColor; - if (dKy_darkworld_check()) { - midna->field_0x6e8 = g_currentMidnaHairColors.normalKColor; - midna->field_0x6ec = g_currentMidnaHairColors.normalKColor2; - } else { - midna->field_0x6e8 = g_currentMidnaHairColors.lNormalKColor; - midna->field_0x6ec = g_currentMidnaHairColors.lNormalKColor2; - } -} - -// Override Midna Hair Color Part 2 -DEFINE_HOOK(&daMidna_c::setBodyPartMatrix, MidnaSetBodyPartMatrix); - -static GXColorS10 midnaField0x6e0{}; -static GXColor midnaField0x6e8{}; -static GXColor midnaField0x6ec{}; - -// Copy the original values before setBodyPartMatrix runs -HookAction midna_set_body_part_matrix_pre(ModContext*, void* args, void* retval, void* userdata) { - auto midna = mods::arg(args, 0); - - midnaField0x6e0 = midna->field_0x6e0; - midnaField0x6e8 = midna->field_0x6e8; - midnaField0x6ec = midna->field_0x6ec; - - return HOOK_CONTINUE; -} - -void midna_set_body_part_matrix_post(ModContext*, void* args, void* retval, void* userdata) { - auto midna = mods::arg(args, 0); - if (midna->mpHairhandBmd != NULL) { - // Restore the original values from before setBodyPartMatrix ran (this undoes the chase) - midna->field_0x6e0 = midnaField0x6e0; - midna->field_0x6e8 = midnaField0x6e8; - midna->field_0x6ec = midnaField0x6ec; - - // Statement copied from inside function to determine colors - bool bigColors = - midna->checkStateFlg0(daMidna_c::FLG0_UNK_10000000) || - midna->mBckHeap[2].getIdx() == daMidna_c::m_anmDataTable[daMidna_c::ANM_HAIR].mResID || - midna->mBckHeap[2].getIdx() == - daMidna_c::m_anmDataTable[daMidna_c::ANM_S_TAKES].mResID || - midna->mBckHeap[2].getIdx() == - daMidna_c::m_anmDataTable[daMidna_c::ANM_S_WAITS].mResID || - midna->mBckHeap[2].getIdx() == - daMidna_c::m_anmDataTable[daMidna_c::ANM_S_PACKAWAY].mResID || - midna->mBckHeap[2].getIdx() == - daMidna_c::m_anmDataTable[daMidna_c::ANM_GRABST].mResID || - midna->checkEndResetStateFlg0(daMidna_c::ERFLG0_UNK_40) || - dComIfGp_checkPlayerStatus1(0, 0x800000); - - GXColorS10 color{}; - GXColor kcolor1{}; - GXColor kcolor2{}; - - // Set our own colors - if (bigColors) { - kcolor1 = g_currentMidnaHairColors.bigKColor; - if (dKy_darkworld_check()) { - color = g_currentMidnaHairColors.bigColor; - kcolor2 = g_currentMidnaHairColors.normalKColor2; - } else { - color = g_currentMidnaHairColors.lBigColor; - kcolor2 = g_currentMidnaHairColors.lBigKColor2; - } - } else { - color = g_currentMidnaHairColors.normalColor; - if (dKy_darkworld_check()) { - kcolor1 = g_currentMidnaHairColors.normalKColor; - kcolor2 = g_currentMidnaHairColors.normalKColor2; - } else { - kcolor1 = g_currentMidnaHairColors.lNormalKColor; - kcolor2 = g_currentMidnaHairColors.lNormalKColor2; - } - } - - // Reapply the chase that happens in the function - cLib_chaseS(&midna->field_0x6e0.r, color.r, 10); - cLib_chaseS(&midna->field_0x6e0.g, color.g, 10); - cLib_chaseS(&midna->field_0x6e0.b, color.b, 10); - cLib_chaseUC(&midna->field_0x6e8.r, kcolor1.r, 10); - cLib_chaseUC(&midna->field_0x6e8.g, kcolor1.g, 10); - cLib_chaseUC(&midna->field_0x6e8.b, kcolor1.b, 10); - cLib_chaseUC(&midna->field_0x6ec.r, kcolor2.r, 10); - cLib_chaseUC(&midna->field_0x6ec.g, kcolor2.g, 10); - cLib_chaseUC(&midna->field_0x6ec.b, kcolor2.b, 10); - } -} - -// Midna Charge Ring Color -DEFINE_HOOK(&daAlink_c::setWolfLockDomeModel, SetWolfLockDomeModel); -void wolf_lock_dome_model_post(ModContext*, void*, void*, void*) { - auto domeRingColorStr = get_str_option(get_cvars().midnaChargeRingColor, ""); - if (is_valid_hex_color_str(domeRingColorStr)) { - auto domeRingColor = hex_color_str_to_gx_color(domeRingColorStr); - const u8 domeWave1RGBA[3] = {domeRingColor.r, domeRingColor.g, domeRingColor.b}; - const u8 domeWave2RGBA[3] = {domeRingColor.r, domeRingColor.g, domeRingColor.b}; - u8** chromaRegisterTable = - reinterpret_cast(&daAlink_getAlinkActorClass()->field_0x0724->mAnmCRegDataR); - - for (int i = 0; i < 3; i++) { - u8* currentTable = chromaRegisterTable[i]; - const u8 currentWave1Color = domeWave1RGBA[i]; - const u8 currentWave2Color = domeWave2RGBA[i]; - const u8 currentBaseColor = (currentWave1Color + currentWave2Color) / 2; - - currentTable[0x3] = currentBaseColor; // Set Alpha for the ring base - currentTable[0x13] = currentWave1Color; // Set Alpha for ring wave 1 - currentTable[0x23] = currentWave2Color; // Set Alpha for ring wave 2 - currentTable[0xB] = currentBaseColor; // Set Alpha for darkworld ring base - currentTable[0x1B] = currentWave1Color; // Set Alpha for darkworld ring wave 1 - currentTable[0x2B] = currentWave2Color; // Set Alpha for darkworld ring wave 2 - } - } -} - -#define ADD_POST_HOOK(defined_hook, function, original) \ - result = mods::hook::add_post(function); \ - if (result != MOD_OK) { \ - mods::log::debug( \ - "failed to add post hook to" #original ", Result {}", static_cast(result)); \ - return result; \ - } - -#define ADD_PRE_HOOK(defined_hook, function, original) \ - result = mods::hook::add_pre(function); \ - if (result != MOD_OK) { \ - mods::log::debug( \ - "failed to add pre hook to" #original ", Result {}", static_cast(result)); \ - return result; \ - } - -ModResult add_all_hooks() { - ModResult result{}; - - // Hooks for lantern glow - ADD_POST_HOOK(WolfEyeLightSet, wolf_eye_light_set_post, dKy_WolfEyeLight_set) - ADD_POST_HOOK(PreKandelaarDraw, pre_kandelaar_draw_post, daAlink_c::preKandelaarDraw) - - // Hooks for lantern meter color - ADD_PRE_HOOK(CPaneMgrSetBlackWhite, cpane_mgr_set_black_white_pre, CPaneMgr::setBlackWhite) - ADD_POST_HOOK( - KanteraIconSetNowGauge, kantera_icon_set_now_gauge_post, dKantera_icon_c::setNowGauge) - - // Hook for midna charge ring - ADD_POST_HOOK(SetWolfLockDomeModel, wolf_lock_dome_model_post, daAlink_c::setWolfLockDomeModel) - - // Hook for light sword glow - ADD_POST_HOOK(SetLightningSwordEffect, set_lightning_sword_effect_post, - daAlink_c::setLightningSwordEffect) - - // Hooks for Midna Hair Color - ADD_POST_HOOK(MidnaCreate, midna_create_post, daMidna_c::create) - ADD_PRE_HOOK( - MidnaSetBodyPartMatrix, midna_set_body_part_matrix_pre, daMidna_c::setBodyPartMatrix) - ADD_POST_HOOK( - MidnaSetBodyPartMatrix, midna_set_body_part_matrix_post, daMidna_c::setBodyPartMatrix) - - // Hooks for UI colors - ADD_POST_HOOK(dMeter2Init, d_meter_2_init_post, dMeter2Draw_c::init) - ADD_POST_HOOK(FileInfoSetHeartCount, file_info_set_heart_count_post, dFile_info_c::setHeartCnt) - ADD_POST_HOOK(ScreenInitButton, screen_init_button_post, dMeterButton_c::screenInitButton) - ADD_POST_HOOK(MenuSaveScreenSet, menu_save_screen_set_post, dMenu_save_c::screenSet) - ADD_POST_HOOK(FileSelectScreenSet, file_select_screen_set_post, dFile_select_c::screenSet) - ADD_POST_HOOK(BrightCheckScreenSet, bright_check_screen_set_post, dBrightCheck_c::screenSet) - ADD_POST_HOOK(MenuRingCreate, menu_ring_create_post, dMenu_Ring_c::_create) - ADD_POST_HOOK(MenuCollect2DCreate, menu_collect_2D_create_post, dMenu_Collect2D_c::_create) - ADD_POST_HOOK(MenuFishingScreenSetDoIcon, menu_fishing_screen_set_do_icon_post, - dMenu_Fishing_c::screenSetDoIcon) - ADD_POST_HOOK(MenuInsectScreenSetDoIcon, menu_insect_screen_set_do_icon_post, - dMenu_Insect_c::screenSetDoIcon) - ADD_POST_HOOK(MenuLetterScreenSetDoIcon, menu_letter_screen_set_do_icon_post, - dMenu_Letter_c::screenSetDoIcon) - ADD_POST_HOOK(MenuOptionCreate, menu_option_create_post, dMenu_Option_c::_create) - ADD_POST_HOOK(MenuSkillScreenSetDoIcon, menu_skill_screen_set_do_icon_post, - dMenu_Skill_c::screenSetDoIcon) - ADD_POST_HOOK(OutFontCreatePane, out_font_create_pane_post, COutFont_c::createPane) - ADD_POST_HOOK(OutFontSetDrawFont, out_font_set_draw_font_post, COutFontSet_c::drawFont) - ADD_POST_HOOK(MenuFMapCreate, menu_fmap_create_post, dMenu_Fmap_c::_create) - ADD_POST_HOOK( - MsgObjectTalkStartInit, msg_object_talk_start_init_post, dMsgObject_c::talkStartInit) - ADD_POST_HOOK(MeterHakushaCreate, meter_hakusha_create_post, dMeterHakusha_c::_create) - - // Heart Model Color - ADD_POST_HOOK( - ItemBaseCreateItemHeap, item_base_create_item_heap_post, daItemBase_c::CreateItemHeap) - - return MOD_OK; -} - -#define UNINSTALL_HOOK(defined_hook) mods::hook::uninstall(svc_hook); - -ModResult remove_all_hooks() { - UNINSTALL_HOOK(WolfEyeLightSet) - UNINSTALL_HOOK(PreKandelaarDraw) - UNINSTALL_HOOK(CPaneMgrSetBlackWhite) - UNINSTALL_HOOK(KanteraIconSetNowGauge) - UNINSTALL_HOOK(SetWolfLockDomeModel) - UNINSTALL_HOOK(SetLightningSwordEffect) - UNINSTALL_HOOK(MidnaCreate) - UNINSTALL_HOOK(MidnaSetBodyPartMatrix) - UNINSTALL_HOOK(MidnaSetBodyPartMatrix) - UNINSTALL_HOOK(dMeter2Init) - UNINSTALL_HOOK(FileInfoSetHeartCount) - UNINSTALL_HOOK(ScreenInitButton) - UNINSTALL_HOOK(MenuSaveScreenSet) - UNINSTALL_HOOK(FileSelectScreenSet) - UNINSTALL_HOOK(BrightCheckScreenSet) - UNINSTALL_HOOK(MenuRingCreate) - UNINSTALL_HOOK(MenuCollect2DCreate) - UNINSTALL_HOOK(MenuFishingScreenSetDoIcon) - UNINSTALL_HOOK(MenuInsectScreenSetDoIcon) - UNINSTALL_HOOK(MenuLetterScreenSetDoIcon) - UNINSTALL_HOOK(MenuOptionCreate) - UNINSTALL_HOOK(MenuSkillScreenSetDoIcon) - UNINSTALL_HOOK(OutFontCreatePane) - UNINSTALL_HOOK(OutFontSetDrawFont) - UNINSTALL_HOOK(MenuFMapCreate) - UNINSTALL_HOOK(MsgObjectTalkStartInit) - UNINSTALL_HOOK(MeterHakushaCreate) - UNINSTALL_HOOK(ItemBaseCreateItemHeap) - return MOD_OK; -} diff --git a/mods/basic_cosmetics_mod/src/hooks.hpp b/mods/basic_cosmetics_mod/src/hooks.hpp deleted file mode 100644 index 62bb77cde9..0000000000 --- a/mods/basic_cosmetics_mod/src/hooks.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "mods/service.hpp" - -ModResult add_all_hooks(); - -ModResult remove_all_hooks(); \ No newline at end of file diff --git a/mods/basic_cosmetics_mod/src/midna_hair_color.cpp b/mods/basic_cosmetics_mod/src/midna_hair_color.cpp deleted file mode 100644 index 905a4345ff..0000000000 --- a/mods/basic_cosmetics_mod/src/midna_hair_color.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "midna_hair_color.hpp" -#include "mod.hpp" - -#include "mods/svc/log.hpp" - -#include - -namespace { -constexpr std::array, 10> kMidnaHairColors = {{ - // Default - {{ - /*l_lNormalKColor*/ /*l_normalKColor*/ /*l_normalColor*/ - {0xFF, 0xDC, 0x00}, {0xB4, 0x87, 0x00}, {0x50, 0x00, 0x00}, - /*l_bigKColor*/ /*l_lBigColor*/ /*l_bigColor*/ - {0x1E, 0x00, 0x00}, {0xFF, 0x78, 0x00}, {0xFF, 0x64, 0x78}, - /*l_lNormalKColor2*//*l_normalKColor2*/ /*l_lBigKColor2*/ - {0x00, 0xC3, 0xEB}, {0x00, 0xC3, 0xC3}, {0xAA, 0xFF, 0xC3} - }}, - // Pink - {{ - {0xF5, 0xCF, 0xF3}, {0xAD, 0x7F, 0x7F}, {0x1B, 0x00, 0x20}, - {0x3C, 0x02, 0x58}, {0xE3, 0x72, 0xF2}, {0xE3, 0x5F, 0xF8}, - {0xDD, 0x00, 0xEB}, {0xDD, 0x00, 0xC3}, {0xF6, 0x4C, 0xFF} - }}, - // Red - {{ - {0xE4, 0x65, 0x41}, {0xA1, 0x3E, 0x22}, {0x21, 0x00, 0x00}, - {0x4F, 0x02, 0x01}, {0xF0, 0x3A, 0x25}, {0xF0, 0x30, 0x8C}, - {0xEB, 0x00, 0x00}, {0xEB, 0x00, 0x00}, {0xFF, 0x4F, 0x3A} - }}, - // Yellow - {{ - {0x91, 0x83, 0x0E}, {0x66, 0x50, 0x07}, {0x0E, 0x0B, 0x00}, - {0x24, 0x25, 0x02}, {0xCB, 0xB7, 0x00}, {0xCB, 0x99, 0x78}, - {0xEB, 0xDE, 0x00}, {0xEB, 0xDE, 0x00}, {0xFF, 0xF8, 0xBF} - }}, - // Green - {{ - {0x35, 0x79, 0x53}, {0x25, 0x4A, 0x2B}, {0x00, 0x0E, 0x05}, - {0x0A, 0x29, 0x10}, {0x00, 0xB6, 0x6F}, {0x00, 0x98, 0xB3}, - {0x1F, 0xEB, 0x00}, {0x1F, 0xEB, 0x00}, {0x9A, 0xFF, 0x81} - }}, - // Blue - {{ - {0x00, 0x72, 0xFF}, {0x00, 0x46, 0x85}, {0x00, 0x08, 0x28}, - {0x16, 0x1B, 0x5D}, {0x00, 0x60, 0xFF}, {0x00, 0x50, 0xFF}, - {0x00, 0x48, 0xEB}, {0x00, 0x48, 0xC3}, {0x3A, 0x66, 0xFF} - }}, - // Purple - {{ - {0x6F, 0x34, 0xFF}, {0x4E, 0x20, 0x85}, {0x0D, 0x00, 0x34}, - {0x15, 0x08, 0x79}, {0x62, 0x00, 0xFF}, {0x62, 0x00, 0xFF}, - {0x7B, 0x00, 0xEB}, {0x7B, 0x00, 0xC3}, {0x94, 0x3E, 0xFF} - }}, - // Brown - {{ - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x1A, 0x05, 0x00}, - {0x3C, 0x19, 0x0E}, {0x3F, 0x1D, 0x0B}, {0x3F, 0x18, 0x7E}, - {0x3F, 0x1D, 0x0B}, {0x3F, 0x1D, 0x09}, {0x59, 0x32, 0x1E} - }}, - // White - {{ - {0xF0, 0xF1, 0xF1}, {0xA9, 0x94, 0x7E}, {0x09, 0x0B, 0x0C}, - {0x22, 0x24, 0x24}, {0xFF, 0xFF, 0xFF}, {0xFF, 0xD5, 0xFF}, - {0xEA, 0xEA, 0xEA}, {0xEA, 0xEA, 0xC2}, {0xF3, 0xF3, 0xF3} - }}, - // Black - {{ - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x0B, 0x0B, 0x0B}, - {0x23, 0x23, 0x23}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x78}, - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00} - }} -}}; - -size_t get_midna_hair_color_index(ConfigVarHandle handle) { - const auto optionIndex = get_int_option(handle, 0); - if (optionIndex < 0 || optionIndex >= static_cast(kMidnaHairColors.size())) { - return 0; - } - return static_cast(optionIndex); -} -} - -MidnaHairColors g_currentMidnaHairColors = { - .normalColor = {0x50, 0x00, 0x00, 0x00}, - .normalKColor = {0xB4, 0x87, 0x00, 0x00}, - .normalKColor2 = {0x00, 0xC3, 0xC3, 0x00}, - .bigColor = {0xFF, 0x64, 0x78, 0x00}, - .bigKColor = {0x1E, 0x00, 0x00, 0x00}, - .lNormalKColor = {0xFF, 0xDC, 0x00, 0x00}, - .lNormalKColor2 = {0x00, 0xC3, 0xEB, 0x00}, - .lBigColor = {0xFF, 0x78, 0x00, 0x00}, - .lBigKColor2 = {0xAA, 0xFF, 0xC3, 0x00}, -}; - -void set_all_midna_hair_colors() { - auto& g_cvars = get_cvars(); - auto hairBaseColor = get_midna_hair_color_index(g_cvars.midnaHairBaseColor); - auto hairTipsColor = get_midna_hair_color_index(g_cvars.midnaHairTipsColor); - - // Colors we have to convert to GXColorS10 - auto& normalColor = kMidnaHairColors.at(hairBaseColor)[2]; - auto& bigColor = kMidnaHairColors.at(hairBaseColor)[5]; - auto& lBigColor = kMidnaHairColors.at(hairBaseColor)[4]; - - g_currentMidnaHairColors.normalColor = GXColorS10{normalColor.r, normalColor.g, normalColor.b}; - g_currentMidnaHairColors.normalKColor = kMidnaHairColors.at(hairBaseColor)[1]; - g_currentMidnaHairColors.normalKColor2 = kMidnaHairColors.at(hairTipsColor)[7]; - g_currentMidnaHairColors.bigColor = GXColorS10{bigColor.r, bigColor.g, bigColor.b}; - g_currentMidnaHairColors.bigKColor = kMidnaHairColors.at(hairBaseColor)[3]; - g_currentMidnaHairColors.lNormalKColor = kMidnaHairColors.at(hairBaseColor)[0]; - g_currentMidnaHairColors.lNormalKColor2 = kMidnaHairColors.at(hairTipsColor)[6]; - g_currentMidnaHairColors.lBigColor = GXColorS10{lBigColor.r, lBigColor.g, lBigColor.b}; - g_currentMidnaHairColors.lBigKColor2 = kMidnaHairColors.at(hairTipsColor)[8]; -} diff --git a/mods/basic_cosmetics_mod/src/midna_hair_color.hpp b/mods/basic_cosmetics_mod/src/midna_hair_color.hpp deleted file mode 100644 index ad08f7c8c6..0000000000 --- a/mods/basic_cosmetics_mod/src/midna_hair_color.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include - -struct MidnaHairColors { - GXColorS10 normalColor; - GXColor normalKColor; - GXColor normalKColor2; - GXColorS10 bigColor; - GXColor bigKColor; - GXColor lNormalKColor; - GXColor lNormalKColor2; - GXColorS10 lBigColor; - GXColor lBigKColor2; -}; - -extern MidnaHairColors g_currentMidnaHairColors; - -void set_all_midna_hair_colors(); diff --git a/mods/basic_cosmetics_mod/src/mod.cpp b/mods/basic_cosmetics_mod/src/mod.cpp deleted file mode 100644 index 89a321da9c..0000000000 --- a/mods/basic_cosmetics_mod/src/mod.cpp +++ /dev/null @@ -1,653 +0,0 @@ -#include "mod.hpp" -#include "color_utils.hpp" -#include "hooks.hpp" -#include "midna_hair_color.hpp" -#include "texture_utils.hpp" - -#include "mods/service.hpp" -#include "mods/svc/config.h" -#include "mods/svc/hook.hpp" -#include "mods/svc/log.h" -#include "mods/svc/log.hpp" -#include "mods/svc/ui.h" - -#include "d/d_com_inf_game.h" - -#include - -#include -#include -#include - -DEFINE_MOD(); -IMPORT_SERVICE(LogService, svc_log); -IMPORT_SERVICE(ConfigService, svc_config); -IMPORT_SERVICE(HookService, svc_hook); -IMPORT_SERVICE(TextureService, svc_texture); -IMPORT_SERVICE(UiService, svc_ui); - -static cvars g_cvars; - -cvars& get_cvars() { - return g_cvars; -} - -std::string get_str_option(ConfigVarHandle handle, const std::string& fallback) { - std::string value{}; - size_t outLength{}; - svc_config->get_string(mod_ctx, handle, NULL, 0, &outLength); - value.resize(outLength); - if (handle == 0 || svc_config->get_string( - mod_ctx, handle, value.data(), value.size() + 1, &outLength) != MOD_OK) - { - return fallback; - } - return value; -} - -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; -} - -// Helper for getting configVar color -std::optional get_config_var_color(ConfigVarHandle handle, bool allowRainbow) { - auto colorStr = get_str_option(handle, ""); - // Convert to lowercase - for (auto& c : colorStr) { - c = static_cast(std::tolower(static_cast(c))); - } - if (colorStr == "rainbow" && allowRainbow) { - auto color = get_rainbow_rgb(127.5f); - color.r /= 2; - color.g /= 2; - color.b /= 2; - return color; - } - if (is_valid_hex_color_str(colorStr)) { - return hex_color_str_to_gx_color(colorStr); - } - return std::nullopt; -} - -namespace { -UiWindowHandle g_cosmeticsWindow = 0; -bool g_loadedAllBaseTextures = false; -constexpr uint32_t kTextureLoadRetryFrames = 30; -uint32_t g_textureLoadRetryCountdown = 0; - -constexpr const char* kOverlayPresets[] = { - "ab706e", - "6382a0", - "94749a", - "ec8644", - "b9ab00", - "ec9fc8", - "505154", - "f8f7f4", - "91723e", -}; - -constexpr const char* kLightPresets[] = { - "ff0000", - "f68821", - "f6f321", - "00ff00", - "0000ff", - "8000ff", - "a0a0a0", - "30d0d0", -}; - -constexpr const char* kRainbowLightPresets[] = { - "rainbow", - "ff0000", - "f68821", - "f6f321", - "00ff00", - "0000ff", - "8000ff", - "a0a0a0", -}; - -constexpr const char* kAButtonPresets[] = { - "ff0000", - "ff5000", - "ffaf00", - "0080ff", - "0000ff", - "8000ff", - "5555ff", - "ff20ff", -}; - -constexpr const char* kBButtonPresets[] = { - "ffff40", - "ffa0ff", - "00e87b", - "00aaff", - "6078ff", - "000000", - "00f3ff", -}; - -constexpr const char* kXyButtonPresets[] = { - "ff0000", - "ff8200", - "f7df00", - "70ff00", - "00bd11", - "0000ff", - "800088", - "000000", - "ff00aa", - "00ffff", -}; - -constexpr const char* kZButtonPresets[] = { - "ff0000", - "ff8200", - "f7df00", - "70ff00", - "00bd11", - "800088", - "000000", - "00ffff", -}; - -constexpr const char* kChargeRingPresets[] = { - "ff9f9f", - "ff0000", - "ffff00", - "00ff00", - "0000ff", - "ff00ff", - "331900", - "feffff", - "000000", -}; - -ModResult register_str_option( - const char* name, const char* defaultValue, ConfigVarHandle& outHandle, ModError* error) { - ConfigVarDesc cvarDesc = CONFIG_VAR_DESC_INIT; - cvarDesc.name = name; - cvarDesc.type = CONFIG_VAR_STRING; - cvarDesc.default_string = defaultValue; - if (svc_config->register_var(mod_ctx, &cvarDesc, &outHandle) != MOD_OK) { - return mods::set_error(error, MOD_ERROR, "failed to register cosmetics 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 cosmetics option"); - } - return MOD_OK; -} - -void add_control(UiElementHandle pane, const UiControlDesc& desc) { - auto result = svc_ui->pane_add_control(mod_ctx, pane, &desc, nullptr); - if (result != MOD_OK) { - mods::log::debug("pane_add_control failed {}", static_cast(result)); - } -} - -template -void add_cosmetic_option( - UiElementHandle pane, ConfigVarHandle cvar, const char* name, const char* const (&presets)[N]) { - UiControlDesc control = UI_CONTROL_DESC_INIT; - control.kind = UI_CONTROL_COLOR; - control.label = name; - control.binding = UI_BINDING_CONFIG_VAR; - control.config_var = cvar; - control.color_presets = presets; - control.color_preset_count = N; - add_control(pane, control); -} - -void add_midna_hair_option(UiElementHandle left, ConfigVarHandle cvar, const std::string& name) { - static const char* kMidnaHairOptions[] = { - "Default", "Pink", "Red", "Yellow", "Green", "Blue", "Purple", "Brown", "White", "Black"}; - UiControlDesc control = UI_CONTROL_DESC_INIT; - control.kind = UI_CONTROL_SELECT; - control.label = name.c_str(); - control.help_rml = "Choose Midna's hair color."; - control.binding = UI_BINDING_CONFIG_VAR; - control.config_var = cvar; - control.options = kMidnaHairOptions; - control.option_count = 10; - add_control(left, control); -} - -void add_group( - UiElementHandle groups, UiElementHandle colors, const char* label, UiGroupBuildFn build) { - UiGroupDesc group = UI_GROUP_DESC_INIT; - group.label = label; - group.build = build; - const auto result = svc_ui->pane_add_group(mod_ctx, groups, colors, &group, nullptr); - if (result != MOD_OK) { - mods::log::debug("pane_add_group failed {}", static_cast(result)); - } -} - -ModResult build_hero_tunic_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Hero's Tunic"); - add_cosmetic_option(pane, g_cvars.herosTunicCapColor, "Cap", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.herosTunicTorsoColor, "Body", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.herosTunicSkirtColor, "Skirt", kOverlayPresets); - return MOD_OK; -} - -ModResult build_zora_armor_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Zora Armor"); - add_cosmetic_option(pane, g_cvars.zoraArmorCapColor, "Cap", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.zoraArmorHelmetColor, "Helmet", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.zoraArmorTorsoColor, "Torso", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.zoraArmorScalesColor, "Scales", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.zoraArmorFlippersColor, "Flippers", kOverlayPresets); - return MOD_OK; -} - -ModResult build_sword_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Swords"); - add_cosmetic_option(pane, g_cvars.woodenSwordColor, "Wooden Sword", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.ordonSwordBladeColor, "Ordon Blade", kLightPresets); - add_cosmetic_option(pane, g_cvars.ordonSwordHandleColor, "Ordon Handle", kLightPresets); - add_cosmetic_option(pane, g_cvars.msBladeColor, "Master Sword Blade", kLightPresets); - add_cosmetic_option(pane, g_cvars.msHandleColor, "Master Sword Handle", kLightPresets); - add_cosmetic_option( - pane, g_cvars.lightSwordGlowColor, "Light Sword Glow", kRainbowLightPresets); - return MOD_OK; -} - -ModResult build_equipment_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Equipment"); - add_cosmetic_option(pane, g_cvars.lanternGlowColor, "Lantern Glow", kRainbowLightPresets); - add_cosmetic_option(pane, g_cvars.boomerangColor, "Gale Boomerang", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.ironBootsColor, "Iron Boots", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.spinnerColor, "Spinner", kOverlayPresets); - return MOD_OK; -} - -ModResult build_button_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Buttons"); - add_cosmetic_option(pane, g_cvars.aButtonColor, "A Button", kAButtonPresets); - add_cosmetic_option(pane, g_cvars.bButtonColor, "B Button", kBButtonPresets); - add_cosmetic_option(pane, g_cvars.xButtonColor, "X Button", kXyButtonPresets); - add_cosmetic_option(pane, g_cvars.yButtonColor, "Y Button", kXyButtonPresets); - add_cosmetic_option(pane, g_cvars.zButtonColor, "Z Button", kZButtonPresets); - return MOD_OK; -} - -ModResult build_hud_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "HUD"); - add_cosmetic_option(pane, g_cvars.heartColor, "Hearts", kBButtonPresets); - return MOD_OK; -} - -ModResult build_link_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Link"); - add_cosmetic_option(pane, g_cvars.linkHairColor, "Hair", kOverlayPresets); - return MOD_OK; -} - -ModResult build_midna_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Midna"); - add_cosmetic_option(pane, g_cvars.midnaChargeRingColor, "Charge Ring", kChargeRingPresets); - return MOD_OK; -} - -ModResult build_companion_colors(ModContext*, UiElementHandle pane, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, pane, "Companions"); - add_cosmetic_option(pane, g_cvars.wolfLinkColor, "Wolf Link", kOverlayPresets); - add_cosmetic_option(pane, g_cvars.eponaColor, "Epona", kOverlayPresets); - return MOD_OK; -} - -ModResult build_equipment_colors_tab( - ModContext*, UiWindowHandle, UiElementHandle left, UiElementHandle right, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, left, "Color Groups"); - add_group(left, right, "Hero's Tunic", build_hero_tunic_colors); - add_group(left, right, "Zora Armor", build_zora_armor_colors); - add_group(left, right, "Swords", build_sword_colors); - add_group(left, right, "Equipment", build_equipment_colors); - - return MOD_OK; -} - -ModResult build_ui_colors_tab( - ModContext*, UiWindowHandle, UiElementHandle left, UiElementHandle right, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, left, "Color Groups"); - add_group(left, right, "Buttons", build_button_colors); - add_group(left, right, "HUD", build_hud_colors); - - return MOD_OK; -} - -ModResult build_misc_colors_tab( - ModContext*, UiWindowHandle, UiElementHandle left, UiElementHandle right, void*, ModError*) { - svc_ui->pane_add_section(mod_ctx, left, "Hair Presets"); - add_midna_hair_option(left, g_cvars.midnaHairBaseColor, "Midna's Hair Base Color"); - add_midna_hair_option(left, g_cvars.midnaHairTipsColor, "Midna's Hair Tips Color"); - svc_ui->pane_add_section(mod_ctx, left, "Color Groups"); - add_group(left, right, "Link", build_link_colors); - add_group(left, right, "Midna", build_midna_colors); - add_group(left, right, "Companions", build_companion_colors); - - return MOD_OK; -} - -void on_cosmetics_menu_window_closed(ModContext*, UiWindowHandle, void*) { - g_cosmeticsWindow = 0; -} - -void on_open_cosmetics_menu(ModContext*, void*) { - if (g_cosmeticsWindow != 0) { - return; - } - UiTabDesc tabs[] = {UI_TAB_DESC_INIT, UI_TAB_DESC_INIT, UI_TAB_DESC_INIT}; - tabs[0].title = "Equipment"; - tabs[0].build = build_equipment_colors_tab; - tabs[1].title = "Interface"; - tabs[1].build = build_ui_colors_tab; - tabs[2].title = "Characters"; - tabs[2].build = build_misc_colors_tab; - UiWindowDesc desc = UI_WINDOW_DESC_INIT; - desc.tabs = tabs; - desc.tab_count = ARRAY_SIZE(tabs); - desc.on_closed = on_cosmetics_menu_window_closed; - if (svc_ui->window_push(mod_ctx, &desc, &g_cosmeticsWindow) != MOD_OK) { - svc_log->error(mod_ctx, "failed to open basic cosmetics window"); - } -} - -ModResult build_panel(ModContext*, UiElementHandle panel, void*, ModError*) { - UiControlDesc control = UI_CONTROL_DESC_INIT; - control.kind = UI_CONTROL_GROUP; - control.label = "Open Cosmetics Menu"; - control.on_pressed = on_open_cosmetics_menu; - add_control(panel, control); - return MOD_OK; -} -} // namespace - -void load_base_texture_data() { - // Go through each texture we can recolor and attempt to load and store - // the texture data for future recoloring - for (auto& replacements : get_texture_replacements() | std::views::values) { - for (auto& replacement : replacements) { - // If we've already loaded the texture data, don't load it again - if (replacement.loadedTextureData) { - continue; - } - - // Avoid noisy resource lookups until the archive has finished loading. - auto* resInfo = dComIfG_getObjectResInfo(replacement.arc); - if (resInfo == nullptr || resInfo->getArchive() == nullptr) { - continue; - } - - // Try to get the model this texture is part of. If we can't get it, try again later - auto model = static_cast( - dComIfG_getObjectRes(replacement.arc, replacement.modelFileName)); - if (model == nullptr) { - continue; - } - - J3DTexture* tex = model->getTexture(); - JUTNameTab* nametable = model->getTextureName(); - if (tex != nullptr && nametable != nullptr) { - for (u16 i = 0; i < tex->getNum(); i++) { - const char* texName = nametable->getName(i); - if (texName != nullptr && std::strcmp(texName, replacement.textureName) == 0) { - // Once we've found the texture, set all our TextureKey and TextureData - // fields that we can set right now. - auto imageHeader = tex->getResTIMG(i); - auto& key = replacement.key; - auto& data = replacement.data; - key.kind = TEXTURE_KEY_SOURCE; - key.has_tlut = imageHeader->numColors > 0; - key.width = imageHeader->width; - key.height = imageHeader->height; - key.gx_format = imageHeader->format; - - // Currently, no replaced textures have a tlut - key.tlut_hash = replacement.tlutHash; - - // Calculate the size of the image data - const uint32_t mipCount = - imageHeader->mipmapEnabled ? - std::max(imageHeader->mipmapCount, 1) : - 1; - auto size = get_image_data_size( - imageHeader->format, imageHeader->width, imageHeader->height, mipCount); - replacement.baseTextureData.resize(size); - std::memcpy( - replacement.baseTextureData.data(), tex->getImgDataPtr(i), size); - - // Source texture keys hash only the base mip level. - const auto baseMipSize = get_image_data_size( - imageHeader->format, imageHeader->width, imageHeader->height, 1); - auto textureHash = - XXH64(replacement.baseTextureData.data(), baseMipSize, 0); - replacement.key.texture_hash = textureHash; - - mods::log::debug("Loaded base texture data for {}. size: {:X} hash: {:X}", - replacement.textureName, size, textureHash); - replacement.loadedTextureData = true; - - data.width = imageHeader->width; - data.height = imageHeader->height; - data.mip_count = mipCount; - data.size = size; - data.gx_format = imageHeader->format; - - break; - } - } - } - } - } - - // If we've loaded all base textures for recoloring, then we don't need to call this function - // again - g_loadedAllBaseTextures = std::ranges::all_of( - get_texture_replacements() | std::views::values, [](auto& replacementList) { - return std::ranges::all_of( - replacementList, [](const TextureReplacementData& replacement) { - return replacement.loadedTextureData; - }); - }); -} - -ModResult check_and_set_recolored_textures() { - for (auto& [configVar, replacements] : get_texture_replacements()) { - // If the configvar hasn't been set, don't continue - if (configVar == 0) { - continue; - } - - auto maybeColor = get_config_var_color(configVar); - if (!maybeColor.has_value()) { - // An empty or invalid option means the original texture should be restored. - for (auto& replacement : replacements) { - if (replacement.handle != 0) { - auto result = svc_texture->unregister(mod_ctx, replacement.handle); - if (result != MOD_OK) { - mods::log::debug("Could not unregister replacement for {}. Result: {}", - replacement.textureName, static_cast(result)); - } - replacement.handle = 0; - } - replacement.curColor.reset(); - } - continue; - } - - auto color = maybeColor.value(); - for (auto& replacement : replacements) { - // If we haven't loaded the base texture yet, don't try to recolor it - if (!replacement.loadedTextureData) { - continue; - } - - // If our color hasn't changed, don't try to recolor - auto& curColor = replacement.curColor; - if (curColor == std::nullopt || curColor.value().r != color.r || - curColor.value().g != color.g || curColor.value().b != color.b) - { - // Make a copy of the base texture data to recolor - auto newTexture = replacement.baseTextureData; - recolor_texture(replacement, color, newTexture); - - TextureData newTextureData = replacement.data; - newTextureData.data = newTexture.data(); - newTextureData.size = newTexture.size(); - - // Keep the current replacement active if registering the new one fails. - TextureReplacementHandle newHandle{}; - auto result = svc_texture->register_data( - mod_ctx, &replacement.key, &newTextureData, &newHandle); - if (result != MOD_OK) { - mods::log::debug("Could not register_data for {}. Result: {}", - replacement.textureName, static_cast(result)); - } else { - mods::log::debug("Registered replacement for {}.", replacement.textureName, - static_cast(result)); - auto oldHandle = replacement.handle; - replacement.handle = newHandle; - curColor = color; - - if (oldHandle != 0) { - result = svc_texture->unregister(mod_ctx, oldHandle); - if (result != MOD_OK) { - mods::log::debug( - "Could not unregister previous replacement for {}. Result: {}", - replacement.textureName, static_cast(result)); - } - } - } - } - } - } - - return MOD_OK; -} - -void unregister_all_texture_handles() { - for (auto& replacements : get_texture_replacements() | std::views::values) { - for (auto& replacement : replacements) { - if (replacement.handle != 0) { - svc_texture->unregister(mod_ctx, replacement.handle); - replacement.handle = 0; - } - replacement.curColor.reset(); - } - } -} - -#define REGISTER_COSMETIC_OPTION(option) \ - result = register_str_option(#option, NULL, g_cvars.option, error); \ - if (result != MOD_OK) { \ - return result; \ - } - -extern "C" { -MOD_EXPORT ModResult mod_initialize(ModError* error) { - svc_log->info(mod_ctx, "basic_cosmetics_mod initialized"); - - ModResult result{}; - - REGISTER_COSMETIC_OPTION(herosTunicCapColor) - REGISTER_COSMETIC_OPTION(herosTunicTorsoColor) - REGISTER_COSMETIC_OPTION(herosTunicSkirtColor) - REGISTER_COSMETIC_OPTION(zoraArmorCapColor) - REGISTER_COSMETIC_OPTION(zoraArmorHelmetColor) - REGISTER_COSMETIC_OPTION(zoraArmorTorsoColor) - REGISTER_COSMETIC_OPTION(zoraArmorScalesColor) - REGISTER_COSMETIC_OPTION(zoraArmorFlippersColor) - REGISTER_COSMETIC_OPTION(lanternGlowColor) - REGISTER_COSMETIC_OPTION(woodenSwordColor) - REGISTER_COSMETIC_OPTION(ordonSwordBladeColor) - REGISTER_COSMETIC_OPTION(ordonSwordHandleColor) - REGISTER_COSMETIC_OPTION(msBladeColor) - REGISTER_COSMETIC_OPTION(msHandleColor) - REGISTER_COSMETIC_OPTION(lightSwordGlowColor) - REGISTER_COSMETIC_OPTION(boomerangColor) - REGISTER_COSMETIC_OPTION(ironBootsColor) - REGISTER_COSMETIC_OPTION(spinnerColor) - REGISTER_COSMETIC_OPTION(aButtonColor) - REGISTER_COSMETIC_OPTION(bButtonColor) - REGISTER_COSMETIC_OPTION(xButtonColor) - REGISTER_COSMETIC_OPTION(yButtonColor) - REGISTER_COSMETIC_OPTION(zButtonColor) - REGISTER_COSMETIC_OPTION(heartColor) - - result = register_int_option("midnaHairBaseColor", 0, g_cvars.midnaHairBaseColor, error); - if (result != MOD_OK) { - return result; - } - - result = register_int_option("midnaHairTipsColor", 0, g_cvars.midnaHairTipsColor, error); - if (result != MOD_OK) { - return result; - } - - REGISTER_COSMETIC_OPTION(midnaChargeRingColor) - REGISTER_COSMETIC_OPTION(linkHairColor) - REGISTER_COSMETIC_OPTION(wolfLinkColor) - REGISTER_COSMETIC_OPTION(eponaColor) - - UiModsPanelDesc panelDesc = UI_MODS_PANEL_DESC_INIT; - panelDesc.build = build_panel; - svc_ui->register_mods_panel(mod_ctx, &panelDesc); - - // Add all our hooks - result = add_all_hooks(); - if (result != MOD_OK) { - return result; - } - - g_loadedAllBaseTextures = false; - g_textureLoadRetryCountdown = 0; - return MOD_OK; -} - -MOD_EXPORT ModResult mod_update(ModError*) { - update_rainbow_rgb(1.0f); - set_all_midna_hair_colors(); - - if (!g_loadedAllBaseTextures) { - if (g_textureLoadRetryCountdown == 0) { - load_base_texture_data(); - g_textureLoadRetryCountdown = kTextureLoadRetryFrames; - } else { - --g_textureLoadRetryCountdown; - } - } - - check_and_set_recolored_textures(); - - return MOD_OK; -} - -MOD_EXPORT ModResult mod_shutdown(ModError*) { - svc_log->info(mod_ctx, "basic_cosmetics_mod unloaded"); - g_cosmeticsWindow = 0; - remove_all_hooks(); - unregister_all_texture_handles(); - get_texture_replacements().clear(); - g_loadedAllBaseTextures = false; - g_textureLoadRetryCountdown = 0; - return MOD_OK; -} -} diff --git a/mods/basic_cosmetics_mod/src/mod.hpp b/mods/basic_cosmetics_mod/src/mod.hpp deleted file mode 100644 index 6d77949b03..0000000000 --- a/mods/basic_cosmetics_mod/src/mod.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include "mods/svc/config.h" -#include "mods/svc/texture.h" - -#include - -#include -#include -#include - -struct cvars { - ConfigVarHandle herosTunicCapColor = 0; - ConfigVarHandle herosTunicTorsoColor = 0; - ConfigVarHandle herosTunicSkirtColor = 0; - ConfigVarHandle zoraArmorCapColor = 0; - ConfigVarHandle zoraArmorHelmetColor = 0; - ConfigVarHandle zoraArmorTorsoColor = 0; - ConfigVarHandle zoraArmorScalesColor = 0; - ConfigVarHandle zoraArmorFlippersColor = 0; - ConfigVarHandle lanternGlowColor = 0; - ConfigVarHandle woodenSwordColor = 0; - ConfigVarHandle ordonSwordBladeColor = 0; - ConfigVarHandle ordonSwordHandleColor = 0; - ConfigVarHandle msBladeColor = 0; - ConfigVarHandle msHandleColor = 0; - ConfigVarHandle lightSwordGlowColor = 0; - ConfigVarHandle boomerangColor = 0; - ConfigVarHandle ironBootsColor = 0; - ConfigVarHandle spinnerColor = 0; - ConfigVarHandle heartColor = 0; - ConfigVarHandle aButtonColor = 0; - ConfigVarHandle bButtonColor = 0; - ConfigVarHandle xButtonColor = 0; - ConfigVarHandle yButtonColor = 0; - ConfigVarHandle zButtonColor = 0; - ConfigVarHandle midnaHairBaseColor = 0; - ConfigVarHandle midnaHairTipsColor = 0; - ConfigVarHandle midnaChargeRingColor = 0; - ConfigVarHandle linkHairColor = 0; - ConfigVarHandle wolfLinkColor = 0; - ConfigVarHandle eponaColor = 0; -}; - -struct TextureReplacementData { - const char* arc{}; - const char* modelFileName{}; - const char* textureName{}; - uint64_t textureHash{}; - uint64_t tlutHash{}; - TextureKey key = TEXTURE_KEY_INIT; - TextureData data = TEXTURE_DATA_INIT; - TextureReplacementHandle handle{}; - std::vector baseTextureData{}; - bool loadedTextureData = false; - std::optional curColor{}; -}; - -cvars& get_cvars(); - -std::string get_str_option(ConfigVarHandle handle, const std::string& fallback); - -int64_t get_int_option(ConfigVarHandle handle, int64_t fallback); - -std::optional get_config_var_color(ConfigVarHandle handle, bool allowRainbow = false); \ No newline at end of file diff --git a/mods/basic_cosmetics_mod/src/texture_utils.cpp b/mods/basic_cosmetics_mod/src/texture_utils.cpp deleted file mode 100644 index 98c60dbad3..0000000000 --- a/mods/basic_cosmetics_mod/src/texture_utils.cpp +++ /dev/null @@ -1,682 +0,0 @@ -#include "texture_utils.hpp" -#include "color_utils.hpp" -#include "mod.hpp" - -#include "mods/svc/config.h" -#include "mods/svc/log.hpp" - -#include "JSystem/J3DGraphLoader/J3DModelLoader.h" -#include "JSystem/JSupport/JSupport.h" -#include "JSystem/JUtility/JUTNameTab.h" -#include "d/actor/d_a_alink.h" - -static void get_gx_tile_info(uint8_t format, uint32_t& tileWidth, uint32_t& tileHeight, uint32_t& tileSize) { - switch (format) { - case GX_TF_I8: - case GX_TF_IA4: - case GX_TF_C8: - tileWidth = 8; tileHeight = 4; tileSize = 32; - break; - case GX_TF_IA8: - case GX_TF_RGB565: - case GX_TF_RGB5A3: - case GX_TF_C14X2: - tileWidth = 4; tileHeight = 4; tileSize = 32; - break; - case GX_TF_RGBA8: - tileWidth = 4; tileHeight = 4; tileSize = 64; - break; - case GX_TF_I4: - case GX_TF_C4: - case GX_TF_CMPR: - default: - tileWidth = 8; tileHeight = 8; tileSize = 32; - break; - } -} - -uint32_t get_image_data_size(uint32_t format, uint32_t width, uint32_t height, uint32_t mipmapCount) { - - uint32_t tileWidth, tileHeight, tileSize; - get_gx_tile_info(format, tileWidth, tileHeight, tileSize); - - uint32_t totalSize = 0; - - for (uint8_t i = 0; i < mipmapCount; ++i) { - // Round dimensions up to nearest tile boundary - uint32_t paddedWidth = (width + tileWidth - 1) & ~(tileWidth - 1); - uint32_t paddedHeight = (height + tileHeight - 1) & ~(tileHeight - 1); - - uint32_t tilesX = paddedWidth / tileWidth; - uint32_t tilesY = paddedHeight / tileHeight; - - totalSize += tilesX * tilesY * tileSize; - - // Downscale dimensions for next mipmap level - width = std::max(1u, width >> 1); - height = std::max(1u, height >> 1); - } - - return totalSize; -} - -// When left is greater than right -// 0b00 points to the left color -// 0b01 points to the right color -// 0b10 is closer to left color -// 0b11 is closer to right color - -// When left is not greater than right -// 0b00 points to the left color -// 0b01 points to the right color -// 0b10 is midway between the colors -// 0b11 is transparent - -// That means when maintaining the relative order, if we have to swap the colors: - -// in the case of left being greater than right: -// 0b00 will swap to 0b01 -// 0b01 will swap to 0b00 -// 0b10 will swap to 0b11 -// 0b11 will swap to 0b10 -// So the left bit stays the same, and the right bit changes -// Can do xor (^) like 0b01010101 or 0x55 for each u16 - -// in the case of left not being greater than right: -// 0b00 will swap to 0b01 -// 0b01 will swap to 0b00 -// 0b10 will stay the same -// 0b11 will stay the same -// so if the left bit is a 0, the right bit will change -uint32_t swap_index_bits(bool leftIsGreater, uint32_t bits) { - if (leftIsGreater) { - return bits ^ 0x55555555; - } - - const uint32_t mask = ((bits >> 1) & 0x55555555) ^ 0x55555555; - return bits ^ mask; -} - -void recolor_cmpr_texture(const TextureReplacementData& replacementData, const GXColor color, std::vector& newTextureDataOut) -{ - uint16_t recolors[0x100]; - for (int32_t i = 0; i < 0x100; i++) { - recolors[i] = blend_overlay_rgb_565(i, color); - } - - const uint8_t mipCount = (replacementData.data.mip_count > 0) ? replacementData.data.mip_count : 1; - uint32_t mipWidth = replacementData.key.width; - uint32_t mipHeight = replacementData.key.height; - - uint8_t* currentAddr = newTextureDataOut.data(); - - for (uint8_t mip = 0; mip < mipCount; ++mip) { - // Round dimensions up to the nearest 8x8 tile boundary - const uint32_t roundedWidth = (mipWidth + 7) & ~7; - const uint32_t roundedHeight = (mipHeight + 7) & ~7; - - const uint32_t numBlocks = (roundedWidth / 8) * (roundedHeight / 8); - const uint32_t iterations = numBlocks * 4; // 4 CMPR sub-blocks per 8x8 tile - - for (uint32_t i = 0; i < iterations; i++) { - auto* rgb565Ptr = reinterpret_cast*>(currentAddr); - - auto leftRgb565 = rgb565Ptr[0]; - auto rightRgb565 = rgb565Ptr[1]; - const bool leftIsGreater = leftRgb565 > rightRgb565; - - const uint32_t leftGrayVal = desaturate_rgb_565(leftRgb565); - const uint32_t rightGrayVal = desaturate_rgb_565(rightRgb565); - - uint16_t leftNewRgb565 = recolors[leftGrayVal]; - uint16_t rightNewRgb565 = recolors[rightGrayVal]; - - bool needsBitSwap = false; - - if (leftIsGreater) { - if (leftNewRgb565 == rightNewRgb565) { - // Need to make sure that subtracting 1 does not mess - // everything up. For example, 0x1000 - 1 => 0x0fff which is - // a completely different color. - if ((leftNewRgb565 & 0x1f) == 0) { - // If left value has 0 blue, we change its blue to 1. - leftNewRgb565 += 1; - } - rightNewRgb565 = leftNewRgb565 - 1; - } - else if (leftNewRgb565 < rightNewRgb565) { - needsBitSwap = true; - } - } - else if (leftNewRgb565 > rightNewRgb565) { - needsBitSwap = true; - } - - if (needsBitSwap) { - // The left and right colors are swapping so that their values - // are relative in the same way. We need to update the bits - // referencing the palette entries to handle the swap. - const uint16_t temp = leftNewRgb565; - leftNewRgb565 = rightNewRgb565; - rightNewRgb565 = temp; - - auto wordPtr = reinterpret_cast*>(currentAddr); - const uint32_t bits = wordPtr[1]; - - const uint32_t newBits = swap_index_bits(leftIsGreater, bits); - wordPtr[1] = newBits; - } - - rgb565Ptr[0] = leftNewRgb565; - rgb565Ptr[1] = rightNewRgb565; - - currentAddr += 8; - } - - // Halve dimensions for the next mipmap level - mipWidth = std::max(1u, mipWidth >> 1); - mipHeight = std::max(1u, mipHeight >> 1); - } -} - -void recolor_rgb5a3_texture(const TextureReplacementData& replacementData, const GXColor color, std::vector& newTextureDataOut) -{ - // Precompute lookup tables for both RGB555 (opaque) and RGB444 (translucent) modes - uint16_t recolors_rgb555[0x100]; - uint16_t recolors_rgb444[0x100]; - - for (int32_t i = 0; i < 0x100; i++) { - const uint8_t r = blend_overlay_channel(i, color.r); - const uint8_t g = blend_overlay_channel(i, color.g); - const uint8_t b = blend_overlay_channel(i, color.b); - - // Pack as RGB555: Bit 15 set to 1 + 5 bits R, G, B - recolors_rgb555[i] = 0x8000 | ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); - - // Pack as RGB444: 4 bits R, G, B (Bit 15 remains 0) - recolors_rgb444[i] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4); - } - - const uint8_t mipCount = - replacementData.data.mip_count > 0 ? replacementData.data.mip_count : 1; - uint32_t mipWidth = replacementData.key.width; - uint32_t mipHeight = replacementData.key.height; - auto* pixelPtr = reinterpret_cast*>(newTextureDataOut.data()); - - for (uint8_t mip = 0; mip < mipCount; ++mip) { - const uint32_t roundedWidth = (mipWidth + 3) & ~3; - const uint32_t roundedHeight = (mipHeight + 3) & ~3; - const uint32_t totalPixels = roundedWidth * roundedHeight; - - for (uint32_t i = 0; i < totalPixels; i++) { - const uint16_t rawPixel = pixelPtr[i]; - - // MSB determines if pixel is opaque or translucent - if (rawPixel & 0x8000) { - // Pixel is opaque - const uint8_t r5 = (rawPixel >> 10) & 0x1F; - const uint8_t g5 = (rawPixel >> 5) & 0x1F; - const uint8_t b5 = rawPixel & 0x1F; - - // Expand 5-bit to 8-bit - const uint8_t r8 = (r5 << 3) | (r5 >> 2); - const uint8_t g8 = (g5 << 3) | (g5 >> 2); - const uint8_t b8 = (b5 << 3) | (b5 >> 2); - - const uint8_t grayVal = static_cast((r8 * 77 + g8 * 150 + b8 * 29) >> 8); - - pixelPtr[i] = recolors_rgb555[grayVal]; - } else { - // Pixel is translucent - const uint16_t alpha3 = rawPixel & 0x7000; - - const uint8_t r4 = (rawPixel >> 8) & 0x0F; - const uint8_t g4 = (rawPixel >> 4) & 0x0F; - const uint8_t b4 = rawPixel & 0x0F; - - // Expand 4-bit to 8-bit - const uint8_t r8 = (r4 << 4) | r4; - const uint8_t g8 = (g4 << 4) | g4; - const uint8_t b8 = (b4 << 4) | b4; - - const uint8_t grayVal = static_cast((r8 * 77 + g8 * 150 + b8 * 29) >> 8); - - // Combine original alpha with recolored RGB444 - pixelPtr[i] = alpha3 | recolors_rgb444[grayVal]; - } - } - - pixelPtr += totalPixels; - mipWidth = std::max(1u, mipWidth >> 1); - mipHeight = std::max(1u, mipHeight >> 1); - } -} - -// Function to encode a single 4x4 sub-block (16 pixels) into an 8-byte CMPR block -static void encode_cmpr_sub_block(uint8_t* dst, const uint8_t pixels[16]) { - uint8_t min_val = 255; - uint8_t max_val = 0; - - for (int i = 0; i < 16; ++i) { - if (pixels[i] < min_val) min_val = pixels[i]; - if (pixels[i] > max_val) max_val = pixels[i]; - } - - auto intensity_to_rgb565 = [](uint8_t val) -> uint16_t { - uint16_t r5 = val >> 3; - uint16_t g6 = val >> 2; - uint16_t b5 = val >> 3; - return static_cast((r5 << 11) | (g6 << 5) | b5); - }; - - uint16_t c0_565 = intensity_to_rgb565(max_val); - uint16_t c1_565 = intensity_to_rgb565(min_val); - uint32_t indices = 0; - - if (max_val > min_val) { - // Enforce c0_565 > c1_565 in unsigned 16-bit representation to use 4-color mode - if (c0_565 == c1_565) { - if ((c0_565 & 0x001F) < 0x001F) { - c0_565 += 1; - } else { - c1_565 -= 1; - } - } - - // Interpolated 8-bit intensity values for quantization - const int c0 = max_val; - const int c1 = min_val; - const int c2 = (2 * max_val + min_val) / 3; - const int c3 = (max_val + 2 * min_val) / 3; - - // Map each pixel to the nearest palette entry - for (int i = 0; i < 16; ++i) { - const int p = pixels[i]; - const int d0 = std::abs(p - c0); - const int d1 = std::abs(p - c1); - const int d2 = std::abs(p - c2); - const int d3 = std::abs(p - c3); - - uint32_t best_idx = 0; - int min_d = d0; - - if (d1 < min_d) { min_d = d1; best_idx = 1; } - if (d2 < min_d) { min_d = d2; best_idx = 2; } - if (d3 < min_d) { min_d = d3; best_idx = 3; } - - indices |= (best_idx << (30 - (2 * i))); - } - } - - // Account for big endian data expectation - dst[0] = static_cast(c0_565 >> 8); - dst[1] = static_cast(c0_565 & 0xFF); - dst[2] = static_cast(c1_565 >> 8); - dst[3] = static_cast(c1_565 & 0xFF); - dst[4] = static_cast(indices >> 24); - dst[5] = static_cast((indices >> 16) & 0xFF); - dst[6] = static_cast((indices >> 8) & 0xFF); - dst[7] = static_cast(indices & 0xFF); -} - -bool convert_i8_to_cmpr(TextureReplacementData& replacementData, std::vector& cmprOut) { - if (cmprOut.empty()) { - return false; - } - - const uint8_t mipCount = (replacementData.data.mip_count > 0) ? replacementData.data.mip_count : 1; - const auto expectedInputSize = get_image_data_size( - GX_TF_I8, replacementData.key.width, replacementData.key.height, mipCount); - if (cmprOut.size() < expectedInputSize) { - return false; - } - - const auto sourceData = cmprOut; - std::vector convertedData(get_image_data_size( - GX_TF_CMPR, replacementData.key.width, replacementData.key.height, mipCount)); - uint32_t mipWidth = replacementData.key.width; - uint32_t mipHeight = replacementData.key.height; - - const uint8_t* readPtr = sourceData.data(); - uint8_t* writePtr = convertedData.data(); - - for (uint8_t mip = 0; mip < mipCount; ++mip) { - const uint32_t paddedWidthI8 = (mipWidth + 7) & ~7; - const uint32_t paddedHeightI8 = (mipHeight + 3) & ~3; - const uint32_t tilesX_I8 = paddedWidthI8 / 8; - - const uint32_t paddedWidthCMPR = (mipWidth + 7) & ~7; - const uint32_t paddedHeightCMPR = (mipHeight + 7) & ~7; - const uint32_t blocksX_CMPR = paddedWidthCMPR / 8; - const uint32_t blocksY_CMPR = paddedHeightCMPR / 8; - - for (uint32_t by = 0; by < blocksY_CMPR; ++by) { - for (uint32_t bx = 0; bx < blocksX_CMPR; ++bx) { - uint8_t subBlockPixels[4][16]{}; - - for (uint32_t subBlockY = 0; subBlockY < 2; ++subBlockY) { - for (uint32_t subBlockX = 0; subBlockX < 2; ++subBlockX) { - const uint32_t subBlock = subBlockY * 2 + subBlockX; - for (uint32_t row = 0; row < 4; ++row) { - for (uint32_t col = 0; col < 4; ++col) { - const uint32_t x = bx * 8 + subBlockX * 4 + col; - const uint32_t y = by * 8 + subBlockY * 4 + row; - if (x >= mipWidth || y >= mipHeight) { - continue; - } - - const uint32_t tile = (y / 4) * tilesX_I8 + (x / 8); - const uint32_t tileOffset = (y % 4) * 8 + (x % 8); - subBlockPixels[subBlock][row * 4 + col] = - readPtr[tile * 32 + tileOffset]; - } - } - } - } - - for (const auto& subBlockPixel : subBlockPixels) { - encode_cmpr_sub_block(writePtr, subBlockPixel); - writePtr += 8; - } - } - } - - const uint32_t tilesY_I8 = paddedHeightI8 / 4; - readPtr += tilesX_I8 * tilesY_I8 * 32; - - mipWidth = std::max(1u, mipWidth >> 1); - mipHeight = std::max(1u, mipHeight >> 1); - } - - cmprOut.swap(convertedData); - - // Update format - replacementData.data.gx_format = GX_TF_CMPR; - - return true; -} - -void recolor_texture(TextureReplacementData& replacementData, GXColor color, std::vector& newTextureDataOut) { - - switch (replacementData.key.gx_format) { - case GX_TF_CMPR: - recolor_cmpr_texture(replacementData, color, newTextureDataOut); - break; - case GX_TF_RGB5A3: - recolor_rgb5a3_texture(replacementData, color, newTextureDataOut); - break; - case GX_TF_I8: - if (convert_i8_to_cmpr(replacementData, newTextureDataOut)) { - recolor_cmpr_texture(replacementData, color, newTextureDataOut); - } else { - mods::log::debug("Could not convert {} from i8 to cmpr", replacementData.textureName); - } - break; - default: - break; - } -} - -std::unordered_map>& get_texture_replacements() { - static std::unordered_map> replacements{}; - - if (replacements.empty()) { - replacements = { - {get_cvars().herosTunicCapColor, { - { - .arc = "Kmdl", - .modelFileName = "al_head.bmd", - .textureName = "al_cap", - } - }}, - {get_cvars().herosTunicTorsoColor, { - { - .arc = "Kmdl", - .modelFileName = "al.bmd", - .textureName = "al_upbody", - } - }}, - {get_cvars().herosTunicSkirtColor, { - { - .arc = "Kmdl", - .modelFileName = "al.bmd", - .textureName = "al_lowbody", - } - }}, - {get_cvars().zoraArmorCapColor, { - { - .arc = "Zmdl", - .modelFileName = "zl_head.bmd", - .textureName = "zl_cap", - } - }}, - {get_cvars().zoraArmorHelmetColor, { - { - .arc = "Zmdl", - .modelFileName = "zl_head.bmd", - .textureName = "zl_helmet", - } - }}, - {get_cvars().zoraArmorTorsoColor, { - { - .arc = "Zmdl", - .modelFileName = "zl.bmd", - .textureName = "zl_armor", - }, - { - .arc = "Zmdl", - .modelFileName = "zl.bmd", - .textureName = "zl_armL", - } - }}, - {get_cvars().zoraArmorScalesColor, { - { - .arc = "Zmdl", - .modelFileName = "zl.bmd", - .textureName = "zl_body", - } - }}, - {get_cvars().zoraArmorFlippersColor, { - { - .arc = "Zmdl", - .modelFileName = "zl.bmd", - .textureName = "zl_boots", - } - }}, - {get_cvars().woodenSwordColor, { - { - .arc = "Bmdl", // Ordon Clothes Model - .modelFileName = "al_swb.bmd", - .textureName = "al_SWB", - }, - { - .arc = "Kmdl", // Hero's Tunic Model - .modelFileName = "al_swb.bmd", - .textureName = "al_SWB", - }, - { - .arc = "Zmdl", // Zora Armor Model - .modelFileName = "al_swb.bmd", - .textureName = "al_SWB", - }, - { - .arc = "Mmdl", // Magic Armor Model - .modelFileName = "al_swb.bmd", - .textureName = "al_SWB", - }, - { - .arc = "O_gD_SWB", // Get Item Model - .modelFileName = "o_gd_al_swb.bmd", - .textureName = "al_SWB", - } - }}, - {get_cvars().ordonSwordHandleColor, { - { - .arc = "Alink", - .modelFileName = "al_swa.bmd", - .textureName = "al_SWgripA", - }, - { - .arc = "O_gD_SWA", // Get Item Model - .modelFileName = "o_gd_al_swa.bmd", - .textureName = "al_SWgripA", - } - }}, - {get_cvars().ordonSwordBladeColor, { - { - .arc = "Alink", - .modelFileName = "al_swa.bmd", - .textureName = "al_SWA", - } - }}, - {get_cvars().msHandleColor, { - { - .arc = "Alink", - .modelFileName = "al_swm.bmd", - .textureName = "al_SWgripM", - } - }}, - {get_cvars().msBladeColor, { - { - .arc = "Alink", - .modelFileName = "al_swm.bmd", - .textureName = "al_SWM", - } - }}, - {get_cvars().boomerangColor, { - { - .arc = "Alink", // Boomerang in Link's hand - .modelFileName = "al_boom.bmd", - .textureName = "L_al_boom00", - }, - { - .arc = "E_mk", // Boomerang in Ook's hand - .modelFileName = "bm.bmd", - .textureName = "L_al_boom00", - }, - { - .arc = "E_mk", // Boomerang in Ook's hand - .modelFileName = "bm.bmd", - .textureName = "bm_boom", - }, - { - .arc = "O_gD_boom", // Get Item Model - .modelFileName = "o_gd_boom.bmd", - .textureName = "L_al_boom00", - } - }}, - {get_cvars().ironBootsColor, { - { - .arc = "Bmdl", // Ordon Clothes Model - .modelFileName = "al_bootsh.bmd", - .textureName = "al_bootsH", - }, - { - .arc = "Kmdl", // Hero's Tunic Model - .modelFileName = "al_bootsh.bmd", - .textureName = "al_bootsH", - }, - { - .arc = "Zmdl", // Zora Armor Model - .modelFileName = "al_bootsh.bmd", - .textureName = "al_bootsH", - }, - { - .arc = "Mmdl", // Magic Armor Model - .modelFileName = "al_bootsh.bmd", - .textureName = "al_bootsH", - }, - { - .arc = "O_gD_boot", // Get Item Model - .modelFileName = "o_gd_al_bootsh.bmd", - .textureName = "al_bootsH", - } - }}, - {get_cvars().spinnerColor, { - { - .arc = "Alink", // Spinner used by Link - .modelFileName = "al_sp.bmd", - .textureName = "al_SP", - }, - { - .arc = "O_gD_SP", // Get Item Model - .modelFileName = "o_gd_al_sp.bmd", - .textureName = "al_SP", - } - }}, - {get_cvars().linkHairColor, { - { - .arc = "Bmdl", // Ordon Clothes Model - .modelFileName = "bl_head.bmd", - .textureName = "bl_hair", - }, - { - .arc = "Kmdl", // Hero's Tunic Model - .modelFileName = "al_head.bmd", - .textureName = "al_hair", - }, - { - .arc = "Mmdl", // Magic Armor Model - .modelFileName = "ml_head.bmd", - .textureName = "al_hair", - } - }}, - {get_cvars().wolfLinkColor, { - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_body", - }, - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_eye.1", - }, - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_eye.2", - }, - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_eye.3", - }, - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_eye.4", - }, - { - .arc = "Wmdl", - .modelFileName = "wl.bmd", - .textureName = "wl_eye.5", - } - }}, - {get_cvars().eponaColor, { - { - .arc = "Horse", - .modelFileName = "hs.bmd", - .textureName = "hs_body", - }, - { - .arc = "Horse", - .modelFileName = "hs.bmd", - .textureName = "hs_eye.1", - }, - { - .arc = "Horse", - .modelFileName = "hs.bmd", - .textureName = "hs_eye.2", - }, - { - .arc = "Horse", - .modelFileName = "hs.bmd", - .textureName = "hs_eye.3", - }, - }}, - }; - } - - return replacements; -} diff --git a/mods/basic_cosmetics_mod/src/texture_utils.hpp b/mods/basic_cosmetics_mod/src/texture_utils.hpp deleted file mode 100644 index 49dd0df81a..0000000000 --- a/mods/basic_cosmetics_mod/src/texture_utils.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -/** - * File originally copied from console TPR with permission from isaac - * https://github.com/zsrtp/libtp_rel/blob/master/include/util/texture_utils.h - */ - -#include "mod.hpp" - -#include - -#include -#include - -uint32_t get_image_data_size( - uint32_t format, uint32_t width, uint32_t height, uint32_t mipmapCount); - -void recolor_texture( - TextureReplacementData& replacementData, GXColor color, std::vector& newTextureDataOut); - -std::unordered_map>& get_texture_replacements(); diff --git a/mods/cosmetics b/mods/cosmetics new file mode 160000 index 0000000000..93971c38aa --- /dev/null +++ b/mods/cosmetics @@ -0,0 +1 @@ +Subproject commit 93971c38aa7286c59be7c3874a95e12d1a37036a diff --git a/mods/basic_cosmetics_mod/CMakeLists.txt b/mods/custom_actor_demo/CMakeLists.txt similarity index 52% rename from mods/basic_cosmetics_mod/CMakeLists.txt rename to mods/custom_actor_demo/CMakeLists.txt index f00540864b..d7e55536d4 100644 --- a/mods/basic_cosmetics_mod/CMakeLists.txt +++ b/mods/custom_actor_demo/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.25) -project(basic_cosmetics_mod CXX) +project(custom_actor_demo CXX) +set(CMAKE_CXX_STANDARD 20) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") @@ -12,24 +13,9 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif () endif () -include(FetchContent) - -message(STATUS "basic_cosmetics_mod: Fetching xxhash") -FetchContent_Declare( - xxhash - GIT_REPOSITORY https://github.com/Cyan4973/xxHash.git - GIT_TAG v0.8.3 -) -FetchContent_MakeAvailable(xxhash) - -set(COSMETIC_SOURCES src/color_utils.cpp src/midna_hair_color.cpp src/texture_utils.cpp src/hooks.cpp) - -add_mod(basic_cosmetics_mod +add_mod(custom_actor_demo FEATURES game fmt - SOURCES src/mod.cpp ${COSMETIC_SOURCES} + SOURCES src/mod.cpp src/m_a_obj_wrock.cpp src/m_a_mine.cpp MOD_JSON mod.json RES_DIR res - BUNDLE ) - -target_link_libraries(basic_cosmetics_mod PRIVATE xxHash::xxhash) diff --git a/mods/custom_actor_demo/mod.json b/mods/custom_actor_demo/mod.json new file mode 100644 index 0000000000..55f57c264d --- /dev/null +++ b/mods/custom_actor_demo/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.custom_actor_demo", + "name": "[Demo] Custom Actor", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "A mod to demonstrate how to create and use custom actors. Spawns a \"wrock\" in South Faron Woods." +} diff --git a/mods/basic_cosmetics_mod/res/.gitkeep b/mods/custom_actor_demo/res/.gitkeep similarity index 100% rename from mods/basic_cosmetics_mod/res/.gitkeep rename to mods/custom_actor_demo/res/.gitkeep diff --git a/mods/custom_actor_demo/src/m_a_mine.cpp b/mods/custom_actor_demo/src/m_a_mine.cpp new file mode 100644 index 0000000000..fd7fa77b65 --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_mine.cpp @@ -0,0 +1,227 @@ +#include "m_a_mine.hpp" +#include "d/d_com_inf_game.h" +#include "res/Object/O_mD_jira.h" + +// The name of the archive in /res/Object/ +static const char* l_resName = "O_mD_jira"; + +// The actor's heap (for resources) should be enough to hold the data for the model and collision +static constexpr u32 heap_size = ALIGN_NEXT(16832, 0x20); + +ma_Mine_c::~ma_Mine_c() { + // Called every time the actor is deleted + + // Delete the sound object + mSound.deleteObject(); + + // Request to unload the archive (the data acts as a shared pointer, and only gets deleted when + // the reference counter goes to zero) + dComIfG_resDelete(&mPhase, l_resName); +} + +cPhs_Step ma_Mine_c::create() { + // Because of how the actor system works, an actor's constructor doesn't get called when an + // actor is created. We need to manually do it here with the following ma: + fopAcM_ct(this, ma_Mine_c); + + // The create function gets called until we return cPhs_COMPLEATE_e while an actor is loading. + // We request to load the archive here, and wait until the dvd completes loading it + cPhs_Step step = dComIfG_resLoad(&mPhase, l_resName); + if (step == cPhs_COMPLEATE_e) { + // Initialize the solid heap for the actor's resources, if needed + if (!fopAcM_entrySolidHeap(this, createHeapCallBack, heap_size)) { + return cPhs_ERROR_e; + } + + // Setup our collision sphere and register it to the world + // Set a circle "wall" of 30 units around the actor + mAcchCir.SetWall(30.0f, 30.0f); + mAcch.Set(this, 1, &mAcchCir); + mAcch.ClrWaterNone(); + mAcch.SetRoofCrrHeight(60.0f); + mAcch.SetWaterCheckOffset(10000.0f); + mAcch.SetWtrChkMode(2); + mAcch.OnLineCheck(); + + mCcStts.Init(30, 0xFF, this); + + // Collision Sphere for the actor (copied from Bomb Actor) + static const dCcD_SrcSph + l_sphSrc = {.mObjInf = + { + .mObj = {.mFlags = 0x0, + .mSrcObjHitInf = {.mObjAt = {.mType = AT_TYPE_BOMB, + .mAtp = 0x4, + .mBase = {.mSPrm = 0x1e}}, + .mObjTg = {.mType = 0xd8fbffef, .mBase = {.mSPrm = 0x11}}, + .mObjCo = {.mBase = {.mSPrm = 0x79}}}}, + .mGObjAt{.mSe = dCcD_SE_NONE, + .mHitMark = 0x0, + .mSpl = 0x1, + .mMtrl = 0x0, + .mBase = {.mGFlag = 0x0}}, + .mGObjTg{.mSe = dCcD_SE_NONE, + .mHitMark = 0x0, + .mSpl = 0x0, + .mMtrl = 0x0, + .mBase = {.mGFlag = 0x4}}, + .mGObjCo{.mBase = {.mGFlag = 0x0}}, + }, + .mSphAttr = {.mSph = {.mCenter = {0.0f, 0.0f, 0.0f}, .mRadius = 80.0f}}}; + + mCollisionSphere.Set(l_sphSrc); + mCollisionSphere.SetStts(&mCcStts); + + // We register a callback anytime the actor is hit (both attacks and is hit) + mCollisionSphere.SetAtHitCallback(atHitCallback); + mCollisionSphere.SetTgHitCallback(atHitCallback); + mCollisionSphere.OffTgSetBit(); + mCollisionSphere.OffCoSetBit(); + mCollisionSphere.OnAtSetBit(); // Enable the attack sphere + + // Set the initial matrix and cull box for the actor + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_SetMin(this, -36.0f, 0.0f, -36.0f); + fopAcM_SetMax(this, 36.0f, 66.0f, 36.0f); + + // Call execute so the actor's information in the world can be updated + Execute(); + } + return step; +} + +// Initializes the heap that all instances of this actor will use for resources +// Gets called from the callback in fopAcM_entrySolidHeap +int ma_Mine_c::CreateHeap() { + // Get the bmd data from the archive and initialize it + J3DModelData* model_data = + (J3DModelData*)dComIfG_getObjectRes(l_resName, dRes_INDEX_O_MD_JIRA_BMD_O_MD_JIRAI_e); + if (model_data == NULL) { + return 0; + } + mpModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084); + if (mpModel == NULL) { + return 0; + } + + // Create the sound object the actor will use + mSound.init(¤t.pos, 1); + + return 1; +} + +int ma_Mine_c::createHeapCallBack(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); +} + +int ma_Mine_c::Delete() { + // Call the destructor anytime we delete the actor + this->~ma_Mine_c(); + return 1; +} + +int ma_Mine_c::Execute() { + // Update collision with the world + mAcch.CrrPos(dComIfG_Bgsp()); + mCollisionSphere.SetC(attention_info.position); + dComIfG_Ccsp()->Set(&mCollisionSphere); + + // Get the collision below the actor + cBgS_GndChk groundChunk = mAcch.m_gnd; + f32 groundH = mAcch.GetGroundH(); + if (groundH != -G_CM3D_F_INF) { + // Set the actor's environment colors to match the room's current ones + int roomNo = dComIfG_Bgsp().GetRoomId(groundChunk); + tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(groundChunk); + tevStr.room_no = roomNo; + + // Set the actor's room to be where it is sitting + mCcStts.SetRoomId(roomNo); + fopAcM_SetRoomNo(this, roomNo); + + // Get the reverb info here that the actor can use when exploding + mReverb = dComIfGp_getReverb(roomNo); + } + + // Update the model's transformation matrix to match the actor's transform + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mDoMtx_stack_c::scaleM(scale); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + + // Set any attention flags (if needed) + eyePos = attention_info.position = current.pos; + attention_info.flags = 0; + return 1; +} + +int ma_Mine_c::Draw() { + // Update the model's lighting with the scene + g_env_light.settingTevStruct(0x20, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); + + // Set the bmd model to be drawn when the display list is executed + mDoExt_modelUpdateDL(mpModel); + + return 1; +} + +void ma_Mine_c::atHit(dCcD_GObjInf* i_atObjInf) { + // Create particles with these IDs at the actor's position + static const u16 normalNameID[] = { + 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167, 0x168, 0x1EC}; + for (int i = 0; i < ARRAY_SIZE(normalNameID); i++) { + dComIfGp_particle_setColor(normalNameID[i], ¤t.pos, &tevStr, NULL, NULL, 0.0f, 0xFF, + &shape_angle, &scale, NULL, -1, NULL); + } + + // Create an explosion sound + mSound.startSound(Z2SE_OBJ_BOMB_EXPLODE, 0, mReverb); + + // Vibrate the controller + dComIfGp_getVibration().StartShock(4, 31, cXyz(0.0f, 1.0f, 0.0f)); + + // Request to delete the actor so it disappears + fopAcM_delete(this); +} + +void ma_Mine_c::atHitCallback(fopAc_ac_c* i_tgActor, dCcD_GObjInf* i_tgObjInf, + fopAc_ac_c* i_atActor, dCcD_GObjInf* i_atObjInf) { + // This callback gets triggered anytime an intersection happens with the object's collision sphere + ((ma_Mine_c*)i_tgActor)->atHit(i_atObjInf); +} + +static cPhs_Step ma_Mine_create(void* i_this) { + return static_cast(i_this)->create(); +} + +static int maMine_Delete(void* i_this) { + return static_cast(i_this)->Delete(); +} + +static int maMine_Execute(void* i_this) { + return static_cast(i_this)->Execute(); +} + +static int maMine_Draw(void* i_this) { + return static_cast(i_this)->Draw(); +} + +static int maMine_IsDelete(void*) { + return 1; +} + +s16 ma_Mine_c::sProcName = -1; +ActorHandle ma_Mine_c::sActorHandle = -1; +const ActorProfileDesc ma_Mine_c::sProfile = {.name = MA_MINE_NAME, + .priority_group = 7, + .process_size = sizeof(ma_Mine_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // An unused draw priority + .status = fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e, + .group = fopAc_ACTOR_e, + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = ma_Mine_create, + .delete_function = maMine_Delete, + .execute_function = maMine_Execute, + .is_delete_function = maMine_IsDelete, + .draw_function = maMine_Draw}; diff --git a/mods/custom_actor_demo/src/m_a_mine.hpp b/mods/custom_actor_demo/src/m_a_mine.hpp new file mode 100644 index 0000000000..147938473f --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_mine.hpp @@ -0,0 +1,43 @@ +#pragma once +#include "mods/svc/actor.h" + +// Base actor class definitions +#include "f_op/f_op_actor.h" + +// Definitions for request_of_phase_process_class and cPhs_Step +#include "SSystem/SComponent/c_phase.h" + +// Definitions for collision +#include "d/d_bg_s_acch.h" +#include "d/d_bg_w.h" +#include "d/d_cc_d.h" + +#define MA_MINE_NAME "m_mine" + +class ma_Mine_c : public fopAc_ac_c { +public: + request_of_phase_process_class mPhase; + J3DModel* mpModel; + dBgS_ObjAcch mAcch; + dBgS_AcchCir mAcchCir; + Mtx mColliderMtx; + dCcD_Stts mCcStts; + dCcD_Sph mCollisionSphere; + Z2SoundObjSimple mSound; + s8 mReverb; + + virtual ~ma_Mine_c(); + cPhs_Step create(); + int CreateHeap(); + int Delete(); + int Execute(); + int Draw(); + void atHit(dCcD_GObjInf* i_atObjInf); + static int createHeapCallBack(fopAc_ac_c*); + static void atHitCallback(fopAc_ac_c* i_tgActor, dCcD_GObjInf* i_tgObjInf, + fopAc_ac_c* i_atActor, dCcD_GObjInf* i_atObjInf); + + static s16 sProcName; + static ActorHandle sActorHandle; + static const ActorProfileDesc sProfile; +}; diff --git a/mods/custom_actor_demo/src/m_a_obj_wrock.cpp b/mods/custom_actor_demo/src/m_a_obj_wrock.cpp new file mode 100644 index 0000000000..bb40d10cf3 --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_obj_wrock.cpp @@ -0,0 +1,195 @@ +/* + * m_a_obj_wrock.cpp + * An example actor for a rock that can be placed in the world. + */ + +#include "m_a_obj_wrock.hpp" +#include "d/d_com_inf_game.h" +#include "res/Object/WRock.h" + +// The name of the archive in /res/Object/ +static const char* l_resName = "Wrock"; + +// The actor's heap (for resources) should be enough to hold the data for the model and collision +static constexpr u32 heap_size = ALIGN_NEXT(13952, 0x20) + ALIGN_NEXT(1920, 0x20); + +maObj_Wrock_c::~maObj_Wrock_c() { + // Called every time the actor is deleted + + // Remove the collider from the world's collision + if (mpCollider != NULL) { + dComIfG_Bgsp().Release(mpCollider); + } + + // Request to unload the archive (the data acts as a shared pointer, and only gets deleted when + // the reference counter goes to zero) + dComIfG_resDelete(&mPhase, l_resName); +} + +cPhs_Step maObj_Wrock_c::create() { + // Because of how the actor system works, an actor's constructor doesn't get called when an + // actor is created. We need to manually do it here with the following macro: + fopAcM_ct(this, maObj_Wrock_c); + + // The create function gets called until we return cPhs_COMPLEATE_e while an actor is loading. + // We request to load the archive here, and wait until the dvd completes loading it + cPhs_Step step = dComIfG_resLoad(&mPhase, l_resName); + if (step == cPhs_COMPLEATE_e) { + // Initialize the solid heap for the actor's resources, if needed + if (!fopAcM_entrySolidHeap(this, createHeapCallBack, heap_size)) { + return cPhs_ERROR_e; + } + + // Register the actor's collider to the current world's collision + if (mpCollider != NULL) { + if (dComIfG_Bgsp().Regist(mpCollider, this) == true) { + return cPhs_ERROR_e; + } + } + + // Set the initial matrix and cull box for the actor + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -400.0f, -400.0f, -400.0f, 400.0f, 400.0f, 400.0f); + + // Setup collision info (will be used in execute) + mAcch.Set(¤t.pos, &old.pos, this, 1, &mAcchCir, &speed, ¤t.angle, &shape_angle); + + // Call execute so the actor's information in the world can be updated + Execute(); + } + return step; +} + +// Initializes the heap that all instances of this actor will use for resources +// Gets called from the callback in fopAcM_entrySolidHeap +int maObj_Wrock_c::CreateHeap() { + // Get the bmd data from the archive and initialize it + J3DModelData* model_data = + (J3DModelData*)dComIfG_getObjectRes(l_resName, dRes_INDEX_WROCK_BMD_WROCK_e); + if (model_data == NULL) { + return 0; + } + mpModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084); + if (mpModel == NULL) { + return 0; + } + + // Get the dzb collision data from the archive and initialize it + mpCollider = JKR_NEW dBgW(); + if (mpCollider == NULL) { + return 0; + } + cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes(l_resName, dRes_INDEX_WROCK_DZB_WROCK_e); + if (mpCollider->Set(dzb, 1, &mColliderMtx) == true) { + return 0; + } + mpCollider->SetCrrFunc(dBgS_MoveBGProc_Typical); + return 1; +} + +int maObj_Wrock_c::createHeapCallBack(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); +} + +int maObj_Wrock_c::Delete() { + // Call the destructor anytime we delete the actor + this->~maObj_Wrock_c(); + return 1; +} + +int maObj_Wrock_c::Execute() { + // Update collision with the world + mAcch.CrrPos(dComIfG_Bgsp()); + + // Get the collision below the actor + mGndChk = mAcch.m_gnd; + mGroundH = mAcch.GetGroundH(); + if (mGroundH != -G_CM3D_F_INF) { + // Set the actor's environment colors to match the room's current ones + tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(mGndChk); + tevStr.room_no = dComIfG_Bgsp().GetRoomId(mGndChk); + + // Set the actor's room to be where it is sitting + fopAcM_SetRoomNo(this, dComIfG_Bgsp().GetRoomId(mGndChk)); + } + + // Update the model's transformation matrix to match the actor's transform + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mDoMtx_stack_c::scaleM(scale); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + + // Copy the model's transformation matrix to the collider's transformation matrix and update the + // collider + if (mpCollider != NULL) { + PSMTXCopy(mpModel->getBaseTRMtx(), mColliderMtx); + mpCollider->Move(); + } + + // Set any attention flags (if needed) + eyePos = attention_info.position = current.pos; + attention_info.flags = 0; + return 1; +} + +int maObj_Wrock_c::Draw() { + // Update the model's lighting with the scene + g_env_light.settingTevStruct(0x20, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); + + // Set the current dlist to BG Which means that shadows can be cast on it + // Because of the messy collider, the shadows don't look great, but this is here as an example + dComIfGd_setListBG(); + + // Set the bmd model to be drawn when the display list is executed + mDoExt_modelUpdateDL(mpModel); + + // Cast a shadow for the actor onto the ground. + // We can only do this if we are drawing to the normal dlist, not the BG dlist + // if (mGroundH != -G_CM3D_F_INF) { + // mShadow = dComIfGd_setShadow(mShadow, 1, mpModel, ¤t.pos, + // 2000.0f, 0.0f, + // current.pos.y, mGroundH, mGndChk, &tevStr, 0, + // 1.0f, &dDlst_shadowControl_c::mSimpleTexObj); + // } + + // Reset the active dlist + dComIfGd_setList(); + + return 1; +} + +static cPhs_Step maObj_Wrock_Create(void* i_this) { + return static_cast(i_this)->create(); +} + +static int maObj_Wrock_Delete(void* i_this) { + return static_cast(i_this)->Delete(); +} + +static int maObj_Wrock_Execute(void* i_this) { + return static_cast(i_this)->Execute(); +} + +static int maObj_Wrock_Draw(void* i_this) { + return static_cast(i_this)->Draw(); +} + +static int maObj_Wrock_IsDelete(void*) { + return 1; +} + +s16 maObj_Wrock_c::sProcName = -1; +ActorHandle maObj_Wrock_c::sActorHandle = -1; +const ActorProfileDesc maObj_Wrock_c::sProfile = {.name = MAOBJ_WROCK_NAME, + .priority_group = 7, + .process_size = sizeof(maObj_Wrock_c), + .draw_priority = fpcDwPi_OBJ_LBOX_e, // An unused draw priority + .status = fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e, + .group = fopAc_ACTOR_e, + .cull_type = fopAc_CULLBOX_CUSTOM_e, + .create_function = maObj_Wrock_Create, + .delete_function = maObj_Wrock_Delete, + .execute_function = maObj_Wrock_Execute, + .is_delete_function = maObj_Wrock_IsDelete, + .draw_function = maObj_Wrock_Draw}; diff --git a/mods/custom_actor_demo/src/m_a_obj_wrock.hpp b/mods/custom_actor_demo/src/m_a_obj_wrock.hpp new file mode 100644 index 0000000000..1e18d36f5f --- /dev/null +++ b/mods/custom_actor_demo/src/m_a_obj_wrock.hpp @@ -0,0 +1,39 @@ +#pragma once +#include "mods/svc/actor.h" + +// Base actor class definitions +#include "f_op/f_op_actor.h" + +// Definitions for request_of_phase_process_class and cPhs_Step +#include "SSystem/SComponent/c_phase.h" + +// Definitions for collision +#include "d/d_bg_s_acch.h" +#include "d/d_bg_w.h" + +#define MAOBJ_WROCK_NAME "wrock" + +class maObj_Wrock_c : public fopAc_ac_c { +public: + request_of_phase_process_class mPhase; + J3DModel* mpModel; + dBgS_ObjAcch mAcch; + cBgS_GndChk mGndChk; + dBgS_AcchCir mAcchCir; + Mtx mColliderMtx; + dBgW* mpCollider; + f32 mGroundH; + int mShadow; + + virtual ~maObj_Wrock_c(); + cPhs_Step create(); + int CreateHeap(); + int Delete(); + int Execute(); + int Draw(); + static int createHeapCallBack(fopAc_ac_c*); + + static s16 sProcName; + static ActorHandle sActorHandle; + static const ActorProfileDesc sProfile; +}; diff --git a/mods/custom_actor_demo/src/mod.cpp b/mods/custom_actor_demo/src/mod.cpp new file mode 100644 index 0000000000..971ad6e4f0 --- /dev/null +++ b/mods/custom_actor_demo/src/mod.cpp @@ -0,0 +1,85 @@ +#include "mods/service.hpp" +#include "mods/svc/actor.h" +#include "mods/svc/log.hpp" +#include "mods/svc/stage.h" + +#include "d/d_com_inf_game.h" + +#include "m_a_mine.hpp" +#include "m_a_obj_wrock.hpp" + +#include + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(ActorService, svc_actor); +IMPORT_SERVICE(StageService, svc_stage); + +extern "C" { +MOD_EXPORT ModResult mod_initialize(ModError*) { + if (svc_actor->register_actor(mod_ctx, &maObj_Wrock_c::sProfile, &maObj_Wrock_c::sProcName, + &maObj_Wrock_c::sActorHandle) != MOD_OK) + { + mods::log::error("Failed to register actor wrock!"); + return MOD_ERROR; + } + + const stage_actor_data_class wrockParams{ + .name = MAOBJ_WROCK_NAME, + .base = + { + .parameters = 0, + .position = {-14324.0f, 0.0f, 341.0f}, + .angle = {0, -16595, 0}, + .setID = 0xFFFF, + }, + }; + if (svc_stage->add_actor( + mod_ctx, "F_SP108", 0, -1, &wrockParams, sizeof(wrockParams), nullptr) != MOD_OK) + { + mods::log::error("Adding wrock to F_SP108 Failed!"); + return MOD_ERROR; + } + + if (svc_actor->register_actor(mod_ctx, &ma_Mine_c::sProfile, &ma_Mine_c::sProcName, + &ma_Mine_c::sActorHandle) != MOD_OK) + { + mods::log::error("Failed to register actor " MA_MINE_NAME); + return MOD_ERROR; + } + + static const std::array minePositions = { + {{-14445.0f, 11.0f, 1304.0f}, {-14557.0f, 7.0f, 990.0f}, {-14790.0f, 7.0f, 634.0f}, + {-14829.0f, 0.0f, 144.0f}, {-14615.0f, 0.0f, -170.0f}, {-14283.0f, 10.0f, -420.0f}}}; + for (const auto& pos : minePositions) { + const stage_actor_data_class mineParams{ + .name = MA_MINE_NAME, + .base = + { + .parameters = 0, + .position = {pos.x, pos.y, pos.z}, + .angle = {0x2000, (s16)(pos.x*100000), 0}, // Adjusted and seemingly random angle + .setID = 0xFFFF, + }, + }; + if (svc_stage->add_actor( + mod_ctx, "F_SP108", 0, -1, &mineParams, sizeof(mineParams), nullptr) != MOD_OK) + { + mods::log::error("Adding mine to F_SP108 Failed!"); + return MOD_ERROR; + } + } + + mods::log::info("custom_actor_demo initialized"); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + mods::log::info("custom_actor_demo shutdown"); + return MOD_OK; +} +} diff --git a/mods/luau_runtime/CMakeLists.txt b/mods/luau_runtime/CMakeLists.txt new file mode 100644 index 0000000000..fa38b64b8a --- /dev/null +++ b/mods/luau_runtime/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.25) +project(luau_runtime CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +include(FetchContent) + +set(LUAU_BUILD_CLI OFF CACHE BOOL "" FORCE) +set(LUAU_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set(LUAU_BUILD_WEB OFF CACHE BOOL "" FORCE) +set(LUAU_WERROR OFF CACHE BOOL "" FORCE) +FetchContent_Declare(luau + URL https://github.com/luau-lang/luau/archive/refs/tags/0.734.tar.gz + URL_HASH SHA256=cb55a891226d8c70284e22eb9281cc2b4496c709a4050f52aaa18a355fe7b1a3 + DOWNLOAD_EXTRACT_TIMESTAMP FALSE + EXCLUDE_FROM_ALL +) +FetchContent_MakeAvailable(luau) + +add_mod(luau_runtime + SOURCES + src/bindings.cpp + src/config.cpp + src/runtime.cpp + src/ui.cpp + MOD_JSON mod.json + RES_DIR res + BUNDLE +) + +target_link_libraries(luau_runtime PRIVATE Luau.VM Luau.Compiler) diff --git a/mods/luau_runtime/mod.json b/mods/luau_runtime/mod.json new file mode 100644 index 0000000000..788a57f554 --- /dev/null +++ b/mods/luau_runtime/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.luau", + "name": "Luau Support", + "version": "1.0.0", + "author": "Twilit Realm", + "description": "Luau script runtime for mods" +} diff --git a/mods/luau_runtime/res/licenses/LUAU-MIT.txt b/mods/luau_runtime/res/licenses/LUAU-MIT.txt new file mode 100644 index 0000000000..2f2aa17066 --- /dev/null +++ b/mods/luau_runtime/res/licenses/LUAU-MIT.txt @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2019-2025 Roblox Corporation +Copyright (c) 1994-2019 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mods/luau_runtime/src/bindings.cpp b/mods/luau_runtime/src/bindings.cpp new file mode 100644 index 0000000000..27f4218a83 --- /dev/null +++ b/mods/luau_runtime/src/bindings.cpp @@ -0,0 +1,340 @@ +#include "runtime.hpp" + +#include +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kOverlayMetatable[] = "dusklight.overlay_handle"; +constexpr char kTextureMetatable[] = "dusklight.texture_handle"; + +uint64_t get_hash_field(lua_State* state, int table, const char* field, bool required) { + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + if (required) { + luaL_error(state, "field '%s' is required", field); + } + return 0; + } + if (!lua_isinteger64(state, -1)) { + luaL_error(state, "field '%s' must be an integer", field); + } + const uint64_t value = static_cast(lua_tointeger64(state, -1, nullptr)); + lua_pop(state, 1); + return value; +} + +int log_write(lua_State* state, LogLevel level, int messageIndex) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + size_t length = 0; + const char* message = luaL_checklstring(state, messageIndex, &length); + const std::string copy{message, length}; + svc_log->write(vm.subject, level, copy.c_str()); + return 0; +} + +int log_trace(lua_State* state) { + return log_write(state, LOG_LEVEL_TRACE, 1); +} + +int log_debug(lua_State* state) { + return log_write(state, LOG_LEVEL_DEBUG, 1); +} + +int log_info(lua_State* state) { + return log_write(state, LOG_LEVEL_INFO, 1); +} + +int log_warn(lua_State* state) { + return log_write(state, LOG_LEVEL_WARN, 1); +} + +int log_error(lua_State* state) { + return log_write(state, LOG_LEVEL_ERROR, 1); +} + +int log_write_level(lua_State* state) { + static constexpr const char* kLevels[] = {"trace", "debug", "info", "warn", "error", nullptr}; + const int level = luaL_checkoption(state, 1, nullptr, kLevels); + return log_write(state, static_cast(level), 2); +} + +int host_mod_id(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_id(vm.subject)); + return 1; +} + +int host_mod_name(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_name(vm.subject)); + return 1; +} + +int host_mod_version(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_version(vm.subject)); + return 1; +} + +int host_mod_dir(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_pushstring(state, svc_host->mod_dir(vm.subject)); + return 1; +} + +int host_data_dir(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr || !SERVICE_HAS(svc_host, HostService, data_dir) || + svc_host->data_dir == nullptr) + { + service_unavailable(state, "HostService::data_dir"); + } + const char* path = nullptr; + check_result(state, svc_host->data_dir(vm.subject, &path), "host.data_dir"); + lua_pushstring(state, path != nullptr ? path : ""); + return 1; +} + +int host_fail(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + const char* message = luaL_checkstring(state, 1); + svc_host->fail(vm.subject, MOD_ERROR, message); + luaL_error(state, "%s", message); +} + +int register_host_callback(lua_State* state, std::vector& callbacks) { + luaL_checktype(state, 1, LUA_TFUNCTION); + lua_pushvalue(state, 1); + callbacks.push_back(lua_ref(state, -1)); + lua_pop(state, 1); + return 0; +} + +int host_on_update(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + return register_host_callback(state, vm.updateRefs); +} + +int host_on_shutdown(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + return register_host_callback(state, vm.shutdownRefs); +} + +int resource_load(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_resource == nullptr) { + service_unavailable(state, "ResourceService"); + } + const char* path = luaL_checkstring(state, 1); + ResourceBuffer buffer = RESOURCE_BUFFER_INIT; + check_result(state, svc_resource->load(vm.subject, path, &buffer), "resource.load"); + const auto* data = buffer.data != nullptr ? static_cast(buffer.data) : ""; + const std::string copy{data, buffer.size}; + svc_resource->free(vm.subject, &buffer); + lua_pushlstring(state, copy.data(), copy.size()); + return 1; +} + +int overlay_remove(lua_State* state) { + auto& handle = check_handle(state, 1, kOverlayMetatable, HandleKind::Overlay); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + check_result(state, svc_overlay->remove(handle.vm->subject, handle.value), "overlay.remove"); + handle.value = 0; + return 0; +} + +int overlay_add_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + const char* discPath = luaL_checkstring(state, 1); + const char* bundlePath = luaL_checkstring(state, 2); + OverlayHandle handle = 0; + check_result(state, svc_overlay->add_file(vm.subject, discPath, bundlePath, &handle), + "overlay.add_file"); + push_handle(state, vm, handle, HandleKind::Overlay, kOverlayMetatable); + return 1; +} + +int overlay_add_buffer(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + const char* discPath = luaL_checkstring(state, 1); + size_t size = 0; + const char* data = luaL_checklstring(state, 2, &size); + OverlayHandle handle = 0; + check_result(state, svc_overlay->add_buffer(vm.subject, discPath, data, size, &handle), + "overlay.add_buffer"); + push_handle(state, vm, handle, HandleKind::Overlay, kOverlayMetatable); + return 1; +} + +int texture_unregister(lua_State* state) { + auto& handle = check_handle(state, 1, kTextureMetatable, HandleKind::Texture); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + check_result( + state, svc_texture->unregister(handle.vm->subject, handle.value), "texture.unregister"); + handle.value = 0; + return 0; +} + +int texture_register_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + const char* path = luaL_checkstring(state, 1); + TextureReplacementHandle handle = 0; + check_result( + state, svc_texture->register_file(vm.subject, path, &handle), "texture.register_file"); + push_handle(state, vm, handle, HandleKind::Texture, kTextureMetatable); + return 1; +} + +int texture_register_data(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + luaL_checktype(state, 1, LUA_TTABLE); + luaL_checktype(state, 2, LUA_TTABLE); + + TextureKey key = TEXTURE_KEY_INIT; + key.kind = TEXTURE_KEY_SOURCE; + key.texture_hash = get_hash_field(state, 1, "texture_hash", true); + key.tlut_hash = get_hash_field(state, 1, "tlut_hash", false); + key.width = static_cast(get_optional_int(state, 1, "width", 0)); + key.height = static_cast(get_optional_int(state, 1, "height", 0)); + key.gx_format = static_cast(get_optional_int(state, 1, "gx_format", 0)); + key.has_tlut = get_optional_bool(state, 1, "has_tlut", false); + + lua_getfield(state, 2, "data"); + size_t size = 0; + const char* bytes = luaL_checklstring(state, -1, &size); + TextureData data = TEXTURE_DATA_INIT; + data.data = bytes; + data.size = size; + data.width = static_cast(get_optional_int(state, 2, "width", key.width)); + data.height = static_cast(get_optional_int(state, 2, "height", key.height)); + data.mip_count = static_cast(get_optional_int(state, 2, "mip_count", 1)); + data.gx_format = static_cast(get_optional_int(state, 2, "gx_format", key.gx_format)); + + TextureReplacementHandle handle = 0; + const ModResult result = svc_texture->register_data(vm.subject, &key, &data, &handle); + lua_pop(state, 1); + check_result(state, result, "texture.register_data"); + push_handle(state, vm, handle, HandleKind::Texture, kTextureMetatable); + return 1; +} + +} // namespace + +int open_log(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + lua_newtable(state); + set_function(state, vm, "write", log_write_level); + set_function(state, vm, "trace", log_trace); + set_function(state, vm, "debug", log_debug); + set_function(state, vm, "info", log_info); + set_function(state, vm, "warn", log_warn); + set_function(state, vm, "error", log_error); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_host(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_host == nullptr) { + service_unavailable(state, "HostService"); + } + lua_newtable(state); + lua_pushstring(state, svc_host->version != nullptr ? svc_host->version : ""); + lua_setfield(state, -2, "version"); + set_function(state, vm, "mod_id", host_mod_id); + set_function(state, vm, "mod_name", host_mod_name); + set_function(state, vm, "mod_version", host_mod_version); + set_function(state, vm, "mod_dir", host_mod_dir); + set_function(state, vm, "data_dir", host_data_dir); + set_function(state, vm, "on_update", host_on_update); + set_function(state, vm, "on_shutdown", host_on_shutdown); + set_function(state, vm, "fail", host_fail); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_resource(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_resource == nullptr) { + service_unavailable(state, "ResourceService"); + } + lua_newtable(state); + set_function(state, vm, "load", resource_load); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_overlay(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_overlay == nullptr) { + service_unavailable(state, "OverlayService"); + } + static const luaL_Reg kMethods[] = {{"remove", overlay_remove}, {nullptr, nullptr}}; + create_handle_metatable(state, kOverlayMetatable, kMethods, "OverlayHandle"); + lua_newtable(state); + set_function(state, vm, "add_file", overlay_add_file); + set_function(state, vm, "add_buffer", overlay_add_buffer); + lua_setreadonly(state, -1, true); + return 1; +} + +int open_texture(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_texture == nullptr) { + service_unavailable(state, "TextureService"); + } + static const luaL_Reg kMethods[] = {{"unregister", texture_unregister}, {nullptr, nullptr}}; + create_handle_metatable(state, kTextureMetatable, kMethods, "TextureHandle"); + lua_newtable(state); + set_function(state, vm, "register_file", texture_register_file); + set_function(state, vm, "register_data", texture_register_data); + lua_pushinteger64(state, static_cast(TEXTURE_HASH_WILDCARD)); + lua_setfield(state, -2, "hash_wildcard"); + lua_pushinteger64(state, static_cast(TEXTURE_TLUT_WILDCARD)); + lua_setfield(state, -2, "tlut_wildcard"); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/config.cpp b/mods/luau_runtime/src/config.cpp new file mode 100644 index 0000000000..b198bdb6e7 --- /dev/null +++ b/mods/luau_runtime/src/config.cpp @@ -0,0 +1,243 @@ +#include "runtime.hpp" + +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kConfigVarMetatable[] = "dusklight.config_var"; +constexpr char kConfigSubscriptionMetatable[] = "dusklight.config_subscription"; + +void config_changed(ModContext*, ConfigVarHandle, const ConfigVarValue* value, + const ConfigVarValue* previous, void* userData) { + auto& callback = *static_cast(userData); + if (value == nullptr || previous == nullptr) { + return; + } + push_config_value(callback.vm->state, *value); + push_config_value(callback.vm->state, *previous); + std::string error; + if (!call_ref(*callback.vm, callback.refs[0], 2, 0, kCallbackBudget, error)) { + fail_callback(*callback.vm, "config change callback", error); + } +} + +int config_get(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + switch (handle.configType) { + case CONFIG_VAR_BOOL: { + bool value = false; + check_result( + state, svc_config->get_bool(handle.vm->subject, handle.value, &value), "config get"); + lua_pushboolean(state, value); + break; + } + case CONFIG_VAR_INT: { + int64_t value = 0; + check_result( + state, svc_config->get_int(handle.vm->subject, handle.value, &value), "config get"); + lua_pushinteger64(state, value); + break; + } + case CONFIG_VAR_FLOAT: { + double value = 0; + check_result( + state, svc_config->get_float(handle.vm->subject, handle.value, &value), "config get"); + lua_pushnumber(state, value); + break; + } + case CONFIG_VAR_STRING: { + size_t size = 0; + check_result(state, + svc_config->get_string(handle.vm->subject, handle.value, nullptr, 0, &size), + "config get"); + std::vector value(size + 1); + check_result(state, + svc_config->get_string( + handle.vm->subject, handle.value, value.data(), value.size(), nullptr), + "config get"); + lua_pushlstring(state, value.data(), size); + break; + } + default: + luaL_error(state, "unknown config value type"); + } + return 1; +} + +int config_set(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + ModResult result = MOD_INVALID_ARGUMENT; + switch (handle.configType) { + case CONFIG_VAR_BOOL: + result = svc_config->set_bool( + handle.vm->subject, handle.value, luaL_checkboolean(state, 2) != 0); + break; + case CONFIG_VAR_INT: + result = svc_config->set_int(handle.vm->subject, handle.value, check_int64(state, 2)); + break; + case CONFIG_VAR_FLOAT: + result = + svc_config->set_float(handle.vm->subject, handle.value, luaL_checknumber(state, 2)); + break; + case CONFIG_VAR_STRING: + result = + svc_config->set_string(handle.vm->subject, handle.value, luaL_checkstring(state, 2)); + break; + default: + break; + } + check_result(state, result, "config set"); + return 0; +} + +int config_unregister(lua_State* state) { + auto& handle = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + check_result( + state, svc_config->unregister_var(handle.vm->subject, handle.value), "config unregister"); + handle.value = 0; + return 0; +} + +int config_unsubscribe(lua_State* state) { + auto& handle = + check_handle(state, 1, kConfigSubscriptionMetatable, HandleKind::ConfigSubscription); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + check_result( + state, svc_config->unsubscribe(handle.vm->subject, handle.value), "config unsubscribe"); + handle.value = 0; + return 0; +} + +int subscribe(lua_State* state, ScriptHandle& variable, int functionIndex) { + luaL_checktype(state, functionIndex, LUA_TFUNCTION); + Callback& callback = retain_callback(*variable.vm); + callback.refs[0] = lua_ref(state, functionIndex); + + ConfigSubscriptionHandle subscription = 0; + check_result(state, + svc_config->subscribe( + variable.vm->subject, variable.value, config_changed, &callback, &subscription), + "config.subscribe"); + push_handle(state, *variable.vm, subscription, HandleKind::ConfigSubscription, + kConfigSubscriptionMetatable); + return 1; +} + +int config_subscribe(lua_State* state) { + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + auto& variable = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + return subscribe(state, variable, 2); +} + +int config_var_subscribe(lua_State* state) { + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + auto& variable = check_handle(state, 1, kConfigVarMetatable, HandleKind::ConfigVar); + return subscribe(state, variable, 2); +} + +int config_register(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + luaL_checktype(state, 1, LUA_TTABLE); + + const std::string name = get_optional_string(state, 1, "name"); + const std::string type = get_optional_string(state, 1, "type"); + ConfigVarDesc desc = CONFIG_VAR_DESC_INIT; + desc.name = name.c_str(); + if (type == "bool") { + desc.type = CONFIG_VAR_BOOL; + desc.default_bool = get_optional_bool(state, 1, "default", false); + } else if (type == "int") { + desc.type = CONFIG_VAR_INT; + desc.default_int = get_optional_int(state, 1, "default", 0); + } else if (type == "float") { + desc.type = CONFIG_VAR_FLOAT; + desc.default_float = get_optional_number(state, 1, "default", 0); + } else if (type == "string") { + desc.type = CONFIG_VAR_STRING; + } else { + luaL_error(state, "config type must be 'bool', 'int', 'float', or 'string'"); + } + + std::string defaultString; + if (desc.type == CONFIG_VAR_STRING) { + defaultString = get_optional_string(state, 1, "default"); + desc.default_string = defaultString.c_str(); + } + + ConfigVarHandle handle = 0; + check_result(state, svc_config->register_var(vm.subject, &desc, &handle), "config.register"); + push_handle(state, vm, handle, HandleKind::ConfigVar, kConfigVarMetatable, desc.type); + return 1; +} + +} // namespace + +void push_config_value(lua_State* state, const ConfigVarValue& value) { + switch (value.type) { + case CONFIG_VAR_BOOL: + lua_pushboolean(state, value.bool_value); + break; + case CONFIG_VAR_INT: + lua_pushinteger64(state, value.int_value); + break; + case CONFIG_VAR_FLOAT: + lua_pushnumber(state, value.float_value); + break; + case CONFIG_VAR_STRING: + lua_pushlstring(state, value.string_value != nullptr ? value.string_value : "", + value.string_value != nullptr ? value.string_length : 0); + break; + default: + lua_pushnil(state); + break; + } +} + +int open_config(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_config == nullptr) { + service_unavailable(state, "ConfigService"); + } + static const luaL_Reg kVarMethods[] = { + {"get", config_get}, + {"set", config_set}, + {"subscribe", config_var_subscribe}, + {"unregister", config_unregister}, + {nullptr, nullptr}, + }; + static const luaL_Reg kSubscriptionMethods[] = { + {"unsubscribe", config_unsubscribe}, + {nullptr, nullptr}, + }; + create_handle_metatable(state, kConfigVarMetatable, kVarMethods, "ConfigVar"); + create_handle_metatable( + state, kConfigSubscriptionMetatable, kSubscriptionMethods, "ConfigSubscription"); + + lua_newtable(state); + set_function(state, vm, "register", config_register); + set_function(state, vm, "subscribe", config_subscribe); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/runtime.cpp b/mods/luau_runtime/src/runtime.cpp new file mode 100644 index 0000000000..87676395d4 --- /dev/null +++ b/mods/luau_runtime/src/runtime.cpp @@ -0,0 +1,645 @@ +#include "runtime.hpp" + +#include "Luau/Common.h" +#include "luacode.h" +#include "mods/runtime.h" +#include "mods/service.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +LUAU_FASTFLAG(LuauIntegerLibrary) +LUAU_FASTFLAG(LuauIntegerType2) + +DEFINE_MOD(); +IMPORT_OPTIONAL_SERVICE(LogService, svc_log); +IMPORT_OPTIONAL_SERVICE(HostService, svc_host); +IMPORT_OPTIONAL_SERVICE(ConfigService, svc_config); +IMPORT_OPTIONAL_SERVICE(ResourceService, svc_resource); +IMPORT_OPTIONAL_SERVICE(OverlayService, svc_overlay); +IMPORT_OPTIONAL_SERVICE(TextureService, svc_texture); +IMPORT_OPTIONAL_SERVICE(UiService, svc_ui); + +namespace luau_runtime { +namespace { + +std::unordered_map> s_vms; + +void* limited_realloc(void* userData, void* pointer, size_t oldSize, size_t newSize) { + auto& budget = *static_cast(userData); + if (newSize == 0) { + std::free(pointer); + budget.used -= std::min(budget.used, oldSize); + return nullptr; + } + + const size_t growth = newSize > oldSize ? newSize - oldSize : 0; + if (growth > budget.limit - std::min(budget.used, budget.limit)) { + return nullptr; + } + void* result = std::realloc(pointer, newSize); + if (result != nullptr) { + budget.used -= std::min(budget.used, oldSize); + budget.used += newSize; + } + return result; +} + +int traceback_handler(lua_State* state) { + const char* message = lua_tostring(state, 1); + luaL_traceback(state, state, message != nullptr ? message : "Luau error", 1); + return 1; +} + +class DeadlineScope { +public: + DeadlineScope(Vm& vm, std::chrono::steady_clock::duration budget) + : m_vm{vm}, m_previousDeadline{vm.deadline}, m_previousActive{vm.deadlineActive} { + const auto requested = std::chrono::steady_clock::now() + budget; + if (!vm.deadlineActive || requested < vm.deadline) { + vm.deadline = requested; + } + vm.deadlineActive = true; + ++vm.callDepth; + } + + ~DeadlineScope() { + --m_vm.callDepth; + m_vm.deadline = m_previousDeadline; + m_vm.deadlineActive = m_previousActive; + } + +private: + Vm& m_vm; + std::chrono::steady_clock::time_point m_previousDeadline; + bool m_previousActive; +}; + +bool protected_call(lua_State* state, Vm& vm, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError) { + const int functionIndex = lua_gettop(state) - argumentCount; + lua_pushcfunction(state, traceback_handler, "dusklight traceback"); + lua_insert(state, functionIndex); + + DeadlineScope deadline{vm, budget}; + const int status = lua_pcall(state, argumentCount, resultCount, functionIndex); + if (status != LUA_OK) { + const char* message = lua_tostring(state, -1); + outError = message != nullptr ? message : "unknown Luau error"; + lua_pop(state, 1); + lua_remove(state, functionIndex); + return false; + } + lua_remove(state, functionIndex); + return true; +} + +std::optional normalize_module_path( + std::string_view currentPath, std::string_view requested) { + if ((!requested.starts_with("./") && !requested.starts_with("../")) || + requested.find('\\') != std::string_view::npos) + { + return std::nullopt; + } + + std::vector parts; + const auto parentEnd = currentPath.rfind('/'); + std::string combined; + if (parentEnd != std::string_view::npos) { + combined.assign(currentPath.substr(0, parentEnd + 1)); + } + combined.append(requested); + + size_t begin = 0; + while (begin <= combined.size()) { + const size_t end = combined.find('/', begin); + const auto part = std::string_view{combined}.substr( + begin, end == std::string::npos ? combined.size() - begin : end - begin); + if (part.empty() || part == ".") { + } else if (part == "..") { + if (parts.empty()) { + return std::nullopt; + } + parts.pop_back(); + } else { + parts.push_back(part); + } + if (end == std::string::npos) { + break; + } + begin = end + 1; + } + if (parts.empty()) { + return std::nullopt; + } + + std::string normalized; + for (const auto part : parts) { + if (!normalized.empty()) { + normalized.push_back('/'); + } + normalized.append(part); + } + if (!normalized.ends_with(".luau")) { + normalized += ".luau"; + } + return normalized; +} + +ModuleOpenFn module_factory(std::string_view name) { + if (name == "dusklight.log") { + return open_log; + } + if (name == "dusklight.host") { + return open_host; + } + if (name == "dusklight.resource") { + return open_resource; + } + if (name == "dusklight.overlay") { + return open_overlay; + } + if (name == "dusklight.texture") { + return open_texture; + } + if (name == "dusklight.config") { + return open_config; + } + if (name == "dusklight.ui") { + return open_ui; + } + return nullptr; +} + +int module_require(lua_State* state); +int print(lua_State* state); + +void install_module_require(lua_State* state, Vm& vm, std::string_view currentPath) { + lua_pushlightuserdata(state, &vm); + lua_pushlstring(state, currentPath.data(), currentPath.size()); + lua_pushcclosure(state, module_require, "require", 2); + lua_setglobal(state, "require"); +} + +void install_globals(Vm& vm) { + push_vm_closure(vm.state, vm, print, "print"); + lua_setglobal(vm.state, "print"); +} + +bool load_source_module( + lua_State* caller, Vm& vm, const std::string& path, bool keepResult, std::string& outError) { + if (svc_resource == nullptr) { + outError = "ResourceService is not available in this Dusklight build"; + return false; + } + + ResourceBuffer buffer = RESOURCE_BUFFER_INIT; + const ModResult loadResult = svc_resource->load(vm.subject, path.c_str(), &buffer); + if (loadResult != MOD_OK) { + outError = loadResult == MOD_UNAVAILABLE ? "module not found: res/" + path : + "failed to load module: res/" + path; + return false; + } + std::string source; + if (buffer.data != nullptr) { + source.assign(static_cast(buffer.data), buffer.size); + } + svc_resource->free(vm.subject, &buffer); + + size_t bytecodeSize = 0; + lua_CompileOptions options{}; + options.optimizationLevel = 1; + options.debugLevel = 1; + char* bytecode = luau_compile(source.data(), source.size(), &options, &bytecodeSize); + if (bytecode == nullptr) { + outError = "Luau compiler ran out of memory"; + return false; + } + + lua_State* moduleState = lua_newthread(caller); + if (moduleState == nullptr) { + std::free(bytecode); + outError = "Luau VM ran out of memory"; + return false; + } + luaL_sandboxthread(moduleState); + install_module_require(moduleState, vm, path); + + const std::string chunkName = "@res/" + path; + const int loadStatus = luau_load(moduleState, chunkName.c_str(), bytecode, bytecodeSize, 0); + std::free(bytecode); + if (loadStatus != LUA_OK) { + const char* message = lua_tostring(moduleState, -1); + outError = message != nullptr ? message : "failed to load Luau bytecode"; + lua_pop(caller, 1); + return false; + } + if (!protected_call(moduleState, vm, 0, keepResult ? 1 : 0, kLifecycleBudget, outError)) { + lua_pop(caller, 1); + return false; + } + if (!keepResult) { + lua_pop(caller, 1); + return true; + } + if (lua_isnil(moduleState, -1)) { + outError = "module res/" + path + " must return a value"; + lua_pop(caller, 1); + return false; + } + + lua_xmove(moduleState, caller, 1); + lua_remove(caller, -2); + return true; +} + +int module_require(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const std::string requested = luaL_checkstring(state, 1); + + std::string moduleName; + ModuleOpenFn factory = nullptr; + if (requested.starts_with("dusklight.")) { + moduleName = requested; + factory = module_factory(moduleName); + if (factory == nullptr) { + luaL_error(state, "unknown module '%s'", moduleName.c_str()); + } + } else { + const char* currentPath = lua_tostring(state, lua_upvalueindex(2)); + const auto normalized = + normalize_module_path(currentPath != nullptr ? currentPath : "main.luau", requested); + if (!normalized.has_value()) { + luaL_error( + state, "module paths must be relative and remain inside the mod's res directory"); + } + moduleName = *normalized; + } + + if (const auto found = vm.moduleRefs.find(moduleName); found != vm.moduleRefs.end()) { + lua_getref(state, found->second); + return 1; + } + if (!vm.loadingModules.insert(moduleName).second) { + luaL_error(state, "cyclic require of '%s'", moduleName.c_str()); + } + + std::string error; + if (factory != nullptr) { + factory(state); + } else if (!load_source_module(state, vm, moduleName, true, error)) { + vm.loadingModules.erase(moduleName); + luaL_error(state, "%s", error.c_str()); + } + vm.loadingModules.erase(moduleName); + + const int ref = lua_ref(state, -1); + vm.moduleRefs.emplace(moduleName, ref); + return 1; +} + +int print(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_log == nullptr) { + service_unavailable(state, "LogService"); + } + + std::string value; + int const numArgs = lua_gettop(state); + for (int i = 0; i < numArgs; i += 1) { + if (i != 0) { + value.push_back('\t'); + } + + size_t length; + char const* str = luaL_tolstring(state, i + 1, &length); + value.append(str, length); + lua_pop(state, 1); + } + + svc_log->info(vm.subject, value.data()); + return 0; +} + +ModResult runtime_activate(ModContext*, ModContext* subject, ModError* outError) { + if (subject == nullptr) { + return set_error(outError, MOD_INVALID_ARGUMENT, "Delegated mod context is null"); + } + if (s_vms.contains(subject)) { + return set_error(outError, MOD_CONFLICT, "Delegated mod is already active"); + } + + auto vm = std::make_unique(); + vm->subject = subject; + vm->state = lua_newstate(limited_realloc, &vm->memory); + if (vm->state == nullptr) { + return set_error(outError, MOD_ERROR, "Failed to create Luau VM"); + } + lua_callbacks(vm->state)->userdata = vm.get(); +#if NDEBUG // Annoying for debuggers + lua_callbacks(vm->state)->interrupt = [](lua_State* state, int gc) { + auto* current = static_cast(lua_callbacks(state)->userdata); + if (gc < 0 && current != nullptr && current->deadlineActive && + std::chrono::steady_clock::now() > current->deadline) + { + luaL_error(state, "script execution exceeded its time budget"); + } + }; +#endif + luaL_openlibs(vm->state); + install_globals(*vm); + luaL_sandbox(vm->state); + + std::string error; + vm->loadingModules.insert("main.luau"); + const bool loadedMain = load_source_module(vm->state, *vm, "main.luau", false, error); + vm->loadingModules.erase("main.luau"); + if (!loadedMain) { + return set_error(outError, MOD_ERROR, error); + } + + s_vms.emplace(subject, std::move(vm)); + return MOD_OK; +} + +ModResult runtime_update(ModContext*, ModContext* subject, ModError* outError) { + const auto found = s_vms.find(subject); + if (found == s_vms.end()) { + return set_error(outError, MOD_INVALID_ARGUMENT, "Delegated mod is not active"); + } + Vm& vm = *found->second; + const size_t callbackCount = vm.updateRefs.size(); + if (callbackCount == 0) { + return MOD_OK; + } + + DeadlineScope deadline{vm, kUpdateBudget}; + std::string error; + for (size_t i = 0; i < callbackCount; ++i) { + const int ref = vm.updateRefs[i]; + if (!call_ref(vm, ref, 0, 0, kUpdateBudget, error)) { + return set_error(outError, MOD_ERROR, error); + } + } + return MOD_OK; +} + +ModResult runtime_deactivate(ModContext*, ModContext* subject, ModError*) { + const auto found = s_vms.find(subject); + if (found == s_vms.end()) { + return MOD_OK; + } + + { + Vm& vm = *found->second; + DeadlineScope deadline{vm, kLifecycleBudget}; + const size_t callbackCount = vm.shutdownRefs.size(); + for (size_t i = callbackCount; i > 0; --i) { + std::string error; + const int ref = vm.shutdownRefs[i - 1]; + if (!call_ref(vm, ref, 0, 0, kLifecycleBudget, error) && svc_log != nullptr) { + svc_log->write(subject, LOG_LEVEL_ERROR, error.c_str()); + } + } + } + s_vms.erase(found); + return MOD_OK; +} + +constexpr ModRuntimeService s_runtimeService{ + .header = SERVICE_HEADER(ModRuntimeService, 1, 0), + .activate = runtime_activate, + .update = runtime_update, + .deactivate = runtime_deactivate, +}; +EXPORT_SERVICE_AS(s_runtimeService, "dev.twilitrealm.luau"); + +} // namespace + +Vm::~Vm() { + if (state != nullptr) { + lua_close(state); + } +} + +Vm& vm_from_upvalue(lua_State* state) { + auto* vm = static_cast(lua_tolightuserdata(state, lua_upvalueindex(1))); + if (vm == nullptr) { + luaL_error(state, "missing Luau runtime context"); + } + return *vm; +} + +void push_vm_closure(lua_State* state, Vm& vm, lua_CFunction function, const char* name) { + lua_pushlightuserdata(state, &vm); + lua_pushcclosure(state, function, name, 1); +} + +void set_function(lua_State* state, Vm& vm, const char* name, lua_CFunction function) { + push_vm_closure(state, vm, function, name); + lua_setfield(state, -2, name); +} + +[[noreturn]] void service_unavailable(lua_State* state, const char* name) { + luaL_error(state, "%s is not available in this Dusklight build", name); +} + +void check_result(lua_State* state, ModResult result, const char* operation) { + if (result == MOD_OK) { + return; + } + const char* resultName = "error"; + switch (result) { + case MOD_UNAVAILABLE: + resultName = "unavailable"; + break; + case MOD_UNSUPPORTED: + resultName = "unsupported"; + break; + case MOD_CONFLICT: + resultName = "conflict"; + break; + case MOD_INVALID_ARGUMENT: + resultName = "invalid argument"; + break; + default: + break; + } + luaL_error(state, "%s failed: %s", operation, resultName); +} + +bool get_optional_bool(lua_State* state, int table, const char* field, bool fallback) { + lua_getfield(state, table, field); + const bool value = lua_isnil(state, -1) ? fallback : luaL_checkboolean(state, -1) != 0; + lua_pop(state, 1); + return value; +} + +bool to_int64(lua_State* state, int index, int64_t& outValue) { + if (lua_isinteger64(state, index)) { + outValue = lua_tointeger64(state, index, nullptr); + return true; + } + if (!lua_isnumber(state, index)) { + return false; + } + const double value = lua_tonumber(state, index); + constexpr double kMaxSafeInteger = 9007199254740991.0; + if (!std::isfinite(value) || value < -kMaxSafeInteger || value > kMaxSafeInteger || + std::trunc(value) != value) + { + return false; + } + outValue = static_cast(value); + return true; +} + +int64_t check_int64(lua_State* state, int index) { + int64_t value = 0; + if (!to_int64(state, index, value)) { + luaL_argerror(state, index, "integer value expected"); + } + return value; +} + +int64_t get_optional_int(lua_State* state, int table, const char* field, int64_t fallback) { + lua_getfield(state, table, field); + const int64_t value = lua_isnil(state, -1) ? fallback : check_int64(state, -1); + lua_pop(state, 1); + return value; +} + +double get_optional_number(lua_State* state, int table, const char* field, double fallback) { + lua_getfield(state, table, field); + const double value = lua_isnil(state, -1) ? fallback : luaL_checknumber(state, -1); + lua_pop(state, 1); + return value; +} + +std::string get_optional_string( + lua_State* state, int table, const char* field, std::string fallback) { + lua_getfield(state, table, field); + if (!lua_isnil(state, -1)) { + size_t length = 0; + const char* value = luaL_checklstring(state, -1, &length); + fallback.assign(value, length); + } + lua_pop(state, 1); + return fallback; +} + +int ref_optional_function(lua_State* state, int table, const char* field) { + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + return LUA_NOREF; + } + luaL_argexpected(state, lua_isfunction(state, -1), table, "function field"); + const int ref = lua_ref(state, -1); + lua_pop(state, 1); + return ref; +} + +int ref_required_function(lua_State* state, int table, const char* field) { + const int ref = ref_optional_function(state, table, field); + if (ref == LUA_NOREF) { + luaL_error(state, "field '%s' is required", field); + } + return ref; +} + +Callback& retain_callback(Vm& vm) { + auto callback = std::make_unique(); + callback->vm = &vm; + callback->refs.fill(LUA_NOREF); + vm.callbacks.push_back(std::move(callback)); + return *vm.callbacks.back(); +} + +bool call_ref(Vm& vm, int ref, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError) { + lua_State* state = vm.state; + lua_getref(state, ref); + if (!lua_isfunction(state, -1)) { + lua_pop(state, 1); + outError = "callback is no longer a function"; + return false; + } + if (argumentCount != 0) { + lua_insert(state, -argumentCount - 1); + } + return protected_call(state, vm, argumentCount, resultCount, budget, outError); +} + +void fail_callback(Vm& vm, std::string_view callbackName, std::string_view error) { + const std::string message = std::string{callbackName} + ": " + std::string{error}; + if (svc_host != nullptr) { + svc_host->fail(vm.subject, MOD_ERROR, message.c_str()); + } else if (svc_log != nullptr) { + svc_log->write(vm.subject, LOG_LEVEL_ERROR, message.c_str()); + } +} + +ModResult set_error(ModError* outError, ModResult result, std::string_view message) { + if (outError != nullptr && outError->struct_size >= sizeof(ModError)) { + outError->code = result; + const size_t size = std::min(message.size(), sizeof(outError->message) - 1); + std::memcpy(outError->message, message.data(), size); + outError->message[size] = '\0'; + } + return result; +} + +void create_handle_metatable( + lua_State* state, const char* name, const luaL_Reg* methods, const char* typeName) { + luaL_newmetatable(state, name); + luaL_register(state, nullptr, methods); + lua_pushvalue(state, -1); + lua_setfield(state, -2, "__index"); + lua_pushstring(state, typeName); + lua_setfield(state, -2, "__type"); + lua_setreadonly(state, -1, true); + lua_pop(state, 1); +} + +ScriptHandle& check_handle(lua_State* state, int index, const char* metatable, HandleKind kind) { + auto* handle = static_cast(luaL_checkudata(state, index, metatable)); + if (handle == nullptr || handle->kind != kind || handle->vm == nullptr || handle->value == 0) { + luaL_argerror(state, index, "stale handle"); + } + return *handle; +} + +void push_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind, const char* metatable, + ConfigVarType configType) { + auto* handle = static_cast(lua_newuserdata(state, sizeof(ScriptHandle))); + *handle = ScriptHandle{.vm = &vm, .value = value, .kind = kind, .configType = configType}; + luaL_getmetatable(state, metatable); + lua_setmetatable(state, -2); +} + +} // namespace luau_runtime + +extern "C" { +MOD_EXPORT ModResult mod_initialize(ModError*) { + FFlag::LuauIntegerType2.value = true; + FFlag::LuauIntegerLibrary.value = true; + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + luau_runtime::s_vms.clear(); + return MOD_OK; +} +} diff --git a/mods/luau_runtime/src/runtime.hpp b/mods/luau_runtime/src/runtime.hpp new file mode 100644 index 0000000000..2916a817e5 --- /dev/null +++ b/mods/luau_runtime/src/runtime.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "lua.h" +#include "lualib.h" + +#include "mods/api.h" +#include "mods/svc/config.h" +#include "mods/svc/host.h" +#include "mods/svc/log.h" +#include "mods/svc/overlay.h" +#include "mods/svc/resource.h" +#include "mods/svc/texture.h" +#include "mods/svc/ui.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace luau_runtime { + +constexpr size_t kMemoryLimit = 64u * 1024u * 1024u; +constexpr auto kUpdateBudget = std::chrono::milliseconds{250}; +constexpr auto kLifecycleBudget = std::chrono::seconds{5}; +constexpr auto kCallbackBudget = std::chrono::milliseconds{250}; + +struct MemoryBudget { + size_t used = 0; + size_t limit = kMemoryLimit; +}; + +struct Vm; + +struct Callback { + Vm* vm = nullptr; + std::array refs{}; + std::string returnedString; + int tag = 0; +}; + +struct Vm { + MemoryBudget memory; + lua_State* state = nullptr; + ModContext* subject = nullptr; + std::vector updateRefs; + std::vector shutdownRefs; + std::unordered_map moduleRefs; + std::unordered_set loadingModules; + std::vector> callbacks; + std::chrono::steady_clock::time_point deadline{}; + unsigned callDepth = 0; + bool deadlineActive = false; + + ~Vm(); +}; + +enum class HandleKind : uint8_t { + ConfigVar, + ConfigSubscription, + Overlay, + Texture, + UiWindow, + UiDialog, + UiElement, + UiStyle, + UiMenuTab, + UiList, +}; + +struct ScriptHandle { + Vm* vm = nullptr; + uint64_t value = 0; + HandleKind kind = HandleKind::ConfigVar; + ConfigVarType configType = CONFIG_VAR_BOOL; +}; + +using ModuleOpenFn = int (*)(lua_State* state); + +Vm& vm_from_upvalue(lua_State* state); +void push_vm_closure(lua_State* state, Vm& vm, lua_CFunction function, const char* name); +void set_function(lua_State* state, Vm& vm, const char* name, lua_CFunction function); + +[[noreturn]] void service_unavailable(lua_State* state, const char* name); +void check_result(lua_State* state, ModResult result, const char* operation); + +bool get_optional_bool(lua_State* state, int table, const char* field, bool fallback); +bool to_int64(lua_State* state, int index, int64_t& outValue); +int64_t check_int64(lua_State* state, int index); +int64_t get_optional_int(lua_State* state, int table, const char* field, int64_t fallback); +double get_optional_number(lua_State* state, int table, const char* field, double fallback); +std::string get_optional_string( + lua_State* state, int table, const char* field, std::string fallback = {}); +int ref_optional_function(lua_State* state, int table, const char* field); +int ref_required_function(lua_State* state, int table, const char* field); + +Callback& retain_callback(Vm& vm); +bool call_ref(Vm& vm, int ref, int argumentCount, int resultCount, + std::chrono::steady_clock::duration budget, std::string& outError); +void fail_callback(Vm& vm, std::string_view callbackName, std::string_view error); +ModResult set_error(ModError* outError, ModResult result, std::string_view message); + +void create_handle_metatable( + lua_State* state, const char* name, const luaL_Reg* methods, const char* typeName); +ScriptHandle& check_handle(lua_State* state, int index, const char* metatable, HandleKind kind); +void push_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind, const char* metatable, + ConfigVarType configType = CONFIG_VAR_BOOL); + +void push_config_value(lua_State* state, const ConfigVarValue& value); +void push_ui_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind); + +int open_log(lua_State* state); +int open_host(lua_State* state); +int open_resource(lua_State* state); +int open_overlay(lua_State* state); +int open_texture(lua_State* state); +int open_config(lua_State* state); +int open_ui(lua_State* state); + +} // namespace luau_runtime diff --git a/mods/luau_runtime/src/ui.cpp b/mods/luau_runtime/src/ui.cpp new file mode 100644 index 0000000000..7c3acc1296 --- /dev/null +++ b/mods/luau_runtime/src/ui.cpp @@ -0,0 +1,856 @@ +#include "runtime.hpp" + +#include +#include +#include +#include + +namespace luau_runtime { +namespace { + +constexpr char kUiWindowMetatable[] = "dusklight.ui_window"; +constexpr char kUiDialogMetatable[] = "dusklight.ui_dialog"; +constexpr char kUiElementMetatable[] = "dusklight.ui_element"; +constexpr char kUiStyleMetatable[] = "dusklight.ui_style"; +constexpr char kUiMenuTabMetatable[] = "dusklight.ui_menu_tab"; +constexpr char kUiListMetatable[] = "dusklight.ui_list"; + +const char* ui_metatable(HandleKind kind) { + switch (kind) { + case HandleKind::UiWindow: + return kUiWindowMetatable; + case HandleKind::UiDialog: + return kUiDialogMetatable; + case HandleKind::UiStyle: + return kUiStyleMetatable; + case HandleKind::UiMenuTab: + return kUiMenuTabMetatable; + case HandleKind::UiList: + return kUiListMetatable; + default: + return kUiElementMetatable; + } +} + +ScriptHandle& check_ui_handle(lua_State* state, int index, HandleKind kind) { + return check_handle(state, index, ui_metatable(kind), kind); +} + +ScriptHandle& check_config_var(lua_State* state, int index) { + luaL_checktype(state, index, LUA_TUSERDATA); + auto* handle = static_cast(lua_touserdata(state, index)); + if (handle == nullptr || handle->kind != HandleKind::ConfigVar || handle->value == 0 || + handle->vm == nullptr) + { + luaL_argerror(state, index, "expected a live ConfigVar"); + } + return *handle; +} + +bool call_callback(Callback& callback, int ref, int argumentCount, int resultCount, + const char* name, std::string* outError = nullptr) { + std::string error; + if (call_ref(*callback.vm, ref, argumentCount, resultCount, kCallbackBudget, error)) { + return true; + } + if (outError != nullptr) { + *outError = std::move(error); + } else { + fail_callback(*callback.vm, name, error); + } + return false; +} + +ModResult call_build( + Callback& callback, int ref, int argumentCount, const char* name, ModError* outError) { + std::string error; + if (call_callback(callback, ref, argumentCount, 0, name, &error)) { + return MOD_OK; + } + return set_error(outError, MOD_ERROR, error); +} + +bool call_predicate(Callback& callback, int ref, int argumentCount, const char* name) { + if (!call_callback(callback, ref, argumentCount, 1, name)) { + return false; + } + lua_State* state = callback.vm->state; + const bool result = lua_toboolean(state, -1) != 0; + lua_pop(state, 1); + return result; +} + +void control_get(ModContext*, void* userData, UiControlValue* outValue) { + auto& callback = *static_cast(userData); + if (outValue == nullptr || !call_callback(callback, callback.refs[0], 0, 1, "control get")) { + return; + } + lua_State* state = callback.vm->state; + switch (static_cast(callback.tag)) { + case UI_CONTROL_TOGGLE: + outValue->bool_value = lua_toboolean(state, -1) != 0; + break; + case UI_CONTROL_NUMBER: + case UI_CONTROL_SELECT: { + int64_t value = 0; + if (!to_int64(state, -1, value)) { + fail_callback(*callback.vm, "control get", "callback must return an integer"); + } else { + outValue->int_value = value; + } + break; + } + case UI_CONTROL_STRING: + case UI_CONTROL_COLOR: + case UI_CONTROL_FILE_PICKER: { + size_t length = 0; + const char* value = lua_tolstring(state, -1, &length); + if (value == nullptr) { + fail_callback(*callback.vm, "control get", "callback must return a string"); + } else { + callback.returnedString.assign(value, length); + outValue->string_value = callback.returnedString.c_str(); + } + break; + } + default: + break; + } + lua_pop(state, 1); +} + +void control_set(ModContext*, void* userData, const UiControlValue* value) { + auto& callback = *static_cast(userData); + if (value == nullptr) { + return; + } + lua_State* state = callback.vm->state; + switch (static_cast(callback.tag)) { + case UI_CONTROL_TOGGLE: + lua_pushboolean(state, value->bool_value); + break; + case UI_CONTROL_NUMBER: + case UI_CONTROL_SELECT: + lua_pushinteger64(state, value->int_value); + break; + case UI_CONTROL_STRING: + case UI_CONTROL_COLOR: + case UI_CONTROL_FILE_PICKER: + lua_pushstring(state, value->string_value != nullptr ? value->string_value : ""); + break; + default: + return; + } + call_callback(callback, callback.refs[1], 1, 0, "control set"); +} + +bool control_disabled(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[3], 0, "control is_disabled"); +} + +bool control_modified(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[4], 0, "control is_modified"); +} + +bool control_selected(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[5], 0, "control is_selected"); +} + +void control_pressed(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + call_callback(callback, callback.refs[2], 0, 0, "control on_pressed"); +} + +ModResult panel_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 1, "panel build", outError); +} + +ModResult panel_update(ModContext*, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + return call_build(callback, callback.refs[1], 0, "panel update", outError); +} + +ModResult group_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 1, "group build", outError); +} + +ModResult tab_build(ModContext*, UiWindowHandle window, UiElementHandle left, UiElementHandle right, + void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, window, HandleKind::UiWindow); + push_ui_handle(callback.vm->state, *callback.vm, left, HandleKind::UiElement); + push_ui_handle(callback.vm->state, *callback.vm, right, HandleKind::UiElement); + return call_build(callback, callback.refs[0], 3, "window tab build", outError); +} + +void window_closed(ModContext*, UiWindowHandle window, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, window, HandleKind::UiWindow); + call_callback(callback, callback.refs[0], 1, 0, "window on_closed"); +} + +void dialog_action(ModContext*, UiDialogHandle dialog, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, dialog, HandleKind::UiDialog); + call_callback(callback, callback.refs[0], 1, 0, "dialog action"); +} + +bool dialog_action_disabled(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + return call_predicate(callback, callback.refs[1], 0, "dialog action is_disabled"); +} + +void dialog_dismissed(ModContext*, UiDialogHandle dialog, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, dialog, HandleKind::UiDialog); + call_callback(callback, callback.refs[0], 1, 0, "dialog on_dismiss"); +} + +ModResult dialog_build(ModContext*, UiElementHandle pane, void* userData, ModError* outError) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, pane, HandleKind::UiElement); + return call_build(callback, callback.refs[1], 1, "dialog build", outError); +} + +void menu_selected(ModContext*, void* userData) { + auto& callback = *static_cast(userData); + call_callback(callback, callback.refs[0], 0, 0, "menu tab on_selected"); +} + +void list_pressed(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + call_callback(callback, callback.refs[0], 2, 0, "list on_pressed"); +} + +bool list_selected(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + return call_predicate(callback, callback.refs[1], 2, "list is_selected"); +} + +bool list_disabled(ModContext*, UiListHandle list, uint64_t key, void* userData) { + auto& callback = *static_cast(userData); + push_ui_handle(callback.vm->state, *callback.vm, list, HandleKind::UiList); + lua_pushinteger64(callback.vm->state, static_cast(key)); + return call_predicate(callback, callback.refs[2], 2, "list is_disabled"); +} + +std::vector string_array(lua_State* state, int table, const char* field) { + std::vector result; + lua_getfield(state, table, field); + if (lua_isnil(state, -1)) { + lua_pop(state, 1); + return result; + } + luaL_checktype(state, -1, LUA_TTABLE); + const int count = lua_objlen(state, -1); + result.reserve(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, -1, i); + result.emplace_back(luaL_checkstring(state, -1)); + lua_pop(state, 1); + } + lua_pop(state, 1); + return result; +} + +std::vector list_items(lua_State* state, int table, std::vector& labels) { + luaL_checktype(state, table, LUA_TTABLE); + const int count = lua_objlen(state, table); + labels.reserve(count); + std::vector items; + items.reserve(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, table, i); + luaL_checktype(state, -1, LUA_TTABLE); + labels.push_back(get_optional_string(state, -1, "label")); + UiListItem item = UI_LIST_ITEM_INIT; + item.key = static_cast(get_optional_int(state, -1, "key", 0)); + items.push_back(item); + lua_pop(state, 1); + } + for (size_t i = 0; i < items.size(); ++i) { + items[i].label = labels[i].c_str(); + } + return items; +} + +UiControlKind control_kind(lua_State* state, const std::string& kind) { + if (kind == "button") + return UI_CONTROL_BUTTON; + if (kind == "toggle") + return UI_CONTROL_TOGGLE; + if (kind == "number") + return UI_CONTROL_NUMBER; + if (kind == "string") + return UI_CONTROL_STRING; + if (kind == "select") + return UI_CONTROL_SELECT; + if (kind == "color") + return UI_CONTROL_COLOR; + if (kind == "group") + return UI_CONTROL_GROUP; + if (kind == "file_picker") + return UI_CONTROL_FILE_PICKER; + luaL_error(state, "unknown UI control kind '%s'", kind.c_str()); +} + +UiStyleScope style_scope(lua_State* state, const std::string& scope) { + if (scope == "prelaunch") + return UI_SCOPE_PRELAUNCH; + if (scope == "window") + return UI_SCOPE_WINDOW; + if (scope == "menu_bar") + return UI_SCOPE_MENU_BAR; + if (scope == "overlay") + return UI_SCOPE_OVERLAY; + if (scope == "touch_controls") + return UI_SCOPE_TOUCH_CONTROLS; + if (scope == "graphics_tuner") + return UI_SCOPE_GRAPHICS_TUNER; + luaL_error(state, "unknown UI style scope '%s'", scope.c_str()); +} + +int pane_add_section(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->pane_add_section(pane.vm->subject, pane.value, luaL_checkstring(state, 2)), + "ui pane_add_section"); + return 0; +} + +int pane_add_text(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_text(pane.vm->subject, pane.value, luaL_checkstring(state, 2), &element), + "ui pane_add_text"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_rml(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_rml(pane.vm->subject, pane.value, luaL_checkstring(state, 2), &element), + "ui pane_add_rml"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_progress(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_progress( + pane.vm->subject, pane.value, static_cast(luaL_checknumber(state, 2)), &element), + "ui pane_add_progress"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_control(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + luaL_checktype(state, 2, LUA_TTABLE); + + UiControlDesc desc = UI_CONTROL_DESC_INIT; + const std::string kind = get_optional_string(state, 2, "kind"); + const std::string label = get_optional_string(state, 2, "label"); + const std::string help = get_optional_string(state, 2, "help_rml"); + const std::string prefix = get_optional_string(state, 2, "prefix"); + const std::string suffix = get_optional_string(state, 2, "suffix"); + desc.kind = control_kind(state, kind); + desc.label = label.c_str(); + desc.help_rml = help.empty() ? nullptr : help.c_str(); + desc.min = get_optional_int(state, 2, "min", 0); + desc.max = get_optional_int(state, 2, "max", 0); + desc.step = get_optional_int(state, 2, "step", 1); + desc.prefix = prefix.empty() ? nullptr : prefix.c_str(); + desc.suffix = suffix.empty() ? nullptr : suffix.c_str(); + desc.max_length = static_cast(get_optional_int(state, 2, "max_length", 0)); + desc.color_alpha = get_optional_bool(state, 2, "color_alpha", false); + desc.directory_mode = get_optional_bool(state, 2, "directory_mode", false); + desc.string_set_mode = get_optional_string(state, 2, "string_set_mode") == "change" ? + UI_STRING_SET_ON_CHANGE : + UI_STRING_SET_ON_COMMIT; + + std::vector options = string_array(state, 2, "options"); + std::vector optionPointers; + optionPointers.reserve(options.size()); + for (const auto& option : options) + optionPointers.push_back(option.c_str()); + desc.options = optionPointers.data(); + desc.option_count = optionPointers.size(); + + std::vector presets = string_array(state, 2, "color_presets"); + std::vector presetPointers; + presetPointers.reserve(presets.size()); + for (const auto& preset : presets) + presetPointers.push_back(preset.c_str()); + desc.color_presets = presetPointers.data(); + desc.color_preset_count = presetPointers.size(); + + std::vector filterNames; + std::vector filterPatterns; + std::vector filters; + lua_getfield(state, 2, "file_filters"); + if (!lua_isnil(state, -1)) { + luaL_checktype(state, -1, LUA_TTABLE); + const int count = lua_objlen(state, -1); + filterNames.reserve(count); + filterPatterns.reserve(count); + filters.resize(count); + for (int i = 1; i <= count; ++i) { + lua_rawgeti(state, -1, i); + filterNames.push_back(get_optional_string(state, -1, "name")); + filterPatterns.push_back(get_optional_string(state, -1, "pattern")); + lua_pop(state, 1); + } + for (int i = 0; i < count; ++i) { + filters[i] = {filterNames[i].c_str(), filterPatterns[i].c_str()}; + } + } + lua_pop(state, 1); + desc.file_filters = filters.data(); + desc.file_filter_count = filters.size(); + + Callback& callback = retain_callback(*pane.vm); + callback.tag = desc.kind; + callback.refs[2] = ref_optional_function(state, 2, "on_pressed"); + callback.refs[3] = ref_optional_function(state, 2, "is_disabled"); + callback.refs[4] = ref_optional_function(state, 2, "is_modified"); + callback.refs[5] = ref_optional_function(state, 2, "is_selected"); + desc.user_data = &callback; + desc.on_pressed = callback.refs[2] != LUA_NOREF ? control_pressed : nullptr; + desc.is_disabled = callback.refs[3] != LUA_NOREF ? control_disabled : nullptr; + desc.is_modified = callback.refs[4] != LUA_NOREF ? control_modified : nullptr; + desc.is_selected = callback.refs[5] != LUA_NOREF ? control_selected : nullptr; + + lua_getfield(state, 2, "config_var"); + if (!lua_isnil(state, -1)) { + auto& variable = check_config_var(state, -1); + desc.binding = UI_BINDING_CONFIG_VAR; + desc.config_var = variable.value; + } else if (desc.kind != UI_CONTROL_BUTTON && desc.kind != UI_CONTROL_GROUP) { + desc.binding = UI_BINDING_CALLBACKS; + callback.refs[0] = ref_required_function(state, 2, "get"); + callback.refs[1] = ref_required_function(state, 2, "set"); + desc.get = control_get; + desc.set = control_set; + } + lua_pop(state, 1); + + UiElementHandle element = 0; + check_result(state, svc_ui->pane_add_control(pane.vm->subject, pane.value, &desc, &element), + "ui pane_add_control"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_group(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + auto& target = check_ui_handle(state, 2, HandleKind::UiElement); + luaL_checktype(state, 3, LUA_TTABLE); + const std::string label = get_optional_string(state, 3, "label"); + Callback& callback = retain_callback(*pane.vm); + callback.refs[0] = ref_required_function(state, 3, "build"); + UiGroupDesc desc = UI_GROUP_DESC_INIT; + desc.label = label.c_str(); + desc.build = group_build; + desc.user_data = &callback; + UiElementHandle element = 0; + check_result(state, + svc_ui->pane_add_group(pane.vm->subject, pane.value, target.value, &desc, &element), + "ui pane_add_group"); + push_ui_handle(state, *pane.vm, element, HandleKind::UiElement); + return 1; +} + +int pane_add_list(lua_State* state) { + auto& pane = check_ui_handle(state, 1, HandleKind::UiElement); + luaL_checktype(state, 2, LUA_TTABLE); + Callback& callback = retain_callback(*pane.vm); + callback.refs[0] = ref_required_function(state, 2, "on_pressed"); + callback.refs[1] = ref_optional_function(state, 2, "is_selected"); + callback.refs[2] = ref_optional_function(state, 2, "is_disabled"); + + std::vector labels; + std::vector items; + lua_getfield(state, 2, "items"); + if (!lua_isnil(state, -1)) + items = list_items(state, -1, labels); + lua_pop(state, 1); + + UiListDesc desc = UI_LIST_DESC_INIT; + desc.items = items.data(); + desc.item_count = items.size(); + desc.on_pressed = list_pressed; + desc.is_selected = callback.refs[1] != LUA_NOREF ? list_selected : nullptr; + desc.is_disabled = callback.refs[2] != LUA_NOREF ? list_disabled : nullptr; + desc.user_data = &callback; + UiListHandle list = 0; + check_result(state, svc_ui->pane_add_list(pane.vm->subject, pane.value, &desc, &list), + "ui pane_add_list"); + push_ui_handle(state, *pane.vm, list, HandleKind::UiList); + return 1; +} + +int element_set_text(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_text(element.vm->subject, element.value, luaL_checkstring(state, 2)), + "ui elem_set_text"); + return 0; +} + +int element_set_rml(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_rml(element.vm->subject, element.value, luaL_checkstring(state, 2)), + "ui elem_set_rml"); + return 0; +} + +int element_set_progress(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_progress( + element.vm->subject, element.value, static_cast(luaL_checknumber(state, 2))), + "ui elem_set_progress"); + return 0; +} + +int element_set_class(lua_State* state) { + auto& element = check_ui_handle(state, 1, HandleKind::UiElement); + check_result(state, + svc_ui->elem_set_class(element.vm->subject, element.value, luaL_checkstring(state, 2), + luaL_checkboolean(state, 3) != 0), + "ui elem_set_class"); + return 0; +} + +int list_set_items(lua_State* state) { + auto& list = check_ui_handle(state, 1, HandleKind::UiList); + std::vector labels; + auto items = list_items(state, 2, labels); + check_result(state, + svc_ui->list_set_items(list.vm->subject, list.value, items.data(), items.size()), + "ui list_set_items"); + return 0; +} + +int window_close(lua_State* state) { + auto& window = check_ui_handle(state, 1, HandleKind::UiWindow); + check_result(state, svc_ui->window_close(window.vm->subject, window.value), "ui window_close"); + window.value = 0; + return 0; +} + +int dialog_close(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, svc_ui->dialog_close(dialog.vm->subject, dialog.value), "ui dialog_close"); + dialog.value = 0; + return 0; +} + +int dialog_set_body(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, + svc_ui->dialog_set_body(dialog.vm->subject, dialog.value, luaL_checkstring(state, 2)), + "ui dialog_set_body"); + return 0; +} + +int dialog_set_icon(lua_State* state) { + auto& dialog = check_ui_handle(state, 1, HandleKind::UiDialog); + check_result(state, + svc_ui->dialog_set_icon(dialog.vm->subject, dialog.value, luaL_checkstring(state, 2)), + "ui dialog_set_icon"); + return 0; +} + +int style_unregister(lua_State* state) { + auto& style = check_ui_handle(state, 1, HandleKind::UiStyle); + check_result( + state, svc_ui->unregister_styles(style.vm->subject, style.value), "ui unregister_styles"); + style.value = 0; + return 0; +} + +int menu_tab_unregister(lua_State* state) { + auto& tab = check_ui_handle(state, 1, HandleKind::UiMenuTab); + check_result( + state, svc_ui->unregister_menu_tab(tab.vm->subject, tab.value), "ui unregister_menu_tab"); + tab.value = 0; + return 0; +} + +int register_mods_panel(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, 1, "build"); + callback.refs[1] = ref_optional_function(state, 1, "update"); + UiModsPanelDesc desc = UI_MODS_PANEL_DESC_INIT; + desc.build = panel_build; + desc.update = callback.refs[1] != LUA_NOREF ? panel_update : nullptr; + desc.user_data = &callback; + check_result(state, svc_ui->register_mods_panel(vm.subject, &desc), "ui register_mods_panel"); + return 0; +} + +int window_push(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + std::vector tabs; + std::vector titles; + lua_getfield(state, 1, "tabs"); + luaL_checktype(state, -1, LUA_TTABLE); + const int tabCount = lua_objlen(state, -1); + tabs.reserve(tabCount); + titles.reserve(tabCount); + for (int i = 1; i <= tabCount; ++i) { + lua_rawgeti(state, -1, i); + titles.push_back(get_optional_string(state, -1, "title")); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, -1, "build"); + callback.refs[1] = ref_optional_function(state, -1, "update"); + UiTabDesc tab = UI_TAB_DESC_INIT; + tab.build = tab_build; + tab.update = callback.refs[1] != LUA_NOREF ? panel_update : nullptr; + tab.user_data = &callback; + tabs.push_back(tab); + lua_pop(state, 1); + } + lua_pop(state, 1); + for (size_t i = 0; i < tabs.size(); ++i) + tabs[i].title = titles[i].c_str(); + + const std::string rcss = get_optional_string(state, 1, "rcss"); + Callback& closed = retain_callback(vm); + closed.refs[0] = ref_optional_function(state, 1, "on_closed"); + UiWindowDesc desc = UI_WINDOW_DESC_INIT; + desc.tabs = tabs.data(); + desc.tab_count = tabs.size(); + desc.rcss = rcss.empty() ? nullptr : rcss.c_str(); + desc.on_closed = closed.refs[0] != LUA_NOREF ? window_closed : nullptr; + desc.user_data = &closed; + UiWindowHandle window = 0; + check_result(state, svc_ui->window_push(vm.subject, &desc, &window), "ui window_push"); + push_ui_handle(state, vm, window, HandleKind::UiWindow); + return 1; +} + +UiDialogVariant dialog_variant(lua_State* state, const std::string& variant) { + if (variant.empty() || variant == "normal") + return UI_DIALOG_NORMAL; + if (variant == "warning") + return UI_DIALOG_WARNING; + if (variant == "danger") + return UI_DIALOG_DANGER; + luaL_error(state, "unknown dialog variant '%s'", variant.c_str()); +} + +int dialog_push(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string title = get_optional_string(state, 1, "title"); + const std::string body = get_optional_string(state, 1, "body_rml"); + const std::string icon = get_optional_string(state, 1, "icon"); + const std::string variant = get_optional_string(state, 1, "variant"); + + std::vector actions; + std::vector labels; + lua_getfield(state, 1, "actions"); + luaL_checktype(state, -1, LUA_TTABLE); + const int actionCount = lua_objlen(state, -1); + actions.reserve(actionCount); + labels.reserve(actionCount); + for (int i = 1; i <= actionCount; ++i) { + lua_rawgeti(state, -1, i); + labels.push_back(get_optional_string(state, -1, "label")); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_optional_function(state, -1, "on_pressed"); + callback.refs[1] = ref_optional_function(state, -1, "is_disabled"); + UiDialogAction action = UI_DIALOG_ACTION_INIT; + action.on_pressed = callback.refs[0] != LUA_NOREF ? dialog_action : nullptr; + action.is_disabled = callback.refs[1] != LUA_NOREF ? dialog_action_disabled : nullptr; + action.user_data = &callback; + action.keep_open = get_optional_bool(state, -1, "keep_open", false); + actions.push_back(action); + lua_pop(state, 1); + } + lua_pop(state, 1); + for (size_t i = 0; i < actions.size(); ++i) + actions[i].label = labels[i].c_str(); + + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_optional_function(state, 1, "on_dismiss"); + callback.refs[1] = ref_optional_function(state, 1, "build"); + UiDialogDesc desc = UI_DIALOG_DESC_INIT; + desc.title = title.c_str(); + desc.body_rml = body.c_str(); + desc.icon = icon.empty() ? nullptr : icon.c_str(); + desc.variant = dialog_variant(state, variant); + desc.actions = actions.data(); + desc.action_count = actions.size(); + desc.on_dismiss = callback.refs[0] != LUA_NOREF ? dialog_dismissed : nullptr; + desc.build = callback.refs[1] != LUA_NOREF ? dialog_build : nullptr; + desc.user_data = &callback; + UiDialogHandle dialog = 0; + check_result(state, svc_ui->dialog_push(vm.subject, &desc, &dialog), "ui dialog_push"); + push_ui_handle(state, vm, dialog, HandleKind::UiDialog); + return 1; +} + +int is_any_document_visible(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + bool visible = false; + check_result( + state, svc_ui->is_any_document_visible(vm.subject, &visible), "ui is_any_document_visible"); + lua_pushboolean(state, visible); + return 1; +} + +int register_styles(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const auto scope = style_scope(state, luaL_checkstring(state, 1)); + UiStyleHandle style = 0; + check_result(state, + svc_ui->register_styles(vm.subject, scope, luaL_checkstring(state, 2), &style), + "ui register_styles"); + push_ui_handle(state, vm, style, HandleKind::UiStyle); + return 1; +} + +int register_styles_file(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + const auto scope = style_scope(state, luaL_checkstring(state, 1)); + UiStyleHandle style = 0; + check_result(state, + svc_ui->register_styles_file(vm.subject, scope, luaL_checkstring(state, 2), &style), + "ui register_styles_file"); + push_ui_handle(state, vm, style, HandleKind::UiStyle); + return 1; +} + +int register_menu_tab(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string label = get_optional_string(state, 1, "label"); + Callback& callback = retain_callback(vm); + callback.refs[0] = ref_required_function(state, 1, "on_selected"); + UiMenuTabDesc desc = UI_MENU_TAB_DESC_INIT; + desc.label = label.c_str(); + desc.on_selected = menu_selected; + desc.user_data = &callback; + UiMenuTabHandle tab = 0; + check_result(state, svc_ui->register_menu_tab(vm.subject, &desc, &tab), "ui register_menu_tab"); + push_ui_handle(state, vm, tab, HandleKind::UiMenuTab); + return 1; +} + +int push_toast(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + luaL_checktype(state, 1, LUA_TTABLE); + const std::string type = get_optional_string(state, 1, "type"); + const std::string title = get_optional_string(state, 1, "title_rml"); + const std::string body = get_optional_string(state, 1, "body_rml"); + UiToastDesc desc = UI_TOAST_DESC_INIT; + desc.type = type.empty() ? nullptr : type.c_str(); + desc.title_rml = title.empty() ? nullptr : title.c_str(); + desc.body_rml = body.empty() ? nullptr : body.c_str(); + desc.duration_ms = static_cast(get_optional_int(state, 1, "duration_ms", 0)); + check_result(state, svc_ui->push_toast(vm.subject, &desc), "ui push_toast"); + return 0; +} + +int get_clipboard_text(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + size_t size = 0; + check_result( + state, svc_ui->get_clipboard_text(vm.subject, nullptr, 0, &size), "ui get_clipboard_text"); + std::vector text(size + 1); + check_result(state, svc_ui->get_clipboard_text(vm.subject, text.data(), text.size(), nullptr), + "ui get_clipboard_text"); + lua_pushlstring(state, text.data(), size); + return 1; +} + +int set_clipboard_text(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + check_result(state, svc_ui->set_clipboard_text(vm.subject, luaL_checkstring(state, 1)), + "ui set_clipboard_text"); + return 0; +} + +} // namespace + +void push_ui_handle(lua_State* state, Vm& vm, uint64_t value, HandleKind kind) { + push_handle(state, vm, value, kind, ui_metatable(kind)); +} + +int open_ui(lua_State* state) { + Vm& vm = vm_from_upvalue(state); + if (svc_ui == nullptr) { + service_unavailable(state, "UiService"); + } + static const luaL_Reg kElementMethods[] = { + {"add_section", pane_add_section}, + {"add_text", pane_add_text}, + {"add_rml", pane_add_rml}, + {"add_progress", pane_add_progress}, + {"add_control", pane_add_control}, + {"add_group", pane_add_group}, + {"add_list", pane_add_list}, + {"set_text", element_set_text}, + {"set_rml", element_set_rml}, + {"set_progress", element_set_progress}, + {"set_class", element_set_class}, + {nullptr, nullptr}, + }; + static const luaL_Reg kWindowMethods[] = {{"close", window_close}, {nullptr, nullptr}}; + static const luaL_Reg kDialogMethods[] = { + {"close", dialog_close}, + {"set_body", dialog_set_body}, + {"set_icon", dialog_set_icon}, + {nullptr, nullptr}, + }; + static const luaL_Reg kStyleMethods[] = {{"unregister", style_unregister}, {nullptr, nullptr}}; + static const luaL_Reg kMenuMethods[] = { + {"unregister", menu_tab_unregister}, {nullptr, nullptr}}; + static const luaL_Reg kListMethods[] = {{"set_items", list_set_items}, {nullptr, nullptr}}; + create_handle_metatable(state, kUiElementMetatable, kElementMethods, "UiElement"); + create_handle_metatable(state, kUiWindowMetatable, kWindowMethods, "UiWindow"); + create_handle_metatable(state, kUiDialogMetatable, kDialogMethods, "UiDialog"); + create_handle_metatable(state, kUiStyleMetatable, kStyleMethods, "UiStyle"); + create_handle_metatable(state, kUiMenuTabMetatable, kMenuMethods, "UiMenuTab"); + create_handle_metatable(state, kUiListMetatable, kListMethods, "UiList"); + + lua_newtable(state); + set_function(state, vm, "register_mods_panel", register_mods_panel); + set_function(state, vm, "window_push", window_push); + set_function(state, vm, "dialog_push", dialog_push); + set_function(state, vm, "is_any_document_visible", is_any_document_visible); + set_function(state, vm, "register_styles", register_styles); + set_function(state, vm, "register_styles_file", register_styles_file); + set_function(state, vm, "register_menu_tab", register_menu_tab); + set_function(state, vm, "push_toast", push_toast); + set_function(state, vm, "get_clipboard_text", get_clipboard_text); + set_function(state, vm, "set_clipboard_text", set_clipboard_text); + lua_setreadonly(state, -1, true); + return 1; +} + +} // namespace luau_runtime diff --git a/mods/randomizer b/mods/randomizer new file mode 160000 index 0000000000..641c9c9e0b --- /dev/null +++ b/mods/randomizer @@ -0,0 +1 @@ +Subproject commit 641c9c9e0bd04d51f9cb32e08daf7d134c65dcb1 diff --git a/platforms/android/app/src/main/AndroidManifest.xml b/platforms/android/app/src/main/AndroidManifest.xml index b7270ee433..8dc7bf3236 100644 --- a/platforms/android/app/src/main/AndroidManifest.xml +++ b/platforms/android/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ android:appCategory="game" android:icon="@mipmap/icon" android:label="@string/app_name" + android:networkSecurityConfig="@xml/network_security_config" android:theme="@android:style/Theme.NoTitleBar" android:enableOnBackInvokedCallback="false"> diff --git a/platforms/android/app/src/main/res/xml/network_security_config.xml b/platforms/android/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000000..aa9543fd1f --- /dev/null +++ b/platforms/android/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,9 @@ + + + + + localhost + 127.0.0.1 + ::1 + + diff --git a/platforms/ios/Info.plist.in b/platforms/ios/Info.plist.in index 395b29b7d7..9a9025b9f7 100644 --- a/platforms/ios/Info.plist.in +++ b/platforms/ios/Info.plist.in @@ -85,5 +85,12 @@ LSSupportsGameMode + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + NSLocalNetworkUsageDescription + Dusklight allows network-enabled mods to connect to devices on your local network. diff --git a/platforms/macos/Info.plist.in b/platforms/macos/Info.plist.in index 7f29358033..3f564d88f7 100644 --- a/platforms/macos/Info.plist.in +++ b/platforms/macos/Info.plist.in @@ -32,5 +32,12 @@ public.app-category.adventure-games LSSupportsGameMode + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + NSLocalNetworkUsageDescription + Dusklight allows network-enabled mods to connect to devices on your local network. diff --git a/platforms/tvos/Info.plist.in b/platforms/tvos/Info.plist.in index 49ed85edd7..7f32e2d207 100644 --- a/platforms/tvos/Info.plist.in +++ b/platforms/tvos/Info.plist.in @@ -47,5 +47,12 @@ Automatic LSSupportsGameMode + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + NSLocalNetworkUsageDescription + Dusklight allows network-enabled mods to connect to devices on your local network. diff --git a/sdk/include/mods/items.h b/sdk/include/mods/items.h index b79563026c..ceee2a0efc 100644 --- a/sdk/include/mods/items.h +++ b/sdk/include/mods/items.h @@ -10,7 +10,7 @@ #define ITEM_CHECK_FREESTANDING_PREFIX "freestanding:" /* : */ #define ITEM_CHECK_GOLDEN_WOLF_PREFIX "golden_wolf:" /* */ #define ITEM_CHECK_POE_PREFIX "poe:" /* : */ -#define ITEM_CHECK_SHOP_PREFIX "shop:" /* : */ +#define ITEM_CHECK_SHOP_PREFIX "shop:" /* :: */ #define ITEM_CHECK_SKY_PREFIX "sky:" /* : */ #define ITEM_CHECK_DUNGEON_REWARD_PREFIX "dungeon_reward:" /* */ @@ -21,6 +21,8 @@ #define ITEM_CHECK_BULBLIN_KEY "bulblin_key:D_MN09" #define ITEM_CHECK_CORAL_EARRING "coral_earring" #define ITEM_CHECK_CORO_BOTTLE "coro_bottle" +#define ITEM_CHECK_CORO_GATE_KEY "coro_gate_key" +#define ITEM_CHECK_CORO_LANTERN "coro_lantern" #define ITEM_CHECK_DUNGEON_MAP_SNOWPEAK "dungeon_map:D_MN11" #define ITEM_CHECK_FAIRY_REWARD "fairy_reward:D_SB01" #define ITEM_CHECK_FISHING_BOTTLE "fishing_bottle" diff --git a/sdk/include/mods/meta.hpp b/sdk/include/mods/meta.hpp index ef85d827c2..6028a3df9c 100644 --- a/sdk/include/mods/meta.hpp +++ b/sdk/include/mods/meta.hpp @@ -13,21 +13,31 @@ * modmeta records. Each IMPORT_SERVICE/EXPORT_SERVICE/DEFINE_HOOK use places one * constant-initialized record object in the metadata section. */ +#if defined(_MSVC_LANG) && !defined(__clang__) +#define MOD_META_NO_ASAN +#else +#if defined(__has_attribute) && __has_attribute(no_sanitize) +#define MOD_META_NO_ASAN __attribute__((no_sanitize("address"))) +#else +#define MOD_META_NO_ASAN +#endif +#endif + #if defined(_WIN32) #pragma section("modmeta$a", read, write) #pragma section("modmeta$d", read, write) #pragma section("modmeta$z", read, write) #if defined(__clang__) -#define MOD_META_RECORD __declspec(allocate("modmeta$d")) __attribute__((used)) +#define MOD_META_RECORD __declspec(allocate("modmeta$d")) __attribute__((used)) MOD_META_NO_ASAN #else #define MOD_META_RECORD __declspec(allocate("modmeta$d")) #endif #elif defined(__APPLE__) -#define MOD_META_RECORD __attribute__((section("__DATA,__modmeta"), used)) +#define MOD_META_RECORD __attribute__((section("__DATA,__modmeta"), used)) MOD_META_NO_ASAN #elif defined(__has_attribute) && __has_attribute(retain) -#define MOD_META_RECORD __attribute__((section("modmeta"), used, retain)) +#define MOD_META_RECORD __attribute__((section("modmeta"), used, retain)) MOD_META_NO_ASAN #else -#define MOD_META_RECORD __attribute__((section("modmeta"), used)) +#define MOD_META_RECORD __attribute__((section("modmeta"), used)) MOD_META_NO_ASAN #endif /* Section bounds for the mod_meta descriptor */ diff --git a/sdk/include/mods/runtime.h b/sdk/include/mods/runtime.h new file mode 100644 index 0000000000..25719e2eb9 --- /dev/null +++ b/sdk/include/mods/runtime.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +/* + * Lifecycle service for mods delegated to a runtime named by mod.json. The host passes the + * runtime's context as ctx and the delegated mod's context as subject. + */ +typedef struct ModRuntimeService { + ServiceHeader header; + + ModResult (*activate)(ModContext* ctx, ModContext* subject, ModError* out_error); + ModResult (*update)(ModContext* ctx, ModContext* subject, ModError* out_error); + ModResult (*deactivate)(ModContext* ctx, ModContext* subject, ModError* out_error); +} ModRuntimeService; diff --git a/sdk/include/mods/svc/actor.h b/sdk/include/mods/svc/actor.h new file mode 100644 index 0000000000..5876ddcaf2 --- /dev/null +++ b/sdk/include/mods/svc/actor.h @@ -0,0 +1,102 @@ +#pragma once + +#include +#include + +#define ACTOR_SERVICE_ID "dev.twilitrealm.dusklight.actor" +#define ACTOR_SERVICE_MAJOR 1u +#define ACTOR_SERVICE_MINOR 0u + +typedef int16_t ProfileName; +typedef uint32_t ActorId; +typedef uint64_t ActorHandle; + +typedef struct { + const char name[8]; // Canonical stage name. Must be unique among active mod actors. Matching a + // game actor name intentionally overrides stage lookup for that actor. + + uint16_t priority_group; /* priorityGroup is the priority for when execute will be called on the + actor. Here are the main groups: + 0: The room manager actor + 1: Game scenes + 2: Various room change actors + 3: Most objects to be executed before Link + 4: Some bosses, canoe, epona, spinner, chests + 5: Link's actor + 6: Boomerang, midna + 7: Most objects, actors, bosses, triggers to be executed after link (most actors go here) + 8: Various objects and enemies + 9: Various actors + 10: Timer, Scene Exit actor + 11: Grass, Suspend Actors + */ + + size_t process_size; // Size of the actor class (use sizeof(my_actor_class)) + int16_t draw_priority; // an enum value that is prefixed with fpcDwPi. Select an existing value + // from the fpcDwPi to pick a draw priority matching the actor you wish + // to match priorities with. + uint32_t status; // Flags from fopAc_Status_e enum (all have fopAcStts_UNK_0x40000_e, a lot + // have fopAcStts_UNK_0x4000_e, add fopAcStts_CULL_e to enable culling) + uint8_t group; // The actor type. An enum value from fopAc_Group_e (fopAc_ACTOR_e, + // fopAc_ENEMY_e, fopAc_NPC_e) + uint8_t cull_type; // Enum value from fopAc_Cull_e + int (*create_function)( + void*); // Called after the actor is spawned, return type is a enum value of cPhs_Step + int (*delete_function)(void*); // Releases resources; returns 1 when deletion is complete + int (*execute_function)(void*); // Called once per game tick, the actor's priorityGroup + // determines when it will run relative to other actors + int (*is_delete_function)(void*); // Returns 1 when normal deletion may begin + int (*draw_function)(void*); // Called to draw the actor +} ActorProfileDesc; + +typedef struct { + uint32_t parameters; // The parameters to be passed to the actor + int8_t argument; // The argument to be passed to the actor (acts as an extra byte for a parameter) + int8_t room_num; // The room to spawn the actor in + struct { + float x; + float y; + float z; + } position; + struct { + int16_t x; + int16_t y; + int16_t z; + } angle; + struct { + float x; + float y; + float z; + } scale; + int (*create_function)(void*); // Optional: A custom function to run when the actor is created. +} ActorSpawnParams; + +typedef struct ActorService { + ServiceHeader header; + ModResult (*register_actor)(ModContext* ctx, const ActorProfileDesc* desc, + ProfileName* outProfileName, ActorHandle* outActorHandle); + ModResult (*unregister_actor)(ModContext* ctx, ActorHandle handle); + ModResult (*create_actor_from_name)( + ModContext* ctx, const char* name, const ActorSpawnParams* params, ActorId* outId); + ModResult (*create_actor)( + ModContext* ctx, ProfileName name, const ActorSpawnParams* params, ActorId* outId); + ModResult (*create_child_actor_from_name)(ModContext* ctx, const char* name, ActorId parentID, + const ActorSpawnParams* params, ActorId* outId); + ModResult (*create_child_actor)(ModContext* ctx, ProfileName name, ActorId parentID, + const ActorSpawnParams* params, ActorId* outId); + ModResult (*get_actor_id)(ModContext* ctx, ProfileName name, ActorId* outId); + ModResult (*get_actor_room_num)(ModContext* ctx, ActorId actorId, int8_t* outRoomNum); + /* Returns MOD_UNAVAILABLE if the actor cannot be queued for deletion immediately. */ + ModResult (*delete_actor)(ModContext* ctx, ActorId actorId); +} ActorService; + +#ifdef __cplusplus +#include "mods/service.hpp" + +template <> +struct mods::ServiceTraits { + static constexpr const char* id = ACTOR_SERVICE_ID; + static constexpr uint16_t major_version = ACTOR_SERVICE_MAJOR; + static constexpr uint16_t minor_version = ACTOR_SERVICE_MINOR; +}; +#endif diff --git a/sdk/include/mods/svc/item.h b/sdk/include/mods/svc/item.h index 94fec6fb6c..ff4f31b547 100644 --- a/sdk/include/mods/svc/item.h +++ b/sdk/include/mods/svc/item.h @@ -8,7 +8,7 @@ #define ITEM_SERVICE_ID "dev.twilitrealm.dusklight.item" #define ITEM_SERVICE_MAJOR 2u -#define ITEM_SERVICE_MINOR 1u +#define ITEM_SERVICE_MINOR 3u /* 0 is never a valid handle. */ typedef uint64_t ItemCheckHandle; @@ -32,11 +32,13 @@ typedef struct ItemCheckInfo { uint8_t vanilla_item; uint8_t current_item; uint8_t current_display_item; + bool was_resolved; } ItemCheckInfo; typedef struct ItemCheckResolution { uint8_t item; uint8_t display_item; /* leave unset (0xFF/NONE) to use the item */ + bool was_resolved; } ItemCheckResolution; /* Return true and write out_result to replace the result, or false to leave it unchanged. */ @@ -97,6 +99,13 @@ typedef struct ItemService { ModContext* ctx, ItemGiveObserveFn fn, void* user_data, ItemGiveHandle* out_handle); ModResult (*unobserve_gives)(ModContext* ctx, ItemGiveHandle handle); + + /* Minor version 2 */ + + /* Resolve a live preview (item + display item) without granting an item or notifying give + * observers. */ + ModResult (*resolve_check_full)(ModContext* ctx, const char* name, uint8_t vanilla_item, + ItemCheckResolution* out_resolution); } ItemService; MOD_DECLARE_SERVICE(ItemService, svc_item, ITEM_SERVICE_ID, ITEM_SERVICE_MAJOR, ITEM_SERVICE_MINOR); diff --git a/sdk/include/mods/svc/net.h b/sdk/include/mods/svc/net.h new file mode 100644 index 0000000000..2c5e9a531a --- /dev/null +++ b/sdk/include/mods/svc/net.h @@ -0,0 +1,145 @@ +#pragma once + +#include + +#ifdef __cplusplus +#include +#endif + +#define NET_SERVICE_ID "dev.twilitrealm.dusklight.net" +#define NET_SERVICE_MAJOR 1u +#define NET_SERVICE_MINOR 0u + +/** 0 is never a valid handle. */ +typedef uint64_t NetHandle; + +typedef enum NetError { + NET_ERROR_NONE = 0, + NET_ERROR_INVALID_ENDPOINT = 1, + NET_ERROR_RESOLVE = 2, + NET_ERROR_TIMEOUT = 3, + NET_ERROR_REFUSED = 4, + NET_ERROR_UNREACHABLE = 5, + NET_ERROR_RESET = 6, + NET_ERROR_ADDRESS_IN_USE = 7, + NET_ERROR_PERMISSION = 8, + NET_ERROR_TOO_LARGE = 9, + NET_ERROR_CANCELED = 10, + NET_ERROR_NETWORK = 11, +} NetError; + +#define NET_ENDPOINT_MAX 80 +/** NUL-terminated tcp://host:port or udp://host:port endpoint. */ +typedef struct NetEndpoint { + char text[NET_ENDPOINT_MAX]; +} NetEndpoint; + +typedef struct NetConnectDesc { + uint32_t struct_size; + /** TCP endpoint. Hostnames and IP literals are accepted. */ + const char* endpoint; + /** 0 defaults to 10 seconds. Resolution is included. */ + uint32_t connect_timeout_ms; + /** 0 defaults to 5 seconds for flush and peer EOF. */ + uint32_t close_timeout_ms; + /** 0 defaults to 1 MiB. Maximum of 8 MiB. */ + size_t max_send_queue_bytes; + bool no_delay; + /** Sampled when each event is polled. */ + void* user_data; +} NetConnectDesc; + +#define NET_CONNECT_DESC_INIT {sizeof(NetConnectDesc), NULL, 0u, 0u, 0u, true, NULL} + +typedef struct NetListenDesc { + uint32_t struct_size; + /** TCP endpoint with an IP literal. Port 0 requests an ephemeral port. */ + const char* bind; + uint32_t close_timeout_ms; + size_t max_send_queue_bytes; + bool no_delay; + void* user_data; +} NetListenDesc; + +#define NET_LISTEN_DESC_INIT {sizeof(NetListenDesc), NULL, 0u, 0u, true, NULL} + +typedef struct NetDatagramDesc { + uint32_t struct_size; + /** UDP endpoint with an IP literal. Port 0 requests an ephemeral port. */ + const char* bind; + size_t max_send_queue_bytes; + void* user_data; +} NetDatagramDesc; + +#define NET_DATAGRAM_DESC_INIT {sizeof(NetDatagramDesc), NULL, 0u, NULL} + +typedef enum NetEventType { + NET_EVENT_NONE = 0, + NET_EVENT_CONNECTED = 1, + NET_EVENT_ACCEPTED = 2, + NET_EVENT_STREAM_DATA = 3, + NET_EVENT_DATAGRAM = 4, + NET_EVENT_DROPPED = 5, + NET_EVENT_RESOLVED = 6, + NET_EVENT_CLOSED = 7, +} NetEventType; + +typedef struct NetEvent { + uint32_t struct_size; + NetEventType type; + /** Source handle. A CLOSED or RESOLVED handle is invalid after poll_event returns it. */ + NetHandle handle; + void* user_data; + NetHandle accepted; + /** Peer, datagram source, or resolved endpoint as applicable. */ + NetEndpoint endpoint; + /** Valid until this mod's next poll_event call or deactivation. */ + const void* data; + size_t size; + uint32_t dropped; + NetError error; + /** Never NULL. Valid until this mod's next poll_event call or deactivation. */ + const char* error_message; +} NetEvent; + +#define NET_EVENT_INIT \ + {sizeof(NetEvent), NET_EVENT_NONE, 0u, NULL, 0u, {{0}}, NULL, 0u, 0u, NET_ERROR_NONE, ""} + +typedef struct NetStats { + uint32_t struct_size; + size_t queued_send_bytes; + uint64_t inbound_dropped; + uint64_t send_failures; + uint64_t bytes_sent; + uint64_t bytes_received; +} NetStats; + +#define NET_STATS_INIT {sizeof(NetStats), 0u, 0u, 0u, 0u, 0u} + +typedef struct NetService { + ServiceHeader header; + + /** Starts an asynchronous TCP connection. */ + ModResult (*connect)(ModContext* ctx, const NetConnectDesc* desc, NetHandle* out_handle); + /** Opens a TCP listener and returns its local endpoint. */ + ModResult (*listen)(ModContext* ctx, const NetListenDesc* desc, NetHandle* out_handle, + NetEndpoint* out_local, NetError* out_error); + /** Opens a UDP socket and returns its local endpoint. */ + ModResult (*open_datagram)(ModContext* ctx, const NetDatagramDesc* desc, NetHandle* out_handle, + NetEndpoint* out_local, NetError* out_error); + /** Resolves a TCP or UDP endpoint asynchronously. */ + ModResult (*resolve)( + ModContext* ctx, const char* endpoint, void* user_data, NetHandle* out_handle); + /** Returns MOD_OK and NET_EVENT_NONE when the queue is empty. */ + ModResult (*poll_event)(ModContext* ctx, NetEvent* out_event); + /** Copies bytes to a connected stream's outbound queue. */ + ModResult (*send)(ModContext* ctx, NetHandle stream, const void* data, size_t size); + /** Copies one datagram for a literal UDP destination. The maximum size is 65,507 bytes. */ + ModResult (*send_to)( + ModContext* ctx, NetHandle socket, const char* endpoint, const void* data, size_t size); + ModResult (*set_user_data)(ModContext* ctx, NetHandle handle, void* user_data); + ModResult (*stats)(ModContext* ctx, NetHandle handle, NetStats* out_stats); + ModResult (*close)(ModContext* ctx, NetHandle handle); +} NetService; + +MOD_DECLARE_SERVICE(NetService, svc_net, NET_SERVICE_ID, NET_SERVICE_MAJOR, NET_SERVICE_MINOR); diff --git a/sdk/include/mods/svc/net.hpp b/sdk/include/mods/svc/net.hpp new file mode 100644 index 0000000000..44edf4001b --- /dev/null +++ b/sdk/include/mods/svc/net.hpp @@ -0,0 +1,189 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace mods::net { + +class Socket { +public: + Socket() = default; + Socket(NetHandle handle, ModResult result) : mHandle{handle}, mResult{result} {} + ~Socket() { reset(); } + + Socket(const Socket&) = delete; + Socket& operator=(const Socket&) = delete; + Socket(Socket&& other) noexcept { *this = std::move(other); } + Socket& operator=(Socket&& other) noexcept { + if (this != &other) { + reset(); + mHandle = std::exchange(other.mHandle, 0); + mResult = other.mResult; + } + return *this; + } + + explicit operator bool() const { return mResult == MOD_OK && mHandle != 0; } + + ModResult result() const { return mResult; } + NetHandle handle() const { return mHandle; } + + ModResult send(std::span bytes) const { + return svc_net != nullptr && mHandle != 0 ? + svc_net->send(mod_ctx, mHandle, bytes.data(), bytes.size()) : + MOD_UNAVAILABLE; + } + + ModResult send_to(std::string_view endpoint, std::span bytes) const { + if (svc_net == nullptr || mHandle == 0) { + return MOD_UNAVAILABLE; + } + const std::string endpointText{endpoint}; + return svc_net->send_to(mod_ctx, mHandle, endpointText.c_str(), bytes.data(), bytes.size()); + } + + std::optional stats() const { + if (svc_net == nullptr || mHandle == 0) { + return std::nullopt; + } + NetStats value = NET_STATS_INIT; + if (svc_net->stats(mod_ctx, mHandle, &value) != MOD_OK) { + return std::nullopt; + } + return value; + } + + ModResult set_user_data(void* userData) const { + return svc_net != nullptr && mHandle != 0 ? + svc_net->set_user_data(mod_ctx, mHandle, userData) : + MOD_UNAVAILABLE; + } + + ModResult close() { + if (mHandle == 0) { + return mResult == MOD_OK ? MOD_OK : MOD_UNAVAILABLE; + } + mResult = svc_net != nullptr ? svc_net->close(mod_ctx, mHandle) : MOD_UNAVAILABLE; + mHandle = 0; + return mResult; + } + + void detach() { mHandle = 0; } + +private: + void reset() { (void)close(); } + + NetHandle mHandle = 0; + ModResult mResult = MOD_UNAVAILABLE; +}; + +struct BindOutcome { + std::string local; + NetError error = NET_ERROR_NONE; +}; + +inline Socket connect(std::string_view endpoint, NetConnectDesc options = NET_CONNECT_DESC_INIT) { + if (svc_net == nullptr) { + return {0, MOD_UNAVAILABLE}; + } + const std::string endpointText{endpoint}; + options.struct_size = sizeof(options); + options.endpoint = endpointText.c_str(); + NetHandle handle = 0; + const ModResult result = svc_net->connect(mod_ctx, &options, &handle); + return {handle, result}; +} + +inline Socket listen(std::string_view bind, BindOutcome* out = nullptr, + NetListenDesc options = NET_LISTEN_DESC_INIT) { + if (svc_net == nullptr) { + return {0, MOD_UNAVAILABLE}; + } + const std::string bindText{bind}; + options.struct_size = sizeof(options); + options.bind = bindText.c_str(); + NetHandle handle = 0; + NetEndpoint local{}; + NetError error = NET_ERROR_NONE; + const ModResult result = svc_net->listen(mod_ctx, &options, &handle, &local, &error); + if (out != nullptr) { + *out = {.local = local.text, .error = error}; + } + return {handle, result}; +} + +inline Socket open_datagram(std::string_view bind, BindOutcome* out = nullptr, + NetDatagramDesc options = NET_DATAGRAM_DESC_INIT) { + if (svc_net == nullptr) { + return {0, MOD_UNAVAILABLE}; + } + const std::string bindText{bind}; + options.struct_size = sizeof(options); + options.bind = bindText.c_str(); + NetHandle handle = 0; + NetEndpoint local{}; + NetError error = NET_ERROR_NONE; + const ModResult result = svc_net->open_datagram(mod_ctx, &options, &handle, &local, &error); + if (out != nullptr) { + *out = {.local = local.text, .error = error}; + } + return {handle, result}; +} + +inline Socket resolve(std::string_view endpoint, void* userData = nullptr) { + if (svc_net == nullptr) { + return {0, MOD_UNAVAILABLE}; + } + const std::string endpointText{endpoint}; + NetHandle handle = 0; + const ModResult result = svc_net->resolve(mod_ctx, endpointText.c_str(), userData, &handle); + return {handle, result}; +} + +inline Socket adopt(NetHandle accepted) { + return {accepted, accepted != 0 ? MOD_OK : MOD_INVALID_ARGUMENT}; +} + +struct Event { + NetEventType type = NET_EVENT_NONE; + NetHandle handle = 0; + void* userData = nullptr; + NetHandle accepted = 0; + std::string_view endpoint; + std::span data; + uint32_t dropped = 0; + NetError error = NET_ERROR_NONE; + std::string_view message; +}; + +inline bool poll(Event& out) { + out = {}; + if (svc_net == nullptr) { + return false; + } + NetEvent raw = NET_EVENT_INIT; + if (svc_net->poll_event(mod_ctx, &raw) != MOD_OK || raw.type == NET_EVENT_NONE) { + return false; + } + out.type = raw.type; + out.handle = raw.handle; + out.userData = raw.user_data; + out.accepted = raw.accepted; + out.endpoint = raw.endpoint.text; + if (raw.data != nullptr && raw.size != 0) { + out.data = {static_cast(raw.data), raw.size}; + } + out.dropped = raw.dropped; + out.error = raw.error; + out.message = raw.error_message != nullptr ? raw.error_message : ""; + return true; +} + +} // namespace mods::net diff --git a/sdk/include/mods/svc/ui.h b/sdk/include/mods/svc/ui.h index 31bff18c58..d0badfda05 100644 --- a/sdk/include/mods/svc/ui.h +++ b/sdk/include/mods/svc/ui.h @@ -19,9 +19,9 @@ * All calls must be made on the game thread from mod callbacks (initialize, update, hooks, or UI * callbacks). Handles are opaque, generation-checked ids; a stale or unknown handle fails with * MOD_INVALID_ARGUMENT. Element handles die with the content that owns them: a panel or tab rebuild - * destroys the previous build's elements, so re-acquire handles inside the build callback rather - * than caching them. Strings are UTF-8 and, in both directions, only valid for the duration of the - * call. + * destroys the previous build's elements, so re-acquire handles in each build callback and use them + * only until the next rebuild. Strings are UTF-8 and, in both directions, only valid for the + * duration of the call. */ /* 0 is never a valid handle. */ diff --git a/sdk/include/mods/svc/websocket.h b/sdk/include/mods/svc/websocket.h new file mode 100644 index 0000000000..bfc12d8fca --- /dev/null +++ b/sdk/include/mods/svc/websocket.h @@ -0,0 +1,107 @@ +#pragma once + +#include +#include + +#ifdef __cplusplus +#include +#endif + +#define WEBSOCKET_SERVICE_ID "dev.twilitrealm.dusklight.websocket" +#define WEBSOCKET_SERVICE_MAJOR 1u +#define WEBSOCKET_SERVICE_MINOR 0u + +/** Generational connection handle. Zero is never valid. */ +typedef uint64_t WebSocketHandle; + +/** Connection outcome. Callers must tolerate values added by later service minors. */ +typedef enum WebSocketError { + WEBSOCKET_ERROR_NONE = 0, + WEBSOCKET_ERROR_INVALID_URL = 1, + WEBSOCKET_ERROR_UNSUPPORTED_SCHEME = 2, + WEBSOCKET_ERROR_TIMEOUT = 3, + WEBSOCKET_ERROR_TOO_LARGE = 4, + WEBSOCKET_ERROR_CANCELED = 5, + WEBSOCKET_ERROR_NETWORK = 6, + WEBSOCKET_ERROR_PROTOCOL = 7, + WEBSOCKET_ERROR_HANDSHAKE = 8, +} WebSocketError; + +typedef enum WebSocketMessageKind { + WEBSOCKET_MESSAGE_TEXT = 0, + WEBSOCKET_MESSAGE_BINARY = 1, +} WebSocketMessageKind; + +typedef struct WebSocketConnectDesc { + uint32_t struct_size; + /** wss:// URL, or ws:// for localhost, 127.0.0.1, or [::1]. */ + const char* url; + /** Request headers. WebSocket handshake headers and User-Agent are reserved. */ + const HttpHeader* headers; + uint32_t header_count; + const char* const* protocols; + uint32_t protocol_count; + uint32_t connect_timeout_ms; + uint32_t close_timeout_ms; + uint32_t keepalive_interval_ms; + /** 0 defaults to 1 MiB. Maximum of 16 MiB. */ + size_t max_message_bytes; + /** Passed in every event. */ + void* user_data; +} WebSocketConnectDesc; + +#define WEBSOCKET_CONNECT_DESC_INIT \ + {sizeof(WebSocketConnectDesc), NULL, NULL, 0u, NULL, 0u, 0u, 0u, 0u, 0u, NULL} + +typedef enum WebSocketEventType { + WEBSOCKET_EVENT_NONE = 0, + WEBSOCKET_EVENT_OPEN = 1, + WEBSOCKET_EVENT_MESSAGE = 2, + WEBSOCKET_EVENT_CLOSED = 3, +} WebSocketEventType; + +typedef struct WebSocketEvent { + uint32_t struct_size; + WebSocketEventType type; + WebSocketHandle ws; + void* user_data; + + const char* protocol; + /** Handshake response headers for OPEN or a handshake-rejected CLOSED event. */ + const HttpHeader* headers; + uint32_t header_count; + + WebSocketMessageKind message_kind; + /** Valid until this mod's next poll_event call or deactivation. */ + const void* data; + size_t size; + + WebSocketError error; + /** Never NULL. Valid until this mod's next poll_event call or deactivation. */ + const char* error_message; + int32_t handshake_status; + uint16_t close_code; + const char* close_reason; +} WebSocketEvent; + +#define WEBSOCKET_EVENT_INIT \ + {sizeof(WebSocketEvent), WEBSOCKET_EVENT_NONE, 0u, NULL, "", NULL, 0u, WEBSOCKET_MESSAGE_TEXT, \ + NULL, 0u, WEBSOCKET_ERROR_NONE, "", 0, 0u, ""} + +typedef struct WebSocketService { + ServiceHeader header; + + /** Starts a connection. */ + ModResult (*connect)( + ModContext* ctx, const WebSocketConnectDesc* desc, WebSocketHandle* out_handle); + /** Returns MOD_OK and WEBSOCKET_EVENT_NONE when the queue is empty. */ + ModResult (*poll_event)(ModContext* ctx, WebSocketEvent* out_event); + /** Copies a message into the outbound queue. */ + ModResult (*send)(ModContext* ctx, WebSocketHandle ws, WebSocketMessageKind kind, + const void* data, size_t size); + /** Code 0 defaults to 1000; accepted: 1000, 1001, and 3000-4999. */ + ModResult (*close)(ModContext* ctx, WebSocketHandle ws, uint16_t code, const char* reason); +} WebSocketService; + +MOD_DECLARE_SERVICE(WebSocketService, svc_websocket, WEBSOCKET_SERVICE_ID, WEBSOCKET_SERVICE_MAJOR, + WEBSOCKET_SERVICE_MINOR); diff --git a/sdk/include/mods/svc/websocket.hpp b/sdk/include/mods/svc/websocket.hpp new file mode 100644 index 0000000000..57d8b37005 --- /dev/null +++ b/sdk/include/mods/svc/websocket.hpp @@ -0,0 +1,172 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mods::ws { + +struct Options { + std::string url; + std::vector headers; + std::vector protocols; + uint32_t connectTimeoutMs = 0; + uint32_t closeTimeoutMs = 0; + uint32_t keepaliveIntervalMs = 0; + size_t maxMessageBytes = 0; + void* userData = nullptr; +}; + +class Connection { +public: + Connection() = default; + Connection(WebSocketHandle handle, ModResult result) : mHandle{handle}, mResult{result} {} + ~Connection() { reset(); } + + Connection(const Connection&) = delete; + Connection& operator=(const Connection&) = delete; + Connection(Connection&& other) noexcept { *this = std::move(other); } + Connection& operator=(Connection&& other) noexcept { + if (this != &other) { + reset(); + mHandle = std::exchange(other.mHandle, 0); + mResult = other.mResult; + } + return *this; + } + + explicit operator bool() const { return mResult == MOD_OK && mHandle != 0; } + + ModResult result() const { return mResult; } + WebSocketHandle handle() const { return mHandle; } + + ModResult send(WebSocketMessageKind kind, std::span bytes) const { + return svc_websocket != nullptr && mHandle != 0 ? + svc_websocket->send(mod_ctx, mHandle, kind, bytes.data(), bytes.size()) : + MOD_UNAVAILABLE; + } + + ModResult send_text(std::string_view text) const { + return svc_websocket != nullptr && mHandle != 0 ? + svc_websocket->send( + mod_ctx, mHandle, WEBSOCKET_MESSAGE_TEXT, text.data(), text.size()) : + MOD_UNAVAILABLE; + } + + ModResult send_binary(std::span bytes) const { + return send(WEBSOCKET_MESSAGE_BINARY, bytes); + } + + ModResult close(uint16_t code = 1000, std::string_view reason = {}) { + if (svc_websocket == nullptr || mHandle == 0) { + return MOD_UNAVAILABLE; + } + const std::string reasonText{reason}; + mResult = svc_websocket->close(mod_ctx, mHandle, code, reasonText.c_str()); + if (mResult == MOD_OK) { + mHandle = 0; + } + return mResult; + } + + void detach() { mHandle = 0; } + +private: + void reset() { + if (mHandle != 0) { + (void)close(1001, "Connection owner released"); + mHandle = 0; + } + } + + WebSocketHandle mHandle = 0; + ModResult mResult = MOD_UNAVAILABLE; +}; + +inline Connection connect(const Options& options) { + if (svc_websocket == nullptr || options.headers.size() > std::numeric_limits::max() || + options.protocols.size() > std::numeric_limits::max()) + { + return {0, svc_websocket == nullptr ? MOD_UNAVAILABLE : MOD_INVALID_ARGUMENT}; + } + + std::vector headers; + headers.reserve(options.headers.size()); + for (const auto& header : options.headers) { + headers.push_back({.name = header.name.c_str(), .value = header.value.c_str()}); + } + std::vector protocols; + protocols.reserve(options.protocols.size()); + for (const auto& protocol : options.protocols) { + protocols.push_back(protocol.c_str()); + } + + WebSocketConnectDesc desc = WEBSOCKET_CONNECT_DESC_INIT; + desc.url = options.url.c_str(); + desc.headers = headers.empty() ? nullptr : headers.data(); + desc.header_count = static_cast(headers.size()); + desc.protocols = protocols.empty() ? nullptr : protocols.data(); + desc.protocol_count = static_cast(protocols.size()); + desc.connect_timeout_ms = options.connectTimeoutMs; + desc.close_timeout_ms = options.closeTimeoutMs; + desc.keepalive_interval_ms = options.keepaliveIntervalMs; + desc.max_message_bytes = options.maxMessageBytes; + desc.user_data = options.userData; + + WebSocketHandle handle = 0; + const ModResult result = svc_websocket->connect(mod_ctx, &desc, &handle); + return {handle, result}; +} + +struct Event { + WebSocketEventType type = WEBSOCKET_EVENT_NONE; + WebSocketHandle handle = 0; + void* userData = nullptr; + std::string_view protocol; + std::span headers; + WebSocketMessageKind messageKind = WEBSOCKET_MESSAGE_TEXT; + std::span data; + WebSocketError error = WEBSOCKET_ERROR_NONE; + std::string_view message; + int handshakeStatus = 0; + uint16_t closeCode = 0; + std::string_view closeReason; +}; + +inline bool poll(Event& out) { + out = {}; + if (svc_websocket == nullptr) { + return false; + } + WebSocketEvent raw = WEBSOCKET_EVENT_INIT; + if (svc_websocket->poll_event(mod_ctx, &raw) != MOD_OK || raw.type == WEBSOCKET_EVENT_NONE) { + return false; + } + out.type = raw.type; + out.handle = raw.ws; + out.userData = raw.user_data; + out.protocol = raw.protocol != nullptr ? raw.protocol : ""; + if (raw.headers != nullptr && raw.header_count != 0) { + out.headers = {raw.headers, raw.header_count}; + } + out.messageKind = raw.message_kind; + if (raw.data != nullptr && raw.size != 0) { + out.data = {static_cast(raw.data), raw.size}; + } + out.error = raw.error; + out.message = raw.error_message != nullptr ? raw.error_message : ""; + out.handshakeStatus = raw.handshake_status; + out.closeCode = raw.close_code; + out.closeReason = raw.close_reason != nullptr ? raw.close_reason : ""; + return true; +} + +} // namespace mods::ws diff --git a/sdk/luau/dusklight.d.luau b/sdk/luau/dusklight.d.luau new file mode 100644 index 0000000000..619e2f4124 --- /dev/null +++ b/sdk/luau/dusklight.d.luau @@ -0,0 +1,160 @@ +--!strict + +export type IntegerInput = integer | number +export type ConfigValue = boolean | integer | number | string +export type ConfigVar = { + get: (self: ConfigVar) -> T, + set: (self: ConfigVar, value: T) -> (), + subscribe: (self: ConfigVar, callback: (value: T, previous: T) -> ()) -> ConfigSubscription, + unregister: (self: ConfigVar) -> (), +} +export type ConfigSubscription = { + unsubscribe: (self: ConfigSubscription) -> (), +} +export type ConfigDesc = { + name: string, + type: "bool" | "int" | "float" | "string", + default: ConfigValue?, +} +export type ConfigModule = { + register: (desc: ConfigDesc) -> ConfigVar, + subscribe: (variable: ConfigVar, callback: (value: T, previous: T) -> ()) -> ConfigSubscription, +} + +export type OverlayHandle = { remove: (self: OverlayHandle) -> () } +export type OverlayModule = { + add_file: (discPath: string, bundlePath: string) -> OverlayHandle, + add_buffer: (discPath: string, data: string) -> OverlayHandle, +} +export type TextureHandle = { unregister: (self: TextureHandle) -> () } +export type TextureKey = { + texture_hash: integer, + tlut_hash: integer?, + width: IntegerInput, + height: IntegerInput, + gx_format: IntegerInput, + has_tlut: boolean?, +} +export type TextureData = { + data: string, + width: IntegerInput?, + height: IntegerInput?, + mip_count: IntegerInput?, + gx_format: IntegerInput?, +} +export type TextureModule = { + hash_wildcard: integer, + tlut_wildcard: integer, + register_file: (bundlePath: string) -> TextureHandle, + register_data: (key: TextureKey, data: TextureData) -> TextureHandle, +} + +export type UiElement = { + add_section: (self: UiElement, title: string) -> (), + add_text: (self: UiElement, text: string) -> UiElement, + add_rml: (self: UiElement, rml: string) -> UiElement, + add_progress: (self: UiElement, value: number) -> UiElement, + add_control: (self: UiElement, desc: UiControlDesc) -> UiElement, + add_group: (self: UiElement, target: UiElement, desc: UiGroupDesc) -> UiElement, + add_list: (self: UiElement, desc: UiListDesc) -> UiList, + set_text: (self: UiElement, text: string) -> (), + set_rml: (self: UiElement, rml: string) -> (), + set_progress: (self: UiElement, value: number) -> (), + set_class: (self: UiElement, name: string, active: boolean) -> (), +} +export type UiControlDesc = { + kind: "button" | "toggle" | "number" | "string" | "select" | "color" | "group" | "file_picker", + label: string, + help_rml: string?, + config_var: ConfigVar?, + get: (() -> ConfigValue)?, + set: ((value: ConfigValue) -> ())?, + on_pressed: (() -> ())?, + is_disabled: (() -> boolean)?, + is_modified: (() -> boolean)?, + is_selected: (() -> boolean)?, + min: IntegerInput?, + max: IntegerInput?, + step: IntegerInput?, + prefix: string?, + suffix: string?, + options: {string}?, + max_length: IntegerInput?, + color_presets: {string}?, + color_alpha: boolean?, + string_set_mode: ("commit" | "change")?, + file_filters: {{name: string, pattern: string}}?, + directory_mode: boolean?, +} +export type UiGroupDesc = { label: string, build: (pane: UiElement) -> () } +export type UiListItem = { key: IntegerInput, label: string } +export type UiListDesc = { + items: {UiListItem}?, + on_pressed: (list: UiList, key: integer) -> (), + is_selected: ((list: UiList, key: integer) -> boolean)?, + is_disabled: ((list: UiList, key: integer) -> boolean)?, +} +export type UiList = { set_items: (self: UiList, items: {UiListItem}) -> () } +export type UiWindow = { close: (self: UiWindow) -> () } +export type UiDialog = { + close: (self: UiDialog) -> (), + set_body: (self: UiDialog, rml: string) -> (), + set_icon: (self: UiDialog, icon: string) -> (), +} +export type UiStyle = { unregister: (self: UiStyle) -> () } +export type UiMenuTab = { unregister: (self: UiMenuTab) -> () } +export type UiTabDesc = { + title: string, + build: (window: UiWindow, left: UiElement, right: UiElement) -> (), + update: (() -> ())?, +} +export type UiModule = { + register_mods_panel: (desc: {build: (panel: UiElement) -> (), update: (() -> ())?}) -> (), + window_push: (desc: {tabs: {UiTabDesc}, rcss: string?, on_closed: ((window: UiWindow) -> ())?}) -> UiWindow, + dialog_push: (desc: { + title: string, + body_rml: string, + variant: ("normal" | "warning" | "danger")?, + icon: string?, + actions: {{label: string, on_pressed: ((dialog: UiDialog) -> ())?, keep_open: boolean?, is_disabled: (() -> boolean)?}}, + on_dismiss: ((dialog: UiDialog) -> ())?, + build: ((pane: UiElement) -> ())?, + }) -> UiDialog, + is_any_document_visible: () -> boolean, + register_styles: (scope: string, rcss: string) -> UiStyle, + register_styles_file: (scope: string, path: string) -> UiStyle, + register_menu_tab: (desc: {label: string, on_selected: () -> ()}) -> UiMenuTab, + push_toast: (desc: {type: string?, title_rml: string?, body_rml: string?, duration_ms: IntegerInput?}) -> (), + get_clipboard_text: () -> string, + set_clipboard_text: (text: string) -> (), +} + +export type LogModule = { + write: (level: "trace" | "debug" | "info" | "warn" | "error", message: string) -> (), + trace: (message: string) -> (), + debug: (message: string) -> (), + info: (message: string) -> (), + warn: (message: string) -> (), + error: (message: string) -> (), +} +export type HostModule = { + version: string, + mod_id: () -> string, + mod_name: () -> string, + mod_version: () -> string, + mod_dir: () -> string, + data_dir: () -> string, + on_update: (callback: () -> ()) -> (), + on_shutdown: (callback: () -> ()) -> (), + fail: (message: string) -> never, +} +export type ResourceModule = { load: (relativePath: string) -> string } + +declare function require(path: "dusklight.log"): LogModule +declare function require(path: "dusklight.host"): HostModule +declare function require(path: "dusklight.config"): ConfigModule +declare function require(path: "dusklight.resource"): ResourceModule +declare function require(path: "dusklight.overlay"): OverlayModule +declare function require(path: "dusklight.texture"): TextureModule +declare function require(path: "dusklight.ui"): UiModule +declare function require(path: string): any diff --git a/sdk/luau/template/mod.json b/sdk/luau/template/mod.json new file mode 100644 index 0000000000..85a13a6459 --- /dev/null +++ b/sdk/luau/template/mod.json @@ -0,0 +1,8 @@ +{ + "id": "com.example.my_script_mod", + "name": "My Script Mod", + "version": "1.0.0", + "author": "Your Name", + "description": "A Luau script mod", + "runtime": "dev.twilitrealm.luau@1.0" +} diff --git a/sdk/luau/template/res/main.luau b/sdk/luau/template/res/main.luau new file mode 100644 index 0000000000..102988c164 --- /dev/null +++ b/sdk/luau/template/res/main.luau @@ -0,0 +1,8 @@ +local log = require("dusklight.log") +local host = require("dusklight.host") + +log.info("My Script Mod initialized") + +host.on_shutdown(function() + log.info("My Script Mod shutting down") +end) diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index 45829188db..02552022a8 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -53,11 +53,25 @@ #if TARGET_PC #include "dusk/action_bindings.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/dual_buffer.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #include "res/Object/Alink.h" #include #include + +static const int IRON_BALL_CHAIN_COUNT = 102; +static const int HS_CHAIN_ANCHOR_COUNT = 4; + +namespace { +struct AlinkInterp { + dusk::interp::DualBuffer ib_pos; + dusk::interp::DualBuffer ib_angle; + dusk::interp::DualBuffer ib_hand; + cXyz hs_draw[HS_CHAIN_ANCHOR_COUNT]; + dusk::interp::DualBuffer hs_chain{hs_draw}; +}; +} // namespace #endif static int daAlink_Create(fopAc_ac_c* i_this); @@ -4313,7 +4327,9 @@ int daAlink_c::createHeap() { return 0; } - JKRReadIdxResource(mFaceBckHeap.getBuffer(), 0xC00, dRes_ID_ALANM_BCK_FAT_e, dComIfGp_getAnmArchive()); + IF_DUSK(mFaceBckHeap.reserveBuffer(dRes_ID_ALANM_BCK_FAT_e);) + JKRReadIdxResource(mFaceBckHeap.getBuffer(), DUSK_IF_ELSE(mFaceBckHeap.getBufferSize(), 0xC00), + dRes_ID_ALANM_BCK_FAT_e, dComIfGp_getAnmArchive()); J3DAnmTransform* bck = (J3DAnmTransform*)J3DAnmLoaderDataBase::load(mFaceBckHeap.getBuffer()); if (!mFaceBck.init(bck, FALSE, J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, false)) { return 0; @@ -5991,7 +6007,7 @@ void daAlink_c::setItemMatrix(int param_0) { mDoMtx_stack_c::XrotS(-0x8000); #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { Mtx boot_mtx; mDoMtx_concat(mpLinkModel->getAnmMtx(0x18), mDoMtx_stack_c::get(), boot_mtx); mpLinkBootModels[1]->setAnmMtx(1, boot_mtx); @@ -14307,7 +14323,11 @@ BOOL daAlink_c::checkMagicArmorWearAbility() const { J3DModelData* daAlink_c::loadAramBmd(u16 i_resIdx, u32 i_bufSize) { JKRArchive* anmArchive = dComIfGp_getAnmArchive(); +#if TARGET_PC + u8* tmpBuffer = (u8*)mItemHeap[field_0x2fa0].allocTempBuffer(i_resIdx, &i_bufSize); +#else u8* tmpBuffer = JKR_NEW_ARRAY_ARGS(u8, i_bufSize, 0x20); +#endif JKRReadIdxResource(tmpBuffer, i_bufSize, i_resIdx, anmArchive); #if DEBUG @@ -14328,7 +14348,11 @@ J3DModelData* daAlink_c::loadAramBmd(u16 i_resIdx, u32 i_bufSize) { } void* daAlink_c::loadAram(u16 i_resIdx, u32 i_bufSize) { +#if TARGET_PC + u8* tmpBuffer = (u8*)mItemHeap[field_0x2fa0].allocTempBuffer(i_resIdx, &i_bufSize); +#else u8* tmpBuffer = JKR_NEW_ARRAY_ARGS(u8, i_bufSize, 0x20); +#endif JKRReadIdxResource(tmpBuffer, i_bufSize, i_resIdx, dComIfGp_getAnmArchive()); #if DEBUG daPy_aramBufferCheck(tmpBuffer, i_bufSize); @@ -14806,10 +14830,13 @@ void daAlink_c::deleteEquipItem(BOOL i_isPlaySound, BOOL i_isDeleteKantera) { mIronBallChainAngle = NULL; field_0x3848 = NULL; #if TARGET_PC - mIBChainInterpPrevValid = false; - mIBChainInterpCurrValid = false; - mHsChainInterpPrevValid = false; - mHsChainInterpCurrValid = false; + { + auto& interp = dusk::interp::get(this); + interp.ib_pos.reset(); + interp.ib_angle.reset(); + interp.ib_hand.reset(); + interp.hs_chain.reset(); + } #endif field_0x0774 = NULL; field_0x0778 = NULL; @@ -19782,36 +19809,21 @@ int daAlink_c::draw() { dComIfGd_getOpaListDark()->entryImm(mpHookChain, 0); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { + auto& interp = dusk::interp::get(this); if (mEquipItem == dItemNo_IRONBALL_e && mIronBallChainPos != NULL && mIronBallChainAngle != NULL) { - if (mIBChainInterpCurrValid) { - memcpy(mIBChainInterpPrevPos, mIBChainInterpCurrPos, IRON_BALL_CHAIN_COUNT * sizeof(cXyz)); - memcpy(mIBChainInterpPrevAngle, mIBChainInterpCurrAngle, IRON_BALL_CHAIN_COUNT * sizeof(csXyz)); - mIBChainInterpPrevHandRoot = mIBChainInterpCurrHandRoot; - mIBChainInterpPrevValid = true; - } - - memcpy(mIBChainInterpCurrPos, mIronBallChainPos, IRON_BALL_CHAIN_COUNT * sizeof(cXyz)); - memcpy(mIBChainInterpCurrAngle, mIronBallChainAngle, IRON_BALL_CHAIN_COUNT * sizeof(csXyz)); - mIBChainInterpCurrHandRoot = mHookshotTopPos; - mIBChainInterpCurrValid = true; - - dusk::frame_interp::add_interpolation_callback(&ironBallChainInterpCallback, this); + interp.ib_pos.writeback(mIronBallChainPos, IRON_BALL_CHAIN_COUNT); + interp.ib_angle.writeback(mIronBallChainAngle, IRON_BALL_CHAIN_COUNT); + interp.ib_hand.writeback(&mHookshotTopPos, 1); } else { - if (mHsChainInterpCurrValid) { - mHsChainInterpPrevTop = mHsChainInterpCurrTop; - mHsChainInterpPrevRoot = mHsChainInterpCurrRoot; - mHsChainInterpPrevSubRoot = mHsChainInterpCurrSubRoot; - mHsChainInterpPrevSubTop = mHsChainInterpCurrSubTop; - mHsChainInterpPrevValid = true; - } - mHsChainInterpCurrTop = mHookshotTopPos; - mHsChainInterpCurrRoot = mHeldItemRootPos; - mHsChainInterpCurrSubRoot = field_0x3810; - mHsChainInterpCurrSubTop = mIronBallBgChkPos; - mHsChainInterpCurrValid = true; + cXyz hsAnchors[HS_CHAIN_ANCHOR_COUNT]; + hsAnchors[0] = mHookshotTopPos; + hsAnchors[1] = mHeldItemRootPos; + hsAnchors[2] = field_0x3810; + hsAnchors[3] = mIronBallBgChkPos; + interp.hs_chain.capture_and_schedule(hsAnchors, HS_CHAIN_ANCHOR_COUNT); } } #endif diff --git a/src/d/actor/d_a_alink_demo.inc b/src/d/actor/d_a_alink_demo.inc index f16c8a6887..aaa38f544e 100644 --- a/src/d/actor/d_a_alink_demo.inc +++ b/src/d/actor/d_a_alink_demo.inc @@ -2387,7 +2387,7 @@ int daAlink_c::procCoGetItemInit() { if (var_r31 != 0) { mProcVar3.field_0x300e = -0x8000; mProcVar4.field_0x3010 = 1; - } else if (mDemo.getParam1() == 2) { + } else if (mDemo.getParam1() == DUSK_IF_ELSE(dusk::mods::item_give_tag("prayer_reward"), 2)) { mProcVar3.field_0x300e = 0; } else { mProcVar3.field_0x300e = shape_angle.y - (fopCamM_GetAngleY(dComIfGp_getCamera(field_0x317c)) + 0x8000); diff --git a/src/d/actor/d_a_alink_effect.inc b/src/d/actor/d_a_alink_effect.inc index db64d25b81..b3a9d7bdc4 100644 --- a/src/d/actor/d_a_alink_effect.inc +++ b/src/d/actor/d_a_alink_effect.inc @@ -8,7 +8,10 @@ #include "d/actor/d_a_alink.h" #include "d/d_com_inf_game.h" #include "d/d_k_wmark.h" + +#if TARGET_PC #include "helpers/gx_helper.h" +#endif DUSK_GAME_DATA const EffParamProc daAlink_c::m_fEffParamProc[] = { &daAlink_c::setEffectFrontRollParam, diff --git a/src/d/actor/d_a_alink_hook.inc b/src/d/actor/d_a_alink_hook.inc index 660cf3b2ce..9e4e7090f8 100644 --- a/src/d/actor/d_a_alink_hook.inc +++ b/src/d/actor/d_a_alink_hook.inc @@ -8,9 +8,15 @@ #include "d/actor/d_a_obj_swhang.h" #include "d/actor/d_a_obj_chandelier.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/dual_buffer.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" +static const int HS_CHAIN_MAX_LINKS = 600; +#endif + enum { HS_MODE_NONE_e, HS_MODE_READY_e, @@ -19,10 +25,6 @@ enum { HS_MODE_RETURN_e = 6, }; -#if TARGET_PC -static const int HS_CHAIN_MAX_LINKS = 600; -#endif - void daAlink_c::hsChainShape_c::draw() { static const int dummy = 0; @@ -34,9 +36,7 @@ void daAlink_c::hsChainShape_c::draw() { j3dSys.setVtxPos(modelData->getVtxPosArray(), modelData->getVtxNum()); j3dSys.setVtxNrm(modelData->getVtxNrmArray(), modelData->getNrmNum()); j3dSys.setVtxCol(modelData->getVtxColorArray(0), modelData->getColNum()); -#if TARGET_PC - j3dSys.setTexture(modelData->getTexture()); -#endif + IF_DUSK(j3dSys.setTexture(modelData->getTexture())); J3DShape::resetVcdVatCache(); material->loadSharedDL(); @@ -138,24 +138,21 @@ void daAlink_c::hsChainShape_c::draw() { } else { #if TARGET_PC cXyz hsInterpTop, hsInterpRoot, hsInterpSubRoot, hsInterpSubTop; - if (dusk::frame_interp::is_enabled() && alink->mHsChainInterpPrevValid && alink->mHsChainInterpCurrValid) { - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - hsInterpTop = alink->mHsChainInterpPrevTop + (alink->mHsChainInterpCurrTop - alink->mHsChainInterpPrevTop) * alpha; - hsInterpRoot = alink->mHsChainInterpPrevRoot + (alink->mHsChainInterpCurrRoot - alink->mHsChainInterpPrevRoot) * alpha; - hsInterpSubRoot = alink->mHsChainInterpPrevSubRoot + (alink->mHsChainInterpCurrSubRoot - alink->mHsChainInterpPrevSubRoot) * alpha; - hsInterpSubTop = alink->mHsChainInterpPrevSubTop + (alink->mHsChainInterpCurrSubTop - alink->mHsChainInterpPrevSubTop) * alpha; + auto& hsInterp = dusk::interp::get(alink); + if (dusk::interp::is_enabled() && hsInterp.hs_chain.ready()) { + hsInterpTop = hsInterp.hs_draw[0]; + hsInterpRoot = hsInterp.hs_draw[1]; + hsInterpSubRoot = hsInterp.hs_draw[2]; + hsInterpSubTop = hsInterp.hs_draw[3]; } else { - hsInterpTop = alink->getHsChainTopPos(); - hsInterpRoot = alink->getHsChainRootPos(); + hsInterpTop = alink->getHsChainTopPos(); + hsInterpRoot = alink->getHsChainRootPos(); hsInterpSubRoot = alink->getHsSubChainRootPos(); hsInterpSubTop = alink->getHsSubChainTopPos(); } - const cXyz& chainRootPos = hsInterpRoot; - const cXyz& chainTopPos = hsInterpTop; -#else - const cXyz& chainRootPos = alink->getHsChainRootPos(); - const cXyz& chainTopPos = alink->getHsChainTopPos(); #endif + const cXyz& chainRootPos = DUSK_IF_ELSE(hsInterpRoot, alink->getHsChainRootPos()); + const cXyz& chainTopPos = DUSK_IF_ELSE(hsInterpTop, alink->getHsChainTopPos()); cXyz maxDistance = chainRootPos - chainTopPos; f32 maxDistanceF = maxDistance.abs(); @@ -185,11 +182,9 @@ void daAlink_c::hsChainShape_c::draw() { } (void)0; -#if TARGET_PC - int chainLinks = 0; -#endif + IF_DUSK(int chainLinks = 0); - while (maxDistanceF > var_f30 IF_DUSK(&&chainLinks < HS_CHAIN_MAX_LINKS)) { + while (maxDistanceF > var_f30 IF_DUSK(&& chainLinks < HS_CHAIN_MAX_LINKS)) { temp_f27 = var_f28 * cM_fsin(sp34 * var_f30); s16 spC = cM_atan2s(temp_f27 - var_f26, 5.0f); sp64.x = sp6C.x + spC; @@ -212,19 +207,12 @@ void daAlink_c::hsChainShape_c::draw() { var_f26 = temp_f27; var_f30 += fabsf(cM_scos(spC)) * 5.0f; -#if TARGET_PC - chainLinks++; -#endif + IF_DUSK(chainLinks++); } } -#if TARGET_PC - const cXyz& subChainRootPos = hsInterpSubRoot; - const cXyz& subChainTopPos = hsInterpSubTop; -#else - const cXyz& subChainRootPos = alink->getHsSubChainRootPos(); - const cXyz& subChainTopPos = alink->getHsSubChainTopPos(); -#endif + const cXyz& subChainRootPos = DUSK_IF_ELSE(hsInterpSubRoot, alink->getHsSubChainRootPos()); + const cXyz& subChainTopPos = DUSK_IF_ELSE(hsInterpSubTop, alink->getHsSubChainTopPos()); maxDistance = subChainRootPos - subChainTopPos; maxDistanceF = maxDistance.abs(); @@ -235,11 +223,9 @@ void daAlink_c::hsChainShape_c::draw() { sp98 = subChainTopPos; sp6C.set(maxDistance.atan2sY_XZ(), maxDistance.atan2sX_Z(), 0); -#if TARGET_PC - int subChainLinks = 0; -#endif + IF_DUSK(int subChainLinks = 0); - while (maxDistanceF > var_f30 IF_DUSK(&&subChainLinks < HS_CHAIN_MAX_LINKS)) { + while (maxDistanceF > var_f30 IF_DUSK(&& subChainLinks < HS_CHAIN_MAX_LINKS)) { mDoMtx_stack_c::copy(j3dSys.getViewMtx()); mDoMtx_stack_c::transM(sp98); mDoMtx_stack_c::ZXYrotM(sp6C); @@ -252,39 +238,12 @@ void daAlink_c::hsChainShape_c::draw() { sp98 += maxDistance * 5.0f; ANGLE_ADD_2(sp6C.z, 0x3000); var_f30 += 5.0f; -#if TARGET_PC - subChainLinks++; -#endif + IF_DUSK(subChainLinks++); } } } } -#if TARGET_PC -static void ironBallChainInterpCallback(bool isSimFrame, void* pUserWork) { - static_cast(pUserWork)->onIronBallChainInterpCallback(); -} - -void daAlink_c::onIronBallChainInterpCallback() { - if (!mIBChainInterpPrevValid || !mIBChainInterpCurrValid) { - return; - } - if (mIronBallChainPos == NULL || mIronBallChainAngle == NULL) { - return; - } - - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - - for (int i = 0; i < IRON_BALL_CHAIN_COUNT; i++) { - mIronBallChainPos[i] = mIBChainInterpPrevPos[i] + (mIBChainInterpCurrPos[i] - mIBChainInterpPrevPos[i]) * alpha; - mIronBallChainAngle[i].x = mIBChainInterpPrevAngle[i].x + (s16)((s16)(mIBChainInterpCurrAngle[i].x - mIBChainInterpPrevAngle[i].x) * alpha); - mIronBallChainAngle[i].y = mIBChainInterpPrevAngle[i].y + (s16)((s16)(mIBChainInterpCurrAngle[i].y - mIBChainInterpPrevAngle[i].y) * alpha); - mIronBallChainAngle[i].z = mIBChainInterpPrevAngle[i].z + (s16)((s16)(mIBChainInterpCurrAngle[i].z - mIBChainInterpPrevAngle[i].z) * alpha); - } - mHookshotTopPos = mIBChainInterpPrevHandRoot + (mIBChainInterpCurrHandRoot - mIBChainInterpPrevHandRoot) * alpha; -} -#endif - void daAlink_c::hookshotAtHitCallBack(dCcD_GObjInf* i_atObjInf, fopAc_ac_c* i_tgActor, dCcD_GObjInf* i_tgObjInf) { if (i_tgActor != NULL && fopAcM_IsActor(i_tgActor) && !i_tgObjInf->ChkTgHookshotThrough()) { diff --git a/src/d/actor/d_a_alink_horse.inc b/src/d/actor/d_a_alink_horse.inc index 7389decb73..f271ed401e 100644 --- a/src/d/actor/d_a_alink_horse.inc +++ b/src/d/actor/d_a_alink_horse.inc @@ -340,18 +340,31 @@ void daAlink_c::setHorseStirrup() { mDoMtx_stack_c::copy(mpLinkModel->getAnmMtx(field_0x30bc)); mDoMtx_stack_c::transM(-2.0f, -11.0f, 1.5f); mDoMtx_stack_c::ZXYrotM(0, -0x8000, 0x4000); +#if TARGET_PC + horse->m_model->setAnmMtx(0x17, mDoMtx_stack_c::get()); +#else mDoMtx_copy(mDoMtx_stack_c::get(), horse->getLeftStirrupMtx()); +#endif } if (field_0x2fab & 2) { mDoMtx_stack_c::copy(mpLinkModel->getAnmMtx(field_0x30be)); mDoMtx_stack_c::transM(-2.0f, 11.0f, 1.5f); mDoMtx_stack_c::ZrotM(-0x4000); +#if TARGET_PC + horse->m_model->setAnmMtx(0x19, mDoMtx_stack_c::get()); +#else mDoMtx_copy(mDoMtx_stack_c::get(), horse->getRightStirrupMtx()); +#endif } if (field_0x2fab & 3) { horse->calcWeightEnvMtx(); +#if TARGET_PC + for (u16 i = 0; i < horse->m_model->getModelData()->getWEvlpMtxNum(); i++) { + dusk::interp::record_final_mtx(horse->m_model->getWeightAnmMtx(i)); + } +#endif } int hand_type = getReinHandType(); diff --git a/src/d/actor/d_a_alink_swindow.inc b/src/d/actor/d_a_alink_swindow.inc index 33f1fee37b..0359bc99bb 100644 --- a/src/d/actor/d_a_alink_swindow.inc +++ b/src/d/actor/d_a_alink_swindow.inc @@ -11,6 +11,16 @@ static int daAlink_modelCallBack(J3DJoint* i_joint, int param_1); static int daAlink_headModelCallBack(J3DJoint* i_joint, int param_1); static int daAlink_wolfModelCallBack(J3DJoint* i_joint, int param_1); +#if TARGET_PC +static void* read_anm_resource(void** o_buffer, u16 i_resIdx, u32 i_fixedSize) { + u32 size = daPy_getAnmResourceSize(i_resIdx, i_fixedSize); + *o_buffer = JKRAllocFromSysHeap(size, 0x20); + JUT_ASSERT(__LINE__, *o_buffer); + JKRReadIdxResource(*o_buffer, size, i_resIdx, dComIfGp_getAnmArchive()); + return *o_buffer; +} +#endif + void daAlink_c::setArcName(BOOL i_isWolf) { if (i_isWolf) { mArcName = l_wArcName; @@ -247,8 +257,10 @@ void daAlink_c::changeModelDataDirectWolf(int param_0) { void daAlink_c::initStatusWindow() { onNoResetFlg2(FLG2_STATUS_WINDOW_DRAW); +#if !TARGET_PC void* tmpBuffer = JKR_NEW_ARRAY_ARGS(void*, 0x500, 0x20); JUT_ASSERT(394, tmpBuffer); +#endif u16 bckResIdx, btpResIdx, btkResIdx; if (checkWolf()) { @@ -268,7 +280,11 @@ void daAlink_c::initStatusWindow() { changeModelDataDirect(0); } +#if TARGET_PC + void* tmpBuffer = read_anm_resource(&mAnmBuffers[0], bckResIdx, 0x1400); +#else JKRReadIdxResource(tmpBuffer, 0x1400, bckResIdx, dComIfGp_getAnmArchive()); +#endif m_sWindowBck = JKR_NEW mDoExt_bckAnm(); JUT_ASSERT(428, m_sWindowBck); @@ -276,20 +292,28 @@ void daAlink_c::initStatusWindow() { JUT_ASSERT(433, FALSE); } +#if TARGET_PC + tmpBuffer = read_anm_resource(&mAnmBuffers[1], btpResIdx, 0x400); +#else tmpBuffer = JKR_NEW_ARRAY_ARGS(void*, 0x100, 0x20); JUT_ASSERT(437, tmpBuffer); JKRReadIdxResource(tmpBuffer, 0x400, btpResIdx, dComIfGp_getAnmArchive()); +#endif // this should call J3DAnmLoaderDataBase::load(const void*) but it breaks retail J3DAnmTexPattern* btp = (J3DAnmTexPattern*)J3DAnmLoaderDataBase::load(tmpBuffer, J3DLOADER_UNK_FLAG0); btp->setFrame(0.0f); btp->searchUpdateMaterialID(field_0x06c0); field_0x06c0->entryTexNoAnimator(btp); +#if TARGET_PC + tmpBuffer = read_anm_resource(&mAnmBuffers[2], btkResIdx, 0x400); +#else tmpBuffer = JKR_NEW_ARRAY_ARGS(void*, 0x100, 0x20); JUT_ASSERT(449, tmpBuffer); JKRReadIdxResource(tmpBuffer, 0x400, btkResIdx, dComIfGp_getAnmArchive()); +#endif // this should call J3DAnmLoaderDataBase::load(const void*) but it breaks retail J3DAnmTextureSRTKey* btk = (J3DAnmTextureSRTKey*)J3DAnmLoaderDataBase::load(tmpBuffer, J3DLOADER_UNK_FLAG0); btk->setFrame(0.0f); @@ -387,4 +411,12 @@ void daAlink_c::resetStatusWindow() { offNoResetFlg2(FLG2_STATUS_WINDOW_DRAW); m_sWindowBck = NULL; +#if TARGET_PC + for (int i = 0; i < 3; i++) { + if (mAnmBuffers[i] != NULL) { + JKRFreeToSysHeap(mAnmBuffers[i]); + mAnmBuffers[i] = NULL; + } + } +#endif } diff --git a/src/d/actor/d_a_b_gnd.cpp b/src/d/actor/d_a_b_gnd.cpp index 80cca37f6e..42eeac303a 100644 --- a/src/d/actor/d_a_b_gnd.cpp +++ b/src/d/actor/d_a_b_gnd.cpp @@ -17,10 +17,10 @@ #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #if TARGET_PC #include "dusk/achievements.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/settings.h" #endif class daB_GND_HIO_c : public JORReflexible { @@ -285,30 +285,6 @@ static int h_nodeCallBack(J3DJoint* i_joint, int param_2) { return 1; } -#if TARGET_PC -static void b_gnd_rein_interp_callback(bool isSimFrame, void* pUserWork) { - b_gnd_class* i_this = (b_gnd_class*)pUserWork; - if (!i_this->mReinsInterpPrevValid || !i_this->mReinsInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - for (int r = 0; r < 2; r++) { - cXyz* dst = i_this->mHorseReins[r].getPos(0); - for (int i = 0; i < 16; i++) { - const cXyz& p0 = i_this->mReinsInterpPrev[r][i]; - const cXyz& p1 = i_this->mReinsInterpCurr[r][i]; - dst[i] = p0 + (p1 - p0) * alpha; - } - } - cXyz* dst = i_this->field_0x21e8.getPos(0); - for (int i = 0; i < 2; i++) { - const cXyz& p0 = i_this->mReinsTexInterpPrev[i]; - const cXyz& p1 = i_this->mReinsTexInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static int daB_GND_Draw(b_gnd_class* i_this) { fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; @@ -396,21 +372,6 @@ static int daB_GND_Draw(b_gnd_class* i_this) { i_this->field_0x21e8.update(2, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->field_0x21e8); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mReinsInterpCurrValid) { - memcpy(i_this->mReinsInterpPrev, i_this->mReinsInterpCurr, sizeof(i_this->mReinsInterpCurr)); - memcpy(i_this->mReinsTexInterpPrev, i_this->mReinsTexInterpCurr, sizeof(i_this->mReinsTexInterpCurr)); - i_this->mReinsInterpPrevValid = true; - } - for (int r = 0; r < 2; r++) { - memcpy(i_this->mReinsInterpCurr[r], i_this->mHorseReins[r].getPos(0), 16 * sizeof(cXyz)); - } - memcpy(i_this->mReinsTexInterpCurr, i_this->field_0x21e8.getPos(0), 2 * sizeof(cXyz)); - i_this->mReinsInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&b_gnd_rein_interp_callback, i_this); - } -#endif } return 1; @@ -3791,7 +3752,7 @@ static void demo_camera(b_gnd_class* i_this) { i_this->mDemoCamSyncTicks = 2; } if (i_this->mDemoCamSyncTicks > 0) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); i_this->mDemoCamSyncTicks--; } #endif diff --git a/src/d/actor/d_a_balloon_2D.cpp b/src/d/actor/d_a_balloon_2D.cpp index a9d6d0db4f..5d5923abc3 100644 --- a/src/d/actor/d_a_balloon_2D.cpp +++ b/src/d/actor/d_a_balloon_2D.cpp @@ -6,7 +6,6 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_balloon_2D.h" -#include "dusk/frame_interpolation.h" #include "JSystem/J2DGraph/J2DGrafContext.h" #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J2DGraph/J2DTextBox.h" @@ -21,6 +20,10 @@ #include "m_Do/m_Do_lib.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + class daBalloon2D_HIO_c : public mDoHIO_entry_c { public: inline daBalloon2D_HIO_c() { @@ -439,12 +442,9 @@ void daBalloon2D_c::setComboAlpha() { void daBalloon2D_c::drawAddScore() { for (s32 i = 19; i >= 0; i--) { if (field_0x5f8[i].field_0xe != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x5f8[i].field_0xe--; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x5f8[i].field_0xe--; + IF_DUSK_BLOCK_END s32 score3; s32 score2; s32 score = field_0x5f8[i].field_0xc; @@ -452,13 +452,10 @@ void daBalloon2D_c::drawAddScore() { u8 local_88 = 0xff; f32 dVar11 = 30.0f; f32 dVar9 = 30.0f; -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x5f8[i].field_0x0.x += cM_ssin(temp0) * 0.3f; - field_0x5f8[i].field_0x0.y -= 1.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x5f8[i].field_0x0.x += cM_ssin(temp0) * 0.3f; + field_0x5f8[i].field_0x0.y -= 1.0f; + IF_DUSK_BLOCK_END if (field_0x5f8[i].field_0xe < 10) { f32 fVar5 = field_0x5f8[i].field_0xe / 10.0f; local_88 = fVar5 * 255.0f; diff --git a/src/d/actor/d_a_bg.cpp b/src/d/actor/d_a_bg.cpp index 110e2aef15..051abc4172 100644 --- a/src/d/actor/d_a_bg.cpp +++ b/src/d/actor/d_a_bg.cpp @@ -624,9 +624,7 @@ int daBg_c::create() { dComIfGp_roomControl_onStatusFlag(roomNo, 0x10); OS_REPORT(" room%d\n", roomNo); -#if TARGET_PC - draw_interp_frame = true; -#endif + IF_DUSK(draw_interp_frame = true); return cPhs_COMPLEATE_e; } diff --git a/src/d/actor/d_a_bg_obj.cpp b/src/d/actor/d_a_bg_obj.cpp index da18ce4501..84a8995cb8 100644 --- a/src/d/actor/d_a_bg_obj.cpp +++ b/src/d/actor/d_a_bg_obj.cpp @@ -5,15 +5,18 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep -#include -#include -#include -#include "JSystem/J3DGraphBase/J3DMaterial.h" -#include "SSystem/SComponent/c_math.h" #include "d/actor/d_a_bg_obj.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include +#include +#include #include "d/actor/d_a_set_bgobj.h" #include "d/d_s_play.h" +#include "SSystem/SComponent/c_math.h" + +#if TARGET_PC #include "helpers/string.hpp" +#endif static const char* getBmdName(int param_0, int param_1) { static char l_bmdName[16]; diff --git a/src/d/actor/d_a_demo00.cpp b/src/d/actor/d_a_demo00.cpp index 60a99d4d54..b89965a8ce 100644 --- a/src/d/actor/d_a_demo00.cpp +++ b/src/d/actor/d_a_demo00.cpp @@ -1103,14 +1103,8 @@ inline int daDemo00_c::execute() { case 2: { u16 sp0A = sp0E & 0x3FFF; if ((sp0E & 0xC000) == 0) { -#if !MOVIE_SUPPORT - // If movie support isn't available, automatically reset. - // TPHD-esque. Maybe not the best solution, but it works. - dComIfGp_event_reset(); -#else fopAcM_create(fpcNm_MOVIE_PLAYER_e, sp0A, NULL, fopAcM_GetRoomNo(this), NULL, NULL, 0xFF); mDoGph_gInf_c::fadeOut(1.0f); -#endif } else { switch (sp0A) { case 0: diff --git a/src/d/actor/d_a_demo_item.cpp b/src/d/actor/d_a_demo_item.cpp index 465532a5f0..0c092cf59b 100644 --- a/src/d/actor/d_a_demo_item.cpp +++ b/src/d/actor/d_a_demo_item.cpp @@ -462,7 +462,7 @@ int daDitem_c::create() { m_itemNo = daDitem_prm::getNo(this); #if TARGET_PC - const auto [item, displayItem] = dusk::mods::item_check_resolve(mItemGiveTag, m_itemNo, this); + const auto [item, displayItem, _] = dusk::mods::item_check_resolve(mItemGiveTag, m_itemNo, this); m_itemNo = item; setDisplayItemNo(displayItem); const char* arc_name = dItem_data::getArcName(displayItem); @@ -550,7 +550,7 @@ static int daDitem_Execute(daDitem_c* i_this) { } int daDitem_c::draw() { - switch (m_itemNo) { + switch (DUSK_IF_ELSE(getDisplayItemNo(), m_itemNo)) { case dItemNo_WOOD_STICK_e: draw_WOOD_STICK(); break; diff --git a/src/d/actor/d_a_door_shutter.cpp b/src/d/actor/d_a_door_shutter.cpp index 3b7cdcc5f2..b7a7286903 100644 --- a/src/d/actor/d_a_door_shutter.cpp +++ b/src/d/actor/d_a_door_shutter.cpp @@ -18,8 +18,9 @@ #include #if TARGET_PC -#include -#include +#include "dusk/autosave.h" + +#include "f_ap/f_ap_game.h" #endif char DUSK_CONST* daDoor20_c::getStopBmdName() { diff --git a/src/d/actor/d_a_e_bee.cpp b/src/d/actor/d_a_e_bee.cpp index 09909f9e0a..3cfadae812 100644 --- a/src/d/actor/d_a_e_bee.cpp +++ b/src/d/actor/d_a_e_bee.cpp @@ -15,6 +15,10 @@ #include "SSystem/SComponent/c_math.h" #include "Z2AudioLib/Z2Instances.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static bool hio_set; static daE_Bee_HIO_c l_HIO; @@ -50,6 +54,26 @@ static int daE_Bee_Draw(e_bee_class* i_this) { return 1; } +#if TARGET_PC +static void bee_interp(bee_s* i_bee) { + if (!dusk::interp::is_enabled()) { + return; + } + + J3DModel* models[] = { + i_bee->mpModel1, + i_bee->mpModel2, + i_bee->mpModel3, + i_bee->mpModel4, + }; + MtxP mtx = mDoMtx_stack_c::get(); + for (int i = 0; i < 4; i++) { + models[i]->setBaseTRMtx(mtx); + models[i]->calc(); + } +} +#endif + static void bee_mtxset(bee_s* i_bee) { mDoMtx_stack_c::transS(i_bee->mPos.x, i_bee->mPos.y, i_bee->mPos.z); mDoMtx_stack_c::YrotM(i_bee->mAngle.y); @@ -62,6 +86,7 @@ static void bee_mtxset(bee_s* i_bee) { } else { i_bee->mpModel2->setBaseTRMtx(mDoMtx_stack_c::get()); } + IF_DUSK(bee_interp(i_bee)); } static void bee_ground_ang_set(bee_s* i_bee) { @@ -332,6 +357,7 @@ static void bee_nest_action(e_bee_class* i_this, bee_s* i_bee, s8 i_nestHealth) i_bee->mpModel4->setBaseTRMtx(mDoMtx_stack_c::get()); } } + IF_DUSK(bee_interp(i_bee)); if (i_nestHealth == 1) { i_bee->mAction = bee_s::ACT_FLY; diff --git a/src/d/actor/d_a_e_db.cpp b/src/d/actor/d_a_e_db.cpp index dcc3849756..65f91843a3 100644 --- a/src/d/actor/d_a_e_db.cpp +++ b/src/d/actor/d_a_e_db.cpp @@ -10,10 +10,6 @@ #include "f_op/f_op_kankyo_mng.h" #include "f_op/f_op_actor_enemy.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - class daE_DB_HIO_c : public JORReflexible { public: daE_DB_HIO_c(); @@ -70,22 +66,6 @@ static BOOL leaf_anm_init(e_db_class* i_this, int i_anm, f32 i_morf, u8 i_mode, return FALSE; } -#if TARGET_PC -static void daE_DB_interp_callback(bool isSimFrame, void* pUserWork) { - e_db_class* i_this = (e_db_class*)pUserWork; - if (!i_this->mStalkLineInterpPrevValid || !i_this->mStalkLineInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz* dst = i_this->stalkLine.getPos(0); - for (int i = 0; i < 12; i++) { - const cXyz& p0 = i_this->mStalkLineInterpPrev[i]; - const cXyz& p1 = i_this->mStalkLineInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static int daE_DB_Draw(e_db_class* i_this) { fopAc_ac_c* actor = &i_this->enemy; @@ -115,17 +95,6 @@ static int daE_DB_Draw(e_db_class* i_this) { static GXColor l_color = {0x14, 0x0F, 0x00, 0xFF}; i_this->stalkLine.update(12, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->stalkLine); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mStalkLineInterpCurrValid) { - memcpy(i_this->mStalkLineInterpPrev, i_this->mStalkLineInterpCurr, sizeof(i_this->mStalkLineInterpCurr)); - i_this->mStalkLineInterpPrevValid = true; - } - memcpy(i_this->mStalkLineInterpCurr, i_this->stalkLine.getPos(0), 12 * sizeof(cXyz)); - i_this->mStalkLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_DB_interp_callback, i_this); - } -#endif for (int i = 1; i < 11; i++) { if (i_this->thornModel[i] != NULL) { diff --git a/src/d/actor/d_a_e_hb.cpp b/src/d/actor/d_a_e_hb.cpp index f0dfbda3a6..b39f4750a1 100644 --- a/src/d/actor/d_a_e_hb.cpp +++ b/src/d/actor/d_a_e_hb.cpp @@ -9,10 +9,6 @@ #include "d/actor/d_a_e_hb_leaf.h" #include "f_op/f_op_actor_enemy.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - enum daE_HB_ACTION { ACTION_STAY, ACTION_APPEAR, @@ -68,22 +64,6 @@ static BOOL leaf_anm_init(e_hb_class* i_this, int i_anm, f32 i_morf, u8 i_mode, return FALSE; } -#if TARGET_PC -static void daE_HB_interp_callback(bool isSimFrame, void* pUserWork) { - e_hb_class* i_this = (e_hb_class*)pUserWork; - if (!i_this->mStalkLineInterpPrevValid || !i_this->mStalkLineInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz* dst = i_this->stalkLine.getPos(0); - for (int i = 0; i < 12; i++) { - const cXyz& p0 = i_this->mStalkLineInterpPrev[i]; - const cXyz& p1 = i_this->mStalkLineInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static int daE_HB_Draw(e_hb_class* i_this) { fopAc_ac_c* actor = &i_this->enemy; @@ -102,17 +82,6 @@ static int daE_HB_Draw(e_hb_class* i_this) { static GXColor l_color = {0x14, 0x0F, 0x00, 0xFF}; i_this->stalkLine.update(12, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->stalkLine); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mStalkLineInterpCurrValid) { - memcpy(i_this->mStalkLineInterpPrev, i_this->mStalkLineInterpCurr, sizeof(i_this->mStalkLineInterpCurr)); - i_this->mStalkLineInterpPrevValid = true; - } - memcpy(i_this->mStalkLineInterpCurr, i_this->stalkLine.getPos(0), 12 * sizeof(cXyz)); - i_this->mStalkLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_HB_interp_callback, i_this); - } -#endif for (int i = 1; i < 11; i++) { if (i_this->thornModel[i] != NULL) { diff --git a/src/d/actor/d_a_e_mb.cpp b/src/d/actor/d_a_e_mb.cpp index 1fff337b33..9eaef0cc1c 100644 --- a/src/d/actor/d_a_e_mb.cpp +++ b/src/d/actor/d_a_e_mb.cpp @@ -12,8 +12,6 @@ #include "d/d_bomb.h" #include "c/c_damagereaction.h" #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #define ACTION_STANDBY 0 #define ACTION_WALK1 1 @@ -65,22 +63,6 @@ static void anm_init(e_mb_class* i_this, int i_anmID, f32 i_morf, u8 i_attr, f32 i_this->mAnm = i_anmID; } -#if TARGET_PC -static void e_mb_rope_interp_callback(bool isSimFrame, void* pUserWork) { - e_mb_class* i_this = (e_mb_class*)pUserWork; - if (!i_this->mRopeInterpPrevValid || !i_this->mRopeInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz* dst = i_this->mRopeMat.getPos(0); - for (int i = 0; i < 16; i++) { - const cXyz& p0 = i_this->mRopeInterpPrev[i]; - const cXyz& p1 = i_this->mRopeInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static int daE_MB_Draw(e_mb_class* i_this) { fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; @@ -104,17 +86,6 @@ static int daE_MB_Draw(e_mb_class* i_this) { static GXColor l_color = {0x14, 0x0F, 0x00, 0xFF}; i_this->mRopeMat.update(16, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mRopeMat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mRopeInterpCurrValid) { - memcpy(i_this->mRopeInterpPrev, i_this->mRopeInterpCurr, sizeof(i_this->mRopeInterpCurr)); - i_this->mRopeInterpPrevValid = true; - } - memcpy(i_this->mRopeInterpCurr, i_this->mRopeMat.getPos(0), 16 * sizeof(cXyz)); - i_this->mRopeInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&e_mb_rope_interp_callback, i_this); - } -#endif return 1; } diff --git a/src/d/actor/d_a_e_po.cpp b/src/d/actor/d_a_e_po.cpp index a7a7be6dd1..112ad2d56f 100644 --- a/src/d/actor/d_a_e_po.cpp +++ b/src/d/actor/d_a_e_po.cpp @@ -7,6 +7,9 @@ #include "d/actor/d_a_e_po.h" #include "d/actor/d_a_obj_poFire.h" +#if TARGET_PC +#include "d/actor/d_a_alink.h" +#endif #include "d/d_cc_d.h" #include "d/d_cc_uty.h" #include "f_op/f_op_actor_enemy.h" diff --git a/src/d/actor/d_a_e_s1.cpp b/src/d/actor/d_a_e_s1.cpp index cd48a103e1..3c7c6700e5 100644 --- a/src/d/actor/d_a_e_s1.cpp +++ b/src/d/actor/d_a_e_s1.cpp @@ -14,8 +14,6 @@ #include "d/d_s_play.h" #include "f_op/f_op_actor_enemy.h" #include "f_op/f_op_camera_mng.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include class daE_S1_HIO_c { @@ -101,32 +99,6 @@ static void anm_init(e_s1_class* i_this, int i_resNo, f32 i_morf, u8 i_attr, f32 i_this->mAnm = i_resNo; } -#if TARGET_PC -static void daE_S1_interp_callback(bool isSimFrame, void* pUserWork) { - e_s1_class* i_this = (e_s1_class*)pUserWork; - if (!i_this->mHairInterpPrevValid || !i_this->mHairInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - for (int s = 0; s < e_s1_class::HAIR_STRAND_COUNT; s++) { - cXyz* dst = i_this->mLineMat.getPos(s); - for (int i = 0; i < e_s1_class::HAIR_SEGMENT_COUNT; i++) { - int idx = s * e_s1_class::HAIR_SEGMENT_COUNT + i; - const cXyz& p0 = i_this->mHairInterpPrev[idx]; - const cXyz& p1 = i_this->mHairInterpCurr[idx]; - dst[i] = p0 + (p1 - p0) * alpha; - } - } - GXColor line_color; - line_color.r = JREG_S(0) + 5; - line_color.g = JREG_S(1) + 10; - line_color.b = JREG_S(2) + 10; - line_color.a = 0xFF; - - i_this->mLineMat.update(16, line_color, &i_this->tevStr); -} -#endif - static int daE_S1_Draw(e_s1_class* i_this) { if (i_this->field_0x306c != 0) { return 1; @@ -160,22 +132,6 @@ static int daE_S1_Draw(e_s1_class* i_this) { i_this->mLineMat.update(16, line_color, &i_this->tevStr); dComIfGd_set3DlineMatDark(&i_this->mLineMat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mHairInterpCurrValid) { - memcpy(i_this->mHairInterpPrev, i_this->mHairInterpCurr, sizeof(i_this->mHairInterpCurr)); - i_this->mHairInterpPrevValid = true; - } - for (int s = 0; s < e_s1_class::HAIR_STRAND_COUNT; s++) { - cXyz* src = i_this->mLineMat.getPos(s); - memcpy(&i_this->mHairInterpCurr[s * e_s1_class::HAIR_SEGMENT_COUNT], src, - e_s1_class::HAIR_SEGMENT_COUNT * sizeof(cXyz)); - } - i_this->mHairInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_S1_interp_callback, i_this); - } -#endif - dComIfGd_setList(); return 1; } @@ -2193,11 +2149,6 @@ static int daE_S1_Create(fopAc_ac_c* i_this) { return cPhs_ERROR_e; } -#if TARGET_PC - a_this->mHairInterpPrevValid = false; - a_this->mHairInterpCurrValid = false; -#endif - OS_REPORT("//////////////E_S1 SET 2 !!\n"); if (path_no != 0xFF) { diff --git a/src/d/actor/d_a_e_sm2.cpp b/src/d/actor/d_a_e_sm2.cpp index 808301527e..96f718ce0b 100644 --- a/src/d/actor/d_a_e_sm2.cpp +++ b/src/d/actor/d_a_e_sm2.cpp @@ -15,7 +15,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class daE_SM2_HIO_c : public fOpAcm_HIO_entry_c { @@ -81,7 +81,7 @@ static int nodeCallBack(J3DJoint* i_joint, int param_1) { } #if TARGET_PC -static void daE_SM2_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_SM2_interp_callback(void* pUserWork) { e_sm2_class* i_this = static_cast(pUserWork); if (i_this == NULL) { return; @@ -133,7 +133,7 @@ static int daE_SM2_Draw(e_sm2_class* i_this) { fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->enemy; #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daE_SM2_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_SM2_interp_callback, i_this); #endif g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); diff --git a/src/d/actor/d_a_e_wb.cpp b/src/d/actor/d_a_e_wb.cpp index b5a38eff65..cf9e4ccbf7 100644 --- a/src/d/actor/d_a_e_wb.cpp +++ b/src/d/actor/d_a_e_wb.cpp @@ -18,10 +18,12 @@ #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_graphic.h" #include "res/Object/Always.h" -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/dusk.h" +#include "dusk/interp/frame_interpolation.h" +#endif class daE_WB_HIO_c : public JORReflexible { public: @@ -186,30 +188,6 @@ static bool hio_set; static daE_WB_HIO_c l_HIO; -#if TARGET_PC -static void e_wb_rein_interp_callback(bool isSimFrame, void* pUserWork) { - e_wb_class* i_this = (e_wb_class*)pUserWork; - if (!i_this->himo_interp_prev_valid || !i_this->himo_interp_curr_valid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - for (int r = 0; r < 2; r++) { - cXyz* dst = i_this->himo_mat[r].getPos(0); - for (int i = 0; i < 16; i++) { - const cXyz& p0 = i_this->himo_mat_interp_prev[r][i]; - const cXyz& p1 = i_this->himo_mat_interp_curr[r][i]; - dst[i] = p0 + (p1 - p0) * alpha; - } - } - cXyz* dst = i_this->himo_tex.getPos(0); - for (int i = 0; i < 2; i++) { - const cXyz& p0 = i_this->himo_tex_interp_prev[i]; - const cXyz& p1 = i_this->himo_tex_interp_curr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static void himo_control1(e_wb_class* i_this, cXyz* i_pos, int i_no, s8 param_3) { fopEn_enemy_c* enemy = &i_this->enemy; cXyz mae, ato; @@ -534,21 +512,6 @@ static int daE_WB_Draw(e_wb_class* i_this) { dComIfGd_set3DlineMat(&i_this->himo_mat[1]); i_this->himo_tex.update(2, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->himo_tex); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->himo_interp_curr_valid) { - memcpy(i_this->himo_mat_interp_prev, i_this->himo_mat_interp_curr, sizeof(i_this->himo_mat_interp_curr)); - memcpy(i_this->himo_tex_interp_prev, i_this->himo_tex_interp_curr, sizeof(i_this->himo_tex_interp_curr)); - i_this->himo_interp_prev_valid = true; - } - for (int r = 0; r < 2; r++) { - memcpy(i_this->himo_mat_interp_curr[r], i_this->himo_mat[r].getPos(0), 16 * sizeof(cXyz)); - } - memcpy(i_this->himo_tex_interp_curr, i_this->himo_tex.getPos(0), 2 * sizeof(cXyz)); - i_this->himo_interp_curr_valid = true; - dusk::frame_interp::add_interpolation_callback(&e_wb_rein_interp_callback, i_this); - } -#endif } return 1; @@ -4542,9 +4505,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_way_spd.z = fabsf(i_this->demo_cam_way.z - i_this->demo_cam_ctr.z); i_this->demo_cam_morf = 0; pla->setPlayerPosAndAngle(&pla->current.pos, pla->shape_angle.y - 4000, 0); -#if TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } if (i_this->demo_timer == 345) { daPy_getPlayerActorClass()->setThrowDamage(boss->enemy.shape_angle.y - 8000 + TREG_S(8), @@ -4791,9 +4752,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_eye.x += 300.0f + VREG_F(8); i_this->demo_cam_eye.y += 150.0f + VREG_F(9); i_this->demo_cam_eye.z -= 1400.0f + VREG_F(10); -#if TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } } else { i_this->demo_cam_eye = enemy->current.pos; @@ -5054,7 +5013,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_sync_ticks = 2; } if (i_this->demo_cam_sync_ticks > 0) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); i_this->demo_cam_sync_ticks--; } #endif diff --git a/src/d/actor/d_a_e_yd.cpp b/src/d/actor/d_a_e_yd.cpp index 52a5be7fdc..bdc7c527e2 100644 --- a/src/d/actor/d_a_e_yd.cpp +++ b/src/d/actor/d_a_e_yd.cpp @@ -12,10 +12,6 @@ #include "d/d_cc_uty.h" #include "f_op/f_op_actor_enemy.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - class daE_YD_HIO_c { public: daE_YD_HIO_c(); @@ -77,22 +73,6 @@ static s32 leaf_anm_init(e_yd_class* i_this, int param_1, f32 param_2, u8 param_ return false; } -#if TARGET_PC -static void daE_YD_interp_callback(bool isSimFrame, void* pUserWork) { - e_yd_class* i_this = (e_yd_class*)pUserWork; - if (!i_this->mLineMatInterpPrevValid || !i_this->mLineMatInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz* dst = i_this->mLineMat.getPos(0); - for (int i = 0; i < 12; i++) { - const cXyz& p0 = i_this->mLineMatInterpPrev[i]; - const cXyz& p1 = i_this->mLineMatInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static s32 daE_YD_Draw(e_yd_class* i_this) { static GXColor l_color = { 0x14, 0x0F, 0x00, 0xFF }; @@ -106,17 +86,6 @@ static s32 daE_YD_Draw(e_yd_class* i_this) { i_this->mpMorf->entryDL(); i_this->mLineMat.update(12, l_color, &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->mLineMat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mLineMatInterpCurrValid) { - memcpy(i_this->mLineMatInterpPrev, i_this->mLineMatInterpCurr, sizeof(i_this->mLineMatInterpCurr)); - i_this->mLineMatInterpPrevValid = true; - } - memcpy(i_this->mLineMatInterpCurr, i_this->mLineMat.getPos(0), 12 * sizeof(cXyz)); - i_this->mLineMatInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YD_interp_callback, i_this); - } -#endif for (s32 i = 1; i < 11; i++) { if (i_this->field_0x77c[i] != 0) { g_env_light.setLightTevColorType_MAJI(i_this->field_0x77c[i], &i_this->actor.tevStr); diff --git a/src/d/actor/d_a_e_yg.cpp b/src/d/actor/d_a_e_yg.cpp index 71756d6f57..e6bcd05098 100644 --- a/src/d/actor/d_a_e_yg.cpp +++ b/src/d/actor/d_a_e_yg.cpp @@ -10,8 +10,6 @@ #include "f_op/f_op_kankyo_mng.h" #include "d/actor/d_a_obj_carry.h" #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include "f_op/f_op_actor_enemy.h" enum E_yg_RES_File_ID { @@ -136,33 +134,6 @@ static BOOL pl_check(e_yg_class* i_this, f32 i_dist) { return FALSE; } -#if TARGET_PC -static void daE_YG_interp_callback(bool isSimFrame, void* pUserWork) { - e_yg_class* i_this = (e_yg_class*)pUserWork; - fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor; - if (!i_this->mTentacleInterpPrevValid || !i_this->mTentacleInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - for (int s = 0; s < e_yg_class::TENTACLE_STRAND_COUNT; s++) { - cXyz* dst = i_this->mLineMat.getPos(s); - for (int i = 0; i < e_yg_class::TENTACLE_SEGMENT_COUNT; i++) { - int idx = s * e_yg_class::TENTACLE_SEGMENT_COUNT + i; - const cXyz& p0 = i_this->mTentacleInterpPrev[idx]; - const cXyz& p1 = i_this->mTentacleInterpCurr[idx]; - dst[i] = p0 + (p1 - p0) * alpha; - } - } - GXColor color; - color.r = JREG_S(0) + 20; - color.g = JREG_S(1) + 20; - color.b = JREG_S(2) + 20; - color.a = 0xFF; - - i_this->mLineMat.update(10, color, &actor->tevStr); -} -#endif - static int daE_YG_Draw(e_yg_class* i_this) { if (i_this->mDispFlag) { return 1; @@ -190,22 +161,6 @@ static int daE_YG_Draw(e_yg_class* i_this) { i_this->mLineMat.update(10, color, &actor->tevStr); dComIfGd_set3DlineMatDark(&i_this->mLineMat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mTentacleInterpCurrValid) { - memcpy(i_this->mTentacleInterpPrev, i_this->mTentacleInterpCurr, sizeof(i_this->mTentacleInterpCurr)); - i_this->mTentacleInterpPrevValid = true; - } - for (int s = 0; s < e_yg_class::TENTACLE_STRAND_COUNT; s++) { - cXyz* src = i_this->mLineMat.getPos(s); - memcpy(&i_this->mTentacleInterpCurr[s * e_yg_class::TENTACLE_SEGMENT_COUNT], src, - e_yg_class::TENTACLE_SEGMENT_COUNT * sizeof(cXyz)); - } - i_this->mTentacleInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YG_interp_callback, i_this); - } -#endif - dComIfGd_setList(); return 1; @@ -1424,11 +1379,6 @@ static cPhs_Step daE_YG_Create(fopAc_ac_c* actor) { return cPhs_ERROR_e; } -#if TARGET_PC - i_this->mTentacleInterpPrevValid = false; - i_this->mTentacleInterpCurrValid = false; -#endif - if (!hio_set) { i_this->mIsFirstSpawn = 1; hio_set = true; diff --git a/src/d/actor/d_a_e_yh.cpp b/src/d/actor/d_a_e_yh.cpp index fb00a4bab1..55f175d78e 100644 --- a/src/d/actor/d_a_e_yh.cpp +++ b/src/d/actor/d_a_e_yh.cpp @@ -12,10 +12,6 @@ #include "f_op/f_op_actor_enemy.h" #include "f_op/f_op_kankyo_mng.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - class daE_YH_HIO_c : public JORReflexible { public: daE_YH_HIO_c(); @@ -89,22 +85,6 @@ static BOOL leaf_anm_init(e_yh_class* i_this, int param_2, f32 param_3, u8 param return FALSE; } -#if TARGET_PC -static void daE_YH_interp_callback(bool isSimFrame, void* pUserWork) { - e_yh_class* i_this = (e_yh_class*)pUserWork; - if (!i_this->mLineInterpPrevValid || !i_this->mLineInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz* dst = i_this->mLine.getPos(0); - for (int i = 0; i < 12; i++) { - const cXyz& p0 = i_this->mLineInterpPrev[i]; - const cXyz& p1 = i_this->mLineInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - static int daE_YH_Draw(e_yh_class* i_this) { fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; @@ -134,17 +114,6 @@ static int daE_YH_Draw(e_yh_class* i_this) { i_this->mLine.update(12, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mLine); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mLineInterpCurrValid) { - memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, sizeof(i_this->mLineInterpCurr)); - i_this->mLineInterpPrevValid = true; - } - memcpy(i_this->mLineInterpCurr, i_this->mLine.getPos(0), 12 * sizeof(cXyz)); - i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YH_interp_callback, i_this); - } -#endif for (int i = 1; i < 11; i++) { if (i_this->mModels[i] != NULL) { diff --git a/src/d/actor/d_a_horse.cpp b/src/d/actor/d_a_horse.cpp index 72b1fb1e7b..b738460bb8 100644 --- a/src/d/actor/d_a_horse.cpp +++ b/src/d/actor/d_a_horse.cpp @@ -20,23 +20,6 @@ #include #include -#if TARGET_PC -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" - -namespace { -// FRAME INTERP NOTE: Sim tick control point snapshots for interpolation -constexpr int kHorseReinSimMax = 75; -cXyz s_horseReinSimPrev[kHorseReinSimMax]; -cXyz s_horseReinSimCurr[kHorseReinSimMax]; -int s_horseReinSimNumPrev; -int s_horseReinSimNumCurr; -bool s_horseReinSimPrevValid; -bool s_horseReinSimCurrValid; -uint64_t s_horseReinSimRolledSeq; -} // namespace -#endif - #define ANM_HS_BACK_WALK 6 #define ANM_HS_WALK_START 7 #define ANM_HS_EXCITEMENT 8 @@ -3033,24 +3016,6 @@ void daHorse_c::copyReinPos() { for (i = rein->field_0x8[0] - 1; i >= 0; i--, pos_p++) { *pos_p = rein->field_0x0[0][i]; } -#if TARGET_PC - if (field_0x1204 > 0) { - const uint64_t simSeq = dusk::frame_interp::sim_tick_seq(); - if (simSeq != s_horseReinSimRolledSeq) { - s_horseReinSimRolledSeq = simSeq; - if (s_horseReinSimCurrValid && s_horseReinSimNumCurr > 0) { - memcpy(s_horseReinSimPrev, s_horseReinSimCurr, s_horseReinSimNumCurr * sizeof(cXyz)); - s_horseReinSimNumPrev = s_horseReinSimNumCurr; - s_horseReinSimPrevValid = true; - } - } - memcpy(s_horseReinSimCurr, m_reinLine.getPos(0), field_0x1204 * sizeof(cXyz)); - s_horseReinSimNumCurr = field_0x1204; - s_horseReinSimCurrValid = true; - } else { - s_horseReinSimCurrValid = false; - } -#endif } void daHorse_c::setReinPosHandSubstance(int param_0) { @@ -3162,30 +3127,6 @@ void daHorse_c::setReinPosNormalSubstance() { copyReinPos(); } -#if TARGET_PC -void daHorse_c::lerpControlPoints(f32 alpha) { - // FRAME INTERP NOTE: Currently only lerping points for Epona's reins. Need a more global solution. - if (!dusk::frame_interp::is_enabled() || !s_horseReinSimPrevValid || !s_horseReinSimCurrValid) { - return; - } - const int nCurr = s_horseReinSimNumCurr; - const int nPrev = s_horseReinSimNumPrev; - if (nCurr <= 0) { - return; - } - int n = nPrev < nCurr ? nPrev : nCurr; - if (n <= 0 || n > kHorseReinSimMax) { - return; - } - cXyz* dst = m_reinLine.getPos(0); - for (int i = 0; i < n; i++) { - const cXyz& p0 = s_horseReinSimPrev[i]; - const cXyz& p1 = s_horseReinSimCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - void daHorse_c::bgCheck() { if (m_procID != PROC_LARGE_DAMAGE_e) { static DUSK_CONSTEXPR cXyz localCenterPos(0.0f, 100.0f, 0.0f); diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index cc83028b9c..4f175e794f 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -11,9 +11,10 @@ #include "d/d_com_inf_game.h" #if TARGET_PC -#include #include "dusk/dvd_asset.hpp" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" + +#include #include @@ -211,8 +212,8 @@ void daMant_packet_c::draw() { MtxP src25 = model->getAnmMtx(25); Mtx joint_34_scratch; Mtx joint_25_scratch; - MtxP joint_34 = dusk::frame_interp::lookup_replacement(src34, joint_34_scratch) ? joint_34_scratch : src34; - MtxP joint_25 = dusk::frame_interp::lookup_replacement(src25, joint_25_scratch) ? joint_25_scratch : src25; + MtxP joint_34 = dusk::interp::lookup_replacement(src34, joint_34_scratch) ? joint_34_scratch : src34; + MtxP joint_25 = dusk::interp::lookup_replacement(src25, joint_25_scratch) ? joint_25_scratch : src25; cXyz presented_anchor_a; cXyz presented_anchor_b; @@ -231,7 +232,7 @@ void daMant_packet_c::draw() { } } - const f32 step = dusk::frame_interp::get_interpolation_step(); + const f32 step = dusk::interp::get_interpolation_step(); for (int i = 0; i < 169; ++i) { cXyz curr_local; MTXMultVec(curr_frame_inverse, &curr_pos[i], &curr_local); diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp index 6cf1e76024..53dba36b74 100644 --- a/src/d/actor/d_a_mg_rod.cpp +++ b/src/d/actor/d_a_mg_rod.cpp @@ -26,7 +26,6 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" #include "dusk/mods/item.hpp" #include "dusk/settings.h" #include "dusk/version.hpp" @@ -183,25 +182,6 @@ static int Worm_nodeCallBack(J3DJoint* i_joint, int param_1) { return 1; } -#if TARGET_PC -static void dmg_rod_interp_callback(bool isSimFrame, void* pUserWork) { - dmg_rod_class* i_this = (dmg_rod_class*)pUserWork; - if (!i_this->mLineInterpPrevValid || !i_this->mLineInterpCurrValid) { - return; - } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - const int count = i_this->kind == MG_ROD_KIND_LURE ? MG_ROD_LURE_LINE_LEN : MG_ROD_UKI_LINE_LEN; - cXyz* dst = i_this->linemat.getPos(0); - for (int i = 0; i < count; i++) { - const cXyz& p0 = i_this->mLineInterpPrev[i]; - const cXyz& p1 = i_this->mLineInterpCurr[i]; - dst[i] = p0 + (p1 - p0) * alpha; - } - static GXColor l_color = {0xFF, 0xFF, 0x96, 0xFF}; - i_this->linemat.update(count, l_color, &i_this->actor.tevStr); -} -#endif - static int dmg_rod_Draw(dmg_rod_class* i_this) { int unused; fopAc_ac_c* actor = &i_this->actor; @@ -242,18 +222,6 @@ static int dmg_rod_Draw(dmg_rod_class* i_this) { i_this->linemat.update(MG_ROD_LURE_LINE_LEN, l_color, &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->linemat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mLineInterpCurrValid) { - memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, MG_ROD_LURE_LINE_LEN * sizeof(cXyz)); - i_this->mLineInterpPrevValid = true; - } - memcpy(i_this->mLineInterpCurr, i_this->linemat.getPos(0), MG_ROD_LURE_LINE_LEN * sizeof(cXyz)); - i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); - } -#endif - model = i_this->rod_modelMorf->getModel(); g_env_light.setLightTevColorType_MAJI(model, &i_this->actor.tevStr); i_this->rod_modelMorf->entryDL(); @@ -278,18 +246,6 @@ static int dmg_rod_Draw(dmg_rod_class* i_this) { i_this->linemat.update(MG_ROD_UKI_LINE_LEN, l_color, &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->linemat); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mLineInterpCurrValid) { - memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, MG_ROD_UKI_LINE_LEN * sizeof(cXyz)); - i_this->mLineInterpPrevValid = true; - } - memcpy(i_this->mLineInterpCurr, i_this->linemat.getPos(0), MG_ROD_UKI_LINE_LEN * sizeof(cXyz)); - i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); - } -#endif - for (int i = 0; i < 15; i++) { g_env_light.setLightTevColorType_MAJI(i_this->rod_uki_model[i], &actor->tevStr); mDoExt_modelUpdateDL(i_this->rod_uki_model[i]); @@ -6481,11 +6437,6 @@ static int dmg_rod_Create(fopAc_ac_c* i_this) { return cPhs_ERROR_e; } -#if TARGET_PC - rod->mLineInterpPrevValid = false; - rod->mLineInterpCurrValid = false; -#endif - OS_REPORT("//////////////MG_ROD SET 2 !!\n"); if (!hio_set) { rod->HIOInit = TRUE; diff --git a/src/d/actor/d_a_midna.cpp b/src/d/actor/d_a_midna.cpp index a50753cdf0..794dbe1d64 100644 --- a/src/d/actor/d_a_midna.cpp +++ b/src/d/actor/d_a_midna.cpp @@ -14,7 +14,10 @@ #include "d/d_msg_object.h" #include "d/d_s_play.h" #include "d/d_debug_viewer.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif static f32 dummy_lit_3777(int idx, u8 foo) { Vec dummy_vec = {0.0f, 0.0f, 0.0f}; @@ -496,6 +499,7 @@ int daMidna_c::createHeap() { } } + IF_DUSK(mBckHeap[0].reserveBuffer(0x1DC);) JKRReadIdxResource(mBckHeap[0].getBuffer(), mBckHeap[0].getBufferSize(), 0x1DC, dComIfGp_getAnmArchive()); J3DAnmTransform* md_anm = (J3DAnmTransform*)J3DAnmLoaderDataBase::load(mBckHeap[0].getBuffer()); modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, 14); @@ -1106,10 +1110,10 @@ void daMidna_c::setBodyPartMatrix() { mpModel->setAnmMtx(i, mpShadowModel->getAnmMtx(i)); } mpModel->calcWeightEnvelopeMtx(); -#ifdef TARGET_PC +#if TARGET_PC // FRAME INTERP NOTE: Record weight envelopes for Midna here, as they are otherwise missed causing distortion for (u16 i = 0; i < mpModel->getModelData()->getWEvlpMtxNum(); i++) { - dusk::frame_interp::record_final_mtx(mpModel->getWeightAnmMtx(i)); + dusk::interp::record_final_mtx(mpModel->getWeightAnmMtx(i)); } #endif } diff --git a/src/d/actor/d_a_mirror.cpp b/src/d/actor/d_a_mirror.cpp index 486a035590..123279e8af 100644 --- a/src/d/actor/d_a_mirror.cpp +++ b/src/d/actor/d_a_mirror.cpp @@ -13,13 +13,6 @@ #include #include #include "m_Do/m_Do_lib.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - -#ifndef __MWERKS__ -#include "helpers/math.h" -#endif static BOOL daMirror_c_createHeap(fopAc_ac_c* i_this) { return ((daMirror_c*)i_this)->createHeap(); @@ -30,7 +23,7 @@ static DUSK_CONSTEXPR char DUSK_CONST* l_arcName = "Mirror"; static DUSK_CONSTEXPR char DUSK_CONST* l_arcName2 = "MR-Table"; dMirror_packet_c::dMirror_packet_c() { -#ifdef TARGET_PC +#if TARGET_PC GXInitTexObj(&mTexObj, nullptr, 0, 0, static_cast(-1), GX_MAX_TEXWRAPMODE, GX_MAX_TEXWRAPMODE, GX_FALSE); #endif diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 5f4290611f..aabe220578 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -14,34 +14,21 @@ #pragma optimization_level 4 #pragma optimize_for_size off -#include -#include +#include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JAudio2/JASAiCtrl.h" #include "JSystem/JAudio2/JASDriverIF.h" -#include "JSystem/JKernel/JKRExpHeap.h" -#include "Z2AudioLib/Z2Instances.h" #include "d/actor/d_a_movie_player.h" - -#include - +#include "Z2AudioLib/Z2Instances.h" #include "f_op/f_op_overlap_mng.h" +#include + +#if TARGET_PC +#include "dusk/layout.hpp" +#include "dusk/os.h" +#include "helpers/gx_helper.h" #include "JSystem/JAudio2/JASCriticalSection.h" -#if TARGET_PC -#include "helpers/gx_helper.h" -#include "dusk/os.h" -#include "dusk/layout.hpp" -#if MOVIE_SUPPORT -#include "turbojpeg.h" -#endif -#endif - -inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { - return *(BE(s32)*)readBuf->ptr; -} - -#if TARGET_PC // idk what OS_THREAD_ATTR_DETACH does, and it stops OSThreadJoin() // probably the difference doesn't matter since we are using OS threads anyways. #define OS_THREAD_ATTR 0 @@ -49,7 +36,12 @@ inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { #define OS_THREAD_ATTR OS_THREAD_ATTR_DETACH #endif -#if defined(__cplusplus) && !TARGET_PC +inline s32 daMP_NEXT_READ_SIZE(daMP_THPReadBuffer* readBuf) { + return *(BE(s32)*)readBuf->ptr; +} + +#if !TARGET_PC +#if defined(__cplusplus) extern "C" { #endif @@ -217,7 +209,6 @@ static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr) { info->encodeData++; } -#if !TARGET_PC ATTRIBUTE_ALIGN(32) static u8 THPStatistics[1120]; ATTRIBUTE_ALIGN(32) static THPHuffmanTab* Ydchuff; @@ -2587,104 +2578,9 @@ static void __THPHuffDecodeDCTCompV(__REGISTER THPFileInfo* info, THPCoeff* bloc #else // !TARGET_PC static daMP_THPPlayer daMP_ActivePlayer; - -#if MOVIE_SUPPORT -static std::vector FixedJpegData; -static tjhandle JpegDecompressHandle; - -static const std::vector& FixJpeg(const std::span data) { - FixedJpegData.resize(0); - FixedJpegData.reserve(data.size()); - - size_t startOfScanLocation = 0; - for (; startOfScanLocation < data.size() - 1; startOfScanLocation++) { - if (data[startOfScanLocation] == 0xFF && data[startOfScanLocation + 1] == 0xDA) { - goto sosFound; - } - } - - CRASH("Unable to find SOS marker!"); - - sosFound: - - startOfScanLocation += 2; // TODO: Skip entire SOS header? - - size_t endOfImage = data.size() - 1; - for (; endOfImage > startOfScanLocation; endOfImage--) { - if (data[endOfImage] == 0xFF && data[endOfImage + 1] == 0xD9) { - goto eoiFound; - } - } - - CRASH("Unable to find EOI marker!"); - eoiFound: - - // Copy data before SOS - for (size_t i = 0; i < startOfScanLocation; i++) { - FixedJpegData.push_back(data[i]); - } - - // Copy data inside SOS, fixing up lacking of "byte shuffling" - for (size_t i = startOfScanLocation; i < endOfImage; i++) { - u8 value = data[i]; - FixedJpegData.push_back(value); - if (value == 0xFF) { - FixedJpegData.push_back(0x00); - } - } - - // Copy data after SOS. - for (size_t i = endOfImage; i < data.size(); i++) { - FixedJpegData.push_back(data[i]); - } - - return FixedJpegData; -} - -static s32 THPVideoDecode(void* file, size_t fileSize, void* tileY, void* tileU, void* tileV, void*) { - assert(JpegDecompressHandle); - - const auto handle = JpegDecompressHandle; - const auto fixedData = FixJpeg(std::span(static_cast(file), fileSize)); - - auto ret = tj3DecompressHeader(handle, fixedData.data(), fixedData.size()); - if (ret == -1) { - OSReport_Error("Parsing JPEG header failed: %s", tj3GetErrorStr(handle)); - return 1; - } - - if (tj3Get(handle, TJPARAM_JPEGWIDTH) != daMP_ActivePlayer.videoInfo.xSize) { - OSReport_Error("Invalid width in video frame!"); - return 1; - } - - if (tj3Get(handle, TJPARAM_JPEGHEIGHT) != daMP_ActivePlayer.videoInfo.ySize) { - OSReport_Error("Invalid height in video frame!"); - return 1; - } - - ret = tj3Set(handle, TJPARAM_SUBSAMP, TJSAMP_420); - if (ret != 0) { - OSReport_Error("Failed to set subsampling mode: %s", tj3GetErrorStr(handle)); - return 1; - } - - u8* planes[3] = {static_cast(tileY), static_cast(tileU), static_cast(tileV)}; - ret = tj3DecompressToYUVPlanes8(handle, fixedData.data(), fixedData.size(), planes, nullptr); - if (ret != 0) { - OSReport_Error("Image decompression failed: %s", tj3GetErrorStr(handle)); - return 1; - } - - return 0; -} -#else // MOVIE_SUPPORT -static s32 THPVideoDecode(void*, size_t, void*, void*, void*, void*) { - return 1; // Immediate error. -} -#endif #endif +#if !TARGET_PC static BOOL THPInit() { #if !TARGET_PC u8* base; @@ -2712,9 +2608,10 @@ static BOOL THPInit() { return TRUE; } -#if defined(__cplusplus) && !TARGET_PC +#if defined(__cplusplus) } #endif +#endif // !TARGET_PC #if !TARGET_PC // Defined earlier in file. static daMP_THPPlayer daMP_ActivePlayer; @@ -2937,9 +2834,6 @@ static void daMP_VideoDecode(daMP_THPReadBuffer* readBuffer) { case 0: { if ((daMP_ActivePlayer.videoError = THPVideoDecode( tile, -#if TARGET_PC - *tileOffsets, -#endif textureSet->ytexture, textureSet->utexture, textureSet->vtexture, daMP_ActivePlayer.thpWork))) { @@ -3434,26 +3328,19 @@ static void daMP_THPGXYuv2RgbDraw(u8* y_data, u8* u_data, u8* v_data, s16 x, TGXTexObj tobj0; TGXTexObj tobj1; TGXTexObj tobj2; -#if TARGET_PC -#define FMT (GXTexFmt)GX_TF_R8_PC -#else -#define FMT GX_TF_I8 -#endif - GXInitTexObj(&tobj0, y_data, textureWidth, textureHeight, FMT, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObj(&tobj0, y_data, textureWidth, textureHeight, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); GXInitTexObjLOD(&tobj0, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); GXLoadTexObj(&tobj0, GX_TEXMAP0); - GXInitTexObj(&tobj1, u_data, textureWidth >> 1, textureHeight >> 1, FMT, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObj(&tobj1, u_data, textureWidth >> 1, textureHeight >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); GXInitTexObjLOD(&tobj1, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); GXLoadTexObj(&tobj1, GX_TEXMAP1); - GXInitTexObj(&tobj2, v_data, textureWidth >> 1, textureHeight >> 1, FMT, GX_CLAMP, GX_CLAMP, GX_FALSE); + GXInitTexObj(&tobj2, v_data, textureWidth >> 1, textureHeight >> 1, GX_TF_I8, GX_CLAMP, GX_CLAMP, GX_FALSE); GXInitTexObjLOD(&tobj2, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); GXLoadTexObj(&tobj2, GX_TEXMAP2); -#undef FMT - GXBegin(GX_QUADS, GX_VTXFMT7, 4); GXPosition3s16(x, y, 0); GXTexCoord2u16(0, 0); @@ -3774,13 +3661,6 @@ static BOOL daMP_THPPlayerOpen(char const* filename, BOOL onMemory) { } static BOOL daMP_THPPlayerClose() { -#if TARGET_PC && MOVIE_SUPPORT - tj3Destroy(JpegDecompressHandle); - JpegDecompressHandle = nullptr; - - FixedJpegData.clear(); -#endif - if (daMP_ActivePlayer.open && daMP_ActivePlayer.state == 0) { daMP_ActivePlayer.open = 0; DVDClose(&daMP_ActivePlayer.fileInfo); @@ -3832,11 +3712,6 @@ static BOOL daMP_THPPlayerSetBuffer(u8* buffer) { ysize = ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize, 32); uvsize = ALIGN_NEXT(daMP_ActivePlayer.videoInfo.xSize * daMP_ActivePlayer.videoInfo.ySize / 4, 32); -#if TARGET_PC - assert(ysize >= tj3YUVPlaneSize(0, daMP_ActivePlayer.videoInfo.xSize, 0, daMP_ActivePlayer.videoInfo.ySize, TJSAMP_420)); - assert(uvsize >= tj3YUVPlaneSize(1, daMP_ActivePlayer.videoInfo.xSize, 0, daMP_ActivePlayer.videoInfo.ySize, TJSAMP_420)); - assert(uvsize >= tj3YUVPlaneSize(2, daMP_ActivePlayer.videoInfo.xSize, 0, daMP_ActivePlayer.videoInfo.ySize, TJSAMP_420)); -#endif for (i = 0; i < ARRAY_SIZE(daMP_ActivePlayer.textureSet); i++) { daMP_ActivePlayer.textureSet[i].ytexture = ptr; @@ -4329,15 +4204,6 @@ static BOOL daMP_ActivePlayer_Init(char const* moviePath) { daMP_THPPlayerSetBuffer((u8*)daMP_buffer); -#if TARGET_PC && MOVIE_SUPPORT - assert(JpegDecompressHandle == nullptr); - JpegDecompressHandle = tj3Init(TJINIT_DECOMPRESS); - if (JpegDecompressHandle == nullptr) { - OSReport_Error("Failed to create turbojpeg handle: %s", tj3GetErrorStr(nullptr)); - return 0; - } -#endif - if (!daMP_THPPlayerPrepare(0, 0, daMP_audioInfo.sndNumTracks != 1 ? OSGetTick() % daMP_audioInfo.sndNumTracks : 0)) { OSReport("Fail to prepare\n"); #if DEBUG @@ -4373,10 +4239,6 @@ static void daMP_ActivePlayer_Main() { } } -#if TARGET_PC && 0 -#include "imgui.h" -#endif - static void daMP_ActivePlayer_Draw() { #if TARGET_PC u16 width = JUTVideo::getManager()->getFbWidth(); diff --git a/src/d/actor/d_a_npc_gra.cpp b/src/d/actor/d_a_npc_gra.cpp index e5e0d6eed0..6f6293bed7 100644 --- a/src/d/actor/d_a_npc_gra.cpp +++ b/src/d/actor/d_a_npc_gra.cpp @@ -12,10 +12,11 @@ #include "d/actor/d_a_npc_gra.h" #include "d/actor/d_a_tag_gra.h" #include "Z2AudioLib/Z2Instances.h" +#include + #if TARGET_PC #include "mods/items.h" #endif -#include DUSK_GAME_DATA const daNpc_grA_HIOParam daNpc_grA_Param_c::m = { {90.0f, -4.0f, 1.0f, 850.0f, 255.0f, 280.0f, 40.0f, 100.0f, 0.0f, 0.0f, 20.0f, @@ -4022,16 +4023,53 @@ BOOL daNpc_grA_c::talk(void*) { if (r26 && talkProc(NULL, TRUE, NULL)) { if (mFlow.getEventId(&sp8) == 1) { #if TARGET_PC + const u8 originalItem = sp8; u32 itemGiveTag = 0; - if (sp8 == dItemNo_BOMB_IN_BAG_e) { + bool isItemCheck = false; + if (originalItem == dItemNo_BOMB_IN_BAG_e) { const auto itemCheck = - dusk::mods::item_check_commit("goron_reward:F_SP113", sp8, this); + dusk::mods::item_check_commit("goron_reward:F_SP113", originalItem, this); sp8 = itemCheck.itemNo; itemGiveTag = itemCheck.tag; + isItemCheck = true; + } else { + const char* stage = dComIfGp_getStartStageName(); + const bool isAdultGoronShop = (strcmp(stage, "R_SP160") == 0 && originalItem == dItemNo_HYLIA_SHIELD_e) || + (strcmp(stage, "F_SP116") == 0 && originalItem == dItemNo_ARROW_30_e); + if (isAdultGoronShop) { + const auto itemCheck = dusk::mods::item_check_commit( + dusk::mods::item_give_tag_shop(originalItem), originalItem, this); + sp8 = itemCheck.itemNo; + itemGiveTag = itemCheck.tag; + isItemCheck = true; + } } -#endif + + if (isItemCheck && sp8 == dItemNo_NONE_e) { + dusk::mods::item_check_complete({itemGiveTag, dItemNo_NONE_e}, this); + r29 = 1; + if (mType == 0xb) { + field_0x1691 = 1; + } + } else { + field_0x1480 = fopAcM_createItemForPresentDemo( + ¤t.pos, sp8, 0, -1, -1, NULL, NULL, itemGiveTag); + if (field_0x1480 != fpcM_ERROR_PROCESS_ID_e) { + s16 r25 = + dComIfGp_getEventManager().getEventIdx(this, "DEFAULT_GETITEM", 0xff); + dComIfGp_getEvent()->reset(this); + fopAcM_orderChangeEventId(this, r25, 1, -1); + field_0x9ec = 1; + r29 = 1; + mOrderNewEvt = 1; + if (mType == 0xb) { + field_0x1691 = 1; + } + } + } +#else field_0x1480 = fopAcM_createItemForPresentDemo(¤t.pos, sp8, 0, -1, -1, NULL, - NULL IF_DUSK_ARG(itemGiveTag)); + NULL); if (field_0x1480 != fpcM_ERROR_PROCESS_ID_e) { s16 r25 = dComIfGp_getEventManager().getEventIdx(this, "DEFAULT_GETITEM", 0xff); dComIfGp_getEvent()->reset(this); @@ -4043,6 +4081,7 @@ BOOL daNpc_grA_c::talk(void*) { field_0x1691 = 1; } } +#endif } else { if (mType == 0xa && field_0x1486 == 0 && daNpcF_chkEvtBit(0x187)) { dComIfGp_getEvent()->reset(this); diff --git a/src/d/actor/d_a_npc_grc.cpp b/src/d/actor/d_a_npc_grc.cpp index 2435f13c77..77aeb8016d 100644 --- a/src/d/actor/d_a_npc_grc.cpp +++ b/src/d/actor/d_a_npc_grc.cpp @@ -10,6 +10,10 @@ #include "Z2AudioLib/Z2Instances.h" #include +#if TARGET_PC +#include "mods/items.h" +#endif + enum grC_RES_File_ID { /* BCK */ /* 0x05 */ BCK_GRC_F_CHEERFUL = 0x5, @@ -1476,8 +1480,27 @@ BOOL daNpc_grC_c::talk(void* param_1) { rv = TRUE; if (mFlow.getEventId(&i_itemNo) == 1) { - mItemID = fopAcM_createItemForPresentDemo(¤t.pos, i_itemNo, 0, -1, -1, NULL, NULL); +#if TARGET_PC + const bool isCastleTownShop = + strcmp(dComIfGp_getStartStageName(), "R_SP160") == 0 && + (i_itemNo == dItemNo_RED_BOTTLE_e || i_itemNo == dItemNo_OIL_BOTTLE_e); + u32 itemGiveTag = 0; + if (isCastleTownShop) { + const auto itemCheck = dusk::mods::item_check_commit( + dusk::mods::item_give_tag_shop(i_itemNo), i_itemNo, this); + i_itemNo = itemCheck.itemNo; + itemGiveTag = itemCheck.tag; + } + if (isCastleTownShop && i_itemNo == dItemNo_NONE_e) { + dusk::mods::item_check_complete({itemGiveTag, dItemNo_NONE_e}, this); + } else { + mItemID = fopAcM_createItemForPresentDemo( + ¤t.pos, i_itemNo, 0, -1, -1, NULL, NULL, itemGiveTag); + } +#else + mItemID = fopAcM_createItemForPresentDemo(¤t.pos, i_itemNo, 0, -1, -1, NULL, NULL); +#endif if (mItemID != fpcM_ERROR_PROCESS_ID_e) { s16 i_eventID = dComIfGp_getEventManager().getEventIdx(this, "DEFAULT_GETITEM", 0xFF); dComIfGp_getEvent()->reset(this); diff --git a/src/d/actor/d_a_npc_hanjo.cpp b/src/d/actor/d_a_npc_hanjo.cpp index cbd3d9dcf9..2b5284e69d 100644 --- a/src/d/actor/d_a_npc_hanjo.cpp +++ b/src/d/actor/d_a_npc_hanjo.cpp @@ -15,7 +15,9 @@ #include "Z2AudioLib/Z2Instances.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif static DUSK_CONSTEXPR int l_bmdData[4][2] = { {14, 1}, {26, 2}, diff --git a/src/d/actor/d_a_npc_kkri.cpp b/src/d/actor/d_a_npc_kkri.cpp index 755257bff7..9082c9c473 100644 --- a/src/d/actor/d_a_npc_kkri.cpp +++ b/src/d/actor/d_a_npc_kkri.cpp @@ -9,6 +9,10 @@ #include "d/actor/d_a_e_ym.h" #include +#if TARGET_PC +#include "mods/items.h" +#endif + static DUSK_CONSTEXPR int l_bmdData[2][2] = { {35, 1}, {18, 2}, @@ -1183,16 +1187,39 @@ int daNpc_Kkri_c::talk(void*) { if (mItemPartnerId == fpcM_ERROR_PROCESS_ID_e) { #if TARGET_PC u32 itemGiveTag = 0; - if (item_no == dItemNo_OIL_BOTTLE3_e) { - const auto itemCheck = - dusk::mods::item_check_commit("coro_bottle", item_no, this); + const char* itemCheckName = nullptr; + switch (item_no) { + case dItemNo_OIL_BOTTLE3_e: + itemCheckName = ITEM_CHECK_CORO_BOTTLE; + break; + case dItemNo_KANTERA_e: + itemCheckName = ITEM_CHECK_CORO_LANTERN; + break; + case dItemNo_KEY_OF_FILONE_e: + itemCheckName = ITEM_CHECK_CORO_GATE_KEY; + break; + } + + if (itemCheckName != nullptr) { + const auto itemCheck = dusk::mods::item_check_commit( + itemCheckName, item_no, this); item_no = itemCheck.itemNo; itemGiveTag = itemCheck.tag; } + + if (item_no == dItemNo_NONE_e && itemCheckName != nullptr) { + dusk::mods::item_check_complete({itemGiveTag, dItemNo_NONE_e}, this); + field_0xfd5 = 1; + mEvtNo = 1; + evtChange(); + } else { + mItemPartnerId = fopAcM_createItemForPresentDemo( + ¤t.pos, item_no, 0, -1, -1, NULL, NULL, itemGiveTag); + } +#else + mItemPartnerId = fopAcM_createItemForPresentDemo( + ¤t.pos, item_no, 0, -1, -1, NULL, NULL); #endif - mItemPartnerId = fopAcM_createItemForPresentDemo(¤t.pos, item_no, - 0, -1, -1, NULL, - NULL IF_DUSK_ARG(itemGiveTag)); } if (fopAcM_IsExecuting(mItemPartnerId)) { diff --git a/src/d/actor/d_a_npc_ne.cpp b/src/d/actor/d_a_npc_ne.cpp index edce270a2c..530654400f 100644 --- a/src/d/actor/d_a_npc_ne.cpp +++ b/src/d/actor/d_a_npc_ne.cpp @@ -18,9 +18,12 @@ #include "f_op/f_op_kankyo_mng.h" #include "c/c_damagereaction.h" #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static home_path_pnt home_path[38] = { {0, {561.0f, 87.0f, -1110.0f}}, {1, {306.0f, 87.0f, -849.0f}}, @@ -2656,9 +2659,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraFovY = 55.0f; camera->mCamera.SetTrimSize(3); daPy_getPlayerActorClass()->changeOriginalDemo(); -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); // fallthrough case 2: @@ -2687,9 +2688,7 @@ static void demo_camera(npc_ne_class* i_this) { if (i_this->mDemoCounter == 0) { i_this->mCameraCenter1.set(387.0f, 133.0f, -866.0f); i_this->mCameraEye1.set(284.0f, 208.0f, -585.0f); -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } if (i_this->mDemoCounter == 12) { @@ -2726,9 +2725,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraFovY = 45.0f; camera->mCamera.SetTrimSize(3); daPy_getPlayerActorClass()->changeOriginalDemo(); -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); // fallthrough case 11: @@ -2809,14 +2806,10 @@ static void demo_camera(npc_ne_class* i_this) { MtxPosition(&vec, &i_this->mCameraEye2); i_this->mCameraEye2 += player->current.pos; player->changeDemoParam2(2); -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } else if (i_this->mDemoCounter == 120) { player->changeDemoParam2(0); -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } } } @@ -2869,9 +2862,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraCenter1 = _this->current.pos; i_this->mCameraCenter1.y += 20.0f; i_this->mCameraFovY = 55.0f; -#ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } camera->mCamera.Set(i_this->mCameraCenter1, i_this->mCameraEye1, diff --git a/src/d/actor/d_a_npc_saru.cpp b/src/d/actor/d_a_npc_saru.cpp index 7f3f9e1126..4f98b7f6e9 100644 --- a/src/d/actor/d_a_npc_saru.cpp +++ b/src/d/actor/d_a_npc_saru.cpp @@ -11,7 +11,9 @@ #include "d/actor/d_a_e_ym.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif enum saru_TW_RES_File_ID { /* BMDR */ diff --git a/src/d/actor/d_a_npc_shop0.cpp b/src/d/actor/d_a_npc_shop0.cpp index e61ea44f4e..eaa0b1d603 100644 --- a/src/d/actor/d_a_npc_shop0.cpp +++ b/src/d/actor/d_a_npc_shop0.cpp @@ -8,7 +8,9 @@ #include "d/actor/d_a_npc_shop0.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif static int createHeapCallBack(fopAc_ac_c* i_this) { return static_cast(i_this)->createHeap(); diff --git a/src/d/actor/d_a_npc_toby.cpp b/src/d/actor/d_a_npc_toby.cpp index 53a39a3e91..d42787e2a2 100644 --- a/src/d/actor/d_a_npc_toby.cpp +++ b/src/d/actor/d_a_npc_toby.cpp @@ -14,9 +14,12 @@ #include "d/actor/d_a_obj_automata.h" #include "d/d_msg_object.h" #include "d/actor/d_a_obj_scannon.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + DUSK_GAME_DATA const daNpc_Toby_HIOParam daNpc_Toby_Param_c::m = { 160.0f, -3.0f, @@ -1399,7 +1402,7 @@ int daNpc_Toby_c::cutRepairSCannon(int arg0) { old.pos = current.pos; setAngle(cM_deg2s(5.0f * f32(mPath.getArg0()))); mEventTimer = mPath.getArg2(); - dusk::frame_interp::request_presentation_sync(); + IF_DUSK(dusk::interp::request_presentation_sync()); } } else if (!mHide) { mHide = 1; diff --git a/src/d/actor/d_a_npc_yelia.cpp b/src/d/actor/d_a_npc_yelia.cpp index 44b408b35c..d826abd947 100644 --- a/src/d/actor/d_a_npc_yelia.cpp +++ b/src/d/actor/d_a_npc_yelia.cpp @@ -9,7 +9,9 @@ #include "d/actor/d_a_demo_item.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif static DUSK_CONSTEXPR daNpc_GetParam1 l_bmdData[3] = { {3, 1}, diff --git a/src/d/actor/d_a_npc_ykw.cpp b/src/d/actor/d_a_npc_ykw.cpp index 7b84e1a1bb..f79b71b7e2 100644 --- a/src/d/actor/d_a_npc_ykw.cpp +++ b/src/d/actor/d_a_npc_ykw.cpp @@ -20,7 +20,9 @@ #include "m_Do/m_Do_ext.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif #if DEBUG class daNpc_ykW_HIO_c : public mDoHIO_entry_c { diff --git a/src/d/actor/d_a_npc_zra.cpp b/src/d/actor/d_a_npc_zra.cpp index 9d97a3ac2c..f77200c514 100644 --- a/src/d/actor/d_a_npc_zra.cpp +++ b/src/d/actor/d_a_npc_zra.cpp @@ -20,6 +20,10 @@ #include "d/actor/d_a_obj_zraMark.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static NPC_ZRA_HIO_CLASS l_HIO; DUSK_GAME_DATA daNpc_zrA_HIOParam const daNpc_zrA_Param_c::m = { @@ -686,6 +690,69 @@ int daNpc_zrA_c::Execute() { return execute(); } +#if TARGET_PC +void daNpc_zrA_interp_callback(void* pUserWork) { + daNpc_zrA_c* i_this = static_cast(pUserWork); + if (i_this == NULL || i_this->mAnm_p == NULL || i_this->checkHide()) { + return; + } + + J3DModel* model = i_this->mAnm_p->getModel(); + if (model == NULL) { + return; + } + + J3DModelData* model_data = model->getModelData(); + model_data->getMaterialNodePointer(1)->setMaterialAnm(i_this->mpMatAnm); + + if (i_this->mTwilight) { + g_env_light.settingTevStruct(4, &i_this->current.pos, &i_this->tevStr); + } else { + g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr); + } + g_env_light.setLightTevColorType_MAJI(model, &i_this->tevStr); + + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mWaterBtkAnm.entry(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BPK) { + i_this->mWaterBpkAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTP) { + i_this->mBtpAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mBtkAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BRK) { + i_this->mBrkAnm.entry(model_data); + } + + if (!i_this->mHide && !i_this->mTwilight) { + fopAcM_setEffectMtx(i_this, model_data); + } + + model->calcMaterial(); + model->diff(); + + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTP) { + i_this->mBtpAnm.remove(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mBtkAnm.remove(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BRK) { + i_this->mBrkAnm.remove(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BPK) { + i_this->mWaterBpkAnm.remove(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mWaterBtkAnm.remove(model_data); + } +} +#endif + int daNpc_zrA_c::Draw() { BOOL bvar2 = false; J3DModel* model = mAnm_p->getModel(); @@ -737,6 +804,8 @@ int daNpc_zrA_c::Draw() { mAnm_p->entryDL(); } + IF_DUSK(dusk::interp::add_interpolation_callback(&daNpc_zrA_interp_callback, this)); + if (mAnmFlags & ANM_PLAY_BTP) { mBtpAnm.remove(model_data); } diff --git a/src/d/actor/d_a_obj_fchain.cpp b/src/d/actor/d_a_obj_fchain.cpp index b4d473c424..cf2470fc17 100644 --- a/src/d/actor/d_a_obj_fchain.cpp +++ b/src/d/actor/d_a_obj_fchain.cpp @@ -10,10 +10,15 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "SSystem/SComponent/c_math.h" #include "d/d_com_inf_game.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include +#if TARGET_PC +#include "dusk/interp/dual_buffer.h" + +static const int CHAIN_COUNT = 22; +typedef dusk::interp::DualBuffer ChainInterp; +#endif + static char const l_arcName[] = "Fchain"; int daObjFchain_c::createHeap() { @@ -67,10 +72,6 @@ int daObjFchain_c::create() { local_48++; } rv = cPhs_COMPLEATE_e; -#if TARGET_PC - mChainInterpPrevValid = false; - mChainInterpCurrValid = false; -#endif break; } return rv; @@ -295,26 +296,6 @@ void daObjFchain_shape_c::draw() { } } -#if TARGET_PC -static void fchain_interp_callback(bool isSimFrame, void* pUserWork) { - static_cast(pUserWork)->onInterpCallback(); -} - -void daObjFchain_c::onInterpCallback() { - if (!mChainInterpPrevValid || !mChainInterpCurrValid) { - return; - } - - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - - for (int i = 0; i < CHAIN_COUNT; i++) { - const cXyz& p0 = mChainInterpPrev[i]; - const cXyz& p1 = mChainInterpCurr[i]; - field_0x694[i] = p0 + (p1 - p0) * alpha; - } -} -#endif - int daObjFchain_c::draw() { if (field_0x584 != 0) { g_env_light.settingTevStruct(0, ¤t.pos, &tevStr); @@ -324,18 +305,7 @@ int daObjFchain_c::draw() { } dComIfGd_getOpaListDark()->entryImm(&mShape, 0); -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (mChainInterpCurrValid) { - memcpy(mChainInterpPrev, mChainInterpCurr, sizeof(mChainInterpCurr)); - mChainInterpPrevValid = true; - } - - memcpy(mChainInterpCurr, field_0x694, sizeof(mChainInterpCurr)); - mChainInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&fchain_interp_callback, this); - } -#endif + IF_DUSK(dusk::interp::get(this).writeback(field_0x694, CHAIN_COUNT)); } return 1; } diff --git a/src/d/actor/d_a_obj_gra2.cpp b/src/d/actor/d_a_obj_gra2.cpp index a5fa226ee7..97036418fc 100644 --- a/src/d/actor/d_a_obj_gra2.cpp +++ b/src/d/actor/d_a_obj_gra2.cpp @@ -5,14 +5,13 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep -#include "d/actor/d_a_npc4.h" #include "d/actor/d_a_obj_gra2.h" +#include "d/actor/d_a_npc4.h" #include "d/actor/d_a_tag_gra.h" #include "d/d_bg_w.h" #include "d/d_cc_uty.h" -#include "d/d_com_inf_actor.h" #include "d/d_com_inf_game.h" -#include "helpers/string.hpp" +#include "d/d_com_inf_actor.h" #if DEBUG #include "d/d_debug_viewer.h" #endif @@ -21,6 +20,10 @@ #include "Z2AudioLib/Z2Instances.h" #include +#if TARGET_PC +#include "helpers/string.hpp" +#endif + class daObj_GrA_Param_c { public: virtual ~daObj_GrA_Param_c() {} diff --git a/src/d/actor/d_a_obj_item.cpp b/src/d/actor/d_a_obj_item.cpp index fba0ad7d91..cfd7963207 100644 --- a/src/d/actor/d_a_obj_item.cpp +++ b/src/d/actor/d_a_obj_item.cpp @@ -17,7 +17,7 @@ #include "m_Do/m_Do_mtx.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif static f32 Reflect(cXyz* i_vec, cBgS_PolyInfo const& i_polyinfo, f32 i_scale) { @@ -36,7 +36,7 @@ static f32 Reflect(cXyz* i_vec, cBgS_PolyInfo const& i_polyinfo, f32 i_scale) { } #if TARGET_PC -static void d_a_obj_item_interp_callback(bool isSimFrame, void* pUserWork) { +static void d_a_obj_item_interp_callback(void* pUserWork) { daItem_c* item = static_cast(pUserWork); if (item == NULL || item->mpModel == NULL || !item->chkDraw()) { return; @@ -206,7 +206,7 @@ void daItem_c::CreateInit() { initBaseMtx(); animPlay(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); - if (m_itemNo == dItemNo_BOOMERANG_e IF_DUSK(&&!mItemOverridden)) { + if (DUSK_IF_ELSE(mOriginalItemNo, m_itemNo) == dItemNo_BOOMERANG_e) { itemGetNextExecute(); } else if ((m_itemNo == dItemNo_ORANGE_RUPEE_e || m_itemNo == dItemNo_SILVER_RUPEE_e) && mSparkleEmtr.getEmitter() == NULL) @@ -268,7 +268,7 @@ int daItem_c::_daItem_create() { const u32 params = fopAcM_GetParam(this); mOriginalItemNo = params & 0xFF; mItemGiveTag = dusk::mods::item_give_tag_freestanding(daItem_prm::getItemBitNo(this)); - const auto [item, displayItem] = + const auto [item, displayItem, _] = dusk::mods::item_check_resolve(mItemGiveTag, mOriginalItemNo, this); mItemOverridden = item != mOriginalItemNo; setDisplayItemNo(displayItem); @@ -412,7 +412,7 @@ int daItem_c::_daItem_draw() { } #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&d_a_obj_item_interp_callback, this); + dusk::interp::add_interpolation_callback(&d_a_obj_item_interp_callback, this); #endif if (chkDraw()) { @@ -563,7 +563,7 @@ void daItem_c::procWaitGetDemoEvent() { dComIfGp_event_setItemPartnerId(m_item_id); } } else { - if (m_itemNo == dItemNo_BOOMERANG_e IF_DUSK(&&!mItemOverridden)) { + if (DUSK_IF_ELSE(mOriginalItemNo, m_itemNo) == dItemNo_BOOMERANG_e) { fopAcM_orderItemEvent(this, 0, 0); eventInfo.onCondition(dEvtCnd_CANGETITEM_e); return; @@ -787,32 +787,44 @@ void daItem_c::mode_wait() { mAcch.SetGrndNone(); } - switch (m_itemNo) { - case dItemNo_HEART_e: - itemActionForHeart(); - break; - case dItemNo_ARROW_10_e: - case dItemNo_ARROW_20_e: - case dItemNo_ARROW_30_e: - case dItemNo_ARROW_1_e: - case dItemNo_PACHINKO_SHOT_e: - case dItemNo_LIGHT_ARROW_e: - itemActionForArrow(); - break; - case dItemNo_BOOMERANG_e: +#if TARGET_PC + if (mOriginalItemNo == dItemNo_BOOMERANG_e) { itemActionForBoomerang(); - break; - case dItemNo_GREEN_RUPEE_e: - case dItemNo_BLUE_RUPEE_e: - case dItemNo_YELLOW_RUPEE_e: - case dItemNo_RED_RUPEE_e: - case dItemNo_PURPLE_RUPEE_e: - case dItemNo_ORANGE_RUPEE_e: - case dItemNo_SILVER_RUPEE_e: - default: - itemActionForRupee(); - break; + } else { +#endif + switch (m_itemNo) { + case dItemNo_HEART_e: + itemActionForHeart(); + break; + case dItemNo_ARROW_10_e: + case dItemNo_ARROW_20_e: + case dItemNo_ARROW_30_e: + case dItemNo_ARROW_1_e: + case dItemNo_PACHINKO_SHOT_e: + case dItemNo_LIGHT_ARROW_e: + itemActionForArrow(); + break; + case dItemNo_BOOMERANG_e: + // The boomerang check is already handled above, so if we got here, it's guaranteed to be + // an override. Fallthrough to the rupee action +#if !TARGET_PC + itemActionForBoomerang(); + break; +#endif + case dItemNo_GREEN_RUPEE_e: + case dItemNo_BLUE_RUPEE_e: + case dItemNo_YELLOW_RUPEE_e: + case dItemNo_RED_RUPEE_e: + case dItemNo_PURPLE_RUPEE_e: + case dItemNo_ORANGE_RUPEE_e: + case dItemNo_SILVER_RUPEE_e: + default: + itemActionForRupee(); + break; + } +#if TARGET_PC } +#endif if (field_0x9c0 == 0 && mAcch.ChkWaterHit() && mAcch.m_wtr.GetHeight() > current.pos.y) { mode_water_init(); @@ -868,55 +880,64 @@ void daItem_c::itemGetNextExecute() { setFlag(FLAG_INIT_GET_ITEM_e); BOOL haveItem = false; - switch (m_itemNo) { - case dItemNo_HEART_e: - case dItemNo_GREEN_RUPEE_e: - case dItemNo_ARROW_10_e: - case dItemNo_ARROW_20_e: - case dItemNo_ARROW_30_e: - case dItemNo_ARROW_1_e: - procInitSimpleGetDemo(); - itemGet(); - break; - case dItemNo_BLUE_RUPEE_e: - case dItemNo_YELLOW_RUPEE_e: - case dItemNo_RED_RUPEE_e: - case dItemNo_PURPLE_RUPEE_e: - case dItemNo_ORANGE_RUPEE_e: - case dItemNo_SILVER_RUPEE_e: - case dItemNo_PACHINKO_SHOT_e: - if (daPy_getPlayerActorClass()->checkCanoeRide() || - daPy_getPlayerActorClass()->checkHorseRide()) - { - if (checkItemGet(m_itemNo, 1)) { - haveItem = true; - } - procInitSimpleGetDemo(); - itemGet(); - - if (!haveItem) { - dComIfGs_offItemFirstBit(m_itemNo); - } - } else if (!checkItemGet(m_itemNo, 1)) { - procInitGetDemoEvent(); - } else { - procInitSimpleGetDemo(); - itemGet(); - } - break; - case dItemNo_BOOMERANG_e: - procInitGetDemoEvent(); - break; - default: #if TARGET_PC - if (mItemOverridden) { + // Always call demo event for the original boomerang check + if (mOriginalItemNo == dItemNo_BOOMERANG_e) { + procInitGetDemoEvent(); + } else { +#endif + switch (m_itemNo) { + case dItemNo_HEART_e: + case dItemNo_GREEN_RUPEE_e: + case dItemNo_ARROW_10_e: + case dItemNo_ARROW_20_e: + case dItemNo_ARROW_30_e: + case dItemNo_ARROW_1_e: + procInitSimpleGetDemo(); + itemGet(); + break; + case dItemNo_BLUE_RUPEE_e: + case dItemNo_YELLOW_RUPEE_e: + case dItemNo_RED_RUPEE_e: + case dItemNo_PURPLE_RUPEE_e: + case dItemNo_ORANGE_RUPEE_e: + case dItemNo_SILVER_RUPEE_e: + case dItemNo_PACHINKO_SHOT_e: + if (daPy_getPlayerActorClass()->checkCanoeRide() || + daPy_getPlayerActorClass()->checkHorseRide()) + { + if (checkItemGet(m_itemNo, 1)) { + haveItem = true; + } + procInitSimpleGetDemo(); + itemGet(); + + if (!haveItem) { + dComIfGs_offItemFirstBit(m_itemNo); + } + } else if (!checkItemGet(m_itemNo, 1)) { + procInitGetDemoEvent(); + } else { + procInitSimpleGetDemo(); + itemGet(); + } + break; + case dItemNo_BOOMERANG_e: procInitGetDemoEvent(); break; - } + default: +#if TARGET_PC + if (mItemOverridden) { + procInitGetDemoEvent(); + break; + } #endif - // "[daItem_c] Get process not defined[%d]\n" - OS_REPORT_ERROR("[daItem_c]ゲット処理が定義されていません[%d]\n", m_itemNo); + // "[daItem_c] Get process not defined[%d]\n" + OS_REPORT_ERROR("[daItem_c]ゲット処理が定義されていません[%d]\n", m_itemNo); + } +#if TARGET_PC } +#endif fopAcM_onItem(this, mItemBitNo); mCcCyl.SetTgType(0); @@ -935,10 +956,6 @@ void daItem_c::itemGet() { mItemOverridden = m_itemNo != mOriginalItemNo; #endif switch (m_itemNo) { -#if TARGET_PC - case dItemNo_UTAWA_HEART_e: - case dItemNo_KAKERA_HEART_e: -#endif case dItemNo_HEART_e: mDoAud_seStart(Z2SE_HEART_PIECE_GET, NULL, 0, 0); execItemGet(m_itemNo IF_DUSK_ARG(mItemGiveTag) IF_DUSK_ARG(this)); @@ -972,6 +989,13 @@ void daItem_c::itemGet() { execItemGet(m_itemNo IF_DUSK_ARG(mItemGiveTag) IF_DUSK_ARG(this)); break; case dItemNo_BOOMERANG_e: +#if TARGET_PC + if (mItemOverridden) { + mDoAud_seStart(Z2SE_CONSUMP_ITEM_GET, NULL, 0, 0); + execItemGet(m_itemNo, mItemGiveTag, this); + break; + } +#endif break; case dItemNo_ARROW_10_e: case dItemNo_ARROW_20_e: @@ -980,9 +1004,6 @@ void daItem_c::itemGet() { case dItemNo_PACHINKO_SHOT_e: mDoAud_seStart(Z2SE_CONSUMP_ITEM_GET, NULL, 0, 0); execItemGet(m_itemNo IF_DUSK_ARG(mItemGiveTag) IF_DUSK_ARG(this)); -#if TARGET_PC - break; -#endif default: #if TARGET_PC if (mItemOverridden) { @@ -1304,7 +1325,7 @@ void daItem_c::initSpeed(BOOL i_noTypeChk) { u8 type = daItem_prm::getType(this); if (!i_noTypeChk) { - if (type == TYPE_WAIT_e || type == TYPE_BOOM_HIT_e || m_itemNo == dItemNo_BOOMERANG_e) { + if (type == TYPE_WAIT_e || type == TYPE_BOOM_HIT_e || DUSK_IF_ELSE(mOriginalItemNo, m_itemNo) == dItemNo_BOOMERANG_e) { y_speed = 0.0f; speedf = 0.0f; } else if (type == TYPE_LAUNCH_NO_RND_e || type == TYPE_FIXED_PLACE_e) { diff --git a/src/d/actor/d_a_obj_keyhole.cpp b/src/d/actor/d_a_obj_keyhole.cpp index d56f39f40b..8b120f77e3 100644 --- a/src/d/actor/d_a_obj_keyhole.cpp +++ b/src/d/actor/d_a_obj_keyhole.cpp @@ -10,9 +10,6 @@ #include "d/d_s_play.h" #include "d/actor/d_a_player.h" #include "Z2AudioLib/Z2Instances.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif daObj_Keyhole_HIO_c::daObj_Keyhole_HIO_c() { id = -1; @@ -56,21 +53,6 @@ static int daObj_Keyhole_Draw(obj_keyhole_class* i_this) { for (int i = 0; i < 6; i++) { kh_chain_s* chain_s = &i_this->chain_s[i]; for (int j = 0; j < i_this->chain_num; j++) { -#if TARGET_PC - if (dusk::frame_interp::is_enabled() && i_this->mChainInterpPrevValid && i_this->mChainInterpCurrValid) { - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - Mtx mtx; - const f32* p0 = (const f32*)i_this->mChainInterpPrev[i][j]; - const f32* p1 = (const f32*)i_this->mChainInterpCurr[i][j]; - f32* dst = (f32*)mtx; - for (int k = 0; k < 12; k++) { - dst[k] = p0[k] + (p1[k] - p0[k]) * alpha; - } - chain_s->model[j]->setBaseTRMtx(mtx); - g_env_light.setLightTevColorType_MAJI(chain_s->model[j], &actor->tevStr); - mDoExt_modelUpdateDL(chain_s->model[j]); - } else -#endif dComIfGp_entrySimpleModel(chain_s->model[j], fopAcM_GetRoomNo(actor)); } } @@ -388,21 +370,6 @@ static void chain_move(obj_keyhole_class* i_this) { ANGLE_ADD(sp8, TREG_S(0) + 0x3D00); } } - -#if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (i_this->mChainInterpCurrValid) { - memcpy(i_this->mChainInterpPrev, i_this->mChainInterpCurr, sizeof(i_this->mChainInterpCurr)); - i_this->mChainInterpPrevValid = true; - } - for (int i = 0; i < 6; i++) { - for (int j = 0; j < i_this->chain_num; j++) { - MTXCopy(i_this->chain_s[i].model[j]->getBaseTRMtx(), i_this->mChainInterpCurr[i][j]); - } - } - i_this->mChainInterpCurrValid = true; - } -#endif } static void open(obj_keyhole_class* i_this) { @@ -783,11 +750,6 @@ static int daObj_Keyhole_Create(fopAc_ac_c* a_this) { return cPhs_ERROR_e; } -#if TARGET_PC - i_this->mChainInterpPrevValid = false; - i_this->mChainInterpCurrValid = false; -#endif - OS_REPORT("//////////////OBJ_KEYHOLE SET 2 !!\n"); if (i_this->arg0 == 3) { diff --git a/src/d/actor/d_a_obj_klift00.cpp b/src/d/actor/d_a_obj_klift00.cpp index fbccb64edb..8a0eb5e38e 100644 --- a/src/d/actor/d_a_obj_klift00.cpp +++ b/src/d/actor/d_a_obj_klift00.cpp @@ -11,8 +11,20 @@ #include "d/d_bg_w.h" #include "d/d_cc_uty.h" #include "d/d_com_inf_game.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" + +#if TARGET_PC +#include "dusk/interp/dual_buffer.h" +#include "dusk/interp/frame_interpolation.h" + +static const int CHAIN_INTERP_MAX = 64; + +namespace { +struct KLiftInterp { + cXyz draw[CHAIN_INTERP_MAX]; + dusk::interp::DualBuffer chain{draw}; +}; +} // namespace +#endif struct daObjKLift00_HIO_c : public mDoHIO_entry_c { daObjKLift00_HIO_c(); @@ -297,11 +309,6 @@ int daObjKLift00_c::Create() { if(getLock()) mStopSwingingFrames = 5; -#if TARGET_PC - mChainInterpPrevValid = false; - mChainInterpCurrValid = false; -#endif - return 1; } @@ -444,23 +451,20 @@ int daObjKLift00_c::Execute(Mtx** i_mtx) { } #if TARGET_PC -static void klift00_interp_callback(bool isSimFrame, void* pUserWork) { - static_cast(pUserWork)->onInterpCallback(); +static void klift00_interp_post(void* pUserWork) { + static_cast(pUserWork)->onInterpPresentation(); } -void daObjKLift00_c::onInterpCallback() { - if (!mChainInterpPrevValid || !mChainInterpCurrValid) { - return; - } - - const f32 alpha = dusk::frame_interp::get_interpolation_step(); - cXyz savedPositions[64]; +void daObjKLift00_c::onInterpPresentation() { + cXyz savedPositions[CHAIN_INTERP_MAX]; for (int i = 0; i < mNumChains; i++) { savedPositions[i] = mChainPositions[i].mCurrentPos; - const cXyz& p0 = mChainInterpPrev[i]; - const cXyz& p1 = mChainInterpCurr[i]; - mChainPositions[i].mCurrentPos = p0 + (p1 - p0) * alpha; + } + + auto& interp = dusk::interp::get(this); + for (int i = 0; i < mNumChains; i++) { + mChainPositions[i].mCurrentPos = interp.draw[i]; } setMtx(); @@ -493,18 +497,12 @@ int daObjKLift00_c::Draw() { dComIfGd_setList(); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - if (mChainInterpCurrValid) { - memcpy(mChainInterpPrev, mChainInterpCurr, mNumChains * sizeof(cXyz)); - mChainInterpPrevValid = true; - } - + if (dusk::interp::is_enabled() && mNumChains > 0 && mNumChains <= CHAIN_INTERP_MAX) { + cXyz curr[CHAIN_INTERP_MAX]; for (int i = 0; i < mNumChains; i++) { - mChainInterpCurr[i] = mChainPositions[i].mCurrentPos; + curr[i] = mChainPositions[i].mCurrentPos; } - - mChainInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&klift00_interp_callback, this); + dusk::interp::get(this).chain.capture_and_schedule(curr, mNumChains, &klift00_interp_post, this); } #endif diff --git a/src/d/actor/d_a_obj_life_container.cpp b/src/d/actor/d_a_obj_life_container.cpp index b2eb30167a..85553cda28 100644 --- a/src/d/actor/d_a_obj_life_container.cpp +++ b/src/d/actor/d_a_obj_life_container.cpp @@ -99,6 +99,15 @@ int daObjLife_c::Create() { mRotateSpeed = 7000; #if TARGET_PC + // Restore speeds that were skipped if created from a boss with create instead of fastCreate + auto bossItemSpeeds = dusk::mods::get_boss_item_actor_speeds(); + if (bossItemSpeeds.f != 0.f || bossItemSpeeds.y != 0.f) { + mOverrideHover = false; + speedF = bossItemSpeeds.f; + speed.y = bossItemSpeeds.y; + dusk::mods::set_boss_item_actor_speeds(0.f, 0.f); + } + if (mOverrideHover) { fopAcM_SetGravity(this, 0.0f); mRotateSpeed = 550; @@ -153,20 +162,20 @@ int daObjLife_c::create() { if (mItemGiveOriginalNo == dItemNo_NONE_e) { mOriginalItemNo = parameterItemNo; mItemGiveTag = dusk::mods::item_give_tag_freestanding(getSaveBitNo()); - const auto [item, displayItem] = + const auto [item, displayItem, was_resolved] = dusk::mods::item_check_resolve(mItemGiveTag, mOriginalItemNo, this); setDisplayItemNo(displayItem); - mItemOverridden = item != mOriginalItemNo; + mItemOverridden = was_resolved; if (mItemOverridden) { fopAcM_SetParam(this, (params & 0xFFFFFF00) | item); } } else if (mGoldenWolfItem) { mOriginalItemNo = mItemGiveOriginalNo; mItemGiveTag = dusk::mods::item_give_tag_golden_wolf(static_cast(field_0x938)); - const auto [item, displayItem] = + const auto [item, displayItem, was_resolved] = dusk::mods::item_check_resolve(mItemGiveTag, mOriginalItemNo, this); setDisplayItemNo(displayItem); - mItemOverridden = item != mOriginalItemNo; + mItemOverridden = was_resolved; if (item != parameterItemNo) { fopAcM_SetParam(this, (params & 0xFFFFFF00) | item); } diff --git a/src/d/actor/d_a_obj_lv4chandelier.cpp b/src/d/actor/d_a_obj_lv4chandelier.cpp index 7847b37358..56f9aa93c1 100644 --- a/src/d/actor/d_a_obj_lv4chandelier.cpp +++ b/src/d/actor/d_a_obj_lv4chandelier.cpp @@ -12,10 +12,6 @@ #include "d/d_cc_d.h" #include "d/d_cc_uty.h" -#ifndef __MWERKS__ -#include "helpers/math.h" -#endif - #if DEBUG class daObjLv4Chan_HIO_c : public mDoHIO_entry_c { public: diff --git a/src/d/actor/d_a_obj_lv8Lift.cpp b/src/d/actor/d_a_obj_lv8Lift.cpp index 9ac8206f6b..b77e098487 100644 --- a/src/d/actor/d_a_obj_lv8Lift.cpp +++ b/src/d/actor/d_a_obj_lv8Lift.cpp @@ -11,7 +11,7 @@ #include "d/d_bg_w.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif daL8Lift_HIO_c::daL8Lift_HIO_c() { @@ -385,7 +385,7 @@ void daL8Lift_c::setNextPoint() { } #if TARGET_PC -void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork) { +void daL8Lift_interp_callback(void* pUserWork) { daL8Lift_c* lift = static_cast(pUserWork); if (lift == NULL || lift->mpModel == NULL) { return; @@ -419,7 +419,7 @@ void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork) { int daL8Lift_c::Draw() { #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daL8Lift_interp_callback, this); + dusk::interp::add_interpolation_callback(&daL8Lift_interp_callback, this); #endif g_env_light.settingTevStruct(16, ¤t.pos, &tevStr); diff --git a/src/d/actor/d_a_obj_lv8OptiLift.cpp b/src/d/actor/d_a_obj_lv8OptiLift.cpp index e367b89b36..b63b0979f8 100644 --- a/src/d/actor/d_a_obj_lv8OptiLift.cpp +++ b/src/d/actor/d_a_obj_lv8OptiLift.cpp @@ -12,7 +12,7 @@ #include "d/d_path.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif daOptiLift_HIO_c::daOptiLift_HIO_c() { @@ -417,7 +417,7 @@ void daOptiLift_c::setNextPoint() { } #if TARGET_PC -static void daOptiLift_interp_callback(bool isSimFrame, void* pUserWork) { +static void daOptiLift_interp_callback(void* pUserWork) { daOptiLift_c* lift = static_cast(pUserWork); if (lift == NULL || lift->mpModel == NULL) { return; @@ -451,7 +451,7 @@ static void daOptiLift_interp_callback(bool isSimFrame, void* pUserWork) { int daOptiLift_c::Draw() { #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daOptiLift_interp_callback, this); + dusk::interp::add_interpolation_callback(&daOptiLift_interp_callback, this); #endif g_env_light.settingTevStruct(0x10, ¤t.pos, &tevStr); diff --git a/src/d/actor/d_a_obj_master_sword.cpp b/src/d/actor/d_a_obj_master_sword.cpp index 36fa786808..444b7356e3 100644 --- a/src/d/actor/d_a_obj_master_sword.cpp +++ b/src/d/actor/d_a_obj_master_sword.cpp @@ -11,9 +11,10 @@ #include "d/d_meter2_info.h" #if TARGET_PC -#include "d/d_item.h" #include "dusk/mods/item.hpp" #include "mods/items.h" + +#include "d/d_item.h" #endif DUSK_GAME_DATA daObjMasterSword_Attr_c const daObjMasterSword_c::mAttr = {1.0f}; @@ -151,11 +152,7 @@ void daObjMasterSword_c::create_init() { int daObjMasterSword_c::create() { fopAcM_ct(this, daObjMasterSword_c); -#if TARGET_PC - if (dComIfGs_isEventBit(dSv_event_flag_c::F_0264)) { -#else if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[getFlagNo()])) { -#endif return cPhs_ERROR_e; } @@ -199,7 +196,7 @@ int daObjMasterSword_c::execute() { #if TARGET_PC const auto masterSword = dusk::mods::item_check_commit( ITEM_CHECK_MASTER_SWORD, dItemNo_MASTER_SWORD_e, this); - if (masterSword.itemNo == dItemNo_MASTER_SWORD_e) { + if (!masterSword.was_resolved) { dComIfGs_onItemFirstBit(dItemNo_MASTER_SWORD_e); dMeter2Info_setSword(dItemNo_MASTER_SWORD_e, false); dComIfGs_setSelectEquipSword(dItemNo_MASTER_SWORD_e); @@ -214,7 +211,7 @@ int daObjMasterSword_c::execute() { const auto shadowCrystal = dusk::mods::item_check_commit( ITEM_CHECK_SHADOW_CRYSTAL, dItemNo_SHADOW_CRYSTAL_e, this); - if (shadowCrystal.itemNo == dItemNo_SHADOW_CRYSTAL_e) { + if (!shadowCrystal.was_resolved) { execItemGet(shadowCrystal.itemNo, shadowCrystal.tag, this); } else if (shadowCrystal.itemNo == dItemNo_NONE_e) { dusk::mods::item_check_complete(shadowCrystal, this); @@ -222,15 +219,14 @@ int daObjMasterSword_c::execute() { dusk::mods::item_check_enqueue(shadowCrystal, dusk::mods::ItemGiveMode::Demo); } - dComIfGs_onEventBit(dSv_event_flag_c::F_0264); #else dComIfGs_onItemFirstBit(dItemNo_MASTER_SWORD_e); dMeter2Info_setSword(dItemNo_MASTER_SWORD_e, false); dComIfGs_setSelectEquipSword(dItemNo_MASTER_SWORD_e); dComIfGp_setItemLifeCount(dComIfGs_getMaxLife(), 0); - dComIfGs_onEventBit(dSv_event_flag_c::saveBitLabels[getFlagNo()]); #endif + dComIfGs_onEventBit(dSv_event_flag_c::saveBitLabels[getFlagNo()]); fopAcM_delete(this); } diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp index f8493ec385..fece4d9773 100644 --- a/src/d/actor/d_a_obj_sekizoa.cpp +++ b/src/d/actor/d_a_obj_sekizoa.cpp @@ -8,11 +8,12 @@ #include "d/actor/d_a_tag_kmsg.h" #include #include - -#include "helpers/string.hpp" #include "f_op/f_op_actor_mng.h" #include "f_op/f_op_msg.h" +#if TARGET_PC +#include "helpers/string.hpp" +#endif static DUSK_CONSTEXPR daNpc_GetParam1 l_bmdData[9] = { {36, 1}, {36, 1}, {35, 1}, {37, 1}, {38, 1}, {3, 2}, {3, 2}, {4, 2}, {5, 2}, diff --git a/src/d/actor/d_a_obj_smallkey.cpp b/src/d/actor/d_a_obj_smallkey.cpp index 6914cee5f0..1fd6025ce6 100644 --- a/src/d/actor/d_a_obj_smallkey.cpp +++ b/src/d/actor/d_a_obj_smallkey.cpp @@ -157,7 +157,7 @@ int daKey_c::create() { #if TARGET_PC mItemGiveTag = dusk::mods::item_give_tag_freestanding(getSaveBitNo()); - const auto [item, displayItem] = + const auto [item, displayItem, _] = dusk::mods::item_check_resolve(mItemGiveTag, dItemNo_SMALL_KEY_e, this); m_itemNo = item; if (m_itemNo == dItemNo_NONE_e) { diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index 48ad37e2ec..e10f7e490c 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -224,6 +224,12 @@ daPy_anmHeap_c::~daPy_anmHeap_c() { if (mAnimeHeap != NULL) { mDoExt_destroySolidHeap(mAnimeHeap); } +#if TARGET_PC + freeTempBuffers(); + if (mOwnedBuffer != NULL) { + JKRFreeToSysHeap(mOwnedBuffer); + } +#endif } void daPy_anmHeap_c::initData() { @@ -237,6 +243,56 @@ void* daPy_anmHeap_c::mallocBuffer() { return mBuffer; } +#if TARGET_PC +constexpr u32 kAlignment = 0x20; + +void daPy_anmHeap_c::reserveBuffer(u16 i_resId) { + // Ensure mBuffer is large enough to hold the resource + u32 size = daPy_getAnmResourceSize(i_resId, mBufferSize); + if (size <= mBufferSize) { + return; + } + + // If not, replace it with a new buffer allocated from the system heap. Callers still copy + // archive data in on every load: setAnmTransform bswaps key tables in place, so we can't point + // it at the archive's cached copy directly. + u8* buffer = static_cast(JKRAllocFromSysHeap(size, kAlignment)); + JUT_ASSERT(__LINE__, buffer != NULL); + if (mOwnedBuffer != NULL) { + JKRFreeToSysHeap(mOwnedBuffer); + } + mOwnedBuffer = buffer; // Mark it as owned so we release it later + mBuffer = buffer; + mBufferSize = size; +} + +void* daPy_anmHeap_c::allocTempBuffer(u16 i_resId, u32* io_size) { + // Check if the resource can fit in io_size + u32 size = daPy_getAnmResourceSize(i_resId, *io_size); + if (size <= *io_size) { + return JKR_NEW_ARRAY_ARGS(u8, *io_size, kAlignment); + } + + // If not, allocate a new temp buffer from the system heap, plus kAlignment extra bytes. + // We stash a pointer to the next buffer at the beginning, forming a chain so we can free + // them all later. + void** temp = static_cast(JKRAllocFromSysHeap(kAlignment + size, kAlignment)); + JUT_ASSERT(__LINE__, temp != NULL); + *temp = mTempBuffers; + mTempBuffers = temp; + *io_size = size; + return reinterpret_cast(temp) + kAlignment; +} + +void daPy_anmHeap_c::freeTempBuffers() { + while (mTempBuffers != NULL) { + void** temp = mTempBuffers; + mTempBuffers = static_cast(*temp); + JKRFreeToSysHeap(temp); + } +} +#endif + void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType, const char* name) { u32 size; @@ -310,6 +366,7 @@ void* daPy_anmHeap_c::loadData(u16 i_resId) { }; if (mArcNo == 0xFFFF) { + IF_DUSK(reserveBuffer(i_resId);) JKRReadIdxResource(mBuffer, mBufferSize, i_resId, dComIfGp_getAnmArchive()); #if DEBUG daPy_aramBufferCheck(mBuffer, mBufferSize); @@ -363,35 +420,12 @@ void* daPy_anmHeap_c::loadDataDemoRID(u16 i_resID, u16 i_arcNo) { JKRHeap* daPy_anmHeap_c::setAnimeHeap() { mAnimeHeap->freeAll(); + IF_DUSK(freeTempBuffers();) return mDoExt_setCurrentHeap(mAnimeHeap); } #if !PLATFORM_WII -#if TARGET_PC -#include "dusk/dvd_asset.hpp" -using GameVersion = dusk::version::GameVersion; -static const u8* l_sightDL_get() { - static u8 buf[0x89]; - static bool _ = ( - dusk::LoadDolAsset( - buf, - { - {GameVersion::GcnUsa, 0x803BA0C0}, - {GameVersion::GcnPal, 0x803BBDA0}, - {GameVersion::GcnJpn, 0x803B4220}, - {GameVersion::WiiUsaRev0, 0x803F63C0}, - {GameVersion::WiiUsa, 0x803E1640}, - {GameVersion::WiiPal, 0x803E23A0}, - {GameVersion::WiiJpn, 0x803DF600} - }, - 0x89 - ), - true - ); - return buf; -} -#define l_sightDL (l_sightDL_get()) -#else +#if !TARGET_PC #include "assets/l_sightDL__d_a_player.h" #endif @@ -435,7 +469,33 @@ void daPy_sightPacket_c::draw() { GXLoadPosMtxImm(mProjMtx, GX_PNMTX0); GXSetCurrentMtx(0); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); +#if TARGET_PC + GXSetNumTexGens(1); + GXSetNumTevStages(1); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GXSetCullMode(GX_CULL_NONE); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C1, GX_CC_C0, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_A0, GX_CA_TEXA, GX_CA_ZERO); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetZMode(GX_FALSE, GX_LEQUAL, GX_FALSE); + GXSetColorUpdate(GX_TRUE); + GXSetAlphaUpdate(GX_FALSE); + GXSetDither(GX_TRUE); + GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4); + GXPosition3u8(1, 1, 0); + GXTexCoord2u8(1, 1); + GXPosition3u8(255, 1, 0); + GXTexCoord2u8(0, 1); + GXPosition3u8(1, 255, 0); + GXTexCoord2u8(1, 0); + GXPosition3u8(255, 255, 0); + GXTexCoord2u8(0, 0); + GXEnd(); +#else GXCallDisplayList(l_sightDL, 0x80); +#endif J3DShape::resetVcdVatCache(); } diff --git a/src/d/actor/d_a_shop_item.cpp b/src/d/actor/d_a_shop_item.cpp index a7a159ab1c..edd16b9ecf 100644 --- a/src/d/actor/d_a_shop_item.cpp +++ b/src/d/actor/d_a_shop_item.cpp @@ -106,8 +106,9 @@ const char* daShopItem_c::getShopArcname() { if (m_itemNo != dItemNo_NONE_e && mItemGiveOriginalNo == dItemNo_NONE_e) { mItemGiveOriginalNo = m_itemNo; mItemGiveTag = dusk::mods::item_give_tag_shop(mItemGiveOriginalNo); - const auto [_, displayItem] = + const auto [_, displayItem, was_resolved] = dusk::mods::item_check_resolve(mItemGiveTag, mItemGiveOriginalNo, this); + setDisplayItemNo(displayItem); mItemOverridden = displayItem != mItemGiveOriginalNo; if (mItemOverridden) { mOverrideData = mData[mShopItemID]; diff --git a/src/d/actor/d_a_tag_evt.cpp b/src/d/actor/d_a_tag_evt.cpp index 780fc1d38c..92bc7b2494 100644 --- a/src/d/actor/d_a_tag_evt.cpp +++ b/src/d/actor/d_a_tag_evt.cpp @@ -8,7 +8,9 @@ #include "f_op/f_op_actor_mng.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif static DUSK_CONST char* l_evtNameList[] = { NULL, diff --git a/src/d/actor/d_a_tag_msg.cpp b/src/d/actor/d_a_tag_msg.cpp index e023319a9f..2f5ccd2761 100644 --- a/src/d/actor/d_a_tag_msg.cpp +++ b/src/d/actor/d_a_tag_msg.cpp @@ -11,7 +11,9 @@ #include "d/d_debug_viewer.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif static int createHeapCallBack(fopAc_ac_c* i_this) { daTag_Msg_c* msg = (daTag_Msg_c*)i_this; diff --git a/src/d/actor/d_a_title.cpp b/src/d/actor/d_a_title.cpp index b9edd72fa1..0d011f9213 100644 --- a/src/d/actor/d_a_title.cpp +++ b/src/d/actor/d_a_title.cpp @@ -11,7 +11,6 @@ #include "d/d_pane_class_alpha.h" #include "d/d_s_logo.h" #include "d/d_s_play.h" -#include "dusk/version.hpp" #include "f_op/f_op_msg_mng.h" #include "f_op/f_op_overlap_mng.h" #include "f_op/f_op_scene_mng.h" @@ -19,9 +18,9 @@ #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_graphic.h" -#ifdef TARGET_PC -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "dusk/version.hpp" #endif class daTit_HIO_c : public JORReflexible { @@ -170,7 +169,7 @@ int daTitle_c::Execute() { } #ifdef TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { #endif dMenu_Collect3D_c::setViewPortOffsetY(0.0f); #ifdef TARGET_PC @@ -353,11 +352,7 @@ void daTitle_c::fastLogoDispInit() { mWaitTimer = 30; mProcID = 5; -#ifdef TARGET_PC - if (dusk::frame_interp::is_enabled()) { - dusk::frame_interp::request_presentation_sync(); - } -#endif + IF_DUSK(dusk::interp::request_presentation_sync()); } void daTitle_c::fastLogoDisp() { diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 9e3d77efd0..e42cc7ded0 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -5,7 +5,9 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "SSystem/SComponent/c_counter.h" -#include "dusk/frame_interpolation.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif const u16 l_J_Ohana00_64TEX__width = 63; const u16 l_J_Ohana00_64TEX__height = 63; @@ -1163,16 +1165,12 @@ void dFlower_packet_c::draw() { GXSetChanAmbColor(GX_COLOR0A0, sp64); if (!cLib_checkBit(sp44->m_state, 4) && !cLib_checkBit(sp44->m_state, 0x40)) { -#ifdef TARGET_PC - Mtx flower_mtx; - if (dusk::frame_interp::lookup_replacement(&sp44->m_modelMtx, flower_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx); - GXLoadPosMtxImm(flower_mtx, 0); - } else +#if TARGET_PC + Mtx flowerMtx; + GXLoadPosMtxImm(get_model_mtx(sp44->m_modelMtx, flowerMtx), 0); +#else + GXLoadPosMtxImm(sp44->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(sp44->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); #if TARGET_PC @@ -1322,16 +1320,12 @@ void dFlower_packet_c::draw() { sp30++; if (!cLib_checkBit(sp34->m_state, 4) && cLib_checkBit(sp34->m_state, 0x40)) { -#ifdef TARGET_PC - Mtx flower_mtx; - if (dusk::frame_interp::lookup_replacement(&sp34->m_modelMtx, flower_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx); - GXLoadPosMtxImm(flower_mtx, 0); - } else +#if TARGET_PC + Mtx flowerMtx; + GXLoadPosMtxImm(get_model_mtx(sp34->m_modelMtx, flowerMtx), 0); +#else + GXLoadPosMtxImm(sp34->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(sp34->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); #if TARGET_PC GXLoadTexObj(&mTexObj_l_J_Ohana01_64128_0419TEX, GX_TEXMAP0); @@ -1461,9 +1455,13 @@ void dFlower_packet_c::update() { mDoMtx_stack_c::copy(temp_r28); mDoMtx_stack_c::scaleM(temp_f31, temp_f31, temp_f31); +#if TARGET_PC + cMtx_copy(temp_r28, data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), temp_r28, data_p->m_modelMtx); +#endif #ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(temp_r28, data_p->m_modelMtx); + dusk::interp::record_final_mtx(temp_r28, data_p->m_modelMtx); #endif } } diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 6c7a898c56..fd911083f4 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -11,15 +11,10 @@ #include "d/d_camera.h" #include "f_op/f_op_camera_mng.h" -#include "dusk/frame_interpolation.h" - -const u16 l_M_Hijiki00TEX__width = 31; -const u16 l_M_Hijiki00TEX__height = 31; -const u16 l_M_kusa05_RGBATEX__width = 31; -const u16 l_M_kusa05_RGBATEX__height = 31; - #if TARGET_PC #include "dusk/dvd_asset.hpp" +#include "dusk/interp/frame_interpolation.h" + using GameVersion = dusk::version::GameVersion; template @@ -61,6 +56,11 @@ DEFINE_GRASS_ASSET(l_M_Hijiki00TEX, u8, 0x800, { #include "assets/l_M_Hijiki00TEX.h" // ALIGN 32 #endif +const u16 l_M_Hijiki00TEX__width = 31; +const u16 l_M_Hijiki00TEX__height = 31; +const u16 l_M_kusa05_RGBATEX__width = 31; +const u16 l_M_kusa05_RGBATEX__height = 31; + static u8 l_pos[960] = { 0x3F, 0x4A, 0x56, 0xEF, 0xC2, 0x20, 0x00, 0x00, 0x41, 0xFB, 0x17, 0xE4, 0x41, 0xAA, 0xBB, 0xEA, 0xC2, 0x20, 0x00, 0x00, 0xC1, 0xB7, 0x03, 0x7A, 0x42, 0x55, 0x8D, 0x6F, 0x43, 0x13, 0x16, 0x3F, @@ -608,11 +608,12 @@ dGrass_packet_c::dGrass_packet_c() { #if TARGET_PC static MtxP get_model_mtx(Mtx modelMtx, Mtx storage) { - if (dusk::frame_interp::lookup_replacement(modelMtx, storage)) { + if (dusk::interp::lookup_replacement(modelMtx, storage)) { cMtx_concat(j3dSys.getViewMtx(), storage, storage); - return storage; + } else { + cMtx_concat(j3dSys.getViewMtx(), modelMtx, storage); } - return modelMtx; + return storage; } static void transform_positions( @@ -1193,16 +1194,12 @@ void dGrass_packet_c::draw() { GXSetChanAmbColor(GX_COLOR0A0, sp38); if (!cLib_checkBit(var_r29->field_0x01, 2)) { -#ifdef TARGET_PC - Mtx grass_mtx; - if (dusk::frame_interp::lookup_replacement(reinterpret_cast(&var_r29->m_modelMtx), grass_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), grass_mtx, grass_mtx); - GXLoadPosMtxImm(grass_mtx, 0); - } else +#if TARGET_PC + Mtx grassMtx; + GXLoadPosMtxImm(get_model_mtx(var_r29->m_modelMtx, grassMtx), 0); +#else + GXLoadPosMtxImm(var_r29->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(var_r29->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); if (var_r29->field_0x05 <= 3 || var_r29->field_0x05 >= 10) { if (var_r29->field_0x02 < -1) { @@ -1445,7 +1442,11 @@ void dGrass_packet_c::update() { } } +#if TARGET_PC + cMtx_copy(mDoMtx_stack_c::get(), data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), data_p->m_modelMtx); +#endif } else { mDoMtx_stack_c::transS(data_p->m_pos.x, data_p->m_pos.y, data_p->m_pos.z); mDoMtx_stack_c::YrotM(i * 3535); @@ -1456,11 +1457,13 @@ void dGrass_packet_c::update() { f32 scale = ((((s16)data_p->m_pos.x * 3535) & 0xFFF) / 4096.0f) * 0.3f + 0.7f; mDoMtx_stack_c::scaleM(scale, scale, scale); +#if TARGET_PC + cMtx_copy(mDoMtx_stack_c::get(), data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), data_p->m_modelMtx); - } -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), data_p->m_modelMtx); #endif + } + IF_DUSK(dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), data_p->m_modelMtx)); } } data_p++; diff --git a/src/d/d_bg_parts.cpp b/src/d/d_bg_parts.cpp index 07c91f8807..50eb634c25 100644 --- a/src/d/d_bg_parts.cpp +++ b/src/d/d_bg_parts.cpp @@ -8,7 +8,9 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif void dBgp_c::material_c::draw() { material_c* material = this; diff --git a/src/d/d_bg_s.cpp b/src/d/d_bg_s.cpp index 51811d9538..23f87e4e4c 100644 --- a/src/d/d_bg_s.cpp +++ b/src/d/d_bg_s.cpp @@ -11,12 +11,14 @@ #include "d/d_com_inf_game.h" #include "f_op/f_op_actor_mng.h" +#if TARGET_PC || DEBUG #include "d/d_debug_viewer.h" #include "d/d_bg_s_capt_poly.h" +#endif #if TARGET_PC -#include "helpers/offset_ptr.h" #include "dusk/settings.h" +#include "helpers/offset_ptr.h" #endif #if DEBUG @@ -30,7 +32,6 @@ int g_sph_counter; int g_capt_poly_counter; #endif - void dBgS_HIO::genMessage(JORMContext* mctx) { #if DEBUG mctx->genLabel("zelda地形チェック", 0); diff --git a/src/d/d_bright_check.cpp b/src/d/d_bright_check.cpp index b9ea46e58e..17c6f77267 100644 --- a/src/d/d_bright_check.cpp +++ b/src/d/d_bright_check.cpp @@ -11,15 +11,14 @@ #include "d/d_msg_string.h" #include "m_Do/m_Do_controller_pad.h" -#ifdef TARGET_PC -#include +#if TARGET_PC +#include "dusk/autosave.h" #include "dusk/game_mode.hpp" #include "dusk/imgui/ImGuiConsole.hpp" #include "dusk/livesplit.h" #include "dusk/speedrun.h" -#endif - #include "dusk/version.hpp" +#endif dBrightCheck_c::dBrightCheck_c(JKRArchive* i_archive) { mArchive = i_archive; diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index b38a336e02..feb7148cc0 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -29,15 +29,18 @@ #endif #if TARGET_PC +#include "dusk/action_bindings.h" #include "dusk/camera_operators.hpp" #include "dusk/commands.hpp" -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" +#include "dusk/interp/camera.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" -#include "dusk/action_bindings.h" #include "dusk/mouse.h" #include "dusk/settings.h" #include "dusk/touch_camera.h" -#include "imgui.h" + +#include #endif namespace { @@ -10502,13 +10505,13 @@ bool dCamera_c::eventCamera(s32 param_0) { #endif #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { switch (var_r29) { case 3: case 4: case 5: case 12: - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); break; default: DuskLog.debug( @@ -11358,7 +11361,7 @@ void widezoom_correction(camera_process_class* i_this, float trim_height) { trim_width = FB_WIDTH_BASE / 2.0f * (1.0f - target_ar_real / current_ar); } - if (dusk::frame_interp::is_sim_frame()) { + if (dusk::game_clock::is_sim_frame()) { constexpr auto base_ar = static_cast(FB_WIDTH_BASE) / static_cast(FB_HEIGHT_BASE); const auto ar_corr = base_ar / std::min(current_ar, target_ar_real); @@ -11396,8 +11399,8 @@ static int camera_execute(camera_process_class* i_this) { #ifdef TARGET_PC widezoom_correction(i_this, i_this->mCamera.TrimHeight()); - if (dusk::frame_interp::is_enabled()) { - dusk::frame_interp::add_interpolation_callback([](bool _, void* pUserWork) { + if (dusk::interp::is_enabled()) { + dusk::interp::add_interpolation_callback([](void* pUserWork) { const auto i_this = static_cast(pUserWork); const auto camera = &i_this->mCamera; @@ -11406,7 +11409,7 @@ static int camera_execute(camera_process_class* i_this) { if (camera->mCurState != 2 && trim_size >= 0 && trim_size <= 3) { // derive trim height at previous tick using current camera state const auto target = get_target_trim_height(i_this); - const auto step = dusk::frame_interp::get_interpolation_step(); + const auto step = dusk::interp::get_interpolation_step(); const auto cur = camera->TrimHeight(); const auto prev = (4.0f * cur - target) / 3.0f; const auto trim_height = prev + (cur - prev) * step; @@ -11417,10 +11420,10 @@ static int camera_execute(camera_process_class* i_this) { } // record new camera for our sim frame - dusk::frame_interp::record_camera(i_this, get_camera_id(i_this)); + dusk::interp::record_camera(i_this, get_camera_id(i_this)); // interpolate the view now so that this sim frame's view matrix matches what // we'll be rendering with later - dusk::frame_interp::interp_view(&i_this->view); + dusk::interp::interp_view(&i_this->view); #endif view_setup(i_this); diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index ecd0b796a0..8b3f0bde1d 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -19,17 +19,18 @@ #include "d/d_timer.h" #include "f_op/f_op_msg_mng.h" #include "f_op/f_op_scene_mng.h" -#include "m_Do/m_Do_MemCard.h" #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_graphic.h" #include #include -#include "helpers/string.hpp" #if TARGET_PC #include "dusk/settings.h" +#include "helpers/string.hpp" + +#include "m_Do/m_Do_MemCard.h" #endif void dComIfG_play_c::ct() { @@ -1245,12 +1246,12 @@ BOOL dComIfG_resetToOpening(scene_class* i_scene) { } #endif - #ifdef TARGET_PC +#if TARGET_PC if (!mDoMemCd_isCardCommNone()) { return 0; } g_mDoMemCd_control.SaveSync(); - #endif +#endif dComIfG_changeOpeningScene(i_scene, fpcNm_OPENING_SCENE_e); mDoAud_bgmStop(30); diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index cf4a830799..b5ed876126 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -14,14 +14,18 @@ #include "m_Do/m_Do_mtx.h" #if TARGET_PC +#include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/logging.h" +#include "helpers/gx_helper.h" + +#include "JSystem/JKernel/JKRHeap.h" + +#include +#include + #include #include -#include "JSystem/JKernel/JKRHeap.h" -#include "absl/container/flat_hash_map.h" -#include "tracy/Tracy.hpp" -#include "dusk/frame_interpolation.h" -#include "helpers/gx_helper.h" -#include "dusk/logging.h" static const void* getInterpKey(const void* base, int idx) { return reinterpret_cast(reinterpret_cast(base) ^ idx); @@ -1078,7 +1082,7 @@ void dDlst_shadowReal_c::reset() { void dDlst_shadowReal_c::imageDraw(Mtx param_0) { #ifdef TARGET_PC Mtx render_proj_mtx; - if (dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 2), render_proj_mtx)) { + if (dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 2), render_proj_mtx)) { GXSetProjection(render_proj_mtx, GX_ORTHOGRAPHIC); } else #endif @@ -1099,7 +1103,7 @@ void dDlst_shadowReal_c::imageDraw(Mtx param_0) { shape_pkt = (*models)->getShapePacket(j); #ifdef TARGET_PC Mtx view_mtx; - if (dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx)) { + if (dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx)) { shape_pkt->setBaseMtxPtr(&view_mtx); } else #endif @@ -1128,8 +1132,8 @@ void dDlst_shadowReal_c::draw() { GXSetCurrentMtx(GX_PNMTX0); #ifdef TARGET_PC Mtx view_mtx, recv_proj_mtx; - const auto have_view_mtx = dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx); - const auto have_recv_proj_mtx = dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 3), recv_proj_mtx); + const auto have_view_mtx = dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx); + const auto have_recv_proj_mtx = dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 3), recv_proj_mtx); if (have_view_mtx && have_recv_proj_mtx) { cMtx_concat(recv_proj_mtx, view_mtx, recv_proj_mtx); GXLoadTexMtxImm(recv_proj_mtx, GX_TEXMTX0, GX_MTX3x4); @@ -1297,9 +1301,9 @@ u8 dDlst_shadowReal_c::setShadowRealMtx(cXyz* param_0, cXyz* param_1, f32 param_ #ifdef TARGET_PC const auto keybase = mpModels[0]; - dusk::frame_interp::record_final_mtx(mViewMtx, getInterpKey(keybase, 1)); - dusk::frame_interp::record_final_mtx(mRenderProjMtx, getInterpKey(keybase, 2)); - dusk::frame_interp::record_final_mtx(mReceiverProjMtx, getInterpKey(keybase, 3)); + dusk::interp::record_final_mtx(mViewMtx, getInterpKey(keybase, 1)); + dusk::interp::record_final_mtx(mRenderProjMtx, getInterpKey(keybase, 2)); + dusk::interp::record_final_mtx(mReceiverProjMtx, getInterpKey(keybase, 3)); #endif cMtx_concat(mReceiverProjMtx, mViewMtx, mReceiverProjMtx); return r29; @@ -1361,6 +1365,16 @@ bool dDlst_shadowReal_c::add(J3DModel* i_model) { return true; } +#if TARGET_PC +static MtxP get_simple_shadow_mtx(Mtx worldMtx, const void* key, Mtx storage) { + if (!dusk::interp::lookup_replacement(key, storage)) { + cMtx_copy(worldMtx, storage); + } + cMtx_concat(j3dSys.getViewMtx(), storage, storage); + return storage; +} +#endif + void dDlst_shadowSimple_c::draw() { static GXColor l_color = {0, 0, 0, 64}; l_color.a = mAlpha; @@ -1368,31 +1382,23 @@ void dDlst_shadowSimple_c::draw() { GXSetTevColor(GX_TEVREG0, l_color); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); -#ifdef TARGET_PC - Mtx volume_mtx; - if (dusk::frame_interp::lookup_replacement(mVolumeMtxKey, volume_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), volume_mtx, volume_mtx); - GXLoadPosMtxImm(volume_mtx, GX_PNMTX0); - } else +#if TARGET_PC + Mtx volumeMtx; + GXLoadPosMtxImm(get_simple_shadow_mtx(mVolumeMtx, mVolumeMtxKey, volumeMtx), GX_PNMTX0); +#else + GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0); #endif - { - GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0); - } GXSetCurrentMtx(GX_PNMTX0); GXCallDisplayList(l_frontMat, 0x40); GXCallDisplayList(l_shadowVolumeDL, 0x40); GXCallDisplayList(l_backSubMat, 0x20); GXCallDisplayList(l_shadowVolumeDL, 0x40); -#ifdef TARGET_PC - Mtx shadow_mtx; - if (dusk::frame_interp::lookup_replacement(mMtxKey, shadow_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), shadow_mtx, shadow_mtx); - GXLoadPosMtxImm(shadow_mtx, GX_PNMTX1); - } else +#if TARGET_PC + Mtx shadowMtx; + GXLoadPosMtxImm(get_simple_shadow_mtx(mMtx, mMtxKey, shadowMtx), GX_PNMTX1); +#else + GXLoadPosMtxImm(mMtx, GX_PNMTX1); #endif - { - GXLoadPosMtxImm(mMtx, GX_PNMTX1); - } GXSetCurrentMtx(GX_PNMTX1); if (mpTexObj != NULL) { @@ -1447,9 +1453,11 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa mDoMtx_stack_c::scaleM(param_2, f30 + f30 + 16.0f, param_2 * param_5); #if TARGET_PC mVolumeMtxKey = getInterpKey(param_0, 0x1); - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mVolumeMtxKey); -#endif + dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), mVolumeMtxKey); + cMtx_copy(mDoMtx_stack_c::get(), mVolumeMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mVolumeMtx); +#endif f32 f31 = JMAFastSqrt(1.0f - param_3->x * param_3->x); f32 f29; f32 f28; @@ -1474,11 +1482,13 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa mDoMtx_stack_c::get()[2][3] = param_0->z; mDoMtx_stack_c::YrotM(param_4); mDoMtx_stack_c::scaleM(param_2, 1.0f, param_2 * param_5); -#ifdef TARGET_PC +#if TARGET_PC mMtxKey = getInterpKey(param_0, 0x2); - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mMtxKey); -#endif + dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), mMtxKey); + cMtx_copy(mDoMtx_stack_c::get(), mMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mMtx); +#endif mpTexObj = param_6; } @@ -1639,7 +1649,7 @@ void dDlst_shadowControl_c::draw(Mtx param_0) { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); #ifdef TARGET_PC Mtx draw_mtx; - if (dusk::frame_interp::lookup_replacement(param_0, draw_mtx)) { + if (dusk::interp::lookup_replacement(param_0, draw_mtx)) { GXLoadPosMtxImm(draw_mtx, GX_PNMTX0); } else { #endif @@ -1988,7 +1998,7 @@ void dDlst_list_c::drawXluListItem3d() { } int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base_c* p_newDlst) { - if (p_start >= p_end) { + if (p_start >= p_end IF_DUSK(|| !dusk::game_clock::is_sim_frame())) { return 0; } *p_start = p_newDlst; @@ -2071,10 +2081,10 @@ void dDlst_list_c::calcWipe() { } #if TARGET_PC -void dDlst_list_c::refresh3DlineMats(const cXyz& eye) { +void dDlst_list_c::refresh3DlineMats() { for (int i = 0; i < 3; i++) { for (mDoExt_3DlineMat_c* mat = m3DLineMatSortPacket[i].getFirstMat(); mat != NULL; mat = mat->field_0x4) { - mat->refreshGeometryForPresentationEye(eye); + mat->refreshGeometryForPresentation(); } } } diff --git a/src/d/d_ev_camera.cpp b/src/d/d_ev_camera.cpp index 2650c2d05e..78a2d0b657 100644 --- a/src/d/d_ev_camera.cpp +++ b/src/d/d_ev_camera.cpp @@ -13,12 +13,12 @@ #include "d/actor/d_a_alink.h" #include +#if TARGET_PC #include "helpers/string.hpp" -#ifdef __MWERKS__ -#define LOAD_4BYTE_STRING_LITERAL(x) (*(u32*)(x)) -#else #define LOAD_4BYTE_STRING_LITERAL(x) read_big_endian_u32(x) +#else +#define LOAD_4BYTE_STRING_LITERAL(x) (*(u32*)(x)) #endif namespace { diff --git a/src/d/d_event.cpp b/src/d/d_event.cpp index b17ebf61f0..4200b1ed75 100644 --- a/src/d/d_event.cpp +++ b/src/d/d_event.cpp @@ -13,7 +13,9 @@ #include "SSystem/SComponent/c_counter.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif namespace { static u8 event_debug_evnt() { diff --git a/src/d/d_event_manager.cpp b/src/d/d_event_manager.cpp index da50ec7d96..70b818c922 100644 --- a/src/d/d_event_manager.cpp +++ b/src/d/d_event_manager.cpp @@ -15,7 +15,9 @@ #include "SSystem/SComponent/c_counter.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif #if DEBUG static dEvM_HIO_c l_HIO; @@ -337,10 +339,13 @@ bool dEvent_manager_c::setObjectArchive(DUSK_CONST char* arcname) { rt = dComIfG_getObjectRes(arcname, DataFileName); #if TARGET_PC if (rt != nullptr && strcmp(arcname, "Prayer") == 0) { - // pointer to Prayer event `011get_item` prm0 in it's event_list.dat + // pointer to Prayer event `011get_item` prm0 in its event_list.dat u8* itemNo = static_cast(rt) + 0x927; *itemNo = dusk::mods::item_check("prayer_reward", dItemNo_KAKERA_HEART_e, NULL); + // set the proper item give tag + u32* prm1 = reinterpret_cast(static_cast(rt) + 0x928); + *prm1 = dusk::mods::item_give_tag("prayer_reward"); } #endif int base_status = mEventList[BASE_ACTOR].init((char*)rt, -1); diff --git a/src/d/d_file_sel_info.cpp b/src/d/d_file_sel_info.cpp index 70bd101aa0..377754b834 100644 --- a/src/d/d_file_sel_info.cpp +++ b/src/d/d_file_sel_info.cpp @@ -14,8 +14,10 @@ #include #include -#include "helpers/string.hpp" +#if TARGET_PC #include "dusk/version.hpp" +#include "helpers/string.hpp" +#endif dFile_info_c::dFile_info_c(JKRArchive* i_archive, u8 param_1) { mArchive = i_archive; diff --git a/src/d/d_file_sel_warning.cpp b/src/d/d_file_sel_warning.cpp index fc17e05a0d..97b667bb45 100644 --- a/src/d/d_file_sel_warning.cpp +++ b/src/d/d_file_sel_warning.cpp @@ -11,7 +11,10 @@ #include "d/d_file_sel_warning.h" #include "d/d_msg_string.h" #include "d/d_pane_class.h" + +#if TARGET_PC #include "dusk/version.hpp" +#endif typedef void (dFile_warning_c::*procFunc)(); static procFunc fileWarningProc[] = {&dFile_warning_c::modeWait, &dFile_warning_c::modeMove}; diff --git a/src/d/d_file_select.cpp b/src/d/d_file_select.cpp index 3f64b8b239..ed73d5f9cf 100644 --- a/src/d/d_file_select.cpp +++ b/src/d/d_file_select.cpp @@ -23,13 +23,12 @@ #include "m_Do/m_Do_graphic.h" #include -#include "dusk/utilities.hpp" -#include "dusk/version.hpp" - #if TARGET_PC #include "dusk/game_mode.hpp" #include "dusk/menu_pointer.h" #include "dusk/mods/svc/save.hpp" +#include "dusk/utilities.hpp" +#include "dusk/version.hpp" #include "helpers/string.hpp" namespace { @@ -4432,15 +4431,15 @@ void dFile_select_c::_draw() { dComIfGd_set2DOpa(mSelIcon); dComIfGd_set2DOpa(mSelIcon2); - #if PLATFORM_GCN - #if TARGET_PC +#if PLATFORM_GCN +#if TARGET_PC dComIfGd_set2DOpaTop(&mFadeDlst); - #else +#else mpFadePict->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), false, false, false); - #endif - #endif +#endif +#endif } } diff --git a/src/d/d_gameover.cpp b/src/d/d_gameover.cpp index c7dcde357c..ac85b5d2b4 100644 --- a/src/d/d_gameover.cpp +++ b/src/d/d_gameover.cpp @@ -14,7 +14,9 @@ #include "JSystem/J2DGraph/J2DGrafContext.h" #include +#if TARGET_PC #include "helpers/gx_helper.h" +#endif class dGov_HIO_c : public mDoHIO_entry_c { public: diff --git a/src/d/d_item.cpp b/src/d/d_item.cpp index a388ef155c..f89d4f37e8 100644 --- a/src/d/d_item.cpp +++ b/src/d/d_item.cpp @@ -269,7 +269,10 @@ static void (*item_func_ptr[256])() = { item_func_noentry, }; -inline void getItemFunc(u8 i_itemNo) { +#if !TARGET_PC +inline +#endif +void getItemFunc(u8 i_itemNo) { dComIfGs_onItemFirstBit(i_itemNo); item_func_ptr[i_itemNo](); } diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index f9d77837f9..b8e397e0ad 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -32,11 +32,10 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include #include + #if TARGET_PC -#include "dusk/imgui/ImGuiBloomWindow.hpp" -#include "dusk/settings.h" -#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" +#include "dusk/imgui/ImGuiBloomWindow.hpp" static f32 timeScale = 1.0f; #endif @@ -8275,9 +8274,7 @@ static int dKy_Create(void* i_this) { kankyo_class* kankyo = (kankyo_class*)i_this; BOOL next_time_set = false; -#if TARGET_PC - kankyo->base.draw_interp_frame = true; -#endif + IF_DUSK(kankyo->base.draw_interp_frame = true); stage_envr_info_class* stage_envr_p = dComIfGp_getStageEnvrInfo(); if (stage_envr_p != NULL && dComIfGp_getStartStageRoomNo() != -1) { diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index 02dcd94d68..dc01322291 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -13,9 +13,9 @@ #include "m_Do/m_Do_lib.h" #include -#include "dusk/version.hpp" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/version.hpp" #endif static void vectle_calc(DOUBLE_POS* i_pos, cXyz* o_out) { @@ -129,24 +129,73 @@ static GXTexObj* load_cached_tex(CachedTexObjs& cache, ResTIMG* img, GXTexMap } #endif +#if TARGET_PC +static void dKyr_place_sun(camera_class* camera, cXyz* o_sunpos) { + cXyz lightDir; + u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); + if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { + dKyr_get_vectle_calc(&camera->view.lookat.eye, &g_env_light.base_light.mPosition, + &lightDir); + } else { + dKyr_get_vectle_calc(&camera->view.lookat.eye, &g_env_light.sun_light_pos, &lightDir); + } + o_sunpos->x = camera->view.lookat.eye.x + 8000.0f * lightDir.x; + o_sunpos->y = camera->view.lookat.eye.y + 8000.0f * lightDir.y; + o_sunpos->z = camera->view.lookat.eye.z + 8000.0f * lightDir.z; +} + +static void dKyr_place_lenzflare(camera_class* camera, cXyz* sunpos, cXyz* o_positions) { + cXyz eyeVect; + cXyz sunDirSmth; + cXyz camFwd; + + dKy_set_eyevect_calc(camera, &eyeVect, 4000.0f, 4000.0f); + dKyr_get_vectle_calc(&eyeVect, sunpos, &sunDirSmth); + o_positions[0] = *sunpos; + o_positions[1] = *sunpos; + + dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camFwd); + + for (int i = 2; i < 8; i++) { + if (i == 2) { + f32 size = 250.0f + 600.0f * sunDirSmth.abs(camFwd); + o_positions[i].x = sunpos->x - sunDirSmth.x * size * i; + o_positions[i].y = sunpos->y - sunDirSmth.y * size * i; + o_positions[i].z = sunpos->z - sunDirSmth.z * size * i; + } else { + f32 size = 250.0f + 110.0f * sunDirSmth.abs(camFwd); + o_positions[i].x = sunpos->x - (4100.0f * sunDirSmth.x + sunDirSmth.x * size * i); + o_positions[i].y = sunpos->y - (4100.0f * sunDirSmth.y + sunDirSmth.y * size * i); + o_positions[i].z = sunpos->z - (4100.0f * sunDirSmth.z + sunDirSmth.z * size * i); + } + } +} +#endif + void dKyr_lenzflare_move() { dKankyo_sun_Packet* sun_packet = g_env_light.mpSunPacket; dKankyo_sunlenz_Packet* lenz_packet = g_env_light.mpSunLenzPacket; camera_process_class* camera = dComIfGp_getCamera(0); +#if !TARGET_PC cXyz eyeVect; cXyz field_0x3c; cXyz sunDirSmth; cXyz camFwd; +#endif if (sun_packet->mVisibility < 0.0001f) { return; } +#if TARGET_PC + dKyr_place_lenzflare(camera, sun_packet->mPos, lenz_packet->mPositions); +#else dKy_set_eyevect_calc(camera, &eyeVect, 4000.0f, 4000.0f); dKyr_get_vectle_calc(&eyeVect, sun_packet->mPos, &sunDirSmth); lenz_packet->mPositions[0] = sun_packet->mPos[0]; lenz_packet->mPositions[1] = sun_packet->mPos[0]; +#endif cXyz vect; cXyz proj; @@ -162,6 +211,7 @@ void dKyr_lenzflare_move() { lenz_packet->field_0x94 *= S2DEG_CONSTANT; // convert from short angle to degrees lenz_packet->field_0x94 += 180.0f; +#if !TARGET_PC dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camFwd); for (int i = 2; i < 8; i++) { @@ -177,6 +227,7 @@ void dKyr_lenzflare_move() { lenz_packet->mPositions[i].z = sun_packet->mPos[0].z - (4100.0f * sunDirSmth.z + sunDirSmth.z * size * i); } } +#endif } static BOOL dKyr_moon_arrival_check() { @@ -205,6 +256,10 @@ void dKyr_sun_move() { u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); +#if TARGET_PC + dKyr_place_sun(camera_p2, &sun_packet->mPos[0]); + dKyr_get_vectle_calc(&camera_p2->view.lookat.eye, &sun_packet->mPos[0], &lightDir); +#else if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { dKyr_get_vectle_calc(&camera_p2->view.lookat.eye, &g_env_light.base_light.mPosition, &lightDir); @@ -215,6 +270,7 @@ void dKyr_sun_move() { sun_packet->mPos[0].x = camera_p2->view.lookat.eye.x + 8000.0f * lightDir.x; sun_packet->mPos[0].y = camera_p2->view.lookat.eye.y + 8000.0f * lightDir.y; sun_packet->mPos[0].z = camera_p2->view.lookat.eye.z + 8000.0f * lightDir.z; +#endif f32 horizon_y = (sun_packet->mPos[0].y - camera_p2->view.lookat.eye.y) / 8000.0f; if (horizon_y < 0.0f) { @@ -2414,15 +2470,17 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* ppos, GXColor& unused, u8** tex) { sunpos.y = ppos->y; sunpos.z = ppos->z; + IF_DUSK(dKyr_place_sun(camera, &sunpos)); + u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { if (g_env_light.daytime > 285.0f || g_env_light.daytime < 105.0f) { draw_moon = false; } - spB4.x = ppos->x; - spB4.y = ppos->y; - spB4.z = ppos->z; + spB4.x = DUSK_IF_ELSE(sunpos.x, ppos->x); + spB4.y = DUSK_IF_ELSE(sunpos.y, ppos->y); + spB4.z = DUSK_IF_ELSE(sunpos.z, ppos->z); } else { if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) { spB4 = envlight->moon_pos; @@ -2588,7 +2646,8 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* ppos, GXColor& unused, u8** tex) { }; if (strcmp(dComIfGp_getStartStageName(), "F_SP200") != 0) { - dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camfwd); + dKyr_get_vectle_calc(&camera->view.lookat.eye, + &camera->view.lookat.center, &camfwd); f32 cam_distXZ = JMAFastSqrt((camfwd.x * camfwd.x) + (camfwd.z * camfwd.z)); f32 cam_theta = atan2f(camfwd.x, camfwd.z); f32 cam_phi = atan2f(camfwd.y, cam_distXZ); @@ -2783,6 +2842,13 @@ void dKyr_drawLenzflare(Mtx drawMtx, cXyz* ppos, GXColor& param_2, u8** tex) { f32 spA8 = sun_packet->mVisibility * sun_packet->mVisibility; if (!(sun_visibility < 0.1f)) { +#if TARGET_PC + cXyz sunpos; + cXyz positions[8]; + dKyr_place_sun(camera, &sunpos); + dKyr_place_lenzflare(camera, &sunpos, positions); + ppos = positions; +#endif dKy_set_eyevect_calc2(camera, &spFC, 8000.0f, 8000.0f); GXColor color_reg0; @@ -2962,25 +3028,25 @@ void dKyr_drawLenzflare(Mtx drawMtx, cXyz* ppos, GXColor& param_2, u8** tex) { spE4.y = sp9C; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[0].x = sun_packet->mPos[0].x + spD8.x; - pos[0].y = sun_packet->mPos[0].y + spD8.y; - pos[0].z = sun_packet->mPos[0].z + spD8.z; + pos[0].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[0].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[0].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; spE4.x = sp98; spE4.y = sp94; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[1].x = sun_packet->mPos[0].x + spD8.x; - pos[1].y = sun_packet->mPos[0].y + spD8.y; - pos[1].z = sun_packet->mPos[0].z + spD8.z; + pos[1].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[1].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[1].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; spE4.x = sp90; spE4.y = sp8C; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[2].x = sun_packet->mPos[0].x + spD8.x; - pos[2].y = sun_packet->mPos[0].y + spD8.y; - pos[2].z = sun_packet->mPos[0].z + spD8.z; + pos[2].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[2].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[2].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; GXBegin(GX_TRIANGLES, GX_VTXFMT0, 3); GXPosition3f32(pos[0].x, pos[0].y, pos[0].z); @@ -6207,12 +6273,9 @@ static void dKyr_evil_draw2(Mtx drawMtx, u8** tex) { dKyr_set_btitex(&texobj, (ResTIMG*)tex[1]); #endif -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - rot += 0.7f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + rot += 0.7f; + IF_DUSK_BLOCK_END MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot)); MTXConcat(camMtx, rotMtx, camMtx); @@ -6451,12 +6514,9 @@ void dKyr_evil_draw(Mtx drawMtx, u8** tex) { dKyr_set_btitex(&texobj, (ResTIMG*)tex[0]); #endif -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - rot += 1.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + rot += 1.0f; + IF_DUSK_BLOCK_END MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot)); MTXConcat(camMtx, rotMtx, camMtx); diff --git a/src/d/d_menu_calibration.cpp b/src/d/d_menu_calibration.cpp index 23f81121bc..e596609292 100644 --- a/src/d/d_menu_calibration.cpp +++ b/src/d/d_menu_calibration.cpp @@ -14,7 +14,9 @@ #include "m_Do/m_Do_controller_pad.h" #include +#if TARGET_PC #include "helpers/string.hpp" +#endif // Need 0xC bytes of padding with no symbol between dMenu_Calibration_c::__vtable and the end of // .data @@ -25,7 +27,7 @@ public: virtual void virt_func_0() = 0; }; class dummy_child_class : dummy_abstract_class { -#ifdef TARGET_PC +#if TARGET_PC virtual void virt_func_0() {} #else virtual void virt_func_0(); diff --git a/src/d/d_menu_dmap.cpp b/src/d/d_menu_dmap.cpp index 4557edfb4c..f8514e3817 100644 --- a/src/d/d_menu_dmap.cpp +++ b/src/d/d_menu_dmap.cpp @@ -21,16 +21,15 @@ #include "d/d_msg_string.h" #include "d/d_meter_haihai.h" #include "d/d_menu_window.h" -#include "dusk/settings.h" #include "f_op/f_op_msg_mng.h" #include "m_Do/m_Do_graphic.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "dusk/settings.h" #include "dusk/version.hpp" #include "helpers/string.hpp" - -#if TARGET_PC -#include "dusk/frame_interpolation.h" #endif #if (PLATFORM_WII || PLATFORM_SHIELD) @@ -1113,7 +1112,7 @@ void dMenu_DmapBg_c::draw() { -35.0f + (local_224.x - local_218.x), -35.0f + (local_224.y - local_218.y)); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { field_0xdda = 0; } #else @@ -2775,7 +2774,7 @@ void dMenu_Dmap_c::zoomIn_proc() { void dMenu_Dmap_c::zoomOut_init_proc() { #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { mpDrawBg->resetScrollArrowMask(); } #endif diff --git a/src/d/d_menu_dmap_map.cpp b/src/d/d_menu_dmap_map.cpp index bc63706617..b0be1dbf4b 100644 --- a/src/d/d_menu_dmap_map.cpp +++ b/src/d/d_menu_dmap_map.cpp @@ -11,6 +11,7 @@ #include "d/d_menu_dmap_map.h" #include "f_op/f_op_msg_mng.h" #include "m_Do/m_Do_graphic.h" + #if TARGET_PC #include #endif diff --git a/src/d/d_menu_fishing.cpp b/src/d/d_menu_fishing.cpp index 2579d328fb..84e62b2385 100644 --- a/src/d/d_menu_fishing.cpp +++ b/src/d/d_menu_fishing.cpp @@ -16,8 +16,10 @@ #include "m_Do/m_Do_graphic.h" #include -#include "helpers/string.hpp" +#if TARGET_PC #include "dusk/version.hpp" +#include "helpers/string.hpp" +#endif typedef void (dMenu_Fishing_c::*initFunc)(); DUSK_GAME_DATA initFunc map_init_process[] = { diff --git a/src/d/d_menu_fmap.cpp b/src/d/d_menu_fmap.cpp index c2d642a6d4..57c329a61f 100644 --- a/src/d/d_menu_fmap.cpp +++ b/src/d/d_menu_fmap.cpp @@ -1,33 +1,33 @@ #include "d/dolzel.h" // IWYU pragma: keep -#include -#include +#include "d/d_menu_fmap.h" +#include "SSystem/SComponent/c_math.h" #include "JSystem/JKernel/JKRAramArchive.h" #include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JKernel/JKRMemArchive.h" -#include "SSystem/SComponent/c_math.h" -#include "d/actor/d_a_midna.h" -#include "d/actor/d_a_player.h" +#include +#include +#include "f_op/f_op_msg_mng.h" #include "d/d_com_inf_game.h" #include "d/d_lib.h" -#include "d/d_menu_fmap.h" #include "d/d_menu_fmap2D.h" #include "d/d_menu_fmap_map.h" #include "d/d_menu_window.h" -#include "d/d_meter2_draw.h" -#include "d/d_meter2_info.h" #include "d/d_meter_HIO.h" #include "d/d_meter_map.h" +#include "d/d_meter2_draw.h" +#include "d/d_meter2_info.h" #include "d/d_msg_object.h" #include "d/d_msg_scrn_explain.h" #include "d/d_stage.h" -#include "dusk/version.hpp" -#include "f_op/f_op_msg_mng.h" -#include "helpers/string.hpp" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_midna.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/memory.h" +#include "dusk/version.hpp" +#include "helpers/string.hpp" #endif static dMf_HIO_c g_fmHIO; @@ -783,7 +783,6 @@ void dMenu_Fmap_c::all_map_proc() { { setAreaName(mTitleName[mpDraw2DBack->getSelectRegion()]); mpDraw2DBack->setSpotCursor(0); - } else { setAreaNameZero(); } @@ -1153,7 +1152,7 @@ void dMenu_Fmap_c::zoom_spot_to_region_init() { field_0x1ec = 1.0f; #if TARGET_PC // Frame interp note: field_0x122d used to be set every draw, causing flickering. Do it here instead. - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { mpDraw2DBack->resetScrollArrowMask(); } #endif @@ -1273,7 +1272,7 @@ void dMenu_Fmap_c::spot_map_proc() { f32 pos_y = mpDraw2DBack->getMapAreaGlobalCenterPosY() - mDoGph_gInf_c::getHeightF() * 0.5f; mpMenuFmapMap->getPointStagePathInnerNo(getNowFmapRegionData(), pos_x, pos_y, mStayStageNo, &stage_no, &room_no); - + if (mStageCursor != stage_no || mResetAreaName) { mStageCursor = stage_no; mRoomCursor = room_no; diff --git a/src/d/d_menu_fmap2D.cpp b/src/d/d_menu_fmap2D.cpp index cd2e09c6d7..58db87ee68 100644 --- a/src/d/d_menu_fmap2D.cpp +++ b/src/d/d_menu_fmap2D.cpp @@ -17,15 +17,13 @@ #include "d/d_msg_scrn_explain.h" #include "m_Do/m_Do_graphic.h" #include "d/actor/d_a_midna.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#include "dusk/ui/touch_controls.hpp" -#endif #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "dusk/ui/touch_controls.hpp" #include "dusk/version.hpp" -#if TARGET_PC void dMenu_Fmap2DBack_c::fMapBackWide() { mpBaseScreen->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f); mpBaseScreen->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f); @@ -360,13 +358,10 @@ void dMenu_Fmap2DBack_c::draw() { scrollAreaDraw(); } -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - blinkMove(30); - moveLightDropAnime(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + blinkMove(30); + moveLightDropAnime(); + IF_DUSK_BLOCK_END setCenterPosX(field_0x11dc, 1); drawIcon(mTransX, mTransZ, mAlphaRate, field_0xfa8 * mSpotTextureFadeAlpha); @@ -401,16 +396,13 @@ void dMenu_Fmap2DBack_c::draw() { (mArrowPos3DZ + control_ypos + fVar3) - fVar5, &mArrowPos2DX, &mArrowPos2DY); -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x11e0 -= g_fmapHIO.mCursorSpeed; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x11e0 -= g_fmapHIO.mCursorSpeed; - if (field_0x11e0 < 0.0f) { - field_0x11e0 += 360.0f; - } + if (field_0x11e0 < 0.0f) { + field_0x11e0 += 360.0f; } + IF_DUSK_BLOCK_END mpPointParent->getPanePtr()->rotate(mpPointParent->getSizeX() / 2.0f, mpPointParent->getSizeY() / 2.0f, ROTATE_Z, @@ -450,7 +442,7 @@ void dMenu_Fmap2DBack_c::draw() { if (field_0x122d) { mpMeterHaihai->drawHaihai(field_0x122d); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { field_0x122d = 0; } #else @@ -1870,21 +1862,18 @@ void dMenu_Fmap2DBack_c::calcBlink() { t * (g_fmapHIO.mMapBlink[i + 1].mUnselectedRegion.mBlinkSpeed - g_fmapHIO.mMapBlink[i].mUnselectedRegion.mBlinkSpeed); -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x1218++; - if (field_0x1218 >= selected_blink_speed) { - field_0x1218 = 0; - } - - field_0x121a++; - if (field_0x121a >= unselected_blink_speed) { - field_0x121a = 0; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x1218++; + if (field_0x1218 >= selected_blink_speed) { + field_0x1218 = 0; } + field_0x121a++; + if (field_0x121a >= unselected_blink_speed) { + field_0x121a = 0; + } + IF_DUSK_BLOCK_END + f32 t_selected = 0.0f; f32 t_unselected = 0.0f; diff --git a/src/d/d_menu_fmap_map.cpp b/src/d/d_menu_fmap_map.cpp index b2477b8b06..8a3c34fbde 100644 --- a/src/d/d_menu_fmap_map.cpp +++ b/src/d/d_menu_fmap_map.cpp @@ -8,10 +8,11 @@ #include "d/d_debug_viewer.h" #include "d/d_menu_fmap_map.h" #include "m_Do/m_Do_graphic.h" +#include + #if TARGET_PC #include #endif -#include static u8 twoValueLineInterpolation(u8 i_value1, u8 i_value2, f32 i_param) { return (u8)((f32)i_value1 + i_param * ((f32)i_value2 - (f32)i_value1)); diff --git a/src/d/d_menu_insect.cpp b/src/d/d_menu_insect.cpp index e7917532a2..684dd1235c 100644 --- a/src/d/d_menu_insect.cpp +++ b/src/d/d_menu_insect.cpp @@ -22,10 +22,9 @@ #include #include -#include "dusk/version.hpp" - #if TARGET_PC #include "dusk/menu_pointer.h" +#include "dusk/version.hpp" #endif typedef void (dMenu_Insect_c::*initFunc)(); diff --git a/src/d/d_menu_item_explain.cpp b/src/d/d_menu_item_explain.cpp index 9ef85ed32e..e6134e6c8b 100644 --- a/src/d/d_menu_item_explain.cpp +++ b/src/d/d_menu_item_explain.cpp @@ -5,26 +5,29 @@ #include "d/dolzel.h" // IWYU pragma: keep -#include -#include +#include "d/d_menu_item_explain.h" #include "JSystem/J2DGraph/J2DTextBox.h" #include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JUtility/JUTTexture.h" +#include +#include #include "d/actor/d_a_player.h" #include "d/d_com_inf_game.h" #include "d/d_item.h" #include "d/d_kantera_icon_meter.h" #include "d/d_lib.h" -#include "d/d_menu_item_explain.h" +#include "d/d_select_cursor.h" #include "d/d_meter2_info.h" #include "d/d_meter_HIO.h" -#include "d/d_msg_scrn_3select.h" -#include "d/d_msg_scrn_arrow.h" #include "d/d_msg_string.h" -#include "d/d_select_cursor.h" -#include "dusk/version.hpp" #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_graphic.h" +#include "d/d_msg_scrn_3select.h" +#include "d/d_msg_scrn_arrow.h" + +#if TARGET_PC +#include "dusk/version.hpp" +#endif typedef void (dMenu_ItemExplain_c::*initFunc)(); static initFunc init_process[] = { diff --git a/src/d/d_menu_option.cpp b/src/d/d_menu_option.cpp index e70382bab0..6790684e7b 100644 --- a/src/d/d_menu_option.cpp +++ b/src/d/d_menu_option.cpp @@ -25,11 +25,11 @@ #include #include "JSystem/JAudio2/JASDriverIF.h" -#include "dusk/version.hpp" #if TARGET_PC #include "dusk/menu_pointer.h" #include "dusk/ui/touch_controls.hpp" +#include "dusk/version.hpp" #endif typedef void (dMenu_Option_c::*initFunc)(); diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp index ed79d40524..73832f8918 100644 --- a/src/d/d_menu_ring.cpp +++ b/src/d/d_menu_ring.cpp @@ -29,14 +29,13 @@ #include -#include "dusk/version.hpp" - #if TARGET_PC -#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/menu_pointer.h" #include "dusk/settings.h" #include "dusk/ui/touch_controls.hpp" +#include "dusk/version.hpp" #endif typedef void (dMenu_Ring_c::*initFunc)(); @@ -761,13 +760,13 @@ void dMenu_Ring_c::_draw() { f32 simX = 0.0f; f32 simY = 0.0f; bool restoreSimPos = false; - if (dusk::frame_interp::is_enabled() && mAlphaRate >= 1.0f) { + if (dusk::interp::is_enabled() && mAlphaRate >= 1.0f) { simX = mpDrawCursor->getPositionX(); simY = mpDrawCursor->getPositionY(); const bool isAngular = (mStatus == STATUS_MOVE) && !mDirectSelectActive; - if (dusk::frame_interp::get_ui_tick_pending()) { + if (dusk::interp::get_ui_tick_pending()) { mCursorInterpPrevX = mCursorInterpCurrX; mCursorInterpPrevY = mCursorInterpCurrY; mCursorInterpPrevAngle = mCursorInterpCurrAngle; @@ -791,7 +790,7 @@ void dMenu_Ring_c::_draw() { } } if (mCursorInterpInit) { - const f32 step = dusk::frame_interp::get_interpolation_step(); + const f32 step = dusk::interp::get_interpolation_step(); if (mCursorInterpPrevAngular && mCursorInterpCurrAngular) { const s16 delta = mCursorInterpCurrAngle - mCursorInterpPrevAngle; const s16 lerpedAngle = mCursorInterpPrevAngle + (s16)(delta * step); diff --git a/src/d/d_menu_save.cpp b/src/d/d_menu_save.cpp index 48f3f953ea..a2b1a5dd2c 100644 --- a/src/d/d_menu_save.cpp +++ b/src/d/d_menu_save.cpp @@ -14,7 +14,6 @@ #include "d/d_msg_scrn_explain.h" #include "d/d_msg_string.h" #include "d/d_select_cursor.h" -#include "dusk/version.hpp" #include "f_op/f_op_msg_mng.h" #include "m_Do/m_Do_MemCard.h" #include "m_Do/m_Do_MemCardRWmng.h" @@ -23,10 +22,11 @@ #include "m_Do/m_Do_graphic.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/menu_pointer.h" -#include "dusk/settings.h" #include "dusk/mods/svc/save.hpp" +#include "dusk/settings.h" +#include "dusk/version.hpp" #endif static int SelStartFrameTbl[3] = { @@ -828,44 +828,38 @@ void dMenu_save_c::saveSelAnm() { } void dMenu_save_c::selFileWakuAnm() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - mFileWakuAnmFrame += 2; - if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) { - mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax(); - } - - mFileWakuRotAnmFrame += 2; - if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) { - mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mFileWakuAnmFrame += 2; + if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) { + mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax(); } + + mFileWakuRotAnmFrame += 2; + if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) { + mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax(); + } + IF_DUSK_BLOCK_END mpFileWakuAnm->setFrame(mFileWakuAnmFrame); mpFileWakuRotAnm->setFrame(mFileWakuRotAnmFrame); } void dMenu_save_c::bookIconAnm() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x154 += 2; - if (field_0x154 >= field_0x150->getFrameMax()) { - field_0x154 -= field_0x150->getFrameMax(); - } - - field_0x15c += 2; - if (field_0x15c >= field_0x158->getFrameMax()) { - field_0x15c -= field_0x158->getFrameMax(); - } - - field_0x164 += 2; - if (field_0x164 >= field_0x160->getFrameMax()) { - field_0x164 -= field_0x160->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x154 += 2; + if (field_0x154 >= field_0x150->getFrameMax()) { + field_0x154 -= field_0x150->getFrameMax(); } + + field_0x15c += 2; + if (field_0x15c >= field_0x158->getFrameMax()) { + field_0x15c -= field_0x158->getFrameMax(); + } + + field_0x164 += 2; + if (field_0x164 >= field_0x160->getFrameMax()) { + field_0x164 -= field_0x160->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x150->setFrame(field_0x154); field_0x158->setFrame(field_0x15c); field_0x160->setFrame(field_0x164); @@ -1452,6 +1446,12 @@ void dMenu_save_c::memCardDataSaveWait() { mCmdState = g_mDoMemCd_control.SaveSync(); if (mCmdState != 0) { +#if TARGET_PC + if (mCmdState == 1) { + dusk::mods::svc::save_slot_written( + mSelectedFile, mSaveBuffer + mSelectedFile * QUEST_LOG_SIZE); + } +#endif printf("save cmdState %d\n", mCmdState); mMenuProc = PROC_MEMCARD_DATA_SAVE_WAIT2; } @@ -1469,10 +1469,6 @@ void dMenu_save_c::memCardDataSaveWait2() { dComIfGs_setDataNum(mSelectedFile); dComIfGs_setNoFile(0); -#if TARGET_PC - dusk::mods::svc::save_slot_written(mSelectedFile, mSaveBuffer + mSelectedFile * QUEST_LOG_SIZE); -#endif - if (mUseType == TYPE_WHITE_EVENT || mUseType == TYPE_BLACK_EVENT) { headerTxtSet(0x530); // Saved. mWarning->closeInit(); diff --git a/src/d/d_menu_window.cpp b/src/d/d_menu_window.cpp index eb67822899..80f374cf46 100644 --- a/src/d/d_menu_window.cpp +++ b/src/d/d_menu_window.cpp @@ -26,8 +26,8 @@ #include "f_op/f_op_overlap_mng.h" #include "m_Do/m_Do_controller_pad.h" -#ifdef TARGET_PC -#include "dusk/frame_interpolation.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" #endif class dDlst_MENU_CAPTURE_c : public dDlst_base_c { @@ -126,7 +126,7 @@ public: void setCaptureFlag() { mFlag = 1; #ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); #endif } diff --git a/src/d/d_meter2_draw.cpp b/src/d/d_meter2_draw.cpp index 865b57be59..742fe6762d 100644 --- a/src/d/d_meter2_draw.cpp +++ b/src/d/d_meter2_draw.cpp @@ -20,14 +20,14 @@ #include "d/d_msg_class.h" #include "d/d_msg_object.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" #include -#include "dusk/version.hpp" - #if TARGET_PC +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #include "dusk/ui/icon_provider.hpp" +#include "dusk/version.hpp" + #include namespace { @@ -198,6 +198,20 @@ dMeter2Draw_c::dMeter2Draw_c(JKRExpHeap* mp_heap) { IF_DUSK_BLOCK_END #endif +#if TARGET_PC + if (dusk::version::isLessThanWiiJpn()) { + if (J2DPicture* b_btn = static_cast(mpScreen->search(MULTI_CHAR('b_btn')))) { + b_btn->setAlpha(255); + b_btn->setWhite(JUtility::TColor(195, 63, 63, 255)); + } + + for (int i = 0; i < 5; i++) { + static_cast(mpXYText[i][0]->getPanePtr())->setCharSpace(0.0f); + static_cast(mpXYText[i][1]->getPanePtr())->setCharSpace(0.0f); + } + } +#endif + init(); field_0xa8 = 0; field_0x1e4 = 0; @@ -755,42 +769,38 @@ void dMeter2Draw_c::draw() { if (field_0x756 >= 0) { var_f29 = g_drawHIO.mLightDrop.mDropPikariAnimSpeed_Completed; int temp_r5_2 = g_drawHIO.mLightDrop.mPikariInterval * 15; -#ifdef TARGET_PC - // FRAME INTERP NOTE: Set even if not advancing - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (field_0x756 <= temp_r5_2) { - int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval); - int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval; + IF_DUSK(var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete); // FRAME INTERP NOTE: Set even if not advancing + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (field_0x756 <= temp_r5_2) { + int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval); + int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval; - if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) { - field_0x62c[temp_r3_5] = 18.0f; - } + if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) { + field_0x62c[temp_r3_5] = 18.0f; + } - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - field_0x756++; - } else { - int temp_r5_3 = temp_r5_2 + 1; + var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; + field_0x756++; + } else { + int temp_r5_3 = temp_r5_2 + 1; - if (field_0x756 == temp_r5_3) { - if (field_0x62c[15] == 0.0f) { - field_0x756++; - } - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - } else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) { - for (int i = 0; i < 16; i++) { - field_0x62c[i] = 18.0f - var_f29; - field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed; - } - - field_0x756 = -1; - } else { + if (field_0x756 == temp_r5_3) { + if (field_0x62c[15] == 0.0f) { field_0x756++; } + var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; + } else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) { + for (int i = 0; i < 16; i++) { + field_0x62c[i] = 18.0f - var_f29; + field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed; + } + + field_0x756 = -1; + } else { + field_0x756++; } } + IF_DUSK_BLOCK_END } for (int i = 0; i < 16; i++) { @@ -1480,26 +1490,23 @@ void dMeter2Draw_c::drawPikari(f32 i_posX, f32 i_posY, f32* i_framep, f32 i_scal if (param_9 != 3 && param_9 != 4 && param_9 != 5 && dMsgObject_isTalkNowCheck()) { *i_framep = 0.0f; } else { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_framep += param_8; - if (*i_framep > var_f31) { - if (param_9 == 1 || param_9 == 2 || param_9 == 3) { - *i_framep = 18.0f; - } else { - *i_framep = 0.0f; - } - } - - if (*i_framep == 18.0f && param_9 == 1) { - mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0); - } else if (*i_framep == 18.0f && param_9 == 2) { - mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0); + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_framep += param_8; + if (*i_framep > var_f31) { + if (param_9 == 1 || param_9 == 2 || param_9 == 3) { + *i_framep = 18.0f; + } else { + *i_framep = 0.0f; } } + if (*i_framep == 18.0f && param_9 == 1) { + mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0); + } else if (*i_framep == 18.0f && param_9 == 2) { + mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0); + } + IF_DUSK_BLOCK_END + playPikariBckAnimation(*i_framep); playPikariBpkAnimation(*i_framep); @@ -2460,7 +2467,7 @@ void dMeter2Draw_c::drawButtonA(u8 i_action, f32 i_posX, f32 i_posY, f32 i_textP mpButtonA->paneTrans(i_posX, i_posY); mpTextA->scale(var_f30 * i_scale, var_f30 * i_scale); mpTextA->paneTrans(g_drawHIO.mButtonATextPosX + i_textPosX, - g_drawHIO.mButtonATextPosY + i_textPosY); + g_drawHIO.mButtonATextPosY + i_textPosY IF_DUSK(+ (dusk::version::isLessThanWiiJpn() ? 6.0f : 0.0f))); } void dMeter2Draw_c::drawButtonB(u8 i_action, bool param_1, f32 i_posX, f32 i_posY, f32 i_textPosX, @@ -2658,6 +2665,11 @@ void dMeter2Draw_c::drawButtonXY(int i_no, u8 i_itemNo, u8 i_action, bool param_ static u64 const tag[] = {MULTI_CHAR('item_x_n'), MULTI_CHAR('item_y_n')}; +#if TARGET_PC + const float btnXOffsetX = dusk::version::isLessThanWiiJpn() ? 2.0f : 0.0f; + const float btnXOffsetY = dusk::version::isLessThanWiiJpn() ? 38.0f : 0.0f; +#endif + if (!param_3) { mpScreen->search(tag[i_no])->hide(); @@ -2704,7 +2716,8 @@ void dMeter2Draw_c::drawButtonXY(int i_no, u8 i_itemNo, u8 i_action, bool param_ if (i_no == SELECT_X_e) { mpTextXY[i_no]->scale(g_drawHIO.mButtonXYTextScale, g_drawHIO.mButtonXYTextScale); - mpTextXY[i_no]->paneTrans(g_drawHIO.mButtonXYTextPosX, g_drawHIO.mButtonXYTextPosY); + mpTextXY[i_no]->paneTrans(g_drawHIO.mButtonXYTextPosX IF_DUSK(- btnXOffsetX), + g_drawHIO.mButtonXYTextPosY IF_DUSK(+ btnXOffsetY)); } else if (i_no == SELECT_Y_e) { mpTextXY[i_no]->scale(g_drawHIO.mButtonXYTextScale, g_drawHIO.mButtonXYTextScale); mpTextXY[i_no]->paneTrans(g_drawHIO.mButtonXYTextPosX, g_drawHIO.mButtonXYTextPosY); @@ -2766,7 +2779,8 @@ void dMeter2Draw_c::drawButtonXY(int i_no, u8 i_itemNo, u8 i_action, bool param_ mpLightXY[0]->setAlphaRate(mButtonXItemBaseAlpha[var_r29] * field_0x7f0); mpTextXY[i_no]->scale(g_drawHIO.mButtonXYTextScale, g_drawHIO.mButtonXYTextScale); - mpTextXY[i_no]->paneTrans(g_drawHIO.mButtonXYTextPosX, g_drawHIO.mButtonXYTextPosY); + mpTextXY[i_no]->paneTrans(g_drawHIO.mButtonXYTextPosX IF_DUSK(- btnXOffsetX), + g_drawHIO.mButtonXYTextPosY IF_DUSK(+ btnXOffsetY)); } else if (i_no == SELECT_Y_e) { mpButtonXY[1]->scale(g_drawHIO.mButtonYScale, g_drawHIO.mButtonYScale); mpButtonXY[1]->paneTrans(g_drawHIO.mButtonYPosX, g_drawHIO.mButtonYPosY); diff --git a/src/d/d_meter2_info.cpp b/src/d/d_meter2_info.cpp index 15569a72d8..3bb9ffdcd3 100644 --- a/src/d/d_meter2_info.cpp +++ b/src/d/d_meter2_info.cpp @@ -15,8 +15,10 @@ #include +#if TARGET_PC #include "dusk/version.hpp" #include "helpers/string.hpp" +#endif enum ITEMICON_RES_FILE_ID { ITEMICON_BTI_ARI_MESU_00=0x3, diff --git a/src/d/d_meter_button.cpp b/src/d/d_meter_button.cpp index 56d756ef44..5c4207b2c8 100644 --- a/src/d/d_meter_button.cpp +++ b/src/d/d_meter_button.cpp @@ -16,18 +16,15 @@ #include "d/d_msg_out_font.h" #include "d/d_msg_string.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" #include -#include "dusk/version.hpp" - #if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "dusk/version.hpp" #include "helpers/string.hpp" #endif -#if TARGET_PC -#define STR_BUF_LEN 528 -#elif VERSION == VERSION_GCN_JPN +#if TARGET_PC || VERSION == VERSION_GCN_JPN #define STR_BUF_LEN 528 #else #define STR_BUF_LEN 512 @@ -297,22 +294,19 @@ void dMeterButton_c::draw() { s16 temp_r6 = g_drawHIO.mEmpButton.mRepeatHitFrameNum; s16 temp_r6_2 = g_drawHIO.mEmpButton.mRepeatHitFrameNum / 2; -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x4b8[i]++; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x4b8[i]++; - if (field_0x4b8[i] >= temp_r6) { - field_0x4b8[i] = 0; + if (field_0x4b8[i] >= temp_r6) { + field_0x4b8[i] = 0; - if (field_0x4bc[i] == 0) { - field_0x4bc[i] = 1; - } else { - field_0x4bc[i] = 0; - } + if (field_0x4bc[i] == 0) { + field_0x4bc[i] = 1; + } else { + field_0x4bc[i] = 0; } } + IF_DUSK_BLOCK_END f32 var_f2; if (temp_r6_2 < field_0x4b8[i]) { @@ -384,8 +378,8 @@ void dMeterButton_c::draw() { } if (var_r3) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { +#if TARGET_PC + if (dusk::interp::get_ui_tick_pending()) { mWasListen[i] = var_r22; mWasRepeat[i] = var_r23; } else { @@ -394,11 +388,7 @@ void dMeterButton_c::draw() { } #endif if (var_r22) { -#ifdef TARGET_PC - if (field_0x2e8[i] == 18.0f && dusk::frame_interp::get_ui_tick_pending()) -#else - if (field_0x2e8[i] == 18.0f) -#endif + if (field_0x2e8[i] == 18.0f IF_DUSK(&& dusk::interp::get_ui_tick_pending())) { mDoAud_seStart(Z2SE_SY_HINT_BUTTON_BLINK, NULL, 0, 0); } diff --git a/src/d/d_meter_haihai.cpp b/src/d/d_meter_haihai.cpp index 5ea5dad5b7..59a69ed61e 100644 --- a/src/d/d_meter_haihai.cpp +++ b/src/d/d_meter_haihai.cpp @@ -11,7 +11,10 @@ #include "d/d_com_inf_game.h" #include "d/d_meter_HIO.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif dMeterHaihai_c::dMeterHaihai_c(u8 i_type) { mType = i_type; @@ -287,20 +290,17 @@ void dMeterHaihai_c::updateHaihai() { void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) { if (checkPlayAnime(1)) { if (i_bck != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed; - } else { - mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed; - } - - if (mBckFrame >= i_bck->getFrameMax()) { - mBckFrame -= i_bck->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed; + } else { + mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed; } + + if (mBckFrame >= i_bck->getFrameMax()) { + mBckFrame -= i_bck->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBtkFrame = 1.0f; } @@ -315,20 +315,17 @@ void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) { void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) { if (checkPlayAnime(2)) { if (i_btk != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed; - } else { - mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed; - } - - if (mBtkFrame >= i_btk->getFrameMax()) { - mBtkFrame -= i_btk->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed; + } else { + mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed; } + + if (mBtkFrame >= i_btk->getFrameMax()) { + mBtkFrame -= i_btk->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBtkFrame = 1.0f; } @@ -342,20 +339,17 @@ void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) { void dMeterHaihai_c::playBpkAnime(J2DAnmColor* i_bpk) { if (checkPlayAnime(0)) { if (i_bpk != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed; - } else { - mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed; - } - - if (mBpkFrame >= i_bpk->getFrameMax()) { - mBpkFrame -= i_bpk->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed; + } else { + mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed; } + + if (mBpkFrame >= i_bpk->getFrameMax()) { + mBpkFrame -= i_bpk->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBpkFrame = 1.0f; } diff --git a/src/d/d_meter_string.cpp b/src/d/d_meter_string.cpp index c99e7c564e..3bc5795dc0 100644 --- a/src/d/d_meter_string.cpp +++ b/src/d/d_meter_string.cpp @@ -16,9 +16,12 @@ #include "d/d_meter2_info.h" #include "d/d_meter_HIO.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + dMeterString_c::dMeterString_c(int i_stringID) { mpMapArchive = dComIfGp_getAllMapArchive(); field_0x28 = 0; @@ -106,27 +109,22 @@ void dMeterString_c::draw() { f32 var_f30 = 1.0f; if (mAnimFrame < 60.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed; - if (mAnimFrame > 60.0f) { - mAnimFrame = 60.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed; + if (mAnimFrame > 60.0f) { + mAnimFrame = 60.0f; } + IF_DUSK_BLOCK_END playBckAnimation(mAnimFrame); } else if (mAnimFrame < (f32)g_drawHIO.mMiniGame.mReadyFightTextWaitFrames + 60.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - mAnimFrame += var_f30; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += var_f30; + IF_DUSK_BLOCK_END } else if (mAnimFrame < var_f31) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - mAnimFrame += var_f30; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += var_f30; + IF_DUSK_BLOCK_END var_f30 = acc(g_drawHIO.mMiniGame.field_0x172, var_f31 - mAnimFrame, 0); } @@ -139,23 +137,17 @@ void dMeterString_c::draw() { if (mPikariAnimFrame > 0.0f) { drawPikari(); - } else if (mPikariAnimFrame == -1.0f && -#if TARGET_PC - dusk::frame_interp::get_ui_tick_pending() && -#endif + } else if (mPikariAnimFrame == -1.0f IF_DUSK(&& dusk::interp::get_ui_tick_pending()) && mAnimFrame > g_drawHIO.mMiniGame.mReadyFightPikariAppearFrames) { mPikariAnimFrame = 18.0f - g_drawHIO.mMiniGame.mReadyFightPikariAnimSpeed; } -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mAnimFrame >= var_f31) { - dMeter2Info_resetMeterString(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mAnimFrame >= var_f31) { + dMeter2Info_resetMeterString(); } + IF_DUSK_BLOCK_END } } } diff --git a/src/d/d_model.cpp b/src/d/d_model.cpp index bdff472367..c236b5f2db 100644 --- a/src/d/d_model.cpp +++ b/src/d/d_model.cpp @@ -6,7 +6,7 @@ #include "d/d_com_inf_game.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif void dMdl_c::draw() { @@ -52,7 +52,7 @@ void dMdl_c::entryObj(dMdl_obj_c* i_obj) { #ifdef TARGET_PC // if field_0x1a is false, this dMdl_c is not in the drawlist // if true, we need to make sure with interp enabled - if (dusk::frame_interp::is_enabled() && field_0x1a) { + if (dusk::interp::is_enabled() && field_0x1a) { auto pkt = dComIfGd_getListPacket()->mpBuffer[0]; while (pkt && pkt != this) { pkt = pkt->getNextPacket(); diff --git a/src/d/d_msg_class.cpp b/src/d/d_msg_class.cpp index 4358d6d5d2..0c2c3cf358 100644 --- a/src/d/d_msg_class.cpp +++ b/src/d/d_msg_class.cpp @@ -1,21 +1,21 @@ #include "d/dolzel.h" // IWYU pragma: keep +#include "d/d_msg_class.h" #include #include -#include "JSystem/J2DGraph/J2DTextBox.h" -#include "JSystem/JUtility/JUTFont.h" -#include "d/d_lib.h" #include "d/d_meter2_info.h" -#include "d/d_msg_class.h" #include "d/d_msg_object.h" -#include "d/d_msg_out_font.h" #include "d/d_msg_unit.h" -#include "dusk/version.hpp" +#include "JSystem/J2DGraph/J2DTextBox.h" +#include "d/d_msg_out_font.h" #include "m_Do/m_Do_graphic.h" +#include "d/d_lib.h" +#include "JSystem/JUtility/JUTFont.h" #if TARGET_PC #include "dusk/menu_pointer.h" #include "dusk/scope_guard.hpp" +#include "dusk/version.hpp" #include "helpers/bits.hpp" static bool read_full_color(const void* data, u32 size, u32& ccColor, u32& gcColor) { @@ -31,9 +31,7 @@ static bool read_full_color(const void* data, u32 size, u32& ccColor, u32& gcCol } return false; } -#endif -#if TARGET_PC #define CHAR_CODE_MALE_ICON (dusk::version::isRegionJpn() ? 0x8189 : 0xB2) #define CHAR_CODE_FEMALE_ICON (dusk::version::isRegionJpn() ? 0x818A : 0xB3) #define CHAR_CODE_STAR_ICON (dusk::version::isRegionJpn() ? 0x819A : 0xB1) diff --git a/src/d/d_msg_out_font.cpp b/src/d/d_msg_out_font.cpp index 79bbad5ebb..ce5e97c2d0 100644 --- a/src/d/d_msg_out_font.cpp +++ b/src/d/d_msg_out_font.cpp @@ -5,10 +5,13 @@ #include "d/d_meter2_info.h" #include "d/d_msg_object.h" #include "d/d_msg_out_font.h" -#include "dusk/frame_interpolation.h" -#include "dusk/version.hpp" #include "f_op/f_op_msg_mng.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#include "dusk/version.hpp" +#endif + COutFontSet_c::COutFontSet_c() { initialize(); } @@ -315,9 +318,8 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param sp256[i] = field_0x1b4[i]; } -#ifdef TARGET_PC - bool uiTickPending = dusk::frame_interp::get_ui_tick_pending(); - if (!uiTickPending) { +#if TARGET_PC + if (dusk::interp::get_ui_tick_pending()) { for (int i = 0; i < 70; i++) { sp256[i] = -1; } @@ -526,15 +528,12 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param case 20: case 21: case 22: -#ifdef TARGET_PC - if (uiTickPending) -#endif - { - field_0x1b4[type]++; - if (field_0x1b4[type] >= 28) { - field_0x1b4[type] = 0; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x1b4[type]++; + if (field_0x1b4[type] >= 28) { + field_0x1b4[type] = 0; } + IF_DUSK_BLOCK_END mpPane[type]->rotate(0.5f * sizeX, 0.5f * sizeY, ROTATE_Z, (360.0f * (f32)field_0x1b4[type]) / 28.0f); diff --git a/src/d/d_msg_scrn_3select.cpp b/src/d/d_msg_scrn_3select.cpp index b3a41a2988..b7e0e8a8db 100644 --- a/src/d/d_msg_scrn_3select.cpp +++ b/src/d/d_msg_scrn_3select.cpp @@ -5,20 +5,20 @@ #include "d/dolzel.h" // IWYU pragma: keep -#include +#include "d/d_msg_scrn_3select.h" #include "JSystem/J2DGraph/J2DAnmLoader.h" #include "JSystem/J2DGraph/J2DGrafContext.h" #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J2DGraph/J2DTextBox.h" +#include #include "d/d_com_inf_game.h" -#include "d/d_msg_object.h" -#include "d/d_msg_scrn_3select.h" -#include "d/d_pane_class.h" #include "d/d_select_cursor.h" -#include "dusk/version.hpp" +#include "d/d_msg_object.h" +#include "d/d_pane_class.h" #if TARGET_PC #include "dusk/menu_pointer.h" +#include "dusk/version.hpp" namespace { bool hit_choice_pane(CPaneMgr* pane, f32 padding) { diff --git a/src/d/d_msg_scrn_explain.cpp b/src/d/d_msg_scrn_explain.cpp index 9460ce8921..4771257ccd 100644 --- a/src/d/d_msg_scrn_explain.cpp +++ b/src/d/d_msg_scrn_explain.cpp @@ -14,7 +14,9 @@ #include #include +#if TARGET_PC #include "dusk/version.hpp" +#endif #if TARGET_PC || VERSION == VERSION_GCN_JPN #define STR_BUF_LEN 528 diff --git a/src/d/d_msg_scrn_howl.cpp b/src/d/d_msg_scrn_howl.cpp index 4e5c59546c..c87c4bbb0f 100644 --- a/src/d/d_msg_scrn_howl.cpp +++ b/src/d/d_msg_scrn_howl.cpp @@ -21,8 +21,7 @@ #include "m_Do/m_Do_graphic.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" +#include "dusk/interp/frame_interpolation.h" #endif // POSIX already defines a macro with this name, but we know that this specific name is @@ -596,15 +595,12 @@ void dMsgScrnHowl_c::drawWave() { f17 = local_60; f18 = local_64; } else { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x2134++; - if (field_0x2134 > 30) { - field_0x2134 = 0; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x2134++; + if (field_0x2134 > 30) { + field_0x2134 = 0; } + IF_DUSK_BLOCK_END if (field_0x2134 < 15) { local_dc = field_0x2134 / 15.0f; } else { diff --git a/src/d/d_msg_scrn_item.cpp b/src/d/d_msg_scrn_item.cpp index ab91739acc..17007403dc 100644 --- a/src/d/d_msg_scrn_item.cpp +++ b/src/d/d_msg_scrn_item.cpp @@ -24,7 +24,9 @@ #include "JSystem/JUtility/JUTTexture.h" #include +#if TARGET_PC #include "dusk/version.hpp" +#endif dMsgScrnItem_c::dMsgScrnItem_c(u8 param_1, u8 param_2, JKRExpHeap* param_3) { if (param_3 != NULL) { diff --git a/src/d/d_msg_scrn_kanban.cpp b/src/d/d_msg_scrn_kanban.cpp index 8e2346feab..7f254bbafb 100644 --- a/src/d/d_msg_scrn_kanban.cpp +++ b/src/d/d_msg_scrn_kanban.cpp @@ -12,10 +12,10 @@ #include "d/d_msg_out_font.h" #include "d/d_msg_scrn_kanban.h" #include "d/d_pane_class.h" -#include "dusk/version.hpp" #if TARGET_PC #include "dusk/settings.h" +#include "dusk/version.hpp" #endif dMsgScrnKanban_c::dMsgScrnKanban_c(JKRExpHeap* param_0) { diff --git a/src/d/d_msg_scrn_light.cpp b/src/d/d_msg_scrn_light.cpp index 19671b5d57..0d9f409978 100644 --- a/src/d/d_msg_scrn_light.cpp +++ b/src/d/d_msg_scrn_light.cpp @@ -6,7 +6,10 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "d/d_com_inf_game.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif class dMsgScrnLight_HIO_c { public: @@ -203,15 +206,12 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX } if (mPlayAnim) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_anmFrame += 1.0f; - if (*i_anmFrame >= mpBck->getFrameMax()) { - *i_anmFrame = 0.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_anmFrame += 1.0f; + if (*i_anmFrame >= mpBck->getFrameMax()) { + *i_anmFrame = 0.0f; } + IF_DUSK_BLOCK_END mBckFrame = *i_anmFrame; mBpkFrame = *i_anmFrame; @@ -226,16 +226,13 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX mpParent_c->setBlackWhite(i_black, i_white); if (mPlayAnim) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_anmFrame += i_anmRate; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_anmFrame += i_anmRate; - if (*i_anmFrame >= mpBck->getFrameMax()) { - *i_anmFrame = 0.0f; - } + if (*i_anmFrame >= mpBck->getFrameMax()) { + *i_anmFrame = 0.0f; } + IF_DUSK_BLOCK_END mBckFrame = *i_anmFrame; mBpkFrame = *i_anmFrame; diff --git a/src/d/d_msg_scrn_talk.cpp b/src/d/d_msg_scrn_talk.cpp index 6a30d08c47..1e63d67a9b 100644 --- a/src/d/d_msg_scrn_talk.cpp +++ b/src/d/d_msg_scrn_talk.cpp @@ -20,10 +20,9 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include -#include "dusk/version.hpp" - #if TARGET_PC #include "dusk/settings.h" +#include "dusk/version.hpp" #endif #if TARGET_PC diff --git a/src/d/d_msg_scrn_tree.cpp b/src/d/d_msg_scrn_tree.cpp index 440b2702d3..bbed47cb05 100644 --- a/src/d/d_msg_scrn_tree.cpp +++ b/src/d/d_msg_scrn_tree.cpp @@ -8,10 +8,10 @@ #include "d/d_msg_out_font.h" #include "d/d_msg_scrn_tree.h" #include "d/d_pane_class.h" -#include "dusk/version.hpp" #if TARGET_PC #include "dusk/settings.h" +#include "dusk/version.hpp" #endif dMsgScrnTree_c::dMsgScrnTree_c(JUTFont* param_0, JKRExpHeap* param_1) { diff --git a/src/d/d_name.cpp b/src/d/d_name.cpp index aa01a39de4..89506e8078 100644 --- a/src/d/d_name.cpp +++ b/src/d/d_name.cpp @@ -8,23 +8,19 @@ #include "m_Do/m_Do_controller_pad.h" #include #include - #include "JSystem/J2DGraph/J2DAnmLoader.h" +#include "f_op/f_op_msg_mng.h" + +#if TARGET_PC #include "dusk/utilities.hpp" #include "dusk/version.hpp" -#include "f_op/f_op_msg_mng.h" static bool isPalOrJpn() { return dusk::version::isRegionPal() || dusk::version::isRegionJpn(); } -#if TARGET_PC #define SJIS_MOJI(wmoji) ((static_cast(static_cast((wmoji)[0])) << 8) | static_cast((wmoji)[1])) -#else -#define SJIS_MOJI(wmoji) *(u16*)wmoji -#endif -#if TARGET_PC static const char* l_mojiHira[65] = { "\x82\xA0", "\x82\xA2", "\x82\xA4", "\x82\xA6", "\x82\xA8", "\x82\xA9", "\x82\xAB", "\x82\xAD", "\x82\xAF", "\x82\xB1", "\x82\xB3", "\x82\xB5", "\x82\xB7", "\x82\xB9", "\x82\xBB", "\x82\xBD", "\x82\xBF", "\x82\xC2", "\x82\xC4", "\x82\xC6", "\x82\xC8", "\x82\xC9", "\x82\xCA", "\x82\xCB", "\x82\xCC", "\x82\xCD", @@ -80,6 +76,8 @@ static const char* l_mojiEisu[65] = { "X", "k", "x", ",", "L", "Y", "l", "y", ".", "M", "Z", "m", "z", " ", }; #else +#define SJIS_MOJI(wmoji) *(u16*)wmoji + static const char* l_mojiHira[65] = { "あ", "い", "う", "え", "お", "か", "き", "く", "け", "こ", "さ", "し", "す", "せ", "そ", "た", "ち", "つ", "て", "と", "な", "に", "ぬ", "ね", "の", "は", @@ -1090,9 +1088,7 @@ void dName_c::selectCursorMove() { ((J2DTextBox*)mMojiIcon[mCharRow + mCharColumn * 5]->getPanePtr()) ->setWhite(JUtility::TColor(0xC8, 0xC8, 0xC8, 0xFF)); - #if TARGET_PC - nameWide(); - #endif + IF_DUSK(nameWide()); Vec pos = mMojiIcon[mCharRow + mCharColumn * 5]->getGlobalVtxCenter(false, 0); mSelIcon->setPos(pos.x, pos.y, mMojiIcon[mCharRow + mCharColumn * 5]->getPanePtr(), true); diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index e33de068db..d1e175dfc1 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -8,30 +8,27 @@ // weak data from it (unlike here). #include "d/d_particle.h" -#include -#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" -#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include "d/d_jnt_col.h" #include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JKernel/JKRSolidHeap.h" -#include "JSystem/JMath/JMATrigonometric.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" #include "JSystem/JParticle/JPAEmitterManager.h" #include "JSystem/JParticle/JPAResourceManager.h" -#include "SSystem/SComponent/c_math.h" -#include "d/actor/d_a_player.h" -#include "d/d_com_inf_game.h" -#include "d/d_jnt_col.h" +#include "JSystem/JMath/JMATrigonometric.h" #include "d/d_s_play.h" -#include "f_op/f_op_actor_mng.h" -#include "m_Do/m_Do_graphic.h" +#include +#include "d/d_com_inf_game.h" #include "m_Do/m_Do_lib.h" -#include "tracy/Tracy.hpp" +#include "m_Do/m_Do_graphic.h" +#include "f_op/f_op_actor_mng.h" +#include "d/actor/d_a_player.h" +#include "SSystem/SComponent/c_math.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif +#include "dusk/game_clock.h" -#ifndef __MWERKS__ -#include "helpers/math.h" +#include #endif #if DEBUG @@ -1979,7 +1976,7 @@ void dPa_light8PcallBack::draw(JPABaseEmitter* param_1, JPABaseParticle* param_2 JGeometry::TVec3 local_160; JGeometry::TVec3 local_16c; #if TARGET_PC - if (dusk::frame_interp::is_sim_frame()) + if (dusk::game_clock::is_sim_frame()) #endif { dPa_setWindPower(param_2); diff --git a/src/d/d_resorce.cpp b/src/d/d_resorce.cpp index 97a230b2e0..26295158f4 100644 --- a/src/d/d_resorce.cpp +++ b/src/d/d_resorce.cpp @@ -95,13 +95,28 @@ static void setIndirectTex(J3DModelData* i_modelData) { for (u16 i = 0; i < texture->getNum(); i++) { textureName = nameTab->getName(i); +#if TARGET_PC + if (textureName == NULL) { + continue; + } + if (strcmp(textureName, "fbtex_dummy") == 0) { +#else if (memcmp(textureName, "fbtex_dummy", 0xc) == 0) { +#endif texture->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg()); } +#if TARGET_PC + if (strcmp(textureName, "dummy") == 0) { +#else if (memcmp(textureName, "dummy", 6) == 0) { +#endif texture->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg()); } +#if TARGET_PC + if (strcmp(textureName, "Zbuffer") == 0) { +#else if (memcmp(textureName, "Zbuffer", 8) == 0) { +#endif texture->setResTIMG(i, *mDoGph_gInf_c::getZbufferTimg()); } } diff --git a/src/d/d_s_name.cpp b/src/d/d_s_name.cpp index de66b0317d..7faabde76b 100644 --- a/src/d/d_s_name.cpp +++ b/src/d/d_s_name.cpp @@ -5,29 +5,25 @@ #include "d/dolzel.h" // IWYU pragma: keep +#include "d/d_s_name.h" #include "JSystem/JKernel/JKRExpHeap.h" #include "d/d_com_inf_game.h" #include "d/d_meter2_info.h" -#include "d/d_s_name.h" -#include "f_op/f_op_overlap_mng.h" #include "f_op/f_op_scene_mng.h" #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_machine.h" -#include "m_Do/m_Do_main.h" #include "m_Do/m_Do_mtx.h" +#include "m_Do/m_Do_main.h" +#include "f_op/f_op_overlap_mng.h" -#ifdef TARGET_PC +#if TARGET_PC #include "dusk/autosave.h" #include "dusk/game_mode.hpp" #include "dusk/imgui/ImGuiConsole.hpp" -#include "dusk/livesplit.h" #include "dusk/memory.h" #include "dusk/settings.h" -#include "dusk/speedrun.h" -#endif -#if TARGET_PC #define SHOW_TV_SETTINGS_SCREEN (this->mShowTvSettingsScreen) #else #define SHOW_TV_SETTINGS_SCREEN (1) diff --git a/src/d/d_save.cpp b/src/d/d_save.cpp index 7caba5c9c8..6a4d4c3c05 100644 --- a/src/d/d_save.cpp +++ b/src/d/d_save.cpp @@ -16,8 +16,6 @@ #include #include -#include "dusk/version.hpp" - #if PLATFORM_WII || PLATFORM_SHIELD #include #include @@ -28,11 +26,11 @@ #endif #if TARGET_PC -#include #include "dusk/game_mode.hpp" #include "dusk/settings.h" - +#include "dusk/version.hpp" #include "helpers/string.hpp" + #define strcpy SafeStringCopy #endif diff --git a/src/d/d_select_cursor.cpp b/src/d/d_select_cursor.cpp index 640f8072cd..4fcc6fd5f8 100644 --- a/src/d/d_select_cursor.cpp +++ b/src/d/d_select_cursor.cpp @@ -5,9 +5,12 @@ #include "d/d_com_inf_game.h" #include "JSystem/J2DGraph/J2DAnimation.h" #include "JSystem/J2DGraph/J2DAnmLoader.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + dSelect_cursorHIO_c::dSelect_cursorHIO_c() { field_0x8 = 1.0f; mXAxisExpansion = 1.0f; @@ -281,21 +284,18 @@ void dSelect_cursor_c::update() { if (mUpdateFlag) { if (field_0x30) { if (chkPlayAnime(0)) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x44 += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x44 += fVar1; - } - - if (field_0x44 >= field_0x30->getFrameMax()) { - field_0x44 -= field_0x30->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x44 += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x44 += fVar1; } + if (field_0x44 >= field_0x30->getFrameMax()) { + field_0x44 -= field_0x30->getFrameMax(); + } + IF_DUSK_BLOCK_END + field_0x30->setFrame(field_0x44); setBpkAnimation(field_0x30); } else { @@ -310,19 +310,16 @@ void dSelect_cursor_c::update() { for (int i = 0; i < 2; i++) { if (field_0x34[i]) { if ((i == 0 && chkPlayAnime(2)) || (i == 1 && chkPlayAnime(3))) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x48[i] += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x48[i] += fVar1; - } - if (field_0x48[i] >= field_0x34[i]->getFrameMax()) { - field_0x48[i] -= field_0x34[i]->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x48[i] += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x48[i] += fVar1; } + if (field_0x48[i] >= field_0x34[i]->getFrameMax()) { + field_0x48[i] -= field_0x34[i]->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x34[i]->setFrame(field_0x48[i]); } @@ -331,19 +328,16 @@ void dSelect_cursor_c::update() { } if (field_0x2C && chkPlayAnime(1)) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x40 += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x40 += fVar1; - } - if (field_0x40 >= field_0x2C->getFrameMax()) { - field_0x40 -= field_0x2C->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x40 += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x40 += fVar1; } + if (field_0x40 >= field_0x2C->getFrameMax()) { + field_0x40 -= field_0x2C->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x2C->setFrame(field_0x40); setBckAnimation(field_0x2C); @@ -351,12 +345,9 @@ void dSelect_cursor_c::update() { } if (chkPlayAnime(1) && mNameIdx == 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - setCursorAnimation(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + setCursorAnimation(); + IF_DUSK_BLOCK_END } mpScreen->animation(); diff --git a/src/d/d_select_icon.cpp b/src/d/d_select_icon.cpp index 32be9c15e2..e55beaf54c 100644 --- a/src/d/d_select_icon.cpp +++ b/src/d/d_select_icon.cpp @@ -2,31 +2,28 @@ #include "d/d_select_icon.h" #include "JSystem/J2DGraph/J2DAnimation.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif dSi_HIO_c::dSi_HIO_c() {} void dSelect_icon_c::animation() { if (field_0x10->getAlpha() != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x20 += field_0x2c; - if (field_0x20 >= field_0x1c->getFrameMax()) { - field_0x20 = 0.0f; - } - field_0x1c->setFrame(field_0x20); - - field_0x28 += field_0x2c; - if (field_0x28 >= field_0x24->getFrameMax()) { - field_0x28 = 0.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x20 += field_0x2c; + if (field_0x20 >= field_0x1c->getFrameMax()) { + field_0x20 = 0.0f; } -#ifdef TARGET_PC - // FRAME INTERP NOTE: Set even if not advancing field_0x1c->setFrame(field_0x20); -#endif + + field_0x28 += field_0x2c; + if (field_0x28 >= field_0x24->getFrameMax()) { + field_0x28 = 0.0f; + } + IF_DUSK_BLOCK_END + IF_DUSK(field_0x1c->setFrame(field_0x20)); // FRAME INTERP NOTE: Set even if not advancing field_0x24->setFrame(field_0x28); field_0x8->animation(); diff --git a/src/d/d_shop_system.cpp b/src/d/d_shop_system.cpp index 1d7fed2406..1ff45e19a7 100644 --- a/src/d/d_shop_system.cpp +++ b/src/d/d_shop_system.cpp @@ -718,13 +718,21 @@ int dShopSystem_c::itemRotate() { return 1; } +#if TARGET_PC +#define D_SHOP_SELECTED_ITEM_NO \ + ((mCursorPos > 0 && mCursorPos <= ITEM_MAX_e) ? dShopSystem_itemNo[mCursorPos - 1] : \ + dItemNo_NONE_e) +#else +#define D_SHOP_SELECTED_ITEM_NO dShopSystem_itemNo[mCursorPos - 1] +#endif + int dShopSystem_c::itemZoom(cXyz* param_0) { cXyz local_1c; if (field_0xf60 >= 0) { local_1c.set(*param_0); - if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_OIL_BOTTLE_e) { + if (D_SHOP_SELECTED_ITEM_NO == dItemNo_OIL_BOTTLE_e) { mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mSeraShopObjZoomAngleX + -5000, isFlag(8) ? true : false); @@ -775,9 +783,9 @@ int dShopSystem_c::itemZoom(cXyz* param_0) { g_cursorHIO.mObjZoom.z + 150.0f); } else { if (mMasterType == 5) { - if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_10_e || - dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_20_e || - dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_30_e) + if (D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_10_e || + D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_20_e || + D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_30_e) { local_34.set(g_cursorHIO.mObjZoom.x, -50.0f + g_cursorHIO.mObjZoom.y + 5.0f, (g_cursorHIO.mObjZoom.z + 250.0f) - 60.0f); @@ -808,7 +816,7 @@ int dShopSystem_c::itemZoom(cXyz* param_0) { u8 dvar1 = mMasterType; if (dvar1 == 1) { - if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_OIL_BOTTLE_e) { + if (D_SHOP_SELECTED_ITEM_NO == dItemNo_OIL_BOTTLE_e) { mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mShopObjZoomAngleX + -7000, isFlag(8) ? true : false); @@ -817,7 +825,7 @@ int dShopSystem_c::itemZoom(cXyz* param_0) { isFlag(8) ? true : false); } } else if (dvar1 == 2) { - if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_RED_BOTTLE_e) { + if (D_SHOP_SELECTED_ITEM_NO == dItemNo_RED_BOTTLE_e) { mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mShopObjZoomAngleX - 3000, isFlag(8) ? true : false); } else { @@ -825,9 +833,9 @@ int dShopSystem_c::itemZoom(cXyz* param_0) { isFlag(8) ? true : false); } } else if (dvar1 == 5) { - if (dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_10_e || - dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_20_e || - dShopSystem_itemNo[mCursorPos - 1] == dItemNo_ARROW_30_e) + if (D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_10_e || + D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_20_e || + D_SHOP_SELECTED_ITEM_NO == dItemNo_ARROW_30_e) { mItemCtrl.setZoomAnime(mCursorPos, &local_1c, g_cursorHIO.mShopObjZoomAngleX - 4000, isFlag(8) ? true : false); @@ -850,6 +858,8 @@ int dShopSystem_c::itemZoom(cXyz* param_0) { return 1; } +#undef D_SHOP_SELECTED_ITEM_NO + int dShopSystem_c::seq_wait(fopAc_ac_c* param_0, dMsgFlow_c* param_1) { return 0; } diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 0b933bdb34..14167723d9 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -22,11 +22,12 @@ #include #include -#include "dusk/logging.h" -#include "helpers/string.hpp" #if TARGET_PC +#include "dusk/logging.h" +#include "dusk/mods/svc/actor.hpp" #include "dusk/mods/svc/stage.hpp" -#include +#include "helpers/string.hpp" + #include #endif @@ -1524,6 +1525,14 @@ static void dummy0() { } dStage_objectNameInf* dStage_searchName(char const* objName) { +#if TARGET_PC + dStage_objectNameInf* info = + dusk::mods::svc::actor_impl::get_stageinfo_from_full_name(objName); + if (info != nullptr) { + return info; + } +#endif + dStage_objectNameInf* obj = l_objectName; for (u32 i = 0; i < ARRAY_SIZEU(l_objectName); i++) { @@ -1561,6 +1570,15 @@ dStage_objectNameInf* dStage_searchNameCI(char const* objName) { const char* dStage_getName(s16 procName, s8 argument) { static char tmp_name[dStage_NAME_LENGTH]; +#if TARGET_PC + const char* name = dusk::mods::svc::actor_impl::get_full_name_from_proc_name(procName); + if (name[0] != '\0') { + strncpy(tmp_name, name, sizeof(tmp_name) - 1); + tmp_name[sizeof(tmp_name) - 1] = '\0'; + return tmp_name; + } +#endif + dStage_objectNameInf* obj = l_objectName; char* tmp = NULL; @@ -1614,17 +1632,15 @@ DUSK_GAME_DATA dStage_roomControl_c::roomDzs_c dStage_roomControl_c::m_roomDzs; u8 dStage_roomControl_c::mNoArcBank; #endif +static void dStage_actorCreate(stage_actor_data_class* i_actorData, fopAcM_prm_class* i_actorPrm + IF_DUSK_ARG(size_t recordSize = sizeof(stage_actor_data_class))) { #if TARGET_PC -static void dStage_actorCreate(stage_actor_data_class* i_actorData, fopAcM_prm_class* i_actorPrm, - size_t recordSize = sizeof(stage_actor_data_class)) { if (!dusk::mods::svc::stage_apply_actor_edits(i_actorData, i_actorPrm, recordSize, i_actorPrm->room_no)) { JKRFree(i_actorPrm); return; } -#else -static void dStage_actorCreate(stage_actor_data_class* i_actorData, fopAcM_prm_class* i_actorPrm) { #endif dStage_objectNameInf* actorInf = dStage_searchName(i_actorData->name); @@ -1687,6 +1703,8 @@ static int dStage_playerInit(dStage_dt_c* i_stage, void* i_data, int num, void* fopAcM_prm_class* appen = fopAcM_CreateAppend(); JUT_ASSERT(1586, appen != NULL); + IF_DUSK(stage_actor_data_class newPoint{};) // data stored on the stack for any newly registered spawn points + int point = dComIfGp_getStartStagePoint(); u32 roomParam = dComIfGs_getRestartRoomParam(); if (point == -2 || point == -3) { @@ -1707,6 +1725,13 @@ static int dStage_playerInit(dStage_dt_c* i_stage, void* i_data, int num, void* int i; for (i = 0; i < num; i++) { +#ifdef TARGET_PC + // If, for whatever reason, we want to patch the point ID, we need to do it here. + if (!dusk::mods::svc::stage_apply_actor_edits(player_data, nullptr, sizeof(*player_data), i_stage->getRoomNo())) { + player_data++; + continue; // If the spawn is deleted, check the next one + } +#endif if ((u8)player_data->base.angle.z == unk) { break; } @@ -1714,16 +1739,43 @@ static int dStage_playerInit(dStage_dt_c* i_stage, void* i_data, int num, void* } if (i == num) { #if TARGET_PC - std::vector valid_points; - valid_points.reserve(num); - player_data = player->m_entries; - for (i = 0; i < num; i++) { - valid_points.push_back(player_data->base.angle.z); - player_data++; + // Search through all new actor edits and return the point data via userdata + struct newActors_userData { + stage_actor_data_class* out_point; + bool out_pointSet; + int16_t pointNo; + }; + newActors_userData params = { + &newPoint, false, (int16_t)unk + }; + dusk::mods::svc::stage_create_new_actors(i_stage->getRoomNo(), + [](void* user, const void* record, size_t size) { + const stage_actor_data_class* i_record = static_cast(record); + auto* params = static_cast(user); + + // We don't cast i_record->base.angle.z to a u8 here so we can register any spawn point within the s16 range + if (i_record->base.angle.z == params->pointNo && size == sizeof(stage_actor_data_class) && strncmp(i_record->name,"Link",7) == 0) { + std::memcpy(params->out_point, i_record, size); + params->out_pointSet = true; + } + }, + ¶ms); + + if (params.out_pointSet) { + player_data = &newPoint; + } else { + // If the requested spawn point isn't found, print all valid points within the log + std::vector valid_points; + valid_points.reserve(num); + player_data = player->m_entries; + for (i = 0; i < num; i++) { + valid_points.push_back(player_data->base.angle.z); + player_data++; + } + std::ranges::sort(valid_points); + DuskLog.fatal("Failed to find player start point for next stage! Requested point: {}, Valid points: [{}]", + point, fmt::join(valid_points, ", ")); } - std::ranges::sort(valid_points); - DuskLog.fatal("Failed to find player start point for next stage! Requested point: {}, Valid points: [{}]", - point, fmt::join(valid_points, ", ")); #else OS_REPORT_ERROR("プレイヤーが発見できません。[No.%d]\n切り替えの情報や処理の確認をお願いします。\n", point); #endif @@ -2129,12 +2181,8 @@ static int dStage_doorInfoInit(dStage_dt_c* i_stage, void* i_data, int entryNum, appen->base = actor_data->base; appen->room_no = (int)i_stage->getRoomNo(); appen->scale = tgsc_data->scale; -#if TARGET_PC - dStage_actorCreate(actor_data, appen, - sizeof(stage_actor_data_class) + sizeof(fopAcM_prmScale_class)); -#else - dStage_actorCreate(actor_data, appen); -#endif + dStage_actorCreate(actor_data, appen IF_DUSK_ARG( + sizeof(stage_actor_data_class) + sizeof(fopAcM_prmScale_class))); } tgsc_data++; } @@ -2567,6 +2615,11 @@ static void dusk_stage_svc_new_actor_create(dStage_dt_c* i_stage) { stage_tgsc_data_class object{}; std::memcpy(&object, record, size); + if (strncmp(object.name,"Link",7) == 0) { + // We create new spawns for Link during dStage_playerInit. Ignore them here so we don't get duplicates. + return; + } + fopAcM_prm_class* appen = fopAcM_CreateAppend(); if (appen != nullptr) { appen->base = object.base; @@ -2778,9 +2831,7 @@ void dStage_dt_c_roomReLoader(void* i_data, dStage_dt_c* i_stage, int param_2) { }; dStage_dt_c_decode(i_data, i_stage, l_funcTable, ARRAY_SIZEU(l_funcTable)); -#if TARGET_PC - dusk_stage_svc_new_actor_create(i_stage); -#endif + IF_DUSK(dusk_stage_svc_new_actor_create(i_stage)); layerActorLoader(i_data, i_stage, param_2); } diff --git a/src/d/d_timer.cpp b/src/d/d_timer.cpp index e07cc3af80..df1a3ef104 100644 --- a/src/d/d_timer.cpp +++ b/src/d/d_timer.cpp @@ -23,8 +23,10 @@ #include "m_Do/m_Do_lib.h" #include -#include "dusk/frame_interpolation.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" #include "dusk/version.hpp" +#endif static int dTimer_createStart2D(s32 param_0, u16 param_1); @@ -1340,23 +1342,20 @@ void dDlst_TimerScrnDraw_c::draw() { ((f32)g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f); for (int i = 0; i < 51; i++) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { - if (m_getin_info[i].bck_frame < 60.0f) { - m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed; - if (m_getin_info[i].bck_frame > 60.0f) { - m_getin_info[i].bck_frame = 60.0f; - } - } else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) { - m_getin_info[i].bck_frame++; - } else if (m_getin_info[i].bck_frame < temp) { - m_getin_info[i].bck_frame++; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { + if (m_getin_info[i].bck_frame < 60.0f) { + m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed; + if (m_getin_info[i].bck_frame > 60.0f) { + m_getin_info[i].bck_frame = 60.0f; } + } else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) { + m_getin_info[i].bck_frame++; + } else if (m_getin_info[i].bck_frame < temp) { + m_getin_info[i].bck_frame++; } } + IF_DUSK_BLOCK_END if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { f32 var_f29 = 1.0f; @@ -1396,20 +1395,17 @@ void dDlst_TimerScrnDraw_c::draw() { if (m_getin_info[i].pikari_frame > 0.0f) { drawPikari(i); } else if (m_getin_info[i].pikari_frame == -1.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (m_getin_info[i].field_0xc == 0) { - if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) { - m_getin_info[i].pikari_frame = - 18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed; - } - } else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) { + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (m_getin_info[i].field_0xc == 0) { + if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) { m_getin_info[i].pikari_frame = - 18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed; + 18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed; } + } else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) { + m_getin_info[i].pikari_frame = + 18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed; } + IF_DUSK_BLOCK_END } } } diff --git a/src/dusk/achievements.h b/src/dusk/achievements.h index c93ea5d626..eec7fc6d5a 100644 --- a/src/dusk/achievements.h +++ b/src/dusk/achievements.h @@ -1,13 +1,12 @@ #pragma once +#include + #include #include -#include -#include #include #include #include -#include "nlohmann/json.hpp" namespace dusk { diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index c919c9d4fe..2c97c2c894 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -1,9 +1,10 @@ #include "dusk/action_bindings.h" -#include "aurora/lib/input.hpp" #include "dusk/settings.h" #include "dusk/ui/ui.hpp" +#include + namespace dusk { static std::array(ActionBinds::COUNT)>, PAD_CHANMAX> actionPressData{}; diff --git a/src/dusk/audio/DuskAudioSystem.cpp b/src/dusk/audio/DuskAudioSystem.cpp index b1c36b419c..90ab355228 100644 --- a/src/dusk/audio/DuskAudioSystem.cpp +++ b/src/dusk/audio/DuskAudioSystem.cpp @@ -1,20 +1,21 @@ -#include "dusk/audio/DuskAudioSystem.h" +#include "DuskAudioSystem.h" -#include -#include -#include -#include +#include "DuskDsp.hpp" #include "JSystem/JAudio2/JASAiCtrl.h" +#include "JSystem/JAudio2/JASAudioThread.h" #include "JSystem/JAudio2/JASChannel.h" #include "JSystem/JAudio2/JASCriticalSection.h" +#include "JSystem/JAudio2/JASDriverIF.h" #include "JSystem/JAudio2/JASDSPChannel.h" #include "JSystem/JAudio2/JASHeapCtrl.h" -#include "DuskDsp.hpp" -#include "JSystem/JAudio2/JASAudioThread.h" -#include "JSystem/JAudio2/JASDriverIF.h" -#include "tracy/Tracy.hpp" +#include +#include + +#include +#include +#include using namespace dusk::audio; diff --git a/src/dusk/audio/DuskDsp.cpp b/src/dusk/audio/DuskDsp.cpp index d8293b4cd2..2e3c14cad7 100644 --- a/src/dusk/audio/DuskDsp.cpp +++ b/src/dusk/audio/DuskDsp.cpp @@ -1,23 +1,23 @@ +#include "DuskDsp.hpp" + +#include "Adpcm.hpp" +#include "DuskAudioSystem.h" +#include "global.h" + +#include "dusk/logging.h" +#include "helpers/endian.h" + #include #include - -#include "DuskDsp.hpp" +#include +#include #include #include #include -#include #include #include -#include "Adpcm.hpp" -#include "dusk/audio/DuskAudioSystem.h" -#include "dusk/logging.h" -#include "freeverb/revmodel.hpp" -#include "global.h" -#include "helpers/endian.h" -#include "tracy/Tracy.hpp" - using namespace dusk::audio; ChannelAuxData dusk::audio::ChannelAux[DSP_CHANNELS] = {}; diff --git a/src/dusk/audio/DuskDsp.hpp b/src/dusk/audio/DuskDsp.hpp index 47900233a5..bef422b956 100644 --- a/src/dusk/audio/DuskDsp.hpp +++ b/src/dusk/audio/DuskDsp.hpp @@ -1,13 +1,14 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "global.h" #include "JSystem/JAudio2/JASDSPInterface.h" +#include + #include #include -// ReSharper disable once CppUnusedIncludeDirective -#include "global.h" - namespace dusk::audio { constexpr int SampleRate = 32000; diff --git a/src/dusk/audio/JASCriticalSection.cpp b/src/dusk/audio/JASCriticalSection.cpp index 9baf2d9bac..73a2671630 100644 --- a/src/dusk/audio/JASCriticalSection.cpp +++ b/src/dusk/audio/JASCriticalSection.cpp @@ -1,8 +1,8 @@ #include "JSystem/JAudio2/JASCriticalSection.h" -#include +#include -#include "tracy/Tracy.hpp" +#include static TracyLockable(std::recursive_mutex, gAudioThreadMutex); diff --git a/src/dusk/autosave.cpp b/src/dusk/autosave.cpp index bae2812a1f..e53395d9b6 100644 --- a/src/dusk/autosave.cpp +++ b/src/dusk/autosave.cpp @@ -1,8 +1,13 @@ #include "dusk/autosave.h" + #include "dusk/ui/ui.hpp" #include "imgui/ImGuiConsole.hpp" #include "mods/svc/save.hpp" +#include "d/actor/d_a_alink.h" +#include "m_Do/m_Do_MemCard.h" +#include "m_Do/m_Do_MemCardRWmng.h" + bool shouldAutoSave = false; u8 mSaveBuffer[QUEST_LOG_SIZE * 3]; u8 mAutoSaveProc = 0; diff --git a/src/dusk/autosave.h b/src/dusk/autosave.h index 2ab0887295..d9e83b442a 100644 --- a/src/dusk/autosave.h +++ b/src/dusk/autosave.h @@ -1,9 +1,5 @@ #pragma once -#include -#include -#include - void noAutoSave(); void triggerAutoSave(); void updateAutoSave(); diff --git a/src/dusk/commands.cpp b/src/dusk/commands.cpp index b953095936..b4267700da 100644 --- a/src/dusk/commands.cpp +++ b/src/dusk/commands.cpp @@ -1,31 +1,33 @@ #include "commands.hpp" -#include "JSystem/JUtility/JUTGamePad.h" -#include "SSystem/SComponent/c_math.h" -#include "SSystem/SComponent/c_sxyz.h" -#include "SSystem/SComponent/c_xyz.h" +#include "game_clock.h" + #include "c/c_damagereaction.h" #include "d/actor/d_a_alink.h" +#include "d/d_camera.h" #include "d/d_com_inf_actor.h" #include "d/d_com_inf_game.h" -#include "d/d_camera.h" #include "d/d_kankyo.h" #include "d/d_stage.h" -#include "dusk/game_clock.h" #include "f_op/f_op_actor_mng.h" #include "f_pc/f_pc_layer.h" #include "f_pc/f_pc_layer_iter.h" #include "f_pc/f_pc_manager.h" #include "f_pc/f_pc_node.h" +#include "JSystem/JUtility/JUTGamePad.h" +#include "SSystem/SComponent/c_math.h" +#include "SSystem/SComponent/c_sxyz.h" +#include "SSystem/SComponent/c_xyz.h" + +#include + #include #include #include #include #include -#include "fmt/format.h" - namespace dusk { namespace { diff --git a/src/dusk/config.cpp b/src/dusk/config.cpp index 51c8a7a16c..1749e964d7 100644 --- a/src/dusk/config.cpp +++ b/src/dusk/config.cpp @@ -1,12 +1,16 @@ #include "dusk/config.hpp" -#include "absl/container/flat_hash_map.h" -#include "fmt/format.h" -#include "nlohmann/json.hpp" +#include "dusk/action_bindings.h" #include "dusk/io.hpp" -#include +#include "dusk/logging.h" +#include "dusk/main.h" #include "dusk/settings.h" +#include +#include +#include +#include + #include #include #include @@ -18,10 +22,6 @@ #include #include -#include "dusk/action_bindings.h" -#include "dusk/logging.h" -#include "dusk/main.h" - namespace dusk::config { namespace { constexpr auto ConfigFileName = "config.json"; diff --git a/src/dusk/discord_presence.cpp b/src/dusk/discord_presence.cpp index 6eca5d2186..29e4f27617 100644 --- a/src/dusk/discord_presence.cpp +++ b/src/dusk/discord_presence.cpp @@ -1,14 +1,15 @@ #if BOREALIS_HAS_DISCORD +#include "discord_presence.hpp" + +#include "app_info.hpp" +#include "logging.h" +#include "main.h" +#include "map_loader_definitions.h" -#include "dusk/discord_presence.hpp" #include "d/d_com_inf_game.h" -#include "dusk/app_info.hpp" -#include "dusk/logging.h" -#include "dusk/main.h" -#include "dusk/map_loader_definitions.h" -#include "fmt/format.h" #include +#include #include #include diff --git a/src/dusk/dusk.h b/src/dusk/dusk.h index b95b33515e..e360a24d26 100644 --- a/src/dusk/dusk.h +++ b/src/dusk/dusk.h @@ -1,8 +1,7 @@ #pragma once #include - -#include "aurora/gfx.h" +#include extern AuroraInfo auroraInfo; diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index f5c8e73d4d..335b1c5572 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -1,12 +1,13 @@ #include "dusk/dvd_asset.hpp" + #include "dusk/logging.h" #include "helpers/endian.h" -#include "dolphin/dvd.h" + #include "DynamicLink.h" #include "JSystem/JKernel/JKRArchive.h" #include "JSystem/JKernel/JKRDvdRipper.h" -#include +#include namespace dusk { diff --git a/src/dusk/frame_interpolation.cpp b/src/dusk/frame_interpolation.cpp deleted file mode 100644 index ca30ec0db5..0000000000 --- a/src/dusk/frame_interpolation.cpp +++ /dev/null @@ -1,463 +0,0 @@ -#include "dusk/frame_interpolation.h" - -#include "f_op/f_op_camera_mng.h" -#include "m_Do/m_Do_graphic.h" -#include "mtx.h" - -#include - -namespace { - -struct Recording { - absl::flat_hash_map matrix_values; -}; - -bool s_initialized = false; - -bool g_enabled = false; -bool g_recording = false; -bool g_interpolating = false; -bool g_sync_presentation = false; - -float g_step = 0.0f; -bool g_is_sim_frame = false; -bool g_ui_tick_pending = false; -uint64_t g_sim_tick_seq = 0; - -Recording g_current_recording; -Recording g_previous_recording; - -absl::flat_hash_map g_replacements; - -struct CameraSnapshot { - cXyz eye{}; - cXyz center{}; - cXyz up{}; - s16 bank{}; - f32 fovy{}; - f32 aspect{}; - f32 near_{}; - f32 far_{}; - bool wideZoom{}; - bool valid{}; -}; - -CameraSnapshot s_cam_prev{}; -CameraSnapshot s_cam_curr{}; - -view_class s_presentation_view_backup{}; -int s_presentation_depth = 0; - -struct InterpolationCallBackWork { - dusk::frame_interp::InterpolationCallBack pCallBack; - void* pUserWork; -}; - -std::vector s_interpolationCallBackWork; - -void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) { - dst->eye = v.lookat.eye; - dst->center = v.lookat.center; - dst->up = v.lookat.up; - dst->bank = v.bank; - dst->fovy = v.fovy; - dst->aspect = v.aspect; - dst->near_ = v.near_; - dst->far_ = v.far_; - dst->valid = true; -} - -inline void lerp_matrix(Mtx out, const Mtx lhs, const Mtx rhs, float step) { - for (size_t row = 0; row < 3; ++row) { - for (size_t col = 0; col < 4; ++col) { - const float l = lhs[row][col]; - out[row][col] = l + (rhs[row][col] - l) * step; - } - } -} - -inline void lerp_xyz(cXyz* out, const cXyz& lhs, const cXyz& rhs, float step) { - out->x = lhs.x + (rhs.x - lhs.x) * step; - out->y = lhs.y + (rhs.y - lhs.y) * step; - out->z = lhs.z + (rhs.z - lhs.z) * step; -} - -static s16 lerp_bank(s16 a, s16 b, f32 t) { - const f32 ra = S2RAD(a); - const f32 d = remainderf(S2RAD(b) - ra, 2.0f * static_cast(M_PI)); - return cAngle::Radian_to_SAngle(ra + d * t); -} - -inline bool matrix_differs(const Mtx lhs, const Mtx rhs, float epsilon = 0.0001f) { - for (size_t row = 0; row < 3; ++row) { - for (size_t col = 0; col < 4; ++col) { - if (std::abs(lhs[row][col] - rhs[row][col]) > epsilon) { - return true; - } - } - } - return false; -} - -const Mtx* resolve_replacement(const Mtx* source, Mtx* scratch) { - if (!g_interpolating || source == nullptr || dusk::frame_interp::presentation_sync_active()) { - return source; - } - - auto it = g_replacements.find(reinterpret_cast(source)); - if (it == g_replacements.end()) { - return source; - } - - MTXCopy(it->second, *scratch); - return scratch; -} - -bool has_recording_data(const Recording& recording) { - return !recording.matrix_values.empty(); -} - -void clear_replacements() { - g_replacements.clear(); -} - -} // namespace - -namespace dusk::frame_interp { -void ensure_initialized() { - s_initialized = true; -} - -void begin_sim_tick() { - ensure_initialized(); - if (!g_enabled) { - return; - } - - s_interpolationCallBackWork.clear(); - s_cam_prev = std::move(s_cam_curr); - ++g_sim_tick_seq; -} - -uint64_t sim_tick_seq() { - return g_sim_tick_seq; -} - -void begin_frame(FrameInterpMode mode, bool is_sim_frame, float step) { - g_enabled = mode != FrameInterpMode::Off; - g_is_sim_frame = is_sim_frame; - g_step = std::clamp(step, 0.0f, 1.0f); - if (!g_enabled) { - g_interpolating = false; - clear_replacements(); - } -} - -bool is_enabled() { - return g_enabled; -} - -bool is_sim_frame() { - return g_is_sim_frame; -} - -void begin_record() { - ensure_initialized(); - - if (!g_enabled) { - g_interpolating = false; - g_sync_presentation = false; - g_previous_recording = {}; - g_current_recording = {}; - clear_replacements(); - s_cam_prev.valid = false; - s_cam_curr.valid = false; - return; - } - - g_sync_presentation = false; - g_previous_recording = std::move(g_current_recording); - g_current_recording = {}; - g_recording = true; - g_interpolating = false; - clear_replacements(); - - ::camera_process_class* cam = dComIfGp_getCamera(0); - if (cam == nullptr) { - s_cam_prev.valid = false; - s_cam_curr.valid = false; - return; - } -} - -void end_record() { - g_recording = false; -} - -void interpolate() { - ensure_initialized(); - clear_replacements(); - g_interpolating = g_enabled && !g_recording && !g_sync_presentation && has_recording_data(g_current_recording); - if (!g_interpolating) { - return; - } - for (auto const& old : g_previous_recording.matrix_values) { - if (auto it = g_current_recording.matrix_values.find(old.first); - it != g_current_recording.matrix_values.end()) - { - lerp_matrix(g_replacements[old.first], old.second, it->second, g_step); - } - } -} - -void request_presentation_sync() { - ensure_initialized(); - if (!g_enabled) { - return; - } - g_sync_presentation = true; -} - -bool presentation_sync_active() { - if (!s_initialized || !g_enabled) { - return false; - } - return g_sync_presentation; -} - -float get_interpolation_step() { - ensure_initialized(); - return presentation_sync_active() ? 1.0f : g_step; -} - -void set_ui_tick_pending(bool value) { - if (g_ui_tick_pending == value) { return; } - g_ui_tick_pending = value; -} - -bool get_ui_tick_pending() { - ensure_initialized(); - return g_enabled ? g_ui_tick_pending : true; -} - -void record_final_mtx(Mtx m, const void* key) { - if (!s_initialized || !g_recording || m == nullptr) { - return; - } - - auto& it = g_current_recording.matrix_values[reinterpret_cast(key)]; - MTXCopy(m, it); -} - -void record_final_mtx(Mtx m) { - record_final_mtx(m, m); -} - -bool lookup_replacement(const void* key, Mtx out) { - if (presentation_sync_active() || !g_interpolating || key == nullptr) { - return false; - } - - auto it = g_replacements.find(reinterpret_cast(key)); - if (it == g_replacements.end()) { - return false; - } - - MTXCopy(it->second, out); - return true; -} - -bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) { - if (presentation_sync_active() || !g_interpolating || lhs == nullptr || rhs == nullptr) { - return false; - } - - Mtx lhs_scratch; - Mtx rhs_scratch; - const Mtx* resolved_lhs = resolve_replacement(reinterpret_cast(lhs), &lhs_scratch); - const Mtx* resolved_rhs = resolve_replacement(reinterpret_cast(rhs), &rhs_scratch); - if (resolved_lhs == reinterpret_cast(lhs) && resolved_rhs == reinterpret_cast(rhs)) { - return false; - } - - MTXConcat(*resolved_lhs, *resolved_rhs, out); - return true; -} - -void record_camera(::camera_process_class* cam, int camera_id) { - if (!g_enabled || camera_id != 0 || cam == nullptr) { - return; - } - copy_view_to_snap(&s_cam_curr, cam->view); -#if WIDESCREEN_SUPPORT - s_cam_curr.wideZoom = mDoGph_gInf_c::isWideZoom(); -#endif -} - -void interp_view(::view_class* view) { - if (!g_enabled) - return; - - if (!s_cam_prev.valid || !s_cam_curr.valid) - return; - - const f32 step = get_interpolation_step(); - const bool is_cam_curr_authoritative = g_is_sim_frame && step <= 0.0f; - - cXyz eye; - cXyz center; - cXyz up; - if (is_cam_curr_authoritative) { - eye = s_cam_curr.eye; - center = s_cam_curr.center; - up = s_cam_curr.up; - } else { - lerp_xyz(&eye, s_cam_prev.eye, s_cam_curr.eye, step); - lerp_xyz(¢er, s_cam_prev.center, s_cam_curr.center, step); - lerp_xyz(&up, s_cam_prev.up, s_cam_curr.up, step); - } - if (!up.normalizeRS()) { - up = s_cam_curr.up; - up.normalizeRS(); - } - - view->lookat.eye = eye; - view->lookat.center = center; - view->lookat.up = up; - if (is_cam_curr_authoritative) { - view->bank = s_cam_curr.bank; - view->fovy = s_cam_curr.fovy; - view->aspect = s_cam_curr.aspect; - view->near_ = s_cam_curr.near_; - view->far_ = s_cam_curr.far_; - } else { - view->bank = lerp_bank(s_cam_prev.bank, s_cam_curr.bank, step); - view->fovy = s_cam_prev.fovy + (s_cam_curr.fovy - s_cam_prev.fovy) * step; - view->aspect = s_cam_prev.aspect + (s_cam_curr.aspect - s_cam_prev.aspect) * step; - view->near_ = s_cam_prev.near_ + (s_cam_curr.near_ - s_cam_prev.near_) * step; - view->far_ = s_cam_prev.far_ + (s_cam_curr.far_ - s_cam_prev.far_) * step; - } - - // FRAME INTERP TODO: It might be better if I rewired the game to not clear this flag until the - // next sim frame, but I don't care enough to right now -#if WIDESCREEN_SUPPORT - const f32 wide_step = is_cam_curr_authoritative ? 1.0f : step; - if (mDoGph_gInf_c::isWide() && !mDoGph_gInf_c::isWideZoom() && wide_step >= 0.5f ? s_cam_curr.wideZoom : s_cam_prev.wideZoom) { - mDoGph_gInf_c::onWideZoom(); - } -#endif -} - -static void run_interpolation_callbacks() { - for (size_t i = 0; i < s_interpolationCallBackWork.size(); i++) { - auto const& work = s_interpolationCallBackWork[i]; - work.pCallBack(g_is_sim_frame, work.pUserWork); - } -} - -void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork) { - if (!is_enabled() || s_presentation_depth > 0 || !g_is_sim_frame) - return; - - s_interpolationCallBackWork.emplace_back(pCallBack, pUserWork); -} - -void begin_presentation_camera() { - ensure_initialized(); - if (!g_enabled) { - return; - } - if (s_presentation_depth > 0) { - s_presentation_depth++; - return; - } - if (!s_cam_prev.valid || !s_cam_curr.valid) { - return; - } - - view_class* const view = dComIfGd_getView(); - if (view == nullptr) { - return; - } - - std::memcpy(&s_presentation_view_backup, view, sizeof(view_class)); - interp_view(view); - - // FRAME INTERP TODO: Largely copied from d_camera's camera_draw function from this point, got any better ideas? - C_MTXPerspective(view->projMtx, view->fovy, view->aspect, view->near_, view->far_); - mDoMtx_lookAt(view->viewMtx, &view->lookat.eye, &view->lookat.center, &view->lookat.up, view->bank); -#if WIDESCREEN_SUPPORT - mDoGph_gInf_c::setWideZoomProjection(view->projMtx); -#endif - j3dSys.setViewMtx(view->viewMtx); - cMtx_inverse(view->viewMtx, view->invViewMtx); - - bool camera_attention_status = dComIfGp_getCameraAttentionStatus(0) & 0x80; - Z2GetAudience()->setAudioCamera(view->viewMtx, view->lookat.eye, view->lookat.center, view->fovy, view->aspect, camera_attention_status, 0, false); - - dBgS_GndChk gndchk; - gndchk.OnWaterGrp(); - gndchk.SetPos(&view->lookat.eye); - f32 cross = dComIfG_Bgsp().GroundCross(&gndchk); - if (cross != -G_CM3D_F_INF) { - if (dComIfG_Bgsp().ChkGrpInf(gndchk, 0x100)) { - mDoAud_getCameraMapInfo(6); - } else { - mDoAud_getCameraMapInfo(dComIfG_Bgsp().GetMtrlSndId(gndchk)); - } - mDoAud_setCameraGroupInfo(dComIfG_Bgsp().GetGrpSoundId(gndchk)); - Vec spDC; - spDC.x = view->lookat.eye.x; - spDC.y = cross; - spDC.z = view->lookat.eye.z; - Z2AudioMgr::getInterface()->setCameraPolygonPos(&spDC); - } else { - Z2AudioMgr::getInterface()->setCameraPolygonPos(nullptr); - } - - MTXCopy(view->viewMtx, view->viewMtxNoTrans); - view->viewMtxNoTrans[0][3] = 0.0f; - view->viewMtxNoTrans[1][3] = 0.0f; - view->viewMtxNoTrans[2][3] = 0.0f; - cMtx_concatProjView(view->projMtx, view->viewMtx, view->projViewMtx); - - f32 far_; - f32 var_f30; - if (dComIfGp_getCameraAttentionStatus(0) & 8) { - far_ = view->far_; - } else { -#if DEBUG - if (g_envHIO.mOther.mAdjustCullFar != 0) { - var_f30 = g_envHIO.mOther.mCullFarValue; - } else -#endif - { - var_f30 = dStage_stagInfo_GetCullPoint(dComIfGp_getStageStagInfo()); - } - far_ = var_f30; - } - - mDoLib_clipper::setup(view->fovy, view->aspect, view->near_, far_); - - // FRAME INTERP NOTE: Removed the call to offWideZoom that was here, it causes problems with presentation during cutscenes. - - s_presentation_depth = 1; - - run_interpolation_callbacks(); -} - -void end_presentation_camera() { - if (s_presentation_depth == 0) { - return; - } - s_presentation_depth--; - if (s_presentation_depth > 0) { - return; - } - - view_class* const view = dComIfGd_getView(); - if (view != nullptr) { - std::memcpy(view, &s_presentation_view_backup, sizeof(view_class)); - } -} -} // namespace dusk::frame_interp diff --git a/src/dusk/frame_interpolation.h b/src/dusk/frame_interpolation.h deleted file mode 100644 index 5f2f3d134b..0000000000 --- a/src/dusk/frame_interpolation.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "settings.h" - -class camera_process_class; -class view_class; - -#ifdef __cplusplus -namespace dusk { -namespace frame_interp { - -void ensure_initialized(); - -void begin_record(); -void end_record(); -void begin_sim_tick(); -uint64_t sim_tick_seq(); -void begin_frame(FrameInterpMode mode, bool is_sim_frame, float step); -void interpolate(); -float get_interpolation_step(); - -void request_presentation_sync(); -bool presentation_sync_active(); - -bool is_enabled(); - -// TODO: These should be phased out as UI is progressively updated to use game_clock -void set_ui_tick_pending(bool value); -bool get_ui_tick_pending(); - -bool is_sim_frame(); - -void record_camera(::camera_process_class* cam, int camera_id); -void interp_view(::view_class* view); -void record_final_mtx(Mtx m, const void *key); -void record_final_mtx(Mtx m); - -bool lookup_replacement(const void* key, Mtx out); -bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); - -typedef void (*InterpolationCallBack)(bool isSimFrame, void* pUserWork); -// call on a sim tick, will get called during presentation -void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork); - -void begin_presentation_camera(); -void end_presentation_camera(); - -} // namespace frame_interp -} // namespace dusk -#endif diff --git a/src/dusk/game_clock.cpp b/src/dusk/game_clock.cpp index a38a08c7d2..3a680fcca8 100644 --- a/src/dusk/game_clock.cpp +++ b/src/dusk/game_clock.cpp @@ -1,10 +1,9 @@ #include "dusk/game_clock.h" -#include #include + +#include #include -#include -#include #include namespace dusk::game_clock { @@ -12,18 +11,21 @@ namespace dusk::game_clock { using native_clock = aurora::time::native_clock; using game_clock = aurora::time::game_clock; -FrameTiming g_frameTiming; +FrameTiming g_frameTiming{.dt = kUiInitialDt}; namespace { bool s_initialized = false; -bool s_fixedStepActive = false; bool s_simTickActive = false; native_clock::time_point s_previousNativeSample{}; game_clock::time_point s_latestGameSample{}; game_clock::time_point s_currentSnapshotTime{}; game_clock::time_point s_pendingSimTime{}; - std::unordered_map s_intervalLastSample; +uint64_t s_presentationEpoch = 1; +bool s_timingModeInitialized = false; +bool s_previousSeparatePresentation = false; +bool s_previousInterpolating = false; +bool s_previousTimeStopped = false; constexpr game_clock::duration kSimPeriodDuration = std::chrono::duration_cast(std::chrono::duration(kSimPeriod)); @@ -48,6 +50,7 @@ void reset() { s_currentSnapshotTime = s_latestGameSample - kSimPeriodDuration; s_pendingSimTime = s_currentSnapshotTime; s_simTickActive = false; + ++s_presentationEpoch; } void set_sim_rate(float hz) { @@ -64,11 +67,15 @@ const FrameTiming& advance() { const auto nativeNow = native_clock::now(); const auto gameNow = game_clock::now(); const auto nativeFrameGap = nativeNow - s_previousNativeSample; + const auto gameFrameGap = gameNow - s_latestGameSample; s_previousNativeSample = nativeNow; s_latestGameSample = gameNow; auto& out = g_frameTiming; - out = {.dt = std::chrono::duration().count()}; + out = { + .dt = std::chrono::duration(gameFrameGap).count(), + .presentationEpoch = s_presentationEpoch, + }; const float timeScale = aurora::time::scale(); const bool interpolating = @@ -76,7 +83,21 @@ const FrameTiming& advance() { const bool separatePresentation = interpolating || timeScale != 1.0f; out.interpolating = interpolating; out.separatePresentation = separatePresentation; - s_fixedStepActive = separatePresentation; + + const bool timeStopped = timeScale == 0.0f; + const bool timingModeChanged = + s_timingModeInitialized && + (separatePresentation != s_previousSeparatePresentation || + interpolating != s_previousInterpolating || timeStopped != s_previousTimeStopped); + const bool abnormalGap = nativeFrameGap > kAbnormalGapResetThreshold; + if (timingModeChanged || abnormalGap) { + ++s_presentationEpoch; + out.presentationEpoch = s_presentationEpoch; + } + s_timingModeInitialized = true; + s_previousSeparatePresentation = separatePresentation; + s_previousInterpolating = interpolating; + s_previousTimeStopped = timeStopped; if (!separatePresentation) { s_currentSnapshotTime = gameNow; @@ -85,7 +106,7 @@ const FrameTiming& advance() { } const auto simulationTarget = interpolating ? gameNow - kSimPeriodDuration : gameNow; - if (timeScale == 0.f || nativeFrameGap > kAbnormalGapResetThreshold) { + if (timeStopped || abnormalGap) { s_currentSnapshotTime = simulationTarget; out.numSimTicks = 0; return out; @@ -108,8 +129,8 @@ const FrameTiming& advance() { } void begin_sim_tick() { - s_pendingSimTime = - s_fixedStepActive ? s_currentSnapshotTime + kSimPeriodDuration : s_latestGameSample; + s_pendingSimTime = g_frameTiming.separatePresentation ? s_currentSnapshotTime + kSimPeriodDuration : + s_latestGameSample; s_simTickActive = true; } @@ -122,6 +143,10 @@ void commit_sim_tick() { } } +bool is_sim_frame() { + return !g_frameTiming.separatePresentation || s_simTickActive; +} + float sample_interpolation_step() { const float step = std::chrono::duration(game_clock::now() - s_currentSnapshotTime).count() / diff --git a/src/dusk/game_clock.h b/src/dusk/game_clock.h index 5e71ea4c0f..3492456927 100644 --- a/src/dusk/game_clock.h +++ b/src/dusk/game_clock.h @@ -16,6 +16,8 @@ struct FrameTiming { bool separatePresentation; // Number of simulation ticks to run int numSimTicks; + // Changes whenever presentation history must be discarded and re-anchored. + uint64_t presentationEpoch; }; extern FrameTiming g_frameTiming; @@ -26,10 +28,12 @@ void begin_sim_tick(); void commit_sim_tick(); float sample_interpolation_step(); +bool is_sim_frame(); + float consume_interval(const void* consumer); // Sets the effective simulation rate through the game clock time scale. void set_sim_rate(float hz); float get_sim_rate(); -} // namespace dusk::game_clock +} // namespace dusk::game_clock diff --git a/src/dusk/game_mode.cpp b/src/dusk/game_mode.cpp index 8fdb3106f3..ffecd66df3 100644 --- a/src/dusk/game_mode.cpp +++ b/src/dusk/game_mode.cpp @@ -1,10 +1,14 @@ #include "dusk/game_mode.hpp" -#include "JSystem/JUtility/JUTGamePad.h" -#include "aurora/lib/logging.hpp" + #include "dusk/config.hpp" #include "dusk/ui/prelaunch.hpp" + #include "m_Do/m_Do_MemCard.h" +#include "JSystem/JUtility/JUTGamePad.h" + +#include + namespace dusk::gamemode { namespace { aurora::Module Log("dusk::gamemode"); diff --git a/src/dusk/game_mode.hpp b/src/dusk/game_mode.hpp index 3c2b63a484..2376eb062b 100644 --- a/src/dusk/game_mode.hpp +++ b/src/dusk/game_mode.hpp @@ -1,8 +1,9 @@ #pragma once -#include "d/d_file_select.h" #include "mods/svc/game_mode.h" +#include "d/d_file_select.h" + #include #include #include diff --git a/src/dusk/gamepad_color.cpp b/src/dusk/gamepad_color.cpp index 9fea8fd769..36e738c29e 100644 --- a/src/dusk/gamepad_color.cpp +++ b/src/dusk/gamepad_color.cpp @@ -1,14 +1,17 @@ -#include -#include -#include -#include -#include -#include +#include "dusk/gamepad_color.h" #include "ui/controller_config.hpp" +#include "d/d_com_inf_game.h" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_alink.h" + +#include + #include +#include + namespace dusk::input { namespace { diff --git a/src/dusk/globals.cpp b/src/dusk/globals.cpp index 591ece679f..34649470c9 100644 --- a/src/dusk/globals.cpp +++ b/src/dusk/globals.cpp @@ -34,5 +34,5 @@ DSPTaskInfo* __DSP_first_task; DSPTaskInfo* __DSP_curr_task; // mDo_dvd -#include +#include "m_Do/m_Do_dvd_thread.h" u8 mDoDvdThd::DVDLogoMode; diff --git a/src/dusk/hq_minimap.cpp b/src/dusk/hq_minimap.cpp index a4d73cbcf1..790597d579 100644 --- a/src/dusk/hq_minimap.cpp +++ b/src/dusk/hq_minimap.cpp @@ -1,6 +1,7 @@ -#include "aurora/texture.hpp" #include "dusk/texture_replacements.hpp" -#include "fmt/format.h" + +#include +#include #include #include diff --git a/src/dusk/imgui/ImGuiActorSpawner.cpp b/src/dusk/imgui/ImGuiActorSpawner.cpp index f3aefd4c41..ba2a41dcc4 100644 --- a/src/dusk/imgui/ImGuiActorSpawner.cpp +++ b/src/dusk/imgui/ImGuiActorSpawner.cpp @@ -1,12 +1,13 @@ -#include "imgui.h" - #include "ImGuiMenuTools.hpp" + #include "d/actor/d_a_alink.h" -#include "d/d_com_inf_game.h" #include "f_op/f_op_actor_mng.h" + #include "SSystem/SComponent/c_sxyz.h" #include "SSystem/SComponent/c_xyz.h" +#include + namespace dusk { namespace { diff --git a/src/dusk/imgui/ImGuiBloomWindow.cpp b/src/dusk/imgui/ImGuiBloomWindow.cpp index 1741f82cd8..e22b86ee1e 100644 --- a/src/dusk/imgui/ImGuiBloomWindow.cpp +++ b/src/dusk/imgui/ImGuiBloomWindow.cpp @@ -1,11 +1,13 @@ -#include - -#include "imgui.h" - #include "ImGuiBloomWindow.hpp" + #include "ImGuiMenuTools.hpp" + #include "m_Do/m_Do_graphic.h" +#include + +#include + namespace dusk { namespace { struct BloomOverride { diff --git a/src/dusk/imgui/ImGuiCameraOverlay.cpp b/src/dusk/imgui/ImGuiCameraOverlay.cpp index 3b859769b9..914f13f1af 100644 --- a/src/dusk/imgui/ImGuiCameraOverlay.cpp +++ b/src/dusk/imgui/ImGuiCameraOverlay.cpp @@ -1,13 +1,16 @@ -#include "f_op/f_op_camera_mng.h" -#include "SSystem/SComponent/c_xyz.h" -#include "d/d_com_inf_game.h" - -#include "imgui.h" #include "ImGuiConfig.hpp" #include "ImGuiConsole.hpp" #include "ImGuiMenuTools.hpp" + #include "dusk/settings.h" +#include "d/d_com_inf_game.h" +#include "f_op/f_op_camera_mng.h" + +#include "SSystem/SComponent/c_xyz.h" + +#include + namespace dusk { void ImGuiMenuTools::ShowCameraOverlay() { if (!getSettings().backend.enableAdvancedSettings || diff --git a/src/dusk/imgui/ImGuiConfig.hpp b/src/dusk/imgui/ImGuiConfig.hpp index 4bceb36a38..6e6cbdea9d 100644 --- a/src/dusk/imgui/ImGuiConfig.hpp +++ b/src/dusk/imgui/ImGuiConfig.hpp @@ -2,7 +2,8 @@ #define DUSK_IMGUICONFIG_HPP #include "dusk/config.hpp" -#include "imgui.h" + +#include namespace dusk::config { inline bool ImGuiCheckbox(const char* title, ConfigVar& var) { diff --git a/src/dusk/imgui/ImGuiConsole.cpp b/src/dusk/imgui/ImGuiConsole.cpp index d15e1c1b8e..badf7297c2 100644 --- a/src/dusk/imgui/ImGuiConsole.cpp +++ b/src/dusk/imgui/ImGuiConsole.cpp @@ -1,35 +1,32 @@ -#include -#include -#include -#include -#include -#include - #define IMGUI_DEFINE_MATH_OPERATORS -#include "imgui.h" -#include - #include "ImGuiConsole.hpp" + #include "ImGuiEngine.hpp" -#include "JSystem/JUtility/JUTGamePad.h" + #include "dusk/action_bindings.h" -#include "dusk/audio/DuskAudioSystem.h" #include "dusk/config.hpp" #include "dusk/data.hpp" -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" #include "dusk/game_mode.hpp" #include "dusk/livesplit.h" #include "dusk/main.h" #include "dusk/presentation.hpp" #include "dusk/settings.h" #include "dusk/ui/ui.hpp" + #include "f_pc/f_pc_manager.h" #include "f_pc/f_pc_name.h" -#include "fmt/format.h" -#include "m_Do/m_Do_controller_pad.h" -#include "m_Do/m_Do_main.h" -#include "tracy/Tracy.hpp" + +#include "JSystem/JUtility/JUTGamePad.h" + +#include +#include +#include +#include +#include + +#include +#include +#include #if _WIN32 #define NOMINMAX diff --git a/src/dusk/imgui/ImGuiConsole.hpp b/src/dusk/imgui/ImGuiConsole.hpp index be344afa3f..87f0b1795a 100644 --- a/src/dusk/imgui/ImGuiConsole.hpp +++ b/src/dusk/imgui/ImGuiConsole.hpp @@ -1,15 +1,14 @@ #ifndef DUSK_IMGUI_HPP #define DUSK_IMGUI_HPP +#include "ImGuiMenuTools.hpp" -#include -#include -#include +#include "dusk/main.h" #include +#include -#include "ImGuiMenuTools.hpp" -#include "dusk/main.h" -#include "imgui.h" +#include +#include union SDL_Event; struct ImGuiWindow; diff --git a/src/dusk/imgui/ImGuiControllerOverlay.cpp b/src/dusk/imgui/ImGuiControllerOverlay.cpp index ad07978a8b..7432c1f49f 100644 --- a/src/dusk/imgui/ImGuiControllerOverlay.cpp +++ b/src/dusk/imgui/ImGuiControllerOverlay.cpp @@ -1,11 +1,12 @@ -#include "m_Do/m_Do_controller_pad.h" - -#include "imgui.h" -#include #include "ImGuiConsole.hpp" + #include "dusk/settings.h" +#include "m_Do/m_Do_controller_pad.h" + #include +#include +#include namespace dusk { void ImGuiMenuTools::ShowInputViewer() { diff --git a/src/dusk/imgui/ImGuiEngine.cpp b/src/dusk/imgui/ImGuiEngine.cpp index b2ea1f8e1a..8c4fd16a43 100644 --- a/src/dusk/imgui/ImGuiEngine.cpp +++ b/src/dusk/imgui/ImGuiEngine.cpp @@ -1,17 +1,17 @@ #include "ImGuiEngine.hpp" +#include "dusk/logging.h" + +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include "aurora/lib/window.hpp" -#include "dusk/logging.h" +#include +#include #ifdef IMGUI_ENABLE_FREETYPE #include "misc/freetype/imgui_freetype.h" diff --git a/src/dusk/imgui/ImGuiEngine.hpp b/src/dusk/imgui/ImGuiEngine.hpp index 44077c9625..2c40b02c89 100644 --- a/src/dusk/imgui/ImGuiEngine.hpp +++ b/src/dusk/imgui/ImGuiEngine.hpp @@ -1,8 +1,8 @@ #pragma once +#include + #include -#include "imgui.h" -#include "misc/cpp/imgui_stdlib.h" namespace dusk { class ImGuiEngine { diff --git a/src/dusk/imgui/ImGuiHeapOverlay.cpp b/src/dusk/imgui/ImGuiHeapOverlay.cpp index 33209ab0d4..0d6da0b210 100644 --- a/src/dusk/imgui/ImGuiHeapOverlay.cpp +++ b/src/dusk/imgui/ImGuiHeapOverlay.cpp @@ -1,13 +1,15 @@ -#include -#include - #include "ImGuiConsole.hpp" #include "ImGuiMenuTools.hpp" + #include "JSystem/JFramework/JFWSystem.h" #include "JSystem/JKernel/JKRExpHeap.h" #include "JSystem/JKernel/JKRHeap.h" -#include "absl/container/flat_hash_map.h" -#include "imgui.h" + +#include +#include + +#include +#include struct OpenHeapData { bool Safe; diff --git a/src/dusk/imgui/ImGuiMenuTools.cpp b/src/dusk/imgui/ImGuiMenuTools.cpp index 7657c48815..0ecfdce149 100644 --- a/src/dusk/imgui/ImGuiMenuTools.cpp +++ b/src/dusk/imgui/ImGuiMenuTools.cpp @@ -1,25 +1,26 @@ -#include "fmt/format.h" -#include "imgui.h" -#include "aurora/gfx.h" - -#include "ImGuiConfig.hpp" -#include "dusk/hotkeys.h" -#include "dusk/settings.h" -#include "ImGuiConsole.hpp" #include "ImGuiMenuTools.hpp" +#include "ImGuiConfig.hpp" +#include "ImGuiConsole.hpp" #include "ImGuiEngine.hpp" + +#include "dusk/data.hpp" +#include "dusk/dusk.h" +#include "dusk/hotkeys.h" +#include "dusk/main.h" +#include "dusk/os.h" +#include "dusk/settings.h" +#include "dusk/speedrun.h" + #include "d/actor/d_a_alink.h" #include "d/actor/d_a_horse.h" #include "d/d_com_inf_game.h" -#include "dusk/data.hpp" -#include "dusk/dusk.h" -#include "dusk/speedrun.h" -#include "dusk/main.h" -#include "dusk/os.h" #include "m_Do/m_Do_main.h" +#include #include +#include +#include #include #if defined(__APPLE__) diff --git a/src/dusk/imgui/ImGuiMenuTools.hpp b/src/dusk/imgui/ImGuiMenuTools.hpp index 61fab81f79..68b150b6d4 100644 --- a/src/dusk/imgui/ImGuiMenuTools.hpp +++ b/src/dusk/imgui/ImGuiMenuTools.hpp @@ -1,14 +1,10 @@ #ifndef DUSK_IMGUI_MENUTOOLS_HPP #define DUSK_IMGUI_MENUTOOLS_HPP - -#include -#include -#include - -#include "imgui.h" #include "ImGuiSaveEditor.hpp" #include "ImGuiStateShare.hpp" +#include + namespace dusk { class ImGuiMenuTools { public: diff --git a/src/dusk/imgui/ImGuiProcessOverlay.cpp b/src/dusk/imgui/ImGuiProcessOverlay.cpp index 5b4fff28db..03ad595ac1 100644 --- a/src/dusk/imgui/ImGuiProcessOverlay.cpp +++ b/src/dusk/imgui/ImGuiProcessOverlay.cpp @@ -1,19 +1,17 @@ #define PROCS_DUMP_NAMES 1 -#include +#include "ImGuiConsole.hpp" +#include "ImGuiMenuTools.hpp" -#include "f_pc/f_pc_name.h" #include "f_pc/f_pc_create_iter.h" #include "f_pc/f_pc_create_req.h" #include "f_pc/f_pc_layer.h" #include "f_pc/f_pc_layer_iter.h" #include "f_pc/f_pc_leaf.h" +#include "f_pc/f_pc_name.h" #include "f_pc/f_pc_node.h" -#include "d/d_debug_viewer.h" -#include "imgui.h" -#include "ImGuiConsole.hpp" -#include "ImGuiMenuTools.hpp" -#include "imgui_internal.h" + +#include namespace dusk { static bool BeginProcTable() { diff --git a/src/dusk/imgui/ImGuiSaveEditor.cpp b/src/dusk/imgui/ImGuiSaveEditor.cpp index 244b26e200..866b0fe369 100644 --- a/src/dusk/imgui/ImGuiSaveEditor.cpp +++ b/src/dusk/imgui/ImGuiSaveEditor.cpp @@ -1,16 +1,16 @@ -#include "fmt/format.h" -#include "imgui.h" -#include "aurora/gfx.h" +#include "ImGuiSaveEditor.hpp" #include "ImGuiConsole.hpp" -#include "ImGuiSaveEditor.hpp" #include "ImGuiEventFlags.hpp" +#include "d/actor/d_a_player.h" #include "d/d_com_inf_game.h" #include "d/d_item_data.h" #include "d/d_meter2_info.h" #include "d/d_save.h" -#include "d/actor/d_a_player.h" + +#include +#include #include diff --git a/src/dusk/imgui/ImGuiSaveEditor.hpp b/src/dusk/imgui/ImGuiSaveEditor.hpp index a18262862f..50ac7530a5 100644 --- a/src/dusk/imgui/ImGuiSaveEditor.hpp +++ b/src/dusk/imgui/ImGuiSaveEditor.hpp @@ -1,11 +1,6 @@ #ifndef DUSK_IMGUI_SAVEEDITOR_HPP #define DUSK_IMGUI_SAVEEDITOR_HPP -#include -#include - -#include "imgui.h" - namespace dusk { class ImGuiSaveEditor { public: diff --git a/src/dusk/imgui/ImGuiStateShare.cpp b/src/dusk/imgui/ImGuiStateShare.cpp index be45d5394b..9f7ee09282 100644 --- a/src/dusk/imgui/ImGuiStateShare.cpp +++ b/src/dusk/imgui/ImGuiStateShare.cpp @@ -1,24 +1,26 @@ #include "ImGuiStateShare.hpp" -#include "ImGuiMenuTools.hpp" + #include "ImGuiConsole.hpp" +#include "ImGuiMenuTools.hpp" -#include "imgui.h" -#include "fmt/format.h" -#include "absl/strings/escaping.h" -#include "nlohmann/json.hpp" - -#include "d/d_com_inf_game.h" -#include "dusk/main.h" +#include "dusk/autosave.h" #include "dusk/io.hpp" #include "dusk/logging.h" +#include "dusk/main.h" #include "dusk/settings.h" + +#include "d/d_com_inf_game.h" #include "f_op/f_op_overlap_mng.h" + +#include +#include #include -#include "aurora/lib/window.hpp" +#include +#include +#include +#include #include -#include -#include namespace dusk { diff --git a/src/dusk/imgui/ImGuiStubLog.cpp b/src/dusk/imgui/ImGuiStubLog.cpp index 9a6f084eef..cc28bbc53d 100644 --- a/src/dusk/imgui/ImGuiStubLog.cpp +++ b/src/dusk/imgui/ImGuiStubLog.cpp @@ -1,9 +1,11 @@ -#include -#include +#include "ImGuiMenuTools.hpp" #include "dusk/logging.h" -#include "imgui.h" -#include "ImGuiMenuTools.hpp" + +#include + +#include +#include namespace dusk { static ImGuiTextBuffer StubLogBuffer; diff --git a/src/dusk/interp/camera.cpp b/src/dusk/interp/camera.cpp new file mode 100644 index 0000000000..19ab197214 --- /dev/null +++ b/src/dusk/interp/camera.cpp @@ -0,0 +1,218 @@ +#include "dusk/interp/camera.h" + +#include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/interp/lerp.h" + +#include "d/d_com_inf_game.h" +#include "f_op/f_op_camera_mng.h" +#include "m_Do/m_Do_graphic.h" + +#include +#include + +namespace { + +struct CameraSnapshot { + cXyz eye{}; + cXyz center{}; + cXyz up{}; + s16 bank{}; + f32 fovy{}; + f32 aspect{}; + f32 near_{}; + f32 far_{}; + bool wideZoom{}; + bool valid{}; +}; + +CameraSnapshot s_camPrev{}; +CameraSnapshot s_camCurr{}; + +view_class s_presentationViewBackup{}; + +void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) { + dst->eye = v.lookat.eye; + dst->center = v.lookat.center; + dst->up = v.lookat.up; + dst->bank = v.bank; + dst->fovy = v.fovy; + dst->aspect = v.aspect; + dst->near_ = v.near_; + dst->far_ = v.far_; + dst->valid = true; +} + +void apply_presented_view(view_class* view) { + // FRAME INTERP TODO: Largely copied from d_camera's camera_draw function from this point, got any + // better ideas? + C_MTXPerspective(view->projMtx, view->fovy, view->aspect, view->near_, view->far_); + mDoMtx_lookAt(view->viewMtx, &view->lookat.eye, &view->lookat.center, &view->lookat.up, + view->bank); +#if WIDESCREEN_SUPPORT + mDoGph_gInf_c::setWideZoomProjection(view->projMtx); +#endif + j3dSys.setViewMtx(view->viewMtx); + cMtx_inverse(view->viewMtx, view->invViewMtx); + + bool camera_attention_status = dComIfGp_getCameraAttentionStatus(0) & 0x80; + Z2GetAudience()->setAudioCamera(view->viewMtx, view->lookat.eye, view->lookat.center, view->fovy, + view->aspect, camera_attention_status, 0, false); + + dBgS_GndChk gndchk; + gndchk.OnWaterGrp(); + gndchk.SetPos(&view->lookat.eye); + f32 cross = dComIfG_Bgsp().GroundCross(&gndchk); + if (cross != -G_CM3D_F_INF) { + if (dComIfG_Bgsp().ChkGrpInf(gndchk, 0x100)) { + mDoAud_getCameraMapInfo(6); + } else { + mDoAud_getCameraMapInfo(dComIfG_Bgsp().GetMtrlSndId(gndchk)); + } + mDoAud_setCameraGroupInfo(dComIfG_Bgsp().GetGrpSoundId(gndchk)); + Vec spDC; + spDC.x = view->lookat.eye.x; + spDC.y = cross; + spDC.z = view->lookat.eye.z; + Z2AudioMgr::getInterface()->setCameraPolygonPos(&spDC); + } else { + Z2AudioMgr::getInterface()->setCameraPolygonPos(nullptr); + } + + MTXCopy(view->viewMtx, view->viewMtxNoTrans); + view->viewMtxNoTrans[0][3] = 0.0f; + view->viewMtxNoTrans[1][3] = 0.0f; + view->viewMtxNoTrans[2][3] = 0.0f; + cMtx_concatProjView(view->projMtx, view->viewMtx, view->projViewMtx); + + f32 far_; + f32 var_f30; + if (dComIfGp_getCameraAttentionStatus(0) & 8) { + far_ = view->far_; + } else { +#if DEBUG + if (g_envHIO.mOther.mAdjustCullFar != 0) { + var_f30 = g_envHIO.mOther.mCullFarValue; + } else +#endif + { + var_f30 = dStage_stagInfo_GetCullPoint(dComIfGp_getStageStagInfo()); + } + far_ = var_f30; + } + + mDoLib_clipper::setup(view->fovy, view->aspect, view->near_, far_); + + // FRAME INTERP NOTE: Removed the call to offWideZoom that was here, it causes problems with + // presentation during cutscenes. +} + +} // namespace + +namespace dusk::interp { + +void record_camera(::camera_process_class* cam, int camera_id) { + if (!is_enabled() || camera_id != 0 || cam == nullptr) { + return; + } + copy_view_to_snap(&s_camCurr, cam->view); +#if WIDESCREEN_SUPPORT + s_camCurr.wideZoom = mDoGph_gInf_c::isWideZoom(); +#endif +} + +void interp_view(::view_class* view) { + if (!is_enabled()) + return; + + if (!s_camPrev.valid || !s_camCurr.valid) + return; + + const f32 step = get_interpolation_step(); + const bool is_cam_curr_authoritative = game_clock::is_sim_frame() && step <= 0.0f; + + cXyz eye; + cXyz center; + cXyz up; + if (is_cam_curr_authoritative) { + eye = s_camCurr.eye; + center = s_camCurr.center; + up = s_camCurr.up; + } else { + lerp(eye, s_camPrev.eye, s_camCurr.eye, step); + lerp(center, s_camPrev.center, s_camCurr.center, step); + lerp(up, s_camPrev.up, s_camCurr.up, step); + } + if (!up.normalizeRS()) { + up = s_camCurr.up; + up.normalizeRS(); + } + + view->lookat.eye = eye; + view->lookat.center = center; + view->lookat.up = up; + if (is_cam_curr_authoritative) { + view->bank = s_camCurr.bank; + view->fovy = s_camCurr.fovy; + view->aspect = s_camCurr.aspect; + view->near_ = s_camCurr.near_; + view->far_ = s_camCurr.far_; + } else { + view->bank = lerp(s_camPrev.bank, s_camCurr.bank, step); + view->fovy = s_camPrev.fovy + (s_camCurr.fovy - s_camPrev.fovy) * step; + view->aspect = s_camPrev.aspect + (s_camCurr.aspect - s_camPrev.aspect) * step; + view->near_ = s_camPrev.near_ + (s_camCurr.near_ - s_camPrev.near_) * step; + view->far_ = s_camPrev.far_ + (s_camCurr.far_ - s_camPrev.far_) * step; + } + + // FRAME INTERP TODO: It might be better if I rewired the game to not clear this flag until the + // next sim frame, but I don't care enough to right now +#if WIDESCREEN_SUPPORT + const f32 wide_step = is_cam_curr_authoritative ? 1.0f : step; + if (mDoGph_gInf_c::isWide() && !mDoGph_gInf_c::isWideZoom() && + wide_step >= 0.5f ? s_camCurr.wideZoom : s_camPrev.wideZoom) + { + mDoGph_gInf_c::onWideZoom(); + } +#endif +} + +void camera_on_sim_tick() { + s_camPrev = std::move(s_camCurr); +} + +void camera_invalidate_snapshots() { + s_camPrev.valid = false; + s_camCurr.valid = false; +} + +void camera_on_begin_record() { + if (dComIfGp_getCamera(0) == nullptr) { + camera_invalidate_snapshots(); + } +} + +bool camera_apply_presentation() { + if (!s_camPrev.valid || !s_camCurr.valid) { + return false; + } + + view_class* const view = dComIfGd_getView(); + if (view == nullptr) { + return false; + } + + std::memcpy(&s_presentationViewBackup, view, sizeof(view_class)); + interp_view(view); + apply_presented_view(view); + return true; +} + +void camera_restore_presentation() { + view_class* const view = dComIfGd_getView(); + if (view != nullptr) { + std::memcpy(view, &s_presentationViewBackup, sizeof(view_class)); + } +} + +} // namespace dusk::interp diff --git a/src/dusk/interp/camera.h b/src/dusk/interp/camera.h new file mode 100644 index 0000000000..e4a1824979 --- /dev/null +++ b/src/dusk/interp/camera.h @@ -0,0 +1,13 @@ +#pragma once + +class camera_process_class; +class view_class; + +#ifdef __cplusplus +namespace dusk::interp { + +void record_camera(::camera_process_class* cam, int camera_id); +void interp_view(::view_class* view); + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/dual_buffer.cpp b/src/dusk/interp/dual_buffer.cpp new file mode 100644 index 0000000000..be1160e6a6 --- /dev/null +++ b/src/dusk/interp/dual_buffer.cpp @@ -0,0 +1,65 @@ +#include "dusk/interp/dual_buffer.h" + +#include +#include + +namespace dusk::interp { +namespace { + +struct Slot { + const void* type; + void* ptr; + void (*destroy)(void*); +}; + +using OwnerMap = absl::flat_hash_map>; + +OwnerMap& owner_map() { + static OwnerMap s_map; + return s_map; +} + +} // namespace + +void* detail::acquire(const void* key, const void* type, void* (*make)(), void (*destroy)(void*)) { + const uintptr_t id = reinterpret_cast(key); + auto& slots = owner_map()[id]; + for (Slot& slot : slots) { + if (slot.type == type) { + return slot.ptr; + } + } + + void* ptr = make(); + slots.push_back({type, ptr, destroy}); + return ptr; +} + +void erase_owned_buffers(const void* key) { + if (key == nullptr) { + return; + } + + OwnerMap& stored = owner_map(); + auto it = stored.find(reinterpret_cast(key)); + if (it == stored.end()) { + return; + } + + for (Slot& slot : it->second) { + slot.destroy(slot.ptr); + } + stored.erase(it); +} + +void clear_owned_buffers() { + OwnerMap& stored = owner_map(); + for (auto& entry : stored) { + for (Slot& slot : entry.second) { + slot.destroy(slot.ptr); + } + } + stored.clear(); +} + +} // namespace dusk::interp diff --git a/src/dusk/interp/dual_buffer.h b/src/dusk/interp/dual_buffer.h new file mode 100644 index 0000000000..bbae6a3a01 --- /dev/null +++ b/src/dusk/interp/dual_buffer.h @@ -0,0 +1,123 @@ +#pragma once + +#include "dusk/interp/frame_interpolation.h" +#include "dusk/interp/lerp.h" + +#include + +#ifdef __cplusplus +namespace dusk::interp { + +template +class DualBuffer { +public: + explicit DualBuffer(T* dst = NULL) + : m_prev_valid(false), + m_curr_valid(false), + m_count(0), + m_dst(dst), + m_post(NULL), + m_post_user(NULL) {} + + void bind(T* dst) { m_dst = dst; } + + void reset() { + m_prev_valid = false; + m_curr_valid = false; + m_count = 0; + } + + bool ready() const { return m_prev_valid && m_curr_valid; } + + void capture_and_schedule(const T* src, int count, void (*post)(void*) = NULL, + void* post_user = NULL) { + roll(); + capture(src, count); + schedule(post, post_user); + } + + void writeback(T* src_and_dst, int count, void (*post)(void*) = NULL, void* post_user = NULL) { + bind(src_and_dst); + capture_and_schedule(src_and_dst, count, post, post_user); + } + +private: + bool fits(int count) const { + if (count > capacity) { + return false; + } + return count > 0; + } + + void roll() { + if (!is_enabled() || !m_curr_valid || m_count <= 0) { + return; + } + std::memcpy(m_prev, m_curr, static_cast(m_count) * sizeof(T)); + m_prev_valid = true; + } + + void capture(const T* src, int count) { + if (!fits(count) || !is_enabled() || src == NULL) { + return; + } + std::memcpy(m_curr, src, static_cast(count) * sizeof(T)); + m_count = count; + m_curr_valid = true; + } + + void apply(T* dst, int count) const { + if (!fits(count) || dst == NULL || !ready()) { + return; + } + const f32 step = get_interpolation_step(); + for (int i = 0; i < count; ++i) { + lerp(dst[i], m_prev[i], m_curr[i], step); + } + } + + void schedule(void (*post)(void*) = NULL, void* post_user = NULL) { + if (!is_enabled() || m_dst == NULL || !fits(m_count)) { + return; + } + m_post = post; + m_post_user = post_user; + add_interpolation_callback(&present_trampoline, this); + } + + static void present_trampoline(void* user) { static_cast(user)->present(); } + + void present() { + apply(m_dst, m_count); + if (m_post != NULL) { + m_post(m_post_user); + } + } + + T m_prev[capacity]; + T m_curr[capacity]; + bool m_prev_valid; + bool m_curr_valid; + int m_count; + T* m_dst; + void (*m_post)(void*); + void* m_post_user; +}; + +namespace detail { +void* acquire(const void* key, const void* type, void* (*make)(), void (*destroy)(void*)); +} + +template +Record& get(const void* key) { + static const char token{}; + return *static_cast(detail::acquire( + key, &token, []() -> void* { return new Record; }, + [](void* p) { delete static_cast(p); })); +} + +void erase_owned_buffers(const void* key); +void clear_owned_buffers(); + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/frame_interpolation.cpp b/src/dusk/interp/frame_interpolation.cpp new file mode 100644 index 0000000000..4edfee234a --- /dev/null +++ b/src/dusk/interp/frame_interpolation.cpp @@ -0,0 +1,293 @@ +#include "dusk/interp/frame_interpolation.h" + +#include "dusk/game_clock.h" +#include "dusk/interp/dual_buffer.h" +#include "dusk/interp/lerp.h" + +#include "mtx.h" + +#include +#include +#include + +namespace dusk::interp { +void camera_on_sim_tick(); +void camera_on_begin_record(); +bool camera_apply_presentation(); +void camera_restore_presentation(); +void camera_invalidate_snapshots(); +} // namespace dusk::interp + +namespace { + +struct Recording { + absl::flat_hash_map matrix_values; +}; + +bool s_recording = false; +bool s_replacementsActive = false; +bool s_syncPresentation = false; + +float s_step = 0.0f; +bool s_uiTickPending = false; +uint64_t s_simTickSeq = 0; +uint64_t s_observedPresentationEpoch = 0; + +Recording s_currentRecording; +Recording s_previousRecording; + +absl::flat_hash_map g_replacements; + +int s_presentationDepth = 0; + +const Mtx* resolve_replacement(const Mtx* source, Mtx* scratch) { + if (!s_replacementsActive || source == nullptr || dusk::interp::presentation_sync_active()) { + return source; + } + + auto it = g_replacements.find(reinterpret_cast(source)); + if (it == g_replacements.end()) { + return source; + } + + MTXCopy(it->second, *scratch); + return scratch; +} + +bool has_recording_data(const Recording& recording) { + return !recording.matrix_values.empty(); +} + +void clear_replacements() { + g_replacements.clear(); +} + +void interpolate_replacements() { + clear_replacements(); + s_replacementsActive = dusk::interp::is_enabled() && !s_recording && !s_syncPresentation && + has_recording_data(s_currentRecording); + if (!s_replacementsActive) { + return; + } + for (auto const& old : s_previousRecording.matrix_values) { + if (auto it = s_currentRecording.matrix_values.find(old.first); + it != s_currentRecording.matrix_values.end()) + { + dusk::interp::lerp(g_replacements[old.first], old.second, it->second, s_step); + } + } +} + +struct InterpolationCallBackWork { + dusk::interp::InterpolationCallBack pCallBack; + void* pUserWork; +}; + +std::vector s_interpolationCallBackWork; + +void clear_callbacks() { + s_interpolationCallBackWork.clear(); +} + +void callbacks_run() { + for (const auto& work : s_interpolationCallBackWork) { + if (work.pCallBack != nullptr) { + work.pCallBack(work.pUserWork); + } + } +} + +void clear_interpolation_history() { + s_recording = false; + s_replacementsActive = false; + s_syncPresentation = false; + s_previousRecording = {}; + s_currentRecording = {}; + clear_replacements(); + dusk::interp::clear_owned_buffers(); + clear_callbacks(); + dusk::interp::camera_invalidate_snapshots(); + s_presentationDepth = 0; +} + +} // namespace + +namespace dusk::interp { + +void begin_sim_tick() { + if (!is_enabled()) { + return; + } + + clear_callbacks(); + camera_on_sim_tick(); + ++s_simTickSeq; +} + +uint64_t sim_tick_seq() { + return s_simTickSeq; +} + +void begin_frame(float step) { + const game_clock::FrameTiming& timing = game_clock::g_frameTiming; + if (s_observedPresentationEpoch != timing.presentationEpoch) { + s_observedPresentationEpoch = timing.presentationEpoch; + clear_interpolation_history(); + } + + s_step = std::clamp(step, 0.0f, 1.0f); + if (!is_enabled()) { + clear_interpolation_history(); + } +} + +bool is_enabled() { + return game_clock::g_frameTiming.interpolating; +} + +bool should_capture() { + return is_enabled() && game_clock::is_sim_frame(); +} + +void begin_record() { + if (!is_enabled()) { + clear_interpolation_history(); + return; + } + + s_syncPresentation = false; + s_previousRecording = std::move(s_currentRecording); + s_currentRecording = {}; + s_recording = true; + s_replacementsActive = false; + clear_replacements(); + camera_on_begin_record(); +} + +void end_record() { + s_recording = false; +} + +void request_presentation_sync() { + if (!is_enabled()) { + return; + } + s_syncPresentation = true; +} + +bool presentation_sync_active() { + if (!is_enabled()) { + return false; + } + return s_syncPresentation; +} + +float get_interpolation_step() { + return presentation_sync_active() ? 1.0f : s_step; +} + +void set_ui_tick_pending(bool value) { + if (s_uiTickPending == value) { + return; + } + s_uiTickPending = value; +} + +bool get_ui_tick_pending() { + return is_enabled() ? s_uiTickPending : true; +} + +void record_final_mtx(Mtx m, const void* key) { + if (!s_recording || m == nullptr) { + return; + } + + auto& it = s_currentRecording.matrix_values[reinterpret_cast(key)]; + MTXCopy(m, it); +} + +void record_final_mtx(Mtx m) { + record_final_mtx(m, m); +} + +bool lookup_replacement(const void* key, Mtx out) { + if (presentation_sync_active() || !s_replacementsActive || key == nullptr) { + return false; + } + + auto it = g_replacements.find(reinterpret_cast(key)); + if (it == g_replacements.end()) { + return false; + } + + MTXCopy(it->second, out); + return true; +} + +bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) { + if (presentation_sync_active() || !s_replacementsActive || lhs == nullptr || rhs == nullptr) { + return false; + } + + Mtx lhs_scratch; + Mtx rhs_scratch; + const Mtx* resolved_lhs = resolve_replacement(reinterpret_cast(lhs), &lhs_scratch); + const Mtx* resolved_rhs = resolve_replacement(reinterpret_cast(rhs), &rhs_scratch); + if (resolved_lhs == reinterpret_cast(lhs) && + resolved_rhs == reinterpret_cast(rhs)) + { + return false; + } + + MTXConcat(*resolved_lhs, *resolved_rhs, out); + return true; +} + +void begin_presentation(float step) { + begin_frame(step); + if (!is_enabled()) { + return; + } + + interpolate_replacements(); + + if (s_presentationDepth > 0) { + s_presentationDepth++; + return; + } + if (!camera_apply_presentation()) { + return; + } + + s_presentationDepth = 1; + callbacks_run(); +} + +void end_presentation() { + if (s_presentationDepth == 0) { + return; + } + s_presentationDepth--; + if (s_presentationDepth > 0) { + return; + } + + camera_restore_presentation(); +} + +bool is_presentation_active() { + return s_presentationDepth > 0; +} + +void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork) { + if (!is_enabled() || is_presentation_active() || !game_clock::is_sim_frame()) { + return; + } + if (pCallBack == nullptr) { + return; + } + + s_interpolationCallBackWork.push_back({pCallBack, pUserWork}); +} + +} // namespace dusk::interp diff --git a/src/dusk/interp/frame_interpolation.h b/src/dusk/interp/frame_interpolation.h new file mode 100644 index 0000000000..64ae2acec4 --- /dev/null +++ b/src/dusk/interp/frame_interpolation.h @@ -0,0 +1,42 @@ +#pragma once + +#include + +#include + +#ifdef __cplusplus +namespace dusk::interp { + +void begin_record(); +void end_record(); +void begin_sim_tick(); +uint64_t sim_tick_seq(); +void begin_frame(float step); +float get_interpolation_step(); + +void request_presentation_sync(); +bool presentation_sync_active(); + +bool is_enabled(); + +bool should_capture(); + +// TODO: These should be phased out as UI is progressively updated to use game_clock +void set_ui_tick_pending(bool value); +bool get_ui_tick_pending(); + +void record_final_mtx(Mtx m, const void* key); +void record_final_mtx(Mtx m); + +bool lookup_replacement(const void* key, Mtx out); +bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); + +void begin_presentation(float step); +void end_presentation(); +bool is_presentation_active(); + +typedef void (*InterpolationCallBack)(void* pUserWork); +void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork); + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/lerp.h b/src/dusk/interp/lerp.h new file mode 100644 index 0000000000..1f05f070fa --- /dev/null +++ b/src/dusk/interp/lerp.h @@ -0,0 +1,53 @@ +#pragma once + +#include "SSystem/SComponent/c_angle.h" +#include "SSystem/SComponent/c_sxyz.h" +#include "SSystem/SComponent/c_xyz.h" + +#include +#include + +#ifdef __cplusplus +namespace dusk::interp { + +inline s16 lerp(s16 lhs, s16 rhs, float step) { + const f32 ra = S2RAD(lhs); + const f32 d = remainderf(S2RAD(rhs) - ra, 2.0f * M_PI); + return cAngle::Radian_to_SAngle(ra + d * step); +} + +inline u16 lerp(u16 lhs, u16 rhs, float step) { + return static_cast(lerp(static_cast(lhs), static_cast(rhs), step)); +} + +inline f32 lerp(f32 lhs, f32 rhs, float step) { + return lhs + (rhs - lhs) * step; +} + +inline u8 lerp(u8 lhs, u8 rhs, float step) { + return static_cast(std::lround(lerp(static_cast(lhs), static_cast(rhs), step))); +} + +inline void lerp(cXyz& out, const cXyz& lhs, const cXyz& rhs, float step) { + out.x = lerp(lhs.x, rhs.x, step); + out.y = lerp(lhs.y, rhs.y, step); + out.z = lerp(lhs.z, rhs.z, step); +} + +inline void lerp(csXyz& out, const csXyz& lhs, const csXyz& rhs, float step) { + out.x = lerp(lhs.x, rhs.x, step); + out.y = lerp(lhs.y, rhs.y, step); + out.z = lerp(lhs.z, rhs.z, step); +} + +inline void lerp(Mtx& out, const Mtx& lhs, const Mtx& rhs, float step) { + for (size_t row = 0; row < 3; ++row) { + for (size_t col = 0; col < 4; ++col) { + const float l = lhs[row][col]; + out[row][col] = l + (rhs[row][col] - l) * step; + } + } +} + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/line.cpp b/src/dusk/interp/line.cpp new file mode 100644 index 0000000000..3d509debea --- /dev/null +++ b/src/dusk/interp/line.cpp @@ -0,0 +1,159 @@ +#include "dusk/interp/line.h" + +#include "dusk/interp/dual_buffer.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/interp/lerp.h" + +#include "m_Do/m_Do_ext.h" + +#include +#include +#include +#include + +namespace { + +struct Record { + Record() + : store(nullptr), previous(nullptr), current(nullptr), sample_capacity(0), tick(0), + strand_count(0), point_count(0), previous_valid(false), current_valid(false) {} + + ~Record() { delete[] store; } + + Record(const Record&) = delete; + Record& operator=(const Record&) = delete; + + void invalidate() { + previous_valid = false; + current_valid = false; + } + + bool ensure(size_t required) { + if (required <= sample_capacity) { + return store != nullptr; + } + if (required > std::numeric_limits::max() / (2 * sizeof(cXyz))) { + return false; + } + + cXyz* next = new (std::nothrow) cXyz[required * 2]; + if (next == nullptr) { + return false; + } + + delete[] store; + store = next; + previous = store; + current = store + required; + sample_capacity = required; + invalidate(); + return true; + } + + cXyz* store; + cXyz* previous; + cXyz* current; + size_t sample_capacity; + uint64_t tick; + u16 strand_count; + u16 point_count; + bool previous_valid; + bool current_valid; +}; + +bool valid(const dusk::interp::line::Points& points) { + if (points.strands == nullptr || points.strand_count == 0 || points.point_count == 0) { + return false; + } + for (u16 strand = 0; strand < points.strand_count; ++strand) { + if (points.strands[strand].field_0x0 == nullptr) { + return false; + } + } + return true; +} + +bool same_layout(const Record& record, const dusk::interp::line::Points& points) { + return record.current_valid && record.strand_count == points.strand_count && + record.point_count == points.point_count; +} + +void copy_points(cXyz* destination, const dusk::interp::line::Points& points) { + const size_t points_size = static_cast(points.point_count) * sizeof(cXyz); + for (u16 strand = 0; strand < points.strand_count; ++strand) { + std::memcpy(destination + static_cast(strand) * points.point_count, + points.strands[strand].field_0x0, points_size); + } +} + +} // namespace + +namespace dusk::interp::line { + +void reset(const void* owner) { + erase_owned_buffers(owner); +} + +void capture(const void* owner, Points points) { + if (owner == nullptr || !should_capture()) { + return; + } + + Record& record = get(owner); + if (!valid(points)) { + record.invalidate(); + return; + } + + const size_t required = static_cast(points.strand_count) * points.point_count; + if (!record.ensure(required)) { + record.invalidate(); + return; + } + + const uint64_t tick = sim_tick_seq(); + const bool layout_matches = same_layout(record, points); + + if (layout_matches && tick == record.tick) { + copy_points(record.current, points); + return; + } + + if (layout_matches && tick == record.tick + 1) { + std::swap(record.previous, record.current); + record.previous_valid = true; + } else { + record.previous_valid = false; + } + + copy_points(record.current, points); + record.tick = tick; + record.strand_count = points.strand_count; + record.point_count = points.point_count; + record.current_valid = true; +} + +void write(const void* owner, Points points) { + if (owner == nullptr || !is_enabled() || !valid(points)) { + return; + } + + Record& record = get(owner); + if (!record.previous_valid || !same_layout(record, points) || + record.tick != sim_tick_seq()) + { + return; + } + + const f32 step = get_interpolation_step(); + for (u16 strand = 0; strand < points.strand_count; ++strand) { + cXyz* destination = points.strands[strand].field_0x0; + const size_t offset = static_cast(strand) * points.point_count; + for (u16 point = 0; point < points.point_count; ++point) { + lerp(destination[point], record.previous[offset + point], + record.current[offset + point], step); + } + } +} + +} // namespace dusk::interp::line diff --git a/src/dusk/interp/line.h b/src/dusk/interp/line.h new file mode 100644 index 0000000000..7b4f3b56bc --- /dev/null +++ b/src/dusk/interp/line.h @@ -0,0 +1,19 @@ +#pragma once + +#include "dolphin/types.h" + +class mDoExt_3Dline_c; + +namespace dusk::interp::line { + +struct Points { + mDoExt_3Dline_c* strands; + u16 strand_count; + u16 point_count; +}; + +void reset(const void* owner); +void capture(const void* owner, Points points); +void write(const void* owner, Points points); + +} // namespace dusk::interp::line diff --git a/src/dusk/livesplit.cpp b/src/dusk/livesplit.cpp index d583ef75fa..2bf01dada1 100644 --- a/src/dusk/livesplit.cpp +++ b/src/dusk/livesplit.cpp @@ -1,107 +1,80 @@ -#if _WIN32 -#include -#include -using socket_t = SOCKET; -static void closeSocket(socket_t s) { - LINGER li{1, 0}; - setsockopt(s, SOL_SOCKET, SO_LINGER, reinterpret_cast(&li), sizeof(li)); - closesocket(s); -} -static int socketError(socket_t s) { - int err = 0; - int len = sizeof(err); - getsockopt(s, SOL_SOCKET, SO_ERROR, reinterpret_cast(&err), &len); - return err; -} -static constexpr int kSendFlags = 0; -#else -#include -#include -#include -#include -#include -#include -#include -using socket_t = int; -static void closeSocket(socket_t s) { - struct linger li{1, 0}; - setsockopt(s, SOL_SOCKET, SO_LINGER, &li, sizeof(li)); - close(s); -} -static int socketError(socket_t s) { - int err = 0; - socklen_t len = sizeof(err); - getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len); - return err; -} -#ifndef INVALID_SOCKET -#define INVALID_SOCKET -1 -#endif - -#if defined(__APPLE__) -static constexpr int kSendFlags = 0; -#else -static constexpr int kSendFlags = MSG_NOSIGNAL; -#endif -#endif - -#include #include "dusk/livesplit.h" + +#include "borealis/net.hpp" + #include "f_op/f_op_overlap_mng.h" +#include +#include +#include +#include + namespace dusk::speedrun { +namespace { -static bool running = false; -static bool startPending = false; -static uint64_t frameCount = 0; -static socket_t sock = INVALID_SOCKET; -static bool wasLoading = false; -static bool connected = false; -static bool connectPending = false; -static bool disconnectPending = false; -static uint32_t idleProbeCounter = 0; -static uint32_t reconnectCounter = 0; -static char storedHost[64] = "127.0.0.1"; -static int storedPort = 16834; +bool running = false; +bool startPending = false; +uint64_t frameCount = 0; +bool wasLoading = false; +bool connected = false; +bool connectPending = false; +bool disconnectPending = false; +uint32_t reconnectCounter = 0; +std::string storedEndpoint = "tcp://127.0.0.1:16834"; +std::unique_ptr netContext; +borealis::net::SocketId socketId = 0; -static void sendCmd(const char* cmd) { - if (sock == INVALID_SOCKET) { +void send_cmd(const char* command) { + if (!netContext || !connected || socketId == 0) { return; } - char msg[64]; - const int len = snprintf(msg, sizeof(msg), "%s\r\n", cmd); - if (len <= 0 || len >= static_cast(sizeof(msg))) { + char message[64]; + const int length = snprintf(message, sizeof(message), "%s\r\n", command); + if (length <= 0 || length >= static_cast(sizeof(message))) { return; } - if (send(sock, msg, len, kSendFlags) >= 0) { - if (!connected) { - connected = connectPending = true; - } - return; - } - -#if _WIN32 - const int err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK || err == WSAENOTCONN) { - return; - } -#else - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOTCONN) { - return; - } -#endif - - if (connected) { - disconnectPending = true; - } - closeSocket(sock); - sock = INVALID_SOCKET; - connected = connectPending = false; - reconnectCounter = 0; + const auto chars = std::span{message, static_cast(length)}; + netContext->send(socketId, std::as_bytes(chars)); } +void reconnect() { + netContext.reset(); + netContext = std::make_unique(); + connected = false; + connectPending = false; + socketId = netContext->connect(storedEndpoint); +} + +void poll_network() { + if (!netContext) { + return; + } + + borealis::net::Event event; + while (netContext->poll(event)) { + if (event.id != socketId) { + continue; + } + if (event.kind == borealis::net::Event::Kind::Connected) { + connected = true; + connectPending = true; + send_cmd("initgametime"); + } else if (event.kind == borealis::net::Event::Kind::Closed) { + if (connected) { + disconnectPending = true; + } + connected = false; + connectPending = false; + socketId = 0; + reconnectCounter = 0; + } + } +} + +} // namespace + uint64_t getFrameCount() { return frameCount; } @@ -111,10 +84,9 @@ void onGameFrame() { return; } - bool loading = fopOvlpM_IsDoingReq() != 0; - + const bool loading = fopOvlpM_IsDoingReq() != 0; if (loading != wasLoading) { - sendCmd(loading ? "pausegametime" : "unpausegametime"); + send_cmd(loading ? "pausegametime" : "unpausegametime"); wasLoading = loading; } @@ -141,172 +113,74 @@ void reset() { startPending = false; frameCount = 0; wasLoading = false; - sendCmd("reset"); -} - -static void reconnect() { - if (sock != INVALID_SOCKET) { - closeSocket(sock); - sock = INVALID_SOCKET; - } - connected = connectPending = false; - - sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sock == INVALID_SOCKET) { - return; - } - -#if _WIN32 - u_long nb = 1; - if (ioctlsocket(sock, FIONBIO, &nb) != 0) { - closeSocket(sock); - sock = INVALID_SOCKET; - return; - } -#else - const int fl = fcntl(sock, F_GETFL, 0); - if (fl < 0 || fcntl(sock, F_SETFL, fl | O_NONBLOCK) < 0) { - closeSocket(sock); - sock = INVALID_SOCKET; - return; - } -#endif - -#if defined(__APPLE__) - { - int opt = 1; - setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt)); - } -#endif - - sockaddr_in addr{}; - addr.sin_family = AF_INET; - addr.sin_port = htons(static_cast(storedPort)); - if (inet_pton(AF_INET, storedHost, &addr.sin_addr) != 1) { - closeSocket(sock); - sock = INVALID_SOCKET; - return; - } - - const int cr = connect(sock, reinterpret_cast(&addr), sizeof(addr)); -#if _WIN32 - const bool connectPending_ = cr < 0 && WSAGetLastError() == WSAEWOULDBLOCK; -#else - const bool connectPending_ = cr < 0 && errno == EINPROGRESS; -#endif - if (cr != 0 && !connectPending_) { - closeSocket(sock); - sock = INVALID_SOCKET; - } + send_cmd("reset"); } void connectLiveSplit(const char* host, int port) { -#if _WIN32 - WSADATA wd{}; - WSAStartup(MAKEWORD(2, 2), &wd); -#endif - snprintf(storedHost, sizeof(storedHost), "%s", host); - storedPort = port; + std::string endpointHost = host; + if (endpointHost.find(':') != std::string::npos && + !(endpointHost.starts_with('[') && endpointHost.ends_with(']'))) + { + endpointHost = '[' + endpointHost + ']'; + } + storedEndpoint = "tcp://" + endpointHost + ':' + std::to_string(port); reconnect(); } void disconnectLiveSplit() { - if (sock != INVALID_SOCKET) { - closeSocket(sock); - sock = INVALID_SOCKET; - } - connected = connectPending = disconnectPending = false; + netContext.reset(); + socketId = 0; + connected = false; + connectPending = false; + disconnectPending = false; } bool consumeConnectedEvent() { - bool v = connectPending; + const bool value = connectPending; connectPending = false; - return v; + return value; } + bool consumeDisconnectedEvent() { - bool v = disconnectPending; + const bool value = disconnectPending; disconnectPending = false; - return v; + return value; } void updateLiveSplit() { - if (sock == INVALID_SOCKET) { + poll_network(); + if (socketId == 0) { if ((reconnectCounter++ % 30) == 0) { reconnect(); } return; } - if (!connected) { - fd_set writefds, errorfds; - FD_ZERO(&writefds); - FD_ZERO(&errorfds); - FD_SET(sock, &writefds); - FD_SET(sock, &errorfds); - timeval tv{0, 0}; -#if _WIN32 - const int r = select(0, nullptr, &writefds, &errorfds, &tv); -#else - const int r = select(sock + 1, nullptr, &writefds, &errorfds, &tv); -#endif - if (r < 0 || FD_ISSET(sock, &errorfds) || socketError(sock) != 0) { - closeSocket(sock); - sock = INVALID_SOCKET; - reconnectCounter = 0; - return; - } - if (!FD_ISSET(sock, &writefds)) { - return; - } - sendCmd("initgametime"); return; } if (startPending) { startPending = false; - sendCmd("initgametime"); - sendCmd("reset"); - sendCmd("starttimer"); + send_cmd("initgametime"); + send_cmd("reset"); + send_cmd("starttimer"); } if (!running) { - if ((idleProbeCounter++ % 60) == 0) { - char buf; - const int r = recv(sock, &buf, 1, 0); - if (r == 0 -#if _WIN32 - || (r < 0 && WSAGetLastError() != WSAEWOULDBLOCK) -#else - || (r < 0 && errno != EAGAIN && errno != EWOULDBLOCK) -#endif - ) - { - if (connected) { - disconnectPending = true; - } - closeSocket(sock); - sock = INVALID_SOCKET; - connected = connectPending = false; - reconnectCounter = 0; - } - } return; } const uint64_t totalMs = frameCount * 1000 / 30; const uint64_t totalSec = totalMs / 1000; - char cmd[32]; - snprintf(cmd, sizeof(cmd), "setgametime %u:%02u:%02u.%03u", + char command[32]; + snprintf(command, sizeof(command), "setgametime %u:%02u:%02u.%03u", static_cast(totalSec / 3600), static_cast((totalSec / 60) % 60), static_cast(totalSec % 60), static_cast(totalMs % 1000)); - sendCmd(cmd); + send_cmd(command); } void shutdown() { disconnectLiveSplit(); -#if _WIN32 - WSACleanup(); -#endif } } // namespace dusk::speedrun diff --git a/src/dusk/logging.cpp b/src/dusk/logging.cpp index 1f3a0451b4..b85635f1a5 100644 --- a/src/dusk/logging.cpp +++ b/src/dusk/logging.cpp @@ -1,8 +1,8 @@ #include "dusk/logging.h" -#include +#include -#include "tracy/Tracy.hpp" +#include bool StubLogEnabled = true; diff --git a/src/dusk/mod_loader.hpp b/src/dusk/mod_loader.hpp index bf3e93aa53..d07f0d6f2c 100644 --- a/src/dusk/mod_loader.hpp +++ b/src/dusk/mod_loader.hpp @@ -1,15 +1,17 @@ #pragma once -#include -#include -#include -#include -#include -#include - #include "dusk/config.hpp" #include "dusk/config_var.hpp" #include "mods/api.h" +#include "mods/runtime.h" + +#include +#include +#include +#include +#include +#include +#include namespace dusk::mods { struct LoadedMod; @@ -35,6 +37,7 @@ struct ModManifestInfo { struct Import { std::string id; uint16_t major = 0; + uint16_t minMinor = 0; bool required = false; bool operator==(const Import&) const = default; }; @@ -48,6 +51,19 @@ struct ModManifestInfo { bool operator==(const ModManifestInfo&) const = default; }; +struct DelegatedModRuntime { + std::string id; + uint16_t major = 0; + uint16_t minMinor = 0; + + const ModRuntimeService* service = nullptr; + ModContext* providerContext = nullptr; + + bool operator==(const DelegatedModRuntime& other) const { + return id == other.id && major == other.major && minMinor == other.minMinor; + } +}; + struct ModMetadata { std::string id; std::string name; @@ -180,7 +196,7 @@ struct LoadedMod { bool loadFailed = false; std::string failureReason; - // mod_initialize succeeded; a mod_shutdown is owed on deactivation. + // Initialization succeeded; shutdown is owed on deactivation. bool initialized = false; // Static service exports are currently present in the registry. bool servicesRegistered = false; @@ -202,6 +218,7 @@ struct LoadedMod { NativeModStatus nativeStatus = NativeModStatus::None; std::unique_ptr native; + std::optional runtime; std::unique_ptr context; // Shared with overlay file registrations so in-flight DVD reads survive disable/reload. diff --git a/src/dusk/mods/item.hpp b/src/dusk/mods/item.hpp index bda0d4f7ee..1b8897ae00 100644 --- a/src/dusk/mods/item.hpp +++ b/src/dusk/mods/item.hpp @@ -20,6 +20,7 @@ struct ItemCheckResult { uint32_t tag = 0; uint8_t itemNo = 0; uint8_t displayItemNo = 0; + bool was_resolved = false; }; ItemCheckResolution item_check_resolve(const char* name, uint8_t itemNo, fopAc_ac_c* giver); @@ -57,6 +58,13 @@ uint32_t item_check_message(uint16_t group, uint32_t messageId); bool item_give_queue_dispatching(); uint32_t item_give_queue_take_tag(); +struct BossItemActorSpeeds { + f32 f; + f32 y; +}; +void set_boss_item_actor_speeds(f32 f, f32 y); +BossItemActorSpeeds get_boss_item_actor_speeds(); + namespace detail { struct CommittedCheck { uint8_t vanillaItem = 0; diff --git a/src/dusk/mods/item_actor.cpp b/src/dusk/mods/item_actor.cpp new file mode 100644 index 0000000000..dc0feab472 --- /dev/null +++ b/src/dusk/mods/item_actor.cpp @@ -0,0 +1,15 @@ +#include "item.hpp" + +namespace dusk::mods { + +static BossItemActorSpeeds bossItemActorSpeeds{}; +void set_boss_item_actor_speeds(f32 f, f32 y) { + bossItemActorSpeeds.f = f; + bossItemActorSpeeds.y = y; +} + +BossItemActorSpeeds get_boss_item_actor_speeds() { + return bossItemActorSpeeds; +} + +} diff --git a/src/dusk/mods/item_checks.cpp b/src/dusk/mods/item_checks.cpp index fb145a48df..221654ea07 100644 --- a/src/dusk/mods/item_checks.cpp +++ b/src/dusk/mods/item_checks.cpp @@ -3,17 +3,16 @@ #include "dusk/mod_loader.hpp" #include "dusk/mods/loader/loader.hpp" #include "dusk/mods/svc/item.hpp" - -#include "aurora/lib/logging.hpp" -#include "d/d_com_inf_game.h" -#include "d/d_item_data.h" #include "mods/items.h" +#include "d/d_com_inf_game.h" +#include "d/d_item_data.h" + +#include #include #include #include -#include #include #include #include @@ -120,6 +119,12 @@ constexpr std::array kMessageChecks{ .vanillaItem = dItemNo_HORSE_FLUTE_e, .enqueueAtDisplay = false, }, + MessageCheck{ + .group = 2, + .messageId = 6531, + .name = ITEM_CHECK_SHAD_DOMINION_ROD, + .vanillaItem = dItemNo_COPY_ROD_2_e, + } }; std::unordered_map s_modChecks; @@ -152,7 +157,7 @@ std::string poe_check_name(uint8_t bitNo) { } std::string shop_check_name(uint8_t itemNo) { - return fmt::format("shop:{}:{}", current_stage_name(), itemNo); + return fmt::format("shop:{}:{}:{}", current_stage_name(), dStage_roomControl_c::getStayNo(), itemNo); } std::string bug_check_name(uint8_t insectId) { @@ -229,6 +234,7 @@ ItemCheckResolution item_check_resolve(const char* name, uint8_t itemNo, fopAc_a .vanilla_item = itemNo, .current_item = itemNo, .current_display_item = itemNo, + .was_resolved = false, }; for (const auto& resolve : resolves) { if (!resolve.mod->active) { @@ -237,6 +243,7 @@ ItemCheckResolution item_check_resolve(const char* name, uint8_t itemNo, fopAc_a if (resolve.fixedValue) { info.current_item = resolve.itemNo; info.current_display_item = resolve.itemNo; + info.was_resolved = true; continue; } @@ -251,6 +258,7 @@ ItemCheckResolution item_check_resolve(const char* name, uint8_t itemNo, fopAc_a } info.current_item = resolution.item; info.current_display_item = resolution.display_item; + info.was_resolved = true; } } catch (const std::exception& e) { fail_mod(*resolve.mod, MOD_ERROR, @@ -263,6 +271,7 @@ ItemCheckResolution item_check_resolve(const char* name, uint8_t itemNo, fopAc_a return { .item = info.current_item, .display_item = info.current_display_item, + .was_resolved = info.was_resolved, }; } diff --git a/src/dusk/mods/item_gives.cpp b/src/dusk/mods/item_gives.cpp index 5d75dcfc15..7a0ed3f6b1 100644 --- a/src/dusk/mods/item_gives.cpp +++ b/src/dusk/mods/item_gives.cpp @@ -4,13 +4,13 @@ #include "dusk/mods/loader/loader.hpp" #include "dusk/mods/svc/item.hpp" -#include "aurora/lib/logging.hpp" #include "d/actor/d_a_alink.h" #include "d/d_com_inf_game.h" #include "d/d_item.h" #include "d/d_item_data.h" #include "f_op/f_op_actor_mng.h" +#include #include #include @@ -265,6 +265,7 @@ ItemCheckResult item_check_commit(uint32_t giveTag, uint8_t itemNo, fopAc_ac_c* .tag = giveTag, .itemNo = committed->resolution.item, .displayItemNo = committed->resolution.display_item, + .was_resolved = committed->resolution.was_resolved, }; } @@ -274,6 +275,7 @@ ItemCheckResult item_check_commit(uint32_t giveTag, uint8_t itemNo, fopAc_ac_c* .tag = giveTag, .itemNo = committed.resolution.item, .displayItemNo = committed.resolution.display_item, + .was_resolved = committed.resolution.was_resolved, }; } diff --git a/src/dusk/mods/loader/bundle_zip.cpp b/src/dusk/mods/loader/bundle_zip.cpp index 517c5943c2..6075dd5dc1 100644 --- a/src/dusk/mods/loader/bundle_zip.cpp +++ b/src/dusk/mods/loader/bundle_zip.cpp @@ -1,6 +1,7 @@ -#include "fmt/format.h" #include "loader.hpp" +#include + #include namespace dusk::mods { diff --git a/src/dusk/mods/loader/loader.cpp b/src/dusk/mods/loader/loader.cpp index 83c7660410..71b17b7cff 100644 --- a/src/dusk/mods/loader/loader.cpp +++ b/src/dusk/mods/loader/loader.cpp @@ -1,36 +1,37 @@ #include "loader.hpp" -#include "dusk/logging.h" -#include "dusk/mod_loader.hpp" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "../manifest.hpp" #include "depgraph.hpp" +#include "native_module.hpp" +#if DUSK_HAS_PREPATCH +#include "prepatch.hpp" +#endif + #include "dusk/config.hpp" #include "dusk/data.hpp" #include "dusk/io.hpp" +#include "dusk/logging.h" +#include "dusk/mod_loader.hpp" #include "dusk/mods/log_buffer.hpp" #include "dusk/mods/svc/config.hpp" #include "dusk/mods/svc/hook.hpp" #include "dusk/mods/svc/registry.hpp" #include "dusk/ui/mods_window.hpp" #include "dusk/ui/ui.hpp" -#include "miniz.h" -#include "native_module.hpp" -#include "nlohmann/json.hpp" -#if DUSK_HAS_PREPATCH -#include "prepatch.hpp" -#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std::string_literals; using namespace std::string_view_literals; @@ -269,7 +270,57 @@ static std::string resolve_image_path(ModBundle& bundle, const std::string& modI return {}; } -static ModMetadata load_metadata(const std::filesystem::path& modPath, ModBundle& bundle) { +struct LoadedManifest { + ModMetadata metadata; + std::optional runtime; +}; + +static uint16_t parse_runtime_version_component(std::string_view text, std::string_view fieldName) { + uint32_t value = 0; + const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), value); + if (text.empty() || error != std::errc{} || end != text.data() + text.size() || + value > UINT16_MAX) + { + throw InvalidModDataException(fmt::format("Invalid {} in runtime version pin", fieldName)); + } + return static_cast(value); +} + +static std::optional parse_runtime(const nlohmann::json& manifest) { + const auto field = manifest.find("runtime"); + if (field == manifest.end()) { + return std::nullopt; + } + if (!field->is_string()) { + throw InvalidModDataException("runtime must be a string"); + } + + const std::string pin = field->get(); + const auto at = pin.rfind('@'); + if (at == std::string::npos || at == 0 || at + 1 == pin.size() || pin.find('@') != at || + at >= MOD_META_SERVICE_ID_SIZE) + { + throw InvalidModDataException( + "runtime must be a service id followed by @major or @major.minor"); + } + + const std::string_view version{pin.data() + at + 1, pin.size() - at - 1}; + const auto dot = version.find('.'); + if (dot != std::string_view::npos && version.find('.', dot + 1) != std::string_view::npos) { + throw InvalidModDataException("runtime version pin has too many components"); + } + + DelegatedModRuntime result; + result.id = pin.substr(0, at); + result.major = parse_runtime_version_component( + dot == std::string_view::npos ? version : version.substr(0, dot), "major version"); + if (dot != std::string_view::npos) { + result.minMinor = parse_runtime_version_component(version.substr(dot + 1), "minor version"); + } + return result; +} + +static LoadedManifest load_manifest(const std::filesystem::path& modPath, ModBundle& bundle) { const auto metaJson = bundle.readFile("mod.json"); auto j = nlohmann::json::parse(metaJson); @@ -297,14 +348,18 @@ static ModMetadata load_metadata(const std::filesystem::path& modPath, ModBundle std::string bannerPath = resolve_image_path(bundle, metaId, "banner", metaBanner, "res/banner.png"s); - return ModMetadata{ - std::move(metaId), - std::move(metaName), - std::move(metaVersion), - std::move(metaAuthor), - std::move(metaDescription), - std::move(iconPath), - std::move(bannerPath), + return LoadedManifest{ + .metadata = + { + std::move(metaId), + std::move(metaName), + std::move(metaVersion), + std::move(metaAuthor), + std::move(metaDescription), + std::move(iconPath), + std::move(bannerPath), + }, + .runtime = parse_runtime(j), }; } @@ -517,8 +572,8 @@ std::filesystem::path ModLoader::external_native_lib_path(const LoadedMod& mod) if (libDir.empty()) { return {}; } - fs::path path = libDir / fs::path(mod.metadata.id + - borealis::io::fs_path_to_string(fs::path(k_nativeLibName).extension())); + fs::path path = libDir / fs::path(mod.metadata.id + borealis::io::fs_path_to_string( + fs::path(k_nativeLibName).extension())); std::error_code ec; if (!fs::is_regular_file(path, ec)) { return {}; @@ -684,6 +739,13 @@ bool ModLoader::load_native_if_present(LoadedMod& mod) { } const auto& native = std::get(result); + if (mod.runtime.has_value() && + (native.anyLibs || (mod.inPlace && !external_native_lib_path(mod).empty()))) + { + mod.nativeStatus = NativeModStatus::InvalidBundle; + fail_mod(mod, MOD_CONFLICT, "A mod cannot declare both runtime and native code"); + return false; + } if (!native.anyLibs && !(mod.inPlace && !external_native_lib_path(mod).empty())) { mod.nativeStatus = NativeModStatus::None; return true; @@ -728,7 +790,7 @@ static ModManifestInfo build_manifest_info(const ModMetaParsed& parsed) { continue; } info.imports.push_back({record->service_id.chars, record->major_version, - (record->rec.flags & SERVICE_IMPORT_OPTIONAL) == 0}); + record->min_minor_version, (record->rec.flags & SERVICE_IMPORT_OPTIONAL) == 0}); } info.exports.reserve(parsed.exports.size()); for (const auto* record : parsed.exports) { @@ -801,21 +863,22 @@ void ModLoader::try_load_mod( return; } - ModMetadata metadata; + LoadedManifest manifest; try { - metadata = load_metadata(modPath, *bundle); + manifest = load_manifest(modPath, *bundle); } catch (const std::exception& e) { Log.error("bad mod.json in {}: {}", data::abbreviated_path_string(modPath), e.what()); return; } - if (const auto* existing = find_mod(metadata.id)) { + if (const auto* existing = find_mod(manifest.metadata.id)) { if (existing->searchDirIndex < searchDirIndex) { - log::write(metadata.id, LOG_LEVEL_INFO, "{} shadowed by higher-priority duplicate {}", + log::write(manifest.metadata.id, LOG_LEVEL_INFO, + "{} shadowed by higher-priority duplicate {}", data::abbreviated_path_string(modPath), data::abbreviated_path_string(existing->modPath)); } else { - log::write(metadata.id, LOG_LEVEL_ERROR, "duplicate mod id, not loading {}", + log::write(manifest.metadata.id, LOG_LEVEL_ERROR, "duplicate mod id, not loading {}", data::abbreviated_path_string(modPath)); } return; @@ -827,12 +890,29 @@ void ModLoader::try_load_mod( mod.modPath = fs::absolute(modPath); mod.searchDirIndex = searchDirIndex; mod.inPlace = m_searchDirs[searchDirIndex].inPlaceNative && fromDir; - mod.metadata = std::move(metadata); + mod.metadata = std::move(manifest.metadata); + mod.runtime = std::move(manifest.runtime); mod.bundle = std::move(bundle); mod.context = std::make_unique(); mod.context->mod = &mod; mod.cvarIsEnabled = std::make_unique>(mod_enabled_cvar_name(mod.metadata.id), true); + if (mod.runtime.has_value()) { + const auto& runtime = *mod.runtime; + mod.manifestInfo.imports.push_back({runtime.id, runtime.major, runtime.minMinor, true}); + + std::error_code ec; + mod.dir = fs::absolute(m_cacheDir / mod.metadata.id / "data", ec); + if (!ec) { + fs::create_directories(mod.dir, ec); + } + if (ec) { + fail_mod(mod, MOD_ERROR, + fmt::format("Failed to create script scratch directory: {}", ec.message())); + } else { + mod.dirUtf8 = borealis::io::fs_path_to_string(mod.dir); + } + } if (load_native_if_present(mod) && mod.native) { mod.manifestInfo = build_manifest_info(mod.native->parsed); } @@ -846,12 +926,12 @@ bool ModLoader::activate_mod(LoadedMod& mod) { mod.active = true; // Asset-only mods have no lifecycle beyond their overlay files. - if (!mod.native) { + if (!mod.native && !mod.runtime.has_value()) { mod.enabledApplied = true; return true; } - if (!mod.servicesRegistered) { + if (mod.native && !mod.servicesRegistered) { if (!register_static_service_exports(mod)) { log::write(mod.metadata.id, LOG_LEVEL_ERROR, "failed to register service exports"); deactivate_mod(mod); @@ -860,30 +940,60 @@ bool ModLoader::activate_mod(LoadedMod& mod) { mod.servicesRegistered = true; } - if (!resolve_service_imports(mod)) { + if (mod.native && !resolve_service_imports(mod)) { log::write(mod.metadata.id, LOG_LEVEL_ERROR, "failed to resolve service imports"); deactivate_mod(mod); return false; } - svc::hook_resolve_mod_records(mod); + if (mod.native) { + svc::hook_resolve_mod_records(mod); + *mod.native->contextSymbol = mod.context.get(); + } else { + auto& runtime = *mod.runtime; + const auto* record = svc::find_service(runtime.id.c_str(), runtime.major, runtime.minMinor); + if (record == nullptr) { + fail_mod(mod, MOD_UNAVAILABLE, + describe_missing_import(runtime.id.c_str(), runtime.major, runtime.minMinor)); + deactivate_mod(mod); + return false; + } - *mod.native->contextSymbol = mod.context.get(); + const auto* service = static_cast(record->service); + constexpr size_t kRequiredSize = offsetof(ModRuntimeService, deactivate) + + sizeof(((ModRuntimeService*)nullptr)->deactivate); + if (record->provider == nullptr || service == nullptr || + service->header.struct_size < kRequiredSize || service->activate == nullptr || + service->update == nullptr || service->deactivate == nullptr) + { + fail_mod(mod, MOD_UNAVAILABLE, + fmt::format("Runtime service {}@{} has an invalid lifecycle contract", runtime.id, + runtime.major)); + deactivate_mod(mod); + return false; + } + runtime.service = service; + runtime.providerContext = record->provider->context.get(); + } - log::write(mod.metadata.id, LOG_LEVEL_TRACE, "calling mod_initialize"); + const char* initializeName = mod.native ? "mod_initialize" : "runtime activate"; + log::write(mod.metadata.id, LOG_LEVEL_TRACE, "calling {}", initializeName); try { ModError error = MOD_ERROR_INIT; - const auto result = mod.native->fn_initialize(&error); + const auto result = mod.native ? + mod.native->fn_initialize(&error) : + mod.runtime->service->activate( + mod.runtime->providerContext, mod.context.get(), &error); if (result == MOD_OK && !mod.loadFailed) { mod.initialized = true; - log::write(mod.metadata.id, LOG_LEVEL_TRACE, "mod_initialize succeeded"); + log::write(mod.metadata.id, LOG_LEVEL_TRACE, "{} succeeded", initializeName); } else if (result != MOD_OK && !mod.loadFailed) { - fail_mod(mod, result, lifecycle_error_message("mod_initialize", result, error)); + fail_mod(mod, result, lifecycle_error_message(initializeName, result, error)); } } catch (const std::exception& e) { - fail_mod(mod, MOD_ERROR, fmt::format("Exception in mod_initialize: {}", e.what())); + fail_mod(mod, MOD_ERROR, fmt::format("Exception in {}: {}", initializeName, e.what())); } catch (...) { - fail_mod(mod, MOD_ERROR, "Unknown exception in mod_initialize"); + fail_mod(mod, MOD_ERROR, fmt::format("Unknown exception in {}", initializeName)); } warn_unpublished_deferred_exports(mod); @@ -900,21 +1010,36 @@ bool ModLoader::activate_mod(LoadedMod& mod) { void ModLoader::deactivate_mod(LoadedMod& mod) { svc::modules_mod_deactivating(mod); - if (mod.initialized && mod.native && mod.native->fn_shutdown) { - log::write(mod.metadata.id, LOG_LEVEL_TRACE, "calling mod_shutdown"); + if (mod.initialized && ((mod.native && mod.native->fn_shutdown) || + (mod.runtime.has_value() && mod.runtime->service != nullptr))) + { + const char* shutdownName = mod.native ? "mod_shutdown" : "runtime deactivate"; + log::write(mod.metadata.id, LOG_LEVEL_TRACE, "calling {}", shutdownName); try { ModError error = MOD_ERROR_INIT; - const auto result = mod.native->fn_shutdown(&error); + const auto result = mod.native ? + mod.native->fn_shutdown(&error) : + mod.runtime->service->deactivate( + mod.runtime->providerContext, mod.context.get(), &error); if (result == MOD_OK) { - log::write(mod.metadata.id, LOG_LEVEL_TRACE, "mod_shutdown succeeded"); + log::write(mod.metadata.id, LOG_LEVEL_TRACE, "{} succeeded", shutdownName); } else { - log::write(mod.metadata.id, LOG_LEVEL_ERROR, "mod_shutdown failed: {}", - lifecycle_error_message("mod_shutdown", result, error)); + log::write(mod.metadata.id, LOG_LEVEL_ERROR, "{} failed: {}", shutdownName, + lifecycle_error_message(shutdownName, result, error)); } + } catch (const std::exception& exception) { + log::write( + mod.metadata.id, LOG_LEVEL_ERROR, "{} threw: {}", shutdownName, exception.what()); } catch (...) { + log::write( + mod.metadata.id, LOG_LEVEL_ERROR, "{} threw an unknown exception", shutdownName); } } mod.initialized = false; + if (mod.runtime.has_value()) { + mod.runtime->service = nullptr; + mod.runtime->providerContext = nullptr; + } if (mod.servicesRegistered) { svc::remove_services_for_provider(mod); @@ -1168,29 +1293,35 @@ bool ModLoader::reload_bundle(LoadedMod& mod) { data::abbreviated_path_string(mod.modPath)); std::shared_ptr newBundle; - ModMetadata newMetadata; + LoadedManifest newManifest; try { std::error_code ec; newBundle = load_bundle(mod.modPath, fs::is_directory(mod.modPath, ec)); - newMetadata = load_metadata(mod.modPath, *newBundle); + newManifest = load_manifest(mod.modPath, *newBundle); } catch (const std::exception& e) { fail_mod(mod, MOD_ERROR, fmt::format("Reload failed: {}", e.what())); return false; } - if (newMetadata.id != mod.metadata.id) { + if (newManifest.metadata.id != mod.metadata.id) { fail_mod(mod, MOD_CONFLICT, - fmt::format("Mod ID changed on reload ('{}'); restart required", newMetadata.id)); + fmt::format( + "Mod ID changed on reload ('{}'); restart required", newManifest.metadata.id)); return false; } - mod.metadata = std::move(newMetadata); + mod.metadata = std::move(newManifest.metadata); + mod.runtime = std::move(newManifest.runtime); // In-flight readers of the old bundle keep it alive through their shared_ptr. mod.bundle = std::move(newBundle); mod.loadFailed = false; mod.failureReason.clear(); ModManifestInfo newInfo; + if (mod.runtime.has_value()) { + const auto& runtime = *mod.runtime; + newInfo.imports.push_back({runtime.id, runtime.major, runtime.minMinor, true}); + } if (!load_native_if_present(mod)) { return false; } @@ -1364,17 +1495,23 @@ void ModLoader::tick() { apply_pending_requests(); for (auto& mod : mods()) { - if (!mod.active || !mod.native) { + if (!mod.active || (!mod.native && !mod.runtime.has_value())) { continue; } try { ModError error = MOD_ERROR_INIT; - const auto result = mod.native->fn_update(&error); + const bool delegated = !mod.native; + const auto result = delegated ? + mod.runtime->service->update( + mod.runtime->providerContext, mod.context.get(), &error) : + mod.native->fn_update(&error); if (result != MOD_OK) { - fail_mod(mod, result, lifecycle_error_message("mod_update", result, error)); + fail_mod(mod, result, + lifecycle_error_message( + delegated ? "runtime update" : "mod_update", result, error)); } } catch (const std::exception& e) { - fail_mod(mod, MOD_ERROR, fmt::format("Exception in mod_update: {}", e.what())); + fail_mod(mod, MOD_ERROR, fmt::format("Exception in mod update: {}", e.what())); } catch (...) { fail_mod(mod, MOD_ERROR, "Unknown exception in mod_update"); } diff --git a/src/dusk/mods/log_buffer.hpp b/src/dusk/mods/log_buffer.hpp index 33a143705d..2787ccb07f 100644 --- a/src/dusk/mods/log_buffer.hpp +++ b/src/dusk/mods/log_buffer.hpp @@ -1,13 +1,12 @@ #pragma once -#include -#include -#include -#include +#include "mods/svc/log.h" #include -#include "mods/svc/log.h" +#include +#include +#include namespace dusk::mods::log { diff --git a/src/dusk/mods/manifest.hpp b/src/dusk/mods/manifest.hpp index c6bc03f038..586759a8b1 100644 --- a/src/dusk/mods/manifest.hpp +++ b/src/dusk/mods/manifest.hpp @@ -1,10 +1,10 @@ #pragma once +#include "mods/svc/hook.h" + #include #include -#include "mods/svc/hook.h" - namespace dusk::mods::manifest { // Symbol flags mirrored from symgen. diff --git a/src/dusk/mods/svc/actor.cpp b/src/dusk/mods/svc/actor.cpp new file mode 100644 index 0000000000..19aa8c9c20 --- /dev/null +++ b/src/dusk/mods/svc/actor.cpp @@ -0,0 +1,401 @@ +#include "mods/svc/actor.h" + +#include "actor.hpp" +#include "internal.hpp" +#include "registry.hpp" + +#include "dusk/mod_loader.hpp" +#include "dusk/mods/loader/loader.hpp" + +#include "d/d_stage.h" +#include "f_op/f_op_actor_tag.h" +#include "f_pc/f_pc_deletor.h" + +#include + +#include + +namespace dusk::mods::svc::actor_impl { +namespace { + +aurora::Module Log("dusk::mods::actor"); + +SlotMap> s_slots; +std::unordered_map procNameToHandle; +std::unordered_map fullNameToHandle; + +ActorSlot* get_actor_slot(void* actorPtr) { + auto* actor = static_cast(actorPtr); + const auto handle = procNameToHandle.find(actor->name); + if (handle == procNameToHandle.end()) { + return nullptr; + } + auto* slot = s_slots.find(handle->second); + return slot != nullptr ? slot->value.get() : nullptr; +} + +int actor_is_delete(void* actorPtr) { + auto* slot = get_actor_slot(actorPtr); + if (slot == nullptr || slot->forceDelete) { + return 1; + } + return slot->isDeleteFunction(actorPtr); +} + +int actor_delete(void* actorPtr) { + auto* slot = get_actor_slot(actorPtr); + if (slot == nullptr) { + return 1; + } + const bool forceDelete = slot->forceDelete; + const int result = slot->deleteFunction(actorPtr); + return forceDelete ? 1 : result; +} + +ModResult register_actor(ModContext* ctx, const ActorProfileDesc* desc, ProfileName* outProfileName, + ActorHandle* outActorHandle) { + auto* owner = mod_from_context(ctx); + if (owner == nullptr || desc == nullptr || outProfileName == nullptr || + outActorHandle == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + if (desc->name[0] == '\0' || std::memchr(desc->name, '\0', sizeof(desc->name)) == nullptr || + desc->process_size < sizeof(fopAc_ac_c) || desc->create_function == nullptr || + desc->delete_function == nullptr || desc->execute_function == nullptr || + desc->is_delete_function == nullptr || desc->draw_function == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + + // If another mod has already registered an actor with this name, note a conflict + if (get_stageinfo_from_full_name(desc->name)) { + return MOD_CONFLICT; + } + + const auto handle = s_slots.emplace(*owner, + std::make_unique( + ActorSlot{{desc->create_function, actor_delete, desc->execute_function, actor_is_delete, + desc->draw_function}, + desc->delete_function, desc->is_delete_function, false, + { + {}, // Set after registered + 0, // Set after registered to a slot + -1 // Use the default argument + }, + { + /* Layer ID */ fpcLy_CURRENT_e, + /* List ID */ desc->priority_group, + /* List Prio */ fpcPi_CURRENT_e, // Always fpcPi_CURRENT_e + /* Proc Name */ 0, + /* Proc SubMtd */ &g_fpcLf_Method.base, // usually: &g_fpcLf_Method.base + /* Size */ (u32)desc->process_size, + /* Size Other */ 0, // Always 0 + /* Parameters */ 0, // Always 0 + /* Leaf SubMtd */ &g_fopAc_Method.base, // usually &g_fopAc_Method.base + /* Draw Prio */ desc->draw_priority, + /* Actor SubMtd */ nullptr, // set this later + /* Status */ desc->status, + /* Group */ desc->group, + /* Cull Type */ desc->cull_type, + }})); + + s32 procNameFull = fpcNm_MAX_NUM + s_slots.index_of(handle); + if (procNameFull >= 0x7FFF) { + s_slots.erase(handle); + Log.error("Hit registered actor limit (0x7FFF) while registering actor {}", desc->name); + return MOD_ERROR; + } + + ActorSlot& slot = *s_slots.find(handle)->value.get(); + strncpy(slot.objNameInf.name, desc->name, sizeof(slot.objNameInf.name) - 1); + slot.profile.sub_method = &slot.methodTable; + s16 procName = (s16)procNameFull; + procNameToHandle[procName] = handle; + fullNameToHandle[std::string(slot.objNameInf.name)] = handle; + slot.objNameInf.procname = (s16)procName; + slot.profile.base.base.name = procName; + *outProfileName = procName; + *outActorHandle = handle; + + return MOD_OK; +} + +// Must be called before the slot associated with the handle is erased +void remove_handle_from_maps(ActorHandle handle) { + auto entry = s_slots.find(handle); + if (entry == nullptr) { + return; + } + + std::string fullName = entry->value->objNameInf.name; + + const auto it = fullNameToHandle.find(fullName); + if (it != fullNameToHandle.end()) { + fullNameToHandle.erase(it); + } + + const auto it2 = procNameToHandle.find(entry->value->profile.base.base.name); + if (it2 != procNameToHandle.end()) { + procNameToHandle.erase(it2); + } +} + +void request_delete_all_actors_of_name(s16 procName) { + node_class* node = g_fopAcTg_Queue.mpHead; + while (node != nullptr) { + node_class* next = NODE_GET_NEXT(node); + auto* actor = + static_cast(reinterpret_cast(node)->mpTagData); + if (actor->name == procName) { + fopAcM_delete(actor); + } + node = next; + } +} + +bool finish_delete_all_actors_of_name(s16 procName) { + bool complete = true; + + node_class* node = g_fpcDtTg_Queue.mpHead; + while (node != nullptr) { + node_class* next = NODE_GET_NEXT(node); + auto* tag = reinterpret_cast(node); + auto* proc = static_cast(tag->base.mpTagData); + if (proc->name == procName) { + tag->timer = 0; + const int deleteStatus = fpcDtTg_Do( + tag, [](void* proc) { return fpcDt_deleteMethod((base_process_class*)proc); }); + if (deleteStatus == 0) { + complete = false; + } + } + node = next; + } + return complete; +} + +bool has_actor_of_name(s16 procName) { + node_class* node = g_fopAcTg_Queue.mpHead; + while (node != nullptr) { + auto* actor = + static_cast(reinterpret_cast(node)->mpTagData); + if (actor->name == procName) { + return true; + } + node = NODE_GET_NEXT(node); + } + return false; +} + +ModResult unregister_actor(ModContext* ctx, ActorHandle handle) { + auto* owner = mod_from_context(ctx); + if (owner == nullptr) { + return MOD_INVALID_ARGUMENT; + } + auto* slot = s_slots.find_owned(handle, *owner); + if (slot == nullptr) { + return MOD_INVALID_ARGUMENT; + } + + const s16 actorProcName = slot->value->profile.base.base.name; + slot->value->forceDelete = true; + request_delete_all_actors_of_name(actorProcName); + const bool deletesFinished = finish_delete_all_actors_of_name(actorProcName); + if (!deletesFinished || has_actor_of_name(actorProcName)) { + slot->value->forceDelete = false; + Log.warn("Actor profile '{}' could not be unregistered synchronously", + slot->value->objNameInf.name); + return MOD_UNAVAILABLE; + } + + remove_handle_from_maps(handle); + s_slots.erase_owned(handle, *owner); + + return MOD_OK; +} + +ModResult create_actor( + ModContext* ctx, ProfileName name, const ActorSpawnParams* params, ActorId* outId) { + cXyz pos = {params->position.x, params->position.y, params->position.z}; + csXyz angle = {params->angle.x, params->angle.y, params->angle.z}; + cXyz scale = {params->scale.x, params->scale.y, params->scale.z}; + fpc_ProcID id = fopAcM_create(name, 0xFFFF, params->parameters, &pos, params->room_num, &angle, + &scale, params->argument, params->create_function); + + if (id == fpcM_ERROR_PROCESS_ID_e) { + Log.error("Error Creating Actor with profile name {}", name); + return MOD_ERROR; + } + + if (outId) { + *outId = id; + } + return MOD_OK; +} + +ModResult create_actor_from_name( + ModContext* ctx, const char* name, const ActorSpawnParams* params, ActorId* outId) { + dStage_objectNameInf* objectName = dStage_searchName(name); + if (objectName == nullptr) { + Log.error("Attempted to create actor ({}) but it can't be found!", name); + return MOD_ERROR; + } + + ActorSpawnParams copy = *params; + copy.argument = objectName->argument; + + return create_actor(ctx, objectName->procname, ©, outId); +} + +ModResult create_child_actor(ModContext* ctx, ProfileName name, ActorId parentID, + const ActorSpawnParams* params, ActorId* outId) { + cXyz pos = {params->position.x, params->position.y, params->position.z}; + csXyz angle = {params->angle.x, params->angle.y, params->angle.z}; + cXyz scale = {params->scale.x, params->scale.y, params->scale.z}; + fpc_ProcID id = fopAcM_createChild(name, parentID, params->parameters, &pos, params->room_num, + &angle, &scale, params->argument, params->create_function); + + if (id == fpcM_ERROR_PROCESS_ID_e) { + Log.error("Error Creating Actor with profile name {} as child of actor with id {}", name, + parentID); + return MOD_ERROR; + } + + if (outId) { + *outId = id; + } + return MOD_OK; +} + +ModResult create_child_actor_from_name(ModContext* ctx, const char* name, ActorId parentID, + const ActorSpawnParams* params, ActorId* outId) { + dStage_objectNameInf* objectName = dStage_searchName(name); + if (objectName == nullptr) { + Log.error("Attempted to create actor ({}) but it can't be found!", name); + return MOD_ERROR; + } + + ActorSpawnParams copy = *params; + copy.argument = objectName->argument; + + return create_child_actor(ctx, objectName->procname, parentID, ©, outId); +} + +ModResult get_actor_id(ModContext* ctx, ProfileName name, ActorId* outId) { + fopAc_ac_c* actor = fopAcM_SearchByName(name); + if (actor == nullptr) { + Log.error("Attempting to get actor by profile name ({}) but it doesn't exist!", name); + return MOD_ERROR; + } + + *outId = fopAcM_GetID(actor); + return MOD_OK; +} + +ModResult get_actor_room_num(ModContext* ctx, ActorId actorId, int8_t* outRoomNum) { + fopAc_ac_c* actor = fopAcM_SearchByID(actorId); + if (actor == nullptr) { + Log.error("Attempted to get room number of actor Id ({}) but it doesn't exist!", actorId); + return MOD_ERROR; + } + + *outRoomNum = fopAcM_GetRoomNo(actor); + return MOD_OK; +} + +ModResult delete_actor(ModContext* ctx, ActorId actorId) { + if (mod_from_context(ctx) == nullptr) { + return MOD_INVALID_ARGUMENT; + } + fopAc_ac_c* actor = fopAcM_SearchByID(actorId); + if (actor == nullptr) { + Log.warn("Attempted to delete actor with ID ({}) but it doesn't exist!", actorId); + return MOD_OK; + } + return fopAcM_delete(actor) != 0 ? MOD_OK : MOD_UNAVAILABLE; +} + +} // namespace + +process_profile_definition* get_profile_from_proc_name(s16 name) { + const auto& it = procNameToHandle.find(name); + if (it == procNameToHandle.end()) { + return nullptr; + } + auto entry = s_slots.find(it->second); + if (entry) { + return &entry->value->profile.base.base; + } + return nullptr; +} + +const char* get_full_name_from_proc_name(s16 name) { + const auto& it = procNameToHandle.find(name); + if (it == procNameToHandle.end()) { + return ""; + } + auto entry = s_slots.find(it->second); + if (entry) { + return entry->value->objNameInf.name; + } + return ""; +} + +dStage_objectNameInf* get_stageinfo_from_full_name(const std::string& name) { + const auto& it = fullNameToHandle.find(name); + if (it == fullNameToHandle.end()) { + return nullptr; + } + auto entry = s_slots.find(it->second); + if (entry) { + return &entry->value->objNameInf; + } + return nullptr; +} + +void actor_remove_mod(LoadedMod& mod) { + std::vector handles; + s_slots.for_each([&](const ActorHandle handle, const auto& slot) { + if (slot.owner == &mod) { + handles.push_back(handle); + } + }); + + for (const auto handle : handles) { + const auto result = unregister_actor(mod.context.get(), handle); + if (result != MOD_OK) { + Log.error("Actor profile could not be removed during mod deactivation"); + } + } +} + +} // namespace dusk::mods::svc::actor_impl + +namespace dusk::mods::svc { +namespace { + +constexpr ActorService s_actorService{ + .header = SERVICE_HEADER(ActorService, ACTOR_SERVICE_MAJOR, ACTOR_SERVICE_MINOR), + .register_actor = actor_impl::register_actor, + .unregister_actor = actor_impl::unregister_actor, + .create_actor_from_name = actor_impl::create_actor_from_name, + .create_actor = actor_impl::create_actor, + .create_child_actor_from_name = actor_impl::create_child_actor_from_name, + .create_child_actor = actor_impl::create_child_actor, + .get_actor_id = actor_impl::get_actor_id, + .get_actor_room_num = actor_impl::get_actor_room_num, + .delete_actor = actor_impl::delete_actor, +}; + +} + +constinit const ServiceModule g_actorModule{ + .id = ACTOR_SERVICE_ID, + .majorVersion = ACTOR_SERVICE_MAJOR, + .minorVersion = ACTOR_SERVICE_MINOR, + .service = &s_actorService, + .modDeactivating = actor_impl::actor_remove_mod, +}; + +} // namespace dusk::mods::svc diff --git a/src/dusk/mods/svc/actor.hpp b/src/dusk/mods/svc/actor.hpp new file mode 100644 index 0000000000..7e68760503 --- /dev/null +++ b/src/dusk/mods/svc/actor.hpp @@ -0,0 +1,24 @@ +#pragma once +#include +#include +#include +#include "f_op/f_op_actor_mng.h" + +namespace dusk::mods::svc::actor_impl { + +struct ActorSlot { + actor_method_class methodTable; + int (*deleteFunction)(void*); + int (*isDeleteFunction)(void*); + bool forceDelete; + dStage_objectNameInf objNameInf; + actor_process_profile_definition profile; +}; + +process_profile_definition* get_profile_from_proc_name(s16 name); + +dStage_objectNameInf* get_stageinfo_from_full_name(const std::string& name); + +const char* get_full_name_from_proc_name(s16 name); // Returns "" when not found + +}; // namespace dusk::mods::svc::actor_impl diff --git a/src/dusk/mods/svc/camera.cpp b/src/dusk/mods/svc/camera.cpp index 60fbf42499..b93ea00e62 100644 --- a/src/dusk/mods/svc/camera.cpp +++ b/src/dusk/mods/svc/camera.cpp @@ -1,5 +1,5 @@ +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include "dusk/camera_operators.hpp" #include "dusk/mods/loader/loader.hpp" diff --git a/src/dusk/mods/svc/config.cpp b/src/dusk/mods/svc/config.cpp index b1bbf63705..cf8c249b3c 100644 --- a/src/dusk/mods/svc/config.cpp +++ b/src/dusk/mods/svc/config.cpp @@ -1,7 +1,7 @@ #include "config.hpp" +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include #include "dusk/config.hpp" diff --git a/src/dusk/mods/svc/file.cpp b/src/dusk/mods/svc/file.cpp index f1ede94a3c..8bbd4ced39 100644 --- a/src/dusk/mods/svc/file.cpp +++ b/src/dusk/mods/svc/file.cpp @@ -1,6 +1,6 @@ #include "registry.hpp" -#include "slot_map.hpp" +#include "internal.hpp" #include #include diff --git a/src/dusk/mods/svc/game_mode.cpp b/src/dusk/mods/svc/game_mode.cpp index cfa655baf8..a84afad78f 100644 --- a/src/dusk/mods/svc/game_mode.cpp +++ b/src/dusk/mods/svc/game_mode.cpp @@ -1,14 +1,14 @@ #include "mods/svc/game_mode.h" -#include "dusk/game_mode.hpp" -#include "config.hpp" +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" -#include "aurora/lib/logging.hpp" +#include "dusk/game_mode.hpp" #include "dusk/mod_loader.hpp" #include "dusk/mods/loader/loader.hpp" -#include "fmt/format.h" + +#include +#include #include #include diff --git a/src/dusk/mods/svc/gfx.cpp b/src/dusk/mods/svc/gfx.cpp index 098894007a..9ec8f2415a 100644 --- a/src/dusk/mods/svc/gfx.cpp +++ b/src/dusk/mods/svc/gfx.cpp @@ -1,5 +1,5 @@ +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include "window.hpp" #include diff --git a/src/dusk/mods/svc/host.cpp b/src/dusk/mods/svc/host.cpp index a8e975e22f..bde28f6b89 100644 --- a/src/dusk/mods/svc/host.cpp +++ b/src/dusk/mods/svc/host.cpp @@ -1,15 +1,16 @@ +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include "dusk/main.h" #include "dusk/mods/loader/loader.hpp" #include "dusk/mods/log_buffer.hpp" #include "dusk/mods/manifest.hpp" -#include "fmt/format.h" -#include #include #include +#include + +#include #include #include diff --git a/src/dusk/mods/svc/http.cpp b/src/dusk/mods/svc/http.cpp index 337758d5d4..2277e66e01 100644 --- a/src/dusk/mods/svc/http.cpp +++ b/src/dusk/mods/svc/http.cpp @@ -1,21 +1,20 @@ #include "registry.hpp" -#include "slot_map.hpp" +#include "internal.hpp" +#include "net.hpp" -#include "dusk/app_info.hpp" #include "dusk/main.h" #include "dusk/mods/loader/loader.hpp" #include "mods/svc/http.h" #include #include -#include +#include #include #include #include #include -#include #include #include #include @@ -38,6 +37,15 @@ constexpr size_t MaxRequestBodyBytes = 16 * 1024 * 1024; constexpr size_t DefaultResponseBodyBytes = 1024 * 1024; constexpr size_t MaxResponseBodyBytes = 64 * 1024 * 1024; constexpr std::chrono::milliseconds DefaultTimeout{10000}; +constexpr std::string_view ReservedHeaders[]{ + "User-Agent", + "Host", + "Content-Length", + "Connection", + "Accept-Encoding", + "Range", + "If-Range", +}; struct PendingRequest { HttpCompleteFn callback = nullptr; @@ -52,53 +60,9 @@ static_assert(std::is_nothrow_move_constructible_v); SlotMap s_requests; -bool ascii_iequals(std::string_view left, std::string_view right) { - return left.size() == right.size() && std::ranges::equal(left, right, [](char a, char b) { - return std::tolower(static_cast(a)) == - std::tolower(static_cast(b)); - }); -} - -bool is_reserved_header(std::string_view name) { - constexpr std::string_view reserved[]{ - "User-Agent", - "Host", - "Content-Length", - "Connection", - "Accept-Encoding", - "Range", - "If-Range", - }; - return std::ranges::any_of( - reserved, [&](std::string_view value) { return ascii_iequals(name, value); }); -} - -bool valid_header_name(std::string_view name) { - constexpr std::string_view separators{"()<>@,;:\\\"/[]?={} \t"}; - return !name.empty() && std::ranges::all_of(name, [&](unsigned char value) { - return value > 32 && value < 127 && - separators.find(static_cast(value)) == std::string_view::npos; - }); -} - bool valid_url(std::string_view url) { - constexpr std::string_view scheme{"https://"}; - if (!url.starts_with(scheme) || url.size() <= scheme.size() || url.size() > MaxUrlBytes) { - return false; - } - if (std::ranges::any_of(url, [](unsigned char value) { return value <= 32 || value == 127; })) { - return false; - } - const auto authorityEnd = url.find_first_of("/?#", scheme.size()); - const auto authority = url.substr(scheme.size(), authorityEnd - scheme.size()); - return !authority.empty(); -} - -bool declares_http_import(const LoadedMod& mod) { - return std::ranges::any_of( - mod.manifestInfo.imports, [](const ModManifestInfo::Import& serviceImport) { - return serviceImport.id == HTTP_SERVICE_ID; - }); + const auto parsed = url.size() <= MaxUrlBytes ? borealis::url::parse(url) : std::nullopt; + return parsed && parsed->scheme == "https"; } std::filesystem::path normalized_absolute(const std::filesystem::path& path, std::error_code& ec) { @@ -183,7 +147,6 @@ HttpError map_error(borealis::http::Error error) { case borealis::http::Error::Io: return HTTP_ERROR_IO; case borealis::http::Error::NoBackend: - case borealis::http::Error::NotInitialized: case borealis::http::Error::Network: return HTTP_ERROR_NETWORK; default: @@ -312,14 +275,8 @@ void http_frame_begin() { .download_path = downloadSucceeded ? publishedPath.c_str() : nullptr, }; - try { - callback(owner->context.get(), handle, &snapshot, userData); - } catch (const std::exception& exception) { - fail_mod(*owner, MOD_ERROR, - std::string{"exception in HTTP completion callback: "} + exception.what()); - } catch (...) { - fail_mod(*owner, MOD_ERROR, "unknown exception in HTTP completion callback"); - } + guarded_callback(*owner, "HTTP completion callback", + [&] { callback(owner->context.get(), handle, &snapshot, userData); }); s_requests.erase(handle); } } @@ -344,17 +301,6 @@ bool staging_path_in_use(const LoadedMod& mod, const std::filesystem::path& path return inUse; } -std::string user_agent_version(std::string_view version) { - std::string result{version}; - for (char& ch : result) { - const auto value = static_cast(ch); - if (value <= 32 || value >= 127) { - ch = '_'; - } - } - return result; -} - ModResult start_request(LoadedMod& mod, const HttpRequestDesc& desc, HttpCompleteFn callback, void* userData, HttpRequestHandle& outHandle) { const std::string_view url{desc.url}; @@ -377,9 +323,7 @@ ModResult start_request(LoadedMod& mod, const HttpRequestDesc& desc, HttpComplet } const std::string_view name{header.name}; const std::string_view value{header.value}; - const bool invalidValue = std::ranges::any_of( - value, [](unsigned char ch) { return (ch < 32 && ch != '\t') || ch == 127; }); - if (!valid_header_name(name) || invalidValue || is_reserved_header(name) || + if (!valid_header(name, value, ReservedHeaders, true) || name.size() > MaxHeaderBytes - headerBytes) { return MOD_INVALID_ARGUMENT; @@ -438,14 +382,12 @@ ModResult start_request(LoadedMod& mod, const HttpRequestDesc& desc, HttpComplet .connectTimeout = desc.connect_timeout_ms != 0 ? std::chrono::milliseconds{desc.connect_timeout_ms} : DefaultTimeout, - .idleTimeout = desc.idle_timeout_ms != 0 ? - std::chrono::milliseconds{desc.idle_timeout_ms} : - DefaultTimeout, + .idleTimeout = desc.idle_timeout_ms != 0 ? std::chrono::milliseconds{desc.idle_timeout_ms} : + DefaultTimeout, .totalTimeout = desc.total_timeout_ms != 0 ? std::optional{std::chrono::milliseconds{desc.total_timeout_ms}} : std::nullopt, - .maxBodyBytes = - desc.max_body_bytes != 0 ? desc.max_body_bytes : DefaultResponseBodyBytes, + .maxBodyBytes = desc.max_body_bytes != 0 ? desc.max_body_bytes : DefaultResponseBodyBytes, }; request.headers.reserve(desc.header_count + 1); for (uint32_t i = 0; i < desc.header_count; ++i) { @@ -453,8 +395,7 @@ ModResult start_request(LoadedMod& mod, const HttpRequestDesc& desc, HttpComplet } request.headers.push_back({ .name = "User-Agent", - .value = fmt::format("{}/{} {}/{}", AppName, BOREALIS_APP_VERSION, mod.metadata.id, - user_agent_version(mod.metadata.version)), + .value = user_agent(mod), }); auto task = borealis::http::start(std::move(request)); @@ -463,9 +404,7 @@ ModResult start_request(LoadedMod& mod, const HttpRequestDesc& desc, HttpComplet if (!immediate.has_value()) { return MOD_UNAVAILABLE; } - if (immediate->error == borealis::http::Error::NoBackend || - immediate->error == borealis::http::Error::NotInitialized) - { + if (immediate->error == borealis::http::Error::NoBackend) { return MOD_UNAVAILABLE; } task = borealis::detail::make_ready_task(std::move(*immediate)); @@ -492,14 +431,10 @@ ModResult http_request(ModContext* context, const HttpRequestDesc* desc, HttpCom { return MOD_INVALID_ARGUMENT; } - if (!declares_http_import(*mod)) { + if (!declares_import(*mod, HTTP_SERVICE_ID)) { return MOD_UNSUPPORTED; } - try { - return start_request(*mod, *desc, callback, userData, *outHandle); - } catch (...) { - return MOD_ERROR; - } + return start_request(*mod, *desc, callback, userData, *outHandle); } ModResult http_progress(ModContext* context, HttpRequestHandle handle, HttpProgress* outProgress) { @@ -550,14 +485,14 @@ void http_shutdown() { } bool http_available() { - return borealis::http::available() && borealis::http::initialize(); + return borealis::http::available(); } constexpr HttpService s_httpService{ .header = SERVICE_HEADER(HttpService, HTTP_SERVICE_MAJOR, HTTP_SERVICE_MINOR), - .request = http_request, - .progress = http_progress, - .cancel = http_cancel, + .request = SERVICE_FUNCTION(http_request), + .progress = SERVICE_FUNCTION(http_progress), + .cancel = SERVICE_FUNCTION(http_cancel), }; } // namespace diff --git a/src/dusk/mods/svc/slot_map.hpp b/src/dusk/mods/svc/internal.hpp similarity index 66% rename from src/dusk/mods/svc/slot_map.hpp rename to src/dusk/mods/svc/internal.hpp index 3e45635d79..496b2a58a5 100644 --- a/src/dusk/mods/svc/slot_map.hpp +++ b/src/dusk/mods/svc/internal.hpp @@ -1,5 +1,10 @@ #pragma once +#include "../loader/loader.hpp" +#include "../log_buffer.hpp" + +#include + #include #include #include @@ -106,9 +111,7 @@ public: return erase(handle); } - size_t erase_all(const LoadedMod& owner) { - return take_all(owner).size(); - } + size_t erase_all(const LoadedMod& owner) { return take_all(owner).size(); } template void for_each(Fn&& fn) const { @@ -122,6 +125,9 @@ public: } } + // Returns the index of the handle within the slot map. + static constexpr uint32_t index_of(Handle handle) { return handle_index(handle); } + private: struct Slot { uint32_t generation = 1; @@ -184,5 +190,69 @@ private: std::vector m_freeSlots; }; +template +class PerMod { +public: + template + T& get_or_create(LoadedMod& mod, Args&&... args) { + auto& state = m_states[&mod]; + if (!state) { + state = std::make_unique(std::forward(args)...); + } + return *state; + } + + T* find(LoadedMod& mod) { + const auto found = m_states.find(&mod); + return found != m_states.end() ? found->second.get() : nullptr; + } + + const T* find(const LoadedMod& mod) const { + const auto found = m_states.find(&mod); + return found != m_states.end() ? found->second.get() : nullptr; + } + + void erase(LoadedMod& mod) { m_states.erase(&mod); } + bool contains(const LoadedMod& mod) const { return m_states.contains(&mod); } + void clear() { m_states.clear(); } + +private: + std::unordered_map> m_states; +}; + +template +ModResult guarded(ModContext* context, std::string_view operation, Fn&& fn) noexcept { + try { + return fn(); + } catch (const std::exception& exception) { + log::emit(log::Source::Mod, mod_id_from_context(context), LOG_LEVEL_ERROR, + fmt::format("{}: {}", operation, exception.what())); + } catch (...) { + log::emit(log::Source::Mod, mod_id_from_context(context), LOG_LEVEL_ERROR, + fmt::format("{}: unknown exception", operation)); + } + return MOD_ERROR; +} + +// Wraps a mod callback, attempting to catch any escaping exceptions. +// Immediately logs and fails the mod. +template +void guarded_callback(LoadedMod& mod, std::string_view operation, Fn&& fn) noexcept { + try { + fn(); + } catch (const std::exception& exception) { + fail_mod(mod, MOD_ERROR, fmt::format("exception in {}: {}", operation, exception.what())); + } catch (...) { + fail_mod(mod, MOD_ERROR, fmt::format("unknown exception in {}", operation)); + } +} + } // namespace svc } // namespace dusk::mods + +// Wraps service functions, catching C++ exceptions to avoid unwinding into mod code. +#define SERVICE_FUNCTION(function) \ + [](ModContext* context, auto... arguments) -> ModResult { \ + return ::dusk::mods::svc::guarded( \ + context, #function, [&] { return function(context, arguments...); }); \ + } diff --git a/src/dusk/mods/svc/item.cpp b/src/dusk/mods/svc/item.cpp index f80fc16b9b..44b0eff37e 100644 --- a/src/dusk/mods/svc/item.cpp +++ b/src/dusk/mods/svc/item.cpp @@ -75,6 +75,17 @@ ModResult item_resolve_check( return MOD_OK; } +ModResult item_resolve_check_full(ModContext* context, const char* name, uint8_t originalItemNo, + ItemCheckResolution* outResolution) { + if (mod_from_context(context) == nullptr || !is_valid_check_name(name) || + outResolution == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + *outResolution = item_check_resolve(name, originalItemNo, nullptr); + return MOD_OK; +} + ModResult item_give_item( ModContext* context, const char* checkName, uint8_t itemNo, uint32_t flags) { auto* mod = mod_from_context(context); @@ -130,6 +141,7 @@ constexpr ItemService s_itemService{ .give_item = item_give_item, .observe_gives = item_observe_gives, .unobserve_gives = item_unobserve_gives, + .resolve_check_full = item_resolve_check_full, }; } // namespace diff --git a/src/dusk/mods/svc/net.cpp b/src/dusk/mods/svc/net.cpp new file mode 100644 index 0000000000..4b929524cf --- /dev/null +++ b/src/dusk/mods/svc/net.cpp @@ -0,0 +1,574 @@ +#include "registry.hpp" + +#include "internal.hpp" +#include "net.hpp" + +#include "dusk/logging.h" +#include "dusk/mods/loader/loader.hpp" +#include "mods/svc/net.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace dusk::mods::svc { +namespace { + +constexpr size_t MaxListenersPerMod = 4; +constexpr size_t MaxStreamsPerMod = 32; +constexpr size_t MaxDatagramsPerMod = 4; +constexpr size_t MaxResolversPerMod = 8; +constexpr size_t DefaultSendQueueBytes = 1024 * 1024; +constexpr size_t MaxSendQueueBytes = 8 * 1024 * 1024; +constexpr std::chrono::milliseconds DefaultConnectTimeout{10000}; +constexpr std::chrono::milliseconds DefaultCloseTimeout{5000}; +constexpr std::chrono::milliseconds InboundStallTimeout{30000}; + +enum class HandleKind { + Listener, + Stream, + Datagram, + Resolver, +}; + +struct HandleState { + borealis::net::SocketId socket = 0; + HandleKind kind = HandleKind::Stream; + // Stream sends remain unavailable until the mod observes CONNECTED. + bool openPublished = false; +}; + +struct ModState { + ModState() + : context{borealis::net::ContextOptions{ + .maxQueuedBytes = 16 * 1024 * 1024, + .maxQueuedEvents = 4096, + .maxStreams = MaxStreamsPerMod, + .maxListeners = MaxListenersPerMod, + .maxDatagramSockets = MaxDatagramsPerMod, + .maxResolvers = MaxResolversPerMod, + }} {} + + borealis::net::Context context; + std::unordered_map handles; + borealis::net::Event currentEvent; +}; + +SlotMap s_handles; +PerMod s_modStates; + +NetError map_error(borealis::net::Error error) { + switch (error) { + case borealis::net::Error::None: + return NET_ERROR_NONE; + case borealis::net::Error::InvalidEndpoint: + return NET_ERROR_INVALID_ENDPOINT; + case borealis::net::Error::Resolve: + return NET_ERROR_RESOLVE; + case borealis::net::Error::Timeout: + return NET_ERROR_TIMEOUT; + case borealis::net::Error::Refused: + return NET_ERROR_REFUSED; + case borealis::net::Error::Unreachable: + return NET_ERROR_UNREACHABLE; + case borealis::net::Error::Reset: + return NET_ERROR_RESET; + case borealis::net::Error::AddressInUse: + return NET_ERROR_ADDRESS_IN_USE; + case borealis::net::Error::Permission: + return NET_ERROR_PERMISSION; + case borealis::net::Error::TooLarge: + return NET_ERROR_TOO_LARGE; + case borealis::net::Error::Canceled: + return NET_ERROR_CANCELED; + case borealis::net::Error::Network: + default: + return NET_ERROR_NETWORK; + } +} + +ModResult map_send_result(borealis::net::SendResult result) { + switch (result) { + case borealis::net::SendResult::Ok: + return MOD_OK; + case borealis::net::SendResult::NotOpen: + return MOD_UNAVAILABLE; + case borealis::net::SendResult::QueueFull: + return MOD_CONFLICT; + case borealis::net::SendResult::TooLarge: + case borealis::net::SendResult::InvalidEndpoint: + return MOD_INVALID_ARGUMENT; + } + return MOD_ERROR; +} + +NetEventType map_event(borealis::net::Event::Kind kind) { + switch (kind) { + case borealis::net::Event::Kind::Connected: + return NET_EVENT_CONNECTED; + case borealis::net::Event::Kind::Accepted: + return NET_EVENT_ACCEPTED; + case borealis::net::Event::Kind::StreamData: + return NET_EVENT_STREAM_DATA; + case borealis::net::Event::Kind::Datagram: + return NET_EVENT_DATAGRAM; + case borealis::net::Event::Kind::Dropped: + return NET_EVENT_DROPPED; + case borealis::net::Event::Kind::Resolved: + return NET_EVENT_RESOLVED; + case borealis::net::Event::Kind::Closed: + return NET_EVENT_CLOSED; + default: + return NET_EVENT_NONE; + } +} + +bool valid_endpoint(std::string_view text, std::string_view scheme, bool requireLiteral) { + if (text.empty() || text.size() >= NET_ENDPOINT_MAX) { + return false; + } + const auto endpoint = borealis::net::parse_endpoint(text); + return endpoint && endpoint->scheme == scheme && (!requireLiteral || endpoint->literal); +} + +bool copy_endpoint(NetEndpoint& output, std::string_view endpoint) { + if (endpoint.size() >= sizeof(output.text)) { + output.text[0] = '\0'; + return false; + } + std::memcpy(output.text, endpoint.data(), endpoint.size()); + output.text[endpoint.size()] = '\0'; + return true; +} + +size_t bounded_send_queue(size_t requested) { + return requested != 0 ? requested : DefaultSendQueueBytes; +} + +std::chrono::milliseconds timeout_or_default(uint32_t value, std::chrono::milliseconds fallback) { + return value != 0 ? std::chrono::milliseconds{value} : fallback; +} + +size_t count_handles(const LoadedMod& mod, HandleKind kind) { + size_t count = 0; + s_handles.for_each([&](NetHandle, const auto& entry) { + if (entry.owner == &mod && entry.value.kind == kind) { + ++count; + } + }); + return count; +} + +ModState& state_for(LoadedMod& mod) { + return s_modStates.get_or_create(mod); +} + +ModState* find_state(LoadedMod& mod) { + return s_modStates.find(mod); +} + +NetHandle add_handle(LoadedMod& mod, ModState& state, borealis::net::SocketId socket, + HandleKind kind, bool openPublished) { + const NetHandle handle = s_handles.emplace(mod, HandleState{ + .socket = socket, + .kind = kind, + .openPublished = openPublished, + }); + state.handles.emplace(socket, handle); + return handle; +} + +ModResult net_connect(ModContext* context, const NetConnectDesc* desc, NetHandle* outHandle) { + if (outHandle != nullptr) { + *outHandle = 0; + } + auto* mod = mod_from_context(context); + if (mod == nullptr || desc == nullptr || desc->struct_size < sizeof(NetConnectDesc) || + desc->endpoint == nullptr || outHandle == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + if (!declares_import(*mod, NET_SERVICE_ID)) { + return MOD_UNSUPPORTED; + } + const std::string_view endpoint{desc->endpoint}; + if (!valid_endpoint(endpoint, "tcp", false) || desc->max_send_queue_bytes > MaxSendQueueBytes) { + return MOD_INVALID_ARGUMENT; + } + if (!borealis::net::available()) { + return MOD_UNAVAILABLE; + } + if (count_handles(*mod, HandleKind::Stream) >= MaxStreamsPerMod) { + return MOD_CONFLICT; + } + auto& state = state_for(*mod); + const size_t maxSendQueueBytes = bounded_send_queue(desc->max_send_queue_bytes); + const borealis::net::SocketId socket = state.context.connect(endpoint, + borealis::net::StreamOptions{ + .connectTimeout = timeout_or_default(desc->connect_timeout_ms, DefaultConnectTimeout), + .closeTimeout = timeout_or_default(desc->close_timeout_ms, DefaultCloseTimeout), + .inboundStallTimeout = InboundStallTimeout, + .maxSendQueueBytes = maxSendQueueBytes, + .readChunkBytes = 64 * 1024, + .noDelay = desc->no_delay, + }, + desc->user_data); + if (socket == 0) { + return MOD_CONFLICT; + } + *outHandle = add_handle(*mod, state, socket, HandleKind::Stream, false); + return MOD_OK; +} + +ModResult net_listen(ModContext* context, const NetListenDesc* desc, NetHandle* outHandle, + NetEndpoint* outLocal, NetError* outError) { + if (outHandle != nullptr) { + *outHandle = 0; + } + if (outLocal != nullptr) { + *outLocal = {}; + } + if (outError != nullptr) { + *outError = NET_ERROR_NONE; + } + auto* mod = mod_from_context(context); + if (mod == nullptr || desc == nullptr || desc->struct_size < sizeof(NetListenDesc) || + desc->bind == nullptr || outHandle == nullptr || outLocal == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + if (!declares_import(*mod, NET_SERVICE_ID)) { + return MOD_UNSUPPORTED; + } + const std::string_view bind{desc->bind}; + if (!valid_endpoint(bind, "tcp", true) || desc->max_send_queue_bytes > MaxSendQueueBytes) { + return MOD_INVALID_ARGUMENT; + } + if (!borealis::net::available()) { + return MOD_UNAVAILABLE; + } + if (count_handles(*mod, HandleKind::Listener) >= MaxListenersPerMod) { + return MOD_CONFLICT; + } + auto& state = state_for(*mod); + const size_t maxSendQueueBytes = bounded_send_queue(desc->max_send_queue_bytes); + const auto result = state.context.listen(bind, + borealis::net::ListenOptions{ + .accepted = + borealis::net::StreamOptions{ + .connectTimeout = DefaultConnectTimeout, + .closeTimeout = timeout_or_default(desc->close_timeout_ms, DefaultCloseTimeout), + .inboundStallTimeout = InboundStallTimeout, + .maxSendQueueBytes = maxSendQueueBytes, + .readChunkBytes = 64 * 1024, + .noDelay = desc->no_delay, + }, + .backlog = 64, + .reuseAddress = true, + }, + desc->user_data); + if (result.id == 0) { + if (outError != nullptr) { + *outError = map_error(result.error); + } + DuskLog.error("[{}] could not listen on '{}': {}", mod->metadata.id, bind, result.message); + return MOD_ERROR; + } + if (!copy_endpoint(*outLocal, result.localEndpoint)) { + state.context.close(result.id); + return MOD_ERROR; + } + *outHandle = add_handle(*mod, state, result.id, HandleKind::Listener, true); + return MOD_OK; +} + +ModResult net_open_datagram(ModContext* context, const NetDatagramDesc* desc, NetHandle* outHandle, + NetEndpoint* outLocal, NetError* outError) { + if (outHandle != nullptr) { + *outHandle = 0; + } + if (outLocal != nullptr) { + *outLocal = {}; + } + if (outError != nullptr) { + *outError = NET_ERROR_NONE; + } + auto* mod = mod_from_context(context); + if (mod == nullptr || desc == nullptr || desc->struct_size < sizeof(NetDatagramDesc) || + desc->bind == nullptr || outHandle == nullptr || outLocal == nullptr) + { + return MOD_INVALID_ARGUMENT; + } + if (!declares_import(*mod, NET_SERVICE_ID)) { + return MOD_UNSUPPORTED; + } + const std::string_view bind{desc->bind}; + if (!valid_endpoint(bind, "udp", true) || desc->max_send_queue_bytes > MaxSendQueueBytes) { + return MOD_INVALID_ARGUMENT; + } + if (!borealis::net::available()) { + return MOD_UNAVAILABLE; + } + if (count_handles(*mod, HandleKind::Datagram) >= MaxDatagramsPerMod) { + return MOD_CONFLICT; + } + auto& state = state_for(*mod); + const size_t maxSendQueueBytes = bounded_send_queue(desc->max_send_queue_bytes); + const auto result = state.context.open_datagram(bind, + borealis::net::DatagramOptions{ + .maxSendQueueBytes = maxSendQueueBytes, + .recvBufferBytes = 1024 * 1024, + .sendBufferBytes = 1024 * 1024, + }, + desc->user_data); + if (result.id == 0) { + if (outError != nullptr) { + *outError = map_error(result.error); + } + DuskLog.error("[{}] could not bind datagram socket on '{}': {}", mod->metadata.id, bind, + result.message); + return MOD_ERROR; + } + if (!copy_endpoint(*outLocal, result.localEndpoint)) { + state.context.close(result.id); + return MOD_ERROR; + } + *outHandle = add_handle(*mod, state, result.id, HandleKind::Datagram, true); + return MOD_OK; +} + +ModResult net_resolve( + ModContext* context, const char* endpoint, void* userData, NetHandle* outHandle) { + if (outHandle != nullptr) { + *outHandle = 0; + } + auto* mod = mod_from_context(context); + if (mod == nullptr || endpoint == nullptr || outHandle == nullptr) { + return MOD_INVALID_ARGUMENT; + } + if (!declares_import(*mod, NET_SERVICE_ID)) { + return MOD_UNSUPPORTED; + } + const std::string_view endpointText{endpoint}; + if (endpointText.empty() || endpointText.size() >= NET_ENDPOINT_MAX || + !borealis::net::parse_endpoint(endpointText)) + { + return MOD_INVALID_ARGUMENT; + } + if (!borealis::net::available()) { + return MOD_UNAVAILABLE; + } + if (count_handles(*mod, HandleKind::Resolver) >= MaxResolversPerMod) { + return MOD_CONFLICT; + } + auto& state = state_for(*mod); + const auto socket = state.context.resolve(endpointText, userData); + if (socket == 0) { + return MOD_CONFLICT; + } + *outHandle = add_handle(*mod, state, socket, HandleKind::Resolver, false); + return MOD_OK; +} + +ModResult net_poll_event(ModContext* context, NetEvent* outEvent) { + const uint32_t structSize = outEvent != nullptr ? outEvent->struct_size : 0; + auto* mod = mod_from_context(context); + if (mod == nullptr || outEvent == nullptr || structSize < sizeof(NetEvent)) { + return MOD_INVALID_ARGUMENT; + } + NetEvent output{.struct_size = structSize, .error_message = ""}; + auto* state = find_state(*mod); + if (state == nullptr) { + std::memcpy(outEvent, &output, sizeof(output)); + return MOD_OK; + } + + while (state->context.poll(state->currentEvent)) { + const auto handleFound = state->handles.find(state->currentEvent.id); + if (handleFound == state->handles.end()) { + continue; + } + const NetHandle handle = handleFound->second; + auto* handleState = s_handles.find_owned(handle, *mod); + if (handleState == nullptr) { + continue; + } + output.type = map_event(state->currentEvent.kind); + output.handle = handle; + output.user_data = state->currentEvent.userData; + output.data = state->currentEvent.data.data(); + output.size = state->currentEvent.data.size(); + output.dropped = state->currentEvent.dropped; + output.error = map_error(state->currentEvent.error); + output.error_message = state->currentEvent.message.c_str(); + if (!copy_endpoint(output.endpoint, state->currentEvent.endpoint)) { + output.endpoint = {}; + } + + if (state->currentEvent.kind == borealis::net::Event::Kind::Connected) { + handleState->value.openPublished = true; + } else if (state->currentEvent.kind == borealis::net::Event::Kind::Accepted) { + const NetHandle accepted = + add_handle(*mod, *state, state->currentEvent.accepted, HandleKind::Stream, true); + output.accepted = accepted; + } else if (state->currentEvent.kind == borealis::net::Event::Kind::Closed || + state->currentEvent.kind == borealis::net::Event::Kind::Resolved) + { + state->handles.erase(state->currentEvent.id); + s_handles.erase(handle); + } + + std::memcpy(outEvent, &output, sizeof(output)); + return MOD_OK; + } + + std::memcpy(outEvent, &output, sizeof(output)); + return MOD_OK; +} + +ModResult net_send(ModContext* context, NetHandle handle, const void* data, size_t size) { + auto* mod = mod_from_context(context); + if (mod == nullptr || (size != 0 && data == nullptr)) { + return MOD_INVALID_ARGUMENT; + } + auto* handleState = s_handles.find_owned(handle, *mod); + auto* state = find_state(*mod); + if (handleState == nullptr || state == nullptr || + handleState->value.kind != HandleKind::Stream || !handleState->value.openPublished) + { + return MOD_UNAVAILABLE; + } + const auto* bytes = static_cast(data); + return map_send_result(state->context.send(handleState->value.socket, {bytes, size})); +} + +ModResult net_send_to( + ModContext* context, NetHandle handle, const char* endpoint, const void* data, size_t size) { + auto* mod = mod_from_context(context); + if (mod == nullptr || endpoint == nullptr || (size != 0 && data == nullptr)) { + return MOD_INVALID_ARGUMENT; + } + auto* handleState = s_handles.find_owned(handle, *mod); + auto* state = find_state(*mod); + if (handleState == nullptr || state == nullptr || + handleState->value.kind != HandleKind::Datagram) + { + return MOD_UNAVAILABLE; + } + const auto* bytes = static_cast(data); + return map_send_result( + state->context.send_to(handleState->value.socket, endpoint, {bytes, size})); +} + +ModResult net_set_user_data(ModContext* context, NetHandle handle, void* userData) { + auto* mod = mod_from_context(context); + if (mod == nullptr) { + return MOD_INVALID_ARGUMENT; + } + const auto* handleState = s_handles.find_owned(handle, *mod); + auto* state = find_state(*mod); + if (handleState == nullptr || state == nullptr) { + return MOD_UNAVAILABLE; + } + state->context.set_user_data(handleState->value.socket, userData); + return MOD_OK; +} + +ModResult net_stats(ModContext* context, NetHandle handle, NetStats* outStats) { + const uint32_t structSize = outStats != nullptr ? outStats->struct_size : 0; + auto* mod = mod_from_context(context); + if (mod == nullptr || outStats == nullptr || structSize < sizeof(NetStats)) { + return MOD_INVALID_ARGUMENT; + } + NetStats output{.struct_size = structSize}; + const auto* handleState = s_handles.find_owned(handle, *mod); + auto* state = find_state(*mod); + if (handleState == nullptr || state == nullptr) { + std::memcpy(outStats, &output, sizeof(output)); + return MOD_UNAVAILABLE; + } + const auto stats = state->context.stats(handleState->value.socket); + if (!stats) { + std::memcpy(outStats, &output, sizeof(output)); + return MOD_UNAVAILABLE; + } + output.queued_send_bytes = stats->queuedSendBytes; + output.inbound_dropped = stats->inboundDropped; + output.send_failures = stats->sendFailures; + output.bytes_sent = stats->bytesSent; + output.bytes_received = stats->bytesReceived; + std::memcpy(outStats, &output, sizeof(output)); + return MOD_OK; +} + +ModResult net_close(ModContext* context, NetHandle handle) { + auto* mod = mod_from_context(context); + if (mod == nullptr) { + return MOD_INVALID_ARGUMENT; + } + auto* handleState = s_handles.find_owned(handle, *mod); + auto* state = find_state(*mod); + if (handleState == nullptr || state == nullptr) { + return MOD_UNAVAILABLE; + } + state->context.close(handleState->value.socket); + return MOD_OK; +} + +void net_mod_deactivating(LoadedMod& mod) { + (void)s_handles.take_all(mod); + s_modStates.erase(mod); +} + +void net_mod_detached(LoadedMod& mod) { + assert(find_state(mod) == nullptr); + bool found = false; + s_handles.for_each([&](NetHandle, const auto& entry) { found = found || entry.owner == &mod; }); + assert(!found); +} + +void net_shutdown() { + s_modStates.clear(); + s_handles = {}; +} + +bool net_available() { + return borealis::net::available(); +} + +constexpr NetService s_netService{ + .header = SERVICE_HEADER(NetService, NET_SERVICE_MAJOR, NET_SERVICE_MINOR), + .connect = SERVICE_FUNCTION(net_connect), + .listen = SERVICE_FUNCTION(net_listen), + .open_datagram = SERVICE_FUNCTION(net_open_datagram), + .resolve = SERVICE_FUNCTION(net_resolve), + .poll_event = SERVICE_FUNCTION(net_poll_event), + .send = SERVICE_FUNCTION(net_send), + .send_to = SERVICE_FUNCTION(net_send_to), + .set_user_data = SERVICE_FUNCTION(net_set_user_data), + .stats = SERVICE_FUNCTION(net_stats), + .close = SERVICE_FUNCTION(net_close), +}; + +} // namespace + +constinit const ServiceModule g_netModule{ + .id = NET_SERVICE_ID, + .majorVersion = NET_SERVICE_MAJOR, + .minorVersion = NET_SERVICE_MINOR, + .service = &s_netService, + .available = net_available, + .modDeactivating = net_mod_deactivating, + .modDetached = net_mod_detached, + .shutdown = net_shutdown, +}; + +} // namespace dusk::mods::svc diff --git a/src/dusk/mods/svc/net.hpp b/src/dusk/mods/svc/net.hpp new file mode 100644 index 0000000000..34ca17362f --- /dev/null +++ b/src/dusk/mods/svc/net.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include "dusk/app_info.hpp" +#include "dusk/mods/loader/loader.hpp" +#include "mods/svc/http.h" +#include "mods/svc/net.h" +#include "mods/svc/websocket.h" + +#include +#include + +#include +#include +#include +#include +#include + +namespace dusk::mods::svc { + +inline bool ascii_iequals(std::string_view left, std::string_view right) { + if (left.size() != right.size()) { + return false; + } + const auto ascii_lower = [](char value) { + return value >= 'A' && value <= 'Z' ? static_cast(value - 'A' + 'a') : value; + }; + return std::ranges::equal( + left, right, [&](char a, char b) { return ascii_lower(a) == ascii_lower(b); }); +} + +inline bool valid_header_name(std::string_view name) { + constexpr std::string_view Separators{"()<>@,;:\\\"/[]?={} \t"}; + return !name.empty() && std::ranges::all_of(name, [&](unsigned char value) { + return value > 32 && value < 127 && + Separators.find(static_cast(value)) == std::string_view::npos; + }); +} + +inline bool valid_header_value(std::string_view value, bool allowHorizontalTab) { + return std::ranges::all_of(value, [=](unsigned char character) { + return character >= 32 || (allowHorizontalTab && character == '\t'); + }) && std::ranges::none_of(value, [](unsigned char character) { return character == 127; }); +} + +inline bool is_reserved_header(std::string_view name, std::span reserved) { + return std::ranges::any_of( + reserved, [&](std::string_view value) { return ascii_iequals(name, value); }); +} + +inline bool valid_header(std::string_view name, std::string_view value, + std::span reserved, bool allowHorizontalTab = false) { + return valid_header_name(name) && valid_header_value(value, allowHorizontalTab) && + !is_reserved_header(name, reserved); +} + +inline bool declares_import(const LoadedMod& mod, std::string_view serviceId) { + return std::ranges::any_of( + mod.manifestInfo.imports, [&](const ModManifestInfo::Import& serviceImport) { + return serviceImport.id == serviceId; + }); +} + +inline bool is_network_service(std::string_view serviceId) { + return serviceId == HTTP_SERVICE_ID || serviceId == NET_SERVICE_ID || + serviceId == WEBSOCKET_SERVICE_ID; +} + +inline std::string user_agent(const LoadedMod& mod) { + std::string version{mod.metadata.version}; + for (char& character : version) { + const auto value = static_cast(character); + if (value <= 32 || value >= 127) { + character = '_'; + } + } + return fmt::format("{}/{} {}/{}", AppName, BOREALIS_APP_VERSION, mod.metadata.id, version); +} + +} // namespace dusk::mods::svc::network diff --git a/src/dusk/mods/svc/overlay.cpp b/src/dusk/mods/svc/overlay.cpp index f4ad2ff6a6..478fbe32de 100644 --- a/src/dusk/mods/svc/overlay.cpp +++ b/src/dusk/mods/svc/overlay.cpp @@ -1,15 +1,16 @@ +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" -#include -#include "JSystem/JKernel/JKRArchive.h" -#include "aurora/dvd.h" #include "dusk/mods/loader/loader.hpp" #include "mods/svc/overlay.h" +#include "JSystem/JKernel/JKRArchive.h" + +#include +#include + #include #include -#include #include #include #include diff --git a/src/dusk/mods/svc/registry.cpp b/src/dusk/mods/svc/registry.cpp index 13c042af3d..33ceede924 100644 --- a/src/dusk/mods/svc/registry.cpp +++ b/src/dusk/mods/svc/registry.cpp @@ -215,6 +215,8 @@ void ModLoader::init_services() { &svc::g_resourceModule, &svc::g_fileModule, &svc::g_httpModule, + &svc::g_netModule, + &svc::g_websocketModule, &svc::g_hookModule, &svc::g_overlayModule, &svc::g_textureModule, @@ -231,6 +233,7 @@ void ModLoader::init_services() { &svc::g_flowModule, &svc::g_messageModule, &svc::g_gamemodeModule, + &svc::g_actorModule, }) { svc::register_module(*module); diff --git a/src/dusk/mods/svc/registry.hpp b/src/dusk/mods/svc/registry.hpp index 68ec9353cd..470208fad1 100644 --- a/src/dusk/mods/svc/registry.hpp +++ b/src/dusk/mods/svc/registry.hpp @@ -72,6 +72,8 @@ extern const ServiceModule g_logModule; extern const ServiceModule g_resourceModule; extern const ServiceModule g_fileModule; extern const ServiceModule g_httpModule; +extern const ServiceModule g_netModule; +extern const ServiceModule g_websocketModule; extern const ServiceModule g_hookModule; extern const ServiceModule g_overlayModule; extern const ServiceModule g_textureModule; @@ -88,5 +90,6 @@ extern const ServiceModule g_itemModule; extern const ServiceModule g_flowModule; extern const ServiceModule g_messageModule; extern const ServiceModule g_gamemodeModule; +extern const ServiceModule g_actorModule; } // namespace dusk::mods::svc diff --git a/src/dusk/mods/svc/save.cpp b/src/dusk/mods/svc/save.cpp index 360cdf6dca..b09b3999cc 100644 --- a/src/dusk/mods/svc/save.cpp +++ b/src/dusk/mods/svc/save.cpp @@ -3,13 +3,15 @@ #include "item.hpp" #include "registry.hpp" -#include "aurora/lib/logging.hpp" -#include "d/d_save.h" #include "dusk/main.h" #include "dusk/mods/loader/loader.hpp" #include "dusk/utilities.hpp" #include "mods/svc/save.h" +#include "d/d_save.h" + +#include + #include #include @@ -193,6 +195,8 @@ void save_slot_written(uint32_t slot, const void* slotData) { if (slot >= kSlotCount) { return; } + s_currentSlot = static_cast(slot); + notify(slot, &SaveObserverRecord::onWritten, "save-written"); load_sidecar(); auto& store = s_slots[slot]; if (slotData != nullptr) { @@ -200,7 +204,6 @@ void save_slot_written(uint32_t slot, const void* slotData) { store.snapshotCrc = utils::crc32(slotData, kQuestLogSize); } flush_sidecar(); - notify(slot, &SaveObserverRecord::onWritten, "save-written"); } void save_slot_copied(uint32_t fromSlot, uint32_t toSlot) { diff --git a/src/dusk/mods/svc/stage.cpp b/src/dusk/mods/svc/stage.cpp index 10af84a238..f20634e8ec 100644 --- a/src/dusk/mods/svc/stage.cpp +++ b/src/dusk/mods/svc/stage.cpp @@ -2,12 +2,13 @@ #include "registry.hpp" -#include "aurora/lib/logging.hpp" #include "dusk/mods/loader/loader.hpp" +#include "dusk/utilities.hpp" #include "mods/svc/stage.h" #include "d/d_com_inf_game.h" -#include "dusk/utilities.hpp" + +#include #include #include @@ -130,7 +131,9 @@ bool stage_apply_actor_edits(void* actorData, void* actorPrm, size_t recordSize, } std::memcpy(actorData, winner->record.data(), winner->record.size()); - std::memcpy(actorPrm, winner->record.data() + 8, winner->record.size() - 8); + if (actorPrm) { + std::memcpy(actorPrm, winner->record.data() + 8, winner->record.size() - 8); + } return true; } diff --git a/src/dusk/mods/svc/ui.cpp b/src/dusk/mods/svc/ui.cpp index 75e1d514cf..f10794d1ab 100644 --- a/src/dusk/mods/svc/ui.cpp +++ b/src/dusk/mods/svc/ui.cpp @@ -1,11 +1,10 @@ #include "ui.hpp" #include "config.hpp" +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include "ui_v1.hpp" -#include #include "dusk/mod_loader.hpp" #include "dusk/mods/loader/loader.hpp" #include "dusk/mods/log_buffer.hpp" @@ -16,15 +15,16 @@ #include "dusk/ui/ui.hpp" #include "mods/svc/ui.h" -#include #include +#include #include +#include +#include #include #include #include #include -#include #include #include #include @@ -37,16 +37,13 @@ #include #include -#include "SDL3/SDL_clipboard.h" - namespace { constexpr size_t kUiControlSelectedSize = offsetof(UiControlDesc, is_selected) + sizeof(UiPredicateFn); constexpr size_t kUiControlStringSetModeSize = offsetof(UiControlDesc, string_set_mode) + sizeof(UiStringSetMode); -constexpr size_t kUiControlFilePickerSize = - offsetof(UiControlDesc, directory_mode) + sizeof(bool); +constexpr size_t kUiControlFilePickerSize = offsetof(UiControlDesc, directory_mode) + sizeof(bool); constexpr size_t kUiListItemV21Size = offsetof(UiListItem, label) + sizeof(const char*); constexpr size_t kUiListDescV21Size = offsetof(UiListDesc, user_data) + sizeof(void*); @@ -650,8 +647,7 @@ ModResult ui_pane_add_control( spec.kind = ui::ModControlSpec::Kind::FilePicker; spec.directoryMode = desc.directory_mode; for (size_t i = 0; i < desc.file_filter_count; ++i) { - spec.fileFilters.push_back( - {desc.file_filters[i].name, desc.file_filters[i].pattern}); + spec.fileFilters.push_back({desc.file_filters[i].name, desc.file_filters[i].pattern}); } break; case UI_CONTROL_SELECT: @@ -915,7 +911,7 @@ ModResult ui_window_close(LoadedMod& mod, uint64_t handle) { if (slot == nullptr || slot->document == nullptr) { return MOD_INVALID_ARGUMENT; } - slot->document->hide(true); + slot->document->pop(); return MOD_OK; } @@ -1164,6 +1160,7 @@ void ui_remove_mod(LoadedMod& mod) { if (s_modMenuTabs.erase(&mod) != 0) { s_menuTabsDirty = true; } + bool restoreCoveredDocument = false; auto entries = s_slots.take_all(mod); for (auto& entry : entries) { auto& slot = entry.value; @@ -1171,6 +1168,7 @@ void ui_remove_mod(LoadedMod& mod) { case UiSlotKind::Window: { auto* window = static_cast(slot.document); if (window != nullptr) { + restoreCoveredDocument |= ui::top_document() == window; window->force_hide(true); } break; @@ -1178,6 +1176,7 @@ void ui_remove_mod(LoadedMod& mod) { case UiSlotKind::Dialog: { auto* dialog = static_cast(slot.document); if (dialog != nullptr) { + restoreCoveredDocument |= ui::top_document() == dialog; dialog->force_hide(true); } break; @@ -1189,6 +1188,9 @@ void ui_remove_mod(LoadedMod& mod) { break; } } + if (restoreCoveredDocument) { + ui::uncover_top_document(); + } } ModResult ui_get_clipboard_text( diff --git a/src/dusk/mods/svc/websocket.cpp b/src/dusk/mods/svc/websocket.cpp new file mode 100644 index 0000000000..a53c388b30 --- /dev/null +++ b/src/dusk/mods/svc/websocket.cpp @@ -0,0 +1,393 @@ +#include "registry.hpp" + +#include "internal.hpp" +#include "net.hpp" + +#include "dusk/mods/loader/loader.hpp" +#include "mods/svc/websocket.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace dusk::mods::svc { +namespace { + +constexpr size_t MaxConnectionsPerMod = 4; +constexpr size_t MaxUrlBytes = 8 * 1024; +constexpr size_t MaxHeaders = 64; +constexpr size_t MaxHeaderBytes = 16 * 1024; +constexpr size_t MaxProtocols = 8; +constexpr size_t DefaultMessageBytes = 1024 * 1024; +constexpr size_t MaxMessageBytes = 16 * 1024 * 1024; +constexpr std::chrono::milliseconds DefaultConnectTimeout{10000}; +constexpr std::chrono::milliseconds DefaultCloseTimeout{5000}; +constexpr std::string_view ReservedHeaders[]{ + "User-Agent", + "Host", + "Connection", + "Upgrade", + "Sec-WebSocket-Key", + "Sec-WebSocket-Version", + "Sec-WebSocket-Extensions", + "Sec-WebSocket-Protocol", + "Content-Length", +}; + +struct ConnectionState { + borealis::ws::Connection connection; + void* userData = nullptr; + bool openPublished = false; +}; + +struct ModPollState { + borealis::ws::Event currentEvent; + std::vector headers; + size_t next = 0; +}; + +SlotMap s_connections; +PerMod s_pollStates; + +bool valid_url(std::string_view url, bool& allowPlaintext) { + allowPlaintext = false; + if (url.size() > MaxUrlBytes) { + return false; + } + const auto parsed = borealis::url::parse(url); + if (!parsed || (parsed->scheme != "wss" && parsed->scheme != "ws")) { + return false; + } + allowPlaintext = parsed->scheme == "ws"; + if (!allowPlaintext) { + return true; + } + return parsed->host == "localhost" || parsed->host == "127.0.0.1" || parsed->host == "::1"; +} + +WebSocketError map_error(borealis::ws::Error error) { + switch (error) { + case borealis::ws::Error::None: + return WEBSOCKET_ERROR_NONE; + case borealis::ws::Error::InvalidUrl: + return WEBSOCKET_ERROR_INVALID_URL; + case borealis::ws::Error::UnsupportedScheme: + return WEBSOCKET_ERROR_UNSUPPORTED_SCHEME; + case borealis::ws::Error::Timeout: + return WEBSOCKET_ERROR_TIMEOUT; + case borealis::ws::Error::TooLarge: + return WEBSOCKET_ERROR_TOO_LARGE; + case borealis::ws::Error::Canceled: + return WEBSOCKET_ERROR_CANCELED; + case borealis::ws::Error::Protocol: + return WEBSOCKET_ERROR_PROTOCOL; + case borealis::ws::Error::Handshake: + return WEBSOCKET_ERROR_HANDSHAKE; + case borealis::ws::Error::NoBackend: + case borealis::ws::Error::Network: + default: + return WEBSOCKET_ERROR_NETWORK; + } +} + +ModResult map_send_result(borealis::ws::SendResult result) { + switch (result) { + case borealis::ws::SendResult::Ok: + return MOD_OK; + case borealis::ws::SendResult::NotOpen: + return MOD_UNAVAILABLE; + case borealis::ws::SendResult::QueueFull: + return MOD_CONFLICT; + case borealis::ws::SendResult::TooLarge: + case borealis::ws::SendResult::InvalidText: + return MOD_INVALID_ARGUMENT; + } + return MOD_ERROR; +} + +ModResult map_close_result(borealis::ws::CloseResult result) { + switch (result) { + case borealis::ws::CloseResult::Ok: + return MOD_OK; + case borealis::ws::CloseResult::NotOpen: + return MOD_UNAVAILABLE; + case borealis::ws::CloseResult::InvalidCode: + case borealis::ws::CloseResult::ReasonTooLarge: + case borealis::ws::CloseResult::InvalidText: + return MOD_INVALID_ARGUMENT; + } + return MOD_ERROR; +} + +size_t connection_count(const LoadedMod& mod) { + size_t count = 0; + s_connections.for_each([&](WebSocketHandle, const auto& entry) { + if (entry.owner == &mod) { + ++count; + } + }); + return count; +} + +ModResult websocket_connect( + ModContext* context, const WebSocketConnectDesc* desc, WebSocketHandle* outHandle) { + if (outHandle != nullptr) { + *outHandle = 0; + } + auto* mod = mod_from_context(context); + if (mod == nullptr || desc == nullptr || desc->struct_size < sizeof(WebSocketConnectDesc) || + desc->url == nullptr || outHandle == nullptr || + (desc->header_count != 0 && desc->headers == nullptr) || + (desc->protocol_count != 0 && desc->protocols == nullptr)) + { + return MOD_INVALID_ARGUMENT; + } + if (!declares_import(*mod, WEBSOCKET_SERVICE_ID)) { + return MOD_UNSUPPORTED; + } + bool allowPlaintext = false; + if (!valid_url(desc->url, allowPlaintext) || desc->header_count > MaxHeaders || + desc->protocol_count > MaxProtocols || desc->max_message_bytes > MaxMessageBytes) + { + return MOD_INVALID_ARGUMENT; + } + + size_t headerBytes = 0; + for (uint32_t index = 0; index < desc->header_count; ++index) { + const HttpHeader& header = desc->headers[index]; + if (header.name == nullptr || header.value == nullptr) { + return MOD_INVALID_ARGUMENT; + } + const std::string_view name{header.name}; + const std::string_view value{header.value}; + if (!valid_header(name, value, ReservedHeaders) || + name.size() > MaxHeaderBytes - std::min(headerBytes, MaxHeaderBytes)) + { + return MOD_INVALID_ARGUMENT; + } + headerBytes += name.size(); + if (value.size() > MaxHeaderBytes - std::min(headerBytes, MaxHeaderBytes)) { + return MOD_INVALID_ARGUMENT; + } + headerBytes += value.size(); + } + for (uint32_t index = 0; index < desc->protocol_count; ++index) { + if (desc->protocols[index] == nullptr || !valid_header_name(desc->protocols[index])) { + return MOD_INVALID_ARGUMENT; + } + } + if (!borealis::ws::available()) { + return MOD_UNAVAILABLE; + } + if (connection_count(*mod) >= MaxConnectionsPerMod) { + return MOD_CONFLICT; + } + + const size_t maxMessageBytes = + desc->max_message_bytes != 0 ? desc->max_message_bytes : DefaultMessageBytes; + borealis::ws::Options options{ + .url = desc->url, + .connectTimeout = desc->connect_timeout_ms != 0 ? + std::chrono::milliseconds{desc->connect_timeout_ms} : + DefaultConnectTimeout, + .closeTimeout = desc->close_timeout_ms != 0 ? + std::chrono::milliseconds{desc->close_timeout_ms} : + DefaultCloseTimeout, + .keepaliveInterval = std::chrono::milliseconds{desc->keepalive_interval_ms}, + .maxMessageBytes = maxMessageBytes, + .maxQueuedBytes = 16 * 1024 * 1024, + .maxSendQueueBytes = 4 * 1024 * 1024, + .allowPlaintext = allowPlaintext, + }; + options.headers.reserve(desc->header_count + 1); + for (uint32_t index = 0; index < desc->header_count; ++index) { + options.headers.push_back({desc->headers[index].name, desc->headers[index].value}); + } + options.headers.push_back({ + .name = "User-Agent", + .value = user_agent(*mod), + }); + options.protocols.reserve(desc->protocol_count); + for (uint32_t index = 0; index < desc->protocol_count; ++index) { + options.protocols.emplace_back(desc->protocols[index]); + } + auto connection = borealis::ws::connect(std::move(options)); + if (!connection) { + return MOD_UNAVAILABLE; + } + *outHandle = s_connections.emplace(*mod, ConnectionState{ + .connection = std::move(connection), + .userData = desc->user_data, + }); + return MOD_OK; +} + +ModResult websocket_poll_event(ModContext* context, WebSocketEvent* outEvent) { + const uint32_t structSize = outEvent != nullptr ? outEvent->struct_size : 0; + auto* mod = mod_from_context(context); + if (mod == nullptr || outEvent == nullptr || structSize < sizeof(WebSocketEvent)) { + return MOD_INVALID_ARGUMENT; + } + WebSocketEvent output{ + .struct_size = structSize, + .protocol = "", + .error_message = "", + .close_reason = "", + }; + + std::vector handles; + s_connections.for_each([&](WebSocketHandle handle, const auto& entry) { + if (entry.owner == mod) { + handles.push_back(handle); + } + }); + auto& pollState = s_pollStates.get_or_create(*mod); + if (handles.empty()) { + pollState.next = 0; + std::memcpy(outEvent, &output, sizeof(output)); + return MOD_OK; + } + + const size_t start = pollState.next % handles.size(); + WebSocketHandle selected = 0; + ConnectionState* selectedState = nullptr; + for (size_t offset = 0; offset < handles.size(); ++offset) { + const size_t index = (start + offset) % handles.size(); + auto* entry = s_connections.find_owned(handles[index], *mod); + if (entry != nullptr && entry->value.connection.poll(pollState.currentEvent)) { + selected = handles[index]; + selectedState = &entry->value; + pollState.next = index + 1; + break; + } + } + if (selectedState == nullptr) { + std::memcpy(outEvent, &output, sizeof(output)); + return MOD_OK; + } + + output.ws = selected; + output.user_data = selectedState->userData; + const auto& event = pollState.currentEvent; + pollState.headers.clear(); + pollState.headers.reserve(event.headers.size()); + for (const auto& header : event.headers) { + pollState.headers.push_back({header.name.c_str(), header.value.c_str()}); + } + output.headers = pollState.headers.data(); + output.header_count = static_cast(pollState.headers.size()); + if (event.kind == borealis::ws::Event::Kind::Open) { + output.type = WEBSOCKET_EVENT_OPEN; + output.protocol = event.protocol.c_str(); + selectedState->openPublished = true; + } else if (event.kind == borealis::ws::Event::Kind::Message) { + output.type = WEBSOCKET_EVENT_MESSAGE; + output.message_kind = event.messageKind == borealis::ws::MessageKind::Text ? + WEBSOCKET_MESSAGE_TEXT : + WEBSOCKET_MESSAGE_BINARY; + output.data = event.data.data(); + output.size = event.data.size(); + } else { + output.type = WEBSOCKET_EVENT_CLOSED; + output.error = map_error(event.error); + output.error_message = event.message.c_str(); + output.handshake_status = event.status; + output.close_code = event.code; + output.close_reason = event.reason.c_str(); + } + + std::memcpy(outEvent, &output, sizeof(output)); + if (event.kind == borealis::ws::Event::Kind::Closed) { + s_connections.erase(selected); + } + return MOD_OK; +} + +ModResult websocket_send(ModContext* context, WebSocketHandle handle, WebSocketMessageKind kind, + const void* data, size_t size) { + auto* mod = mod_from_context(context); + if (mod == nullptr || (size != 0 && data == nullptr) || + (kind != WEBSOCKET_MESSAGE_TEXT && kind != WEBSOCKET_MESSAGE_BINARY)) + { + return MOD_INVALID_ARGUMENT; + } + auto* entry = s_connections.find_owned(handle, *mod); + if (entry == nullptr || !entry->value.openPublished) { + return MOD_UNAVAILABLE; + } + const std::string_view bytes = data != nullptr ? + std::string_view{static_cast(data), size} : + std::string_view{}; + return map_send_result(entry->value.connection.send(kind == WEBSOCKET_MESSAGE_TEXT ? + borealis::ws::MessageKind::Text : + borealis::ws::MessageKind::Binary, + bytes)); +} + +ModResult websocket_close( + ModContext* context, WebSocketHandle handle, uint16_t code, const char* reason) { + auto* mod = mod_from_context(context); + const std::string_view reasonText = + reason != nullptr ? std::string_view{reason} : std::string_view{}; + if (mod == nullptr) { + return MOD_INVALID_ARGUMENT; + } + auto* entry = s_connections.find_owned(handle, *mod); + if (entry == nullptr) { + return MOD_UNAVAILABLE; + } + return map_close_result(entry->value.connection.close(code != 0 ? code : 1000, reasonText)); +} + +void websocket_mod_deactivating(LoadedMod& mod) { + (void)s_connections.take_all(mod); + s_pollStates.erase(mod); +} + +void websocket_mod_detached(LoadedMod& mod) { + bool found = false; + s_connections.for_each( + [&](WebSocketHandle, const auto& entry) { found = found || entry.owner == &mod; }); + assert(!found); + assert(!s_pollStates.contains(mod)); +} + +void websocket_shutdown() { + s_connections = {}; + s_pollStates.clear(); +} + +bool websocket_available() { + return borealis::ws::available(); +} + +constexpr WebSocketService s_websocketService{ + .header = SERVICE_HEADER(WebSocketService, WEBSOCKET_SERVICE_MAJOR, WEBSOCKET_SERVICE_MINOR), + .connect = SERVICE_FUNCTION(websocket_connect), + .poll_event = SERVICE_FUNCTION(websocket_poll_event), + .send = SERVICE_FUNCTION(websocket_send), + .close = SERVICE_FUNCTION(websocket_close), +}; + +} // namespace + +constinit const ServiceModule g_websocketModule{ + .id = WEBSOCKET_SERVICE_ID, + .majorVersion = WEBSOCKET_SERVICE_MAJOR, + .minorVersion = WEBSOCKET_SERVICE_MINOR, + .service = &s_websocketService, + .available = websocket_available, + .modDeactivating = websocket_mod_deactivating, + .modDetached = websocket_mod_detached, + .shutdown = websocket_shutdown, +}; + +} // namespace dusk::mods::svc diff --git a/src/dusk/mods/svc/window.cpp b/src/dusk/mods/svc/window.cpp index 7c9e938faf..5e61c43033 100644 --- a/src/dusk/mods/svc/window.cpp +++ b/src/dusk/mods/svc/window.cpp @@ -1,7 +1,7 @@ #include "window.hpp" +#include "internal.hpp" #include "registry.hpp" -#include "slot_map.hpp" #include #include "dusk/mods/loader/loader.hpp" diff --git a/src/dusk/stubs.cpp b/src/dusk/stubs.cpp index ac72f8377d..3cd99264c4 100644 --- a/src/dusk/stubs.cpp +++ b/src/dusk/stubs.cpp @@ -1,19 +1,14 @@ +#include "dusk/logging.h" +#include "dusk/main.h" + #include #include -#include -#include -#include -#include -#include +#include + +#include #include #include -#include #include -#include -#include -#include - -#include "tracy/Tracy.hpp" #ifndef _WIN32 #include diff --git a/src/dusk/time.h b/src/dusk/time.h index fad3186042..6423e084cf 100644 --- a/src/dusk/time.h +++ b/src/dusk/time.h @@ -1,10 +1,10 @@ #pragma once +#include + #include #include -#include "SDL3/SDL_timer.h" - #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN diff --git a/src/dusk/ui/achievements.cpp b/src/dusk/ui/achievements.cpp index 905fa57f59..3fe713520e 100644 --- a/src/dusk/ui/achievements.cpp +++ b/src/dusk/ui/achievements.cpp @@ -1,12 +1,14 @@ #include "achievements.hpp" -#include "Z2AudioLib/Z2SeMgr.h" -#include "dusk/achievements.h" -#include "fmt/format.h" -#include "m_Do/m_Do_audio.h" #include "nav_types.hpp" #include "pane.hpp" +#include "dusk/achievements.h" + +#include "m_Do/m_Do_audio.h" + +#include + namespace dusk::ui { namespace { diff --git a/src/dusk/ui/document.cpp b/src/dusk/ui/document.cpp index 8ad701d3ce..3278361f83 100644 --- a/src/dusk/ui/document.cpp +++ b/src/dusk/ui/document.cpp @@ -1,10 +1,11 @@ #include "document.hpp" -#include "aurora/rmlui.hpp" #include "ui.hpp" #include "m_Do/m_Do_audio.h" +#include + #include namespace dusk::ui { diff --git a/src/dusk/ui/menu_bar.cpp b/src/dusk/ui/menu_bar.cpp index 4884dbf3a9..5ebf65145d 100644 --- a/src/dusk/ui/menu_bar.cpp +++ b/src/dusk/ui/menu_bar.cpp @@ -1,32 +1,30 @@ #include "menu_bar.hpp" -#include - -#include "Z2AudioLib/Z2SeMgr.h" -#include "m_Do/m_Do_audio.h" - #include "achievements.hpp" -#include "aurora/rmlui.hpp" +#include "editor.hpp" +#include "modal.hpp" +#include "mods_window.hpp" +#include "prelaunch.hpp" +#include "settings.hpp" +#include "ui.hpp" +#include "warp.hpp" +#include "window.hpp" + #include "dusk/game_mode.hpp" #include "dusk/livesplit.h" #include "dusk/main.h" #include "dusk/mods/svc/ui.hpp" #include "dusk/settings.h" #include "dusk/speedrun.h" -#include "dusk/ui/prelaunch.hpp" -#include "editor.hpp" -#include "f_op/f_op_scene_mng.h" + #include "f_pc/f_pc_manager.h" #include "f_pc/f_pc_name.h" -#include "imgui.h" -#include "modal.hpp" -#include "mods_window.hpp" -#include "settings.hpp" -#include "ui.hpp" -#include "warp.hpp" -#include "window.hpp" +#include "m_Do/m_Do_audio.h" + +#include +#include +#include -#include #include namespace dusk::ui { diff --git a/src/dusk/ui/mod_texture_provider.cpp b/src/dusk/ui/mod_texture_provider.cpp index 140d95f18b..54cdcbef70 100644 --- a/src/dusk/ui/mod_texture_provider.cpp +++ b/src/dusk/ui/mod_texture_provider.cpp @@ -182,6 +182,7 @@ std::optional mod_texture_provider(std::string_vi .rgba8 = std::span{reinterpret_cast(image.pixels.data()), image.pixels.size()}, .premultipliedAlpha = true, + .generateMipmaps = true, }; } diff --git a/src/dusk/ui/mods_window.cpp b/src/dusk/ui/mods_window.cpp index 757fa42b62..43775d8902 100644 --- a/src/dusk/ui/mods_window.cpp +++ b/src/dusk/ui/mods_window.cpp @@ -1,16 +1,17 @@ #include "mods_window.hpp" -#include "dusk/mod_loader.hpp" -#include "dusk/mods/svc/ui.hpp" -#include "fmt/format.h" #include "logs_window.hpp" #include "mod_texture_provider.hpp" -#include "mods/svc/http.h" #include "pane.hpp" -#include "Z2AudioLib/Z2SeMgr.h" +#include "dusk/mod_loader.hpp" +#include "dusk/mods/svc/net.hpp" +#include "dusk/mods/svc/ui.hpp" + #include "m_Do/m_Do_audio.h" +#include + #include #include #include @@ -44,7 +45,7 @@ ModStatus mod_status(const mods::LoadedMod& mod) { bool mod_uses_network(const mods::LoadedMod& mod) { return std::ranges::any_of( mod.manifestInfo.imports, [](const mods::ModManifestInfo::Import& serviceImport) { - return serviceImport.id == HTTP_SERVICE_ID; + return mods::svc::is_network_service(serviceImport.id); }); } diff --git a/src/dusk/ui/overlay.cpp b/src/dusk/ui/overlay.cpp index be95e99a4f..2dc77aebec 100644 --- a/src/dusk/ui/overlay.cpp +++ b/src/dusk/ui/overlay.cpp @@ -1,22 +1,25 @@ #include "overlay.hpp" -#include #include "controller_config.hpp" +#include "window.hpp" + #include "dusk/achievements.h" #include "dusk/action_bindings.h" #include "dusk/livesplit.h" #include "dusk/settings.h" #include "dusk/speedrun.h" -#include "fmt/format.h" -#include "magic_enum.hpp" -#include "window.hpp" +#include "m_Do/m_Do_main.h" + +#include +#include +#include +#include +#include #include #include + #include -#include -#include -#include #if defined(__APPLE__) #include diff --git a/src/dusk/ui/settings.cpp b/src/dusk/ui/settings.cpp index 123ab4f4bb..c7fc22ccc1 100644 --- a/src/dusk/ui/settings.cpp +++ b/src/dusk/ui/settings.cpp @@ -1,41 +1,38 @@ #include "settings.hpp" -#include "aurora/gfx.h" #include "bool_button.hpp" #include "controller_config.hpp" -#include "dusk/app_info.hpp" -#include "dusk/audio/DuskAudioSystem.h" -#include "dusk/audio/DuskDsp.hpp" -#include "dusk/config.hpp" -#include "dusk/hotkeys.h" -#include "dusk/data.hpp" -#include "dusk/imgui/ImGuiEngine.hpp" -#include "dusk/io.hpp" -#include "dusk/language.hpp" -#include "dusk/presentation.hpp" -#include -#include -#include "dusk/livesplit.h" -#include "dusk/discord_presence.hpp" -#include "dusk/speedrun.h" #include "graphics_tuner.hpp" -#include "m_Do/m_Do_main.h" #include "menu_bar.hpp" #include "modal.hpp" #include "number_button.hpp" -#include "menu_bar.hpp" #include "pane.hpp" #include "prelaunch.hpp" #include "touch_controls_editor.hpp" #include "ui.hpp" -#include -#include -#include +#include "dusk/app_info.hpp" +#include "dusk/audio/DuskAudioSystem.h" +#include "dusk/audio/DuskDsp.hpp" +#include "dusk/config.hpp" +#include "dusk/data.hpp" +#include "dusk/discord_presence.hpp" +#include "dusk/hotkeys.h" +#include "dusk/imgui/ImGuiEngine.hpp" +#include "dusk/language.hpp" +#include "dusk/livesplit.h" +#include "dusk/presentation.hpp" +#include "dusk/speedrun.h" +#include +#include +#include +#include #if BOREALIS_HAS_SENTRY #include #endif +#include +#include #include #include diff --git a/src/dusk/ui/ui.cpp b/src/dusk/ui/ui.cpp index 0e3a8d7c32..91dec21a17 100644 --- a/src/dusk/ui/ui.cpp +++ b/src/dusk/ui/ui.cpp @@ -1,23 +1,5 @@ #include "ui.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "aurora/lib/window.hpp" -#include "dusk/config.hpp" -#include "dusk/io.hpp" -#include #include "command_console.hpp" #include "icon_provider.hpp" #include "input.hpp" @@ -25,6 +7,24 @@ #include "prelaunch.hpp" #include "window.hpp" +#include "dusk/config.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + namespace dusk::ui { namespace { diff --git a/src/dusk/ui/warp.cpp b/src/dusk/ui/warp.cpp index efae7f1d65..0827745fa1 100644 --- a/src/dusk/ui/warp.cpp +++ b/src/dusk/ui/warp.cpp @@ -4,7 +4,8 @@ #include "pane.hpp" #include "dusk/map_loader_definitions.h" -#include "fmt/format.h" + +#include namespace dusk::ui { namespace { diff --git a/src/dusk/ui/window.cpp b/src/dusk/ui/window.cpp index f1162a09b6..bf0fee5ea9 100644 --- a/src/dusk/ui/window.cpp +++ b/src/dusk/ui/window.cpp @@ -1,15 +1,15 @@ #include "window.hpp" -#include "aurora/lib/window.hpp" -#include "aurora/rmlui.hpp" -#include "fmt/format.h" -#include "magic_enum.hpp" #include "pane.hpp" #include "ui.hpp" -#include "Z2AudioLib/Z2SeMgr.h" #include "m_Do/m_Do_audio.h" +#include +#include +#include +#include + #include #include diff --git a/src/dusk/version.cpp b/src/dusk/version.cpp index 5d0856aed1..fe98195126 100644 --- a/src/dusk/version.cpp +++ b/src/dusk/version.cpp @@ -60,8 +60,12 @@ bool isWii() { || getGameVersion() == GameVersion::WiiKor; } +bool isLessThanWiiJpn() { + return getGameVersion() < GameVersion::WiiJpn; +} + bool isJpnOrLessThanWiiJpn() { - return isRegionJpn() || getGameVersion() < GameVersion::WiiJpn; + return isRegionJpn() || isLessThanWiiJpn(); } bool isPalOrAtLeastWiiR2() { diff --git a/src/dusk/version.hpp b/src/dusk/version.hpp index 59e2895f77..4979074d9a 100644 --- a/src/dusk/version.hpp +++ b/src/dusk/version.hpp @@ -17,6 +17,7 @@ namespace dusk::version { bool isGcn(); bool isWii(); + bool isLessThanWiiJpn(); bool isJpnOrLessThanWiiJpn(); bool isPalOrAtLeastWiiR2(); diff --git a/src/f_ap/f_ap_game.cpp b/src/f_ap/f_ap_game.cpp index 3627f16bbb..a3a981eaba 100644 --- a/src/f_ap/f_ap_game.cpp +++ b/src/f_ap/f_ap_game.cpp @@ -1,37 +1,37 @@ #include "f_ap/f_ap_game.h" -#include -#include "DynamicLink.h" -#include "JSystem/J3DGraphLoader/J3DModelLoader.h" -#include "JSystem/J3DGraphLoader/J3DModelSaver.h" -#include "JSystem/JHostIO/JORFile.h" -#include "JSystem/JKernel/JKRAram.h" -#include "JSystem/JKernel/JKRAramArchive.h" -#include "JSystem/JKernel/JKRSolidHeap.h" -#include "JSystem/JUtility/JUTDbPrint.h" #include "SSystem/SComponent/c_counter.h" -#include "d/actor/d_a_alink.h" -#include "d/actor/d_a_grass.h" -#include "d/actor/d_a_midna.h" -#include "d/d_model.h" -#include "d/d_tresure.h" -#include "dusk/achievements.h" -#include "dusk/frame_interpolation.h" -#include "dusk/livesplit.h" -#include "dusk/logging.h" -#include "dusk/mod_loader.hpp" #include "f_op/f_op_camera_mng.h" #include "f_op/f_op_draw_tag.h" #include "f_op/f_op_overlap_mng.h" #include "f_op/f_op_scene_mng.h" -#include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_main.h" +#include "m_Do/m_Do_graphic.h" +#include "DynamicLink.h" +#include "JSystem/JKernel/JKRSolidHeap.h" +#include "JSystem/JKernel/JKRAram.h" +#include "JSystem/JKernel/JKRAramArchive.h" +#include "JSystem/JUtility/JUTDbPrint.h" +#include "JSystem/JHostIO/JORFile.h" +#include "JSystem/J3DGraphLoader/J3DModelLoader.h" +#include "JSystem/J3DGraphLoader/J3DModelSaver.h" +#include "d/actor/d_a_alink.h" +#include "d/actor/d_a_midna.h" +#include "d/d_model.h" +#include "d/actor/d_a_grass.h" +#include "d/d_tresure.h" +#include #if TARGET_PC -#include -#include +#include "dusk/achievements.h" +#include "dusk/autosave.h" #include "dusk/game_mode.hpp" +#include "dusk/gamepad_color.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/logging.h" #include "dusk/menu_pointer.h" -#include "tracy/Tracy.hpp" +#include "dusk/mod_loader.hpp" + +#include #endif fapGm_HIO_c::fapGm_HIO_c() { @@ -735,11 +735,11 @@ void fapGm_After() { #ifdef TARGET_PC static void fapGm_Before() { - dusk::frame_interp::begin_record(); + dusk::interp::begin_record(); } static void fapGm_AfterRecord() { - dusk::frame_interp::end_record(); + dusk::interp::end_record(); fapGm_After(); } @@ -829,7 +829,8 @@ void fapGm_Execute() { #endif cCt_Counter(0); -#ifdef TARGET_PC +#if TARGET_PC + dComIfGp_particle_calcMenu(); const dusk::gamemode::GameMode* gameMode = dusk::gamemode::getGameModeManager().getCurrentGameMode(); if (gameMode) { diff --git a/src/f_op/f_op_actor.cpp b/src/f_op/f_op_actor.cpp index 4e5940eec4..db85ea3bf3 100644 --- a/src/f_op/f_op_actor.cpp +++ b/src/f_op/f_op_actor.cpp @@ -19,6 +19,10 @@ #include "c/c_dylink.h" #include "m_Do/m_Do_printf.h" +#if TARGET_PC +#include "dusk/interp/dual_buffer.h" +#endif + #if DEBUG class print_error_check_c { public: @@ -413,6 +417,7 @@ static int fopAc_Delete(void* i_this) { #endif if (ret == TRUE) { + IF_DUSK(dusk::interp::erase_owned_buffers(actor)); fopAcTg_ActorQTo(&actor->actor_tag); fopDwTg_DrawQTo(&actor->draw_tag); fopAcM_DeleteHeap((fopAc_ac_c*) i_this); diff --git a/src/f_op/f_op_actor_mng.cpp b/src/f_op/f_op_actor_mng.cpp index 3097b9294f..207a0471b3 100644 --- a/src/f_op/f_op_actor_mng.cpp +++ b/src/f_op/f_op_actor_mng.cpp @@ -1621,6 +1621,7 @@ fpc_ProcID fopAcM_createItemForBoss(const cXyz* i_pos, int i_itemNo, int i_roomN if (i_itemNo != originalItemNo) { const u32 params = 0xFFFF0000 | param_8 << 8 | (i_itemNo & 0xFF); + dusk::mods::set_boss_item_actor_speeds(i_speedF, i_speedY); return fopAcM_create(fpcNm_Obj_LifeContainer_e, params, i_pos, i_roomNo, i_angle, i_scale, -1, giveTag, originalItemNo); } diff --git a/src/f_pc/f_pc_draw.cpp b/src/f_pc/f_pc_draw.cpp index 8b775257fc..8c53618219 100644 --- a/src/f_pc/f_pc_draw.cpp +++ b/src/f_pc/f_pc_draw.cpp @@ -8,9 +8,10 @@ #include "f_pc/f_pc_leaf.h" #include "f_pc/f_pc_node.h" #include "f_pc/f_pc_pause.h" -#include "dusk/frame_interpolation.h" -#include + +#if TARGET_PC #include "dusk/logging.h" +#endif int fpcDw_Execute(base_process_class* i_proc) { if (!fpcPause_IsEnable(i_proc, 2)) { diff --git a/src/f_pc/f_pc_leaf.cpp b/src/f_pc/f_pc_leaf.cpp index d28067c7ff..e2fdd97fb0 100644 --- a/src/f_pc/f_pc_leaf.cpp +++ b/src/f_pc/f_pc_leaf.cpp @@ -7,7 +7,7 @@ #include "f_pc/f_pc_debug_sv.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" #endif s16 fpcLf_GetPriority(const leafdraw_class* i_leaf) { @@ -21,7 +21,7 @@ int fpcLf_DrawMethod(leafdraw_method_class DUSK_CONST* i_methods, void* i_proces int fpcLf_Draw(leafdraw_class* i_leaf) { int ret = 0; #if TARGET_PC - if (!i_leaf->draw_interp_frame && !dusk::frame_interp::is_sim_frame()) { + if (!i_leaf->draw_interp_frame && !dusk::game_clock::is_sim_frame()) { return ret; } #endif @@ -65,9 +65,7 @@ int fpcLf_Create(leafdraw_class* i_leaf) { LEAFDRAW_BASE(i_leaf).subtype = fpcBs_MakeOfType(&g_fpcLf_type); fpcDwPi_Init(&i_leaf->draw_priority, pprofile->priority); i_leaf->unk_0xBC = 0; -#if TARGET_PC - i_leaf->draw_interp_frame = false; -#endif + IF_DUSK(i_leaf->draw_interp_frame = false); } int ret = fpcMtd_Create(&i_leaf->leaf_methods->base, i_leaf); diff --git a/src/f_pc/f_pc_manager.cpp b/src/f_pc/f_pc_manager.cpp index 22c705c720..d2276bf8cb 100644 --- a/src/f_pc/f_pc_manager.cpp +++ b/src/f_pc/f_pc_manager.cpp @@ -23,9 +23,9 @@ #if TARGET_PC #include "dusk/game_clock.h" -#endif -#include "tracy/Tracy.hpp" +#include +#endif void fpcM_Draw(void* i_proc) { fpcDw_Execute((base_process_class*)i_proc); @@ -101,11 +101,13 @@ void fpcM_Management(fpcM_ManagementFunc i_preExecuteFn, fpcM_ManagementFunc i_p fpcDw_Handler((fpcDw_HandlerFuncFunc)fpcM_DrawIterater, (fpcDw_HandlerFunc)fpcM_Draw); } + IF_DUSK(dComIfGp_drawSimpleModel()); + if (i_postExecuteFn != NULL) { i_postExecuteFn(); } - dComIfGp_drawSimpleModel(); + IF_NOT_DUSK(dComIfGp_drawSimpleModel()); } else if (!l_dvdError) { dLib_time_c::stopTime(); Z2GetSoundMgr()->pauseAllGameSound(true); diff --git a/src/f_pc/f_pc_node.cpp b/src/f_pc/f_pc_node.cpp index d56cd6d4c6..7cc88ec0db 100644 --- a/src/f_pc/f_pc_node.cpp +++ b/src/f_pc/f_pc_node.cpp @@ -8,10 +8,10 @@ #include "f_pc/f_pc_debug_sv.h" #if TARGET_PC +#include "dusk/game_clock.h" + #include "f_op/f_op_draw_iter.h" #include "f_pc/f_pc_manager.h" - -#include "dusk/frame_interpolation.h" #endif int fpcNd_DrawMethod(nodedraw_method_class* i_method_class, void* i_data) { @@ -26,7 +26,7 @@ int fpcNd_Draw(process_node_class* i_procNode) { layer_class* save_layer = fpcLy_CurrentLayer(); fpcLy_SetCurrentLayer(&var_r28->layer); #if TARGET_PC - if (!i_procNode->draw_interp_frame && !dusk::frame_interp::is_sim_frame()) { + if (!i_procNode->draw_interp_frame && !dusk::game_clock::is_sim_frame()) { for (create_tag_class* i = fopDwIt_Begin(); i != NULL; i = fopDwIt_Next(i)) { void* process = i->mpTagData; fpcM_Draw(process); diff --git a/src/f_pc/f_pc_profile.cpp b/src/f_pc/f_pc_profile.cpp index 4828ca4433..34eafc1701 100644 --- a/src/f_pc/f_pc_profile.cpp +++ b/src/f_pc/f_pc_profile.cpp @@ -5,18 +5,36 @@ #include "f_pc/f_pc_profile.h" +#if TARGET_PC +#include "dusk/mods/svc/actor.hpp" +#include "f_pc/f_pc_name.h" +#endif #ifndef __MWERKS__ // Forward declare the static list from f_pc_profile_lst.cpp DUSK_GAME_EXTERN process_profile_definition DUSK_CONST* DUSK_CONST g_fpcPfLst_ProfileList[]; // On PC: Direct pointer to static array -DUSK_GAME_DATA process_profile_definition DUSK_CONST* DUSK_CONST* DUSK_CONST g_fpcPf_ProfileList_p = g_fpcPfLst_ProfileList; +DUSK_GAME_DATA process_profile_definition DUSK_CONST* DUSK_CONST* DUSK_CONST g_fpcPf_ProfileList_p = + g_fpcPfLst_ProfileList; #else // On Console: Pointer initialized by REL module prolog process_profile_definition** g_fpcPf_ProfileList_p; #endif process_profile_definition DUSK_CONST* fpcPf_Get(s16 i_profname) { +#if TARGET_PC + // Check if a mod has registered an actor with i_profname. Fallback to the profile list if it + // doesn't exist. + process_profile_definition* profile = + dusk::mods::svc::actor_impl::get_profile_from_proc_name(i_profname); + if (profile != nullptr) { + return profile; + } + if (i_profname < 0 || i_profname >= fpcNm_MAX_NUM) { + return nullptr; + } +#endif + int index = i_profname; return g_fpcPf_ProfileList_p[index]; } diff --git a/src/helpers/batch.cpp b/src/helpers/batch.cpp index a614eb8b1c..ea77363e24 100644 --- a/src/helpers/batch.cpp +++ b/src/helpers/batch.cpp @@ -1,4 +1,5 @@ #include "helpers/batch.hpp" + #include "dusk/logging.h" #include diff --git a/src/helpers/endian.cpp b/src/helpers/endian.cpp index a4de822f07..885527da85 100644 --- a/src/helpers/endian.cpp +++ b/src/helpers/endian.cpp @@ -1,8 +1,9 @@ #include "helpers/endian.h" -#include -#include "SSystem/SComponent/c_xyz.h" + #include "helpers/endian_gx.hpp" +#include "SSystem/SComponent/c_xyz.h" + #define IMPL_ENUM(type) \ template <> \ type BE::swap(type val) { \ diff --git a/src/helpers/string.cpp b/src/helpers/string.cpp index 23fdbfb8db..67b8115c51 100644 --- a/src/helpers/string.cpp +++ b/src/helpers/string.cpp @@ -1,5 +1,6 @@ #include "helpers/string.hpp" -#include "fmt/format.h" + +#include namespace { void strncpyProxy(char* dst, const char* src, size_t count) { diff --git a/src/m_Do/m_Do_audio.cpp b/src/m_Do/m_Do_audio.cpp index fec93cbed4..9be3b5dde0 100644 --- a/src/m_Do/m_Do_audio.cpp +++ b/src/m_Do/m_Do_audio.cpp @@ -12,10 +12,11 @@ #include "d/d_debug_viewer.h" #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_dvd_thread.h" -#include "tracy/Tracy.hpp" #if TARGET_PC #include "dusk/settings.h" + +#include #endif #if PLATFORM_WII || PLATFORM_SHIELD diff --git a/src/m_Do/m_Do_controller_pad.cpp b/src/m_Do/m_Do_controller_pad.cpp index 9751bf4f27..f1a8e66637 100644 --- a/src/m_Do/m_Do_controller_pad.cpp +++ b/src/m_Do/m_Do_controller_pad.cpp @@ -10,12 +10,13 @@ #include "f_ap/f_ap_game.h" #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_main.h" -#include "tracy/Tracy.hpp" #if TARGET_PC #include "dusk/menu_pointer.h" #include "dusk/settings.h" #include "dusk/ui/touch_controls.hpp" + +#include #endif DUSK_GAME_DATA JUTGamePad* mDoCPd_c::m_gamePad[4]; diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index 2d7cc86bbd..a53275b7fb 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -24,14 +24,29 @@ #include "m_Do/m_Do_mtx.h" #include #include + +#if TARGET_PC +#include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/interp/line.h" #include "dusk/logging.h" -#include "dusk/frame_interpolation.h" #include "dusk/version.hpp" +#endif DUSK_GAME_DATA u8 mDoExt::CurrentHeapAdjustVerbose; DUSK_GAME_DATA u8 mDoExt::HeapAdjustVerbose; DUSK_GAME_DATA u8 mDoExt::HeapAdjustQuiet; +#if TARGET_PC +namespace { +enum InterpKind : u8 { + LINE_NONE, + LINE_UNIFORM_WIDTH, + LINE_PER_POINT_WIDTH, +}; +} // namespace +#endif + static void mDoExt_setJ3DData(Mtx mtx, const J3DTransformInfo* transformInfo, u16 param_2) { bool local_28; if (cM3d_IsZero(transformInfo->mScale.x - 1.0f) && cM3d_IsZero(transformInfo->mScale.y - 1.0f) && cM3d_IsZero(transformInfo->mScale.z - 1.0f)) { @@ -310,6 +325,11 @@ static void mDoExt_modelDiff(J3DModel* i_model) { modelMtxErrorCheck(i_model); i_model->calcMaterial(); i_model->diff(); +#if TARGET_PC + if (!dusk::game_clock::is_sim_frame()) { + return; + } +#endif i_model->entry(); } @@ -352,10 +372,11 @@ void mDoExt_modelUpdateDL(J3DModel* i_model) { void mDoExt_modelEntryDL(J3DModel* i_model) { #if TARGET_PC - if (!dusk::frame_interp::is_sim_frame()) { + if (!dusk::game_clock::is_sim_frame()) { // FRAME INTERP NOTE: This fixes issue #355 where some lights would flicker. // This is likely better solved by updating J3DMaterial::needsInterpCallBack, // but it's unclear what exactly needs to be added. + i_model->calcMaterial(); i_model->diff(); return; } @@ -2354,6 +2375,12 @@ int mDoExt_3DlineMat0_c::init(u16 param_0, u16 param_1, int param_2) { field_0x4 = NULL; field_0x16 = 0; +#if TARGET_PC + mInterpWidth = 0.0f; + mInterpTaper = 0; + mInterpKind = LINE_NONE; + dusk::interp::line::reset(this); +#endif return 1; } @@ -2413,7 +2440,7 @@ void mDoExt_3DlineMat0_c::draw() { } #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) #endif { field_0x16 ^= (u8)1; @@ -2433,6 +2460,12 @@ void mDoExt_3DlineMat0_c::update(int param_0, f32 param_1, GXColor& param_2, u16 field_0x14 = (u16)param_0; } +#if TARGET_PC + mInterpWidth = param_1; + mInterpTaper = param_3; + mInterpKind = LINE_UNIFORM_WIDTH; +#endif + view_class* sp_2c = dComIfGd_getView(); mDoExt_3Dline_c* sp_28 = field_0x18; @@ -2551,6 +2584,8 @@ void mDoExt_3DlineMat0_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa field_0x14 = (u16)param_0; } + IF_DUSK(mInterpKind = LINE_PER_POINT_WIDTH); + view_class* sp_34 = dComIfGd_getView(); mDoExt_3Dline_c* sp_30 = field_0x18; @@ -2668,7 +2703,10 @@ int mDoExt_3DlineMat1_c::init(u16 param_0, u16 param_1, ResTIMG* param_2, int pa field_0x4 = 0; mIsDrawn = 0; #if TARGET_PC - mInterpLineKind = 0; + mInterpWidth = 0.0f; + mInterpTaper = 0; + mInterpKind = LINE_NONE; + dusk::interp::line::reset(this); #endif GXInitTexObj(&mTextureObject, (void*)((intptr_t)param_2 + param_2->imageOffset), param_2->width, @@ -2745,18 +2783,14 @@ void mDoExt_3DlineMat1_c::draw() { } GXSetTexCoordScaleManually(GX_TEXCOORD0, 0, 0, 0); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) #endif { mIsDrawn ^= (u8)1; } } -#if TARGET_PC -void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 param_3, dKy_tevstr_c* param_4, const cXyz* presentationEye) { -#else void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 param_3, dKy_tevstr_c* param_4) { -#endif mColor = param_2; this->mpTevStr = param_4; if (param_0 < 0) { @@ -2768,9 +2802,9 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 } #if TARGET_PC - mInterpLineKind = 1; - mInterpLineF = param_1; - mInterpLineU16 = param_3; + mInterpWidth = param_1; + mInterpTaper = param_3; + mInterpKind = LINE_UNIFORM_WIDTH; #endif view_class* sp_3c = dComIfGd_getView(); @@ -2826,12 +2860,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 local_f31 += local_f30 * 0.02f * (8.0f / param_1); } -#if TARGET_PC - const cXyz& lineEye = (presentationEye != nullptr && dusk::frame_interp::is_enabled()) ? *presentationEye : sp_3c->lookat.eye; - sp_13c = *local_r27 - lineEye; -#else sp_13c = *local_r27 - sp_3c->lookat.eye; -#endif sp_130 = sp_130.outprod(sp_13c); sp_130.normalizeZP(); @@ -2866,11 +2895,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 local_f31 += local_f30 * 0.02f * (8.0f / param_1); } -#if TARGET_PC - sp_13c = local_r27[0] - lineEye; -#else sp_13c = local_r27[0] - sp_3c->lookat.eye; -#endif sp_130 = sp_130.outprod(sp_13c); sp_130.normalizeZP(); @@ -2943,11 +2968,7 @@ void mDoExt_3DlineMat2_c::setMaterial() { GXLoadNrmMtxImm(cMtx_getIdentity(), 0); } -#if TARGET_PC -void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* param_4, const cXyz* presentationEye) { -#else -void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* param_4 -#endif +void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* param_4) { mColor = param_2; this->mpTevStr = param_4; if (param_0 < 0) { @@ -2958,9 +2979,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa field_0x34 = param_0; } -#if TARGET_PC - mInterpLineKind = 2; -#endif + IF_DUSK(mInterpKind = LINE_PER_POINT_WIDTH); view_class* stack_3c = dComIfGd_getView(); mDoExt_3Dline_c* sp_38 = mpLines; @@ -2987,12 +3006,6 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa for (s32 sp_14 = 0; sp_14 < mNumLines; sp_14++) { local_r27 = sp_38[0].field_0x0; size_p = sp_38->field_0x4; -#if TARGET_PC - if (presentationEye != nullptr && dusk::frame_interp::is_enabled() && size_p == NULL) { - sp_38 += 1; - continue; - } -#endif JUT_ASSERT(5875, size_p != NULL); sp_24 = sp_38->field_0x8[mIsDrawn]; sp_28 = sp_24; @@ -3006,12 +3019,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa sp_130 = local_r27[1] - local_r27[0]; local_f30 = sp_130.abs(); local_f31 += local_f30 * 0.1f; -#if TARGET_PC - const cXyz& lineEye = (presentationEye != nullptr && dusk::frame_interp::is_enabled()) ? *presentationEye : stack_3c->lookat.eye; - sp_13c = local_r27[0] - lineEye; -#else sp_13c = local_r27[0] - stack_3c->lookat.eye; -#endif sp_130 = sp_130.outprod(sp_13c); sp_130.normalizeZP(); local_r30->x = sp_130.x * 64.0f; @@ -3033,11 +3041,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa sp_130 = local_r27[1] - local_r27[0]; local_f30 = sp_130.abs(); local_f31 += local_f30 * 0.1f; -#if TARGET_PC - sp_13c = local_r27[0] - lineEye; -#else sp_13c = local_r27[0] - stack_3c->lookat.eye; -#endif sp_130 = sp_130.outprod(sp_13c); sp_130.normalizeZP(); local_r30 += 2; @@ -3082,16 +3086,42 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa } #if TARGET_PC -void mDoExt_3DlineMat1_c::refreshGeometryForPresentationEye(const cXyz& eye) { - if (!dusk::frame_interp::is_enabled()) { +namespace { + +template +void refresh_3dline_geometry(Material* material, dusk::interp::line::Points points, u8 kind, + f32 width, u16 taper, GXColor& color, dKy_tevstr_c* tevStr) { + if (!dusk::interp::is_enabled()) { return; } - if (mInterpLineKind == 1) { - update(field_0x34, mInterpLineF, mColor, mInterpLineU16, mpTevStr, &eye); - } else if (mInterpLineKind == 2) { - update(field_0x34, mColor, mpTevStr, &eye); + + dusk::interp::line::write(material, points); + if (kind == LINE_UNIFORM_WIDTH) { + material->update(points.point_count, width, color, taper, tevStr); + } else if (kind == LINE_PER_POINT_WIDTH) { + material->update(points.point_count, color, tevStr); } } + +} // namespace + +void mDoExt_3DlineMat0_c::captureInterpPoints() { + dusk::interp::line::capture(this, {field_0x18, field_0x10, field_0x14}); +} + +void mDoExt_3DlineMat0_c::refreshGeometryForPresentation() { + refresh_3dline_geometry(this, {field_0x18, field_0x10, field_0x14}, mInterpKind, + mInterpWidth, mInterpTaper, field_0x8, field_0xc); +} + +void mDoExt_3DlineMat1_c::captureInterpPoints() { + dusk::interp::line::capture(this, {mpLines, mNumLines, field_0x34}); +} + +void mDoExt_3DlineMat1_c::refreshGeometryForPresentation() { + refresh_3dline_geometry(this, {mpLines, mNumLines, field_0x34}, mInterpKind, + mInterpWidth, mInterpTaper, mColor, mpTevStr); +} #endif void mDoExt_3DlineMatSortPacket::setMat(mDoExt_3DlineMat_c* i_3DlineMat) { @@ -3100,6 +3130,7 @@ void mDoExt_3DlineMatSortPacket::setMat(mDoExt_3DlineMat_c* i_3DlineMat) { } i_3DlineMat->field_0x4 = mp3DlineMat; mp3DlineMat = i_3DlineMat; + IF_DUSK(i_3DlineMat->captureInterpPoints()); } void mDoExt_3DlineMatSortPacket::draw() { @@ -3646,12 +3677,22 @@ void mDoExt_cylinderMPacket::draw() { GXSetCullMode(GX_CULL_BACK); GXSetClipMode(GX_CLIP_ENABLE); +#if TARGET_PC + Mtx modelViewMtx; + cMtx_concat(j3dSys.getViewMtx(), mMatrix, modelViewMtx); + GXLoadPosMtxImm(modelViewMtx, 0); + + Mtx normalMtx; + cMtx_inverseTranspose(modelViewMtx, normalMtx); + GXLoadNrmMtxImm(normalMtx, 0); +#else cMtx_concat(j3dSys.getViewMtx(), mMatrix, mMatrix); GXLoadPosMtxImm(mMatrix, 0); cMtx_inverseTranspose(mMatrix, mMatrix); GXLoadNrmMtxImm(mMatrix, 0); +#endif GXSetCurrentMtx(0); GXDrawCylinder(8); diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 0d0f9014dc..f83f151724 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -36,7 +36,6 @@ #include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_machine.h" #include "m_Do/m_Do_main.h" -#include "tracy/Tracy.hpp" #if PLATFORM_WII || PLATFORM_SHIELD #include @@ -47,17 +46,18 @@ #endif #if TARGET_PC -#include -#include "aurora/lib/window.hpp" -#include "d/actor/d_a_horse.h" #include "dusk/dusk.h" -#include "helpers/endian.h" -#include "dusk/frame_interpolation.h" #include "dusk/gfx.hpp" -#include "helpers/gx_helper.h" #include "dusk/imgui/ImGuiConsole.hpp" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" +#include "helpers/endian.h" +#include "helpers/gx_helper.h" + +#include +#include +#include #endif class mDoGph_HIO_c : public JORReflexible { @@ -474,38 +474,35 @@ void darwFilter(GXColor matColor) { } void mDoGph_gInf_c::calcFade() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mFade != 0) { - mFadeRate += mFadeSpeed; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mFade != 0) { + mFadeRate += mFadeSpeed; - if (mFadeRate < 0.0f) { - mFadeRate = 0.0f; - mFade = 0; - } else { - if (mFadeRate > 1.0f) { - mFadeRate = 1.0f; - } - } - mFadeColor.a = 255.0f * mFadeRate; + if (mFadeRate < 0.0f) { + mFadeRate = 0.0f; + mFade = 0; } else { - if (dComIfG_getBrightness() != 255) { - mFadeColor.r = 0; - mFadeColor.g = 0; - mFadeColor.b = 0; - mFadeColor.a = 255 - dComIfG_getBrightness(); - } else { - mFadeColor.a = 0; + if (mFadeRate > 1.0f) { + mFadeRate = 1.0f; } } + mFadeColor.a = 255.0f * mFadeRate; + } else { + if (dComIfG_getBrightness() != 255) { + mFadeColor.r = 0; + mFadeColor.g = 0; + mFadeColor.b = 0; + mFadeColor.a = 255 - dComIfG_getBrightness(); + } else { + mFadeColor.a = 0; + } } + IF_DUSK_BLOCK_END if (mFadeColor.a != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::is_enabled() && mFade != 0) { - const auto step = dusk::frame_interp::get_interpolation_step(); +#if TARGET_PC + if (dusk::interp::is_enabled() && mFade != 0) { + const auto step = dusk::interp::get_interpolation_step(); const auto progress = mFadeSpeed < 0.0f ? 1.0f - mFadeRate : mFadeRate; const auto fade_amt = mFadeRate + mFadeSpeed * (step - 1.0f + progress); mFadeColor.a = 255.0f * std::clamp(fade_amt, 0.0f, 1.0f); @@ -2170,7 +2167,7 @@ static void captureScreenPerspDrawInfo(JPADrawInfo& info) { static void drawItem3D() { ZoneScoped; #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { // FRAME INTERP NOTE: Title screen needs 0.0f while everything else that runs through this is -100.0f. if (fopAcM_SearchByName(fpcNm_TITLE_e) != nullptr) { dMenu_Collect3D_c::setViewPortOffsetY(0.0f); @@ -2213,12 +2210,7 @@ int mDoGph_Painter() { drawHeapMap(); #endif -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - dComIfGp_particle_calcMenu(); - } + IF_NOT_DUSK(dComIfGp_particle_calcMenu()); JFWDisplay::getManager()->setFader(mDoGph_gInf_c::getFader()); mDoGph_gInf_c::setClearColor(mDoGph_gInf_c::getBackColor()); @@ -2348,7 +2340,7 @@ int mDoGph_Painter() { #endif dKy_setLight(); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { dKy_setLight_again(); } #endif @@ -2411,12 +2403,8 @@ int mDoGph_Painter() { } #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { - // FRAME INTERP NOTE: Currently only recalculating points for Epona's reins. Need a more global solution. - if (daHorse_c* horse = dComIfGp_getHorseActor()) { - horse->lerpControlPoints(dusk::frame_interp::get_interpolation_step()); - } - g_dComIfG_gameInfo.drawlist.refresh3DlineMats(camera_p->view.lookat.eye); + if (dusk::interp::is_enabled()) { + g_dComIfG_gameInfo.drawlist.refresh3DlineMats(); } #endif @@ -2774,12 +2762,9 @@ int mDoGph_Painter() { #endif GXSetClipMode(GX_CLIP_ENABLE); -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - dDlst_list_c::calcWipe(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + dDlst_list_c::calcWipe(); + IF_DUSK_BLOCK_END j3dSys.reinitGX(); ortho.setOrtho(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index af0a489770..b44f5e41b8 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -5,114 +5,101 @@ */ #include "m_Do/m_Do_main.h" -#include -#include #include "DynamicLink.h" #include "JSystem/JAudio2/JASAudioThread.h" -#include "JSystem/JAudio2/JAUSectionHeap.h" #include "JSystem/JAudio2/JAUSoundTable.h" #include "JSystem/JFramework/JFWSystem.h" -#include "JSystem/JHostIO/JORServer.h" #include "JSystem/JKernel/JKRAram.h" #include "JSystem/JKernel/JKRSolidHeap.h" #include "JSystem/JUtility/JUTConsole.h" +#include "JSystem/JUtility/JUTReport.h" #include "JSystem/JUtility/JUTException.h" #include "JSystem/JUtility/JUTProcBar.h" -#include "JSystem/JUtility/JUTReport.h" -#include "SSystem/SComponent/c_counter.h" -#include "SSystem/SComponent/c_API_graphic.h" +#include "JSystem/JHostIO/JORServer.h" #include "Z2AudioLib/Z2WolfHowlMgr.h" #include "c/c_dylink.h" #include "d/d_com_inf_game.h" -#include "d/d_debug_pad.h" #include "d/d_s_logo.h" #include "d/d_s_menu.h" #include "d/d_s_play.h" -#include "dusk/time.h" +#include "d/d_debug_pad.h" #include "f_ap/f_ap_game.h" #include "f_op/f_op_msg.h" #include "m_Do/m_Do_MemCard.h" #include "m_Do/m_Do_Reset.h" #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_dvd_thread.h" -#include "m_Do/m_Do_ext2.h" #include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_machine.h" #include "m_Do/m_Do_printf.h" #include "m_Do/m_Do_ext2.h" -#include "SSystem/SComponent/c_counter.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "SSystem/SComponent/c_API.h" #include "dusk/app_info.hpp" -#include "dusk/data.hpp" -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" -#include "dusk/game_clock.h" -#include "dusk/gyro.h" +#include "dusk/audio/DuskAudioSystem.h" +#include "dusk/audio/DuskDsp.hpp" #include "dusk/commands.hpp" +#include "dusk/config.hpp" +#include "dusk/data.hpp" +#include "dusk/discord_presence.hpp" +#include "dusk/dusk.h" +#include "dusk/game_clock.h" #include "dusk/game_combos.h" +#include "dusk/gyro.h" +#include "dusk/hq_minimap.hpp" #include "dusk/imgui/ImGuiConsole.hpp" #include "dusk/imgui/ImGuiEngine.hpp" +#include "dusk/interp/frame_interpolation.h" #include "dusk/iso_validate.hpp" #include "dusk/logging.h" #include "dusk/main.h" -#include "dusk/hq_minimap.hpp" #include "dusk/mod_loader.hpp" #include "dusk/mods/svc/window.hpp" #include "dusk/mouse.h" #include "dusk/os.h" #include "dusk/presentation.hpp" +#include "dusk/settings.h" +#include "dusk/speedrun.h" +#include "dusk/texture_replacements.hpp" +#include "dusk/time.h" #include "dusk/ui/command_console.hpp" #include "dusk/ui/menu_bar.hpp" #include "dusk/ui/overlay.hpp" #include "dusk/ui/prelaunch.hpp" #include "dusk/ui/preset.hpp" -#include "dusk/ui/touch_controls.hpp" -#include "dusk/ui/ui.hpp" - -#include -#include -#include -#include -#include - -#include "SDL3/SDL_init.h" -#include "SDL3/SDL_iostream.h" -#include "SDL3/SDL_misc.h" -#include "cxxopts.hpp" -#include "d/actor/d_a_movie_player.h" -#include "dusk/audio/DuskAudioSystem.h" -#include "dusk/audio/DuskDsp.hpp" -#include "dusk/config.hpp" -#include "dusk/speedrun.h" -#include "dusk/settings.h" -#include "dusk/texture_replacements.hpp" -#include "dusk/io.hpp" -#include "dusk/version.hpp" -#include "dusk/discord_presence.hpp" -#include "tracy/Tracy.hpp" -#include "f_pc/f_pc_draw.h" -#include "tracy/Tracy.hpp" -#include -#ifdef __APPLE__ -#include -#endif - #if BOREALIS_HAS_SENTRY #include "dusk/ui/reporting.hpp" #endif +#include "dusk/ui/touch_controls.hpp" +#include "dusk/ui/ui.hpp" +#include "dusk/version.hpp" + +#include "d/actor/d_a_movie_player.h" + +#include "SSystem/SComponent/c_API_graphic.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef __APPLE__ +#include +#endif // --- GLOBALS --- DUSK_GAME_DATA s8 mDoMain::developmentMode = -1; @@ -295,14 +282,13 @@ void main01(void) { dusk::ui::update(); const auto timing = dusk::game_clock::advance(); - const auto interpolationMode = dusk::getSettings().game.enableFrameInterpolation.getValue(); if (timing.separatePresentation) { if (timing.numSimTicks > 0) { - dusk::frame_interp::begin_frame(interpolationMode, true, 0.0f); - dusk::frame_interp::set_ui_tick_pending(true); + dusk::interp::begin_frame(0.0f); + dusk::interp::set_ui_tick_pending(true); for (int i = 0; i < timing.numSimTicks; ++i) { if (timing.interpolating) { - dusk::frame_interp::begin_sim_tick(); + dusk::interp::begin_sim_tick(); } dusk::game_clock::begin_sim_tick(); mDoCPd_c::read(); @@ -316,23 +302,15 @@ void main01(void) { } } - const float interpolationStep = - timing.interpolating ? dusk::game_clock::sample_interpolation_step() : 1.0f; - dusk::frame_interp::begin_frame(interpolationMode, false, interpolationStep); - if (timing.interpolating) { - dusk::frame_interp::interpolate(); - dusk::frame_interp::begin_presentation_camera(); - } - + const float step = timing.interpolating ? dusk::game_clock::sample_interpolation_step() : 1.0f; + dusk::interp::begin_presentation(step); fpcM_DrawIterater((fpcM_DrawIteraterFunc)fpcM_Draw); cAPIGph_Painter(); - if (timing.interpolating) { - dusk::frame_interp::end_presentation_camera(); - } - dusk::frame_interp::set_ui_tick_pending(false); + dusk::interp::end_presentation(); + dusk::interp::set_ui_tick_pending(false); } else { - dusk::frame_interp::begin_frame(dusk::FrameInterpMode::Off, true, 0.0f); - dusk::frame_interp::set_ui_tick_pending(true); + dusk::interp::begin_frame(0.0f); + dusk::interp::set_ui_tick_pending(true); dusk::game_clock::begin_sim_tick(); // Game Inputs @@ -757,6 +735,7 @@ int game_main(int argc, char* argv[]) { // Run ImGui UI loop if Aurora couldn't initialize a backend if (auroraInfo.backend == BACKEND_NULL) { launchUILoop(); + borealis::shutdown(); borealis::sentry::shutdown(); borealis::log::shutdown(); fflush(stdout); @@ -769,10 +748,6 @@ int game_main(int argc, char* argv[]) { return 0; } - if (borealis::http::available() && !borealis::http::initialize()) { - DuskLog.warn("Failed to initialize the HTTP worker pool"); - } - if (dusk::getSettings().game.enableHighQualityMinimapTextures.getValue()) { dusk::hq_minimap::set_active(true); } @@ -889,7 +864,7 @@ int game_main(int argc, char* argv[]) { // pre game launch ui main loop if (!launchUILoop()) { - borealis::http::shutdown(); + borealis::shutdown(); borealis::sentry::shutdown(); borealis::log::shutdown(); fflush(stdout); @@ -980,7 +955,7 @@ int game_main(int argc, char* argv[]) { OSReport("Starting main01 (Game Loop)...\n"); main01(); - borealis::http::shutdown(); + borealis::shutdown(); // We need to cleanly shut down the threads to avoid crashes on shutdown. if (daMP_c::m_myObj) {