mirror of
https://github.com/zeldaret/ss
synced 2026-06-03 10:31:28 -04:00
Clean up flag handling
This commit is contained in:
+13
-13
@@ -4073,7 +4073,7 @@ init__16SceneflagManagerFv = .text:0x800BD8C0; // type:function size:0x4
|
||||
setShouldCommit__16SceneflagManagerFUs = .text:0x800BD8D0; // type:function size:0xC
|
||||
__ct__16SceneflagManagerFv = .text:0x800BD8E0; // type:function size:0x64
|
||||
isNotTempOrZoneFlag__16SceneflagManagerFUs = .text:0x800BD950; // type:function size:0xC
|
||||
isZoneFlag__16SceneflagManagerFUl = .text:0x800BD960; // type:function size:0x20
|
||||
isZoneFlag__16SceneflagManagerCFUl = .text:0x800BD960; // type:function size:0x20
|
||||
updateFlagindex__16SceneflagManagerFUs = .text:0x800BD980; // type:function size:0x70
|
||||
copyFromSave__16SceneflagManagerFUl = .text:0x800BD9F0; // type:function size:0x94
|
||||
unsetAllTempflags__16SceneflagManagerFv = .text:0x800BDA90; // type:function size:0x40
|
||||
@@ -4082,16 +4082,16 @@ zoneflagsResetForRoom__16SceneflagManagerFUs = .text:0x800BDB10; // type:functio
|
||||
unsetZoneAndTempflags__16SceneflagManagerFv = .text:0x800BDB60; // type:function size:0x3C
|
||||
unsetAllZoneflags__16SceneflagManagerFv = .text:0x800BDBA0; // type:function size:0x34
|
||||
unsetZoneflagsForRoom__16SceneflagManagerFUs = .text:0x800BDBE0; // type:function size:0x48
|
||||
getZoneflagSlot__16SceneflagManagerFUsUs = .text:0x800BDC30; // type:function size:0x10
|
||||
getSceneflagSlotGlobal__16SceneflagManagerFUsUs = .text:0x800BDC40; // type:function size:0x10
|
||||
getSceneflagSlot__16SceneflagManagerFUs = .text:0x800BDC50; // type:function size:0x8
|
||||
getTempflagSlot__16SceneflagManagerFUs = .text:0x800BDC60; // type:function size:0x8
|
||||
checkZoneFlag__16SceneflagManagerFUsUs = .text:0x800BDC70; // type:function size:0xA8
|
||||
getZoneflagSlot__16SceneflagManagerCFUsUs = .text:0x800BDC30; // type:function size:0x10
|
||||
getSceneflagSlotGlobal__16SceneflagManagerCFUsUs = .text:0x800BDC40; // type:function size:0x10
|
||||
getSceneflagSlot__16SceneflagManagerCFUs = .text:0x800BDC50; // type:function size:0x8
|
||||
getTempflagSlot__16SceneflagManagerCFUs = .text:0x800BDC60; // type:function size:0x8
|
||||
checkZoneFlag__16SceneflagManagerCFUsUs = .text:0x800BDC70; // type:function size:0xA8
|
||||
checkUncommittedZoneflag__16SceneflagManagerFUsUs = .text:0x800BDD20; // type:function size:0xA8
|
||||
checkUncommittedTempOrSceneflag__16SceneflagManagerFUs = .text:0x800BDDD0; // type:function size:0xDC
|
||||
checkFlag__16SceneflagManagerFUsUs = .text:0x800BDEB0; // type:function size:0x70
|
||||
checkSceneflagGlobal__16SceneflagManagerFUsUs = .text:0x800BDF20; // type:function size:0x94
|
||||
checkTempOrSceneflag__16SceneflagManagerFUs = .text:0x800BDFC0; // type:function size:0xA0
|
||||
checkFlag__16SceneflagManagerCFUsUs = .text:0x800BDEB0; // type:function size:0x70
|
||||
checkSceneflagGlobal__16SceneflagManagerCFUsUs = .text:0x800BDF20; // type:function size:0x94
|
||||
checkTempOrSceneflag__16SceneflagManagerCFUs = .text:0x800BDFC0; // type:function size:0xA0
|
||||
checkUncommittedFlag__16SceneflagManagerFUsUs = .text:0x800BE060; // type:function size:0x70
|
||||
setZoneflag__16SceneflagManagerFUsUs = .text:0x800BE0D0; // type:function size:0xB0
|
||||
setFlag__16SceneflagManagerFUsUs = .text:0x800BE180; // type:function size:0x70
|
||||
@@ -4137,7 +4137,7 @@ maskForIdx__9FlagIndexFUsUs = .text:0x800BF050; // type:function size:0x50
|
||||
getCounterOrFlag__9FlagIndexFUsPCUsUl = .text:0x800BF0A0; // type:function size:0x68
|
||||
setCounterOrFlag__9FlagIndexFUsPUsUlUl = .text:0x800BF110; // type:function size:0x9C
|
||||
checkFlagValid__9FlagIndexFUsUl = .text:0x800BF1B0; // type:function size:0x50
|
||||
checkFlag__17BitwiseFlagHelperFUsUsPCUsUs = .text:0x800BF200; // type:function size:0x14
|
||||
checkFlag__17BitwiseFlagHelperCFUsUsPCUsUs = .text:0x800BF200; // type:function size:0x14
|
||||
setFlag__17BitwiseFlagHelperFUsUsPUsUs = .text:0x800BF220; // type:function size:0x20
|
||||
unsetFlag__17BitwiseFlagHelperFUsUsPUsUs = .text:0x800BF240; // type:function size:0x24
|
||||
__ct__20ItemStoryManagerBaseFv = .text:0x800BF270; // type:function size:0x28
|
||||
@@ -4148,13 +4148,13 @@ copyFromSave__20ItemStoryManagerBaseFv = .text:0x800BF380; // type:function size
|
||||
init__20ItemStoryManagerBaseFv = .text:0x800BF3E0; // type:function size:0x88
|
||||
initFlagSpace__20ItemStoryManagerBaseFv = .text:0x800BF470; // type:function size:0x4
|
||||
getFlag__20ItemStoryManagerBaseCFUs = .text:0x800BF480; // type:function size:0x58
|
||||
getUncommittedValue_Priv__20ItemStoryManagerBaseFUs = .text:0x800BF4E0; // type:function size:0x50
|
||||
getUncommittedValue_Priv__20ItemStoryManagerBaseCFUs = .text:0x800BF4E0; // type:function size:0x50
|
||||
setOrClearFlag__20ItemStoryManagerBaseFUsUs = .text:0x800BF530; // type:function size:0x78
|
||||
setFlag__20ItemStoryManagerBaseFUs = .text:0x800BF5B0; // type:function size:0x8
|
||||
unsetFlag__20ItemStoryManagerBaseFUs = .text:0x800BF5C0; // type:function size:0x8
|
||||
setFlagOrCounterToValue__20ItemStoryManagerBaseFUsUs = .text:0x800BF5D0; // type:function size:0x4
|
||||
getCounterOrFlag__20ItemStoryManagerBaseCFUs = .text:0x800BF5E0; // type:function size:0x4
|
||||
getUncommittedValue__20ItemStoryManagerBaseFUs = .text:0x800BF5F0; // type:function size:0x4
|
||||
getUncommittedValue__20ItemStoryManagerBaseCFUs = .text:0x800BF5F0; // type:function size:0x4
|
||||
unk3__20ItemStoryManagerBaseFUs = .text:0x800BF600; // type:function size:0x4
|
||||
onFlagChange__20ItemStoryManagerBaseFUs = .text:0x800BF610; // type:function size:0x18
|
||||
onDirty__20ItemStoryManagerBaseFv = .text:0x800BF630; // type:function size:0x4
|
||||
@@ -10903,7 +10903,7 @@ setField0x3C__7dFlow_cFv = .text:0x801B1C60; // type:function size:0xC
|
||||
checkField0x3C__7dFlow_cCFv = .text:0x801B1C70; // type:function size:0x14
|
||||
start__7dFlow_cFUs = .text:0x801B1C90; // type:function size:0xA4
|
||||
advanceUntil__7dFlow_cFllPl = .text:0x801B1D40; // type:function size:0x1C8
|
||||
matchesUnknownActorCategory__7dFlow_cCFl = .text:0x801B1F10; // type:function size:0x38
|
||||
shouldActorShowKillCount__7dFlow_cCFl = .text:0x801B1F10; // type:function size:0x38
|
||||
clear__7dFlow_cFv = .text:0x801B1F50; // type:function size:0x2C
|
||||
createLytMiniGame__7dFlow_cFv = .text:0x801B1F80; // type:function size:0xD8
|
||||
clearMinigame__7dFlow_cFv = .text:0x801B2060; // type:function size:0x98
|
||||
|
||||
@@ -59,7 +59,7 @@ class dFlow_c : dFlowBase_c {
|
||||
BRANCH_18,
|
||||
BRANCH_19,
|
||||
BRANCH_FREE_SPACE_IN_ITEM_CHECK,
|
||||
BRANCH_21,
|
||||
BRANCH_TARGET_ACTOR_HAS_KILL_COUNT,
|
||||
BRANCH_22,
|
||||
};
|
||||
|
||||
@@ -171,7 +171,7 @@ protected:
|
||||
void setNext(u16 next);
|
||||
void setField0x3C();
|
||||
bool checkField0x3C() const;
|
||||
bool matchesUnknownActorCategory(s32 id) const;
|
||||
bool shouldActorShowKillCount(s32 id) const;
|
||||
static void playSound(u32);
|
||||
void createLytMiniGame();
|
||||
void clearMinigame();
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
/** 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);
|
||||
/** 0x30 */ virtual u16 getUncommittedValue(u16 flag) const;
|
||||
/** 0x34 */ virtual u16 unk3(u16 arg);
|
||||
/** 0x38 */ virtual const u16 *getSaveFlagSpace() const = 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
u16 getMaskForFlag(u16 flag);
|
||||
void postCommit();
|
||||
|
||||
u16 getUncommittedValue_Priv(u16 flag);
|
||||
u16 getUncommittedValue_Priv(u16 flag) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
class BitwiseFlagHelper {
|
||||
public:
|
||||
bool checkFlag(u16 slot, u16 shift, const u16 *pData, u16 flagCount);
|
||||
bool checkFlag(u16 slot, u16 shift, const u16 *pData, u16 flagCount) const;
|
||||
bool checkFlag2(u16 slot, u16 shift, const u16 *pData, s32 flagCount) {
|
||||
return checkFlag(slot, shift, pData, flagCount);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class ItemflagManager : public ItemStoryManagerBase {
|
||||
private:
|
||||
FlagSpace mItemFlags;
|
||||
|
||||
static const u32 MASK = 0x4000;
|
||||
|
||||
public:
|
||||
ItemflagManager();
|
||||
virtual ~ItemflagManager() {}
|
||||
@@ -27,22 +29,22 @@ public:
|
||||
FileManager::GetInstance()->setItemFlags(flags, 0, sz);
|
||||
}
|
||||
/** 0x20 */ virtual void setFlag(u16 flag) override {
|
||||
ItemStoryManagerBase::setFlag(flag & ~0x4000);
|
||||
ItemStoryManagerBase::setFlag(flag & ~MASK);
|
||||
}
|
||||
/** 0x24 */ virtual void unsetFlag(u16 flag) override {
|
||||
ItemStoryManagerBase::unsetFlag(flag & ~0x4000);
|
||||
ItemStoryManagerBase::unsetFlag(flag & ~MASK);
|
||||
}
|
||||
/** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value) override {
|
||||
ItemStoryManagerBase::setFlagOrCounterToValue(flag & ~0x4000, value);
|
||||
ItemStoryManagerBase::setFlagOrCounterToValue(flag & ~MASK, value);
|
||||
}
|
||||
/** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const override {
|
||||
return ItemStoryManagerBase::getCounterOrFlag(flag & ~0x4000);
|
||||
return ItemStoryManagerBase::getCounterOrFlag(flag & ~MASK);
|
||||
}
|
||||
/** 0x30 */ virtual u16 getUncommittedValue(u16 flag) override {
|
||||
return ItemStoryManagerBase::getUncommittedValue(flag & ~0x4000);
|
||||
/** 0x30 */ virtual u16 getUncommittedValue(u16 flag) const override {
|
||||
return ItemStoryManagerBase::getUncommittedValue(flag & ~MASK);
|
||||
}
|
||||
/** 0x34 */ virtual u16 unk3(u16 arg) override {
|
||||
return ItemStoryManagerBase::unk3(arg & ~0x4000);
|
||||
return ItemStoryManagerBase::unk3(arg & ~MASK);
|
||||
}
|
||||
/** 0x38 */ virtual const u16 *getSaveFlagSpace() const override {
|
||||
return FileManager::GetInstance()->getItemFlagsConst();
|
||||
@@ -54,6 +56,26 @@ public:
|
||||
|
||||
static ItemflagManager *sInstance;
|
||||
|
||||
void setItemflag(u16 flag) {
|
||||
setFlag(flag | MASK);
|
||||
}
|
||||
|
||||
u16 getItemCounterOrFlag(u16 flag) const {
|
||||
return getCounterOrFlag(flag | MASK);
|
||||
}
|
||||
|
||||
void setItemFlag(u16 flag) {
|
||||
setFlag(flag | MASK);
|
||||
}
|
||||
|
||||
void setItemFlagOrCounterToValue(u16 flag, u16 value) {
|
||||
setFlagOrCounterToValue(flag | MASK, value);
|
||||
}
|
||||
|
||||
u16 getUncommittedItemValue(u16 flag) const {
|
||||
return getUncommittedValue(flag | MASK);
|
||||
}
|
||||
|
||||
private:
|
||||
static u16 sFlags[0x40];
|
||||
};
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
class SceneflagManager {
|
||||
private:
|
||||
static const u32 TEMPFLAG_OFFSET = 0x80;
|
||||
static const u32 ZONEFLAG_OFFSET = 0xC0;
|
||||
|
||||
FlagSpace mSceneflags;
|
||||
FlagSpace mTempflags;
|
||||
FlagSpace mZoneflags;
|
||||
@@ -18,9 +21,6 @@ private:
|
||||
static u16 sSceneFlags[8];
|
||||
static u16 sZoneFlags[0xFC];
|
||||
|
||||
// helper
|
||||
bool checkSceneflagHelper(u16 flag);
|
||||
|
||||
public:
|
||||
static SceneflagManager *sInstance;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void setShouldCommit(u16 flag);
|
||||
SceneflagManager();
|
||||
s32 isNotTempOrZoneFlag(u16 flag);
|
||||
s32 isZoneFlag(u32 flag);
|
||||
s32 isZoneFlag(u32 flag) const;
|
||||
void updateFlagindex(u16 flagindex);
|
||||
void copyFromSave(u32 flagindex);
|
||||
void unsetAllTempflags();
|
||||
@@ -37,11 +37,11 @@ public:
|
||||
void unsetZoneAndTempflags();
|
||||
void unsetAllZoneflags();
|
||||
void unsetZoneflagsForRoom(u16 roomId);
|
||||
u16 getZoneflagSlot(u16 roomId, u16 flag);
|
||||
u16 getSceneflagSlotGlobal(u16 sceneIdx, u16 flag);
|
||||
u16 getSceneflagSlot(u16 flag);
|
||||
u16 getTempflagSlot(u16 flag);
|
||||
bool checkZoneFlag(u16 roomId, u16 flag);
|
||||
u16 getZoneflagSlot(u16 roomId, u16 flag) const;
|
||||
u16 getSceneflagSlotGlobal(u16 sceneIdx, u16 flag) const;
|
||||
u16 getSceneflagSlot(u16 flag) const ;
|
||||
u16 getTempflagSlot(u16 flag) const;
|
||||
bool checkZoneFlag(u16 roomId, u16 flag) const;
|
||||
bool checkUncommittedZoneflag(u16 roomId, u16 flag);
|
||||
u16 checkUncommittedZoneflag2(u16 roomId, u16 flag) {
|
||||
return checkUncommittedZoneflag(roomId, flag);
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
u16 checkUncommittedTempOrSceneflag2(u16 flag) {
|
||||
return checkUncommittedTempOrSceneflag(flag);
|
||||
}
|
||||
u16 checkFlag(u16 roomId, u16 flag);
|
||||
u16 checkSceneflagGlobal(u16 sceneIdx, u16 flag);
|
||||
u16 checkTempOrSceneflag(u16 flag);
|
||||
u16 checkFlag(u16 roomId, u16 flag) const;
|
||||
u16 checkSceneflagGlobal(u16 sceneIdx, u16 flag) const;
|
||||
u16 checkTempOrSceneflag(u16 flag) const;
|
||||
u16 checkUncommittedFlag(u16 roomId, u16 flag);
|
||||
void setZoneflag(u16 roomId, u16 flag);
|
||||
void setFlag(u16 roomId, u16 flag);
|
||||
@@ -64,9 +64,33 @@ public:
|
||||
void unsetTempOrSceneflag(u16 flag);
|
||||
s32 commit();
|
||||
|
||||
bool checkBoolFlag(u16 roomid, u16 flag) {
|
||||
bool checkBoolFlag(u16 roomid, u16 flag) const {
|
||||
return checkFlag(roomid, flag);
|
||||
}
|
||||
|
||||
u16 checkTempflag_i(u16 roomid, u16 flag) const {
|
||||
return checkFlag(roomid, flag + TEMPFLAG_OFFSET);
|
||||
}
|
||||
|
||||
void setTempflag_i(u16 roomid, u16 flag) {
|
||||
setFlag(roomid, flag + TEMPFLAG_OFFSET);
|
||||
}
|
||||
|
||||
void unsetTempflag_i(u16 roomid, u16 flag) {
|
||||
unsetFlag(roomid, flag + TEMPFLAG_OFFSET);
|
||||
}
|
||||
|
||||
u16 checkZoneflag_i(u16 roomid, u16 flag) const {
|
||||
return checkFlag(roomid, flag + ZONEFLAG_OFFSET);
|
||||
}
|
||||
|
||||
void setZoneflag_i(u16 roomid, u16 flag) {
|
||||
setFlag(roomid, flag + ZONEFLAG_OFFSET);
|
||||
}
|
||||
|
||||
void unsetZoneflag_i(u16 roomid, u16 flag) {
|
||||
unsetFlag(roomid, flag + ZONEFLAG_OFFSET);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+20
-19
@@ -248,14 +248,14 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
|
||||
break;
|
||||
case EVENT_SET_ZONEFLAG:
|
||||
dStageMgr_c::GetInstance()->getFlagIndex();
|
||||
SceneflagManager::sInstance->setFlag(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), ((params1n2 >> 16) & 0xFFFF) + 0xC0
|
||||
SceneflagManager::sInstance->setZoneflag_i(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), (params1n2 >> 16) & 0xFFFF
|
||||
);
|
||||
break;
|
||||
case EVENT_UNSET_ZONEFLAG:
|
||||
dStageMgr_c::GetInstance()->getFlagIndex();
|
||||
SceneflagManager::sInstance->unsetFlag(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), ((params1n2 >> 16) & 0xFFFF) + 0xC0
|
||||
SceneflagManager::sInstance->unsetZoneflag_i(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), (params1n2 >> 16) & 0xFFFF
|
||||
);
|
||||
break;
|
||||
case EVENT_DELAY:
|
||||
@@ -337,7 +337,7 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
|
||||
break;
|
||||
case EVENT_SET_ITEM: {
|
||||
u16 flag = params1n2 & 0xFFFF;
|
||||
ItemflagManager::sInstance->setFlag(flag | 0x4000);
|
||||
ItemflagManager::sInstance->setItemFlag(flag);
|
||||
switch (params1n2) {
|
||||
case ITEM_FARORES_COURAGE:
|
||||
case ITEM_NAYRUS_WISDOM:
|
||||
@@ -380,7 +380,7 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
|
||||
} else if (counter == 0x1F3) {
|
||||
counter = dAcItem_c::getTotalBombCount();
|
||||
} else {
|
||||
counter = ItemflagManager::sInstance->getCounterOrFlag(counter | 0x4000);
|
||||
counter = ItemflagManager::sInstance->getItemCounterOrFlag(counter);
|
||||
}
|
||||
|
||||
if (counter >= threshold) {
|
||||
@@ -394,23 +394,23 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
|
||||
case EVENT_ADD_ITEM: {
|
||||
u16 flag = (params1n2 >> 16) & 0xFFFF;
|
||||
s16 change = (s16)(params1n2 & 0xFFFF);
|
||||
s32 value = ItemflagManager::sInstance->getCounterOrFlag(flag | 0x4000);
|
||||
s32 value = ItemflagManager::sInstance->getItemCounterOrFlag(flag);
|
||||
value += change;
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
} else if (value > 0x8000) {
|
||||
value = 0x7FFF;
|
||||
}
|
||||
ItemflagManager::sInstance->setFlagOrCounterToValue(flag | 0x4000, value);
|
||||
ItemflagManager::sInstance->setItemFlagOrCounterToValue(flag, value);
|
||||
break;
|
||||
}
|
||||
case EVENT_SET_TEMPFLAG:
|
||||
dStageMgr_c::GetInstance()->getFlagIndex();
|
||||
SceneflagManager::sInstance->setFlag(0x3F, ((params1n2 >> 16) & 0xFFFF) + 0x80);
|
||||
SceneflagManager::sInstance->setTempflag_i(0x3F, (params1n2 >> 16) & 0xFFFF);
|
||||
break;
|
||||
case EVENT_UNSET_TEMPFLAG:
|
||||
dStageMgr_c::GetInstance()->getFlagIndex();
|
||||
SceneflagManager::sInstance->unsetFlag(0x3F, ((params1n2 >> 16) & 0xFFFF) + 0x80);
|
||||
SceneflagManager::sInstance->unsetTempflag_i(0x3F, (params1n2 >> 16) & 0xFFFF);
|
||||
break;
|
||||
case EVENT_LIGHT_PILLAR_30: {
|
||||
s8 p4 = (params1n2 >> 24) & 0xFF;
|
||||
@@ -746,8 +746,8 @@ u16 dFlow_c::branchHandler04(const MsbFlowInfo *element) const {
|
||||
}
|
||||
|
||||
u16 dFlow_c::branchHandler05(const MsbFlowInfo *element) const {
|
||||
return !SceneflagManager::sInstance->checkFlag(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), (element->params1n2 & 0xFFFF) + 0xC0
|
||||
return !SceneflagManager::sInstance->checkZoneflag_i(
|
||||
dStage_c::GetInstance()->getCurrRoomId(), element->params1n2 & 0xFFFF
|
||||
);
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ u16 dFlow_c::branchHandler08(const MsbFlowInfo *element) const {
|
||||
}
|
||||
|
||||
u16 dFlow_c::branchHandler09(const MsbFlowInfo *element) const {
|
||||
return !SceneflagManager::sInstance->checkFlag(0x3F, (element->params1n2 & 0xFFFF) + 0x80);
|
||||
return !SceneflagManager::sInstance->checkTempflag_i(0x3F, element->params1n2 & 0xFFFF);
|
||||
}
|
||||
|
||||
u16 dFlow_c::branchHandler10(const MsbFlowInfo *element) const {
|
||||
@@ -892,7 +892,7 @@ u16 dFlow_c::branchHandler20(const MsbFlowInfo *element) const {
|
||||
|
||||
u16 dFlow_c::branchHandler21(const MsbFlowInfo *element) const {
|
||||
u16 ret = 0;
|
||||
if (matchesUnknownActorCategory(FiContext::getTargetActorId())) {
|
||||
if (shouldActorShowKillCount(FiContext::getTargetActorId())) {
|
||||
ret = 1;
|
||||
}
|
||||
return ret;
|
||||
@@ -1086,12 +1086,13 @@ bool dFlow_c::advanceUntil(s32 searchType, s32 searchParam3, s32 *pOutParams1n2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const s32 sTargetActorIds[] = {0, 1, 10, 46, 47, 48, 49, 50, 51, 52, 53,
|
||||
54, 55, 65, 67, 77, 81, 87, 88, 89, 90, -1};
|
||||
// TODO: Where are these IDs from?
|
||||
static const s32 sActorsWithKillCount[] = {0, 1, 10, 46, 47, 48, 49, 50, 51, 52, 53,
|
||||
54, 55, 65, 67, 77, 81, 87, 88, 89, 90, -1};
|
||||
|
||||
bool dFlow_c::matchesUnknownActorCategory(s32 id) const {
|
||||
for (s32 i = 0; sTargetActorIds[i] >= 0; i++) {
|
||||
if (sTargetActorIds[i] == id) {
|
||||
bool dFlow_c::shouldActorShowKillCount(s32 id) const {
|
||||
for (s32 i = 0; sActorsWithKillCount[i] >= 0; i++) {
|
||||
if (sActorsWithKillCount[i] == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ u16 ItemStoryManagerBase::getFlag(u16 flag) const {
|
||||
}
|
||||
|
||||
/** 800bf4e0 */
|
||||
u16 ItemStoryManagerBase::getUncommittedValue_Priv(u16 flag) {
|
||||
u16 ItemStoryManagerBase::getUncommittedValue_Priv(u16 flag) const {
|
||||
u16 *data = mpFlagSpace->getFlagPtrUnchecked();
|
||||
return mpFlagIndex->getCounterOrFlag(flag, data, mFlagCount);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ u16 ItemStoryManagerBase::getCounterOrFlag(u16 flag) const {
|
||||
}
|
||||
|
||||
/** 800bf5f0 */
|
||||
u16 ItemStoryManagerBase::getUncommittedValue(u16 flag) {
|
||||
u16 ItemStoryManagerBase::getUncommittedValue(u16 flag) const {
|
||||
return getUncommittedValue_Priv(flag);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
bool BitwiseFlagHelper::checkFlag(u16 slot, u16 shift, const u16 *pData, u16 flagCount) {
|
||||
bool BitwiseFlagHelper::checkFlag(u16 slot, u16 shift, const u16 *pData, u16 flagCount) const {
|
||||
return (pData[slot] >> shift) & 1;
|
||||
}
|
||||
void BitwiseFlagHelper::setFlag(u16 slot, u16 shift, u16 *pData, u16 flagCount) {
|
||||
|
||||
@@ -19,21 +19,15 @@ SceneflagManager::SceneflagManager()
|
||||
}
|
||||
|
||||
s32 SceneflagManager::isNotTempOrZoneFlag(u16 flag) {
|
||||
// return ((s32)flag - 0x80) < 0;
|
||||
return flag < 0x80;
|
||||
return flag < TEMPFLAG_OFFSET;
|
||||
}
|
||||
|
||||
inline s32 possiblyZoneFlag(u32 flag) {
|
||||
return flag >= 0xC0;
|
||||
}
|
||||
|
||||
s32 SceneflagManager::isZoneFlag(u32 flag) {
|
||||
if (possiblyZoneFlag(flag) && flag < 0x100) {
|
||||
s32 SceneflagManager::isZoneFlag(u32 flag) const {
|
||||
if (ZONEFLAG_OFFSET <= flag && flag < 0x100) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
// return flag >= 0xC0 && flag < 0x100;
|
||||
}
|
||||
void SceneflagManager::updateFlagindex(u16 sceneIdx) {
|
||||
if (sceneIdx != mSceneIdx) {
|
||||
@@ -43,9 +37,7 @@ void SceneflagManager::updateFlagindex(u16 sceneIdx) {
|
||||
}
|
||||
}
|
||||
void SceneflagManager::copyFromSave(u32 sceneIdx) {
|
||||
// sceneIdx &= 0xFFFF;
|
||||
u16 sceneIdx2 = sceneIdx;
|
||||
// missing clrlwi, more inlines?
|
||||
mSceneIdx = sceneIdx2;
|
||||
mSceneflags.copyFromSaveFile2(FileManager::GetInstance()->getSceneFlagsConst() + sceneIdx2 * 8, 0, 8);
|
||||
mTempflags.copyFromSaveFile(FileManager::GetInstance()->getTempFlagsConst(), 0, mTempflags.mCount);
|
||||
@@ -81,23 +73,23 @@ void SceneflagManager::unsetZoneflagsForRoom(u16 roomId) {
|
||||
// ? weird mask
|
||||
mZoneflags.setAllToZero((roomId & 0x3FF) * 4, 4);
|
||||
}
|
||||
u16 SceneflagManager::getZoneflagSlot(u16 roomId, u16 flag) {
|
||||
u16 SceneflagManager::getZoneflagSlot(u16 roomId, u16 flag) const {
|
||||
return (flag + roomId * 0x40) >> 4 & 0xFFF;
|
||||
}
|
||||
u16 SceneflagManager::getSceneflagSlotGlobal(u16 sceneIdx, u16 flag) {
|
||||
u16 SceneflagManager::getSceneflagSlotGlobal(u16 sceneIdx, u16 flag) const {
|
||||
return (flag + sceneIdx * 0x80) >> 4 & 0xFFF;
|
||||
}
|
||||
u16 SceneflagManager::getSceneflagSlot(u16 flag) {
|
||||
u16 SceneflagManager::getSceneflagSlot(u16 flag) const {
|
||||
return flag >> 4 & 0xFFF;
|
||||
}
|
||||
u16 SceneflagManager::getTempflagSlot(u16 flag) {
|
||||
u16 SceneflagManager::getTempflagSlot(u16 flag) const {
|
||||
return flag >> 4 & 0xFFF;
|
||||
}
|
||||
bool SceneflagManager::checkZoneFlag(u16 roomId, u16 flag) {
|
||||
bool SceneflagManager::checkZoneFlag(u16 roomId, u16 flag) const {
|
||||
if (flag == 0xFF) {
|
||||
return false;
|
||||
} else {
|
||||
u16 zoneflag = flag - 0xC0;
|
||||
u16 zoneflag = flag - ZONEFLAG_OFFSET;
|
||||
u16 *pData = FileManager::GetInstance()->getZoneFlagsConst();
|
||||
u16 slot = getZoneflagSlot(roomId, zoneflag);
|
||||
return mFlagHelper.checkFlag(slot, zoneflag % 16, pData, 0xFC);
|
||||
@@ -108,43 +100,38 @@ bool SceneflagManager::checkUncommittedZoneflag(u16 roomId, u16 flag) {
|
||||
return false;
|
||||
} else {
|
||||
u16 *pData;
|
||||
u16 zoneflag = flag - 0xC0;
|
||||
u16 zoneflag = flag - ZONEFLAG_OFFSET;
|
||||
pData = mZoneflags.getFlagPtrUnchecked();
|
||||
u16 slot = getZoneflagSlot(roomId, zoneflag);
|
||||
return mFlagHelper.checkFlag(slot, zoneflag % 16, pData, mZoneflags.mCount);
|
||||
}
|
||||
}
|
||||
inline bool SceneflagManager::checkSceneflagHelper(u16 flag) {
|
||||
u16 *pData;
|
||||
pData = mSceneflags.getFlagPtrUnchecked();
|
||||
// u16 slot = getSceneflagSlot2(flag);
|
||||
return mFlagHelper.checkFlag(getSceneflagSlot(flag), flag % 16, pData, mSceneflags.mCount);
|
||||
}
|
||||
bool SceneflagManager::checkUncommittedTempOrSceneflag(u16 flag) {
|
||||
if (flag >= 0x80) {
|
||||
u16 *pData;
|
||||
u16 tempflag = flag - 0x80;
|
||||
u16 *pData;
|
||||
if (flag >= TEMPFLAG_OFFSET) {
|
||||
u16 tempflag = flag - TEMPFLAG_OFFSET;
|
||||
pData = mTempflags.getFlagPtrUnchecked();
|
||||
u16 slot = getTempflagSlot(tempflag);
|
||||
return mFlagHelper.checkFlag(slot, tempflag % 16, pData, mTempflags.mCount);
|
||||
} else {
|
||||
return checkSceneflagHelper(flag);
|
||||
pData = mSceneflags.getFlagPtrUnchecked();
|
||||
return mFlagHelper.checkFlag(getSceneflagSlot(flag), flag % 16, pData, mSceneflags.mCount);
|
||||
}
|
||||
}
|
||||
u16 SceneflagManager::checkFlag(u16 roomId, u16 flag) {
|
||||
u16 SceneflagManager::checkFlag(u16 roomId, u16 flag) const {
|
||||
if (isZoneFlag(flag)) {
|
||||
return checkZoneFlag(roomId, flag);
|
||||
} else {
|
||||
return checkTempOrSceneflag(flag);
|
||||
}
|
||||
}
|
||||
u16 SceneflagManager::checkSceneflagGlobal(u16 sceneIdx, u16 flag) {
|
||||
u16 SceneflagManager::checkSceneflagGlobal(u16 sceneIdx, u16 flag) const {
|
||||
u16 *pData = FileManager::GetInstance()->getSceneFlagsConst();
|
||||
return mFlagHelper.checkFlag(getSceneflagSlotGlobal(sceneIdx, flag), flag % 16, pData, 0x800);
|
||||
}
|
||||
u16 SceneflagManager::checkTempOrSceneflag(u16 flag) {
|
||||
if (flag >= 0x80) {
|
||||
u16 tempflag = flag - 0x80;
|
||||
u16 SceneflagManager::checkTempOrSceneflag(u16 flag) const {
|
||||
if (flag >= TEMPFLAG_OFFSET) {
|
||||
u16 tempflag = flag - TEMPFLAG_OFFSET;
|
||||
const u16 *pData = FileManager::GetInstance()->getTempFlagsConst();
|
||||
u16 slot = getTempflagSlot(tempflag);
|
||||
return mFlagHelper.checkFlag(slot, tempflag % 16, pData, 4);
|
||||
@@ -162,7 +149,7 @@ u16 SceneflagManager::checkUncommittedFlag(u16 roomId, u16 flag) {
|
||||
void SceneflagManager::setZoneflag(u16 roomId, u16 flag) {
|
||||
if (checkUncommittedZoneflag2(roomId, flag) != 1 && flag != 0xFF) {
|
||||
u16 *pData;
|
||||
u16 zoneflag = flag - 0xC0;
|
||||
u16 zoneflag = flag - ZONEFLAG_OFFSET;
|
||||
pData = mZoneflags.getFlagPtrChecked();
|
||||
u16 slot = getZoneflagSlot(roomId, zoneflag);
|
||||
mFlagHelper.setFlag(slot, zoneflag % 16, pData, mZoneflags.mCount);
|
||||
@@ -191,8 +178,8 @@ void SceneflagManager::setSceneflagGlobal(u16 sceneIdx, u16 flag) {
|
||||
void SceneflagManager::setTempOrSceneflag(u16 flag) {
|
||||
if (checkUncommittedTempOrSceneflag2(flag) != 1) {
|
||||
u16 *pData;
|
||||
if (flag >= 0x80) {
|
||||
u16 tempflag = flag - 0x80;
|
||||
if (flag >= TEMPFLAG_OFFSET) {
|
||||
u16 tempflag = flag - TEMPFLAG_OFFSET;
|
||||
pData = mTempflags.getFlagPtrChecked();
|
||||
mFlagHelper.setFlag(getTempflagSlot(tempflag), tempflag % 16, pData, mTempflags.mCount);
|
||||
} else {
|
||||
@@ -205,7 +192,7 @@ void SceneflagManager::setTempOrSceneflag(u16 flag) {
|
||||
void SceneflagManager::unsetZoneflag(u16 roomId, u16 flag) {
|
||||
if (checkUncommittedZoneflag2(roomId, flag) != 0 && flag != 0xFF) {
|
||||
u16 *pData;
|
||||
u16 zoneflag = flag - 0xC0;
|
||||
u16 zoneflag = flag - ZONEFLAG_OFFSET;
|
||||
pData = mZoneflags.getFlagPtrChecked();
|
||||
u16 slot = getZoneflagSlot(roomId, zoneflag);
|
||||
mFlagHelper.unsetFlag(slot, zoneflag % 16, pData, mZoneflags.mCount);
|
||||
@@ -234,8 +221,8 @@ void SceneflagManager::unsetSceneflagGlobal(u16 sceneIdx, u16 flag) {
|
||||
void SceneflagManager::unsetTempOrSceneflag(u16 flag) {
|
||||
if (checkUncommittedTempOrSceneflag2(flag) != 0) {
|
||||
u16 *pData;
|
||||
if (flag >= 0x80) {
|
||||
u16 tempflag = flag - 0x80;
|
||||
if (flag >= TEMPFLAG_OFFSET) {
|
||||
u16 tempflag = flag - TEMPFLAG_OFFSET;
|
||||
pData = mTempflags.getFlagPtrChecked();
|
||||
mFlagHelper.unsetFlag(getTempflagSlot(tempflag), tempflag % 16, pData, mTempflags.mCount);
|
||||
} else {
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
}
|
||||
|
||||
/* 8016cd30 */ u16 Counter::getCommittedValue() const {
|
||||
return ItemflagManager::sInstance->getCounterOrFlag(counterId | 0x4000);
|
||||
return ItemflagManager::sInstance->getItemCounterOrFlag(counterId);
|
||||
}
|
||||
|
||||
/* 8016cd50 */ u16 Counter::getUncommittedValue() const {
|
||||
return ItemflagManager::sInstance->getUncommittedValue(counterId | 0x4000);
|
||||
return ItemflagManager::sInstance->getUncommittedItemValue(counterId);
|
||||
}
|
||||
|
||||
/* 8016cd70 */ void Counter::setValue(u16 num) {
|
||||
ItemflagManager::sInstance->setFlagOrCounterToValue(counterId | 0x4000, num);
|
||||
ItemflagManager::sInstance->setItemFlagOrCounterToValue(counterId, num);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user