Link dowsing_target, eggException, d_lyt_meter_drink (#128)

* Link dowsing_target, eggException

* d_lyt_meter_drink OK (thanks Zeldex!)

* More sensible DowsingTarget flag code

* Attempt explaining TList inline
This commit is contained in:
robojumper
2025-03-14 03:13:15 +01:00
committed by GitHub
parent 01b964c831
commit 32cbf96184
8 changed files with 53 additions and 43 deletions
+3 -3
View File
@@ -362,7 +362,7 @@ config.libs = [
Object(Matching, "toBeSorted/arc_managers/oarc_manager.cpp"),
Object(Matching, "toBeSorted/arc_managers/layout_arc_manager.cpp"),
Object(NonMatching, "toBeSorted/attention.cpp"),
Object(NonMatching, "toBeSorted/dowsing_target.cpp"),
Object(Matching, "toBeSorted/dowsing_target.cpp"),
Object(NonMatching, "toBeSorted/time_area_mgr.cpp"),
Object(NonMatching, "toBeSorted/nand_request_thread.cpp"),
Object(Matching, "toBeSorted/save_file.cpp"),
@@ -385,7 +385,7 @@ config.libs = [
Object(NonMatching, "d/lyt/meter/d_lyt_meter_a_btn.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_z_btn.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_key.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_drink.cpp"),
Object(Matching, "d/lyt/meter/d_lyt_meter_drink.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_remocon_bg.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_nunchaku_bg.cpp"),
Object(NonMatching, "d/lyt/meter/d_lyt_meter_nun_stk.cpp"),
@@ -906,7 +906,7 @@ config.libs = [
EGGLib(
"util",
[
Object(NonMatching, "egg/util/eggException.cpp"),
Object(Matching, "egg/util/eggException.cpp"),
],
),
# {
+1 -1
View File
@@ -30,7 +30,7 @@ public:
static u32 getTickPerVRetrace();
static const GXRenderModeObj *getStandardRenderModeObj(const RenderModeObjSet *);
GXRenderModeObj *getCurrentOrFallbackRenderModeObj() const {
const GXRenderModeObj *getCurrentOrFallbackRenderModeObj() const {
if (pRenderMode == nullptr) {
return &lbl_8055FC64;
}
+1 -1
View File
@@ -21,7 +21,7 @@ public:
static Exception *sException;
volatile static nw4r::db::ConsoleHandle sConsoleHandle;
static nw4r::db::ConsoleHandle sConsoleHandle;
static void *sMapFileWorks;
static u32 sMapFileNumMax;
static u32 sCurrentMapFileNum;
+1 -1
View File
@@ -27,7 +27,7 @@ struct BitGXNums {
template <typename T>
inline bool TestBit(T bits, int index) {
T mask = 1 << index;
return bits & mask;
return (bits & mask) != 0;
}
template <typename T>
inline void SetBit(T *bits, int pos, bool val) {
+15
View File
@@ -78,6 +78,21 @@ public:
}
}
/**
* Returns an iterator representing the position of pT in this
* list. If pT is not in the list, the result is the end iterator.
*
* This is typically used to check if an object is contained in a
* list of this type.
*/
Iterator GetPosition(T *pT) {
if (pT->mLink.mpNext == nullptr || pT->mLink.mpPrev == nullptr) {
return GetEndIter();
} else {
return Iterator(pT);
}
}
Iterator GetEndIter() {
return Iterator(GetPtrFromNode(&mStartEnd));
}
+18 -18
View File
@@ -406,6 +406,15 @@ bool dLytMeterDrink_c::build(d2d::ResAccIf_c *resAcc) {
return true;
}
bool dLytMeterDrink_c::remove() {
for (int i = 0; i < 20; i++) {
mAnmGroups[i].unbind();
mAnmGroups[i].afterUnbind();
}
return true;
}
bool dLytMeterDrink_c::execute() {
mStateMgr.executeState();
@@ -420,29 +429,11 @@ bool dLytMeterDrink_c::execute() {
return true;
}
bool dLytMeterDrink_c::remove() {
for (int i = 0; i < 20; i++) {
mAnmGroups[i].unbind();
mAnmGroups[i].afterUnbind();
}
return true;
}
bool dLytMeterDrink_c::draw() {
mLyt.addToDrawList();
return true;
}
int dLytMeterDrink_c::getPartForDrinkType(dLytMeterDrinkParts_c::DrinkType_e ty) const {
for (int i = 0; i < 3; i++) {
if (ty == mParts[i].mDrinkType) {
return i;
}
}
return 3;
}
bool dLytMeterDrink_c::fn_800E5C40(int i) {
if ((i == 0 || i == 3) && (FileManager::GetInstance()->getStaminaPotionTimer() != 0 ||
FileManager::GetInstance()->getStaminaPotionPlusTimer() != 0)) {
@@ -462,6 +453,15 @@ bool dLytMeterDrink_c::fn_800E5C40(int i) {
return false;
}
int dLytMeterDrink_c::getPartForDrinkType(dLytMeterDrinkParts_c::DrinkType_e ty) const {
for (int i = 0; i < 3; i++) {
if (ty == mParts[i].mDrinkType) {
return i;
}
}
return 3;
}
void dLytMeterDrink_c::executeInternal() {
bool bHasNotSoonExpiringDrink = false;
bool bHasSoonExpiringDrink = false;
+6 -5
View File
@@ -13,7 +13,7 @@
namespace EGG {
Exception *Exception::sException;
volatile nw4r::db::ConsoleHandle Exception::sConsoleHandle;
nw4r::db::ConsoleHandle Exception::sConsoleHandle;
void *Exception::sMapFileWorks;
u32 Exception::sMapFileNumMax;
u32 Exception::sCurrentMapFileNum;
@@ -179,16 +179,17 @@ Exception::Exception(u16 width, u16 height, u16 attr, EGG::Heap *heap, int mapFi
return;
}
GXRenderModeObj *o = EGG::BaseSystem::getVideo()->getCurrentOrFallbackRenderModeObj();
nw4r::db::Exception_SetConsole(sConsoleHandle, o);
const GXRenderModeObj *o = EGG::BaseSystem::getVideo()->getCurrentOrFallbackRenderModeObj();
// Fakematch? Everything before Exception_SetConsole matches if it's volatile, but things after
// it break
nw4r::db::Exception_SetConsole(*(nw4r::db::ConsoleHandle *volatile)&sConsoleHandle, o);
nw4r::db::Console_SetPosition(sConsoleHandle, 0, 30);
nw4r::db::Console_SetVisible(sConsoleHandle, false);
sMapFileNumMax = mapFileNum;
size_t size = mapFileNum * 0x14;
sCurrentMapFileNum = 0;
sMapFileWorks = Heap::alloc(size, 4, heap);
sMapFileWorks = Heap::alloc(mapFileNum * 0x14, 4, heap);
SetCallbackArgs(nullptr);
}
+8 -14
View File
@@ -136,9 +136,12 @@ bool DowsingTarget::hasDowsingInSlot(int slot) {
} else if (slot == 2) {
return hasCrystalBallDowsing() || hasPumpkinDowsing() || hasNewPlantSpeciesDowsing() || hasKikwiDowsing() ||
hasKeyPieceDowsing() || hasDesertNodeDowsing() || hasPartyWheelDowsing();
} else if (StoryflagManager::sInstance->getCounterOrFlag(DOWSING_TARGET_STORY_FLAGS[slot])) {
// TODO small instruction shuffle
return true;
} else {
u16 flag = DOWSING_TARGET_STORY_FLAGS[slot];
flag = StoryflagManager::sInstance->getCounterOrFlag(flag);
if (flag != 0) {
return true;
}
}
return false;
@@ -199,22 +202,13 @@ void DowsingTarget::init() {}
void DowsingTarget::execute() {}
// Not sure what this is
inline static TListNode<DowsingTarget> *getNode(u8 slot, DowsingTarget *t) {
if (t->mLink.mpNext == nullptr || t->mLink.mpPrev == nullptr) {
return &DOWSING_LISTS[slot].mStartEnd;
} else {
return &t->mLink;
}
}
static bool insertDowsingTarget(DowsingTarget *target) {
u8 slot = target->getSlot();
if (slot == DowsingTarget::SLOT_NONE) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
if (DOWSING_LISTS[slot].GetPosition(target) != DOWSING_LISTS[slot].GetEndIter()) {
return false;
}
DOWSING_LISTS[slot].insert(target);
@@ -227,7 +221,7 @@ static bool removeDowsingTarget(DowsingTarget *target) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
if (DOWSING_LISTS[slot].GetPosition(target) != DOWSING_LISTS[slot].GetEndIter()) {
DOWSING_LISTS[slot].remove(target);
return true;
}