OTRGlobals cleanup (#4251)

* Remove unused headers

* Move all "ResourceMgr_" functions to a new file

* Don't transitively include SaveManager

* Move cvar prefixes to a new header

* Add missing includes

* Update OTRGlobals.cpp

* Fix build

* Address review

* Fix some of the errors

* Update gameplaystats.h

* Update z_en_in.c

* Hopefully fix the linux issues

* Fix Linux issues for real this time, I checked

* Update ResourceManagerHelpers.cpp

* Update z_obj_mure2.c

* Post-merge fixes

* Fix build (hopefully)

* Post-merge fixes

* Update z_file_nameset_PAL.c

* cleanup some unnecessary headers (#7)

---------

Co-authored-by: Archez <Archez@users.noreply.github.com>
This commit is contained in:
Pepe20129 2024-11-19 17:44:44 +01:00 committed by GitHub
parent 70f3dfa8c5
commit 9bed5af33b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
258 changed files with 985 additions and 635 deletions

View File

@ -8,7 +8,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "macros.h" #include "macros.h"
#include "soh/OTRGlobals.h" #include "soh/cvar_prefixes.h"
#include "soh/Enhancements/gameconsole.h" #include "soh/Enhancements/gameconsole.h"
#include "soh/Enhancements/gameplaystats.h" #include "soh/Enhancements/gameplaystats.h"
#include <libultraship/bridge.h> #include <libultraship/bridge.h>

View File

@ -1,6 +1,7 @@
#include "AudioCollection.h" #include "AudioCollection.h"
#include "sequence.h" #include "sequence.h"
#include "sfx.h" #include "sfx.h"
#include "soh/cvar_prefixes.h"
#include <vector> #include <vector>
#include <utils/StringHelper.h> #include <utils/StringHelper.h>
#include <libultraship/bridge.h> #include <libultraship/bridge.h>

View File

@ -8,9 +8,10 @@
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include <functions.h> #include <functions.h>
#include "../randomizer/3drando/random.hpp" #include "../randomizer/3drando/random.hpp"
#include "../../OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include <utils/StringHelper.h> #include <utils/StringHelper.h>
#include "../../UIWidgets.hpp" #include "soh/UIWidgets.hpp"
#include "AudioCollection.h" #include "AudioCollection.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"

View File

@ -10,6 +10,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <z64.h> #include <z64.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
uint8_t gLoadFileSelect = 0, gSkipLogoTest = 0; uint8_t gLoadFileSelect = 0, gSkipLogoTest = 0;

View File

@ -4,6 +4,7 @@
#include "libultraship/libultra/controller.h" #include "libultraship/libultra/controller.h"
#include "Context.h" #include "Context.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#ifndef IMGUI_DEFINE_MATH_OPERATORS #ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#endif #endif

View File

@ -3,6 +3,7 @@
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "../../UIWidgets.hpp" #include "../../UIWidgets.hpp"
#include "z64.h" #include "z64.h"
#include "soh/cvar_prefixes.h"
#ifndef __WIIU__ #ifndef __WIIU__
#include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" #include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h"
#endif #endif

View File

@ -14,10 +14,12 @@
#include "soh/UIWidgets.hpp" #include "soh/UIWidgets.hpp"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
#include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_boy/object_link_boy.h"
#include "objects/object_link_child/object_link_child.h" #include "objects/object_link_child/object_link_child.h"
@ -48,9 +50,6 @@ extern PlayState* gPlayState;
#include "objects/object_gjyo_objects/object_gjyo_objects.h" #include "objects/object_gjyo_objects/object_gjyo_objects.h"
#include "textures/nintendo_rogo_static/nintendo_rogo_static.h" #include "textures/nintendo_rogo_static/nintendo_rogo_static.h"
#include "objects/object_gi_rabit_mask/object_gi_rabit_mask.h" #include "objects/object_gi_rabit_mask/object_gi_rabit_mask.h"
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
} }

View File

@ -1,6 +1,8 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include <string> #include <string>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h"
extern "C" { extern "C" {
#include <libultraship/libultra.h> #include <libultraship/libultra.h>
@ -9,11 +11,6 @@ extern "C" {
#include "objects/object_gi_soldout/object_gi_soldout.h" #include "objects/object_gi_soldout/object_gi_soldout.h"
#include "objects/object_ik/object_ik.h" #include "objects/object_ik/object_ik.h"
#include "objects/object_link_child/object_link_child.h" #include "objects/object_link_child/object_link_child.h"
uint32_t ResourceMgr_GameHasMasterQuest();
uint32_t ResourceMgr_GameHasOriginal();
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
} }
typedef struct { typedef struct {

View File

@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include <soh/Enhancements/item-tables/ItemTableManager.h> #include <soh/Enhancements/item-tables/ItemTableManager.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/cosmetics/CosmeticsEditor.h" #include "soh/Enhancements/cosmetics/CosmeticsEditor.h"

View File

@ -6,6 +6,7 @@
#include "../custom-message/CustomMessageManager.h" #include "../custom-message/CustomMessageManager.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "message_data_static.h" #include "message_data_static.h"
#include "variables.h" #include "variables.h"
#include "soh/util.h" #include "soh/util.h"

View File

@ -13,6 +13,7 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>

View File

@ -15,6 +15,7 @@ extern "C" {
#include "variables.h" #include "variables.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
} }

View File

@ -18,6 +18,7 @@ extern "C" {
#include "variables.h" #include "variables.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h" #include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;

View File

@ -7,6 +7,7 @@ extern "C" {
#include "variables.h" #include "variables.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a); void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a);
void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y); void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y);

View File

@ -6,13 +6,13 @@
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "variables.h" #include "variables.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h"
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
} }
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
const char* enemyCVarList[] = { const char* enemyCVarList[] = {
CVAR_ENHANCEMENT("RandomizedEnemyList.Armos"), CVAR_ENHANCEMENT("RandomizedEnemyList.Arwing"), CVAR_ENHANCEMENT("RandomizedEnemyList.Armos"), CVAR_ENHANCEMENT("RandomizedEnemyList.Arwing"),
CVAR_ENHANCEMENT("RandomizedEnemyList.BabyDodongo"), CVAR_ENHANCEMENT("RandomizedEnemyList.Bari"), CVAR_ENHANCEMENT("RandomizedEnemyList.BabyDodongo"), CVAR_ENHANCEMENT("RandomizedEnemyList.Bari"),

View File

@ -8,6 +8,7 @@
extern "C" { extern "C" {
#include "variables.h" #include "variables.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h" #include "functions.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
} }

View File

@ -1,11 +1,10 @@
extern "C" {
#include "gameplaystats.h" #include "gameplaystats.h"
}
#include "gameplaystatswindow.h" #include "gameplaystatswindow.h"
#include "soh/SaveManager.h" #include "soh/SaveManager.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "../UIWidgets.hpp" #include "../UIWidgets.hpp"
#include "soh/util.h" #include "soh/util.h"

View File

@ -1,5 +1,17 @@
#pragma once #pragma once
#include "soh/cvar_prefixes.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
uint64_t GetUnixTimestamp(void);
char* GameplayStats_GetCurrentTime();
#ifdef __cplusplus
};
#endif
// When using RTA timing // When using RTA timing
// get the diff since the save was created, // get the diff since the save was created,
// unless the game is complete in which we use the defeated ganon timestamp // unless the game is complete in which we use the defeated ganon timestamp
@ -17,7 +29,6 @@
gSaveContext.sohStats.sceneTimer) gSaveContext.sohStats.sceneTimer)
void InitStatTracker(); void InitStatTracker();
char* GameplayStats_GetCurrentTime();
typedef enum { typedef enum {
// 0x00 to 0x9B (0 to 155) used for getting items, // 0x00 to 0x9B (0 to 155) used for getting items,

View File

@ -3,6 +3,9 @@
#include "game-interactor/GameInteractor.h" #include "game-interactor/GameInteractor.h"
#include "tts/tts.h" #include "tts/tts.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/boss-rush/BossRushTypes.h"
#include "soh/Enhancements/boss-rush/BossRush.h" #include "soh/Enhancements/boss-rush/BossRush.h"
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/randomizer/3drando/random.hpp" #include "soh/Enhancements/randomizer/3drando/random.hpp"
@ -41,17 +44,15 @@ extern "C" {
#include <z64.h> #include <z64.h>
#include "align_asset_macro.h" #include "align_asset_macro.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "functions.h" #include "functions.h"
#include "src/overlays/actors/ovl_En_Door/z_en_door.h" #include "src/overlays/actors/ovl_En_Door/z_en_door.h"
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
extern SaveContext gSaveContext; extern SaveContext gSaveContext;
extern PlayState* gPlayState; extern PlayState* gPlayState;
extern void Overlay_DisplayText(float duration, const char* text); extern void Overlay_DisplayText(float duration, const char* text);
uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
} }
// GreyScaleEndDlist // GreyScaleEndDlist

View File

@ -10,6 +10,7 @@
extern "C" { extern "C" {
#include "z64.h" #include "z64.h"
#include "macros.h" #include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "textures/message_static/message_static.h" #include "textures/message_static/message_static.h"

View File

@ -8,6 +8,7 @@
#include "soh/Enhancements/randomizer/randomizerTypes.h" #include "soh/Enhancements/randomizer/randomizerTypes.h"
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
enum PresetEntryType { enum PresetEntryType {
PRESET_ENTRY_TYPE_S32, PRESET_ENTRY_TYPE_S32,

View File

@ -10,6 +10,7 @@
#include "soh/Enhancements/randomizer/randomizerTypes.h" #include "soh/Enhancements/randomizer/randomizerTypes.h"
#include "variables.h" #include "variables.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "../option.h" #include "../option.h"
#include "soh/Enhancements/debugger/performanceTimer.h" #include "soh/Enhancements/debugger/performanceTimer.h"

View File

@ -9,6 +9,7 @@
#include <Context.h> #include <Context.h>
#include <libultraship/libultra/types.h> #include <libultraship/libultra/types.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks, void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
std::string seedString) { std::string seedString) {

View File

@ -5,6 +5,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "randomizerTypes.h" #include "randomizerTypes.h"
#include <array> #include <array>
#include "objects/object_gi_key/object_gi_key.h" #include "objects/object_gi_key/object_gi_key.h"

View File

@ -1,5 +1,6 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/custom-message/CustomMessageTypes.h" #include "soh/Enhancements/custom-message/CustomMessageTypes.h"
#include "soh/Enhancements/item-tables/ItemTableManager.h" #include "soh/Enhancements/item-tables/ItemTableManager.h"
@ -10,6 +11,7 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ImGuiUtils.h" #include "soh/ImGuiUtils.h"
#include "soh/Notification/Notification.h" #include "soh/Notification/Notification.h"
#include "soh/SaveManager.h"
extern "C" { extern "C" {
#include "macros.h" #include "macros.h"
@ -1834,7 +1836,7 @@ void RandomizerOnActorInitHandler(void* actorRef) {
if ( if (
actor->id == ACTOR_OBJ_OSHIHIKI && actor->id == ACTOR_OBJ_OSHIHIKI &&
LINK_IS_CHILD && LINK_IS_CHILD &&
IsGameMasterQuest() && ResourceMgr_IsGameMasterQuest() &&
gPlayState->sceneNum == SCENE_SPIRIT_TEMPLE && actor->room == 6 && // Spirit Temple silver block hallway gPlayState->sceneNum == SCENE_SPIRIT_TEMPLE && actor->room == 6 && // Spirit Temple silver block hallway
actor->params == 0x9C7 // Silver block that is marked as in the hole actor->params == 0x9C7 // Silver block that is marked as in the hole
) { ) {

View File

@ -10,6 +10,8 @@
#include <textures/icon_item_24_static/icon_item_24_static.h> #include <textures/icon_item_24_static/icon_item_24_static.h>
#include "3drando/rando_main.hpp" #include "3drando/rando_main.hpp"
#include "3drando/random.hpp" #include "3drando/random.hpp"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "3drando/custom_messages.hpp" #include "3drando/custom_messages.hpp"
#include "../../UIWidgets.hpp" #include "../../UIWidgets.hpp"
#ifndef IMGUI_DEFINE_MATH_OPERATORS #ifndef IMGUI_DEFINE_MATH_OPERATORS
@ -41,9 +43,6 @@
#include "fishsanity.h" #include "fishsanity.h"
#include "randomizerTypes.h" #include "randomizerTypes.h"
extern "C" uint32_t ResourceMgr_IsGameMasterQuest();
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
extern std::map<RandomizerCheckArea, std::string> rcAreaNames; extern std::map<RandomizerCheckArea, std::string> rcAreaNames;
using json = nlohmann::json; using json = nlohmann::json;

View File

@ -6,6 +6,7 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include "z64.h" #include "z64.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "fishsanity.h" #include "fishsanity.h"
std::map<RandomizerCheckArea, std::string> rcAreaNames = { std::map<RandomizerCheckArea, std::string> rcAreaNames = {

View File

@ -2,9 +2,12 @@
#include "randomizer_entrance_tracker.h" #include "randomizer_entrance_tracker.h"
#include "randomizer_item_tracker.h" #include "randomizer_item_tracker.h"
#include "randomizerTypes.h" #include "randomizerTypes.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "dungeon.h" #include "dungeon.h"
#include "../../OTRGlobals.h"
#include "../../UIWidgets.hpp"
#include "3drando/location_access.hpp" #include "3drando/location_access.hpp"
#include <string> #include <string>
@ -24,7 +27,6 @@ extern "C" {
#include "macros.h" #include "macros.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
} }
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 modIndex, s16 getItemID); extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 modIndex, s16 getItemID);
extern std::vector<ItemTrackerItem> dungeonRewardStones; extern std::vector<ItemTrackerItem> dungeonRewardStones;

View File

@ -9,6 +9,8 @@
#include "randomizer_entrance.h" #include "randomizer_entrance.h"
#include "randomizer_grotto.h" #include "randomizer_grotto.h"
#include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#include <string.h> #include <string.h>
#include "global.h" #include "global.h"

View File

@ -1,5 +1,6 @@
#include "randomizer_entrance_tracker.h" #include "randomizer_entrance_tracker.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/UIWidgets.hpp" #include "soh/UIWidgets.hpp"
#include <map> #include <map>

View File

@ -4,6 +4,7 @@
*/ */
#include "randomizer_grotto.h" #include "randomizer_grotto.h"
#include "soh/OTRGlobals.h"
#include "global.h" #include "global.h"

View File

@ -1,7 +1,10 @@
#include "randomizer_item_tracker.h" #include "randomizer_item_tracker.h"
#include "../../util.h" #include "soh/util.h"
#include "../../OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "../../UIWidgets.hpp" #include "soh/cvar_prefixes.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "randomizerTypes.h" #include "randomizerTypes.h"
#include <map> #include <map>
@ -22,7 +25,6 @@ extern PlayState* gPlayState;
#include "textures/icon_item_static/icon_item_static.h" #include "textures/icon_item_static/icon_item_static.h"
#include "textures/icon_item_24_static/icon_item_24_static.h" #include "textures/icon_item_24_static/icon_item_24_static.h"
} }
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
void DrawEquip(ItemTrackerItem item); void DrawEquip(ItemTrackerItem item);
void DrawItem(ItemTrackerItem item); void DrawItem(ItemTrackerItem item);

View File

@ -1,5 +1,6 @@
#include "savefile.h" #include "savefile.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
extern "C" { extern "C" {
@ -8,7 +9,6 @@ extern "C" {
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
uint8_t Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); uint8_t Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
} }

View File

@ -5,6 +5,7 @@
#include <soh/UIWidgets.hpp> #include <soh/UIWidgets.hpp>
#include <graphic/Fast3D/gfx_pc.h> #include <graphic/Fast3D/gfx_pc.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
/* Console Variables are grouped under gAdvancedResolution. (e.g. CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled") /* Console Variables are grouped under gAdvancedResolution. (e.g. CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled")

View File

@ -6,17 +6,14 @@
#include <fstream> #include <fstream>
#include <chrono> #include <chrono>
#include <ResourceManager.h> #include "ResourceManagerHelpers.h"
#include "graphic/Fast3D/Fast3dWindow.h" #include "graphic/Fast3D/Fast3dWindow.h"
#include <File.h> #include <File.h>
#include <DisplayList.h> #include <DisplayList.h>
#include <Window.h> #include <Window.h>
#include <GameVersions.h> #include <GameVersions.h>
#include "z64animation.h"
#include "z64bgcheck.h"
#include "Enhancements/gameconsole.h" #include "Enhancements/gameconsole.h"
#include <libultraship/libultra/gbi.h>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#else #else
@ -27,7 +24,6 @@
#include "Enhancements/controls/SohInputEditorWindow.h" #include "Enhancements/controls/SohInputEditorWindow.h"
#include "Enhancements/cosmetics/CosmeticsEditor.h" #include "Enhancements/cosmetics/CosmeticsEditor.h"
#include "Enhancements/audio/AudioCollection.h" #include "Enhancements/audio/AudioCollection.h"
#include "Enhancements/audio/AudioEditor.h"
#include "Enhancements/enhancementTypes.h" #include "Enhancements/enhancementTypes.h"
#include "Enhancements/debugconsole.h" #include "Enhancements/debugconsole.h"
#include "Enhancements/randomizer/randomizer.h" #include "Enhancements/randomizer/randomizer.h"
@ -56,7 +52,6 @@
#endif #endif
#include <Fast3D/gfx_pc.h> #include <Fast3D/gfx_pc.h>
#include <Fast3D/gfx_rendering_api.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <SDL_scancode.h> #include <SDL_scancode.h>
@ -77,6 +72,7 @@
#include "Enhancements/item-tables/ItemTableManager.h" #include "Enhancements/item-tables/ItemTableManager.h"
#include "SohGui.hpp" #include "SohGui.hpp"
#include "ActorDB.h" #include "ActorDB.h"
#include "SaveManager.h"
#ifdef ENABLE_REMOTE_CONTROL #ifdef ENABLE_REMOTE_CONTROL
#include "soh/Network/CrowdControl/CrowdControl.h" #include "soh/Network/CrowdControl/CrowdControl.h"
@ -506,18 +502,11 @@ uint32_t OTRGlobals::GetInterpolationFPS() {
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20)); return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20));
} }
struct ExtensionEntry {
std::string path;
std::string ext;
};
extern "C" void OTRMessage_Init(); extern "C" void OTRMessage_Init();
extern "C" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); extern "C" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len); extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
extern "C" int AudioPlayer_Buffered(void); extern "C" int AudioPlayer_Buffered(void);
extern "C" int AudioPlayer_GetDesiredBuffered(void); extern "C" int AudioPlayer_GetDesiredBuffered(void);
extern "C" void ResourceMgr_LoadDirectory(const char* resName);
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path);
std::unordered_map<std::string, ExtensionEntry> ExtensionCache; std::unordered_map<std::string, ExtensionEntry> ExtensionCache;
void OTRAudio_Thread() { void OTRAudio_Thread() {
@ -1478,269 +1467,7 @@ extern "C" uint16_t OTRGetPixelDepth(float x, float y) {
return wnd->GetPixelDepth(x, y); return wnd->GetPixelDepth(x, y);
} }
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size();
}
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
}
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
case OOT_NTSC_US_11:
case OOT_NTSC_US_12:
case OOT_PAL_10:
case OOT_PAL_11:
return GAME_PLATFORM_N64;
case OOT_NTSC_JP_GC:
case OOT_NTSC_US_GC:
case OOT_PAL_GC:
case OOT_NTSC_JP_MQ:
case OOT_NTSC_US_MQ:
case OOT_PAL_MQ:
case OOT_PAL_GC_DBG1:
case OOT_PAL_GC_DBG2:
case OOT_PAL_GC_MQ_DBG:
return GAME_PLATFORM_GC;
}
}
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
case OOT_NTSC_US_11:
case OOT_NTSC_US_12:
case OOT_NTSC_JP_GC:
case OOT_NTSC_US_GC:
case OOT_NTSC_JP_MQ:
case OOT_NTSC_US_MQ:
return GAME_REGION_NTSC;
case OOT_PAL_10:
case OOT_PAL_11:
case OOT_PAL_GC:
case OOT_PAL_MQ:
case OOT_PAL_GC_DBG1:
case OOT_PAL_GC_DBG2:
case OOT_PAL_GC_MQ_DBG:
return GAME_REGION_PAL;
}
}
uint32_t IsSceneMasterQuest(s16 sceneNum) {
uint32_t value = 0;
uint8_t mqMode = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_OFF);
if (mqMode == WARP_MODE_OVERRIDE_MQ_AS_VANILLA) {
return 1;
} else if (mqMode == WARP_MODE_OVERRIDE_VANILLA_AS_MQ) {
return 0;
} else {
if (OTRGlobals::Instance->HasMasterQuest()) {
if (!OTRGlobals::Instance->HasOriginal()) {
value = 1;
} else if (IS_MASTER_QUEST) {
value = 1;
} else {
value = 0;
if (IS_RANDO) {
auto dungeon = OTRGlobals::Instance->gRandoContext->GetDungeons()->GetDungeonFromScene(sceneNum);
if (dungeon != nullptr && dungeon->IsMQ()) {
value = 1;
}
}
}
}
}
return value;
}
uint32_t IsGameMasterQuest() {
return gPlayState != NULL ? IsSceneMasterQuest(gPlayState->sceneNum) : 0;
}
extern "C" uint32_t ResourceMgr_GameHasMasterQuest() {
return OTRGlobals::Instance->HasMasterQuest();
}
extern "C" uint32_t ResourceMgr_GameHasOriginal() {
return OTRGlobals::Instance->HasOriginal();
}
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum) {
return IsSceneMasterQuest(sceneNum);
}
extern "C" uint32_t ResourceMgr_IsGameMasterQuest() {
return IsGameMasterQuest();
}
extern "C" void ResourceMgr_LoadDirectory(const char* resName) {
Ship::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName);
}
extern "C" void ResourceMgr_DirtyDirectory(const char* resName) {
Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName);
}
extern "C" void ResourceMgr_UnloadResource(const char* resName) {
std::string path = resName;
if (path.substr(0, 7) == "__OTR__") {
path = path.substr(7);
}
auto res = Ship::Context::GetInstance()->GetResourceManager()->UnloadResource(path);
}
// OTRTODO: There is probably a more elegant way to go about this...
// Kenix: This is definitely leaking memory when it's called.
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
auto lst = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask);
char** result = (char**)malloc(lst->size() * sizeof(char*));
for (size_t i = 0; i < lst->size(); i++) {
char* str = (char*)malloc(lst.get()[0][i].size() + 1);
memcpy(str, lst.get()[0][i].data(), lst.get()[0][i].size());
str[lst.get()[0][i].size()] = '\0';
result[i] = str;
}
*resultSize = lst->size();
return result;
}
extern "C" uint8_t ResourceMgr_FileExists(const char* filePath) {
std::string path = filePath;
if(path.substr(0, 7) == "__OTR__"){
path = path.substr(7);
}
return ExtensionCache.contains(path);
}
extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) {
std::string path = filePath;
if (path.substr(0, 7) == "__OTR__") {
path = path.substr(7);
}
if (path.substr(0, 4) != "alt/") {
path = "alt/" + path;
}
return ExtensionCache.contains(path);
}
extern "C" bool ResourceMgr_IsAltAssetsEnabled() {
return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled();
}
// Unloads a resource if an alternate version exists when alt assets are enabled
// The resource is only removed from the internal cache to prevent it from used in the next resource lookup
extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) {
if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*)resName)) {
ResourceMgr_UnloadResource((char*) resName);
}
}
std::shared_ptr<Ship::IResource> GetResourceByNameHandlingMQ(const char* path) {
std::string Path = path;
if (ResourceMgr_IsGameMasterQuest()) {
size_t pos = 0;
if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) {
Path.replace(pos, 7, "/mq/");
}
}
return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str());
}
extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) {
auto res = GetResourceByNameHandlingMQ(path);
if (res == nullptr) {
return nullptr;
}
return (char*)res->GetRawPointer();
}
extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) {
auto res = std::static_pointer_cast<LUS::Texture>(GetResourceByNameHandlingMQ(texPath));
return res->Flags & TEX_FLAG_LOAD_AS_RAW;
}
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
auto res = GetResourceByNameHandlingMQ(texPath);
return res->GetInitData()->Type == static_cast<uint32_t>(SOH::ResourceType::SOH_Background);
}
extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize)
{
static char* finalBuffer = 0;
if (finalBuffer == 0)
finalBuffer = (char*)malloc(dataSize);
int w;
int h;
int comp;
unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 320 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
//unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 480 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
int idx = 0;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
uint16_t* bufferTest = (uint16_t*)finalBuffer;
int pixelIdx = ((y * w) + x) * 4;
uint8_t r = pixels[pixelIdx + 0] / 8;
uint8_t g = pixels[pixelIdx + 1] / 8;
uint8_t b = pixels[pixelIdx + 2] / 8;
uint8_t alphaBit = pixels[pixelIdx + 3] != 0;
uint16_t data = (r << 11) + (g << 6) + (b << 1) + alphaBit;
finalBuffer[idx++] = (data & 0xFF00) >> 8;
finalBuffer[idx++] = (data & 0x00FF);
}
}
return (char*)finalBuffer;
}
extern "C" uint16_t ResourceMgr_LoadTexWidthByName(char* texPath);
extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
auto res = GetResourceByNameHandlingMQ(filePath);
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
else if (res->GetInitData()->Type == static_cast<uint32_t>(SOH::ResourceType::SOH_Array))
return (char*)(std::static_pointer_cast<SOH::Array>(res))->Vertices.data();
else {
return (char*)GetResourceDataByNameHandlingMQ(filePath);
}
}
extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
auto res = GetResourceByNameHandlingMQ(filePath);
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
return nullptr;
}
extern "C" Sprite* GetSeedTexture(uint8_t index) { extern "C" Sprite* GetSeedTexture(uint8_t index) {
return OTRGlobals::Instance->gRandoContext->GetSeedTexture(index); return OTRGlobals::Instance->gRandoContext->GetSeedTexture(index);
} }
@ -1748,157 +1475,6 @@ extern "C" uint8_t GetSeedIconIndex(uint8_t index) {
return OTRGlobals::Instance->gRandoContext->hashIconIndexes[index]; return OTRGlobals::Instance->gRandoContext->hashIconIndexes[index];
} }
extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) {
auto anim = std::static_pointer_cast<SOH::PlayerAnimation>(GetResourceByNameHandlingMQ(animPath));
return (char*)&anim->limbRotData[0];
}
extern "C" void ResourceMgr_PushCurrentDirectory(char* path)
{
gfx_push_current_dir(path);
}
extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path)
{
// When an alt resource exists for the DL, we need to unload the original asset
// to clear the cache so the alt asset will be loaded instead
// OTRTODO: If Alt loading over original cache is fixed, this line can most likely be removed
ResourceMgr_UnloadOriginalWhenAltExists(path);
auto res = std::static_pointer_cast<LUS::DisplayList>(GetResourceByNameHandlingMQ(path));
return (Gfx*)&res->Instructions[0];
}
extern "C" uint8_t ResourceMgr_FileIsCustomByName(const char* path) {
auto res = std::static_pointer_cast<LUS::DisplayList>(GetResourceByNameHandlingMQ(path));
return res->GetInitData()->IsCustom;
}
typedef struct {
int index;
Gfx instruction;
} GfxPatch;
std::unordered_map<std::string, std::unordered_map<std::string, GfxPatch>> originalGfx;
// Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be using OTRs
// instead (When that is available). Index can be found using the commented out section below.
extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
// Leaving this here for people attempting to find the correct Dlist index to patch
/*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) {
for (int i = 0; i < res->instructions.size(); i++) {
Gfx* gfx = (Gfx*)&res->instructions[i];
// Log all commands
// SPDLOG_INFO("index:{} command:{}", i, gfx->words.w0 >> 24);
// Log only SetPrimColors
if (gfx->words.w0 >> 24 == 250) {
SPDLOG_INFO("index:{} r:{} g:{} b:{} a:{}", i, _SHIFTR(gfx->words.w1, 24, 8), _SHIFTR(gfx->words.w1, 16, 8), _SHIFTR(gfx->words.w1, 8, 8), _SHIFTR(gfx->words.w1, 0, 8));
}
}
}*/
// Index refers to individual gfx words, which are half the size on 32-bit
// if (sizeof(uintptr_t) < 8) {
// index /= 2;
// }
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
if (res->GetInitData()->IsCustom) {
return;
}
Gfx* gfx = (Gfx*)&res->Instructions[index];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
index,
*gfx
};
}
*gfx = instruction;
}
extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
if (res->GetInitData()->IsCustom) {
return;
}
Gfx* destinationGfx = (Gfx*)&res->Instructions[destinationIndex];
Gfx sourceGfx = *(Gfx*)&res->Instructions[sourceIndex];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
destinationIndex,
*destinationGfx
};
}
*destinationGfx = sourceGfx;
}
extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) {
if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index];
*gfx = originalGfx[path][patchName].instruction;
originalGfx[path].erase(patchName);
}
}
extern "C" char* ResourceMgr_LoadArrayByName(const char* path)
{
auto res = std::static_pointer_cast<SOH::Array>(GetResourceByNameHandlingMQ(path));
return (char*)res->Scalars.data();
}
// Return of LoadArrayByNameAsVec3s must be freed by the caller
extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
auto res = std::static_pointer_cast<SOH::Array>(GetResourceByNameHandlingMQ(path));
// if (res->CachedGameAsset != nullptr)
// return (char*)res->CachedGameAsset;
// else
// {
Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->Scalars.size());
for (size_t i = 0; i < res->Scalars.size(); i += 3) {
data[(i / 3)].x = res->Scalars[i + 0].s16;
data[(i / 3)].y = res->Scalars[i + 1].s16;
data[(i / 3)].z = res->Scalars[i + 2].s16;
}
// res->CachedGameAsset = data;
return (char*)data;
// }
}
extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) {
return (CollisionHeader*) ResourceGetDataByName(path);
}
extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
return (Vtx*) ResourceGetDataByName(path);
}
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*) ResourceGetDataByName(path);
return *sequence;
}
std::map<std::string, SoundFontSample*> cachedCustomSFs; std::map<std::string, SoundFontSample*> cachedCustomSFs;
extern "C" SoundFontSample* ReadCustomSample(const char* path) { extern "C" SoundFontSample* ReadCustomSample(const char* path) {
@ -1959,81 +1535,6 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) {
*/ */
} }
extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) {
return (SoundFontSample*) ResourceGetDataByName(path);
}
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) {
return (SoundFont*) ResourceGetDataByName(path);
}
extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
{
uintptr_t i = (uintptr_t)(imgData);
// if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1)
if ((i & 1) == 1)
return 0;
// if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) {
if (i != 0) {
if (imgData[0] == '_' && imgData[1] == '_' && imgData[2] == 'O' && imgData[3] == 'T' && imgData[4] == 'R' &&
imgData[5] == '_' && imgData[6] == '_')
return 1;
}
return 0;
}
extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
return (AnimationHeaderCommon*) ResourceGetDataByName(path);
}
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) {
std::string pathStr = std::string(path);
static const std::string sOtr = "__OTR__";
if (pathStr.starts_with(sOtr)) {
pathStr = pathStr.substr(sOtr.length());
}
bool isAlt = ResourceMgr_IsAltAssetsEnabled();
if (isAlt) {
pathStr = Ship::IResource::gAltAssetPrefix + pathStr;
}
SkeletonHeader* skelHeader = (SkeletonHeader*) ResourceGetDataByName(pathStr.c_str());
// If there isn't an alternate model, load the regular one
if (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*) ResourceGetDataByName(path);
}
// This function is only called when a skeleton is initialized.
// Therefore we can take this oppurtunity to take note of the Skeleton that is created...
if (skelAnime != nullptr) {
auto stringPath = std::string(path);
SOH::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
}
return skelHeader;
}
extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) {
if (skelAnime != nullptr)
SOH::SkeletonPatcher::UnregisterSkeleton(skelAnime);
}
extern "C" void ResourceMgr_ClearSkeletons(SkelAnime* skelAnime) {
if (skelAnime != nullptr)
SOH::SkeletonPatcher::ClearSkeletons();
}
extern "C" s32* ResourceMgr_LoadCSByName(const char* path) {
return (s32*)GetResourceDataByNameHandlingMQ(path);
}
std::filesystem::path GetSaveFile(std::shared_ptr<Ship::Config> Conf) { std::filesystem::path GetSaveFile(std::shared_ptr<Ship::Config> Conf) {
const std::string fileName = Conf->GetString("Game.SaveName", Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav")); const std::string fileName = Conf->GetString("Game.SaveName", Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav"));
std::filesystem::path saveFile = std::filesystem::absolute(fileName); std::filesystem::path saveFile = std::filesystem::absolute(fileName);
@ -2884,7 +2385,7 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) {
} }
if (ResourceMgr_OTRSigCheck(imgName)) { if (ResourceMgr_OTRSigCheck(imgName)) {
texAddr = (const uint8_t*)GetResourceDataByNameHandlingMQ(imgName); texAddr = (const uint8_t*)ResourceMgr_GetResourceDataByNameHandlingMQ(imgName);
} }
gfx_texture_cache_delete(texAddr); gfx_texture_cache_delete(texAddr);

View File

@ -3,15 +3,6 @@
#pragma once #pragma once
#include "SaveManager.h"
#include <soh/Enhancements/item-tables/ItemTableTypes.h>
#define GAME_REGION_NTSC 0
#define GAME_REGION_PAL 1
#define GAME_PLATFORM_N64 0
#define GAME_PLATFORM_GC 1
#define BTN_CUSTOM_MODIFIER1 0x0040 #define BTN_CUSTOM_MODIFIER1 0x0040
#define BTN_CUSTOM_MODIFIER2 0x0080 #define BTN_CUSTOM_MODIFIER2 0x0080
@ -29,6 +20,14 @@
#include "Enhancements/savestates.h" #include "Enhancements/savestates.h"
#include "Enhancements/randomizer/randomizer.h" #include "Enhancements/randomizer/randomizer.h"
#include <vector> #include <vector>
#include <string>
struct ExtensionEntry {
std::string path;
std::string ext;
};
extern std::unordered_map<std::string, ExtensionEntry> ExtensionCache;
#include "Enhancements/randomizer/context.h" #include "Enhancements/randomizer/context.h"
const std::string customMessageTableID = "BaseGameOverrides"; const std::string customMessageTableID = "BaseGameOverrides";
@ -42,8 +41,7 @@ const uint32_t defaultImGuiScale = 1;
const float imguiScaleOptionToValue[4] = { 0.75f, 1.0f, 1.5f, 2.0f }; const float imguiScaleOptionToValue[4] = { 0.75f, 1.0f, 1.5f, 2.0f };
class OTRGlobals class OTRGlobals {
{
public: public:
static OTRGlobals* Instance; static OTRGlobals* Instance;
@ -72,28 +70,8 @@ private:
bool hasOriginal; bool hasOriginal;
ImFont* CreateDefaultFontWithSize(float size); ImFont* CreateDefaultFontWithSize(float size);
}; };
uint32_t IsGameMasterQuest();
#endif #endif
#define CVAR_RANDOMIZER_ENHANCEMENT(var) CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "." var
#define CVAR_RANDOMIZER_SETTING(var) CVAR_PREFIX_RANDOMIZER_SETTING "." var
#define CVAR_COSMETIC(var) CVAR_PREFIX_COSMETIC "." var
#define CVAR_AUDIO(var) CVAR_PREFIX_AUDIO "." var
#define CVAR_CHEAT(var) CVAR_PREFIX_CHEAT "." var
#define CVAR_ENHANCEMENT(var) CVAR_PREFIX_ENHANCEMENT "." var
#define CVAR_SETTING(var) CVAR_PREFIX_SETTING "." var
#define CVAR_WINDOW(var) CVAR_PREFIX_WINDOW "." var
#define CVAR_TRACKER(var) CVAR_PREFIX_TRACKER "." var
#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER(".ItemTracker." var)
#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER(".CheckTracker." var)
#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER(".EntranceTracker." var)
#define CVAR_DEVELOPER_TOOLS(var) CVAR_PREFIX_DEVELOPER_TOOLS "." var
#define CVAR_GENERAL(var) CVAR_PREFIX_GENERAL "." var
#define CVAR_REMOTE(var) CVAR_PREFIX_REMOTE "." var
#define CVAR_REMOTE_CROWD_CONTROL(var) CVAR_REMOTE(".CrowdControl." var)
#define CVAR_REMOTE_SAIL(var) CVAR_REMOTE(".Sail." var)
#ifndef __cplusplus #ifndef __cplusplus
void InitOTR(void); void InitOTR(void);
void DeinitOTR(void); void DeinitOTR(void);
@ -109,53 +87,12 @@ void OTRGfxPrint(const char* str, void* printer, void (*printImpl)(void*, char))
void OTRGetPixelDepthPrepare(float x, float y); void OTRGetPixelDepthPrepare(float x, float y);
uint16_t OTRGetPixelDepth(float x, float y); uint16_t OTRGetPixelDepth(float x, float y);
int32_t OTRGetLastScancode(); int32_t OTRGetLastScancode();
uint32_t ResourceMgr_IsGameMasterQuest();
uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
uint32_t ResourceMgr_GameHasMasterQuest();
uint32_t ResourceMgr_GameHasOriginal();
uint32_t ResourceMgr_GetNumGameVersions();
uint32_t ResourceMgr_GetGameVersion(int index);
uint32_t ResourceMgr_GetGamePlatform(int index);
uint32_t ResourceMgr_GetGameRegion(int index);
void ResourceMgr_LoadDirectory(const char* resName);
void ResourceMgr_UnloadResource(const char* resName);
char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize);
uint8_t ResourceMgr_FileExists(const char* resName);
uint8_t ResourceMgr_FileAltExists(const char* resName);
void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName);
char* GetResourceDataByNameHandlingMQ(const char* path); char* GetResourceDataByNameHandlingMQ(const char* path);
uint8_t ResourceMgr_TexIsRaw(const char* texPath);
uint8_t ResourceMgr_ResourceIsBackground(char* texPath);
char* ResourceMgr_LoadJPEG(char* data, size_t dataSize);
uint16_t ResourceMgr_LoadTexWidthByName(char* texPath);
uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
char* ResourceMgr_LoadTexOrDListByName(const char* filePath);
char* ResourceMgr_LoadPlayerAnimByName(const char* animPath);
AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path);
char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc);
Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc);
Gfx* ResourceMgr_LoadGfxByName(const char* path);
uint8_t ResourceMgr_FileIsCustomByName(const char* path);
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path);
Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc);
Vtx* ResourceMgr_LoadVtxByName(char* path);
SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path);
SequenceData ResourceMgr_LoadSeqByName(const char* path);
SoundFontSample* ResourceMgr_LoadAudioSample(const char* path);
CollisionHeader* ResourceMgr_LoadColByName(const char* path);
void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size); void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size);
void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size); void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size);
uint64_t GetPerfCounter(); uint64_t GetPerfCounter();
bool ResourceMgr_IsAltAssetsEnabled();
struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime);
void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime);
void ResourceMgr_ClearSkeletons();
s32* ResourceMgr_LoadCSByName(const char* path);
int ResourceMgr_OTRSigCheck(char* imgData);
uint64_t osGetTime(void); uint64_t osGetTime(void);
uint32_t osGetCount(void); uint32_t osGetCount(void);
uint32_t OTRGetCurrentWidth(void); uint32_t OTRGetCurrentWidth(void);

View File

@ -0,0 +1,505 @@
#include "ResourceManagerHelpers.h"
#include "OTRGlobals.h"
#include "variables.h"
#include "z64.h"
#include "cvar_prefixes.h"
#include "Enhancements/enhancementTypes.h"
#include "Enhancements/randomizer/dungeon.h"
#include <libultraship/libultraship.h>
#include <GameVersions.h>
#include "resource/type/SohResourceType.h"
#include "resource/type/Array.h"
#include "resource/type/Skeleton.h"
#include "resource/type/PlayerAnimation.h"
#include <Fast3D/gfx_pc.h>
#include <DisplayList.h>
extern "C" PlayState* gPlayState;
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size();
}
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
}
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
case OOT_NTSC_US_11:
case OOT_NTSC_US_12:
case OOT_PAL_10:
case OOT_PAL_11:
return GAME_PLATFORM_N64;
case OOT_NTSC_JP_GC:
case OOT_NTSC_US_GC:
case OOT_PAL_GC:
case OOT_NTSC_JP_MQ:
case OOT_NTSC_US_MQ:
case OOT_PAL_MQ:
case OOT_PAL_GC_DBG1:
case OOT_PAL_GC_DBG2:
case OOT_PAL_GC_MQ_DBG:
return GAME_PLATFORM_GC;
}
}
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
case OOT_NTSC_US_11:
case OOT_NTSC_US_12:
case OOT_NTSC_JP_GC:
case OOT_NTSC_US_GC:
case OOT_NTSC_JP_MQ:
case OOT_NTSC_US_MQ:
return GAME_REGION_NTSC;
case OOT_PAL_10:
case OOT_PAL_11:
case OOT_PAL_GC:
case OOT_PAL_MQ:
case OOT_PAL_GC_DBG1:
case OOT_PAL_GC_DBG2:
case OOT_PAL_GC_MQ_DBG:
return GAME_REGION_PAL;
}
}
u32 IsSceneMasterQuest(s16 sceneNum) {
u8 mqMode = CVarGetInteger(CVAR_GENERAL("BetterDebugWarpScreenMQMode"), WARP_MODE_OVERRIDE_OFF);
if (mqMode == WARP_MODE_OVERRIDE_MQ_AS_VANILLA) {
return true;
}
if (mqMode == WARP_MODE_OVERRIDE_VANILLA_AS_MQ) {
return false;
}
if (OTRGlobals::Instance->HasMasterQuest()) {
if (!OTRGlobals::Instance->HasOriginal()) {
return true;
}
if (IS_MASTER_QUEST) {
return true;
}
if (IS_RANDO) {
auto dungeon = OTRGlobals::Instance->gRandoContext->GetDungeons()->GetDungeonFromScene(sceneNum);
if (dungeon != nullptr && dungeon->IsMQ()) {
return true;
}
}
}
return false;
}
extern "C" uint32_t ResourceMgr_GameHasMasterQuest() {
return OTRGlobals::Instance->HasMasterQuest();
}
extern "C" uint32_t ResourceMgr_GameHasOriginal() {
return OTRGlobals::Instance->HasOriginal();
}
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum) {
return IsSceneMasterQuest(sceneNum);
}
extern "C" uint32_t ResourceMgr_IsGameMasterQuest() {
return gPlayState != NULL ? IsSceneMasterQuest(gPlayState->sceneNum) : 0;
}
extern "C" void ResourceMgr_LoadDirectory(const char* resName) {
Ship::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName);
}
extern "C" void ResourceMgr_DirtyDirectory(const char* resName) {
Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName);
}
extern "C" void ResourceMgr_UnloadResource(const char* resName) {
std::string path = resName;
if (path.substr(0, 7) == "__OTR__") {
path = path.substr(7);
}
auto res = Ship::Context::GetInstance()->GetResourceManager()->UnloadResource(path);
}
// OTRTODO: There is probably a more elegant way to go about this...
// Kenix: This is definitely leaking memory when it's called.
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
auto lst = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask);
char** result = (char**)malloc(lst->size() * sizeof(char*));
for (size_t i = 0; i < lst->size(); i++) {
char* str = (char*)malloc(lst.get()[0][i].size() + 1);
memcpy(str, lst.get()[0][i].data(), lst.get()[0][i].size());
str[lst.get()[0][i].size()] = '\0';
result[i] = str;
}
*resultSize = lst->size();
return result;
}
extern "C" uint8_t ResourceMgr_FileExists(const char* filePath) {
std::string path = filePath;
if(path.substr(0, 7) == "__OTR__"){
path = path.substr(7);
}
return ExtensionCache.contains(path);
}
extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) {
std::string path = filePath;
if (path.substr(0, 7) == "__OTR__") {
path = path.substr(7);
}
if (path.substr(0, 4) != "alt/") {
path = "alt/" + path;
}
return ExtensionCache.contains(path);
}
extern "C" bool ResourceMgr_IsAltAssetsEnabled() {
return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled();
}
// Unloads a resource if an alternate version exists when alt assets are enabled
// The resource is only removed from the internal cache to prevent it from used in the next resource lookup
extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) {
if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*)resName)) {
ResourceMgr_UnloadResource((char*) resName);
}
}
std::shared_ptr<Ship::IResource> ResourceMgr_GetResourceByNameHandlingMQ(const char* path) {
std::string Path = path;
if (ResourceMgr_IsGameMasterQuest()) {
size_t pos = 0;
if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) {
Path.replace(pos, 7, "/mq/");
}
}
return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str());
}
extern "C" char* ResourceMgr_GetResourceDataByNameHandlingMQ(const char* path) {
auto res = ResourceMgr_GetResourceByNameHandlingMQ(path);
if (res == nullptr) {
return nullptr;
}
return (char*)res->GetRawPointer();
}
extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) {
auto res = std::static_pointer_cast<LUS::Texture>(ResourceMgr_GetResourceByNameHandlingMQ(texPath));
return res->Flags & TEX_FLAG_LOAD_AS_RAW;
}
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
auto res = ResourceMgr_GetResourceByNameHandlingMQ(texPath);
return res->GetInitData()->Type == static_cast<uint32_t>(SOH::ResourceType::SOH_Background);
}
extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) {
static char* finalBuffer = 0;
if (finalBuffer == 0) {
finalBuffer = (char*)malloc(dataSize);
}
int w;
int h;
int comp;
unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 320 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
//unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 480 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
int idx = 0;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
uint16_t* bufferTest = (uint16_t*)finalBuffer;
int pixelIdx = ((y * w) + x) * 4;
uint8_t r = pixels[pixelIdx + 0] / 8;
uint8_t g = pixels[pixelIdx + 1] / 8;
uint8_t b = pixels[pixelIdx + 2] / 8;
uint8_t alphaBit = pixels[pixelIdx + 3] != 0;
uint16_t data = (r << 11) + (g << 6) + (b << 1) + alphaBit;
finalBuffer[idx++] = (data & 0xFF00) >> 8;
finalBuffer[idx++] = (data & 0x00FF);
}
}
return (char*)finalBuffer;
}
extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
auto res = ResourceMgr_GetResourceByNameHandlingMQ(filePath);
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList)) {
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
}
if (res->GetInitData()->Type == static_cast<uint32_t>(SOH::ResourceType::SOH_Array)) {
return (char*)(std::static_pointer_cast<SOH::Array>(res))->Vertices.data();
}
return (char*)ResourceMgr_GetResourceDataByNameHandlingMQ(filePath);
}
extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
auto res = ResourceMgr_GetResourceByNameHandlingMQ(filePath);
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList)) {
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
}
return nullptr;
}
extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) {
auto anim = std::static_pointer_cast<SOH::PlayerAnimation>(ResourceMgr_GetResourceByNameHandlingMQ(animPath));
return (char*)&anim->limbRotData[0];
}
extern "C" void ResourceMgr_PushCurrentDirectory(char* path) {
gfx_push_current_dir(path);
}
extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) {
// When an alt resource exists for the DL, we need to unload the original asset
// to clear the cache so the alt asset will be loaded instead
// OTRTODO: If Alt loading over original cache is fixed, this line can most likely be removed
ResourceMgr_UnloadOriginalWhenAltExists(path);
auto res = std::static_pointer_cast<LUS::DisplayList>(ResourceMgr_GetResourceByNameHandlingMQ(path));
return (Gfx*)&res->Instructions[0];
}
extern "C" uint8_t ResourceMgr_FileIsCustomByName(const char* path) {
auto res = std::static_pointer_cast<LUS::DisplayList>(ResourceMgr_GetResourceByNameHandlingMQ(path));
return res->GetInitData()->IsCustom;
}
typedef struct {
int index;
Gfx instruction;
} GfxPatch;
std::unordered_map<std::string, std::unordered_map<std::string, GfxPatch>> originalGfx;
// Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be using OTRs
// instead (When that is available). Index can be found using the commented out section below.
extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
// Leaving this here for people attempting to find the correct Dlist index to patch
/*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) {
for (int i = 0; i < res->instructions.size(); i++) {
Gfx* gfx = (Gfx*)&res->instructions[i];
// Log all commands
// SPDLOG_INFO("index:{} command:{}", i, gfx->words.w0 >> 24);
// Log only SetPrimColors
if (gfx->words.w0 >> 24 == 250) {
SPDLOG_INFO("index:{} r:{} g:{} b:{} a:{}", i, _SHIFTR(gfx->words.w1, 24, 8), _SHIFTR(gfx->words.w1, 16, 8), _SHIFTR(gfx->words.w1, 8, 8), _SHIFTR(gfx->words.w1, 0, 8));
}
}
}*/
// Index refers to individual gfx words, which are half the size on 32-bit
// if (sizeof(uintptr_t) < 8) {
// index /= 2;
// }
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
if (res->GetInitData()->IsCustom) {
return;
}
Gfx* gfx = (Gfx*)&res->Instructions[index];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
index,
*gfx
};
}
*gfx = instruction;
}
extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
// Do not patch custom assets as they most likely do not have the same instructions as authentic assets
if (res->GetInitData()->IsCustom) {
return;
}
Gfx* destinationGfx = (Gfx*)&res->Instructions[destinationIndex];
Gfx sourceGfx = *(Gfx*)&res->Instructions[sourceIndex];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
destinationIndex,
*destinationGfx
};
}
*destinationGfx = sourceGfx;
}
extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) {
if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) {
auto res = std::static_pointer_cast<LUS::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index];
*gfx = originalGfx[path][patchName].instruction;
originalGfx[path].erase(patchName);
}
}
extern "C" char* ResourceMgr_LoadArrayByName(const char* path) {
auto res = std::static_pointer_cast<SOH::Array>(ResourceMgr_GetResourceByNameHandlingMQ(path));
return (char*)res->Scalars.data();
}
// Return of LoadArrayByNameAsVec3s must be freed by the caller
extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
auto res = std::static_pointer_cast<SOH::Array>(ResourceMgr_GetResourceByNameHandlingMQ(path));
// if (res->CachedGameAsset != nullptr)
// return (char*)res->CachedGameAsset;
// else
// {
Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->Scalars.size());
for (size_t i = 0; i < res->Scalars.size(); i += 3) {
data[(i / 3)].x = res->Scalars[i + 0].s16;
data[(i / 3)].y = res->Scalars[i + 1].s16;
data[(i / 3)].z = res->Scalars[i + 2].s16;
}
// res->CachedGameAsset = data;
return (char*)data;
// }
}
extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) {
return (CollisionHeader*) ResourceGetDataByName(path);
}
extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
return (Vtx*) ResourceGetDataByName(path);
}
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*) ResourceGetDataByName(path);
return *sequence;
}
extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) {
return (SoundFontSample*) ResourceGetDataByName(path);
}
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) {
return (SoundFont*) ResourceGetDataByName(path);
}
extern "C" int ResourceMgr_OTRSigCheck(char* imgData) {
uintptr_t i = (uintptr_t)(imgData);
// if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1)
if ((i & 1) == 1)
return 0;
// if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) {
if (i != 0) {
if (
imgData[0] == '_' &&
imgData[1] == '_' &&
imgData[2] == 'O' &&
imgData[3] == 'T' &&
imgData[4] == 'R' &&
imgData[5] == '_' &&
imgData[6] == '_'
) {
return 1;
}
}
return 0;
}
extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
return (AnimationHeaderCommon*) ResourceGetDataByName(path);
}
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) {
std::string pathStr = std::string(path);
static const std::string sOtr = "__OTR__";
if (pathStr.starts_with(sOtr)) {
pathStr = pathStr.substr(sOtr.length());
}
bool isAlt = ResourceMgr_IsAltAssetsEnabled();
if (isAlt) {
pathStr = Ship::IResource::gAltAssetPrefix + pathStr;
}
SkeletonHeader* skelHeader = (SkeletonHeader*) ResourceGetDataByName(pathStr.c_str());
// If there isn't an alternate model, load the regular one
if (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*) ResourceGetDataByName(path);
}
// This function is only called when a skeleton is initialized.
// Therefore we can take this oppurtunity to take note of the Skeleton that is created...
if (skelAnime != nullptr) {
auto stringPath = std::string(path);
SOH::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
}
return skelHeader;
}
extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) {
if (skelAnime != nullptr) {
SOH::SkeletonPatcher::UnregisterSkeleton(skelAnime);
}
}
extern "C" void ResourceMgr_ClearSkeletons() {
SOH::SkeletonPatcher::ClearSkeletons();
}
extern "C" s32* ResourceMgr_LoadCSByName(const char* path) {
return (s32*)ResourceMgr_GetResourceDataByNameHandlingMQ(path);
}

View File

@ -0,0 +1,66 @@
#pragma once
#include "libultraship/libultra/types.h"
#define GAME_REGION_NTSC 0
#define GAME_REGION_PAL 1
#define GAME_PLATFORM_N64 0
#define GAME_PLATFORM_GC 1
#ifdef __cplusplus
#include <memory>
#include <Resource.h>
std::shared_ptr<Ship::IResource> ResourceMgr_GetResourceByNameHandlingMQ(const char* path);
extern "C" {
#endif // __cplusplus
#include "z64animation.h"
#include "z64audio.h"
#include "z64bgcheck.h"
uint32_t ResourceMgr_IsGameMasterQuest();
uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
uint32_t ResourceMgr_GameHasMasterQuest();
uint32_t ResourceMgr_GameHasOriginal();
uint32_t ResourceMgr_GetNumGameVersions();
uint32_t ResourceMgr_GetGameVersion(int index);
uint32_t ResourceMgr_GetGamePlatform(int index);
uint32_t ResourceMgr_GetGameRegion(int index);
void ResourceMgr_LoadDirectory(const char* resName);
void ResourceMgr_UnloadResource(const char* resName);
char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize);
uint8_t ResourceMgr_FileExists(const char* resName);
uint8_t ResourceMgr_FileAltExists(const char* resName);
void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName);
uint8_t ResourceMgr_TexIsRaw(const char* texPath);
uint8_t ResourceMgr_ResourceIsBackground(char* texPath);
char* ResourceMgr_LoadJPEG(char* data, size_t dataSize);
uint16_t ResourceMgr_LoadTexWidthByName(char* texPath);
uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
char* ResourceMgr_LoadTexOrDListByName(const char* filePath);
char* ResourceMgr_LoadPlayerAnimByName(const char* animPath);
AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path);
char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc);
Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc);
Gfx* ResourceMgr_LoadGfxByName(const char* path);
uint8_t ResourceMgr_FileIsCustomByName(const char* path);
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path);
Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc);
Vtx* ResourceMgr_LoadVtxByName(char* path);
SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path);
SequenceData ResourceMgr_LoadSeqByName(const char* path);
SoundFontSample* ResourceMgr_LoadAudioSample(const char* path);
CollisionHeader* ResourceMgr_LoadColByName(const char* path);
bool ResourceMgr_IsAltAssetsEnabled();
SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime);
void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime);
void ResourceMgr_ClearSkeletons();
s32* ResourceMgr_LoadCSByName(const char* path);
int ResourceMgr_OTRSigCheck(char* imgData);
char* ResourceMgr_GetResourceDataByNameHandlingMQ(const char* path);
#ifdef __cplusplus
}
#endif // __cplusplus

View File

@ -10,6 +10,7 @@
#include "Enhancements/randomizer/item.h" #include "Enhancements/randomizer/item.h"
#include "z64.h" #include "z64.h"
#include "cvar_prefixes.h"
#include "functions.h" #include "functions.h"
#include "macros.h" #include "macros.h"
#include <variables.h> #include <variables.h>

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <libultraship/libultra/gbi.h> #include <libultraship/libultra/gbi.h>
#include "z64save.h"
#define SECTION_PARENT_NONE -1 #define SECTION_PARENT_NONE -1
typedef struct { typedef struct {
@ -45,8 +46,6 @@ typedef struct {
#define BS_THREAD_POOL_ENABLE_PAUSE #define BS_THREAD_POOL_ENABLE_PAUSE
#include <BS_thread_pool.hpp> #include <BS_thread_pool.hpp>
#include "z64save.h"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
class SaveManager { class SaveManager {

View File

@ -10,7 +10,9 @@
#include "include/z64audio.h" #include "include/z64audio.h"
#include "graphic/Fast3D/gfx_rendering_api.h" #include "graphic/Fast3D/gfx_rendering_api.h"
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include "SaveManager.h"
#include "z64.h" #include "z64.h"
#include "cvar_prefixes.h"
#include "macros.h" #include "macros.h"
#include "Enhancements/game-interactor/GameInteractor.h" #include "Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/presets.h" #include "soh/Enhancements/presets.h"

17
soh/soh/cvar_prefixes.h Normal file
View File

@ -0,0 +1,17 @@
#define CVAR_RANDOMIZER_ENHANCEMENT(var) CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "." var
#define CVAR_RANDOMIZER_SETTING(var) CVAR_PREFIX_RANDOMIZER_SETTING "." var
#define CVAR_COSMETIC(var) CVAR_PREFIX_COSMETIC "." var
#define CVAR_AUDIO(var) CVAR_PREFIX_AUDIO "." var
#define CVAR_CHEAT(var) CVAR_PREFIX_CHEAT "." var
#define CVAR_ENHANCEMENT(var) CVAR_PREFIX_ENHANCEMENT "." var
#define CVAR_SETTING(var) CVAR_PREFIX_SETTING "." var
#define CVAR_WINDOW(var) CVAR_PREFIX_WINDOW "." var
#define CVAR_TRACKER(var) CVAR_PREFIX_TRACKER "." var
#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER(".ItemTracker." var)
#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER(".CheckTracker." var)
#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER(".EntranceTracker." var)
#define CVAR_DEVELOPER_TOOLS(var) CVAR_PREFIX_DEVELOPER_TOOLS "." var
#define CVAR_GENERAL(var) CVAR_PREFIX_GENERAL "." var
#define CVAR_REMOTE(var) CVAR_PREFIX_REMOTE "." var
#define CVAR_REMOTE_CROWD_CONTROL(var) CVAR_REMOTE(".CrowdControl." var)
#define CVAR_REMOTE_SAIL(var) CVAR_REMOTE(".Sail." var)

View File

@ -1,5 +1,6 @@
#include "Resource.h" #include "Resource.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
namespace SOH { namespace SOH {
void LogPathAsXML(std::shared_ptr<Ship::IResource> resource); void LogPathAsXML(std::shared_ptr<Ship::IResource> resource);

View File

@ -1,5 +1,6 @@
#include "Resource.h" #include "Resource.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
namespace SOH { namespace SOH {

View File

@ -1,4 +1,5 @@
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include "ResourceManagerHelpers.h"
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h" #include "soh/resource/type/Scene.h"
#include <utils/StringHelper.h> #include <utils/StringHelper.h>
@ -35,7 +36,7 @@ extern "C" void OTRPlay_SpawnScene(PlayState* play, s32 sceneId, s32 spawn) {
std::string sceneVersion = "shared"; std::string sceneVersion = "shared";
if (inNonSharedScene) { if (inNonSharedScene) {
sceneVersion = IsGameMasterQuest() ? "mq" : "nonmq"; sceneVersion = ResourceMgr_IsGameMasterQuest() ? "mq" : "nonmq";
} }
std::string scenePath = StringHelper::Sprintf("scenes/%s/%s/%s", sceneVersion.c_str(), scene->sceneFile.fileName, scene->sceneFile.fileName); std::string scenePath = StringHelper::Sprintf("scenes/%s/%s/%s", sceneVersion.c_str(), scene->sceneFile.fileName, scene->sceneFile.fileName);

View File

@ -1,4 +1,5 @@
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include "ResourceManagerHelpers.h"
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h" #include "soh/resource/type/Scene.h"
#include <utils/StringHelper.h> #include <utils/StringHelper.h>
@ -39,9 +40,6 @@ extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId);
extern "C" RomFile sNaviMsgFiles[]; extern "C" RomFile sNaviMsgFiles[];
s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene);
// Forward Declaration of function declared in OTRGlobals.cpp
std::shared_ptr<Ship::IResource> GetResourceByNameHandlingMQ(const char* path);
bool Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) { bool Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) {
// SOH::SetStartPositionList* cmdStartPos = std::static_pointer_cast<SOH::SetStartPositionList>(cmd); // SOH::SetStartPositionList* cmdStartPos = std::static_pointer_cast<SOH::SetStartPositionList>(cmd);
SOH::SetStartPositionList* cmdStartPos = (SOH::SetStartPositionList*)cmd; SOH::SetStartPositionList* cmdStartPos = (SOH::SetStartPositionList*)cmd;
@ -512,7 +510,7 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN
//&roomCtx->loadQueue, NULL, __FILE__, __LINE__); //&roomCtx->loadQueue, NULL, __FILE__, __LINE__);
auto roomData = auto roomData =
std::static_pointer_cast<SOH::Scene>(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); std::static_pointer_cast<SOH::Scene>(ResourceMgr_GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName));
roomCtx->status = 1; roomCtx->status = 1;
roomCtx->roomToLoad = roomData.get(); roomCtx->roomToLoad = roomData.get();

View File

@ -7,6 +7,7 @@
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/Enhancements/audio/AudioCollection.h" #include "soh/Enhancements/audio/AudioCollection.h"
#include "soh/Enhancements/audio/AudioEditor.h" #include "soh/Enhancements/audio/AudioEditor.h"
#include "soh/ResourceManagerHelpers.h"
#define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status)) #define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status))
#define ASYNC_TBLTYPE(v) ((u8)(v >> 16)) #define ASYNC_TBLTYPE(v) ((u8)(v >> 16))

View File

@ -1,4 +1,5 @@
#include "global.h" #include "global.h"
#include "soh/ResourceManagerHelpers.h"
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
extern bool gUseLegacySD; extern bool gUseLegacySD;

View File

@ -4,6 +4,7 @@
#include "global.h" #include "global.h"
#include "soh/Enhancements/audio/AudioEditor.h" #include "soh/Enhancements/audio/AudioEditor.h"
#include "soh/ResourceManagerHelpers.h"
extern char** sequenceMap; extern char** sequenceMap;

View File

@ -1,5 +1,6 @@
#include <libultraship/libultra.h> #include <libultraship/libultra.h>
#include "global.h" #include "global.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/audio/AudioEditor.h" #include "soh/Enhancements/audio/AudioEditor.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

View File

@ -4,6 +4,7 @@
#include "libultraship/bridge.h" #include "libultraship/bridge.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ResourceManagerHelpers.h"
SpeedMeter D_801664D0; SpeedMeter D_801664D0;
VisCvg sVisCvg; VisCvg sVisCvg;

View File

@ -1,5 +1,7 @@
#include "global.h" #include "global.h"
#include "align_asset_macro.h" #include "align_asset_macro.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
u16 sGfxPrintFontTLUT[64] = { u16 sGfxPrintFontTLUT[64] = {
0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000,

View File

@ -3,6 +3,8 @@
#include <string.h> #include <string.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
s32 D_8012D280 = 1; s32 D_8012D280 = 1;

View File

@ -13,6 +13,7 @@
#include "soh/Enhancements/nametag.h" #include "soh/Enhancements/nametag.h"
#include "soh/ActorDB.h" #include "soh/ActorDB.h"
#include "soh/OTRGlobals.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,8 @@
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
#include <soh/OTRGlobals.h> #include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include <assert.h> #include <assert.h>
#define SS_NULL 0xFFFF #define SS_NULL 0xFFFF

View File

@ -1,4 +1,5 @@
#include "global.h" #include "global.h"
#include "soh/ResourceManagerHelpers.h"
void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) { void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) {
OPEN_DISPS(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx);

View File

@ -32,6 +32,8 @@
#include "scenes/misc/hakaana_ouke/hakaana_ouke_scene.h" #include "scenes/misc/hakaana_ouke/hakaana_ouke_scene.h"
#include "soh/Enhancements/randomizer/randomizer_entrance.h" #include "soh/Enhancements/randomizer/randomizer_entrance.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
u16 D_8011E1C0 = 0; u16 D_8011E1C0 = 0;

View File

@ -1,6 +1,7 @@
#include "global.h" #include "global.h"
#include "z64elf_message.h" #include "z64elf_message.h"
#include <assert.h> #include <assert.h>
#include "soh/OTRGlobals.h"
ElfMessage sChildSariaMsgs[] = { ElfMessage sChildSariaMsgs[] = {
ELF_MSG_STRENGTH_UPG(SKIP, 3, false, 0), ELF_MSG_STRENGTH_UPG(SKIP, 3, false, 0),

View File

@ -4,6 +4,7 @@
#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" #include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h"
#include "textures/icon_item_static/icon_item_static.h" #include "textures/icon_item_static/icon_item_static.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -1,5 +1,7 @@
#include "global.h" #include "global.h"
#include <string.h> #include <string.h>
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
// unused // unused
Gfx sCircleNullDList[] = { Gfx sCircleNullDList[] = {

View File

@ -1,5 +1,6 @@
#include "global.h" #include "global.h"
#include <assert.h> #include <assert.h>
#include "soh/ResourceManagerHelpers.h"
void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { void SkelCurve_Clear(SkelAnimeCurve* skelCurve) {
skelCurve->limbCount = 0; skelCurve->limbCount = 0;

View File

@ -1,4 +1,5 @@
#include "global.h" #include "global.h"
#include "soh/OTRGlobals.h"
void GameOver_Init(PlayState* play) { void GameOver_Init(PlayState* play) {
play->gameOverCtx.state = GAMEOVER_INACTIVE; play->gameOverCtx.state = GAMEOVER_INACTIVE;

View File

@ -4,6 +4,8 @@
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
typedef enum { typedef enum {
/* 0 */ LENS_FLARE_CIRCLE0, /* 0 */ LENS_FLARE_CIRCLE0,

View File

@ -1,6 +1,7 @@
#include "global.h" #include "global.h"
#include "textures/parameter_static/parameter_static.h" #include "textures/parameter_static/parameter_static.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
s16 Top_LM_Margin = 0; s16 Top_LM_Margin = 0;
s16 Left_LM_Margin = 0; s16 Left_LM_Margin = 0;

View File

@ -5,6 +5,7 @@
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
#define LIGHTS_BUFFER_SIZE 32 #define LIGHTS_BUFFER_SIZE 32
//#define LIGHTS_BUFFER_SIZE 1024 // Kill me //#define LIGHTS_BUFFER_SIZE 1024 // Kill me

View File

@ -5,6 +5,7 @@
#include "textures/map_i_static/map_i_static.h" #include "textures/map_i_static/map_i_static.h"
#include "textures/map_grand_static/map_grand_static.h" #include "textures/map_grand_static/map_grand_static.h"
#include <assert.h> #include <assert.h>
#include "soh/OTRGlobals.h"
MapData* gMapData; MapData* gMapData;

View File

@ -1,6 +1,8 @@
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
#include "textures/parameter_static/parameter_static.h" #include "textures/parameter_static/parameter_static.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
typedef struct { typedef struct {
/* 0x00 */ void* texture; /* 0x00 */ void* texture;

View File

@ -21,6 +21,9 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/Enhancements/randomizer/randomizer_grotto.h" #include "soh/Enhancements/randomizer/randomizer_grotto.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/gameplaystats.h"
#define DO_ACTION_TEX_WIDTH() 48 #define DO_ACTION_TEX_WIDTH() 48
#define DO_ACTION_TEX_HEIGHT() 16 #define DO_ACTION_TEX_HEIGHT() 16

View File

@ -11,6 +11,8 @@
#include <overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h> #include <overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h>
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#include "soh/framebuffer_effects.h" #include "soh/framebuffer_effects.h"
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>

View File

@ -8,6 +8,7 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/randomizer/draw.h" #include "soh/Enhancements/randomizer/draw.h"
#include "soh/ResourceManagerHelpers.h"
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,5 +1,6 @@
#include "global.h" #include "global.h"
#include <assert.h> #include <assert.h>
#include "soh/OTRGlobals.h"
Gfx sSetupDL[SETUPDL_MAX][6] = { Gfx sSetupDL[SETUPDL_MAX][6] = {
{ {

View File

@ -9,6 +9,8 @@
#include <assert.h> #include <assert.h>
#include "public/bridge/gfxbridge.h" #include "public/bridge/gfxbridge.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
void func_80095AB4(PlayState* play, Room* room, u32 flags); void func_80095AB4(PlayState* play, Room* room, u32 flags);
void func_80095D04(PlayState* play, Room* room, u32 flags); void func_80095D04(PlayState* play, Room* room, u32 flags);

View File

@ -25,6 +25,8 @@
#include "soh/mq_asset_hacks.h" #include "soh/mq_asset_hacks.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h" #include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
// Entrance Table definition // Entrance Table definition
#define DEFINE_ENTRANCE(_0, sceneId, spawn, continueBgm, displayTitleCard, endTransType, startTransType) \ #define DEFINE_ENTRANCE(_0, sceneId, spawn, continueBgm, displayTitleCard, endTransType, startTransType) \

View File

@ -3,6 +3,8 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#define ANIM_INTERP 1 #define ANIM_INTERP 1

View File

@ -1,6 +1,7 @@
#include "global.h" #include "global.h"
#include "overlays/actors/ovl_En_fHG/z_en_fhg.h" #include "overlays/actors/ovl_En_fHG/z_en_fhg.h"
#include <assert.h> #include <assert.h>
#include "soh/ResourceManagerHelpers.h"
/** /**
* Initialises the Vtx buffers used for limb at index `limbIndex` * Initialises the Vtx buffers used for limb at index `limbIndex`

View File

@ -5,6 +5,8 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/Enhancements/randomizer/savefile.h" #include "soh/Enhancements/randomizer/savefile.h"
#include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#define NUM_DUNGEONS 8 #define NUM_DUNGEONS 8
#define NUM_COWS 10 #define NUM_COWS 10

View File

@ -1,5 +1,6 @@
#include <libultraship/libultra.h> #include <libultraship/libultra.h>
#include "global.h" #include "global.h"
#include "soh/OTRGlobals.h"
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>

View File

@ -8,6 +8,7 @@
#include "scenes/dungeons/ddan/ddan_scene.h" #include "scenes/dungeons/ddan/ddan_scene.h"
#include "objects/object_bwall/object_bwall.h" #include "objects/object_bwall/object_bwall.h"
#include "objects/object_kingdodongo/object_kingdodongo.h" #include "objects/object_kingdodongo/object_kingdodongo.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

View File

@ -11,6 +11,8 @@
#include "scenes/indoors/yousei_izumi_yoko/yousei_izumi_yoko_scene.h" #include "scenes/indoors/yousei_izumi_yoko/yousei_izumi_yoko_scene.h"
#include "scenes/indoors/daiyousei_izumi/daiyousei_izumi_scene.h" #include "scenes/indoors/daiyousei_izumi/daiyousei_izumi_scene.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED | ACTOR_FLAG_NO_FREEZE_OCARINA) #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED | ACTOR_FLAG_NO_FREEZE_OCARINA)

View File

@ -7,6 +7,7 @@
#include "z_bg_gate_shutter.h" #include "z_bg_gate_shutter.h"
#include "objects/object_spot01_matoyab/object_spot01_matoyab.h" #include "objects/object_spot01_matoyab/object_spot01_matoyab.h"
#include "vt.h" #include "vt.h"
#include "soh/OTRGlobals.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -7,6 +7,7 @@
#include "z_bg_gjyo_bridge.h" #include "z_bg_gjyo_bridge.h"
#include "objects/object_gjyo_objects/object_gjyo_objects.h" #include "objects/object_gjyo_objects/object_gjyo_objects.h"
#include "scenes/dungeons/ganon_tou/ganon_tou_scene.h" #include "scenes/dungeons/ganon_tou/ganon_tou_scene.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -1,5 +1,6 @@
#include "z_bg_ice_shelter.h" #include "z_bg_ice_shelter.h"
#include "objects/object_ice_objects/object_ice_objects.h" #include "objects/object_ice_objects/object_ice_objects.h"
#include "soh/OTRGlobals.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -6,6 +6,7 @@
#include "z_bg_jya_lift.h" #include "z_bg_jya_lift.h"
#include "objects/object_jya_obj/object_jya_obj.h" #include "objects/object_jya_obj/object_jya_obj.h"
#include "soh/OTRGlobals.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED

View File

@ -6,6 +6,7 @@
#include "z_bg_spot01_idosoko.h" #include "z_bg_spot01_idosoko.h"
#include "objects/object_spot01_matoya/object_spot01_matoya.h" #include "objects/object_spot01_matoya/object_spot01_matoya.h"
#include "soh/OTRGlobals.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED

View File

@ -6,6 +6,7 @@
#include "z_bg_spot03_taki.h" #include "z_bg_spot03_taki.h"
#include "objects/object_spot03_object/object_spot03_object.h" #include "objects/object_spot03_object/object_spot03_object.h"
#include "soh/ResourceManagerHelpers.h"
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

View File

@ -6,6 +6,7 @@
#include "z_bg_spot12_saku.h" #include "z_bg_spot12_saku.h"
#include "objects/object_spot12_obj/object_spot12_obj.h" #include "objects/object_spot12_obj/object_spot12_obj.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -6,6 +6,7 @@
#include "z_bg_sst_floor.h" #include "z_bg_sst_floor.h"
#include "objects/object_sst/object_sst.h" #include "objects/object_sst/object_sst.h"
#include "soh/ResourceManagerHelpers.h"
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

View File

@ -6,6 +6,7 @@
#include "z_bg_toki_swd.h" #include "z_bg_toki_swd.h"
#include "objects/object_toki_objects/object_toki_objects.h" #include "objects/object_toki_objects/object_toki_objects.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED

View File

@ -7,6 +7,7 @@
#include "z_bg_treemouth.h" #include "z_bg_treemouth.h"
#include "objects/object_spot04_objects/object_spot04_objects.h" #include "objects/object_spot04_objects/object_spot04_objects.h"
#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

View File

@ -6,6 +6,7 @@
#include "z_bg_ydan_sp.h" #include "z_bg_ydan_sp.h"
#include "objects/object_ydan_objects/object_ydan_objects.h" #include "objects/object_ydan_objects/object_ydan_objects.h"
#include "soh/ResourceManagerHelpers.h"
#define FLAGS 0 #define FLAGS 0

View File

@ -5,6 +5,8 @@
#include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h" #include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include <stdlib.h> // malloc #include <stdlib.h> // malloc
#include <string.h> // memcpy #include <string.h> // memcpy

View File

@ -11,6 +11,7 @@
#include "assets/scenes/dungeons/ganon_boss/ganon_boss_scene.h" #include "assets/scenes/dungeons/ganon_boss/ganon_boss_scene.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include <string.h> #include <string.h>

View File

@ -7,6 +7,8 @@
#include "objects/object_ganon_anime3/object_ganon_anime3.h" #include "objects/object_ganon_anime3/object_ganon_anime3.h"
#include "objects/object_geff/object_geff.h" #include "objects/object_geff/object_geff.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include <string.h> #include <string.h>

View File

@ -11,6 +11,7 @@
#include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" #include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h"
#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h"
#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

View File

@ -4,6 +4,7 @@
#include "overlays/actors/ovl_En_Goma/z_en_goma.h" #include "overlays/actors/ovl_En_Goma/z_en_goma.h"
#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" #include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h"
#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

View File

@ -11,6 +11,7 @@
#include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h" #include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h"
#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

View File

@ -14,6 +14,7 @@
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h"
#include "soh/OTRGlobals.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

View File

@ -12,6 +12,7 @@
#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" #include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h"
#include "soh/frame_interpolation.h" #include "soh/frame_interpolation.h"
#include <assert.h> #include <assert.h>
#include "soh/ResourceManagerHelpers.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED

View File

@ -10,6 +10,8 @@
#include "objects/object_efc_tw/object_efc_tw.h" #include "objects/object_efc_tw/object_efc_tw.h"
#include "objects/object_gi_jewel/object_gi_jewel.h" #include "objects/object_gi_jewel/object_gi_jewel.h"
#include <assert.h> #include <assert.h>
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

View File

@ -1,6 +1,7 @@
#include "z_demo_ik.h" #include "z_demo_ik.h"
#include "vt.h" #include "vt.h"
#include "objects/object_ik/object_ik.h" #include "objects/object_ik/object_ik.h"
#include "soh/ResourceManagerHelpers.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED

Some files were not shown because too many files have changed in this diff Show More