Merge branch 'main' into pr/17

This commit is contained in:
elijah-thomas774
2024-05-05 12:21:58 -04:00
43 changed files with 1656 additions and 528 deletions
+5 -8
View File
@@ -18,10 +18,10 @@ class Allocator;
struct HeapAllocArg {
void *userArg; // 00
u32 size; // 04
int align; // 08
Heap *heap; // 0C heap to allocate in
int another; // 10
u32 size; // 04
int align; // 08
Heap *heap; // 0C heap to allocate in
int another; // 10
inline HeapAllocArg() : userArg(0), size(0), align(0), heap(nullptr) {}
};
@@ -158,9 +158,6 @@ public:
/* 80495a70 */ void *operator new(size_t size, EGG::Heap *heap, u32 align);
/* 80495a80 */ void *operator new(size_t size, EGG::Allocator *alloc);
/* 80495a90 */ void *operator new[](size_t size, u32 align);
/* 80495aa0 */ void *operator new[](size_t size, EGG::Heap *heap, int align);
};
} // namespace EGG
/* 80495aa0 */ void *operator new[](size_t size, EGG::Heap *heap, u32 align);
#endif
+5 -3
View File
@@ -11,9 +11,9 @@ namespace EGG {
class Thread {
public: // vtable: 0x00 | 8056ea40
/* 0x08 | 80496a60 */ virtual ~Thread();
/* 0x0C | 80496dd0 */ virtual void *run();
/* 0x10 | 800bd600 */ virtual void onEnter();
/* 0x14 | 800bd5f0 */ virtual void onExit();
/* 0x0C | 80496dd0 */ virtual void *run() { return nullptr; }
/* 0x10 | 800bd600 */ virtual void onEnter() {}
/* 0x14 | 800bd5f0 */ virtual void onExit() {}
public:
/* 0x04 */ Heap *mContainingHeap;
@@ -24,6 +24,8 @@ public:
/* 0x34 */ void *mStackMemory;
/* 0x38 */ u32 mStackSize;
/* 0x3C */ Heap *mAllocatableHeap;
// TODO from the usage in eggThread this really looks like
// it's stashed thread that's restored when switching threads
/* 0x40 */ Heap *mCurrentHeap;
/* 0x44 */ nw4r::ut::Node mLink;
+1 -1
View File
@@ -33,7 +33,7 @@ namespace mHeap {
u32 unk);
/* 802f1450 */ int getGameHeapNum();
/* 802f1460 */ EGG::ExpHeap *createGameHeap(s32 heapNum, size_t size, EGG::Heap *parentHeap);
/* 802f1510 */ EGG::Heap *createGameHeap1(s32 size, EGG::Heap *parentHeap);
/* 802f1510 */ EGG::ExpHeap *createGameHeap1(s32 size, EGG::Heap *parentHeap);
/* 802f1560 */ EGG::ExpHeap *createArchiveHeap(size_t size, EGG::Heap *parentHeap);
/* 802f1590 */ EGG::ExpHeap *createCommandHeap(size_t size, EGG::Heap *parentHeap);
/* 802f15c0 */ EGG::ExpHeap *createDylinkHeap(size_t size, EGG::Heap *parentHeap);
+2 -1
View File
@@ -8,7 +8,8 @@
class mVec3_c : public EGG::Vector3f {
public:
/// @brief Constructs an empty vector.
mVec3_c() {}
/* 80009ee0 */ mVec3_c() {}
/* 80007460 */ ~mVec3_c() {}
/// @brief Constructs a vector from a float array.
mVec3_c(const f32 *p) {
+14 -8
View File
@@ -16,14 +16,20 @@ public:
public:
FilePosition() : mFileSize(0), mFileOffset(0) {}
u32 GetFileSize() const { return mFileSize; }
void SetFileSize(u32 fileSize) { mFileSize = fileSize; }
u32 GetFileSize() const {
return mFileSize;
}
void SetFileSize(unsigned long fileSize) {
mFileSize = fileSize;
}
u32 Tell() const { return mFileOffset; }
u32 Tell() const {
return mFileOffset;
}
u32 Skip(s32 offset);
u32 Append(s32 offset);
void Seek(s32 offset, u32 origin);
u32 Skip(long offset);
u32 Append(long offset);
void Seek(long offset, unsigned long origin);
private:
u32 mFileSize; // at 0x0
@@ -35,9 +41,9 @@ public:
virtual ~FileStream() {} // at 0xC
virtual u32 GetSize() const = 0; // at 0x40
virtual void Seek(s32 offset, u32 origin); // at 0x44
virtual void Seek(long offset, unsigned long origin); // at 0x44
virtual void Cancel(); // at 0x48
virtual bool CancelAsync(AsyncCallback callback, void* arg); // at 0x4C
virtual bool CancelAsync(AsyncCallback callback, void *arg); // at 0x4C
virtual bool CanSeek() const = 0; // at 0x50
virtual bool CanCancel() const = 0; // at 0x54
virtual u32 Tell() const = 0; // at 0x58
+24 -16
View File
@@ -10,33 +10,41 @@ class IOStream {
public:
NW4R_UT_RTTI_DECL(IOStream);
typedef void (*AsyncCallback)(s32 result, IOStream* stream, void* arg);
typedef void (*AsyncCallback)(long result, IOStream *stream, void *arg);
IOStream() : mIsOpen(false), mCallback(NULL), mCallbackArg(NULL) {}
virtual ~IOStream() {} // at 0xC
virtual void Close() = 0; // at 0x10
virtual s32 Read(void* dst, u32 size) = 0; // at 0x14
virtual bool ReadAsync(void* dst, u32 size, AsyncCallback callback,
void* arg); // at 0x18
virtual void Write(const void* src, u32 size); // at 0x1C
virtual bool WriteAsync(const void* src, u32 size, AsyncCallback callback,
void* arg); // at 0x20
virtual bool IsBusy() const; // at 0x24
virtual bool CanAsync() const = 0; // at 0x28
virtual bool CanRead() const = 0; // at 0x2C
virtual bool CanWrite() const = 0; // at 0x30
virtual u32 GetOffsetAlign() const { return 1; } // at 0x34
virtual u32 GetSizeAlign() const { return 1; } // at 0x38
virtual u32 GetBufferAlign() const { return 1; } // at 0x3C
virtual s32 Read(void *dst, u32 size) = 0; // at 0x14
virtual bool ReadAsync(void *dst, unsigned long size, AsyncCallback callback,
void *arg); // at 0x18
virtual bool Write(const void *src, unsigned long size); // at 0x1C
virtual bool WriteAsync(const void *src, unsigned long size, AsyncCallback callback,
void *arg); // at 0x20
virtual bool IsBusy() const; // at 0x24
virtual bool CanAsync() const = 0; // at 0x28
virtual bool CanRead() const = 0; // at 0x2C
virtual bool CanWrite() const = 0; // at 0x30
virtual u32 GetOffsetAlign() const {
return 1;
} // at 0x34
virtual u32 GetSizeAlign() const {
return 1;
} // at 0x38
virtual u32 GetBufferAlign() const {
return 1;
} // at 0x3C
bool IsAvailable() const { return mIsOpen; }
bool IsAvailable() const {
return mIsOpen;
}
protected:
bool mIsOpen; // at 0x4
s32 mResult; // at 0x8
AsyncCallback mCallback; // at 0xC
void* mCallbackArg; // at 0x10
void *mCallbackArg; // at 0x10
};
} // namespace ut
+11 -9
View File
@@ -10,9 +10,10 @@ enum PrintFlags {
PRINTFLAGS_CHARSPACE = (1 << 0),
};
template <typename T> struct PrintContext {
TextWriterBase<T>* writer; // at 0x0
const T* str; // at 0x4
template <typename T>
struct PrintContext {
TextWriterBase<T> *writer; // at 0x0
const T *str; // at 0x4
f32 x; // at 0x8
f32 y; // at 0xC
u32 flags; // at 0x10
@@ -26,17 +27,18 @@ enum Operation {
OPERATION_END_DRAW
};
template <typename T> class TagProcessorBase {
template <typename T>
class TagProcessorBase {
public:
TagProcessorBase();
virtual ~TagProcessorBase(); // at 0x8
virtual Operation Process(u16 ch, PrintContext<T>* ctx); // at 0xC
virtual Operation CalcRect(Rect* rect, u16 ch,
PrintContext<T>* ctx); // at 0x10
virtual Operation Process(u16 ch, PrintContext<T> *ctx); // at 0xC
virtual Operation CalcRect(Rect *rect, u16 ch,
PrintContext<T> *ctx); // at 0x10
void ProcessTab(PrintContext<T>* ctx);
void ProcessLinefeed(PrintContext<T>* ctx);
void ProcessLinefeed(PrintContext<T> *ctx);
void ProcessTab(PrintContext<T> *ctx);
};
} // namespace ut
+1 -2
View File
@@ -19,8 +19,7 @@ struct BinaryFileHeader {
u16 numBlocks; // at 0xE
};
bool IsValidBinaryFile(const BinaryFileHeader* header, u32 magic, u16 version,
u16 numBlocks);
bool IsValidBinaryFile(const BinaryFileHeader *header, unsigned long magic, u16 version, u16 numBlocks);
} // namespace ut
} // namespace nw4r
+2 -2
View File
@@ -47,8 +47,8 @@ typedef struct OSThread {
OSMutexQueue mutexQueue; // at 0x2F4
struct OSThread *nextActive; // at 0x2FC
struct OSThread *prevActive; // at 0x300
u32 *stackBegin; // at 0x304
u32 *stackEnd; // at 0x308
void *stackBegin; // at 0x304
void *stackEnd; // at 0x308
s32 error; // at 0x30C
void *specific[2]; // at 0x310
} OSThread;
+19
View File
@@ -0,0 +1,19 @@
#ifndef COUNTER_H
#define COUNTER_H
#include <common.h>
class Counter {
public:
Counter(u16 id): counterId(id) {}
virtual ~Counter() {};
virtual s32 checkedAdd(s32 num);
virtual u16 getCommittedValue();
virtual u16 getMax() = 0;
virtual u16 getUncommittedValue();
virtual void setValue(u16 num);
u16 counterId;
};
#endif COUNTER_H
+30 -13
View File
@@ -4,18 +4,32 @@
#include "toBeSorted/save_file.h"
#include <common.h>
enum ITEM_ID {};
enum SAVE_ITEM_ID {};
class SkipData {
public:
/** 0x00 */ u16 data[16];
/** 0x20 */ u32 crc;
};
class SavedSaveFiles {
public:
/* 0x0000 */ char regionCode[4];
/* 0x0004 */ u8 unk1[0x1C - 0x04];
/* 0x001C */ u32 m_0x1C;
/* 0x0020 */ SaveFile saveFiles[3];
/* 0xfb60 */ SkipData skipData[3];
/* 0xfbcc */ u8 unk2[0xfbe0 - 0xfbcc];
};
class FileManager {
public:
/* 0x0000 */ void *mpSavedSaveFiles;
/* 0x0004 */ void *mpSkipData; // skip data Arrary (3 entries )
/* 0x0000 */ SavedSaveFiles *mpSavedSaveFiles;
/* 0x0004 */ SkipData *mpSkipData; // skip data Arrary (3 entries )
/* 0x0008 */ SaveFile mFileA;
/* 0x53C8 */ SaveFile mFileB;
/* 0xA788 */ u16 mSkipFlags[16];
/* 0xA7A8 */ u32 mSkipFlagsCRC;
/* 0xA788 */ SkipData mSkipData;
/* 0xA7AC */ wchar_t mHeroNames[3][9]; // each name is 9 wchars
/* 0xA7E2 */ wchar_t mHeroName[9]; // The current Hero Name
/* 0xA7F4 */ char mCurrentArea[32];
@@ -46,7 +60,7 @@ public:
/* 80009DB0 */ FileManager(); //
/* 80009EE0 */ // mVec3();
/* 80009EF0 */ static FileManager create(EGG::Heap *);
/* 80009EF0 */ static FileManager *create(EGG::Heap *);
/* 80009F30 */ bool loadSaveData(void *out, char *name, bool isSkipData);
/* 80009F70 */ void saveSaveData(void *unk, bool isSkipData);
/* 8000A000 */ void refreshSaveFileData();
@@ -57,7 +71,7 @@ public:
/* 8000A2E0 */ void fn_8000A2E0(); // idk something blank save files
/* 8000A330 */ u16 *getStoryFlagsMut();
/* 8000A360 */ u16 *getStoryFlagsConst();
/* 8000A360 */ const u16 *getStoryFlagsConst() const;
/* 8000A3B0 */ u16 *getItemFlagsMut();
/* 8000A3E0 */ u16 *getItemFlagsConst();
/* 8000A430 */ u16 *getDungeonFlagsMut();
@@ -219,7 +233,7 @@ public:
/* 8000D040 */ u8 getSkykeepPuzzleTile(u32 spot);
/* 8000D0B0 */ void checkFileStatus();
/* 8000D1D0 */ void checkSkipDataCRCs();
/* 8000D1D0 */ bool checkSkipDataCRCs();
/* 8000D270 */ void saveOrClearSelectedFileToFileA();
/* 8000D280 */ void saveOrClearToFileA(int fileNum);
/* 8000D9C0 */ void copyFileBToCurrentFile();
@@ -230,7 +244,7 @@ public:
/* 8000EF90 */ void saveFileAToFile(int fileNum);
/* 8000F730 */ void copyCurrentToFileB();
/* 8000FDF0 */ void copySelectedFileSkipData();
/* 8000FE00 */ void copySkipData(int fileNum);
/* 8000FE00 */ void copySkipData(u8 fileNum);
/* 8000FEB0 */ void setInfo_FileB();
/* 8000FF60 */ void clearFileA();
@@ -243,18 +257,21 @@ public:
/* 80010440 */ void clearTempFileData();
/* 800104A0 */ void saveAfterCredits();
/* 80011210 */ SaveFile *getCurrentFile();
inline const SaveFile *getCurrentFile() const {
return isFileInactive() ? &mFileB : &mFileA;
}
/* 80011250 */ u16 *getSkipFlags2();
/* 80011260 */ SaveFile *getFileA();
/* 80011270 */ SaveFile *getFileB();
/* 80011280 */ void calcFileCRC(const SaveFile *file, u32 length);
/* 80011280 */ u32 calcFileCRC(const void *data, u32 length);
/* 80011290 */ void updateEmptyFiles();
/* 800112D0 */ void updateEmptyFileFlags();
/* 80011370 */ bool isFileEmpty(int fileNum);
/* 80011390 */ bool isFileUnk3(int fileNum);
/* 80011390 */ bool isFileDirty(int fileNum);
/* 800113B0 */ u8 get_0xA84C();
/* 800113C0 */ bool checkRegionCode();
/* 80011440 */ bool checkFileCRC(int fileNum);
/* 80011490 */ bool isFileInactive();
/* 80011440 */ bool checkFileCRC(u8 fileNum);
/* 80011490 */ bool isFileInactive() const;
/* 80011500 */ void setPlayerInfoFileA();
/* 800115E0 */ void setT3Info(mVec3_c *pos, mAng3_c *rot);
/* 800116C0 */ static void getRegionVersion(char *out);
+28 -28
View File
@@ -1,27 +1,27 @@
#ifndef SAVE_FILE_H
#define SAVE_FILE_H
#include "UnknownTypeBelongings.h"
#include "m/m_vec.h"
#include <common.h>
// Ghidra: SaveFile
// Size: 0x53c0
// non-offical name
class SaveFile {
struct SaveFile {
public:
/* 0x 0000 */ char field_0x0000[0x8 - 0x0];
/* 0x 0000 */ s64 playTime;
/* 0x 0008 */ s64 savedTime;
/* 0x 0010 */ Vec3f pos_t1;
/* 0x 001c */ Vec3f pos_t2;
/* 0x 0028 */ Vec3f pos_t3;
/* 0x 0034 */ Vec3f beacon_pos[32][5];
/* 0x 0010 */ mVec3_c pos_t1;
/* 0x 001c */ mVec3_c pos_t2;
/* 0x 0028 */ mVec3_c pos_t3;
/* 0x 0034 */ mVec3_c beacon_pos[32][5];
/* 0x 07b4 */ s32 beedleShopPathSegment;
/* 0x 07b8 */ f32 beedlShopPathSegFrac;
/* 0x 07bc */ char field_0x07BC[0x7c0 - 0x7bc];
/* 0x 07bc */ u32 field_0x07BC;
/* 0x 07c0 */ s32 pouch_items[8];
/* 0x 07e0 */ s32 item_check_items[60];
/* 0x 08d0 */ int file_area_index;
/* 0x 08d4 */ s16 player_name[8];
/* 0x 08d4 */ wchar_t player_name[8];
/* 0x 08e4 */ u16 story_flags[128];
/* 0x 09e4 */ u16 item_flags[64];
/* 0x 0a64 */ u16 dungeon_flags[8][22];
@@ -34,15 +34,15 @@ public:
/* 0x 302c */ u16 hitByEnemyCounts[100];
/* 0x 30f4 */ u16 temp_flags[4];
/* 0x 30fc */ u16 zone_flags[252];
/* 0x 32f4 */ u16 unk_flags[4096]; // size guessed? (saw memset)
/* 0x 52f4 */ s16 air_potion_timer;
/* 0x 52f6 */ s16 air_potion_plus_timer;
/* 0x 52f8 */ s16 stamina_potion_timer;
/* 0x 52fa */ s16 stamina_potion_plus_timer;
/* 0x 52fc */ s16 gaurdian_potion_timer;
/* 0x 52fe */ s16 gaurdian_potion_plus_timer;
/* 0x 5300 */ s16 field_0x5300;
/* 0x 5302 */ s16 health_capacity;
/* 0x 32f4 */ u16 enemy_flags[4096];
/* 0x 52f4 */ u16 air_potion_timer;
/* 0x 52f6 */ u16 air_potion_plus_timer;
/* 0x 52f8 */ u16 stamina_potion_timer;
/* 0x 52fa */ u16 stamina_potion_plus_timer;
/* 0x 52fc */ u16 gaurdian_potion_timer;
/* 0x 52fe */ u16 gaurdian_potion_plus_timer;
/* 0x 5300 */ u16 field_0x5300;
/* 0x 5302 */ u16 health_capacity;
/* 0x 5304 */ u16 unused_heart_related;
/* 0x 5306 */ u16 current_health;
/* 0x 5308 */ u16 room_id_t1;
@@ -86,22 +86,22 @@ public:
// ----------------------------------------------------------
public:
/* 800099b0 */ u16 *getStoryFlags0();
/* 800099c0 */ u16 *getStoryFlags1();
/* 800099c0 */ const u16 *getStoryFlags1() const;
/* 800099d0 */ u16 *getItemFlags0();
/* 800099e0 */ u16 *getItemFlags1();
/* 800099e0 */ const u16 *getItemFlags1() const;
/* 800099F0 */ u16 *getDungeonFlags0();
/* 80009A00 */ u16 *getDungeonFlags1();
/* 80009A00 */ const u16 *getDungeonFlags1() const;
/* 80009A10 */ u16 *getSceneFlags0();
/* 80009A20 */ u16 *getSceneFlags1();
/* 80009A20 */ const u16 *getSceneFlags1() const;
/* 80009A30 */ u16 *getTboxFlags0();
/* 80009A40 */ u16 *getTboxFlags1();
/* 80009A40 */ const u16 *getTboxFlags1() const;
/* 80009A50 */ u16 *getTempFlags0();
/* 80009A60 */ u16 *getTempFlags1();
/* 80009A60 */ const u16 *getTempFlags1() const;
/* 80009A70 */ u16 *getZoneFlags0();
/* 80009A80 */ u16 *getZoneFlags1();
/* 80009A90 */ u16 *getUnkFlags0();
/* 80009AA0 */ u16 *getUnkFlags1();
/* 80009AB0 */ s16 *getPlayerName(); // UTF16-BE
/* 80009A80 */ const u16 *getZoneFlags1() const;
/* 80009A90 */ u16 *getEnemyFlags0();
/* 80009AA0 */ const u16 *getEnemyFlags1() const;
/* 80009AB0 */ wchar_t *getPlayerName(); // UTF16-BE
/* 80009AC0 */ void setAreaT1(char *name);
/* 80009BE0 */ char *getAreaT1();
/* 80009BF0 */ void setAreaT2(char *name);