summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-09-12 22:23:11 +0200
committerGitHub <noreply@github.com>2024-09-12 16:23:11 -0400
commite2c4bb7be7fa731a335bce4bc22283d899133e39 (patch)
tree91152d84cae384b376f4ce4c87e9e247255ec954 /include
parent9aa30ee4995be938e1ea05f6d476d63fcb8cc67e (diff)
Dowsing (#17)
* Dowsing. * d_t_dowsing * d_t_holy_water OK
Diffstat (limited to 'include')
-rw-r--r--include/d/a/d_a_base.h16
-rw-r--r--include/d/d_player.h6
-rw-r--r--include/d/tg/d_t_dowsing.h66
-rw-r--r--include/d/tg/d_t_genki_dws_tgt.h23
-rw-r--r--include/d/tg/d_t_holy_water.h24
-rw-r--r--include/d/tg/d_t_light_shaft_eff.h5
-rw-r--r--include/d/tg/d_t_map_inst.h3
-rw-r--r--include/d/tg/d_t_tackle.h5
-rw-r--r--include/d/tg/d_tg.h12
-rw-r--r--include/m/m_vec.h14
-rw-r--r--include/toBeSorted/dowsing_target.h71
-rw-r--r--include/toBeSorted/item_story_flag_manager.h46
-rw-r--r--include/toBeSorted/room_manager.h6
-rw-r--r--include/toBeSorted/sceneflag_manager.h5
-rw-r--r--include/toBeSorted/scgame.h4
-rw-r--r--include/toBeSorted/tlist.h130
16 files changed, 402 insertions, 34 deletions
diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h
index 46072cb0..659a3d59 100644
--- a/include/d/a/d_a_base.h
+++ b/include/d/a/d_a_base.h
@@ -10,6 +10,7 @@
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "toBeSorted/room_manager.h"
+#include "toBeSorted/tlist.h"
class dAcBase_c;
@@ -60,21 +61,6 @@ public:
}
};
-template <typename T, int offset>
-struct TList {
- T *GetOffset() {
- return (T *)((u8 *)this - offset);
- }
- TList() {
- sound_info_next = GetOffset();
- sound_info_tail = GetOffset();
- count = 0;
- }
- T *sound_info_tail;
- T *sound_info_next;
- s32 count;
-};
-
// Ghidra: ActorBase
// size: 0xFC
// non-official name
diff --git a/include/d/d_player.h b/include/d/d_player.h
index cc99016f..7477b0a9 100644
--- a/include/d/d_player.h
+++ b/include/d/d_player.h
@@ -7,9 +7,9 @@
class dPlayer: public dAcObjBase_c {
public:
/* 0x330 */ u8 unk_0x330[0x350 - 0x330];
- /* 0x350 */ u32 someFlags;
-
-
+ /* 0x350 */ u32 someFlags_0x350;
+ u8 UNK_0x354[0x35C - 0x354];
+ /* 0x35C */ u32 mForceOrPreventActionFlags;
static dPlayer *LINK;
};
diff --git a/include/d/tg/d_t_dowsing.h b/include/d/tg/d_t_dowsing.h
new file mode 100644
index 00000000..21a583a1
--- /dev/null
+++ b/include/d/tg/d_t_dowsing.h
@@ -0,0 +1,66 @@
+#ifndef D_T_DOWSING_H
+#define D_T_DOWSING_H
+
+#include <d/tg/d_tg.h>
+#include <toBeSorted/dowsing_target.h>
+
+class dTgDowsing_c : public dTg_c {
+public:
+ dTgDowsing_c();
+ virtual ~dTgDowsing_c() {}
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+ virtual int draw() override;
+
+ bool checkDowsing() const;
+
+private:
+ enum DowsingOption {
+ TRIAL_0,
+ TRIAL_1,
+ TRIAL_2,
+ TRIAL_3,
+ PROPELLER,
+ WATER_BASIN,
+ CRYSTAL_BALL,
+ PUMPKIN,
+ NEW_PLANT_SPECIES,
+ PARTY_WHEEL,
+ ZELDA,
+ DOWSING_MAX
+ };
+
+ DowsingTarget mDowsingTarget; // 0x0FC
+ DowsingOption mDowsingOption; // 0x11C
+ u16 mUntriggerStoryFlag; // 0x120
+ u16 mTriggerStoryFlag; // 0x122
+ bool mTargetActive; // 0x124
+
+ u16 getTriggerSceneFlag() {
+ return params & 0xFF;
+ }
+
+ u16 getUntriggerSceneFlag() {
+ return params >> 0x8 & 0xFF;
+ }
+
+ DowsingOption getDowsingOption() {
+ return (DowsingOption)(params >> 0x10 & 0xF);
+ }
+
+ u32 getDowsingOptionNum() {
+ return mDowsingOption;
+ }
+
+ u16 getUntriggerStoryFlag() {
+ return params >> 0x14 & 0x7FF;
+ }
+
+ u16 getTriggerStoryFlag() {
+ return rotation.z.mVal & 0x7FF;
+ }
+};
+
+#endif
diff --git a/include/d/tg/d_t_genki_dws_tgt.h b/include/d/tg/d_t_genki_dws_tgt.h
new file mode 100644
index 00000000..b6d9899f
--- /dev/null
+++ b/include/d/tg/d_t_genki_dws_tgt.h
@@ -0,0 +1,23 @@
+#ifndef D_T_GENKI_DWS_TGT_H
+#define D_T_GENKI_DWS_TGT_H
+
+#include <d/tg/d_tg.h>
+#include <toBeSorted/dowsing_target.h>
+
+class dTgGenkiDwsTgt_c : public dTg_c {
+public:
+ dTgGenkiDwsTgt_c() : mDowsingTarget(this, DowsingTarget::SLOT_NONE) {}
+ virtual ~dTgGenkiDwsTgt_c() {}
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+
+
+private:
+ u16 getSceneFlagFromParams();
+
+ DowsingTarget mDowsingTarget; // 0xFC
+};
+
+#endif
diff --git a/include/d/tg/d_t_holy_water.h b/include/d/tg/d_t_holy_water.h
new file mode 100644
index 00000000..fd6bacfe
--- /dev/null
+++ b/include/d/tg/d_t_holy_water.h
@@ -0,0 +1,24 @@
+#ifndef D_T_HOLY_WATER_H
+#define D_T_HOLY_WATER_H
+
+#include <d/tg/d_tg.h>
+#include <toBeSorted/dowsing_target.h>
+
+class dTgHolyWater_c : public dTg_c {
+public:
+ dTgHolyWater_c() : mDowsingTarget(this, DowsingTarget::SLOT_NONE) {}
+ virtual ~dTgHolyWater_c() {}
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+ virtual int draw() override;
+
+ bool isLinkNearby();
+ bool dowsingActive();
+
+private:
+ DowsingTarget mDowsingTarget; // 0x0FC
+};
+
+#endif
diff --git a/include/d/tg/d_t_light_shaft_eff.h b/include/d/tg/d_t_light_shaft_eff.h
index 18928aad..d3d8a35f 100644
--- a/include/d/tg/d_t_light_shaft_eff.h
+++ b/include/d/tg/d_t_light_shaft_eff.h
@@ -7,6 +7,11 @@ class dTgLightShaftEff_c : public dTg_c {
public:
dTgLightShaftEff_c() {}
virtual ~dTgLightShaftEff_c() {}
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+ virtual int draw() override;
};
#endif
diff --git a/include/d/tg/d_t_map_inst.h b/include/d/tg/d_t_map_inst.h
index 855cc6c0..f5545962 100644
--- a/include/d/tg/d_t_map_inst.h
+++ b/include/d/tg/d_t_map_inst.h
@@ -9,6 +9,9 @@ public:
virtual ~dTgMapInst_c() {}
virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+ virtual int draw() override;
u8 field_0xfc;
};
diff --git a/include/d/tg/d_t_tackle.h b/include/d/tg/d_t_tackle.h
index c325c7bb..aba9f97c 100644
--- a/include/d/tg/d_t_tackle.h
+++ b/include/d/tg/d_t_tackle.h
@@ -7,6 +7,11 @@ class dTgTackle_c : public dTg_c {
public:
dTgTackle_c() {}
virtual ~dTgTackle_c() {}
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int actorExecute() override;
+ virtual int draw() override;
};
#endif
diff --git a/include/d/tg/d_tg.h b/include/d/tg/d_tg.h
index ceb14579..6f8f519e 100644
--- a/include/d/tg/d_tg.h
+++ b/include/d/tg/d_tg.h
@@ -6,18 +6,6 @@
class dTg_c : public dAcBase_c {
public:
virtual ~dTg_c() {}
- virtual int draw() override {
- return 1;
- }
- virtual int actorExecute() override {
- return 1;
- }
- virtual int doDelete() override {
- return 1;
- }
- virtual int create() override {
- return 1;
- }
};
#endif
diff --git a/include/m/m_vec.h b/include/m/m_vec.h
index f7ba025d..1009f7a1 100644
--- a/include/m/m_vec.h
+++ b/include/m/m_vec.h
@@ -122,7 +122,7 @@ public:
/// @brief Scalar product operator.
mVec3_c operator*(f32 f) const {
- return mVec3_c(f * x, f * y, f * z);
+ return mVec3_c(x * f, y * f, z * f);
}
/// @brief Scalar division operator.
@@ -140,6 +140,18 @@ public:
bool operator!=(const mVec3_c &v) const {
return x != v.x || y != v.y || z != v.z;
}
+
+ void normalize();
+ bool normalizeRS();
+
+ inline f32 mag() const {
+ return PSVECMag(*this);
+ }
+
+ static mVec3_c Zero;
+ static mVec3_c Ex;
+ static mVec3_c Ey;
+ static mVec3_c Ez;
};
#endif
diff --git a/include/toBeSorted/dowsing_target.h b/include/toBeSorted/dowsing_target.h
new file mode 100644
index 00000000..a157cbae
--- /dev/null
+++ b/include/toBeSorted/dowsing_target.h
@@ -0,0 +1,71 @@
+#ifndef DOWSING_TARGET_H
+#define DOWSING_TARGET_H
+
+#include <d/a/d_a_base.h>
+#include <f/f_list_nd.h>
+#include <m/m_vec.h>
+
+class DowsingTarget {
+public:
+ TListNode mLink; // 0x00
+private:
+ dAcBase_c *mpActor; // 0x08
+ u8 mDowsingSlot; // 0x0C
+ u16 field_0x0E; // 0x0E
+ mVec3_c mOffset; // 0x10
+
+public:
+ enum DowsingSlot {
+ SLOT_STORY_EVENT = 0,
+ SLOT_RUPEE = 1,
+ SLOT_QUEST = 2,
+ SLOT_CRYSTAL = 3,
+ SLOT_HEART = 4,
+ SLOT_GODDESS_CUBE = 5,
+ SLOT_LOOK = 6,
+ SLOT_TREASURE = 7,
+ SLOT_NONE = 8,
+ };
+
+ DowsingTarget(dAcBase_c *ac, u8 dowsingSlot) : mpActor(ac), mDowsingSlot(dowsingSlot) {}
+ // vt offset 0x1C
+ virtual ~DowsingTarget(); // 0x08
+ virtual void getPosition(mVec3_c &); // 0x0C
+
+ bool doRegister();
+ bool doUnregister();
+ void initialize(DowsingSlot type, u16 unk, const mVec3_c *offset, f32 f);
+ void reinitialize(DowsingSlot type);
+
+ inline DowsingSlot getSlot() {
+ return (DowsingSlot)mDowsingSlot;
+ }
+
+ static bool hasZeldaDowsing();
+ static bool hasKikwiDowsing();
+ static bool hasKeyPieceDowsing();
+ static bool hasDesertNodeDowsing();
+ static bool hasAnyTrialDowsing();
+ static bool hasSacredWaterDowsing();
+ static bool hasSandshipDowsing();
+ static bool hasTadtoneDowsing();
+ static bool hasPropellerDowsing();
+ static bool hasWaterBasinDowsing();
+ static bool hasCrystalBallDowsing();
+ static bool hasPumpkinDowsing();
+ static bool hasNewPlantSpeciesDowsing();
+ static bool hasPartyWheelDowsing();
+
+ static bool hasDowsingInSlot(int slot);
+
+ static DowsingTarget *getDowsingInfo(const mVec3_c &playerPosition, const mVec3_c &dowsingDirection, f32 *, f32 *,
+ f32 *intensity, int slot);
+
+ static void init();
+ static void execute();
+
+ static u8 getTopDowsingIcon();
+ static u8 getLeftDowsingIcon();
+};
+
+#endif
diff --git a/include/toBeSorted/item_story_flag_manager.h b/include/toBeSorted/item_story_flag_manager.h
new file mode 100644
index 00000000..b2eaf6f8
--- /dev/null
+++ b/include/toBeSorted/item_story_flag_manager.h
@@ -0,0 +1,46 @@
+#ifndef ITEM_STORY_FLAG_MANAGER_H
+#define ITEM_STORY_FLAG_MANAGER_H
+
+#include <toBeSorted/flag_space.h>
+#include <toBeSorted/unk_flag_stuff.h>
+
+// TODO These classes have an interesting relation and there are like 5 vtables, so
+// the stuff in this header should not be relied upon for actually implementing these,
+// but we need the interface
+
+class ItemStoryManagerBase {
+public:
+ ItemStoryManagerBase();
+
+ /** 0x08 */ virtual ~ItemStoryManagerBase();
+ /** 0x0C */ virtual void setFlagszptr();
+ /** 0x10 */ virtual void onDirty();
+ /** 0x14 */ virtual void copyFlagsFromSave() = 0;
+ /** 0x18 */ virtual void setupUnkFlagsStuff() = 0;
+ /** 0x1C */ virtual bool doCommit() = 0;
+ /** 0x20 */ virtual void setFlag(u16 flag);
+ /** 0x24 */ virtual void unsetFlag(u16 flag);
+ /** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value);
+ /** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const;
+ /** 0x30 */ virtual u16 getUncommittedValue(u16 flag);
+ /** 0x34 */ virtual void unk3();
+ /** 0x38 */ virtual u16 *getSaveFlagSpace() = 0;
+
+ u16 getFlag(u16 flag) const;
+};
+
+class StoryFlagManager : public ItemStoryManagerBase {
+ FlagSpace storyFlags;
+
+public:
+ static StoryFlagManager *sInstance;
+};
+
+class ItemFlagManager : public ItemStoryManagerBase {
+ FlagSpace itemFlags;
+
+public:
+ static ItemFlagManager *sInstance;
+};
+
+#endif
diff --git a/include/toBeSorted/room_manager.h b/include/toBeSorted/room_manager.h
index c4c19821..5e17f25c 100644
--- a/include/toBeSorted/room_manager.h
+++ b/include/toBeSorted/room_manager.h
@@ -21,7 +21,7 @@ class dRoomCollision {
char todo[352];
};
-class dRoom : dBase_c {
+class dRoom : public dBase_c {
public:
mAllocator_c allocator;
nw4r::g3d::ResFile *roomRes;
@@ -94,8 +94,8 @@ public:
/* 80575760 */ static RoomManager *m_Instance;
public:
- dRoom *GetRoomByIndex(int roomid);
- /* 801b42b0 */ static dBase_c *getRoom(int roomid);
+ /* 801b3970 */ dRoom *GetRoomByIndex(int roomid);
+ /* 801b42b0 */ static dRoom *getRoom(int roomid);
/* 801b42d0 */ static void bindStageResToFile(nw4r::g3d::ResFile *);
/* 801b4320 */ static void bindSkyCmnToResFile(nw4r::g3d::ResFile *);
/* 801b4380 */ static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, char *);
diff --git a/include/toBeSorted/sceneflag_manager.h b/include/toBeSorted/sceneflag_manager.h
index bb2106e6..a8fe5112 100644
--- a/include/toBeSorted/sceneflag_manager.h
+++ b/include/toBeSorted/sceneflag_manager.h
@@ -58,6 +58,11 @@ public:
void unsetSceneflagGlobal(u16 sceneIdx, u16 flag);
void unsetTempOrSceneflag(u16 flag);
s32 doCommit();
+
+
+ bool checkBoolFlag(u16 roomid, u16 flag) {
+ return checkFlag(roomid, flag);
+ }
};
#endif
diff --git a/include/toBeSorted/scgame.h b/include/toBeSorted/scgame.h
index aa465d4a..229c0e7a 100644
--- a/include/toBeSorted/scgame.h
+++ b/include/toBeSorted/scgame.h
@@ -13,6 +13,10 @@ struct SpawnInfo {
/* 0x26 */ s8 trial;
/* 0x27 */ s8 transitionType;
/* 0x28 */ s32 unk;
+
+ bool isNight() {
+ return night == 1;
+ }
};
class ScGame {
diff --git a/include/toBeSorted/tlist.h b/include/toBeSorted/tlist.h
new file mode 100644
index 00000000..9d62beb2
--- /dev/null
+++ b/include/toBeSorted/tlist.h
@@ -0,0 +1,130 @@
+#ifndef T_LIST_H
+#define T_LIST_H
+
+// A templated list, similar to nw4r::ut::LinkList.
+// Notable differences are:
+// * No dtor
+// * Entirely in headers
+// * Swapped node and count members
+// Used in DowsingTarget, maybe also in dAcBase_c.soundStuff
+
+// It's not immediately clear whether this stores pointers to nodes
+// or pointers to objects. DowsingTarget's node offset is 0, so there's
+// no observable difference, but the SoundSource stuff makes it
+// look like it stores object pointers
+
+class TListNode {
+public:
+ TListNode() : mpPrev(nullptr), mpNext(nullptr) {}
+
+ void *GetNext() const {
+ return mpNext;
+ }
+ void *GetPrev() const {
+ return mpPrev;
+ }
+ void *mpPrev;
+ void *mpNext;
+};
+
+template <typename T, int offset>
+class TList {
+public:
+ class Iterator {
+ public:
+ Iterator() : mNode(NULL) {}
+ Iterator(TListNode *node) : mNode(node) {}
+
+ Iterator &operator++() {
+ mNode = GetNodeFromPointer(mNode->GetNext());
+ return *this;
+ }
+
+ Iterator &operator--() {
+ mNode = mNode->GetPrev();
+ return *this;
+ }
+
+ T *operator->() const {
+ return GetPointerFromNode(mNode);
+ }
+
+ T &operator*() {
+ return *this->operator->();
+ }
+
+ friend bool operator==(Iterator lhs, Iterator rhs) {
+ return lhs.mNode == rhs.mNode;
+ }
+
+ friend bool operator!=(Iterator lhs, Iterator rhs) {
+ return !(lhs.mNode == rhs.mNode);
+ }
+
+ private:
+ TListNode *mNode; // at 0x0
+ };
+
+ TList() {
+ this->mNode.mpNext = GetPointerFromNode(&mNode);
+ this->mNode.mpPrev = GetPointerFromNode(&mNode);
+ mCount = 0;
+ }
+
+ Iterator GetBeginIter() {
+ return GetNodeFromPointer(&mNode) != mNode.GetNext() ? Iterator(GetNodeFromPointer(mNode.GetNext())) :
+ Iterator(&mNode);
+ }
+ Iterator GetEndIter() {
+ return Iterator(&mNode);
+ }
+
+ static TListNode *GetNodeFromPointer(void *p) {
+ return reinterpret_cast<TListNode *>(reinterpret_cast<char *>(p) + offset);
+ }
+
+ static T *GetPointerFromNode(TListNode *node) {
+ return reinterpret_cast<T *>(reinterpret_cast<char *>(node) - offset);
+ }
+
+ void insert(T *value) {
+ TListNode *node = GetNodeFromPointer(value);
+ if (GetPointerFromNode(&mNode) == this->mNode.mpNext) {
+ node->mpNext = GetPointerFromNode(&mNode);
+ node->mpPrev = GetPointerFromNode(&mNode);
+ this->mNode.mpNext = value;
+ this->mNode.mpPrev = value;
+ mCount++;
+ } else {
+ node->mpPrev = this->mNode.mpPrev;
+ node->mpNext = GetPointerFromNode(&mNode);
+ GetNodeFromPointer(this->mNode.mpPrev)->mpNext = value;
+ this->mNode.mpPrev = value;
+ mCount++;
+ }
+ }
+
+ void remove(T *value) {
+ TListNode *node = GetNodeFromPointer(value);
+ T *next = reinterpret_cast<T *>(node->mpNext);
+ if (GetPointerFromNode(&mNode) == node->mpPrev) {
+ this->mNode.mpNext = next;
+ } else {
+ GetNodeFromPointer(node->mpPrev)->mpNext = next;
+ }
+
+ if (GetPointerFromNode(&mNode) == node->mpNext) {
+ this->mNode.mpPrev = node->mpPrev;
+ } else {
+ GetNodeFromPointer(node->mpNext)->mpPrev = node->mpPrev;
+ }
+ node->mpPrev = nullptr;
+ node->mpNext = nullptr;
+ mCount--;
+ }
+
+ TListNode mNode;
+ s32 mCount;
+};
+
+#endif