mirror of
https://github.com/zeldaret/ss
synced 2026-05-23 23:05:20 -04:00
flagmanager progress
This commit is contained in:
+11
-11
@@ -4110,17 +4110,17 @@ copyFromSave__15TBoxFlagManagerFUs = .text:0x800BE930; // type:function size:0x5
|
||||
checkFlag__15TBoxFlagManagerFUsUs = .text:0x800BE990; // type:function size:0x94
|
||||
getFlagCount__15TBoxFlagManagerCFv = .text:0x800BEA30; // type:function size:0x8
|
||||
setFlag__15TBoxFlagManagerFUs = .text:0x800BEA40; // type:function size:0x80
|
||||
fn_800BEAC0 = .text:0x800BEAC0; // type:function size:0x40
|
||||
fn_800BEB00 = .text:0x800BEB00; // type:function size:0x7C
|
||||
fn_800BEB80 = .text:0x800BEB80; // type:function size:0x38
|
||||
fn_800BEBC0 = .text:0x800BEBC0; // type:function size:0xC
|
||||
fn_800BEBD0 = .text:0x800BEBD0; // type:function size:0x54
|
||||
fn_800BEC30 = .text:0x800BEC30; // type:function size:0x18
|
||||
fn_800BEC50 = .text:0x800BEC50; // type:function size:0x34
|
||||
fn_800BEC90 = .text:0x800BEC90; // type:function size:0x18
|
||||
fn_800BECB0 = .text:0x800BECB0; // type:function size:0xA0
|
||||
fn_800BED50 = .text:0x800BED50; // type:function size:0x8
|
||||
fn_800BED60 = .text:0x800BED60; // type:function size:0x94
|
||||
clearSavedFlags__18EnemyDefeatManagerFv = .text:0x800BEAC0; // type:function size:0x40
|
||||
checkUncommittedFlag__18EnemyDefeatManagerFUs = .text:0x800BEB00; // type:function size:0x7C
|
||||
__ct__18EnemyDefeatManagerFv = .text:0x800BEB80; // type:function size:0x38
|
||||
init__18EnemyDefeatManagerFv = .text:0x800BEBC0; // type:function size:0xC
|
||||
copyFromSave__18EnemyDefeatManagerFUs = .text:0x800BEBD0; // type:function size:0x54
|
||||
updateFlagIndex__18EnemyDefeatManagerFUs = .text:0x800BEC30; // type:function size:0x18
|
||||
clearAll__18EnemyDefeatManagerFv = .text:0x800BEC50; // type:function size:0x34
|
||||
checkIsValidFlag__18EnemyDefeatManagerFUs = .text:0x800BEC90; // type:function size:0x18
|
||||
checkFlag__18EnemyDefeatManagerFUs = .text:0x800BECB0; // type:function size:0xA0
|
||||
getFlagCount__18EnemyDefeatManagerCFv = .text:0x800BED50; // type:function size:0x8
|
||||
setFlag__18EnemyDefeatManagerFUs = .text:0x800BED60; // type:function size:0x94
|
||||
getFlagPtrChecked__9FlagSpaceFv = .text:0x800BEE00; // type:function size:0x3C
|
||||
getFlagPtrUnchecked__9FlagSpaceFv = .text:0x800BEE40; // type:function size:0x8
|
||||
unsetAll__9FlagSpaceFv = .text:0x800BEE50; // type:function size:0xC
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
class BitwiseFlagHelper {
|
||||
public:
|
||||
bool checkFlag(u16 slot, u16 shift, const u16 *pData, u16 flagCount);
|
||||
bool checkFlag2(u16 slot, u16 shift, const u16 *pData, s32 flagCount) {
|
||||
return checkFlag(slot, shift, pData, flagCount);
|
||||
}
|
||||
void setFlag(u16 slot, u16 shift, u16 *pData, u16 flagCount);
|
||||
void unsetFlag(u16 slot, u16 shift, u16 *pData, u16 flagCount);
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <toBeSorted/flag_space.h>
|
||||
#include <toBeSorted/file_manager.h>
|
||||
#include <toBeSorted/bitwise_flag_helper.h>
|
||||
#include <libc.h>
|
||||
|
||||
class CommittableFlagManager {
|
||||
public:
|
||||
@@ -12,9 +13,12 @@ class CommittableFlagManager {
|
||||
void setNeedsCommit(bool commit) {
|
||||
mNeedsCommit = commit;
|
||||
}
|
||||
// CommittableFlagManager(bool commit) {
|
||||
// mNeedsCommit = commit;
|
||||
// }
|
||||
CommittableFlagManager() {
|
||||
mNeedsCommit = false;
|
||||
}
|
||||
CommittableFlagManager(bool commit) {
|
||||
mNeedsCommit = commit;
|
||||
}
|
||||
};
|
||||
|
||||
bool CommittableFlagManager::commitIfNecessary() {
|
||||
@@ -32,21 +36,24 @@ class TBoxFlagManager: public CommittableFlagManager {
|
||||
// bool mNeedsCommit;
|
||||
// u32 pad;
|
||||
FlagSpace mFlagSpace;
|
||||
s16 mSceneIndex;
|
||||
u16 mSceneIndex;
|
||||
BitwiseFlagHelper mFlagHelper;
|
||||
|
||||
static u16* sFlags;
|
||||
public:
|
||||
virtual void doCommit();
|
||||
virtual void doCommit() override;
|
||||
bool checkUncommittedFlag(u16 flag);
|
||||
TBoxFlagManager();
|
||||
virtual ~TBoxFlagManager() {}
|
||||
void init();
|
||||
void copyFromSave(u16 sceneIndex);
|
||||
bool checkFlag(u16 sceneIndex, u16 flag);
|
||||
virtual s32 getFlagCount() const;
|
||||
virtual u16 getFlagCount() const;
|
||||
void setFlag(u16 flag);
|
||||
bool checkUncommittedFlag(u16 sceneIndex, u16 flag);
|
||||
u16 checkUncommittedFlag2(u16 flag) {
|
||||
return checkUncommittedFlag(flag);
|
||||
}
|
||||
};
|
||||
|
||||
void TBoxFlagManager::doCommit() {
|
||||
@@ -59,27 +66,124 @@ bool TBoxFlagManager::checkUncommittedFlag(u16 flag) {
|
||||
return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount);
|
||||
}
|
||||
|
||||
TBoxFlagManager::TBoxFlagManager(): mFlagSpace(sFlags, 2) {
|
||||
TBoxFlagManager::TBoxFlagManager(): CommittableFlagManager(false), mFlagSpace(sFlags, 2) {
|
||||
mSceneIndex = 0xFFFF;
|
||||
}
|
||||
|
||||
void TBoxFlagManager::init() {}
|
||||
|
||||
void TBoxFlagManager::copyFromSave(u16 sceneIndex) {
|
||||
// mr should be a clrlwi
|
||||
mSceneIndex = sceneIndex;
|
||||
u16* flags = FileManager::getInstance()->getTBoxFlagsConst();
|
||||
mFlagSpace.copyFromSaveFile2(flags + (sceneIndex * 2), 0, 2);
|
||||
}
|
||||
|
||||
bool TBoxFlagManager::checkFlag(u16 sceneIndex, u16 flag) {
|
||||
s32 actualFlag = sceneIndex * 0x20 + flag;
|
||||
return mFlagHelper.checkFlag(actualFlag % 16, actualFlag / 16, FileManager::getInstance()->getTBoxFlagsConst(), getFlagCount());
|
||||
s32 actualFlag = (flag + sceneIndex * 0x20);
|
||||
return mFlagHelper.checkFlag(actualFlag / 16, flag % 16, FileManager::getInstance()->getTBoxFlagsConst(), getFlagCount());
|
||||
}
|
||||
|
||||
s32 TBoxFlagManager::getFlagCount() const {
|
||||
u16 TBoxFlagManager::getFlagCount() const {
|
||||
return 0x200;
|
||||
}
|
||||
|
||||
void TBoxFlagManager::setFlag(u16 flag) {
|
||||
if (checkUncommittedFlag2(flag) != 1) {
|
||||
mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount);
|
||||
setNeedsCommit(true);
|
||||
}
|
||||
}
|
||||
|
||||
class EnemyDefeatManager : public CommittableFlagManager {
|
||||
public:
|
||||
FlagSpace mFlagSpace;
|
||||
BitwiseFlagHelper mFlagHelper;
|
||||
u16 mSceneIndex;
|
||||
|
||||
static u16* sFlags;
|
||||
|
||||
void clearSavedFlags();
|
||||
bool checkUncommittedFlag(u16 flag);
|
||||
u16 checkUncommittedFlag2(u16 flag) {
|
||||
return checkUncommittedFlag(flag);
|
||||
}
|
||||
EnemyDefeatManager();
|
||||
void init();
|
||||
void copyFromSave(u16 sceneIndex);
|
||||
void updateFlagIndex(u16 sceneIndex);
|
||||
void clearAll();
|
||||
bool checkIsValidFlag(u16 flag);
|
||||
bool checkFlag(u16 flag);
|
||||
virtual ~EnemyDefeatManager() {}
|
||||
virtual u16 getFlagCount() const;
|
||||
void setFlag(u16 flag);
|
||||
};
|
||||
|
||||
void EnemyDefeatManager::clearSavedFlags() {
|
||||
u16 empty[0x1000];
|
||||
memset(empty, 0, 0x2000);
|
||||
FileManager::getInstance()->setEnemyDefeatFlags(empty, 0, 0x1000);
|
||||
}
|
||||
|
||||
bool EnemyDefeatManager::checkUncommittedFlag(u16 flag) {
|
||||
if (checkIsValidFlag(flag)) {
|
||||
|
||||
return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
EnemyDefeatManager::EnemyDefeatManager(): CommittableFlagManager(false), mFlagSpace(sFlags, 12 /* later */) {
|
||||
|
||||
}
|
||||
|
||||
void EnemyDefeatManager::init() {
|
||||
mSceneIndex = 0;
|
||||
clearAll();
|
||||
}
|
||||
|
||||
void EnemyDefeatManager::copyFromSave(u16 sceneIndex) {
|
||||
mSceneIndex = sceneIndex;
|
||||
u16 count = mFlagSpace.mCount;
|
||||
u16* flags = FileManager::getInstance()->getEnemyDefeatFlagsConst();
|
||||
mFlagSpace.copyFromSaveFile(flags, 0, count);
|
||||
}
|
||||
|
||||
void EnemyDefeatManager::updateFlagIndex(u16 sceneIndex) {
|
||||
if (mSceneIndex == sceneIndex) {
|
||||
return;
|
||||
}
|
||||
mSceneIndex = sceneIndex;
|
||||
clearAll();
|
||||
}
|
||||
|
||||
void EnemyDefeatManager::clearAll() {
|
||||
clearSavedFlags();
|
||||
mFlagSpace.unsetAll();
|
||||
}
|
||||
|
||||
bool EnemyDefeatManager::checkIsValidFlag(u16 flag) {
|
||||
return flag < 0xFFFF;
|
||||
}
|
||||
|
||||
bool EnemyDefeatManager::checkFlag(u16 flag) {
|
||||
if (!checkIsValidFlag(flag)) {
|
||||
return false;
|
||||
} else {
|
||||
u16* pData = FileManager::getInstance()->getEnemyDefeatFlagsConst();
|
||||
return mFlagHelper.checkFlag(flag / 16, flag % 16, pData, getFlagCount());
|
||||
}
|
||||
}
|
||||
|
||||
u16 EnemyDefeatManager::getFlagCount() const {
|
||||
return 0x1000;
|
||||
}
|
||||
|
||||
void EnemyDefeatManager::setFlag(u16 flag) {
|
||||
if (checkUncommittedFlag2(flag) != 1 && checkIsValidFlag(flag)) {
|
||||
mFlagHelper.setFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrChecked(), mFlagSpace.mCount);
|
||||
setNeedsCommit(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user