diff --git a/cmake/AndroidExports.cmake b/cmake/AndroidExports.cmake index 23e14898e0..66e80d3f4a 100644 --- a/cmake/AndroidExports.cmake +++ b/cmake/AndroidExports.cmake @@ -33,8 +33,6 @@ function(setup_android_exports target) set(_vscript "${CMAKE_BINARY_DIR}/dusklight_exports.ver") add_custom_command(TARGET ${target} PRE_LINK - # TODO: src/dusk/ is NOT excluded: inline code in game headers - # currently call into it (e.g. dusk::frame_interp::lookup_replacement). COMMAND "${SYMGEN_EXE}" exports "@${_rsp}" --out "${_vscript}" @@ -42,6 +40,7 @@ function(setup_android_exports target) --exclude cmake_pch --exclude miniz --exclude asan_options + --exclude src/dusk # Resolved from the Java side; the SDL ones live in the statically-linked # SDL archive, outside the provenance scan. --extra-sym JNI_OnLoad diff --git a/cmake/AppleExports.cmake b/cmake/AppleExports.cmake index 0b43fdb6ee..2c78939811 100644 --- a/cmake/AppleExports.cmake +++ b/cmake/AppleExports.cmake @@ -41,14 +41,13 @@ function(setup_apple_exports target) set(_exp "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_exports.exp") add_custom_command(TARGET ${target} PRE_LINK - # TODO: src/dusk/ is NOT excluded: inline code in game headers - # currently call into it (e.g. dusk::frame_interp::lookup_replacement). COMMAND "${_symgen}" exports "@${_rsp}" --out "${_exp}" --exclude cmake_pch --exclude miniz --exclude asan_options + --exclude src/dusk ${_sdk_args} COMMENT "Generating dusklight exports" VERBATIM) diff --git a/cmake/GameABIConfig.cmake b/cmake/GameABIConfig.cmake index d48be445a2..8b95dcaf67 100644 --- a/cmake/GameABIConfig.cmake +++ b/cmake/GameABIConfig.cmake @@ -9,24 +9,47 @@ if (ANDROID) list(APPEND _game_compile_defs TARGET_ANDROID=1) endif () -set(_game_include_dirs +# Public game headers +set(_game_abi_include_dirs ${_game_root}/include - ${_game_root}/src - ${_game_root}/assets/GZ2E01 # TODO: make this dynamic if needed? + ${_game_root}/assets/GZ2E01 ${_game_root}/libs/JSystem/include - ${_game_root}/libs ${_game_root}/extern/aurora/include/dolphin ${_game_root}/extern/aurora/include + ${_game_root}/sdk/include +) + +# Internal game headers +set(_game_include_dirs + ${_game_abi_include_dirs} + ${_game_root}/src ${_game_root}/extern ${CMAKE_CURRENT_BINARY_DIR} ) -# Interface target for mods and sub-projects to inherit game headers/defines. +# Mod API, including services +add_library(dusklight_mod_api INTERFACE) +target_include_directories(dusklight_mod_api INTERFACE ${_game_root}/sdk/include) + +# Full internal headers used to build the game add_library(dusklight_game_headers INTERFACE) target_include_directories(dusklight_game_headers INTERFACE ${_game_include_dirs}) target_compile_definitions(dusklight_game_headers INTERFACE ${_game_compile_defs}) -if (TARGET dawn::dawncpp_headers) - target_link_libraries(dusklight_game_headers INTERFACE dawn::dawncpp_headers) -elseif (TARGET dawn::webgpu_dawn) - target_link_libraries(dusklight_game_headers INTERFACE dawn::webgpu_dawn) -endif () + +# Public game ABI for mods +add_library(dusklight_game_abi_headers INTERFACE) +target_include_directories(dusklight_game_abi_headers INTERFACE ${_game_abi_include_dirs}) +target_compile_definitions(dusklight_game_abi_headers INTERFACE ${_game_compile_defs}) + +# Mod feature targets +add_library(dusklight_mod_feature_game INTERFACE) +target_link_libraries(dusklight_mod_feature_game INTERFACE + dusklight_mod_api + dusklight_game_abi_headers) +target_compile_definitions(dusklight_mod_feature_game INTERFACE DUSK_MOD_FEATURE_GAME=1) +target_sources(dusklight_mod_feature_game INTERFACE + ${_game_root}/sdk/src/game_feature.cpp) + +add_library(dusklight_mod_feature_webgpu INTERFACE) +target_link_libraries(dusklight_mod_feature_webgpu INTERFACE dusklight_mod_api) +target_compile_definitions(dusklight_mod_feature_webgpu INTERFACE DUSK_MOD_FEATURE_WEBGPU=1) diff --git a/cmake/ModSDK.cmake b/cmake/ModSDK.cmake index 0e8d72a0a0..87125e12fd 100644 --- a/cmake/ModSDK.cmake +++ b/cmake/ModSDK.cmake @@ -1,4 +1,4 @@ -# add_mod( SOURCES ... MOD_JSON +# add_mod( [FEATURES ...] SOURCES ... MOD_JSON # [RUNTIME_LIBRARIES ...] [RES_DIR ] [OVERLAY_DIR ] # [TEXTURES_DIR ] [OUTPUT_DIR ] [BUNDLE]) set(DUSK_MODS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/mods" CACHE PATH "Directory to write mod packages into") @@ -47,9 +47,28 @@ function(_mod_collect_assets out_var dir) set(${out_var} ${_files} PARENT_SCOPE) endfunction() +function(_mod_add_webgpu_headers target_name) + if (NOT TARGET dawn::dawncpp_headers AND NOT TARGET dawn::webgpu_dawn) + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../extern/aurora/cmake/AuroraDependencyVersions.cmake") + set(AURORA_DAWN_PROVIDER "package" CACHE STRING "How to provide Dawn for the mod SDK") + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../extern/aurora/cmake/AuroraDawnProvider.cmake") + endif () + + if (TARGET dawn::dawncpp_headers) + target_link_libraries(${target_name} PRIVATE dawn::dawncpp_headers) + elseif (TARGET dawn::webgpu_dawn) + target_link_libraries(${target_name} PRIVATE dawn::webgpu_dawn) + else () + message(FATAL_ERROR "add_mod: FEATURES webgpu could not provide WebGPU headers") + endif () +endfunction() + function(add_mod target_name) cmake_parse_arguments(ARG "BUNDLE" "MOD_JSON;RES_DIR;OVERLAY_DIR;TEXTURES_DIR;OUTPUT_DIR" - "SOURCES;RUNTIME_LIBRARIES" ${ARGN}) + "SOURCES;RUNTIME_LIBRARIES;FEATURES" ${ARGN}) + if (ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "add_mod: unknown arguments: ${ARG_UNPARSED_ARGUMENTS}") + endif () if (NOT ARG_MOD_JSON) message(FATAL_ERROR "add_mod: MOD_JSON is required") endif () @@ -58,7 +77,27 @@ function(add_mod target_name) message(FATAL_ERROR "add_mod: MOD_JSON does not exist: ${_mod_json}") endif () + set(_supported_features game webgpu) + set(_features "") + foreach (_feature IN LISTS ARG_FEATURES) + list(FIND _supported_features "${_feature}" _feature_index) + if (_feature_index EQUAL -1) + list(JOIN _supported_features ", " _supported_features_text) + message(FATAL_ERROR + "add_mod: unknown feature '${_feature}' (supported: ${_supported_features_text})") + endif () + list(FIND _features "${_feature}" _duplicate_index) + if (NOT _duplicate_index EQUAL -1) + message(FATAL_ERROR "add_mod: duplicate feature '${_feature}'") + endif () + list(APPEND _features "${_feature}") + endforeach () + if (_features AND NOT ARG_SOURCES) + message(FATAL_ERROR "add_mod: FEATURES requires SOURCES") + endif () + set(_has_lib FALSE) + set(_needs_host_link FALSE) set(_lib_platform "") set(_lib_name "") if (ARG_SOURCES) @@ -72,7 +111,16 @@ function(add_mod target_name) VISIBILITY_INLINES_HIDDEN ON WINDOWS_EXPORT_ALL_SYMBOLS OFF) target_compile_features(${target_name} PRIVATE cxx_std_20) - target_link_libraries(${target_name} PRIVATE dusklight_game_headers) + target_link_libraries(${target_name} PRIVATE dusklight_mod_api) + foreach (_feature IN LISTS _features) + target_link_libraries(${target_name} PRIVATE dusklight_mod_feature_${_feature}) + if (_feature STREQUAL "webgpu") + _mod_add_webgpu_headers(${target_name}) + endif () + if (_feature STREQUAL "game" OR _feature STREQUAL "webgpu") + set(_needs_host_link TRUE) + endif () + endforeach () if (NOT TARGET dusklight) # Apply global compile options for out-of-tree mod builds @@ -95,34 +143,42 @@ function(add_mod target_name) endif () if (APPLE) - if (TARGET dusklight) - set(_game_exe "$") - add_dependencies(${target_name} dusklight) - elseif (DUSK_GAME_EXE) - _mod_resolve_source_path(_game_exe "${DUSK_GAME_EXE}") - else () - message(FATAL_ERROR "add_mod: DUSK_GAME_EXE is not set (game executable)") + if (_needs_host_link) + if (TARGET dusklight) + set(_game_exe "$") + add_dependencies(${target_name} dusklight) + elseif (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_exe "${DUSK_GAME_EXE}") + else () + message(FATAL_ERROR + "add_mod: FEATURES ${_features} requires DUSK_GAME_EXE (game executable)") + endif () + target_link_options(${target_name} PRIVATE + -Xlinker -bundle_loader -Xlinker "${_game_exe}") + set_property(TARGET ${target_name} APPEND PROPERTY LINK_DEPENDS "${_game_exe}") endif () - target_link_options(${target_name} PRIVATE - -Xlinker -bundle_loader -Xlinker "${_game_exe}") - set_property(TARGET ${target_name} APPEND PROPERTY LINK_DEPENDS "${_game_exe}") set_target_properties(${target_name} PROPERTIES BUILD_RPATH "@loader_path" INSTALL_RPATH "@loader_path") elseif (ANDROID) - if (TARGET dusklight) - target_link_libraries(${target_name} PRIVATE dusklight) - elseif (DUSK_GAME_EXE) - _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") - target_link_libraries(${target_name} PRIVATE "${_game_lib}") - else () - message(FATAL_ERROR "add_mod: DUSK_GAME_EXE is not set (libmain.so or stub)") + if (_needs_host_link) + if (TARGET dusklight) + target_link_libraries(${target_name} PRIVATE dusklight) + elseif (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") + target_link_libraries(${target_name} PRIVATE "${_game_lib}") + else () + message(FATAL_ERROR + "add_mod: FEATURES ${_features} requires DUSK_GAME_EXE (libmain.so or stub)") + endif () endif () set_target_properties(${target_name} PROPERTIES BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN") elseif (UNIX) - target_link_options(${target_name} PRIVATE -Wl,--allow-shlib-undefined) + if (_needs_host_link) + target_link_options(${target_name} PRIVATE -Wl,--allow-shlib-undefined) + endif () set_target_properties(${target_name} PROPERTIES BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN") @@ -131,22 +187,26 @@ function(add_mod target_name) # setup_windows_exports); cl and clang-cl both consume it in MSVC mode. Function # calls resolve through import thunks; game data is reachable only through # __declspec(dllimport), i.e. DUSK_GAME_DATA-annotated declarations. - if (TARGET dusklight) - if (NOT DUSK_GAME_IMPLIB) - message(FATAL_ERROR "add_mod: DUSK_GAME_IMPLIB is not set (see setup_windows_exports)") - endif () - set(_game_lib "${DUSK_GAME_IMPLIB}") - elseif (DUSK_GAME_EXE) - _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") - if (NOT _game_lib MATCHES "\\.lib$") + if (_needs_host_link) + if (TARGET dusklight) + if (NOT DUSK_GAME_IMPLIB) + message(FATAL_ERROR + "add_mod: DUSK_GAME_IMPLIB is not set (see setup_windows_exports)") + endif () + set(_game_lib "${DUSK_GAME_IMPLIB}") + elseif (DUSK_GAME_EXE) + _mod_resolve_source_path(_game_lib "${DUSK_GAME_EXE}") + if (NOT _game_lib MATCHES "\\.lib$") + message(FATAL_ERROR + "add_mod: DUSK_GAME_EXE must be an import library on Windows " + "(sdk/windows-.lib)") + endif () + else () message(FATAL_ERROR - "add_mod: DUSK_GAME_EXE must be an import library on Windows " - "(sdk/windows-.lib)") + "add_mod: FEATURES ${_features} requires DUSK_GAME_EXE (import library)") endif () - else () - message(FATAL_ERROR "add_mod: DUSK_GAME_EXE is not set (import library)") + target_link_libraries(${target_name} PRIVATE "${_game_lib}") endif () - target_link_libraries(${target_name} PRIVATE "${_game_lib}") set_target_properties(${target_name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") target_compile_definitions(${target_name} PRIVATE _ITERATOR_DEBUG_LEVEL=0) endif () diff --git a/cmake/WindowsExports.cmake b/cmake/WindowsExports.cmake index a82f7756af..4596ac7b69 100644 --- a/cmake/WindowsExports.cmake +++ b/cmake/WindowsExports.cmake @@ -57,14 +57,13 @@ function(setup_windows_exports target) # Generate curated exports list from the main binary set(_def "${CMAKE_BINARY_DIR}/${_config_subdir}dusklight_exports.def") add_custom_command(TARGET ${target} PRE_LINK - # TODO: src/dusk/ is NOT excluded: inline code in game headers - # currently call into it (e.g. dusk::frame_interp::lookup_replacement). COMMAND "${_symgen}" def "@${_rsp}" --out "${_def}" --exclude cmake_pch --exclude miniz --exclude asan_options + --exclude src/dusk --max-exports 58000 ${_sdk_args} ${_forward_args} diff --git a/docs/modding.md b/docs/modding.md index 4988f6a6e4..8afe8701e5 100644 --- a/docs/modding.md +++ b/docs/modding.md @@ -50,6 +50,7 @@ set(DUSKLIGHT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dusklight" CACHE PATH "Path to du add_subdirectory("${DUSKLIGHT_DIR}/sdk" dusklight-sdk EXCLUDE_FROM_ALL) add_mod(my_mod + FEATURES game # optional SOURCES src/mod.cpp MOD_JSON mod.json RES_DIR res # optional @@ -58,6 +59,12 @@ add_mod(my_mod ) ``` +Available features: +- `game`: Allows calling into and hooking game code. Mods that **only** use services may omit it, providing a wider + range of compatibility with Dusklight versions and a slightly faster build process. +- `webgpu`: Allows importing the WebGPU API (`webgpu/webgpu.h`). Must be enabled when using + [GfxService](#gfxservice-modssvcgfxh). + Building produces `my_mod.dusk` in `build//mods/` (configurable via the `DUSK_MODS_OUTPUT_DIR` cache variable). Dusklight searches a `mods/` directory next to the app in addition to the user directory, so a dev build launched from `build//` picks these up automatically: rebuild, relaunch (or click Reload), done. @@ -146,7 +153,7 @@ the service safe to call. A mod can use `IMPORT_SERVICE_VERSION` (or its optiona 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 `include/mods/api.h` for the full 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. @@ -415,6 +422,8 @@ unless changing host UI is intentional. ### GfxService (`mods/svc/gfx.h`) +**Requires `add_mod(... FEATURES webgpu)`** + Direct WebGPU access at various stages of the rendering pipeline. Mods use the `wgpu*` C API (via `webgpu/webgpu.h`) for custom draws and compute dispatches. Mods must manage their own WebGPU state, including pipelines and bind groups. @@ -465,6 +474,8 @@ first in-game frame. Projection matrices match the renderer's WebGPU clip conven ## Hooking Game Functions +**Requires `add_mod(... FEATURES game)`** + Mods may hook the vast majority of game functions, including file-local static, private and virtual functions. `mods/hook.hpp` provides typed helpers over the hook service: @@ -581,24 +592,6 @@ dusk::mods::hook_add_pre(svc_hook, on_create_item_pre); For reference parameters (e.g. `const cXyz& pos`), `arg_ref` yields a direct reference. -### Game code ABI contract - -A primary consideration when letting mods link against the game is maintaining ABI stability across Dusklight -versions. If your mod calls or hooks game code directly (anything beyond the service APIs), import `GameService` -(`mods/svc/game.h`): - -```cpp -IMPORT_SERVICE(GameService, svc_game); -``` - -Its major version is the game code ABI epoch: it's bumped when game struct or vtable layouts change incompatibly, and -the ordinary service version check then rejects your mod with a clear error instead of letting it corrupt memory in a -version it wasn't built for. Service-only and asset-only mods should *not* import it and will continue to work across -game ABI changes. - -The more you can do through services, the better: a mod that avoids touching game code directly sidesteps future ABI -breaks entirely and plays nicer with other enabled mods. - --- ## Asset Overlays diff --git a/files.cmake b/files.cmake index c1546f1db0..c8c92c9b75 100644 --- a/files.cmake +++ b/files.cmake @@ -1411,68 +1411,101 @@ set(DOLPHIN_FILES ) set(DUSK_FILES - include/dusk/action_bindings.h - include/dusk/endian_gx.hpp - include/dusk/config.hpp - include/dusk/dvd_asset.hpp - include/dusk/scope_guard.hpp - src/dusk/dvd_asset.cpp + include/helpers/batch.hpp + include/helpers/endian_gx.hpp src/d/actor/d_a_alink_dusk.cpp - src/dusk/android_frame_rate.hpp + src/dusk/OSContext.cpp + src/dusk/OSMutex.cpp + src/dusk/OSReport.cpp + src/dusk/OSThread.cpp + src/dusk/achievements.cpp + src/dusk/action_bindings.cpp + src/dusk/action_bindings.h src/dusk/android_frame_rate.cpp + src/dusk/android_frame_rate.hpp src/dusk/asserts.cpp - src/dusk/batch.cpp - src/dusk/batch.hpp + src/dusk/autosave.cpp src/dusk/config.cpp + src/dusk/config.hpp src/dusk/crash_handler.cpp src/dusk/crash_reporting.cpp src/dusk/data.cpp src/dusk/data.hpp - src/dusk/endian.cpp + src/dusk/discord.cpp + src/dusk/discord.hpp + src/dusk/discord_presence.cpp + src/dusk/dvd_asset.cpp + src/dusk/dvd_asset.hpp src/dusk/extras.c src/dusk/file_select.cpp src/dusk/file_select.hpp src/dusk/frame_interpolation.cpp src/dusk/game_clock.cpp + src/dusk/gamepad_color.cpp src/dusk/globals.cpp src/dusk/gyro.cpp - include/dusk/menu_pointer.h - src/dusk/menu_pointer.cpp - src/dusk/mouse.cpp - src/dusk/gamepad_color.cpp - src/dusk/autosave.cpp src/dusk/http/http.hpp - src/dusk/io.cpp - src/dusk/layout.cpp - src/dusk/logging.cpp - src/dusk/settings.cpp - src/dusk/speedrun.cpp - src/dusk/string.cpp - src/dusk/stubs.cpp - include/dusk/texture_replacements.hpp - src/dusk/texture_replacements.cpp - src/dusk/touch_camera.cpp - src/dusk/update_check.cpp - src/dusk/update_check.hpp - #src/dusk/m_Do_ext_dusk.cpp - src/dusk/imgui/ImGuiConfig.hpp - src/dusk/imgui/ImGuiConsole.hpp - src/dusk/imgui/ImGuiConsole.cpp - src/dusk/imgui/ImGuiEngine.cpp - src/dusk/imgui/ImGuiEngine.hpp + src/dusk/imgui/ImGuiActorSpawner.cpp src/dusk/imgui/ImGuiBloomWindow.cpp src/dusk/imgui/ImGuiBloomWindow.hpp + src/dusk/imgui/ImGuiCameraOverlay.cpp + src/dusk/imgui/ImGuiConfig.hpp + src/dusk/imgui/ImGuiConsole.cpp + src/dusk/imgui/ImGuiConsole.hpp + src/dusk/imgui/ImGuiControllerOverlay.cpp + src/dusk/imgui/ImGuiEngine.cpp + src/dusk/imgui/ImGuiEngine.hpp + src/dusk/imgui/ImGuiHeapOverlay.cpp src/dusk/imgui/ImGuiMenuTools.cpp src/dusk/imgui/ImGuiMenuTools.hpp - src/dusk/imgui/ImGuiActorSpawner.cpp src/dusk/imgui/ImGuiProcessOverlay.cpp - src/dusk/imgui/ImGuiCameraOverlay.cpp - src/dusk/imgui/ImGuiHeapOverlay.cpp - src/dusk/imgui/ImGuiControllerOverlay.cpp - src/dusk/imgui/ImGuiStubLog.cpp src/dusk/imgui/ImGuiSaveEditor.cpp - src/dusk/imgui/ImGuiStateShare.hpp src/dusk/imgui/ImGuiStateShare.cpp + src/dusk/imgui/ImGuiStateShare.hpp + src/dusk/imgui/ImGuiStubLog.cpp + src/dusk/io.cpp + src/dusk/iso_validate.cpp + src/dusk/layout.cpp + src/dusk/livesplit.cpp + src/dusk/logging.cpp + src/dusk/menu_pointer.cpp + src/dusk/menu_pointer.h + src/dusk/mods/loader/bundle_disk.cpp + src/dusk/mods/loader/bundle_zip.cpp + src/dusk/mods/loader/context.cpp + src/dusk/mods/loader/depgraph.cpp + src/dusk/mods/loader/depgraph.hpp + src/dusk/mods/loader/loader.cpp + src/dusk/mods/loader/loader.hpp + src/dusk/mods/loader/native_module.cpp + src/dusk/mods/loader/native_module.hpp + src/dusk/mods/log_buffer.cpp + src/dusk/mods/log_buffer.hpp + src/dusk/mods/manifest.cpp + src/dusk/mods/manifest.hpp + src/dusk/mods/svc/camera.cpp + src/dusk/mods/svc/config.cpp + src/dusk/mods/svc/config.hpp + src/dusk/mods/svc/game.cpp + src/dusk/mods/svc/gfx.cpp + src/dusk/mods/svc/hook.cpp + src/dusk/mods/svc/host.cpp + src/dusk/mods/svc/log.cpp + src/dusk/mods/svc/overlay.cpp + src/dusk/mods/svc/registry.cpp + src/dusk/mods/svc/registry.hpp + src/dusk/mods/svc/resource.cpp + src/dusk/mods/svc/texture.cpp + src/dusk/mods/svc/ui.cpp + src/dusk/mods/svc/ui.hpp + src/dusk/mouse.cpp + src/dusk/scope_guard.hpp + src/dusk/settings.cpp + src/dusk/speedrun.cpp + src/dusk/stubs.cpp + src/dusk/texture_replacements.cpp + src/dusk/texture_replacements.hpp + src/dusk/touch_camera.cpp src/dusk/ui/achievements.cpp src/dusk/ui/achievements.hpp src/dusk/ui/bool_button.cpp @@ -1481,9 +1514,9 @@ set(DUSK_FILES src/dusk/ui/button.hpp src/dusk/ui/component.cpp src/dusk/ui/component.hpp - src/dusk/ui/controls.hpp src/dusk/ui/controller_config.cpp src/dusk/ui/controller_config.hpp + src/dusk/ui/controls.hpp src/dusk/ui/document.cpp src/dusk/ui/document.hpp src/dusk/ui/editor.cpp @@ -1492,18 +1525,22 @@ set(DUSK_FILES src/dusk/ui/event.hpp src/dusk/ui/graphics_tuner.cpp src/dusk/ui/graphics_tuner.hpp - src/dusk/ui/input.cpp - src/dusk/ui/input.hpp src/dusk/ui/icon_provider.cpp src/dusk/ui/icon_provider.hpp + src/dusk/ui/input.cpp + src/dusk/ui/input.hpp src/dusk/ui/logs_window.cpp src/dusk/ui/logs_window.hpp + src/dusk/ui/menu_bar.cpp + src/dusk/ui/menu_bar.hpp src/dusk/ui/mod_texture_provider.cpp src/dusk/ui/mod_texture_provider.hpp src/dusk/ui/mod_window.cpp src/dusk/ui/mod_window.hpp src/dusk/ui/modal.cpp src/dusk/ui/modal.hpp + src/dusk/ui/mods_window.cpp + src/dusk/ui/mods_window.hpp src/dusk/ui/nav_types.hpp src/dusk/ui/number_button.cpp src/dusk/ui/number_button.hpp @@ -1511,10 +1548,6 @@ set(DUSK_FILES src/dusk/ui/overlay.hpp src/dusk/ui/pane.cpp src/dusk/ui/pane.hpp - src/dusk/ui/menu_bar.cpp - src/dusk/ui/menu_bar.hpp - src/dusk/ui/mods_window.cpp - src/dusk/ui/mods_window.hpp src/dusk/ui/prelaunch.cpp src/dusk/ui/prelaunch.hpp src/dusk/ui/preset.cpp @@ -1529,10 +1562,10 @@ set(DUSK_FILES src/dusk/ui/string_button.hpp src/dusk/ui/tab_bar.cpp src/dusk/ui/tab_bar.hpp - src/dusk/ui/touch_controls_common.cpp - src/dusk/ui/touch_controls_common.hpp src/dusk/ui/touch_controls.cpp src/dusk/ui/touch_controls.hpp + src/dusk/ui/touch_controls_common.cpp + src/dusk/ui/touch_controls_common.hpp src/dusk/ui/touch_controls_editor.cpp src/dusk/ui/touch_controls_editor.hpp src/dusk/ui/ui.cpp @@ -1541,47 +1574,13 @@ set(DUSK_FILES src/dusk/ui/warp.hpp src/dusk/ui/window.cpp src/dusk/ui/window.hpp - src/dusk/achievements.cpp - src/dusk/iso_validate.cpp - src/dusk/livesplit.cpp - src/dusk/offset_ptr.cpp - src/dusk/OSContext.cpp - src/dusk/OSReport.cpp - src/dusk/OSThread.cpp - src/dusk/OSMutex.cpp - src/dusk/mods/log_buffer.cpp - src/dusk/mods/log_buffer.hpp - src/dusk/mods/manifest.cpp - src/dusk/mods/manifest.hpp - src/dusk/mods/loader/bundle_disk.cpp - src/dusk/mods/loader/bundle_zip.cpp - src/dusk/mods/loader/context.cpp - src/dusk/mods/loader/depgraph.cpp - src/dusk/mods/loader/depgraph.hpp - src/dusk/mods/loader/loader.cpp - src/dusk/mods/loader/loader.hpp - src/dusk/mods/loader/native_module.cpp - src/dusk/mods/loader/native_module.hpp - src/dusk/mods/svc/camera.cpp - src/dusk/mods/svc/config.cpp - src/dusk/mods/svc/config.hpp - src/dusk/mods/svc/game.cpp - src/dusk/mods/svc/gfx.cpp - src/dusk/mods/svc/hook.cpp - src/dusk/mods/svc/host.cpp - src/dusk/mods/svc/log.cpp - src/dusk/mods/svc/overlay.cpp - src/dusk/mods/svc/resource.cpp - src/dusk/mods/svc/texture.cpp - src/dusk/mods/svc/ui.cpp - src/dusk/mods/svc/ui.hpp - src/dusk/mods/svc/registry.cpp - src/dusk/mods/svc/registry.hpp - src/dusk/discord.cpp - src/dusk/discord.hpp - src/dusk/discord_presence.cpp + src/dusk/update_check.cpp + src/dusk/update_check.hpp src/dusk/version.cpp - src/dusk/action_bindings.cpp + src/helpers/batch.cpp + src/helpers/endian.cpp + src/helpers/offset_ptr.cpp + src/helpers/string.cpp ) set(DUSK_HTTP_BACKEND_FILES diff --git a/include/SSystem/SComponent/c_bg_s_chk.h b/include/SSystem/SComponent/c_bg_s_chk.h index adbc0c1807..6908ef80ed 100644 --- a/include/SSystem/SComponent/c_bg_s_chk.h +++ b/include/SSystem/SComponent/c_bg_s_chk.h @@ -5,7 +5,7 @@ #include "f_pc/f_pc_base.h" #include "SSystem/SComponent/c_bg_s_grp_pass_chk.h" #include "SSystem/SComponent/c_bg_s_poly_pass_chk.h" -#include "dusk/endian.h" +#include "helpers/endian.h" struct cBgD_Vtx_t : public Vec {}; diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index cac178e064..9947616d54 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -2,7 +2,7 @@ #define C_M3D_G_TRI_H_ #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class cM3dGCyl; diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index 9280c849d3..fbd8784d40 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -95,12 +95,6 @@ static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); #define THP_TEXTURE_SET_COUNT 3 #endif -#if TARGET_PC -namespace dusk { - void MoviePlayerShutdown(); -} -#endif - struct daMP_THPPlayer { /* 0x000 */ DVDFileInfo fileInfo; /* 0x03C */ THPHeader header; diff --git a/include/d/actor/d_flower.h b/include/d/actor/d_flower.h index cda0845867..db8661b92f 100644 --- a/include/d/actor/d_flower.h +++ b/include/d/actor/d_flower.h @@ -5,7 +5,7 @@ #include "SSystem/SComponent/c_xyz.h" #if TARGET_PC -#include "dusk/batch.hpp" +#include "helpers/batch.hpp" #endif class cCcD_Obj; @@ -112,11 +112,11 @@ public: TGXTexObj mTexObj_l_J_Ohana00_64TEX; TGXTexObj mTexObj_l_J_Ohana01_64128_0419TEX; - dusk::batch::LeafTemplate mTplHana00; // l_J_hana00DL - dusk::batch::LeafTemplate mTplHana00Cut; // l_J_hana00_cDL - dusk::batch::LeafTemplate mTplHana01; // l_J_hana01DL - dusk::batch::LeafTemplate mTplHana01Cut00; // l_J_hana01_c_00DL - dusk::batch::LeafTemplate mTplHana01Cut; // l_J_hana01_c_01DL + batch::LeafTemplate mTplHana00; // l_J_hana00DL + batch::LeafTemplate mTplHana00Cut; // l_J_hana00_cDL + batch::LeafTemplate mTplHana01; // l_J_hana01DL + batch::LeafTemplate mTplHana01Cut00; // l_J_hana01_c_00DL + batch::LeafTemplate mTplHana01Cut; // l_J_hana01_c_01DL #endif }; // Size: 0x12A54 diff --git a/include/d/actor/d_grass.h b/include/d/actor/d_grass.h index a7ed081198..4eee08c0e8 100644 --- a/include/d/actor/d_grass.h +++ b/include/d/actor/d_grass.h @@ -5,7 +5,7 @@ #include "SSystem/SComponent/c_xyz.h" #if TARGET_PC -#include "../../../src/dusk/batch.hpp" +#include #endif class cCcD_Obj; @@ -115,9 +115,9 @@ public: TGXTexObj mTexObj_l_M_Hijiki00TEX; TGXTexObj mTexObj_l_M_kusa05_RGBATEX; - dusk::batch::LeafTemplate mTplKusa9q; // l_M_Kusa_9qDL - dusk::batch::LeafTemplate mTplKusa9qCut; // l_M_Kusa_9q_cDL - dusk::batch::LeafTemplate mTplTengusa; // l_M_TenGusaDL + batch::LeafTemplate mTplKusa9q; // l_M_Kusa_9qDL + batch::LeafTemplate mTplKusa9qCut; // l_M_Kusa_9q_cDL + batch::LeafTemplate mTplTengusa; // l_M_TenGusaDL #endif }; // Size: 0x1D718 diff --git a/include/d/d_bg_w.h b/include/d/d_bg_w.h index 580e22d904..ae37d1c6d9 100644 --- a/include/d/d_bg_w.h +++ b/include/d/d_bg_w.h @@ -6,9 +6,9 @@ #include "d/d_bg_w_base.h" #include #include -#include "dusk/offset_ptr.h" -#include "dusk/endian.h" -#include "dusk/endian_ssystem.h" +#include "helpers/offset_ptr.h" +#include "helpers/endian.h" +#include "helpers/endian_ssystem.h" class cBgS_GrpPassChk; class cBgS_PolyPassChk; diff --git a/include/d/d_bg_w_kcol.h b/include/d/d_bg_w_kcol.h index 1fc812dd98..84b0da03f2 100644 --- a/include/d/d_bg_w_kcol.h +++ b/include/d/d_bg_w_kcol.h @@ -6,7 +6,7 @@ #include "d/d_bg_plc.h" #include "d/d_bg_s_sph_chk.h" #include "d/d_bg_w_base.h" -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" class cBgS_GrpPassChk; class cBgS_PolyPassChk; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 98b6dbe81d..a598cbcc10 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -17,7 +17,15 @@ #include "m_Do/m_Do_graphic.h" #include -#include "dusk/profiling.hpp" +#if defined(DUSK_BUILDING_GAME) +#include +#include "dusk/settings.h" +#else +#ifndef ZoneScoped +#define ZoneScoped +#define ZoneScopedN(name) +#endif +#endif enum dComIfG_ButtonStatus { /* 0x00 */ BUTTON_STATUS_NONE, @@ -4837,27 +4845,23 @@ inline void dComIfGd_drawXluListDark() { g_dComIfG_gameInfo.drawlist.drawXluListDark(); } +#if TARGET_PC +void dComIfGd_drawXluListInvisible(); +#else inline void dComIfGd_drawXluListInvisible() { ZoneScoped; -#ifdef TARGET_PC - if (!dusk::getSettings().game.disableWaterRefraction) { -#endif - g_dComIfG_gameInfo.drawlist.drawXluListInvisible(); -#ifdef TARGET_PC - } -#endif + g_dComIfG_gameInfo.drawlist.drawXluListInvisible(); } +#endif +#if TARGET_PC +void dComIfGd_drawOpaListInvisible(); +#else inline void dComIfGd_drawOpaListInvisible() { ZoneScoped; -#ifdef TARGET_PC - if (!dusk::getSettings().game.disableWaterRefraction) { -#endif - g_dComIfG_gameInfo.drawlist.drawOpaListInvisible(); -#ifdef TARGET_PC - } -#endif + g_dComIfG_gameInfo.drawlist.drawOpaListInvisible(); } +#endif inline void dComIfGd_drawXluListZxlu() { ZoneScoped; diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 907cf7b178..25d92aff54 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -5,7 +5,7 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "SSystem/SComponent/c_m3d_g_pla.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "f_op/f_op_view.h" #include "global.h" #include "m_Do/m_Do_ext.h" diff --git a/include/d/d_event_data.h b/include/d/d_event_data.h index ee9b868af4..eef55b1164 100644 --- a/include/d/d_event_data.h +++ b/include/d/d_event_data.h @@ -3,7 +3,7 @@ #include "global.h" #include "f_pc/f_pc_base.h" -#include "dusk/endian.h" +#include "helpers/endian.h" struct msg_class; diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index 307d48f291..5292eed5d3 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -4,8 +4,8 @@ #include "JSystem/JMessage/control.h" #include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" -#include "dusk/endian.h" -#include "dusk/string.hpp" +#include "helpers/endian.h" +#include "helpers/string.hpp" #if REGION_JPN #define D_MSG_CLASS_PAGE_CNT_MAX 30 diff --git a/include/d/d_msg_flow.h b/include/d/d_msg_flow.h index 51ce72033c..233dad7170 100644 --- a/include/d/d_msg_flow.h +++ b/include/d/d_msg_flow.h @@ -2,7 +2,7 @@ #define D_MSG_D_MSG_FLOW_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" enum { NODETYPE_MESSAGE_e = 1, diff --git a/include/d/d_save.h b/include/d/d_save.h index ec5a9ee9ef..06458890e4 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -8,7 +8,7 @@ #include "d/d_item_data.h" #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JHostIO/JORReflexible.h" -#include "dusk/endian.h" +#include "helpers/endian.h" static const int DEFAULT_SELECT_ITEM_INDEX = 0; static const int MAX_SELECT_ITEM = 4; @@ -494,7 +494,7 @@ public: #endif void setPlayerName(const char* i_name) { #if AVOID_UB - dusk::SafeStringCopyTruncate(mPlayerName, i_name); + SafeStringCopyTruncate(mPlayerName, i_name); #else strcpy(mPlayerName, i_name); #endif @@ -506,7 +506,7 @@ public: #endif void setHorseName(const char* i_name) { #if AVOID_UB - dusk::SafeStringCopyTruncate(mHorseName, i_name); + SafeStringCopyTruncate(mHorseName, i_name); #else strcpy(mHorseName, i_name); #endif diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 1fd884e4a6..53fbbac0d9 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -4,7 +4,7 @@ #include "SSystem/SComponent/c_lib.h" #include "d/d_kankyo.h" #include "d/d_kankyo_data.h" -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" #include "f_op/f_op_actor_mng.h" #include "global.h" #include "os_report.h" diff --git a/include/d/d_tresure.h b/include/d/d_tresure.h index 37ff4d84b9..e043dd94fb 100644 --- a/include/d/d_tresure.h +++ b/include/d/d_tresure.h @@ -2,7 +2,7 @@ #define D_D_TRESURE_H #include -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" class dTres_c { public: diff --git a/include/d/dolzel.h b/include/d/dolzel.h index d51eb22372..d4f53c842d 100644 --- a/include/d/dolzel.h +++ b/include/d/dolzel.h @@ -8,7 +8,7 @@ #endif #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif #endif // dolzel.h diff --git a/include/dusk/imgui.h b/include/dusk/imgui.h deleted file mode 100644 index 5c761fb026..0000000000 --- a/include/dusk/imgui.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _SRC_IMGUI_H_ -#define _SRC_IMGUI_H_ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - void imgui_main(const AuroraInfo* info); - void frame_limiter(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/dusk/profiling.hpp b/include/dusk/profiling.hpp deleted file mode 100644 index 82dab45216..0000000000 --- a/include/dusk/profiling.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#if defined(__has_include) -#if __has_include() -#include -#endif -#endif - -#ifndef ZoneScoped -#define ZoneScoped -#define ZoneScopedN(name) -#endif diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 5d51b74aa2..6461c823d1 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -12,7 +12,7 @@ #include "f_pc/f_pc_manager.h" #include "m_Do/m_Do_hostIO.h" #include "SSystem/SComponent/c_phase.h" -#include "dusk/endian_ssystem.h" +#include "helpers/endian_ssystem.h" #if !__MWERKS__ // mwerks compiler makes value initialization act like default initialization so we need diff --git a/include/helpers/README.md b/include/helpers/README.md new file mode 100644 index 0000000000..d14f1e1b36 --- /dev/null +++ b/include/helpers/README.md @@ -0,0 +1,12 @@ +# Public game helpers + +Headers in this directory provide port-specific types and utilities used by ordinary game +headers. Their corresponding implementations live in `src/helpers/`. + +These helpers **must not** depend on internal `src/dusk/` declarations in their public interface. +Unlike the internal `dusk::` namespace, they are exposed to mods that use the `game` feature +and therefore must remain ABI stable within `GameService` major versions. + +APIs _specifically_ for mod use do not belong here; instead they belong in mod services, +which are individually versioned, can provide backwards compatibility, and are designed to +keep track of per-mod runtime state. diff --git a/src/dusk/batch.hpp b/include/helpers/batch.hpp similarity index 90% rename from src/dusk/batch.hpp rename to include/helpers/batch.hpp index 2569f27761..0eaeb17a2c 100644 --- a/src/dusk/batch.hpp +++ b/include/helpers/batch.hpp @@ -2,7 +2,7 @@ #include -namespace dusk::batch { +namespace batch { struct LeafTemplate { static constexpr u32 kMaxVtx = 192; @@ -22,4 +22,4 @@ struct LeafTemplate { void decode_leaf_template(const u8* dl, u32 size, LeafTemplate& out); -} // namespace dusk +} // namespace batch diff --git a/include/dusk/endian.h b/include/helpers/endian.h similarity index 98% rename from include/dusk/endian.h rename to include/helpers/endian.h index d16d0aa80c..689f9f0dab 100644 --- a/include/dusk/endian.h +++ b/include/helpers/endian.h @@ -1,5 +1,4 @@ -#ifndef DOLPHIN_ENDIAN_H -#define DOLPHIN_ENDIAN_H +#pragma once #include @@ -292,6 +291,3 @@ inline void be_swap(Mtx& val) { #define BE(T) T #define BE_HOST(T) (T) #endif - - -#endif // DOLPHIN_ENDIAN_H diff --git a/include/dusk/endian_gx.hpp b/include/helpers/endian_gx.hpp similarity index 100% rename from include/dusk/endian_gx.hpp rename to include/helpers/endian_gx.hpp diff --git a/include/dusk/endian_ssystem.h b/include/helpers/endian_ssystem.h similarity index 93% rename from include/dusk/endian_ssystem.h rename to include/helpers/endian_ssystem.h index fe9248ffa4..b383ef6e43 100644 --- a/include/dusk/endian_ssystem.h +++ b/include/helpers/endian_ssystem.h @@ -1,5 +1,4 @@ -#ifndef _DUSK_ENDIAN_SSYSTEM_H_ -#define _DUSK_ENDIAN_SSYSTEM_H_ +#pragma once #include "SSystem/SComponent/c_sxyz.h" #include "endian.h" @@ -61,5 +60,3 @@ struct BE { }; } }; - -#endif \ No newline at end of file diff --git a/include/dusk/gx_helper.h b/include/helpers/gx_helper.h similarity index 94% rename from include/dusk/gx_helper.h rename to include/helpers/gx_helper.h index 02a36fc6db..32cf340ed5 100644 --- a/include/dusk/gx_helper.h +++ b/include/helpers/gx_helper.h @@ -1,12 +1,17 @@ -#ifndef DUSK_GX_HELPER_H -#define DUSK_GX_HELPER_H +#pragma once #include #include #include -#include "profiling.hpp" +#if defined(DUSK_BUILDING_GAME) +#include +#else +#ifndef ZoneScopedN +#define ZoneScopedN(name) +#endif +#endif #if DUSK_GFX_DEBUG_GROUPS #define GX_DEBUG_GROUP(name, ...) \ @@ -79,5 +84,3 @@ struct GXScopedDebugGroup { }; #define GX_AND_TRACY_SCOPED(name) GXScopedDebugGroup scope(name); ZoneScopedN(name); - -#endif // DUSK_GX_HELPER_H diff --git a/include/dusk/math.h b/include/helpers/math.h similarity index 84% rename from include/dusk/math.h rename to include/helpers/math.h index 04f1087670..c1e966951a 100644 --- a/include/dusk/math.h +++ b/include/helpers/math.h @@ -1,5 +1,4 @@ -#ifndef _SRC_DUSK_MATH_H_ -#define _SRC_DUSK_MATH_H_ +#pragma once #include @@ -17,5 +16,3 @@ inline float i_tanf(float x) { return tan(x); } inline float i_acosf(float x) { return acos(x); } #include - -#endif // _SRC_DUSK_MATH_H_ diff --git a/include/dusk/offset_ptr.h b/include/helpers/offset_ptr.h similarity index 89% rename from include/dusk/offset_ptr.h rename to include/helpers/offset_ptr.h index 3a940804c2..924b840659 100644 --- a/include/dusk/offset_ptr.h +++ b/include/helpers/offset_ptr.h @@ -1,5 +1,4 @@ -#ifndef DUSK_OFFSET_PTR_H -#define DUSK_OFFSET_PTR_H +#pragma once #if TARGET_PC @@ -47,21 +46,17 @@ struct OffsetPtrT { } operator T*() const { - return (T*) value; - } + return (T*)value; } - template + template explicit operator TOther*() const { - return (TOther*) value; + return (TOther*)value; } }; - #define OFFSET_PTR(T) OffsetPtrT #define OFFSET_PTR_RAW OffsetPtr #else #define OFFSET_PTR(T) T* #define OFFSET_PTR_RAW u32 #endif - -#endif // DUSK_OFFSET_PTR_H diff --git a/include/dusk/string.hpp b/include/helpers/string.hpp similarity index 89% rename from include/dusk/string.hpp rename to include/helpers/string.hpp index af91ff8fe9..b7ba0ef3b7 100644 --- a/include/dusk/string.hpp +++ b/include/helpers/string.hpp @@ -1,8 +1,7 @@ -#ifndef DUSK_STRING_HPP -#define DUSK_STRING_HPP -#include +#pragma once -namespace dusk { +#include +#include struct TextSpan { char* buffer; @@ -44,7 +43,7 @@ private: }; #if TARGET_PC -#define TEXT_SPAN dusk::TextSpan +#define TEXT_SPAN TextSpan #else #define TEXT_SPAN char* #endif @@ -111,11 +110,11 @@ int SafeStringPrintf(char (&buffer)[BufSize], const char* format, ...) { } #if TARGET_PC -#define SAFE_STRCPY dusk::SafeStringCopy -#define SAFE_STRCAT dusk::SafeStringCat -#define SAFE_SPRINTF dusk::SafeStringPrintf -#define SAFE_STRCPY_BOUNDED dusk::SafeStringCopy -#define SAFE_STRCAT_BOUNDED dusk::SafeStringCat +#define SAFE_STRCPY SafeStringCopy +#define SAFE_STRCAT SafeStringCat +#define SAFE_SPRINTF SafeStringPrintf +#define SAFE_STRCPY_BOUNDED SafeStringCopy +#define SAFE_STRCAT_BOUNDED SafeStringCat #else #define SAFE_STRCPY strcpy #define SAFE_STRCAT strcat @@ -123,6 +122,3 @@ int SafeStringPrintf(char (&buffer)[BufSize], const char* format, ...) { #define SAFE_STRCPY_BOUNDED strcpy #define SAFE_STRCPY_BOUNDED strcat #endif -} - -#endif // DUSK_STRING_HPP diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 0758298aef..43d0b81766 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -4,8 +4,12 @@ #include "Z2AudioLib/Z2AudioMgr.h" #include "Z2AudioLib/Z2EnvSeMgr.h" #include "Z2AudioLib/Z2LinkMgr.h" +#if defined(DUSK_BUILDING_GAME) #include "dusk/audio.h" #include "dusk/settings.h" +#else +#define DUSK_AUDIO_SKIP(...) +#endif class mDoAud_zelAudio_c : public Z2AudioMgr { public: @@ -134,15 +138,7 @@ inline void mDoAud_seStart(u32 i_sfxID, const Vec* i_sePos, u32 param_2, s8 i_re } #if TARGET_PC -inline void mDoAud_seStartMenu(u32 i_sfxID) { - if (!mDoAud_zelAudio_c::isInitFlag()) { - return; - } - if (!dusk::getSettings().audio.menuSounds.getValue()) { - return; - } - mDoAud_seStart(i_sfxID, nullptr, 0, 0); -} +void mDoAud_seStartMenu(u32 i_sfxID); #endif inline void mDoAud_seStartLevel(u32 i_sfxID, const Vec* i_sePos, u32 param_2, s8 i_reverb) { diff --git a/include/m_Do/m_Do_controller_pad.h b/include/m_Do/m_Do_controller_pad.h index 3ee09cc728..f63c1c8d1c 100644 --- a/include/m_Do/m_Do_controller_pad.h +++ b/include/m_Do/m_Do_controller_pad.h @@ -3,7 +3,10 @@ #include "JSystem/JUtility/JUTGamePad.h" #include "SSystem/SComponent/c_API_controller_pad.h" + +#if defined(DUSK_BUILDING_GAME) #include "dusk/settings.h" +#endif // Controller Ports 1 - 4 enum { PAD_1, PAD_2, PAD_3, PAD_4 }; @@ -54,29 +57,21 @@ public: static f32 getStickValue(u32 pad) { return getCpadInfo(pad).mMainStickValue; } static s16 getStickAngle(u32 pad) { return getCpadInfo(pad).mMainStickAngle; } +#if TARGET_PC + static s16 getStickAngle3D(u32 pad); +#else static s16 getStickAngle3D(u32 pad) { - #if TARGET_PC - if (dusk::getSettings().game.enableMirrorMode) { - return -getCpadInfo(pad).mMainStickAngle; - } else { - return getCpadInfo(pad).mMainStickAngle; - } - #else return getCpadInfo(pad).mMainStickAngle; - #endif } +#endif +#if TARGET_PC + static f32 getSubStickX3D(u32 pad); +#else static f32 getSubStickX3D(u32 pad) { - #if TARGET_PC - if (dusk::getSettings().game.enableMirrorMode) { - return -getCpadInfo(pad).mCStickPosX; - } else { - return getCpadInfo(pad).mCStickPosX; - } - #else return getCpadInfo(pad).mCStickPosX; - #endif } +#endif static f32 getSubStickX(u32 pad) { return getCpadInfo(pad).mCStickPosX; } static f32 getSubStickY(u32 pad) { return getCpadInfo(pad).mCStickPosY; } diff --git a/include/m_Do/m_Do_lib.h b/include/m_Do/m_Do_lib.h index db3a1dbea4..6b85cc0660 100644 --- a/include/m_Do/m_Do_lib.h +++ b/include/m_Do/m_Do_lib.h @@ -8,7 +8,7 @@ #include "JSystem/JGeometry.h" #endif -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" typedef struct Vec Vec; struct ResTIMG; diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index dcd5cd10c7..89e7e8b7cf 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -6,7 +6,7 @@ #include #include "JSystem/JMath/JMath.h" -#include "dusk/endian.h" +#include "helpers/endian.h" 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 527be3d58a..a71669f432 100644 --- a/include/m_Do/m_Do_printf.h +++ b/include/m_Do/m_Do_printf.h @@ -2,7 +2,7 @@ #define M_DO_M_DO_PRINTF_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" void my_PutString(const char*); void mDoPrintf_vprintf_Interrupt(char const*, va_list); diff --git a/include/os_report.h b/include/os_report.h index c622b172b3..0831e45396 100644 --- a/include/os_report.h +++ b/include/os_report.h @@ -31,10 +31,4 @@ extern u8 __OSReport_Warning_disable; extern u8 __OSReport_System_disable; extern u8 __OSReport_enable; -#if TARGET_PC -namespace dusk { - DUSK_GAME_EXTERN bool OSReportReallyForceEnable; -} -#endif - #endif // _OS_REPORT_H diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h b/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h index f82788d57c..1eddcb943a 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DMaterialFactory.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DManage.h" #include "JSystem/J2DGraph/J2DMatBlock.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j2d diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h b/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h index 510381ae10..a588b4e7f7 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DPane.h @@ -5,7 +5,7 @@ #include "JSystem/JSupport/JSUList.h" #include #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DAnmBase; class J2DAnmColor; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h b/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h index f738a96dd4..f311e191fa 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DPicture.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DPane.h" #include "JSystem/JUtility/JUTTexture.h" #include "JSystem/JUtility/TColor.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DMaterial; class JUTPalette; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h b/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h index 9244198475..ffc7568846 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DScreen.h @@ -4,7 +4,7 @@ #include "JSystem/J2DGraph/J2DManage.h" #include "JSystem/J2DGraph/J2DPane.h" #include "JSystem/JUtility/TColor.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J2DMaterial; class JUTNameTab; diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h b/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h index 368325ff81..e515321188 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DTevs.h @@ -4,7 +4,7 @@ #include #include #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j2d diff --git a/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h b/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h index 0d875ad652..96a53c5a16 100644 --- a/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h +++ b/libs/JSystem/include/JSystem/J2DGraph/J2DTextBox.h @@ -3,8 +3,8 @@ #include "JSystem/J2DGraph/J2DMaterial.h" #include "JSystem/J2DGraph/J2DPane.h" -#include "dusk/endian.h" -#include "dusk/string.hpp" +#include "helpers/endian.h" +#include "helpers/string.hpp" class J2DMaterial; class JUTFont; @@ -100,7 +100,7 @@ public: J2DTextBoxVBinding); void private_readStream(J2DPane*, JSURandomInputStream*, JKRArchive*); TEXT_SPAN getStringPtr() const; - dusk::TextSpan getSpan() const; + TextSpan getSpan() const; s32 setString(s16, char const*, ...); s32 setString(char const*, ...); diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h index 3c5133e880..f006183d07 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -6,7 +6,7 @@ #include #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC #define OFFSET_PTR_V0 BE(u32) diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h index 2a71ada3dd..4704fe1ee1 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -3,7 +3,7 @@ #include "JSystem/J3DAssert.h" #include "JSystem/J3DGraphLoader/J3DClusterLoader.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DDeformer; class J3DClusterKey; diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h index 92b252fb7a..e4018f1ea2 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -3,7 +3,7 @@ #include "JSystem/J3DAssert.h" #include "JSystem/J3DGraphBase/J3DTransform.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DJoint; class J3DMtxBuffer; diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h index 2e5b3bd38d..d55bb82465 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -3,7 +3,6 @@ #include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" #include "JSystem/J3DGraphBase/J3DPacket.h" -#include "dusk/frame_interpolation.h" #include enum J3DMdlFlag { @@ -106,12 +105,13 @@ public: void setUserArea(uintptr_t area) { mUserArea = area; } uintptr_t getUserArea() const { return mUserArea; } Vec* getBaseScale() { return &mBaseScale; } +#if TARGET_PC + void setAnmMtx(int jointNo, Mtx m); +#else void setAnmMtx(int jointNo, Mtx m) { mMtxBuffer->setAnmMtx(jointNo, m); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); -#endif } +#endif MtxP getAnmMtx(int jointNo) { return mMtxBuffer->getAnmMtx(jointNo); } MtxP getWeightAnmMtx(int i) { return mMtxBuffer->getWeightAnmMtx(i); } J3DSkinDeform* getSkinDeform() { return mSkinDeform; } diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h index ac9d4558bc..4ba3cc8023 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShape.h @@ -7,7 +7,7 @@ #include "JSystem/JMath/JMath.h" #include "global.h" #include -#include "dusk/endian_gx.hpp" +#include "helpers/endian_gx.hpp" class J3DShapeMtx; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h index 9edd5e6898..2b7ad8ad35 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphBase/J3DShape.h" #include "JSystem/J3DAssert.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DTexMtx; class J3DTexGenBlock; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h index 05663fd84e..0de93bcaf5 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DStruct.h @@ -7,7 +7,7 @@ #include "global.h" #include "JSystem/JMath/JMath.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-j3d diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h index b97be2ec03..a4750e5d29 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DSys.h @@ -6,8 +6,7 @@ #include "JSystem/J3DAssert.h" #include "JSystem/JMath/JMath.h" -#include "dusk/frame_interpolation.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #include "global.h" enum J3DSysDrawBuf { @@ -190,15 +189,13 @@ struct J3DSys { Mtx& getModelDrawMtx(u16 no) { return mModelDrawMtx[no]; } J3DShapePacket* getShapePacket() { return mShapePacket; } +#if TARGET_PC + void setViewMtx(const Mtx m); +#else void setViewMtx(const Mtx m) { -#ifdef TARGET_PC - Mtx patched; - if (dusk::frame_interp::lookup_replacement(m, patched)) { - m = patched; - } -#endif MTXCopy(m, mViewMtx); } +#endif J3DModel* getModel() { return mModel; } diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h index 6e95222b6d..5b05b08bcc 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DTexture.h @@ -7,7 +7,7 @@ #include "global.h" #include -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" /** * @ingroup jsystem-j3d diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h index 1638e316e9..f7ad92afb8 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DVertex.h @@ -3,7 +3,7 @@ #include #include -#include "dusk/endian_gx.hpp" +#include "helpers/endian_gx.hpp" class J3DModel; class J3DAnmVtxColor; diff --git a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h index 2899065150..75ba644be8 100644 --- a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h +++ b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DClusterLoader.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphAnimator/J3DAnimation.h" #include "JSystem/J3DGraphAnimator/J3DAnimation.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC #define OFFSET_PTR_V0 BE(u32) diff --git a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h index 6c856f1a3d..05fc99785b 100644 --- a/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h +++ b/libs/JSystem/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class J3DModelData; class J3DMaterialTable; diff --git a/libs/JSystem/include/JSystem/JAudio2/JAISound.h b/libs/JSystem/include/JSystem/JAudio2/JAISound.h index e96053fc9f..fa262a7426 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAISound.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAISound.h @@ -5,7 +5,7 @@ #include "JSystem/JAudio2/JAIAudible.h" #include "JSystem/JUtility/JUTAssert.h" #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #include class JAISound; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h b/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h index 5128b9186a..46a30d2616 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASAramStream.h @@ -4,7 +4,7 @@ #include "JSystem/JAudio2/JASTaskThread.h" #include "JSystem/JUtility/JUTAssert.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" class JASChannel; diff --git a/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h b/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h index 438bf9c70f..8ac20ce1ca 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h +++ b/libs/JSystem/include/JSystem/JAudio2/JASOscillator.h @@ -2,7 +2,7 @@ #define JASOSCILLATOR_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h b/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h index 44d4137d9b..cc5653fe25 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUAudibleParam.h @@ -2,7 +2,7 @@ #define JAUAUDIBLEPARAM_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h b/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h index c36ad44b22..33a31adb9f 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUAudioArcInterpreter.h @@ -2,7 +2,7 @@ #define JAUAUDIOARCINTERPRETER_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h b/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h index e81cd70ee4..f590815af5 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUSoundAnimator.h @@ -2,7 +2,7 @@ #define JAUSOUNDANIMATOR_H #include "JSystem/JAudio2/JAISound.h" -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" class JAUSoundAnimation; diff --git a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h index 4cc48f2a0b..fbd3427649 100644 --- a/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h +++ b/libs/JSystem/include/JSystem/JAudio2/JAUSoundTable.h @@ -3,7 +3,7 @@ #include "JSystem/JAudio2/JAISound.h" #include "JSystem/JAudio2/JASGadget.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jaudio diff --git a/libs/JSystem/include/JSystem/JGadget/binary.h b/libs/JSystem/include/JSystem/JGadget/binary.h index f93e548f88..eb0ddfb1d0 100644 --- a/libs/JSystem/include/JSystem/JGadget/binary.h +++ b/libs/JSystem/include/JSystem/JGadget/binary.h @@ -3,7 +3,7 @@ #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JGadget/search.h" -#include "dusk/endian.h" +#include "helpers/endian.h" namespace JGadget { namespace binary { diff --git a/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h b/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h index 3d8c452c72..e5a3e11553 100644 --- a/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h +++ b/libs/JSystem/include/JSystem/JHostIO/JHICommonMem.h @@ -2,7 +2,7 @@ #define JHICOMMONMEM_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" inline u32 JHIhtonl(u32 v) { return BSWAP32(v); diff --git a/libs/JSystem/include/JSystem/JKernel/JKRArchive.h b/libs/JSystem/include/JSystem/JKernel/JKRArchive.h index 40fff2dd6d..4ac5de7a46 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRArchive.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRArchive.h @@ -4,7 +4,7 @@ #include "JSystem/JKernel/JKRCompression.h" #include "JSystem/JKernel/JKRFileLoader.h" #include "global.h" -#include "dusk/endian.h" +#include "helpers/endian.h" class JKRHeap; diff --git a/libs/JSystem/include/JSystem/JMath/JMath.h b/libs/JSystem/include/JSystem/JMath/JMath.h index 5d0263d669..8a7efc3f32 100644 --- a/libs/JSystem/include/JSystem/JMath/JMath.h +++ b/libs/JSystem/include/JSystem/JMath/JMath.h @@ -4,7 +4,7 @@ #include #include -#include "dusk/math.h" +#include "helpers/math.h" typedef f32 Mtx33[3][3]; typedef f32 Mtx23[2][3]; diff --git a/libs/JSystem/include/JSystem/JMessage/JMessage.h b/libs/JSystem/include/JSystem/JMessage/JMessage.h index 0b3d1c64c8..7218c7f4a9 100644 --- a/libs/JSystem/include/JSystem/JMessage/JMessage.h +++ b/libs/JSystem/include/JSystem/JMessage/JMessage.h @@ -6,7 +6,7 @@ #else #include #endif -#include "dusk/endian.h" +#include "helpers/endian.h" // Struct definitions might be wrong typedef struct bmg_header_t { diff --git a/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h b/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h index c69ddc07cb..eb08e4ff9f 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h +++ b/libs/JSystem/include/JSystem/JParticle/JPADynamicsBlock.h @@ -4,7 +4,7 @@ #include "JSystem/JGeometry.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" struct JPAEmitterWorkData; diff --git a/libs/JSystem/include/JSystem/JParticle/JPAResource.h b/libs/JSystem/include/JSystem/JParticle/JPAResource.h index 07563fa73d..ba52564b95 100644 --- a/libs/JSystem/include/JSystem/JParticle/JPAResource.h +++ b/libs/JSystem/include/JSystem/JParticle/JPAResource.h @@ -2,7 +2,7 @@ #define JPARESOURCE_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" class JKRHeap; struct JPAEmitterWorkData; diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h index a23eed44e9..826e0948c1 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/jstudio-math.h @@ -6,7 +6,7 @@ #define m_PI_D 3.141592653589793 #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif namespace JStudio { diff --git a/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h b/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h index 77c27d0530..07d5a29b69 100644 --- a/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h +++ b/libs/JSystem/include/JSystem/JSupport/JSUInputStream.h @@ -2,7 +2,7 @@ #define JSUINPUTSTREAM_H #include "JSystem/JSupport/JSUIosBase.h" -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jsupport diff --git a/libs/JSystem/include/JSystem/JUtility/JUTFont.h b/libs/JSystem/include/JSystem/JUtility/JUTFont.h index 3c1cd0bf1f..0b262c0ac4 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTFont.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTFont.h @@ -3,7 +3,7 @@ #include "JSystem/JUtility/TColor.h" #include -#include "dusk/endian.h" +#include "helpers/endian.h" #if TARGET_PC struct FontDrawContext { diff --git a/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h b/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h index 6affae8ecb..6d4994d3f3 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTNameTab.h @@ -2,7 +2,7 @@ #define JUTNAMETAB_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" /** * @ingroup jsystem-jutility diff --git a/libs/JSystem/include/JSystem/JUtility/JUTPalette.h b/libs/JSystem/include/JSystem/JUtility/JUTPalette.h index 5d29005a92..8987c28f13 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTPalette.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTPalette.h @@ -3,7 +3,7 @@ #include -#include "dusk/endian.h" +#include "helpers/endian.h" enum JUTTransparency { UNK0, UNK1 }; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTResFont.h b/libs/JSystem/include/JSystem/JUtility/JUTResFont.h index a333cb9939..5e1cfa0011 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTResFont.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTResFont.h @@ -2,7 +2,7 @@ #define JUTRESFONT_H #include "JSystem/JUtility/JUTFont.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" class JKRHeap; diff --git a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h index 6a7a8f9a0e..c4356b0bf9 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h @@ -3,8 +3,8 @@ #include #include -#include "dusk/endian.h" -#include "dusk/gx_helper.h" +#include "helpers/endian.h" +#include "helpers/gx_helper.h" class JUTPalette; diff --git a/libs/JSystem/include/JSystem/JUtility/TColor.h b/libs/JSystem/include/JSystem/JUtility/TColor.h index d4a615b5b4..5ec7afa42a 100644 --- a/libs/JSystem/include/JSystem/JUtility/TColor.h +++ b/libs/JSystem/include/JSystem/JUtility/TColor.h @@ -2,7 +2,7 @@ #define TCOLOR_H #include -#include "dusk/endian.h" +#include "helpers/endian.h" namespace JUtility { diff --git a/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp b/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp index 2cede2c49a..34e33bc03d 100644 --- a/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp +++ b/libs/JSystem/src/J2DGraph/J2DMaterialFactory.cpp @@ -8,7 +8,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) { mMaterialNum = param_0.field_0x8; diff --git a/libs/JSystem/src/J2DGraph/J2DPane.cpp b/libs/JSystem/src/J2DGraph/J2DPane.cpp index 55a1b27ae1..01ab0e5444 100644 --- a/libs/JSystem/src/J2DGraph/J2DPane.cpp +++ b/libs/JSystem/src/J2DGraph/J2DPane.cpp @@ -8,7 +8,7 @@ #include "JSystem/JSupport/JSURandomInputStream.h" #include "JSystem/JUtility/JUTResource.h" #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) { diff --git a/libs/JSystem/src/J2DGraph/J2DTevs.cpp b/libs/JSystem/src/J2DGraph/J2DTevs.cpp index bb49596d85..bda5576cee 100644 --- a/libs/JSystem/src/J2DGraph/J2DTevs.cpp +++ b/libs/JSystem/src/J2DGraph/J2DTevs.cpp @@ -9,7 +9,7 @@ #ifdef __MWERKS__ #include #else -#include +#include #endif #include diff --git a/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp b/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp index fe4c5df9e6..284d7ea220 100644 --- a/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp +++ b/libs/JSystem/src/J2DGraph/J2DWindowEx.cpp @@ -3,7 +3,7 @@ #include "JSystem/J2DGraph/J2DWindowEx.h" #include "JSystem/JUtility/JUTTexture.h" #include "JSystem/JSupport/JSURandomInputStream.h" -#include "dusk/endian.h" +#include "helpers/endian.h" struct J2DWindowExDef { BE(u32) field_0x0[4]; diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp index 8e111428cc..51f3951e38 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp @@ -8,7 +8,10 @@ #include "JSystem/J3DGraphBase/J3DShapeMtx.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/JKernel/JKRHeap.h" + +#if TARGET_PC #include "dusk/frame_interpolation.h" +#endif #define J3D_ASSERTMSG(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) #define J3D_WARN1(LINE, MSG, ARG1) JUT_WARN(LINE, MSG, ARG1) @@ -105,6 +108,11 @@ void J3DModel::interp_callback(bool isSimFrame, void* pUserWork) { i_this->diff(); } } + +void J3DModel::setAnmMtx(int jointNo, Mtx m) { + mMtxBuffer->setAnmMtx(jointNo, m); + dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); +} #endif s32 J3DModel::createShapePacket(J3DModelData* pModelData) { diff --git a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp index 653b6e08f1..d37b4608bf 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp @@ -4,10 +4,14 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "global.h" #include "tracy/Tracy.hpp" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif + DUSK_GAME_DATA J3DSys j3dSys; DUSK_GAME_DATA Mtx J3DSys::mCurrentMtx; @@ -370,3 +374,13 @@ void J3DSys::reinitPixelProc() { GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GXSetZCompLoc(GX_TRUE); } + +#if TARGET_PC +void J3DSys::setViewMtx(const Mtx m) { + Mtx patched; + if (dusk::frame_interp::lookup_replacement(m, patched)) { + m = patched; + } + MTXCopy(m, mViewMtx); +} +#endif diff --git a/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp b/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp index 6bd9bf225a..1459a705cd 100644 --- a/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp +++ b/libs/JSystem/src/JAHostIO/JAHVirtualNode.cpp @@ -2,7 +2,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" DUSK_GAME_DATA u32 JAHVirtualNode::smVirNodeNum; diff --git a/libs/JSystem/src/JAHostIO/JAHioNode.cpp b/libs/JSystem/src/JAHostIO/JAHioNode.cpp index d3b45a4b5d..6e6ea2a320 100644 --- a/libs/JSystem/src/JAHostIO/JAHioNode.cpp +++ b/libs/JSystem/src/JAHostIO/JAHioNode.cpp @@ -6,7 +6,7 @@ #include "JSystem/JAHostIO/JAHioNode.h" #include "JSystem/JHostIO/JORServer.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" DUSK_GAME_DATA JAHioNode* JAHioNode::smCurrentNode; diff --git a/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp b/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp index 3848a64d3c..02730f46b4 100644 --- a/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp +++ b/libs/JSystem/src/JAudio2/JASWaveArcLoader.cpp @@ -9,7 +9,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" DUSK_GAME_DATA JASHeap* JASWaveArcLoader::sAramHeap; diff --git a/libs/JSystem/src/JFramework/JFWDisplay.cpp b/libs/JSystem/src/JFramework/JFWDisplay.cpp index aef89f309b..99b1e63364 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -14,11 +14,12 @@ #ifdef TARGET_PC #include "dusk/dusk.h" -#include "dusk/gx_helper.h" +#include "dusk/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" #include "dusk/time.h" #include "f_op/f_op_overlap_mng.h" +#include "helpers/gx_helper.h" #include "SDL3/SDL_timer.h" #include "tracy/Tracy.hpp" diff --git a/libs/JSystem/src/JKernel/JKRFileCache.cpp b/libs/JSystem/src/JKernel/JKRFileCache.cpp index 1a97ddefa3..a4795602c0 100644 --- a/libs/JSystem/src/JKernel/JKRFileCache.cpp +++ b/libs/JSystem/src/JKernel/JKRFileCache.cpp @@ -8,7 +8,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" JKRFileCache* JKRFileCache::mount(const char* path, JKRHeap* heap, const char* param_3) { diff --git a/libs/JSystem/src/JKernel/JKRFileLoader.cpp b/libs/JSystem/src/JKernel/JKRFileLoader.cpp index c3c5ac1903..0ff00f5f84 100644 --- a/libs/JSystem/src/JKernel/JKRFileLoader.cpp +++ b/libs/JSystem/src/JKernel/JKRFileLoader.cpp @@ -8,7 +8,7 @@ #include #include #include "JSystem/JKernel/JKRHeap.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" DUSK_GAME_DATA JKRFileLoader* JKRFileLoader::sCurrentVolume; diff --git a/libs/JSystem/src/JKernel/JKRHeap.cpp b/libs/JSystem/src/JKernel/JKRHeap.cpp index 34b3e7c619..3c329e0a43 100644 --- a/libs/JSystem/src/JKernel/JKRHeap.cpp +++ b/libs/JSystem/src/JKernel/JKRHeap.cpp @@ -15,7 +15,7 @@ #include "JSystem/JUtility/JUTAssert.h" #include "JSystem/JUtility/JUTException.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #ifdef __MWERKS__ #include #else @@ -702,7 +702,7 @@ JKRHeap* JKRHeap::getCurrentHeap() { } void JKRHeap::setName(const char* name) { - dusk::SafeStringCopyTruncate(mName, name); + SafeStringCopyTruncate(mName, name); } void JKRHeap::setNamef(const char* fmt, ...) { diff --git a/libs/JSystem/src/JKernel/JKRThread.cpp b/libs/JSystem/src/JKernel/JKRThread.cpp index 8203248339..73135381eb 100644 --- a/libs/JSystem/src/JKernel/JKRThread.cpp +++ b/libs/JSystem/src/JKernel/JKRThread.cpp @@ -7,7 +7,7 @@ #include "global.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if TARGET_PC #include "dusk/os.h" diff --git a/libs/JSystem/src/JParticle/JPAParticle.cpp b/libs/JSystem/src/JParticle/JPAParticle.cpp index eb2395e346..99ba95453c 100644 --- a/libs/JSystem/src/JParticle/JPAParticle.cpp +++ b/libs/JSystem/src/JParticle/JPAParticle.cpp @@ -7,6 +7,10 @@ #include "JSystem/JParticle/JPAEmitterManager.h" #include "JSystem/JParticle/JPAExtraShape.h" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif + JPAParticleCallBack::~JPAParticleCallBack() { /* empty function */ } diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index 2d5d872bac..9385b258e7 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -19,6 +19,8 @@ #include "tracy/Tracy.hpp" #if TARGET_PC +#include "dusk/frame_interpolation.h" + #define JPA_DRAW_CTX_ARG , &ctx #else #define JPA_DRAW_CTX_ARG diff --git a/libs/JSystem/src/JStudio/JStudio/stb-data.cpp b/libs/JSystem/src/JStudio/JStudio/stb-data.cpp index 95b8d7dafd..5de2b8f7bf 100644 --- a/libs/JSystem/src/JStudio/JStudio/stb-data.cpp +++ b/libs/JSystem/src/JStudio/JStudio/stb-data.cpp @@ -1,5 +1,5 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep -#include "dusk/endian.h" +#include "helpers/endian.h" #include "JSystem/JStudio/JStudio/stb-data.h" DUSK_GAME_DATA const s32 JStudio::stb::data::gauDataSize_TEParagraph_data[8] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40}; diff --git a/libs/JSystem/src/JUtility/JUTConsole.cpp b/libs/JSystem/src/JUtility/JUTConsole.cpp index 2899e3f0e4..75150cb498 100644 --- a/libs/JSystem/src/JUtility/JUTConsole.cpp +++ b/libs/JSystem/src/JUtility/JUTConsole.cpp @@ -8,7 +8,7 @@ #include "JSystem/JUtility/JUTConsole.h" #include "JSystem/JUtility/JUTDirectPrint.h" #include "JSystem/JUtility/JUTVideo.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "global.h" DUSK_GAME_DATA JUTConsoleManager* JUTConsoleManager::sManager; diff --git a/libs/JSystem/src/JUtility/JUTException.cpp b/libs/JSystem/src/JUtility/JUTException.cpp index 4b87dd50f8..9e00bce739 100644 --- a/libs/JSystem/src/JUtility/JUTException.cpp +++ b/libs/JSystem/src/JUtility/JUTException.cpp @@ -10,7 +10,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #ifdef __REVOLUTION_SDK__ #include #else diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index e7d33454b7..a8d9fe6028 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -10,6 +10,7 @@ #ifdef TARGET_PC #include +#include "dusk/frame_interpolation.h" #endif JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) diff --git a/libs/freeverb/CMakeLists.txt b/libs/freeverb/CMakeLists.txt index c0c12da293..d0275f62ac 100644 --- a/libs/freeverb/CMakeLists.txt +++ b/libs/freeverb/CMakeLists.txt @@ -7,3 +7,5 @@ add_library(freeverb allpass.cpp revmodel.cpp ) +target_include_directories(freeverb PRIVATE include/freeverb) +target_include_directories(freeverb INTERFACE include) diff --git a/libs/freeverb/allpass.hpp b/libs/freeverb/include/freeverb/allpass.hpp similarity index 100% rename from libs/freeverb/allpass.hpp rename to libs/freeverb/include/freeverb/allpass.hpp diff --git a/libs/freeverb/comb.hpp b/libs/freeverb/include/freeverb/comb.hpp similarity index 100% rename from libs/freeverb/comb.hpp rename to libs/freeverb/include/freeverb/comb.hpp diff --git a/libs/freeverb/denormals.h b/libs/freeverb/include/freeverb/denormals.h similarity index 100% rename from libs/freeverb/denormals.h rename to libs/freeverb/include/freeverb/denormals.h diff --git a/libs/freeverb/revmodel.hpp b/libs/freeverb/include/freeverb/revmodel.hpp similarity index 100% rename from libs/freeverb/revmodel.hpp rename to libs/freeverb/include/freeverb/revmodel.hpp diff --git a/libs/freeverb/tuning.h b/libs/freeverb/include/freeverb/tuning.h similarity index 100% rename from libs/freeverb/tuning.h rename to libs/freeverb/include/freeverb/tuning.h diff --git a/mods/ao_mod/CMakeLists.txt b/mods/ao_mod/CMakeLists.txt index 13590923f0..723ed55006 100644 --- a/mods/ao_mod/CMakeLists.txt +++ b/mods/ao_mod/CMakeLists.txt @@ -13,6 +13,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif () add_mod(ao_mod + FEATURES webgpu SOURCES src/mod.cpp MOD_JSON mod.json RES_DIR res diff --git a/mods/shadow_mod/CMakeLists.txt b/mods/shadow_mod/CMakeLists.txt index 4479d0fcc4..ae44eca49c 100644 --- a/mods/shadow_mod/CMakeLists.txt +++ b/mods/shadow_mod/CMakeLists.txt @@ -13,6 +13,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif () add_mod(shadow_mod + FEATURES game webgpu SOURCES src/mod.cpp MOD_JSON mod.json RES_DIR res diff --git a/mods/shadow_mod/src/mod.cpp b/mods/shadow_mod/src/mod.cpp index 4e3470c9be..0319dab3dc 100644 --- a/mods/shadow_mod/src/mod.cpp +++ b/mods/shadow_mod/src/mod.cpp @@ -24,7 +24,6 @@ #include "mods/service.hpp" #include "mods/svc/camera.h" #include "mods/svc/config.h" -#include "mods/svc/game.h" #include "mods/svc/gfx.h" #include "mods/svc/hook.h" #include "mods/svc/log.h" @@ -45,7 +44,6 @@ IMPORT_SERVICE(UiService, svc_ui); IMPORT_SERVICE(GfxService, svc_gfx); IMPORT_SERVICE(CameraService, svc_camera); IMPORT_SERVICE(HookService, svc_hook); -IMPORT_SERVICE(GameService, svc_game); IMPORT_SERVICE(LogService, svc_log); namespace { diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 7d1d17a8c2..2f25c28efe 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -1,17 +1,17 @@ # Dusklight Mod SDK entry point # -# Provides game/service headers, compile definitions, version.h and WebGPU -# headers without configuring the full game tree. +# Provides selectable mod service, game ABI, and WebGPU header surfaces without configuring the +# full game tree. # # Usage (from a mod project): # add_subdirectory(/sdk dusk-sdk EXCLUDE_FROM_ALL) -# add_mod(my_mod SOURCES ... MOD_JSON mod.json) +# add_mod(my_mod FEATURES game webgpu SOURCES ... MOD_JSON mod.json) # # TODO: auto-download link targets from tag cmake_minimum_required(VERSION 3.25) -if (TARGET dusklight_game_headers) +if (TARGET dusklight_mod_api) message(FATAL_ERROR "Mod SDK already configured") endif () @@ -29,12 +29,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/DetectVersion.cmake") detect_version() configure_version_header() -# Provides dawn::webgpu_dawn and dawn::dawncpp_headers for public gfx service headers. -include("${CMAKE_CURRENT_SOURCE_DIR}/../extern/aurora/cmake/AuroraDependencyVersions.cmake") -set(AURORA_DAWN_PROVIDER "package" CACHE STRING "How to provide Dawn for the mod SDK") -include("${CMAKE_CURRENT_SOURCE_DIR}/../extern/aurora/cmake/AuroraDawnProvider.cmake") - -# Game ABI headers & compile definitions +# Mod API and optional feature header surfaces include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/GameABIConfig.cmake") if (WIN32 OR APPLE OR ANDROID) diff --git a/include/mods/api.h b/sdk/include/mods/api.h similarity index 100% rename from include/mods/api.h rename to sdk/include/mods/api.h diff --git a/include/mods/hook.hpp b/sdk/include/mods/hook.hpp similarity index 98% rename from include/mods/hook.hpp rename to sdk/include/mods/hook.hpp index 94d5bce797..d48e9bff9f 100644 --- a/include/mods/hook.hpp +++ b/sdk/include/mods/hook.hpp @@ -1,6 +1,10 @@ #pragma once -#include "mods/svc/hook.h" +#if !defined(DUSK_BUILDING_GAME) && !defined(DUSK_MOD_FEATURE_GAME) +#error "DEFINE_HOOK requires add_mod(... FEATURES game)" +#endif + +#include #include #include diff --git a/include/mods/meta.hpp b/sdk/include/mods/meta.hpp similarity index 99% rename from include/mods/meta.hpp rename to sdk/include/mods/meta.hpp index 1f533feaa7..7d5d1e5eec 100644 --- a/include/mods/meta.hpp +++ b/sdk/include/mods/meta.hpp @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include #include #include diff --git a/include/mods/service.hpp b/sdk/include/mods/service.hpp similarity index 99% rename from include/mods/service.hpp rename to sdk/include/mods/service.hpp index f5ba322c45..d97d8def31 100644 --- a/include/mods/service.hpp +++ b/sdk/include/mods/service.hpp @@ -1,7 +1,7 @@ #pragma once -#include "mods/api.h" -#include "mods/meta.hpp" +#include +#include #include #include diff --git a/include/mods/svc/camera.h b/sdk/include/mods/svc/camera.h similarity index 99% rename from include/mods/svc/camera.h rename to sdk/include/mods/svc/camera.h index 884aadef1e..ec7724a1de 100644 --- a/include/mods/svc/camera.h +++ b/sdk/include/mods/svc/camera.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include #define CAMERA_SERVICE_ID "dev.twilitrealm.dusklight.camera" #define CAMERA_SERVICE_MAJOR 1u diff --git a/include/mods/svc/config.h b/sdk/include/mods/svc/config.h similarity index 99% rename from include/mods/svc/config.h rename to sdk/include/mods/svc/config.h index 4275312201..50c518bd40 100644 --- a/include/mods/svc/config.h +++ b/sdk/include/mods/svc/config.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include #define CONFIG_SERVICE_ID "dev.twilitrealm.dusklight.config" #define CONFIG_SERVICE_MAJOR 1u diff --git a/include/mods/svc/game.h b/sdk/include/mods/svc/game.h similarity index 81% rename from include/mods/svc/game.h rename to sdk/include/mods/svc/game.h index 116d6fc316..bdcf2d71f0 100644 --- a/include/mods/svc/game.h +++ b/sdk/include/mods/svc/game.h @@ -1,10 +1,10 @@ #pragma once -#include "mods/api.h" +#include /* - * Mods that link or hook game code directly must import this service; service-only and asset-only - * mods must not. + * The mod SDK imports this service automatically for mods built with FEATURES game; service-only + * and asset-only mods do not require it. * * Major version is the game-code ABI epoch: it is bumped when game-visible struct or vtable layouts * change incompatibly (e.g. a TARGET_PC field added to an existing game struct). The loader's @@ -20,7 +20,7 @@ typedef struct GameService { } GameService; #ifdef __cplusplus -#include "mods/service.hpp" +#include template <> struct dusk::mods::ServiceTraits { diff --git a/include/mods/svc/gfx.h b/sdk/include/mods/svc/gfx.h similarity index 98% rename from include/mods/svc/gfx.h rename to sdk/include/mods/svc/gfx.h index d87255e978..fad1b0bf9a 100644 --- a/include/mods/svc/gfx.h +++ b/sdk/include/mods/svc/gfx.h @@ -1,6 +1,10 @@ #pragma once -#include "mods/api.h" +#include + +#if !defined(DUSK_BUILDING_GAME) && !defined(DUSK_MOD_FEATURE_WEBGPU) +#error "mods/svc/gfx.h requires add_mod(... FEATURES webgpu)" +#endif #include diff --git a/include/mods/svc/hook.h b/sdk/include/mods/svc/hook.h similarity index 99% rename from include/mods/svc/hook.h rename to sdk/include/mods/svc/hook.h index 00760d2945..987c438fa0 100644 --- a/include/mods/svc/hook.h +++ b/sdk/include/mods/svc/hook.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include /* * Intercept game functions by address. Prefer the typed helpers in mods/hook.hpp diff --git a/include/mods/svc/host.h b/sdk/include/mods/svc/host.h similarity index 99% rename from include/mods/svc/host.h rename to sdk/include/mods/svc/host.h index b0b278612c..0f7851c7e1 100644 --- a/include/mods/svc/host.h +++ b/sdk/include/mods/svc/host.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include /* * The host service: the calling mod's identity and its runtime interface to the loader. diff --git a/include/mods/svc/log.h b/sdk/include/mods/svc/log.h similarity index 98% rename from include/mods/svc/log.h rename to sdk/include/mods/svc/log.h index b25780ed4a..0dbf4ec48e 100644 --- a/include/mods/svc/log.h +++ b/sdk/include/mods/svc/log.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include /* * Logging into the game's console and log files. Messages are attributed to the calling mod diff --git a/include/mods/svc/overlay.h b/sdk/include/mods/svc/overlay.h similarity index 98% rename from include/mods/svc/overlay.h rename to sdk/include/mods/svc/overlay.h index bf6fd7b975..02f60bd727 100644 --- a/include/mods/svc/overlay.h +++ b/sdk/include/mods/svc/overlay.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include #define OVERLAY_SERVICE_ID "dev.twilitrealm.dusklight.overlay" #define OVERLAY_SERVICE_MAJOR 1u diff --git a/include/mods/svc/resource.h b/sdk/include/mods/svc/resource.h similarity index 98% rename from include/mods/svc/resource.h rename to sdk/include/mods/svc/resource.h index 602ab1a25f..1a8251d83a 100644 --- a/include/mods/svc/resource.h +++ b/sdk/include/mods/svc/resource.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include /* * Read-only access to the res/ tree of the calling mod's own bundle. Reload serves the new diff --git a/include/mods/svc/texture.h b/sdk/include/mods/svc/texture.h similarity index 99% rename from include/mods/svc/texture.h rename to sdk/include/mods/svc/texture.h index 1c7a944cba..bb648cf860 100644 --- a/include/mods/svc/texture.h +++ b/sdk/include/mods/svc/texture.h @@ -1,6 +1,6 @@ #pragma once -#include "mods/api.h" +#include #define TEXTURE_SERVICE_ID "dev.twilitrealm.dusklight.texture" #define TEXTURE_SERVICE_MAJOR 1u diff --git a/include/mods/svc/ui.h b/sdk/include/mods/svc/ui.h similarity index 99% rename from include/mods/svc/ui.h rename to sdk/include/mods/svc/ui.h index 676706a739..73df25cb47 100644 --- a/include/mods/svc/ui.h +++ b/sdk/include/mods/svc/ui.h @@ -1,7 +1,7 @@ #pragma once -#include "mods/api.h" -#include "mods/svc/config.h" +#include +#include #define UI_SERVICE_ID "dev.twilitrealm.dusklight.ui" #define UI_SERVICE_MAJOR 1u diff --git a/sdk/src/game_feature.cpp b/sdk/src/game_feature.cpp new file mode 100644 index 0000000000..15fa16c443 --- /dev/null +++ b/sdk/src/game_feature.cpp @@ -0,0 +1,5 @@ +#include +#include + +// Linking the game feature makes the loader enforce the game ABI epoch. +IMPORT_SERVICE(GameService, svc_game); diff --git a/src/Z2AudioCS/SpkSystem.cpp b/src/Z2AudioCS/SpkSystem.cpp index ebe8c0a88c..0e91ca599c 100644 --- a/src/Z2AudioCS/SpkSystem.cpp +++ b/src/Z2AudioCS/SpkSystem.cpp @@ -1,6 +1,5 @@ #include "Z2AudioCS/SpkSystem.h" -#include "../../libs/JSystem/include/JSystem/JKernel/JKRHeap.h" #include "JSystem/JAudio2/JASGadget.h" #include "JSystem/JAudio2/JASHeapCtrl.h" #include "JSystem/JKernel/JKRHeap.h" diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index e3d4c7252c..45829188db 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -57,7 +57,7 @@ #include "dusk/settings.h" #include "res/Object/Alink.h" #include -#include +#include #endif static int daAlink_Create(fopAc_ac_c* i_this); diff --git a/src/d/actor/d_a_alink_effect.inc b/src/d/actor/d_a_alink_effect.inc index 1e3c8460eb..db64d25b81 100644 --- a/src/d/actor/d_a_alink_effect.inc +++ b/src/d/actor/d_a_alink_effect.inc @@ -8,7 +8,7 @@ #include "d/actor/d_a_alink.h" #include "d/d_com_inf_game.h" #include "d/d_k_wmark.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" DUSK_GAME_DATA const EffParamProc daAlink_c::m_fEffParamProc[] = { &daAlink_c::setEffectFrontRollParam, diff --git a/src/d/actor/d_a_bg_obj.cpp b/src/d/actor/d_a_bg_obj.cpp index 85af9a406c..da18ce4501 100644 --- a/src/d/actor/d_a_bg_obj.cpp +++ b/src/d/actor/d_a_bg_obj.cpp @@ -13,7 +13,7 @@ #include "d/actor/d_a_bg_obj.h" #include "d/actor/d_a_set_bgobj.h" #include "d/d_s_play.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" static const char* getBmdName(int param_0, int param_1) { static char l_bmdName[16]; diff --git a/src/d/actor/d_a_mirror.cpp b/src/d/actor/d_a_mirror.cpp index c405645320..486a035590 100644 --- a/src/d/actor/d_a_mirror.cpp +++ b/src/d/actor/d_a_mirror.cpp @@ -18,7 +18,7 @@ #endif #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif static BOOL daMirror_c_createHeap(fopAc_ac_c* i_this) { diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 43117615e5..a830f1440f 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -29,7 +29,7 @@ #include "JSystem/JAudio2/JASCriticalSection.h" #if TARGET_PC -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "dusk/os.h" #include "dusk/layout.hpp" #if MOVIE_SUPPORT @@ -4592,12 +4592,3 @@ DUSK_PROFILE actor_process_profile_definition DUSK_CONST g_profile_MOVIE_PLAYER }; AUDIO_INSTANCES; - -#if TARGET_PC -void dusk::MoviePlayerShutdown() { - // We need to cleanly shut down the threads to avoid crashes on shutdown. - if (daMP_c::m_myObj) { - daMP_c::m_myObj->daMP_c_Finish(); - } -} -#endif \ No newline at end of file diff --git a/src/d/actor/d_a_npc_hanjo.cpp b/src/d/actor/d_a_npc_hanjo.cpp index ede59f65b5..cbd3d9dcf9 100644 --- a/src/d/actor/d_a_npc_hanjo.cpp +++ b/src/d/actor/d_a_npc_hanjo.cpp @@ -15,7 +15,7 @@ #include "Z2AudioLib/Z2Instances.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" static DUSK_CONSTEXPR int l_bmdData[4][2] = { {14, 1}, {26, 2}, diff --git a/src/d/actor/d_a_npc_saru.cpp b/src/d/actor/d_a_npc_saru.cpp index d3690b833a..7f3f9e1126 100644 --- a/src/d/actor/d_a_npc_saru.cpp +++ b/src/d/actor/d_a_npc_saru.cpp @@ -11,7 +11,7 @@ #include "d/actor/d_a_e_ym.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" 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 b24e372aaf..e61ea44f4e 100644 --- a/src/d/actor/d_a_npc_shop0.cpp +++ b/src/d/actor/d_a_npc_shop0.cpp @@ -8,7 +8,7 @@ #include "d/actor/d_a_npc_shop0.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" static int createHeapCallBack(fopAc_ac_c* i_this) { return static_cast(i_this)->createHeap(); diff --git a/src/d/actor/d_a_npc_yelia.cpp b/src/d/actor/d_a_npc_yelia.cpp index bcdff6b5da..44b408b35c 100644 --- a/src/d/actor/d_a_npc_yelia.cpp +++ b/src/d/actor/d_a_npc_yelia.cpp @@ -9,7 +9,7 @@ #include "d/actor/d_a_demo_item.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" 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 e71a0e6b93..7ca9c4f36f 100644 --- a/src/d/actor/d_a_npc_ykw.cpp +++ b/src/d/actor/d_a_npc_ykw.cpp @@ -20,7 +20,7 @@ #include "m_Do/m_Do_ext.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if DEBUG class daNpc_ykW_HIO_c : public mDoHIO_entry_c { diff --git a/src/d/actor/d_a_obj_gra2.cpp b/src/d/actor/d_a_obj_gra2.cpp index faef741c27..a5fa226ee7 100644 --- a/src/d/actor/d_a_obj_gra2.cpp +++ b/src/d/actor/d_a_obj_gra2.cpp @@ -12,7 +12,7 @@ #include "d/d_cc_uty.h" #include "d/d_com_inf_actor.h" #include "d/d_com_inf_game.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if DEBUG #include "d/d_debug_viewer.h" #endif diff --git a/src/d/actor/d_a_obj_lv4chandelier.cpp b/src/d/actor/d_a_obj_lv4chandelier.cpp index 9ab47345d4..7847b37358 100644 --- a/src/d/actor/d_a_obj_lv4chandelier.cpp +++ b/src/d/actor/d_a_obj_lv4chandelier.cpp @@ -13,7 +13,7 @@ #include "d/d_cc_uty.h" #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif #if DEBUG diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp index 5170fbca4e..f8493ec385 100644 --- a/src/d/actor/d_a_obj_sekizoa.cpp +++ b/src/d/actor/d_a_obj_sekizoa.cpp @@ -9,7 +9,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "f_op/f_op_actor_mng.h" #include "f_op/f_op_msg.h" diff --git a/src/d/actor/d_a_tag_evt.cpp b/src/d/actor/d_a_tag_evt.cpp index 6f1de5a71c..780fc1d38c 100644 --- a/src/d/actor/d_a_tag_evt.cpp +++ b/src/d/actor/d_a_tag_evt.cpp @@ -8,7 +8,7 @@ #include "f_op/f_op_actor_mng.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" 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 cf8db83f8f..e023319a9f 100644 --- a/src/d/actor/d_a_tag_msg.cpp +++ b/src/d/actor/d_a_tag_msg.cpp @@ -11,7 +11,7 @@ #include "d/d_debug_viewer.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" static int createHeapCallBack(fopAc_ac_c* i_this) { daTag_Msg_c* msg = (daTag_Msg_c*)i_this; diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 54b1e022cc..bef7848c24 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -19,7 +19,7 @@ static u8* l_J_Ohana00_64TEX_get() { static u8 buf[0x800]; static bool _ = (dusk // from d_grass.inc static MtxP get_model_mtx(Mtx modelMtx, Mtx storage); static void transform_positions( - const dusk::batch::LeafTemplate& tpl, const Vec* posArray, const Mtx mtx, Vec* xfPos); + const batch::LeafTemplate& tpl, const Vec* posArray, const Mtx mtx, Vec* xfPos); static void split_batch(u32& emitted, u32 vtxCount); #else #include "assets/l_J_Ohana00_64TEX.h" @@ -595,11 +595,11 @@ dFlower_packet_c::dFlower_packet_c() { l_J_Ohana01_64128_0419TEX__width + 1, l_J_Ohana01_64128_0419TEX__height + 1, GX_TF_CMPR, GX_MIRROR, GX_MIRROR, GX_FALSE ); - dusk::batch::decode_leaf_template(l_J_hana00DL, 0x140, mTplHana00); - dusk::batch::decode_leaf_template(l_J_hana00_cDL, 0xC0, mTplHana00Cut); - dusk::batch::decode_leaf_template(l_J_hana01DL, 0x120, mTplHana01); - dusk::batch::decode_leaf_template(l_J_hana01_c_00DL, 0xC0, mTplHana01Cut00); - dusk::batch::decode_leaf_template(l_J_hana01_c_01DL, 0x120, mTplHana01Cut); + batch::decode_leaf_template(l_J_hana00DL, 0x140, mTplHana00); + batch::decode_leaf_template(l_J_hana00_cDL, 0xC0, mTplHana00Cut); + batch::decode_leaf_template(l_J_hana01DL, 0x120, mTplHana01); + batch::decode_leaf_template(l_J_hana01_c_00DL, 0xC0, mTplHana01Cut00); + batch::decode_leaf_template(l_J_hana01_c_01DL, 0x120, mTplHana01Cut); #endif m_deleteRoom = &dFlower_packet_c::deleteRoom; @@ -757,9 +757,9 @@ static GXColor hana01_amb_color(int idx, const dKy_tevstr_c* tevstr) { return amb; } -static void flower_emit(const dusk::batch::LeafTemplate& tpl, const Vec* xformedPos, GXColor amb) { +static void flower_emit(const batch::LeafTemplate& tpl, const Vec* xformedPos, GXColor amb) { for (u32 i = 0; i < tpl.vtxCount; i++) { - const dusk::batch::LeafTemplate::Vtx& v = tpl.vtx[i]; + const batch::LeafTemplate::Vtx& v = tpl.vtx[i]; const Vec& p = xformedPos[v.pos]; GXPosition3f32(p.x, p.y, p.z); GXNormal1x8(v.nrm); @@ -852,7 +852,7 @@ void dFlower_packet_c::draw() { for (int bucket = 0; bucket < 2; bucket++) { const bool cut = bucket != 0; - const dusk::batch::LeafTemplate& tpl = cut ? mTplHana00Cut : mTplHana00; + const batch::LeafTemplate& tpl = cut ? mTplHana00Cut : mTplHana00; bool open = false; u32 emitted = 0; @@ -931,10 +931,10 @@ void dFlower_packet_c::draw() { GXLoadPosMtxImm(identity, GX_PNMTX0); GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); - const dusk::batch::LeafTemplate* const buckets[3] = { + const batch::LeafTemplate* const buckets[3] = { &mTplHana01, &mTplHana01Cut00, &mTplHana01Cut}; for (int bucket = 0; bucket < 3; bucket++) { - const dusk::batch::LeafTemplate& tpl = *buckets[bucket]; + const batch::LeafTemplate& tpl = *buckets[bucket]; bool open = false; u32 emitted = 0; diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 9e8c360518..d2c212f043 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -513,9 +513,9 @@ dGrass_packet_c::dGrass_packet_c() { field_0x1d714 = 0; #if TARGET_PC - dusk::batch::decode_leaf_template(mp_Mkusa_9q_DL, m_Mkusa_9q_DL_size, mTplKusa9q); - dusk::batch::decode_leaf_template(mp_Mkusa_9q_cDL, m_Mkusa_9q_cDL_size, mTplKusa9qCut); - dusk::batch::decode_leaf_template(l_M_TenGusaDL, 0xC0, mTplTengusa); + batch::decode_leaf_template(mp_Mkusa_9q_DL, m_Mkusa_9q_DL_size, mTplKusa9q); + batch::decode_leaf_template(mp_Mkusa_9q_cDL, m_Mkusa_9q_cDL_size, mTplKusa9qCut); + batch::decode_leaf_template(l_M_TenGusaDL, 0xC0, mTplTengusa); #endif OS_REPORT("草群メモリ=%fK\n", 117.7734375f); @@ -533,7 +533,7 @@ static MtxP get_model_mtx(Mtx modelMtx, Mtx storage) { } static void transform_positions( - const dusk::batch::LeafTemplate& tpl, const Vec* posArray, const Mtx mtx, Vec* xfPos) { + const batch::LeafTemplate& tpl, const Vec* posArray, const Mtx mtx, Vec* xfPos) { for (u32 i = 0; i < tpl.posRefCount; i++) { const u8 idx = tpl.posRefs[i]; MTXMultVec(mtx, &posArray[idx], &xfPos[idx]); @@ -609,10 +609,10 @@ static GXColor blade_amb_color(const dGrass_data_c* blade, const dKy_tevstr_c* t return amb; } -static void blade_emit(const dusk::batch::LeafTemplate& tpl, const Vec* xformedPos, +static void blade_emit(const batch::LeafTemplate& tpl, const Vec* xformedPos, const GXColor* colors, GXColor amb) { for (u32 i = 0; i < tpl.vtxCount; i++) { - const dusk::batch::LeafTemplate::Vtx& v = tpl.vtx[i]; + const batch::LeafTemplate::Vtx& v = tpl.vtx[i]; const Vec& p = xformedPos[v.pos]; GXPosition3f32(p.x, p.y, p.z); GXNormal1x8(v.nrm); @@ -765,7 +765,7 @@ void dGrass_packet_c::draw() { for (int bucket = 0; bucket < 4; bucket++) { const bool kusaTex = bucket < 2; const bool cut = (bucket & 1) != 0; - const dusk::batch::LeafTemplate& tpl = + const batch::LeafTemplate& tpl = cut ? mTplKusa9qCut : (kusaTex ? mTplKusa9q : mTplTengusa); bool open = false; diff --git a/src/d/d_bg_parts.cpp b/src/d/d_bg_parts.cpp index c7d94551b9..07c91f8807 100644 --- a/src/d/d_bg_parts.cpp +++ b/src/d/d_bg_parts.cpp @@ -8,7 +8,7 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" 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 f48c58fead..51811d9538 100644 --- a/src/d/d_bg_s.cpp +++ b/src/d/d_bg_s.cpp @@ -15,7 +15,7 @@ #include "d/d_bg_s_capt_poly.h" #if TARGET_PC -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" #include "dusk/settings.h" #endif diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index 0df7475116..cfadb5aa8a 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -26,7 +26,11 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" + +#if TARGET_PC +#include "dusk/settings.h" +#endif void dComIfG_play_c::ct() { mWindowNum = 0; @@ -2990,3 +2994,19 @@ u8 dComIfGs_staffroll_next_go_check() { DUSK_GAME_DATA GXColor g_whiteColor = {255, 255, 255, 255}; DUSK_GAME_DATA GXColor g_saftyWhiteColor = {160, 160, 160, 255}; + +#if TARGET_PC +void dComIfGd_drawXluListInvisible() { + ZoneScoped; + if (!dusk::getSettings().game.disableWaterRefraction) { + g_dComIfG_gameInfo.drawlist.drawXluListInvisible(); + } +} + +void dComIfGd_drawOpaListInvisible() { + ZoneScoped; + if (!dusk::getSettings().game.disableWaterRefraction) { + g_dComIfG_gameInfo.drawlist.drawOpaListInvisible(); + } +} +#endif diff --git a/src/d/d_cursor_mng.cpp b/src/d/d_cursor_mng.cpp index 230b4e740e..b99ec8f4db 100644 --- a/src/d/d_cursor_mng.cpp +++ b/src/d/d_cursor_mng.cpp @@ -1,10 +1,7 @@ #include "JSystem/JKernel/JKRHeap.h" #include "d/dolzel.h" // IWYU pragma: keep - #include "d/d_cursor_mng.h" - -#include "../../libs/JSystem/include/JSystem/JKernel/JKRHeap.h" #include "d/d_com_inf_game.h" dCsr_mng_c* dCsr_mng_c::m_myObj; diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 438e910bff..8552ead16e 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -20,7 +20,7 @@ #include "absl/container/flat_hash_map.h" #include "client/TracyScoped.hpp" #include "dusk/frame_interpolation.h" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "dusk/logging.h" static const void* getInterpKey(const void* base, int idx) { diff --git a/src/d/d_ev_camera.cpp b/src/d/d_ev_camera.cpp index 67cda5863b..2650c2d05e 100644 --- a/src/d/d_ev_camera.cpp +++ b/src/d/d_ev_camera.cpp @@ -13,7 +13,7 @@ #include "d/actor/d_a_alink.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #ifdef __MWERKS__ #define LOAD_4BYTE_STRING_LITERAL(x) (*(u32*)(x)) diff --git a/src/d/d_event.cpp b/src/d/d_event.cpp index 3ae3becd93..b17ebf61f0 100644 --- a/src/d/d_event.cpp +++ b/src/d/d_event.cpp @@ -13,7 +13,7 @@ #include "SSystem/SComponent/c_counter.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" namespace { static u8 event_debug_evnt() { diff --git a/src/d/d_event_manager.cpp b/src/d/d_event_manager.cpp index 9da313c239..154a1c9288 100644 --- a/src/d/d_event_manager.cpp +++ b/src/d/d_event_manager.cpp @@ -15,7 +15,7 @@ #include "SSystem/SComponent/c_counter.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if DEBUG static dEvM_HIO_c l_HIO; diff --git a/src/d/d_file_sel_info.cpp b/src/d/d_file_sel_info.cpp index d54bc4424d..e107d6dacc 100644 --- a/src/d/d_file_sel_info.cpp +++ b/src/d/d_file_sel_info.cpp @@ -14,7 +14,7 @@ #include #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "dusk/version.hpp" dFile_info_c::dFile_info_c(JKRArchive* i_archive, u8 param_1) { diff --git a/src/d/d_file_select.cpp b/src/d/d_file_select.cpp index 19cdcfe81c..f57265aa77 100644 --- a/src/d/d_file_select.cpp +++ b/src/d/d_file_select.cpp @@ -25,7 +25,7 @@ #if TARGET_PC #include "dusk/menu_pointer.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" namespace { constexpr u8 pointer_target(u8 group, u8 index) noexcept { diff --git a/src/d/d_gameover.cpp b/src/d/d_gameover.cpp index 7d421a187c..c7dcde357c 100644 --- a/src/d/d_gameover.cpp +++ b/src/d/d_gameover.cpp @@ -14,7 +14,7 @@ #include "JSystem/J2DGraph/J2DGrafContext.h" #include -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" class dGov_HIO_c : public mDoHIO_entry_c { public: diff --git a/src/d/d_menu_calibration.cpp b/src/d/d_menu_calibration.cpp index bc256547d7..23f81121bc 100644 --- a/src/d/d_menu_calibration.cpp +++ b/src/d/d_menu_calibration.cpp @@ -14,7 +14,7 @@ #include "m_Do/m_Do_controller_pad.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" // Need 0xC bytes of padding with no symbol between dMenu_Calibration_c::__vtable and the end of // .data diff --git a/src/d/d_menu_dmap.cpp b/src/d/d_menu_dmap.cpp index 17d581eeab..36348b4387 100644 --- a/src/d/d_menu_dmap.cpp +++ b/src/d/d_menu_dmap.cpp @@ -26,7 +26,11 @@ #include "m_Do/m_Do_graphic.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" + +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif #if (PLATFORM_WII || PLATFORM_SHIELD) #define POINTER_OPT dComIfGs_getOptPointer() diff --git a/src/d/d_menu_fishing.cpp b/src/d/d_menu_fishing.cpp index 75ba679df7..2af4291525 100644 --- a/src/d/d_menu_fishing.cpp +++ b/src/d/d_menu_fishing.cpp @@ -16,7 +16,7 @@ #include "m_Do/m_Do_graphic.h" #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "dusk/version.hpp" typedef void (dMenu_Fishing_c::*initFunc)(); diff --git a/src/d/d_menu_fmap.cpp b/src/d/d_menu_fmap.cpp index 7b9558c1ce..7db489e51b 100644 --- a/src/d/d_menu_fmap.cpp +++ b/src/d/d_menu_fmap.cpp @@ -21,10 +21,14 @@ #include "d/d_msg_object.h" #include "d/d_msg_scrn_explain.h" #include "d/d_stage.h" -#include "dusk/memory.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "f_op/f_op_msg_mng.h" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#include "dusk/memory.h" +#endif + static dMf_HIO_c g_fmHIO; static dMenu_Fmap_c::process init_process[30] = { diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp index c3f1ed2a4a..a50d6def3a 100644 --- a/src/d/d_menu_ring.cpp +++ b/src/d/d_menu_ring.cpp @@ -30,6 +30,7 @@ #include #if TARGET_PC +#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" #include "dusk/menu_pointer.h" #include "dusk/settings.h" diff --git a/src/d/d_meter2_info.cpp b/src/d/d_meter2_info.cpp index 879ab5d386..6309e83a86 100644 --- a/src/d/d_meter2_info.cpp +++ b/src/d/d_meter2_info.cpp @@ -15,7 +15,7 @@ #include -#include "dusk/string.hpp" +#include "helpers/string.hpp" 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 1f47969f47..0e3354e76e 100644 --- a/src/d/d_meter_button.cpp +++ b/src/d/d_meter_button.cpp @@ -18,11 +18,10 @@ #include "d/d_pane_class.h" #include "dusk/frame_interpolation.h" #include -#if TARGET_PC -#include "dusk/string.hpp" -#endif -#include "dusk/string.hpp" +#if TARGET_PC +#include "helpers/string.hpp" +#endif #if VERSION == VERSION_GCN_JPN #define STR_BUF_LEN 528 diff --git a/src/d/d_model.cpp b/src/d/d_model.cpp index f1e58f2961..bdff472367 100644 --- a/src/d/d_model.cpp +++ b/src/d/d_model.cpp @@ -5,6 +5,10 @@ #include "JSystem/J3DGraphBase/J3DMaterial.h" #include "d/d_com_inf_game.h" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif + void dMdl_c::draw() { j3dSys.setVtxPos(mpModelData->getVtxPosArray(), mpModelData->getVtxNum()); j3dSys.setVtxNrm(mpModelData->getVtxNrmArray(), mpModelData->getNrmNum()); diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index 4bcdc7af5b..e33de068db 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -26,8 +26,12 @@ #include "m_Do/m_Do_lib.h" #include "tracy/Tracy.hpp" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif + #ifndef __MWERKS__ -#include "dusk/math.h" +#include "helpers/math.h" #endif #if DEBUG diff --git a/src/d/d_save.cpp b/src/d/d_save.cpp index cc0deb2213..22729ad43e 100644 --- a/src/d/d_save.cpp +++ b/src/d/d_save.cpp @@ -31,8 +31,8 @@ #include "dusk/settings.h" #include -#include "dusk/string.hpp" -#define strcpy dusk::SafeStringCopy +#include "helpers/string.hpp" +#define strcpy SafeStringCopy #endif static u8 dSv_item_rename(u8 i_itemNo) { diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index cd5c48b20f..a27f0482f8 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -23,7 +23,7 @@ #include #include "dusk/logging.h" -#include "dusk/string.hpp" +#include "helpers/string.hpp" #if TARGET_PC #include #include @@ -157,7 +157,7 @@ void dStage_startStage_c::set(const char* i_Name, s8 i_RoomNo, s16 i_Point, s8 i #if TARGET_PC // UB fix. if (mName != i_Name) { - dusk::SafeStringCopy(mName, i_Name); + SafeStringCopy(mName, i_Name); } #else strcpy(mName, i_Name); diff --git a/src/dusk/OSReport.cpp b/src/dusk/OSReport.cpp index 422b88f03c..78bfd652c9 100644 --- a/src/dusk/OSReport.cpp +++ b/src/dusk/OSReport.cpp @@ -1,6 +1,7 @@ #include #include "aurora/lib/logging.hpp" +#include "dusk/os.h" #include "os_report.h" aurora::Module Log("dusk::osReport"); @@ -143,4 +144,4 @@ void OSAttention(const char* fmt, ...) { va_start(args, fmt); OSVAttention(fmt, args); va_end(args); -} \ No newline at end of file +} diff --git a/include/dusk/achievements.h b/src/dusk/achievements.h similarity index 100% rename from include/dusk/achievements.h rename to src/dusk/achievements.h diff --git a/include/dusk/action_bindings.h b/src/dusk/action_bindings.h similarity index 100% rename from include/dusk/action_bindings.h rename to src/dusk/action_bindings.h diff --git a/include/dusk/app_info.hpp b/src/dusk/app_info.hpp similarity index 86% rename from include/dusk/app_info.hpp rename to src/dusk/app_info.hpp index e08fe680d9..bb8c15856e 100644 --- a/include/dusk/app_info.hpp +++ b/src/dusk/app_info.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_APPNAME_HPP -#define DUSK_APPNAME_HPP +#pragma once namespace dusk { /** @@ -21,5 +20,3 @@ namespace dusk { */ constexpr auto OrgName = "TwilitRealm"; } - -#endif // DUSK_APPNAME_HPP diff --git a/include/dusk/audio.h b/src/dusk/audio.h similarity index 72% rename from include/dusk/audio.h rename to src/dusk/audio.h index e3dfda9f52..0f247689f6 100644 --- a/include/dusk/audio.h +++ b/src/dusk/audio.h @@ -1,5 +1,4 @@ -#ifndef DUSK_AUDIO_H -#define DUSK_AUDIO_H +#pragma once #if TARGET_PC #define DUSK_AUDIO_DISABLED 0 @@ -12,5 +11,3 @@ #else #define DUSK_AUDIO_SKIP(...) #endif - -#endif // DUSK_AUDIO_H diff --git a/include/dusk/audio/DuskAudioSystem.h b/src/dusk/audio/DuskAudioSystem.h similarity index 100% rename from include/dusk/audio/DuskAudioSystem.h rename to src/dusk/audio/DuskAudioSystem.h diff --git a/src/dusk/audio/DuskDsp.cpp b/src/dusk/audio/DuskDsp.cpp index ca4d079e92..1f304d4b3e 100644 --- a/src/dusk/audio/DuskDsp.cpp +++ b/src/dusk/audio/DuskDsp.cpp @@ -10,11 +10,11 @@ #include #include "Adpcm.hpp" -#include "freeverb/revmodel.hpp" #include "dusk/audio/DuskAudioSystem.h" -#include "dusk/endian.h" #include "dusk/logging.h" +#include "freeverb/revmodel.hpp" #include "global.h" +#include "helpers/endian.h" #include "tracy/Tracy.hpp" using namespace dusk::audio; diff --git a/include/dusk/autosave.h b/src/dusk/autosave.h similarity index 86% rename from include/dusk/autosave.h rename to src/dusk/autosave.h index c32cd1e22b..2ab0887295 100644 --- a/include/dusk/autosave.h +++ b/src/dusk/autosave.h @@ -1,8 +1,5 @@ #pragma once -#ifndef AUTOSAVE_H -#define AUTOSAVE_H - #include #include #include @@ -15,5 +12,3 @@ void autoSaving(); void waitingForWrite(); void endAutoSave(); void toggleAutoSave(bool enabled); - -#endif \ No newline at end of file diff --git a/include/dusk/config.hpp b/src/dusk/config.hpp similarity index 99% rename from include/dusk/config.hpp rename to src/dusk/config.hpp index 6d36dff1f3..53591437db 100644 --- a/include/dusk/config.hpp +++ b/src/dusk/config.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_CONFIG_HPP -#define DUSK_CONFIG_HPP +#pragma once #include #include @@ -193,5 +192,3 @@ const ConfigImplBase* GetConfigImpl() { } } // namespace dusk::config - -#endif diff --git a/include/dusk/config_var.hpp b/src/dusk/config_var.hpp similarity index 99% rename from include/dusk/config_var.hpp rename to src/dusk/config_var.hpp index 52e62172cb..c4d3ac1d6b 100644 --- a/include/dusk/config_var.hpp +++ b/src/dusk/config_var.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_CONFIG_VAR_HPP -#define DUSK_CONFIG_VAR_HPP +#pragma once #include "dolphin/types.h" #include @@ -386,5 +385,3 @@ private: using ActionBindConfigVar = ConfigVar; } - -#endif // DUSK_CONFIG_VAR_HPP diff --git a/include/dusk/crash_handler.h b/src/dusk/crash_handler.h similarity index 100% rename from include/dusk/crash_handler.h rename to src/dusk/crash_handler.h diff --git a/include/dusk/crash_reporting.h b/src/dusk/crash_reporting.h similarity index 100% rename from include/dusk/crash_reporting.h rename to src/dusk/crash_reporting.h diff --git a/include/dusk/discord_presence.hpp b/src/dusk/discord_presence.hpp similarity index 100% rename from include/dusk/discord_presence.hpp rename to src/dusk/discord_presence.hpp diff --git a/include/dusk/dusk.h b/src/dusk/dusk.h similarity index 87% rename from include/dusk/dusk.h rename to src/dusk/dusk.h index 911ddbb535..b95b33515e 100644 --- a/include/dusk/dusk.h +++ b/src/dusk/dusk.h @@ -1,5 +1,4 @@ -#ifndef DUSK_DUSK_H -#define DUSK_DUSK_H +#pragma once #include @@ -19,5 +18,3 @@ constexpr u32 defaultAspectRatioW = 19; constexpr u32 defaultAspectRatioH = 14; static_assert(defaultWindowWidth / defaultAspectRatioW == defaultWindowHeight / defaultAspectRatioH); - -#endif // DUSK_DUSK_H diff --git a/src/dusk/dvd_asset.cpp b/src/dusk/dvd_asset.cpp index 75c82107cc..f5c8e73d4d 100644 --- a/src/dusk/dvd_asset.cpp +++ b/src/dusk/dvd_asset.cpp @@ -1,6 +1,6 @@ #include "dusk/dvd_asset.hpp" #include "dusk/logging.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #include "dolphin/dvd.h" #include "DynamicLink.h" #include "JSystem/JKernel/JKRArchive.h" diff --git a/include/dusk/dvd_asset.hpp b/src/dusk/dvd_asset.hpp similarity index 100% rename from include/dusk/dvd_asset.hpp rename to src/dusk/dvd_asset.hpp diff --git a/include/dusk/extras.h b/src/dusk/extras.h similarity index 73% rename from include/dusk/extras.h rename to src/dusk/extras.h index 562ca051c1..8a3d633a3f 100644 --- a/include/dusk/extras.h +++ b/src/dusk/extras.h @@ -1,5 +1,4 @@ -#ifndef _SRC_EXTRAS_H_ -#define _SRC_EXTRAS_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -13,5 +12,3 @@ int stricmp(const char* str1, const char* str2); #ifdef __cplusplus } #endif - -#endif // _SRC_EXTRAS_H_ diff --git a/include/dusk/frame_interpolation.h b/src/dusk/frame_interpolation.h similarity index 100% rename from include/dusk/frame_interpolation.h rename to src/dusk/frame_interpolation.h diff --git a/include/dusk/game_clock.h b/src/dusk/game_clock.h similarity index 100% rename from include/dusk/game_clock.h rename to src/dusk/game_clock.h diff --git a/include/dusk/gamepad_color.h b/src/dusk/gamepad_color.h similarity index 66% rename from include/dusk/gamepad_color.h rename to src/dusk/gamepad_color.h index 0524b0b98d..9e3e35a84e 100644 --- a/include/dusk/gamepad_color.h +++ b/src/dusk/gamepad_color.h @@ -1,11 +1,6 @@ #pragma once -#ifndef GAMEPAD_COLOR_H -#define GAMEPAD_COLOR_H - namespace dusk::input { void handleGamepadColor(); bool pad_has_led(int port) noexcept; } - -#endif \ No newline at end of file diff --git a/include/dusk/gfx.hpp b/src/dusk/gfx.hpp similarity index 100% rename from include/dusk/gfx.hpp rename to src/dusk/gfx.hpp diff --git a/src/dusk/globals.cpp b/src/dusk/globals.cpp index 49ab54ccbe..591ece679f 100644 --- a/src/dusk/globals.cpp +++ b/src/dusk/globals.cpp @@ -1,6 +1,25 @@ #include #include #include +#include "dusk/dusk.h" +#include "dusk/main.h" + +bool dusk::IsRunning = true; +bool dusk::IsShuttingDown = false; +bool dusk::IsGameLaunched = false; +bool dusk::RestartRequested = false; +uint8_t dusk::SaveRequested = 0; +dusk::StageRequest dusk::StageRequested{"", false}; +std::filesystem::path dusk::ConfigPath; +std::filesystem::path dusk::CachePath; +AuroraStats dusk::lastFrameAuroraStats; +float dusk::frameUsagePct = 0.0f; + +void dusk::RequestRestart() noexcept { + RestartRequested = SupportsProcessRestart; + IsRunning = false; +} + u8 g_printOtherHeapDebug; dKankyo_HIO_c g_kankyoHIO; diff --git a/include/dusk/gyro.h b/src/dusk/gyro.h similarity index 100% rename from include/dusk/gyro.h rename to src/dusk/gyro.h diff --git a/include/dusk/hotkeys.h b/src/dusk/hotkeys.h similarity index 89% rename from include/dusk/hotkeys.h rename to src/dusk/hotkeys.h index 7a774bde80..bdf1778c3f 100644 --- a/include/dusk/hotkeys.h +++ b/src/dusk/hotkeys.h @@ -1,5 +1,4 @@ -#ifndef DUSK_HOTKEYS_H -#define DUSK_HOTKEYS_H +#pragma once namespace dusk::hotkeys { @@ -23,5 +22,3 @@ constexpr const char* TOGGLE_FULLSCREEN = "F11"; constexpr const char* TURBO = "Tab"; } - -#endif // DUSK_HOTKEYS_H diff --git a/src/dusk/imgui/ImGuiMenuTools.cpp b/src/dusk/imgui/ImGuiMenuTools.cpp index cf5b22a270..b9ad5eb021 100644 --- a/src/dusk/imgui/ImGuiMenuTools.cpp +++ b/src/dusk/imgui/ImGuiMenuTools.cpp @@ -15,6 +15,7 @@ #include "dusk/data.hpp" #include "dusk/dusk.h" #include "dusk/main.h" +#include "dusk/os.h" #include "m_Do/m_Do_main.h" #include diff --git a/include/dusk/io.hpp b/src/dusk/io.hpp similarity index 97% rename from include/dusk/io.hpp rename to src/dusk/io.hpp index aba6bf8a48..c8f9ae771b 100644 --- a/include/dusk/io.hpp +++ b/src/dusk/io.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_IO_HPP -#define DUSK_IO_HPP +#pragma once #include #include @@ -106,5 +105,3 @@ inline std::string fs_path_to_string(const std::filesystem::path& path) { } } // namespace dusk::io - -#endif // DUSK_IO_HPP diff --git a/include/dusk/layout.hpp b/src/dusk/layout.hpp similarity index 90% rename from include/dusk/layout.hpp rename to src/dusk/layout.hpp index 78316d2e09..bb207c2000 100644 --- a/include/dusk/layout.hpp +++ b/src/dusk/layout.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_LAYOUT_H -#define DUSK_LAYOUT_H +#pragma once #include "dolphin/types.h" @@ -33,5 +32,3 @@ struct LayoutRect { f32 heightInner); }; } - -#endif // DUSK_LAYOUT_H diff --git a/include/dusk/livesplit.h b/src/dusk/livesplit.h similarity index 100% rename from include/dusk/livesplit.h rename to src/dusk/livesplit.h diff --git a/include/dusk/logging.h b/src/dusk/logging.h similarity index 93% rename from include/dusk/logging.h rename to src/dusk/logging.h index 54350af4bf..fdf315752e 100644 --- a/include/dusk/logging.h +++ b/src/dusk/logging.h @@ -1,5 +1,4 @@ -#ifndef DUSK_LOGGING_H -#define DUSK_LOGGING_H +#pragma once #include #include @@ -34,5 +33,3 @@ extern aurora::Module DuskLog; #else #define STUB_RET() (void)0 #endif - -#endif diff --git a/src/dusk/main.cpp b/src/dusk/main.cpp index a35f695b50..c1003a7718 100644 --- a/src/dusk/main.cpp +++ b/src/dusk/main.cpp @@ -5,6 +5,7 @@ #endif #include +#include "d/actor/d_a_movie_player.h" #include "dusk/main.h" #include "dusk/io.hpp" diff --git a/include/dusk/main.h b/src/dusk/main.h similarity index 91% rename from include/dusk/main.h rename to src/dusk/main.h index a16291a8a7..1378e48a1b 100644 --- a/include/dusk/main.h +++ b/src/dusk/main.h @@ -1,5 +1,4 @@ -#ifndef DUSK_MAIN_H -#define DUSK_MAIN_H +#pragma once #include @@ -34,5 +33,3 @@ inline constexpr bool SupportsProcessRestart = true; void RequestRestart() noexcept; } // namespace dusk - -#endif // DUSK_MAIN_H diff --git a/include/dusk/map_loader_definitions.h b/src/dusk/map_loader_definitions.h similarity index 100% rename from include/dusk/map_loader_definitions.h rename to src/dusk/map_loader_definitions.h diff --git a/include/dusk/memory.h b/src/dusk/memory.h similarity index 68% rename from include/dusk/memory.h rename to src/dusk/memory.h index dd55181170..2d24e5b957 100644 --- a/include/dusk/memory.h +++ b/src/dusk/memory.h @@ -1,10 +1,7 @@ -#ifndef DUSK_MEMORY_H -#define DUSK_MEMORY_H +#pragma once #if TARGET_PC #define HEAP_SIZE(original, dusk) (dusk) #else #define HEAP_SIZE(original, dusk) (original) #endif - -#endif diff --git a/include/dusk/menu_pointer.h b/src/dusk/menu_pointer.h similarity index 100% rename from include/dusk/menu_pointer.h rename to src/dusk/menu_pointer.h diff --git a/include/dusk/mod_loader.hpp b/src/dusk/mod_loader.hpp similarity index 100% rename from include/dusk/mod_loader.hpp rename to src/dusk/mod_loader.hpp diff --git a/include/dusk/mouse.h b/src/dusk/mouse.h similarity index 100% rename from include/dusk/mouse.h rename to src/dusk/mouse.h diff --git a/include/dusk/os.h b/src/dusk/os.h similarity index 62% rename from include/dusk/os.h rename to src/dusk/os.h index 180bdb9b1a..46529d1e61 100644 --- a/include/dusk/os.h +++ b/src/dusk/os.h @@ -1,5 +1,4 @@ -#ifndef DUSK_OS_H -#define DUSK_OS_H +#pragma once #ifdef __cplusplus extern "C" { @@ -9,6 +8,8 @@ void OSSetCurrentThreadName(const char* name); #ifdef __cplusplus } -#endif -#endif // DUSK_OS_H \ No newline at end of file +namespace dusk { +extern bool OSReportReallyForceEnable; +} +#endif diff --git a/include/dusk/scope_guard.hpp b/src/dusk/scope_guard.hpp similarity index 79% rename from include/dusk/scope_guard.hpp rename to src/dusk/scope_guard.hpp index 281d23434d..ac35334d5d 100644 --- a/include/dusk/scope_guard.hpp +++ b/src/dusk/scope_guard.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_SCOPE_GUARD_HPP -#define DUSK_SCOPE_GUARD_HPP +#pragma once #include @@ -16,5 +15,3 @@ public: private: std::function m_func; }; - -#endif //DUSK_SCOPE_GUARD_HPP diff --git a/include/dusk/settings.h b/src/dusk/settings.h similarity index 100% rename from include/dusk/settings.h rename to src/dusk/settings.h diff --git a/include/dusk/speedrun.h b/src/dusk/speedrun.h similarity index 100% rename from include/dusk/speedrun.h rename to src/dusk/speedrun.h diff --git a/include/dusk/texture_replacements.hpp b/src/dusk/texture_replacements.hpp similarity index 78% rename from include/dusk/texture_replacements.hpp rename to src/dusk/texture_replacements.hpp index 85cb59b001..1a633d424d 100644 --- a/include/dusk/texture_replacements.hpp +++ b/src/dusk/texture_replacements.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_TEXTURE_REPLACEMENTS_HPP -#define DUSK_TEXTURE_REPLACEMENTS_HPP +#pragma once #include @@ -13,5 +12,3 @@ void set_enabled(bool enabled); void shutdown(); } - -#endif diff --git a/include/dusk/time.h b/src/dusk/time.h similarity index 98% rename from include/dusk/time.h rename to src/dusk/time.h index ead946188b..fad3186042 100644 --- a/include/dusk/time.h +++ b/src/dusk/time.h @@ -1,5 +1,4 @@ -#ifndef DUSK_TIME_H -#define DUSK_TIME_H +#pragma once #include #include @@ -138,5 +137,3 @@ private: void NanoSleep(const duration_t duration) { SDL_DelayPrecise(duration); } #endif }; - -#endif diff --git a/include/dusk/touch_camera.h b/src/dusk/touch_camera.h similarity index 100% rename from include/dusk/touch_camera.h rename to src/dusk/touch_camera.h diff --git a/include/dusk/version.hpp b/src/dusk/version.hpp similarity index 95% rename from include/dusk/version.hpp rename to src/dusk/version.hpp index fe393b049b..4fd6395059 100644 --- a/include/dusk/version.hpp +++ b/src/dusk/version.hpp @@ -1,5 +1,4 @@ -#ifndef DUSK_VERSION_HPP -#define DUSK_VERSION_HPP +#pragma once /** * Functionality for switching game behavior based on the loaded game version (e.g. PAL/JPN, GC/Wii) @@ -63,5 +62,3 @@ namespace dusk::version { return defaultValue; } } // namespace dusk::version - -#endif // DUSK_VERSION_HPP diff --git a/src/f_pc/f_pc_manager.cpp b/src/f_pc/f_pc_manager.cpp index ad226b4d1d..3cda826854 100644 --- a/src/f_pc/f_pc_manager.cpp +++ b/src/f_pc/f_pc_manager.cpp @@ -21,6 +21,10 @@ #include "f_pc/f_pc_priority.h" #include "m_Do/m_Do_controller_pad.h" +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif + #include "tracy/Tracy.hpp" void fpcM_Draw(void* i_proc) { diff --git a/src/dusk/batch.cpp b/src/helpers/batch.cpp similarity index 97% rename from src/dusk/batch.cpp rename to src/helpers/batch.cpp index 04cba52b0d..a614eb8b1c 100644 --- a/src/dusk/batch.cpp +++ b/src/helpers/batch.cpp @@ -1,10 +1,10 @@ -#include "dusk/batch.hpp" +#include "helpers/batch.hpp" #include "dusk/logging.h" #include #include -namespace dusk::batch { +namespace batch { void decode_leaf_template(const u8* dl, u32 size, LeafTemplate& out) { out.vtxCount = 0; @@ -69,4 +69,4 @@ void decode_leaf_template(const u8* dl, u32 size, LeafTemplate& out) { } } -} // namespace dusk::batch +} // namespace batch diff --git a/src/dusk/endian.cpp b/src/helpers/endian.cpp similarity index 94% rename from src/dusk/endian.cpp rename to src/helpers/endian.cpp index 777ed8ae69..a4de822f07 100644 --- a/src/dusk/endian.cpp +++ b/src/helpers/endian.cpp @@ -1,7 +1,7 @@ -#include "dusk/endian.h" +#include "helpers/endian.h" #include #include "SSystem/SComponent/c_xyz.h" -#include "dusk/endian_gx.hpp" +#include "helpers/endian_gx.hpp" #define IMPL_ENUM(type) \ template <> \ diff --git a/src/dusk/offset_ptr.cpp b/src/helpers/offset_ptr.cpp similarity index 92% rename from src/dusk/offset_ptr.cpp rename to src/helpers/offset_ptr.cpp index f26fae3db5..59ca70a4de 100644 --- a/src/dusk/offset_ptr.cpp +++ b/src/helpers/offset_ptr.cpp @@ -1,8 +1,7 @@ -#include "dusk/offset_ptr.h" +#include "helpers/offset_ptr.h" #include "JSystem/JUtility/JUTAssert.h" -#if TARGET_PC bool OffsetPtr::isRelocated() { return value & 0x8000'0000; } @@ -25,4 +24,3 @@ bool OffsetPtr::setBase(void* base) { value = newDiff | 0x8000'0000; return true; } -#endif diff --git a/src/dusk/string.cpp b/src/helpers/string.cpp similarity index 96% rename from src/dusk/string.cpp rename to src/helpers/string.cpp index 7666f9d9ae..23fdbfb8db 100644 --- a/src/dusk/string.cpp +++ b/src/helpers/string.cpp @@ -1,4 +1,4 @@ -#include "dusk/string.hpp" +#include "helpers/string.hpp" #include "fmt/format.h" namespace { @@ -14,8 +14,6 @@ void strncpyProxy(char* dst, const char* src, size_t count) { } } // namespace -namespace dusk { - void TextSpan::CrashSpawnEmpty() { CRASH("Span is empty!"); } @@ -81,5 +79,3 @@ int SafeStringVPrintf(char* buffer, size_t bufSize, const char* src, std::va_lis return vsnprintf(buffer, bufSize, src, args); } - -} // namespace dusk \ No newline at end of file diff --git a/src/m_Do/m_Do_audio.cpp b/src/m_Do/m_Do_audio.cpp index b0427f065e..fec93cbed4 100644 --- a/src/m_Do/m_Do_audio.cpp +++ b/src/m_Do/m_Do_audio.cpp @@ -14,6 +14,10 @@ #include "m_Do/m_Do_dvd_thread.h" #include "tracy/Tracy.hpp" +#if TARGET_PC +#include "dusk/settings.h" +#endif + #if PLATFORM_WII || PLATFORM_SHIELD #include "Z2AudioCS/Z2AudioCS.h" #include @@ -25,6 +29,18 @@ DUSK_GAME_DATA u8 mDoAud_zelAudio_c::mResetFlag; DUSK_GAME_DATA u8 mDoAud_zelAudio_c::mBgmSet; +#if TARGET_PC +void mDoAud_seStartMenu(u32 i_sfxID) { + if (!mDoAud_zelAudio_c::isInitFlag()) { + return; + } + if (!dusk::getSettings().audio.menuSounds.getValue()) { + return; + } + mDoAud_seStart(i_sfxID, nullptr, 0, 0); +} +#endif + void mDoAud_zelAudio_c::reset() { mBgmSet = false; } diff --git a/src/m_Do/m_Do_controller_pad.cpp b/src/m_Do/m_Do_controller_pad.cpp index fc1ebf7b8c..9751bf4f27 100644 --- a/src/m_Do/m_Do_controller_pad.cpp +++ b/src/m_Do/m_Do_controller_pad.cpp @@ -14,6 +14,7 @@ #if TARGET_PC #include "dusk/menu_pointer.h" +#include "dusk/settings.h" #include "dusk/ui/touch_controls.hpp" #endif @@ -22,6 +23,22 @@ DUSK_GAME_DATA JUTGamePad* mDoCPd_c::m_gamePad[4]; DUSK_GAME_DATA interface_of_controller_pad mDoCPd_c::m_cpadInfo[4]; DUSK_GAME_DATA interface_of_controller_pad mDoCPd_c::m_debugCpadInfo[4]; +#if TARGET_PC +s16 mDoCPd_c::getStickAngle3D(u32 pad) { + if (dusk::getSettings().game.enableMirrorMode) { + return -getCpadInfo(pad).mMainStickAngle; + } + return getCpadInfo(pad).mMainStickAngle; +} + +f32 mDoCPd_c::getSubStickX3D(u32 pad) { + if (dusk::getSettings().game.enableMirrorMode) { + return -getCpadInfo(pad).mCStickPosX; + } + return getCpadInfo(pad).mCStickPosX; +} +#endif + void mDoCPd_c::create() { #if PLATFORM_GCN || PLATFORM_SHIELD m_gamePad[0] = JKR_NEW JUTGamePad(JUTGamePad::EPort1); diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 1a4bc19098..0d0f9014dc 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -51,10 +51,10 @@ #include "aurora/lib/window.hpp" #include "d/actor/d_a_horse.h" #include "dusk/dusk.h" -#include "dusk/endian.h" +#include "helpers/endian.h" #include "dusk/frame_interpolation.h" #include "dusk/gfx.hpp" -#include "dusk/gx_helper.h" +#include "helpers/gx_helper.h" #include "dusk/imgui/ImGuiConsole.hpp" #include "dusk/logging.h" #include "dusk/settings.h" diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 70a32e5afc..d291043d67 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -64,6 +64,7 @@ #include "dusk/mod_loader.hpp" #include "dusk/logging.h" #include "dusk/main.h" +#include "dusk/os.h" #include "dusk/ui/menu_bar.hpp" #include "dusk/ui/overlay.hpp" #include "dusk/ui/prelaunch.hpp" @@ -121,22 +122,6 @@ const int audioHeapSize = 0x14D800; // ========================================================================= #define COPYDATE_PATH "/str/Final/Release/COPYDATE" -#if TARGET_PC -DUSK_GAME_DATA bool dusk::IsRunning = true; -DUSK_GAME_DATA bool dusk::IsShuttingDown = false; -DUSK_GAME_DATA bool dusk::IsGameLaunched = false; -DUSK_GAME_DATA bool dusk::RestartRequested = false; -DUSK_GAME_DATA uint8_t dusk::SaveRequested = 0; -DUSK_GAME_DATA dusk::StageRequest dusk::StageRequested = {"",false}; -DUSK_GAME_DATA std::filesystem::path dusk::ConfigPath; -DUSK_GAME_DATA std::filesystem::path dusk::CachePath; -#endif - -void dusk::RequestRestart() noexcept { - RestartRequested = SupportsProcessRestart; - IsRunning = false; -} - s32 LOAD_COPYDATE(void*) { char buffer[32]; memset(buffer, 0, sizeof(buffer)); @@ -164,9 +149,7 @@ s32 LOAD_COPYDATE(void*) { return 1; } -DUSK_GAME_DATA AuroraInfo auroraInfo; -DUSK_GAME_DATA AuroraStats dusk::lastFrameAuroraStats; -DUSK_GAME_DATA float dusk::frameUsagePct = 0.0f; +AuroraInfo auroraInfo; bool launchUILoop() { while (dusk::IsRunning && !dusk::IsGameLaunched) { @@ -910,7 +893,10 @@ int game_main(int argc, char* argv[]) { main01(); - dusk::MoviePlayerShutdown(); + // We need to cleanly shut down the threads to avoid crashes on shutdown. + if (daMP_c::m_myObj) { + daMP_c::m_myObj->daMP_c_Finish(); + } dusk::crash_reporting::shutdown(); dusk::ShutdownFileLogging(); diff --git a/src/m_Do/m_Do_printf.cpp b/src/m_Do/m_Do_printf.cpp index 3cacece77d..70cde36c32 100644 --- a/src/m_Do/m_Do_printf.cpp +++ b/src/m_Do/m_Do_printf.cpp @@ -9,6 +9,7 @@ #include "m_Do/m_Do_ext.h" #if TARGET_PC #include +#include "dusk/os.h" #endif u8 __OSReport_disable;