mirror of
https://github.com/zeldaret/ss
synced 2026-07-11 06:45:20 -04:00
Merge branch 'main' into pr/17
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
#include <egg/core/eggThread.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/* 80673b10 */ nw4r::ut::List Thread::sThreadList;
|
||||
/* 80576770 */ void (*Thread::sOldSwitchThreadCallback)(OSThread *, OSThread *);
|
||||
|
||||
|
||||
/* 80496910 */ Thread::Thread(u32 stackSize, int msgCount, int priority, Heap *heap) {
|
||||
if (heap == nullptr) {
|
||||
heap = Heap::sCurrentHeap;
|
||||
}
|
||||
|
||||
mContainingHeap = heap;
|
||||
mStackSize = ROUND_DOWN(stackSize, 0x20);
|
||||
mStackMemory = Heap::alloc(ROUND_DOWN(stackSize, 0x20), 0x20, heap);
|
||||
mOSThread = Heap::alloc<OSThread>(mContainingHeap, 0x20);
|
||||
OSCreateThread(mOSThread, start, this, (char *)mStackMemory + mStackSize, mStackSize, priority, 1);
|
||||
mAllocatableHeap = nullptr;
|
||||
mCurrentHeap = nullptr;
|
||||
setCommonMesgQueue(msgCount, mContainingHeap);
|
||||
}
|
||||
|
||||
/* 804969e0 */ Thread::Thread(OSThread *osThread, int msgCount) {
|
||||
mContainingHeap = nullptr;
|
||||
mOSThread = osThread;
|
||||
mStackSize = (u8 *)osThread->stackBegin - (u8 *)osThread->stackEnd;
|
||||
mStackMemory = osThread->stackEnd;
|
||||
mAllocatableHeap = nullptr;
|
||||
mCurrentHeap = nullptr;
|
||||
setCommonMesgQueue(msgCount, Heap::sCurrentHeap);
|
||||
}
|
||||
|
||||
/* 80496a60 */ Thread::~Thread() {
|
||||
nw4r::ut::List_Remove(&sThreadList, this);
|
||||
if (mContainingHeap != nullptr) {
|
||||
if (!OSIsThreadTerminated(mOSThread)) {
|
||||
OSDetachThread(mOSThread);
|
||||
OSCancelThread(mOSThread);
|
||||
}
|
||||
Heap::free(mStackMemory, mContainingHeap);
|
||||
Heap::free(mOSThread, mContainingHeap);
|
||||
}
|
||||
Heap::free(mMesgBuffer, nullptr);
|
||||
}
|
||||
|
||||
/* 80496b20 */ Thread *Thread::findThread(OSThread *thread) {
|
||||
Thread *ptr = nullptr;
|
||||
while ((ptr = (Thread *)nw4r::ut::List_GetNext(&sThreadList, ptr)) != nullptr) {
|
||||
if (ptr->mOSThread == thread) {
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* 80496b90 */ void Thread::initialize() {
|
||||
// TODO offsetof
|
||||
nw4r::ut::List_Init(&sThreadList, 0x44);
|
||||
sOldSwitchThreadCallback = OSSetSwitchThreadCallback(switchThreadCallback);
|
||||
}
|
||||
|
||||
/* 80496bd0 */ void Thread::setThreadCurrentHeap(Heap *heap) {
|
||||
OSDisableScheduler();
|
||||
OSThread *myThread = mOSThread;
|
||||
OSThread *currentThread = OSGetCurrentThread();
|
||||
if (currentThread != myThread) {
|
||||
mCurrentHeap = heap;
|
||||
} else {
|
||||
if (heap != nullptr) {
|
||||
if (mCurrentHeap == nullptr) {
|
||||
mCurrentHeap = Heap::sCurrentHeap;
|
||||
}
|
||||
heap->_becomeCurrentHeapWithoutLock();
|
||||
} else {
|
||||
if (mCurrentHeap != nullptr) {
|
||||
mCurrentHeap->_becomeCurrentHeapWithoutLock();
|
||||
mCurrentHeap = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OSEnableScheduler();
|
||||
}
|
||||
|
||||
/* 80496c70 */ void Thread::switchThreadCallback(OSThread *from, OSThread *to) {
|
||||
Thread *fromThread = from != nullptr ? findThread(from) : nullptr;
|
||||
Thread *toThread = to != nullptr ? findThread(to) : nullptr;
|
||||
|
||||
if (fromThread != nullptr) {
|
||||
fromThread->onExit();
|
||||
if (fromThread->mCurrentHeap != nullptr) {
|
||||
Heap *curr = Heap::sCurrentHeap;
|
||||
fromThread->mCurrentHeap->_becomeCurrentHeapWithoutLock();
|
||||
fromThread->mCurrentHeap = curr;
|
||||
}
|
||||
}
|
||||
|
||||
if (toThread != nullptr) {
|
||||
if (toThread->mCurrentHeap != nullptr) {
|
||||
Heap *curr = Heap::sCurrentHeap;
|
||||
toThread->mCurrentHeap->_becomeCurrentHeapWithoutLock();
|
||||
toThread->mCurrentHeap = curr;
|
||||
}
|
||||
toThread->onEnter();
|
||||
}
|
||||
|
||||
if (sOldSwitchThreadCallback != nullptr) {
|
||||
(sOldSwitchThreadCallback)(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
/* 80496d60 */ void Thread::setCommonMesgQueue(int mesgCount, Heap *heap) {
|
||||
mMesgCount = mesgCount;
|
||||
mMesgBuffer = Heap::alloc<OSMessage>(mesgCount, heap);
|
||||
OSInitMessageQueue(&mMesgQueue, mMesgBuffer, mMesgCount);
|
||||
nw4r::ut::List_Append(&sThreadList, this);
|
||||
}
|
||||
|
||||
/* 80496dc0 */ void *Thread::start(void *arg) {
|
||||
Thread *thread = static_cast<Thread*>(arg);
|
||||
return thread->run();
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <nw4r/ut.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
NW4R_UT_RTTI_DEF_DERIVED(FileStream, IOStream);
|
||||
|
||||
void FileStream::Cancel() {}
|
||||
|
||||
bool FileStream::CancelAsync(AsyncCallback callback, void *arg) {
|
||||
#pragma unused(callback)
|
||||
#pragma unused(arg)
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 FileStream::FilePosition::Skip(long offset) {
|
||||
if (offset != 0) {
|
||||
s64 newOffset = mFileOffset + offset;
|
||||
mFileOffset = Clamp<s64>(newOffset, 0, mFileSize);
|
||||
}
|
||||
|
||||
return mFileOffset;
|
||||
}
|
||||
|
||||
u32 FileStream::FilePosition::Append(long offset) {
|
||||
s64 newOffset = mFileOffset + offset;
|
||||
|
||||
if (newOffset < 0) {
|
||||
mFileOffset = 0;
|
||||
} else {
|
||||
mFileOffset = newOffset;
|
||||
mFileSize = Max(mFileOffset, mFileSize);
|
||||
}
|
||||
|
||||
return mFileOffset;
|
||||
}
|
||||
|
||||
void FileStream::FilePosition::Seek(long offset, unsigned long origin) {
|
||||
switch (origin) {
|
||||
case SEEK_BEG:
|
||||
mFileOffset = 0;
|
||||
break;
|
||||
case SEEK_END:
|
||||
mFileOffset = mFileSize;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Skip(offset);
|
||||
}
|
||||
|
||||
// TODO: This should not be necessary. Because of nw4r::snd? still the case for ss
|
||||
DECOMP_FORCEACTIVE(ut_FileStream_cpp, FileStream::GetRuntimeTypeInfo);
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <nw4r/ut.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
NW4R_UT_RTTI_DEF_BASE(IOStream);
|
||||
|
||||
bool IOStream::ReadAsync(void *dst, unsigned long size, AsyncCallback callback, void *arg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IOStream::Write(const void *src, unsigned long size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IOStream::WriteAsync(const void *src, unsigned long size, AsyncCallback callback, void *arg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IOStream::IsBusy() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
@@ -0,0 +1,76 @@
|
||||
#include <nw4r/ut/ut_LinkList.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
namespace detail {
|
||||
|
||||
/* 8042a850 */
|
||||
LinkListImpl::~LinkListImpl() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
/* 8042a8e0 */
|
||||
LinkListImpl::Iterator LinkListImpl::Erase(LinkListImpl::Iterator it) {
|
||||
Iterator copy(it);
|
||||
return Erase(it, ++copy);
|
||||
}
|
||||
|
||||
/* 8042a930 */
|
||||
void LinkListImpl::Clear() {
|
||||
Erase(GetBeginIter(), GetEndIter());
|
||||
}
|
||||
|
||||
/* 8042a980 */
|
||||
LinkListImpl::Iterator LinkListImpl::Insert(Iterator it, LinkListNode *p) {
|
||||
LinkListNode *next = it.mNode;
|
||||
LinkListNode *prev = next->mPrev;
|
||||
|
||||
// prev <- p -> next
|
||||
p->mNext = next;
|
||||
p->mPrev = prev;
|
||||
// prev <-> p <-> next
|
||||
next->mPrev = p;
|
||||
prev->mNext = p;
|
||||
|
||||
mSize++;
|
||||
|
||||
return Iterator(p);
|
||||
}
|
||||
|
||||
/* 8042a9b0 */
|
||||
LinkListImpl::Iterator LinkListImpl::Erase(LinkListNode *p) {
|
||||
LinkListNode *next = p->mNext;
|
||||
LinkListNode *prev = p->mPrev;
|
||||
|
||||
// Remove connections to node
|
||||
next->mPrev = prev;
|
||||
prev->mNext = next;
|
||||
|
||||
mSize--;
|
||||
|
||||
// Isolate node
|
||||
p->mNext = NULL;
|
||||
p->mPrev = NULL;
|
||||
|
||||
return Iterator(next);
|
||||
}
|
||||
|
||||
/* Not in SS */
|
||||
LinkListImpl::Iterator LinkListImpl::Erase(Iterator begin, Iterator end) {
|
||||
LinkListNode *pCur = begin.mNode;
|
||||
LinkListNode *pEnd = end.mNode;
|
||||
|
||||
while (pCur != pEnd) {
|
||||
// Preserve next node before erasing pointers
|
||||
LinkListNode *pNext = pCur->mNext;
|
||||
// Erase current node
|
||||
Erase(pCur);
|
||||
pCur = pNext;
|
||||
}
|
||||
|
||||
return Iterator(pEnd);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
@@ -0,0 +1,88 @@
|
||||
#include <nw4r/ut.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
template <typename T>
|
||||
TagProcessorBase<T>::TagProcessorBase() {}
|
||||
|
||||
template <typename T>
|
||||
TagProcessorBase<T>::~TagProcessorBase() {}
|
||||
|
||||
template <typename T>
|
||||
Operation TagProcessorBase<T>::Process(u16 ch, PrintContext<T> *ctx) {
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
ProcessLinefeed(ctx);
|
||||
return OPERATION_NEXT_LINE;
|
||||
case '\t':
|
||||
ProcessTab(ctx);
|
||||
return OPERATION_NO_CHAR_SPACE;
|
||||
}
|
||||
|
||||
return OPERATION_DEFAULT;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Operation TagProcessorBase<T>::CalcRect(Rect *rect, u16 ch, PrintContext<T> *ctx) {
|
||||
switch (ch) {
|
||||
case '\n': {
|
||||
const TextWriterBase<T> &writer = *ctx->writer;
|
||||
rect->right = writer.GetCursorX();
|
||||
rect->top = writer.GetCursorY();
|
||||
ProcessLinefeed(ctx);
|
||||
rect->left = writer.GetCursorX();
|
||||
rect->bottom = writer.GetCursorY() + ctx->writer->GetFontHeight();
|
||||
rect->Normalize();
|
||||
return OPERATION_NEXT_LINE;
|
||||
}
|
||||
case '\t': {
|
||||
const TextWriterBase<T> &writer = *ctx->writer;
|
||||
rect->left = writer.GetCursorX();
|
||||
ProcessTab(ctx);
|
||||
rect->right = writer.GetCursorX();
|
||||
rect->top = writer.GetCursorY();
|
||||
rect->bottom = rect->top + writer.GetFontHeight();
|
||||
rect->Normalize();
|
||||
return OPERATION_NO_CHAR_SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
return OPERATION_DEFAULT;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TagProcessorBase<T>::ProcessTab(PrintContext<T> *ctx) {
|
||||
TextWriterBase<T> &writer = *ctx->writer;
|
||||
|
||||
int tabWidth = writer.GetTabWidth();
|
||||
if (tabWidth <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
f32 charWidth = writer.IsWidthFixed() ? writer.GetFixedWidth() : writer.GetFontWidth();
|
||||
|
||||
f32 dx = writer.GetCursorX() - ctx->x;
|
||||
f32 tabPixel = tabWidth * charWidth;
|
||||
int numTab = static_cast<int>(dx / tabPixel) + 1;
|
||||
f32 x = ctx->x + (tabPixel * numTab);
|
||||
|
||||
writer.SetCursorX(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TagProcessorBase<T>::ProcessLinefeed(PrintContext<T> *ctx) {
|
||||
TextWriterBase<T> &writer = *ctx->writer;
|
||||
|
||||
f32 x = ctx->x;
|
||||
f32 y = writer.GetCursorY() + writer.GetLineHeight();
|
||||
|
||||
writer.SetCursorX(x);
|
||||
writer.SetCursorY(y);
|
||||
}
|
||||
|
||||
template class TagProcessorBase<char>;
|
||||
template class TagProcessorBase<wchar_t>;
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <nw4r/ut/ut_binaryFileFormat.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace ut {
|
||||
|
||||
/* 8042a9e0 */
|
||||
bool IsValidBinaryFile(const BinaryFileHeader *header, unsigned long magic, u16 version, u16 numBlocks) {
|
||||
if (header->magic != magic) {
|
||||
return false;
|
||||
}
|
||||
if (header->byteOrder != 0xFEFF) {
|
||||
return false;
|
||||
}
|
||||
if (header->version != version) {
|
||||
return false;
|
||||
}
|
||||
if (header->fileSize < (numBlocks * sizeof(BinaryBlockHeader) + sizeof(BinaryFileHeader))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header->numBlocks < numBlocks) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ut
|
||||
} // namespace nw4r
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class ArrowCounter : public Counter {
|
||||
public:
|
||||
ArrowCounter();
|
||||
/* 8016DFA0 */ ~ArrowCounter() {}
|
||||
/* 8016E000 */ virtual u16 getMax() override {
|
||||
return 20;
|
||||
};
|
||||
};
|
||||
|
||||
/* 80575618 */ ArrowCounter lbl_80575618;
|
||||
|
||||
/* 8016DFE0 */ ArrowCounter::ArrowCounter() : Counter(0x1f2) {}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class BombCounter : public Counter {
|
||||
public:
|
||||
BombCounter();
|
||||
/* 8016E020 */ ~BombCounter() {}
|
||||
/* 8016E080 */ virtual u16 getMax() override {
|
||||
return 10;
|
||||
}
|
||||
};
|
||||
|
||||
/* 80575620 */ BombCounter lbl_80575620;
|
||||
|
||||
/* 8016E060 */ BombCounter::BombCounter(): Counter(0x1f3) { }
|
||||
@@ -0,0 +1,55 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
// TODO use the item flag manager once it exists
|
||||
class ItemFlagManager {
|
||||
public:
|
||||
ItemFlagManager() {}
|
||||
/** 0x08 */ virtual ~ItemFlagManager();
|
||||
/** 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);
|
||||
/** 0x30 */ virtual u16 getUncommittedValue(u16 flag);
|
||||
/** 0x34 */ virtual void unk3();
|
||||
/** 0x38 */ virtual u16 *getSaveFlagSpace() = 0;
|
||||
};
|
||||
|
||||
// TODO set up item flag manager
|
||||
extern "C" ItemFlagManager *lbl_80575400;
|
||||
|
||||
|
||||
/* 8016cc40 */ s32 Counter::checkedAdd(s32 num) {
|
||||
s32 uncommitted = getUncommittedValue();
|
||||
s32 max = getMax();
|
||||
s32 result = uncommitted + num;
|
||||
if (result < 0) {
|
||||
setValue(0);
|
||||
} else if (result < max) {
|
||||
setValue(result);
|
||||
} else {
|
||||
setValue(max);
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return result <= max ? 0 : (result - max);
|
||||
}
|
||||
|
||||
/* 8016cd30 */ u16 Counter::getCommittedValue() {
|
||||
return lbl_80575400->getCounterOrFlag(counterId | 0x4000);
|
||||
}
|
||||
|
||||
/* 8016cd50 */ u16 Counter::getUncommittedValue() {
|
||||
return lbl_80575400->getUncommittedValue(counterId | 0x4000);
|
||||
}
|
||||
|
||||
/* 8016cd70 */ void Counter::setValue(u16 num) {
|
||||
lbl_80575400->setFlagOrCounterToValue(counterId | 0x4000, num);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class ExtraWalletCounter : public Counter {
|
||||
public:
|
||||
ExtraWalletCounter();
|
||||
/* 8016E220 */ ~ExtraWalletCounter() {}
|
||||
/* 8016E280 */ virtual u16 getMax() override {
|
||||
return 3;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* 80575640 */ ExtraWalletCounter lbl_80575640;
|
||||
|
||||
/* 8016E260 */ ExtraWalletCounter::ExtraWalletCounter(): Counter(0x1fc) { }
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class KeyPieceCounter : public Counter {
|
||||
public:
|
||||
KeyPieceCounter();
|
||||
/* 8016E1A0 */ ~KeyPieceCounter() {}
|
||||
/* 8016E200 */ virtual u16 getMax() override {
|
||||
return 5;
|
||||
}
|
||||
};
|
||||
|
||||
/* 80575638 */ KeyPieceCounter lbl_80575638;
|
||||
|
||||
/* 8016E1E0 */ KeyPieceCounter::KeyPieceCounter() : Counter(0x1f9) {}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
static u16 getBaseCapacity();
|
||||
static u16 getExtraWalletCapacity();
|
||||
|
||||
class RupeeCounter : public Counter {
|
||||
public:
|
||||
RupeeCounter();
|
||||
/* 8016DEF0 */ ~RupeeCounter() {}
|
||||
/* 8016DF50 */ virtual u16 getMax() override {
|
||||
return (getBaseCapacity() + getExtraWalletCapacity());
|
||||
}
|
||||
};
|
||||
|
||||
struct WalletStruct {
|
||||
u32 flag;
|
||||
u16 capacity;
|
||||
};
|
||||
|
||||
// TODO set up item flag manager
|
||||
extern "C" void *lbl_80575400;
|
||||
extern "C" u16 fn_800BF5E0(void *data, u16 flag);
|
||||
|
||||
/* 8016DE10 */ static u16 getBaseCapacity() {
|
||||
int i = 0;
|
||||
/* 804E91B0 */ WalletStruct wallet_definitions[4] = {
|
||||
{0x6c, 500},
|
||||
{0x6d, 1000},
|
||||
{0x6e, 5000},
|
||||
{0x6f, 9000},
|
||||
};
|
||||
const WalletStruct *wallet = &wallet_definitions[3];
|
||||
for (; i < 4; i++, wallet--) {
|
||||
if (fn_800BF5E0(lbl_80575400, wallet->flag)) {
|
||||
return wallet->capacity;
|
||||
}
|
||||
}
|
||||
return 300;
|
||||
}
|
||||
|
||||
// TODO main counters class
|
||||
extern "C" u16 fn_8016D730(u16);
|
||||
|
||||
/* 8016DEC0 */ static u16 getExtraWalletCapacity() {
|
||||
return 300 * fn_8016D730(0x27);
|
||||
}
|
||||
|
||||
/* 80575610 */ RupeeCounter lbl_80575610;
|
||||
|
||||
/* 8016DF30 */ RupeeCounter::RupeeCounter() : Counter(0x1f5) {}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class SlingshotSeedCounter : public Counter {
|
||||
public:
|
||||
SlingshotSeedCounter();
|
||||
/* 8016E120 */ ~SlingshotSeedCounter() {}
|
||||
/* 8016E180 */ virtual u16 getMax() override {
|
||||
return 20;
|
||||
};
|
||||
};
|
||||
|
||||
/* 80575630 */ SlingshotSeedCounter lbl_80575630;
|
||||
|
||||
/* 8016E160 */ SlingshotSeedCounter::SlingshotSeedCounter() : Counter(0x1ed) {}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <toBeSorted/counters/counter.h>
|
||||
|
||||
class TearCounter : public Counter {
|
||||
public:
|
||||
TearCounter();
|
||||
/* 8016E0A0 */ ~TearCounter() {}
|
||||
/* 8016E100 */ virtual u16 getMax() override {
|
||||
return 15;
|
||||
};
|
||||
};
|
||||
|
||||
/* 80575628 */ TearCounter lbl_80575628;
|
||||
|
||||
/* 8016E0E0 */ TearCounter::TearCounter(): Counter(0x1f4) { }
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "toBeSorted/bitwise_flag_helper.h"
|
||||
#include "toBeSorted/file_manager.h"
|
||||
#include "toBeSorted/flag_space.h"
|
||||
#include "toBeSorted/unk_flag_stuff.h"
|
||||
#include <libc.h>
|
||||
|
||||
// TODO move
|
||||
extern "C" UnkFlagDefinition lbl_80511AF0[];
|
||||
|
||||
class DungeonflagManager {
|
||||
public:
|
||||
bool mShouldCommit;
|
||||
u16 mStageIndex;
|
||||
UnkFlagStuff *mFlagStuff;
|
||||
FlagSpace mFlagSpace;
|
||||
|
||||
static u16 sDungeonFlags[8];
|
||||
// static DungeonflagManager *sInstance;
|
||||
|
||||
void copyFromSave(s16 flag);
|
||||
void copyFromSave(u16 flagIndex);
|
||||
void setCommitFlag(u16 flag);
|
||||
DungeonflagManager();
|
||||
void setupFlagStuff();
|
||||
void setToValue(u16 flag, u32 value);
|
||||
void setFlag(u16 flag);
|
||||
u32 getDungeonFlag(u16 flag);
|
||||
bool doCommit();
|
||||
|
||||
/** inline shenanigans to get copyFromSave to match */
|
||||
static inline u16 *saveFilePtr(u16 flagIndex) {
|
||||
u32 offset = (flagIndex & 0x1fff) * 8;
|
||||
return FileManager::sInstance->getDungeonFlagsConst() + offset;
|
||||
}
|
||||
};
|
||||
|
||||
/** 80575404 */
|
||||
// DungeonflagManager *DungeonflagManager::sInstance = nullptr;
|
||||
|
||||
/** 805a9c58 */
|
||||
u16 DungeonflagManager::sDungeonFlags[8] = {};
|
||||
|
||||
/** 800bf8d0 */
|
||||
void DungeonflagManager::copyFromSave(u16 flagIndex) {
|
||||
mFlagSpace.copyFromSaveFile(saveFilePtr(flagIndex), 0, 0x8);
|
||||
}
|
||||
|
||||
/** 800bf930 */
|
||||
void DungeonflagManager::setCommitFlag(u16 flag) {
|
||||
mShouldCommit = true;
|
||||
}
|
||||
|
||||
/** 0x800bf940 */
|
||||
DungeonflagManager::DungeonflagManager()
|
||||
: mShouldCommit(false), mStageIndex(-1), mFlagStuff(nullptr),
|
||||
mFlagSpace(sDungeonFlags, ARRAY_LENGTH(sDungeonFlags)) {}
|
||||
|
||||
/** 800bf980 */
|
||||
void DungeonflagManager::setupFlagStuff() {
|
||||
mFlagStuff = new UnkFlagStuff(0x11, lbl_80511AF0);
|
||||
mShouldCommit = false;
|
||||
}
|
||||
|
||||
/** 800bf9e0 */
|
||||
void DungeonflagManager::copyFromSave(s16 flag) {
|
||||
mStageIndex = flag;
|
||||
copyFromSave((u16)flag);
|
||||
}
|
||||
|
||||
/** 800bf9f0 */
|
||||
void DungeonflagManager::setToValue(u16 flag, u32 value) {
|
||||
u16 *data = mFlagSpace.getFlagPtrChecked();
|
||||
mFlagStuff->setCounterOrFlag(flag, data, 8, value);
|
||||
setCommitFlag(flag);
|
||||
}
|
||||
|
||||
/** 800bfa60 */
|
||||
void DungeonflagManager::setFlag(u16 flag) {
|
||||
u16 *data = mFlagSpace.getFlagPtrChecked();
|
||||
mFlagStuff->setCounterOrFlag(flag, data, 8, 1);
|
||||
setCommitFlag(flag);
|
||||
}
|
||||
|
||||
/** 800fbac0 */
|
||||
u32 DungeonflagManager::getDungeonFlag(u16 flag) {
|
||||
u16 *data = mFlagSpace.getFlagPtrUnchecked();
|
||||
return mFlagStuff->getCounterOrFlag(flag, data, 8);
|
||||
}
|
||||
|
||||
/** 800fbb10 */
|
||||
bool DungeonflagManager::doCommit() {
|
||||
FileManager *instance;
|
||||
u16 idx = mStageIndex;
|
||||
if (idx == 0xFFFF) {
|
||||
return false;
|
||||
} else if (mShouldCommit) {
|
||||
instance = FileManager::sInstance;
|
||||
u16 *ptr = mFlagSpace.getFlagPtrUnchecked();
|
||||
instance->setDungeonFlags(ptr, (idx & 0x1fff) * 8, 0x08);
|
||||
mShouldCommit = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
+360
-116
@@ -1,83 +1,175 @@
|
||||
#include "toBeSorted/file_manager.h"
|
||||
#include "f/f_base.h"
|
||||
#include <m/m_heap.h>
|
||||
// #include "libc.h"
|
||||
#include <MSL_C/string.h>
|
||||
|
||||
// This class here makes no sense and the name might
|
||||
// be a total misnomer, but this gets the sinit section correct
|
||||
class UnkClass {
|
||||
public:
|
||||
UnkClass();
|
||||
/* vtable at 80500400 */
|
||||
virtual ~UnkClass();
|
||||
|
||||
static UnkClass sInstance;
|
||||
};
|
||||
// This seems really pointless since the class only has a virtual destructor
|
||||
// and no members but /shrug
|
||||
/* 80574FF8 */ UnkClass UnkClass::sInstance;
|
||||
|
||||
/* 80009D30 */ UnkClass::UnkClass() {}
|
||||
/* 80009D40 */ UnkClass::~UnkClass() {}
|
||||
|
||||
/* 80574FFC */ FileManager *FileManager::sInstance;
|
||||
|
||||
extern "C" {
|
||||
/* 80009D30 */ void fn_80009D30() {} // some ctor
|
||||
/* 80009D40 */ void fn_80009D40() {} // some dtor
|
||||
/* 80009D80 */ void fn_80009D80() {} // return
|
||||
/* 80009D90 */ void fn_80009D90() {} // return
|
||||
/* 80009DA0 */ void fn_80009DA0() {} // memset(param_1, 0, 0x20) a 0x24 structure is implied here (0x20 data) a crc is at 0x24
|
||||
/* 80009D80 */ void fn_80009D80() {} // return
|
||||
/* 80009D90 */ void fn_80009D90() {} // return
|
||||
/* 80009DA0 */ void fn_80009DA0(void *ptr) {
|
||||
memset(ptr, 0, 0x20);
|
||||
} // memset(param_1, 0, 0x20) a 0x24 structure is implied here (0x20 data) a crc is at 0x24
|
||||
}
|
||||
|
||||
/* 80009DB0 */ FileManager::FileManager() {}
|
||||
/* 80009DB0 */ FileManager::FileManager() {
|
||||
// TODO the assembly code looks really wild
|
||||
mHeroNames[0][0] = '\0';
|
||||
u32 num_files = (u32)(mHeroName - mHeroNames[0]);
|
||||
num_files = num_files / sizeof(mHeroName);
|
||||
for (int i = 1; mHeroNames[i] < mHeroName && i < num_files; i++) {
|
||||
mHeroNames[i][0] = '\0';
|
||||
}
|
||||
mHeroName[0] = '\0';
|
||||
mCurrentArea[0] = '\0';
|
||||
sInstance = this;
|
||||
// TODO these should probably use the new operators?
|
||||
mpSavedSaveFiles = (SavedSaveFiles *)mHeap::g_gameHeaps[0]->alloc(sizeof(SavedSaveFiles), 0x20);
|
||||
mpSkipData = (SkipData *)mHeap::g_gameHeaps[0]->alloc(0x80, 0x20);
|
||||
|
||||
fn_8000A2E0();
|
||||
}
|
||||
/* 80009EE0 */ // mVec3();
|
||||
|
||||
/* 80009EF0 */ FileManager FileManager::create(EGG::Heap*){}
|
||||
/* 80009F30 */ bool FileManager::loadSaveData(void* out, char* name, bool isSkipData){}
|
||||
/* 80009F70 */ void FileManager::saveSaveData(void* unk, bool isSkipData){}
|
||||
/* 8000A000 */ void FileManager::refreshSaveFileData(){}
|
||||
/* 8000A260 */ wchar_t* FileManager::getFileHeroname(int fileNum){}
|
||||
/* 8000A280 */ s64 FileManager::getFileSaveTime(int fileNum){}
|
||||
/* 8000A2A0 */ s16 FileManager::getFileCurrentHealth(int fileNum){}
|
||||
/* 8000A2C0 */ s16 FileManager::getFileHealthCapacity(int fileNum){}
|
||||
/* 8000A2E0 */ void FileManager::fn_8000A2E0(){}
|
||||
/* 80009EF0 */ FileManager *FileManager::create(EGG::Heap *heap) {
|
||||
return new (heap, 0x04) FileManager();
|
||||
}
|
||||
/* 80009F30 */ bool FileManager::loadSaveData(void *out, char *name, bool isSkipData) {}
|
||||
/* 80009F70 */ void FileManager::saveSaveData(void *unk, bool isSkipData) {}
|
||||
/* 8000A000 */ void FileManager::refreshSaveFileData() {}
|
||||
/* 8000A260 */ wchar_t *FileManager::getFileHeroname(int fileNum) {}
|
||||
/* 8000A280 */ s64 FileManager::getFileSaveTime(int fileNum) {}
|
||||
/* 8000A2A0 */ s16 FileManager::getFileCurrentHealth(int fileNum) {}
|
||||
/* 8000A2C0 */ s16 FileManager::getFileHealthCapacity(int fileNum) {}
|
||||
/* 8000A2E0 */ void FileManager::fn_8000A2E0() {
|
||||
// maybe call this function "reset"
|
||||
mIsFileUnk1[0] = true;
|
||||
initBlankSaveFiles();
|
||||
m_0xA84D = 0;
|
||||
mSelectedFile = 1;
|
||||
}
|
||||
|
||||
/* 8000A330 */
|
||||
u16* FileManager::getStoryFlagsMut() {
|
||||
/* 8000A330 */
|
||||
u16 *FileManager::getStoryFlagsMut() {
|
||||
return getCurrentFile()->getStoryFlags0();
|
||||
}
|
||||
/* 8000A360 */ u16* FileManager::getStoryFlagsConst() {
|
||||
return (isFileInactive() ? mFileB : mFileA).getStoryFlags1();
|
||||
/* 8000A360 */ const u16 *FileManager::getStoryFlagsConst() const {
|
||||
return getCurrentFile()->getStoryFlags1();
|
||||
}
|
||||
/* 8000A3B0 */ u16* FileManager::getItemFlagsMut() {}
|
||||
/* 8000A3E0 */ u16* FileManager::getItemFlagsConst() {}
|
||||
/* 8000A430 */ u16* FileManager::getDungeonFlagsMut() {}
|
||||
/* 8000A460 */ u16* FileManager::getDungeonFlagsConst() {}
|
||||
/* 8000A4B0 */ u16* FileManager::getSceneFlagsMut() {}
|
||||
/* 8000A4E0 */ u16* FileManager::getSceneFlagsConst() {}
|
||||
/* 8000A530 */ u16* FileManager::getTBoxFlagsMut() {}
|
||||
/* 8000A560 */ u16* FileManager::getTBoxFlagsConst() {}
|
||||
/* 8000A5B0 */ u16* FileManager::getTempFlagsMut() {}
|
||||
/* 8000A5E0 */ u16* FileManager::getTempFlagsConst() {}
|
||||
/* 8000A630 */ u16* FileManager::getZoneFlagsMut() {}
|
||||
/* 8000A660 */ u16* FileManager::getZoneFlagsConst() {}
|
||||
/* 8000A6B0 */ u16* FileManager::getEnemyDefeatFlagsMut() {}
|
||||
/* 8000A6E0 */ u16* FileManager::getEnemyDefeatFlagsConst() {}
|
||||
/* 8000A730 */ void FileManager::setStoryFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A790 */ void FileManager::setItemFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A7F0 */ void FileManager::setDungeonFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A850 */ void FileManager::setSceneFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A8B0 */ void FileManager::setTBoxFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A910 */ void FileManager::setTempFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A970 */ void FileManager::setZoneFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A9D0 */ void FileManager::setEnemyDefeatFlags(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000A3B0 */ u16 *FileManager::getItemFlagsMut() {}
|
||||
/* 8000A3E0 */ u16 *FileManager::getItemFlagsConst() {}
|
||||
/* 8000A430 */ u16 *FileManager::getDungeonFlagsMut() {}
|
||||
/* 8000A460 */ u16 *FileManager::getDungeonFlagsConst() {}
|
||||
/* 8000A4B0 */ u16 *FileManager::getSceneFlagsMut() {}
|
||||
/* 8000A4E0 */ u16 *FileManager::getSceneFlagsConst() {}
|
||||
/* 8000A530 */ u16 *FileManager::getTBoxFlagsMut() {}
|
||||
/* 8000A560 */ u16 *FileManager::getTBoxFlagsConst() {}
|
||||
/* 8000A5B0 */ u16 *FileManager::getTempFlagsMut() {}
|
||||
/* 8000A5E0 */ u16 *FileManager::getTempFlagsConst() {}
|
||||
/* 8000A630 */ u16 *FileManager::getZoneFlagsMut() {}
|
||||
/* 8000A660 */ u16 *FileManager::getZoneFlagsConst() {}
|
||||
/* 8000A6B0 */ u16 *FileManager::getEnemyDefeatFlagsMut() {}
|
||||
/* 8000A6E0 */ u16 *FileManager::getEnemyDefeatFlagsConst() {}
|
||||
/* 8000A730 */ void FileManager::setStoryFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A790 */ void FileManager::setItemFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A7F0 */ void FileManager::setDungeonFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A850 */ void FileManager::setSceneFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A8B0 */ void FileManager::setTBoxFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A910 */ void FileManager::setTempFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A970 */ void FileManager::setZoneFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
/* 8000A9D0 */ void FileManager::setEnemyDefeatFlags(u16 *flags, u32 offset, u16 count) {}
|
||||
|
||||
/* 8000AA30 */ u16* FileManager::getSkipFlags() {}
|
||||
/* 8000AA40 */ void FileManager::setSkipFlagsChecked(u16* flags, u32 offset, u16 count) {}
|
||||
/* 8000AA30 */ u16 *FileManager::getSkipFlags() {}
|
||||
/* 8000AA40 */ void FileManager::setSkipFlagsChecked(u16 *flags, u32 offset, u16 count) {}
|
||||
|
||||
/* 8000AAA0 */ void FileManager::initFile(int fileNum) {}
|
||||
// This does strncat things - append src to dest
|
||||
inline void fake_strncat(char *dest, const char *src, size_t max_len) {
|
||||
if (src != nullptr) {
|
||||
size_t len = strlen(dest);
|
||||
size_t count = strlen(src);
|
||||
count = len + count + 1 >= max_len ? max_len - len - 1 : count;
|
||||
strncpy(dest + len, src, count);
|
||||
// one instshuffle here - this should be (len + count),
|
||||
// but then regalloc blows up and uses one more register in initFile
|
||||
dest[count + len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// A function like this is inlined into in a bunch of area-related code
|
||||
// It doesn't make a whole lot of sense to use strncat on a string just
|
||||
// clipped to zero length...
|
||||
inline void strnsth(char *dest, const char *src, size_t max_len) {
|
||||
if (src != dest) {
|
||||
dest[0] = '\0';
|
||||
fake_strncat(dest, src, max_len);
|
||||
}
|
||||
}
|
||||
|
||||
/* 8000AAA0 */ void FileManager::initFile(int fileNum) {
|
||||
|
||||
mIsFileInvalid[1] = 1;
|
||||
SaveFile *file = getFileA();
|
||||
if (fileNum != 0) {
|
||||
file = &mFileB;
|
||||
}
|
||||
file->new_file = 0;
|
||||
file->health_capacity = 0x18;
|
||||
file->unused_heart_related = 0x18;
|
||||
file->current_health = 0x18;
|
||||
file->shield_pouch_slot = 8;
|
||||
file->equipped_b_item = 0xb;
|
||||
file->selectedDowsingSlot = 0x8;
|
||||
file->lastUsedPouchItemSlot = 0x8;
|
||||
|
||||
char buf[0x20];
|
||||
buf[0] = '\0';
|
||||
strnsth(buf, "F405", 0x20);
|
||||
file->setAreaT1(buf);
|
||||
file->room_id_t1 = 0;
|
||||
file->forced_layer_t1 = 0;
|
||||
file->entrance_t1_load_flag = 1;
|
||||
}
|
||||
|
||||
/* 8000ABD0 */ void FileManager::setCurrentHealthCapacity(s16 health) {}
|
||||
/* 8000AC00 */ s16 FileManager::getCurrentHealthCapacity() {}
|
||||
/* 8000AC50 */ void FileManager::setCurrentHealth(s16 health) {}
|
||||
/* 8000AC80 */ s16 FileManager::getCurrentHealth() {}
|
||||
|
||||
/* 8000ACD0 */ u16 FileManager::getLoadRoomT1() {}
|
||||
/* 8000AD20 */ u16 FileManager::getLoadRoomT2() {}
|
||||
/* 8000ACD0 */ u16 FileManager::getLoadRoomT1() {}
|
||||
/* 8000AD20 */ u16 FileManager::getLoadRoomT2() {}
|
||||
/* 8000AD70 */ void FileManager::setLoadRoomT3(s16 room) {}
|
||||
/* 8000ADA0 */ u16 FileManager::getLoadRoomT3() {}
|
||||
/* 8000ADA0 */ u16 FileManager::getLoadRoomT3() {}
|
||||
|
||||
/* 8000ADF0 */ mVec3_c* FileManager::getPosT1() {}
|
||||
/* 8000AE40 */ void FileManager::setPosT2(mVec3_c* pos) {}
|
||||
/* 8000AE90 */ mVec3_c* FileManager::getPosT2() {}
|
||||
/* 8000AEE0 */ void FileManager::setPosT3(mVec3_c* pos) {}
|
||||
/* 8000AF30 */ mVec3_c* FileManager::getPosT3() {}
|
||||
/* 8000ADF0 */ mVec3_c *FileManager::getPosT1() {}
|
||||
/* 8000AE40 */ void FileManager::setPosT2(mVec3_c *pos) {}
|
||||
/* 8000AE90 */ mVec3_c *FileManager::getPosT2() {}
|
||||
/* 8000AEE0 */ void FileManager::setPosT3(mVec3_c *pos) {}
|
||||
/* 8000AF30 */ mVec3_c *FileManager::getPosT3() {}
|
||||
|
||||
/* 8000AF80 */ s16 FileManager::getAngleT1() {}
|
||||
/* 8000AF80 */ s16 FileManager::getAngleT1() {}
|
||||
/* 8000AFD0 */ void FileManager::setAngleT2(s16 angle) {}
|
||||
/* 8000B000 */ s16 FileManager::getAngleT2() {}
|
||||
/* 8000B000 */ s16 FileManager::getAngleT2() {}
|
||||
/* 8000B050 */ void FileManager::setAngleT3(s16 angle) {}
|
||||
/* 8000B080 */ s16 FileManager::getAngleT3() {}
|
||||
/* 8000B080 */ s16 FileManager::getAngleT3() {}
|
||||
|
||||
/* 8000B0D0 */ void FileManager::setPouchData(s32 slot, u32 slotData) {}
|
||||
/* 8000B130 */ u32 FileManager::getPouchData(s32 slot) {}
|
||||
@@ -86,38 +178,38 @@ u16* FileManager::getStoryFlagsMut() {
|
||||
/* 8000B250 */ void FileManager::setPouchUpperData(s32 slot, s32 data) {}
|
||||
/* 8000B2C0 */ u16 FileManager::getPouchUpperData(s32 slot) {}
|
||||
|
||||
/* 8000B2F0 */ void FileManager::setItemCheckData(u32 idx, u32 itemData){}
|
||||
/* 8000B360 */ u32 FileManager::getItemCheckData(u32 idx){}
|
||||
/* 8000B3F0 */ void FileManager::setItemCheckItem(u32 idx, ITEM_ID item){}
|
||||
/* 8000B480 */ ITEM_ID FileManager::getItemCheckItem(u32 idx){}
|
||||
/* 8000B4B0 */ void FileManager::setItemCheckUpperData(u32 idx, u32 itemData){}
|
||||
/* 8000B540 */ u32 FileManager::getItemCheckUpperData(){}
|
||||
/* 8000B2F0 */ void FileManager::setItemCheckData(u32 idx, u32 itemData) {}
|
||||
/* 8000B360 */ u32 FileManager::getItemCheckData(u32 idx) {}
|
||||
/* 8000B3F0 */ void FileManager::setItemCheckItem(u32 idx, ITEM_ID item) {}
|
||||
/* 8000B480 */ ITEM_ID FileManager::getItemCheckItem(u32 idx) {}
|
||||
/* 8000B4B0 */ void FileManager::setItemCheckUpperData(u32 idx, u32 itemData) {}
|
||||
/* 8000B540 */ u32 FileManager::getItemCheckUpperData() {}
|
||||
|
||||
/* 8000B570 */ void FileManager::setEquippedItem(u8 bWheelItem){}
|
||||
/* 8000B5A0 */ u8 FileManager::getEquippedItem(){}
|
||||
/* 8000B5F0 */ void FileManager::setSelectedPouchSlot(u8 slot){}
|
||||
/* 8000B620 */ u8 FileManager::getSelectedPouchSlot(){}
|
||||
/* 8000B670 */ void FileManager::setShieldPouchSlot(u8 slot){}
|
||||
/* 8000B6A0 */ u8 FileManager::getShieldPouchSlot(){}
|
||||
/* 8000B570 */ void FileManager::setEquippedItem(u8 bWheelItem) {}
|
||||
/* 8000B5A0 */ u8 FileManager::getEquippedItem() {}
|
||||
/* 8000B5F0 */ void FileManager::setSelectedPouchSlot(u8 slot) {}
|
||||
/* 8000B620 */ u8 FileManager::getSelectedPouchSlot() {}
|
||||
/* 8000B670 */ void FileManager::setShieldPouchSlot(u8 slot) {}
|
||||
/* 8000B6A0 */ u8 FileManager::getShieldPouchSlot() {}
|
||||
|
||||
/* 8000B6F0 */ void FileManager::setAirPotionTimer(s16 time){}
|
||||
/* 8000B720 */ s16 FileManager::getAirPotionTimer(){}
|
||||
/* 8000B770 */ void FileManager::setAirPotionPlusTimer(s16 time){}
|
||||
/* 8000B7A0 */ s16 FileManager::getAirPotionPlusTimer(){}
|
||||
/* 8000B7F0 */ void FileManager::setStaminaPotionTimer(s16 time){}
|
||||
/* 8000B820 */ s16 FileManager::getStaminaPotionTimer(){}
|
||||
/* 8000B870 */ void FileManager::setStaminaPotionPlusTimer(s16 time){}
|
||||
/* 8000B8A0 */ s16 FileManager::getStaminaPotionPlusTimer(){}
|
||||
/* 8000B8F0 */ void FileManager::setGuardianPotionTimer(s16 time){}
|
||||
/* 8000B920 */ s16 FileManager::getGuardianPotionTimer(){}
|
||||
/* 8000B970 */ void FileManager::setGuardianPotionPlusTimer(s16 time){}
|
||||
/* 8000B9A0 */ s16 FileManager::getGuardianPotionPlusTimer(){}
|
||||
/* 8000B6F0 */ void FileManager::setAirPotionTimer(s16 time) {}
|
||||
/* 8000B720 */ s16 FileManager::getAirPotionTimer() {}
|
||||
/* 8000B770 */ void FileManager::setAirPotionPlusTimer(s16 time) {}
|
||||
/* 8000B7A0 */ s16 FileManager::getAirPotionPlusTimer() {}
|
||||
/* 8000B7F0 */ void FileManager::setStaminaPotionTimer(s16 time) {}
|
||||
/* 8000B820 */ s16 FileManager::getStaminaPotionTimer() {}
|
||||
/* 8000B870 */ void FileManager::setStaminaPotionPlusTimer(s16 time) {}
|
||||
/* 8000B8A0 */ s16 FileManager::getStaminaPotionPlusTimer() {}
|
||||
/* 8000B8F0 */ void FileManager::setGuardianPotionTimer(s16 time) {}
|
||||
/* 8000B920 */ s16 FileManager::getGuardianPotionTimer() {}
|
||||
/* 8000B970 */ void FileManager::setGuardianPotionPlusTimer(s16 time) {}
|
||||
/* 8000B9A0 */ s16 FileManager::getGuardianPotionPlusTimer() {}
|
||||
|
||||
/* 8000B9F0 */ void FileManager::setDowsingSlotIdx(u8 idx) {}
|
||||
/* 8000BA20 */ u8 FileManager::getDowsingSlotIdx() {}
|
||||
|
||||
/* 8000BA70 */ void FileManager::setBeaconPos(u32 beaconArea, u32 beaconNum, mVec3_c* pos) {}
|
||||
/* 8000BB80 */ mVec3_c* FileManager::getBeaconPos(u32 beaconArea, u32 beaconNum) {}
|
||||
/* 8000BA70 */ void FileManager::setBeaconPos(u32 beaconArea, u32 beaconNum, mVec3_c *pos) {}
|
||||
/* 8000BB80 */ mVec3_c *FileManager::getBeaconPos(u32 beaconArea, u32 beaconNum) {}
|
||||
/* 8000BC70 */ void FileManager::setEnemyKillCount(u32 enemy, u16 killCount) {}
|
||||
/* 8000BCE0 */ u16 FileManager::getEnemyKillCount(u32 enemy) {}
|
||||
/* 8000BD60 */ void FileManager::setHitCountFromEnemy(u32 enemy, u16 hitCount) {}
|
||||
@@ -126,9 +218,9 @@ u16* FileManager::getStoryFlagsMut() {
|
||||
/* 8000BE50 */ void FileManager::setLoadRoomT1_FileB(s16 roomId) {}
|
||||
/* 8000BE80 */ s16 FileManager::getLoadRoomT1_FileB() {}
|
||||
/* 8000BE90 */ void FileManager::setEntranceT1_FileB(u8 entrance) {}
|
||||
/* 8000BEC0 */ u8 FileManager::getEntranceT1_FileB() {}
|
||||
/* 8000BED0 */ void FileManager::setAreaT1_FileB(const char* name) {}
|
||||
/* 8000BF80 */ char* FileManager::getAreaT1_FileB() {}
|
||||
/* 8000BEC0 */ u8 FileManager::getEntranceT1_FileB() {}
|
||||
/* 8000BED0 */ void FileManager::setAreaT1_FileB(const char *name) {}
|
||||
/* 8000BF80 */ char *FileManager::getAreaT1_FileB() {}
|
||||
/* 8000C080 */ void FileManager::setNightT1_FileB(bool night) {}
|
||||
/* 8000C0B0 */ bool FileManager::getNightT1_FileB() {}
|
||||
/* 8000C0C0 */ void FileManager::setEntranceT1LoadFlag_FileB(u8 flag) {}
|
||||
@@ -136,13 +228,13 @@ u16* FileManager::getStoryFlagsMut() {
|
||||
/* 8000C120 */ void FileManager::getForcedLayerT1_FileB() {}
|
||||
/* 8000C130 */ void FileManager::setCurrentHealth_FileB(s16 health) {}
|
||||
|
||||
/* 8000C160 */ void FileManager::setHeroname(const wchar_t* name) {}
|
||||
/* 8000C230 */ wchar_t* FileManager::getHeroname() {}
|
||||
/* 8000C160 */ void FileManager::setHeroname(const wchar_t *name) {}
|
||||
/* 8000C230 */ wchar_t *FileManager::getHeroname() {}
|
||||
|
||||
/* 8000C360 */ char* FileManager::getAreaT1() {}
|
||||
/* 8000C470 */ char* FileManager::getAreaT2() {}
|
||||
/* 8000C580 */ void FileManager::setAreaT3(const char* name) {}
|
||||
/* 8000C630 */ char* FileManager::getAreaT3() {}
|
||||
/* 8000C360 */ char *FileManager::getAreaT1() {}
|
||||
/* 8000C470 */ char *FileManager::getAreaT2() {}
|
||||
/* 8000C580 */ void FileManager::setAreaT3(const char *name) {}
|
||||
/* 8000C630 */ char *FileManager::getAreaT3() {}
|
||||
|
||||
/* 8000C740 */ u8 FileManager::getForcedLayerT1() {}
|
||||
/* 8000C790 */ u8 FileManager::getForcedLayerT2() {}
|
||||
@@ -188,54 +280,206 @@ u16* FileManager::getStoryFlagsMut() {
|
||||
/* 8000CFE0 */ void FileManager::setSkykeepPuzzle(u32 spot, u8 tile) {}
|
||||
/* 8000D040 */ u8 FileManager::getSkykeepPuzzleTile(u32 spot) {}
|
||||
|
||||
/* 8000D0B0 */ void FileManager::checkFileStatus() {}
|
||||
/* 8000D1D0 */ void FileManager::checkSkipDataCRCs() {}
|
||||
/* 8000D270 */ void FileManager::saveOrClearSelectedFileToFileA() {}
|
||||
/* 8000D0B0 */ void FileManager::checkFileStatus() {
|
||||
mIsFileInvalid[2] = 0;
|
||||
SkipData *data;
|
||||
SavedSaveFiles *files = mpSavedSaveFiles;
|
||||
|
||||
if (!checkRegionCode()) {
|
||||
mIsFileInvalid[2] = 1;
|
||||
}
|
||||
if (files->m_0x1C != 0x1d) {
|
||||
mIsFileInvalid[2] = 1;
|
||||
}
|
||||
|
||||
for (u8 i = 0; i < 3; i++) {
|
||||
if (checkFileCRC(i) == 0) {
|
||||
mIsFileDataDirty[i] = 1;
|
||||
} else {
|
||||
mIsFileDataDirty[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0, data = files->skipData; i < 3; i++, data++) {
|
||||
u32 crc = calcFileCRC(data->data, sizeof(data->data));
|
||||
if (crc != data->crc) {
|
||||
fn_80009DA0(data);
|
||||
data->crc = calcFileCRC(data->data, sizeof(data->data));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 8000D1D0 */ bool FileManager::checkSkipDataCRCs() {
|
||||
SkipData *data;
|
||||
bool dirty = false;
|
||||
u8 i;
|
||||
for (data = mpSkipData, i = 0; (s32)i < 3; i++, data++) {
|
||||
u32 crc = calcFileCRC(data->data, sizeof(data->data));
|
||||
if (crc == data->crc) {
|
||||
mIsFileSkipDataDirty[i] = 0;
|
||||
} else {
|
||||
mIsFileSkipDataDirty[i] = 1;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
/* 8000D270 */ void FileManager::saveOrClearSelectedFileToFileA() {
|
||||
saveOrClearToFileA(mSelectedFile);
|
||||
}
|
||||
/* 8000D280 */ void FileManager::saveOrClearToFileA(int fileNum) {}
|
||||
/* 8000D9C0 */ void FileManager::copyFileBToCurrentFile() {}
|
||||
/* 8000E060 */ void FileManager::copyFileAToSelectedFile() {}
|
||||
/* 8000E060 */ void FileManager::copyFileAToSelectedFile() {
|
||||
copyFileAToFile(mSelectedFile);
|
||||
}
|
||||
/* 8000E070 */ void FileManager::copyFileAToFile(int fileNum) {}
|
||||
/* 8000E7C0 */ void FileManager::copyFile(int from, int to) {}
|
||||
/* 8000EF80 */ void FileManager::saveFileAToSelectedFile() {}
|
||||
/* 8000EF80 */ void FileManager::saveFileAToSelectedFile() {
|
||||
saveFileAToFile(mSelectedFile);
|
||||
}
|
||||
/* 8000EF90 */ void FileManager::saveFileAToFile(int fileNum) {}
|
||||
/* 8000F730 */ void FileManager::copyCurrentToFileB() {}
|
||||
/* 8000FDF0 */ void FileManager::copySelectedFileSkipData() {}
|
||||
/* 8000FE00 */ void FileManager::copySkipData(int fileNum) {}
|
||||
/* 8000FDF0 */ void FileManager::copySelectedFileSkipData() {
|
||||
copySkipData(mSelectedFile);
|
||||
}
|
||||
/* 8000FE00 */ void FileManager::copySkipData(u8 fileNum) {
|
||||
if (fileNum < 3) {
|
||||
SkipData *curr = &mSkipData;
|
||||
SkipData *data = mpSkipData;
|
||||
curr->crc = calcFileCRC(&curr->data, sizeof(mSkipData.data));
|
||||
data[fileNum] = *curr;
|
||||
}
|
||||
}
|
||||
/* 8000FEB0 */ void FileManager::setInfo_FileB() {}
|
||||
/* 8000FF60 */ void FileManager::clearFileA() {}
|
||||
/* 8000FF60 */ void FileManager::clearFileA() {
|
||||
SkipData *data;
|
||||
SaveFile *file = getFileA();
|
||||
memset(file, 0, sizeof(SaveFile));
|
||||
file->new_file = 1;
|
||||
file->checksum = calcFileCRC(file, sizeof(SaveFile) - sizeof(u32));
|
||||
data = &mSkipData;
|
||||
memset(&data->data, 0, sizeof(SkipData));
|
||||
data->crc = calcFileCRC(data->data, sizeof(mSkipData.data));
|
||||
}
|
||||
|
||||
/* 80010000 */ void FileManager::initBlankSaveFiles() {}
|
||||
/* 80010160 */ void FileManager::initSkipData() {}
|
||||
/* 80010000 */ void FileManager::initBlankSaveFiles() {
|
||||
memset(mpSavedSaveFiles, 0, 0xfbe0);
|
||||
mSelectedFile = 0;
|
||||
memset(mIsFileEmpty, 0, 3);
|
||||
SkipData *data;
|
||||
|
||||
SaveFile *file;
|
||||
SavedSaveFiles *saved = mpSavedSaveFiles;
|
||||
|
||||
mHeroNames[0][0] = '\0';
|
||||
mPlayTime[0] = 0;
|
||||
mCurrentHealth[0] = 0;
|
||||
mCurrentHealthCapacity[0] = 0;
|
||||
|
||||
mHeroNames[1][0] = '\0';
|
||||
mPlayTime[1] = 0;
|
||||
mCurrentHealth[1] = 0;
|
||||
mCurrentHealthCapacity[1] = 0;
|
||||
|
||||
mHeroNames[2][0] = '\0';
|
||||
mPlayTime[2] = 0;
|
||||
mCurrentHealth[2] = 0;
|
||||
mCurrentHealthCapacity[2] = 0;
|
||||
|
||||
getRegionVersion(saved->regionCode);
|
||||
saved->m_0x1C = 0x1d;
|
||||
|
||||
file = saved->saveFiles;
|
||||
for (int num = 0; num < 3; num++, file++) {
|
||||
file->new_file = 1;
|
||||
u32 crc = calcFileCRC(file, sizeof(SaveFile) - sizeof(u32));
|
||||
file->checksum = crc;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0, data = saved->skipData; i < 3; i++, data++) {
|
||||
u32 crc = calcFileCRC(data->data, sizeof(data->data));
|
||||
data->crc = crc;
|
||||
}
|
||||
|
||||
clearFileA();
|
||||
mIsFileUnk1[1] = 0;
|
||||
mIsFileUnk1[2] = 0;
|
||||
mIsFileInvalid[0] = 0;
|
||||
mIsFileInvalid[1] = 0;
|
||||
m_0xA84C = 0;
|
||||
mIsFileInvalid[2] = 0;
|
||||
mIsFileDataDirty[0] = 0;
|
||||
mIsFileDataDirty[1] = 0;
|
||||
mIsFileDataDirty[2] = 0;
|
||||
initSkipData();
|
||||
}
|
||||
/* 80010160 */ void FileManager::initSkipData() {
|
||||
memset(mpSkipData, 0, 0x80);
|
||||
SkipData *data;
|
||||
int i;
|
||||
for (i = 0, data = mpSkipData; i < 3; i++, data++) {
|
||||
u32 crc = calcFileCRC(data->data, sizeof(data->data));
|
||||
data->crc = crc;
|
||||
}
|
||||
mIsFileSkipDataDirty[0] = 0;
|
||||
mIsFileSkipDataDirty[1] = 0;
|
||||
mIsFileSkipDataDirty[2] = 0;
|
||||
}
|
||||
|
||||
/* 800101F0 */ void FileManager::unsetFileANewFile() {}
|
||||
/* 80010220 */ void FileManager::saveT1SaveInfo(u8 entranceT1LoadFlag) {}
|
||||
/* 80010350 */ void FileManager::copyFileSkipData(int fileNum) {}
|
||||
/* 80010440 */ void FileManager::clearTempFileData() {}
|
||||
extern "C" void fn_800C01F0(); // todo flag managers
|
||||
/* 80010440 */ void FileManager::clearTempFileData() {
|
||||
memset(&mFileA, 0, sizeof(SaveFile));
|
||||
memset(&mFileB, 0, sizeof(SaveFile));
|
||||
memset(&mSkipData, 0, sizeof(SkipData));
|
||||
fn_800C01F0();
|
||||
}
|
||||
/* 800104A0 */ void FileManager::saveAfterCredits() {}
|
||||
|
||||
/* 80011210 */ SaveFile* FileManager::getCurrentFile() {}
|
||||
/* 80011250 */ u16* FileManager::getSkipFlags2() {}
|
||||
/* 80011260 */ SaveFile* FileManager::getFileA() {}
|
||||
/* 80011270 */ SaveFile* FileManager::getFileB() {}
|
||||
/* 80011280 */ void FileManager::calcFileCRC(const SaveFile* file, u32 length) {}
|
||||
/* 80011290 */ void FileManager::updateEmptyFiles() {}
|
||||
/* 800112D0 */ void FileManager::updateEmptyFileFlags() {}
|
||||
/* 80011210 */ SaveFile *FileManager::getCurrentFile() {
|
||||
return isFileInactive() ? &mFileB : &mFileA;
|
||||
}
|
||||
/* 80011250 */ u16 *FileManager::getSkipFlags2() {}
|
||||
/* 80011260 */ SaveFile *FileManager::getFileA() {
|
||||
return &mFileA;
|
||||
}
|
||||
/* 80011270 */ SaveFile *FileManager::getFileB() {
|
||||
return &mFileB;
|
||||
}
|
||||
/* 80011280 */ u32 FileManager::calcFileCRC(const void *data, u32 length) {}
|
||||
/* 80011290 */ void FileManager::updateEmptyFiles() {
|
||||
updateEmptyFileFlags();
|
||||
refreshSaveFileData();
|
||||
}
|
||||
/* 800112D0 */ void FileManager::updateEmptyFileFlags() {
|
||||
SaveFile *saves = mpSavedSaveFiles->saveFiles;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (saves[i].new_file == 1) {
|
||||
mIsFileEmpty[i] = 1;
|
||||
} else {
|
||||
mIsFileEmpty[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 80011370 */ bool FileManager::isFileEmpty(int fileNum) {}
|
||||
/* 80011390 */ bool FileManager::isFileUnk3(int fileNum) {}
|
||||
/* 80011390 */ bool FileManager::isFileDirty(int fileNum) {}
|
||||
/* 800113B0 */ u8 FileManager::get_0xA84C() {}
|
||||
/* 800113C0 */ bool FileManager::checkRegionCode() {}
|
||||
/* 80011440 */ bool FileManager::checkFileCRC(int fileNum) {}
|
||||
/* 80011440 */ bool FileManager::checkFileCRC(u8 fileNum) {}
|
||||
/* 80011490 */
|
||||
bool FileManager::isFileInactive() {
|
||||
fBase_c* actor = fManager_c::searchBaseByGroupType(1, nullptr);
|
||||
bool FileManager::isFileInactive() const {
|
||||
fBase_c *actor = fManager_c::searchBaseByGroupType(1, nullptr);
|
||||
if (actor) {
|
||||
if (actor->profile_name == fProfile::TITLE && !mAntiCommitFlag)
|
||||
if (actor->profile_name == fProfile::TITLE && !mAntiCommitFlag) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/* 80011500 */ void FileManager::setPlayerInfoFileA() {}
|
||||
/* 800115E0 */ void FileManager::setT3Info(mVec3_c* pos, mAng3_c* rot) {}
|
||||
/* 800116C0 */ void FileManager::getRegionVersion(char* out) {}
|
||||
|
||||
/* 800115E0 */ void FileManager::setT3Info(mVec3_c *pos, mAng3_c *rot) {}
|
||||
/* 800116C0 */ void FileManager::getRegionVersion(char *out) {}
|
||||
|
||||
@@ -5,68 +5,68 @@
|
||||
u16* SaveFile::getStoryFlags0() {
|
||||
return story_flags;
|
||||
}
|
||||
// 0x800099c0 getStoryFlags1__8SaveFileFv
|
||||
u16* SaveFile::getStoryFlags1() {
|
||||
// 0x800099c0 getStoryFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getStoryFlags1() const {
|
||||
return story_flags;
|
||||
}
|
||||
// 0x800099d0 getItemFlags0__8SaveFileFv
|
||||
u16* SaveFile::getItemFlags0() {
|
||||
return item_flags;
|
||||
}
|
||||
// 0x800099e0 getItemFlags1__8SaveFileFv
|
||||
u16* SaveFile::getItemFlags1() {
|
||||
// 0x800099e0 getItemFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getItemFlags1() const {
|
||||
return item_flags;
|
||||
}
|
||||
// 0x800099F0 getDungeonFlags0__8SaveFileFv
|
||||
u16* SaveFile::getDungeonFlags0() {
|
||||
return dungeon_flags[0];
|
||||
}
|
||||
// 0x80009A00 getDungeonFlags1__8SaveFileFv
|
||||
u16* SaveFile::getDungeonFlags1() {
|
||||
// 0x80009A00 getDungeonFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getDungeonFlags1() const {
|
||||
return dungeon_flags[0];
|
||||
}
|
||||
// 0x80009A10 getSceneFlags0__8SaveFileFv
|
||||
u16* SaveFile::getSceneFlags0() {
|
||||
return scene_flags;
|
||||
}
|
||||
// 0x80009A20 getSceneFlags1__8SaveFileFv
|
||||
u16* SaveFile::getSceneFlags1() {
|
||||
// 0x80009A20 getSceneFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getSceneFlags1() const {
|
||||
return scene_flags;
|
||||
}
|
||||
// 0x80009A30 getTboxFlags0__8SaveFileFv
|
||||
u16* SaveFile::getTboxFlags0() {
|
||||
return tbox_flags;
|
||||
}
|
||||
// 0x80009A40 getTboxFlags1__8SaveFileFv
|
||||
u16* SaveFile::getTboxFlags1() {
|
||||
// 0x80009A40 getTboxFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getTboxFlags1() const {
|
||||
return tbox_flags;
|
||||
}
|
||||
// 0x80009A50 getTempFlags0__8SaveFileFv
|
||||
u16* SaveFile::getTempFlags0() {
|
||||
return temp_flags;
|
||||
}
|
||||
// 0x80009A60 getTempFlags1__8SaveFileFv
|
||||
u16* SaveFile::getTempFlags1() {
|
||||
// 0x80009A60 getTempFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getTempFlags1() const {
|
||||
return temp_flags;
|
||||
}
|
||||
// 0x80009A70 getZoneFlags0__8SaveFileFv
|
||||
u16* SaveFile::getZoneFlags0() {
|
||||
return zone_flags;
|
||||
}
|
||||
// 0x80009A80 getZoneFlags1__8SaveFileFv
|
||||
u16* SaveFile::getZoneFlags1() {
|
||||
// 0x80009A80 getZoneFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getZoneFlags1() const {
|
||||
return zone_flags;
|
||||
}
|
||||
// 0x80009A90 getUnkFlags0__8SaveFileFv
|
||||
u16* SaveFile::getUnkFlags0() {
|
||||
return unk_flags;
|
||||
// 0x80009A90 getEnemyFlags0__8SaveFileFv
|
||||
u16* SaveFile::getEnemyFlags0() {
|
||||
return enemy_flags;
|
||||
}
|
||||
// 0x80009AA0 getUnkFlags1__8SaveFileFv
|
||||
u16* SaveFile::getUnkFlags1() {
|
||||
return unk_flags;
|
||||
// 0x80009AA0 getEnemyFlags1__8SaveFileCFv
|
||||
const u16* SaveFile::getEnemyFlags1() const {
|
||||
return enemy_flags;
|
||||
}
|
||||
// 0x80009AB0 getPlayerName__8SaveFileFv
|
||||
s16* SaveFile::getPlayerName() {
|
||||
wchar_t* SaveFile::getPlayerName() {
|
||||
return player_name;
|
||||
}
|
||||
|
||||
@@ -105,4 +105,4 @@ s8* SaveFile::getAreaT2() {
|
||||
// 0x80009D20 getAreaT3__8SaveFileFv
|
||||
s8* SaveFile::getAreaT3() {
|
||||
return area_t3;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user