d_rawarchive mostly matching

This commit is contained in:
robojumper
2024-05-25 19:30:32 +02:00
parent fda931e2ae
commit 6da4bb94c5
10 changed files with 574 additions and 75 deletions
+104
View File
@@ -0,0 +1,104 @@
#ifndef D_RAWARCHIVE_H
#define D_RAWARCHIVE_H
#include <common.h>
#include <m/m_dvd.h>
// TODO: loading status could be an enum (-2/-1/0/+1)
// Ghidra: ArcManagerEntry
// size: 0x40
class dRawArcEntry_c {
public:
dRawArcEntry_c();
~dRawArcEntry_c();
bool destroy(void *arg);
bool loadArcFromDiskChecked(const char *fileName, const char *dirName, u8 mountDirection, EGG::Heap *heap);
bool loadArcFromDisk(const char *fileName, const char *dirName, u8 mountDirection, EGG::Heap *heap);
static bool checkArcExistsOnDisk(const char *fileName, const char *dirName);
static bool checkArcExistsOnDiskInner(char *outBuf, const char *fileName, const char *dirName);
int mount(const char *name, void *data, void *callbackArg, u8 mountDirection, EGG::Heap *heap);
int onMount(void *callbackArg);
int ensureLoadedMaybe(void *callbackArg);
inline bool isReferenced() {
return mRefCount != 0;
}
inline const char *name() {
return mArcName;
}
inline bool isNotLoaded() {
return mpArc == nullptr;
}
inline bool isLoading() {
return mpDvdReq != nullptr;
}
inline void increaseRefCount() {
mRefCount++;
}
inline void decreaseRefCount() {
mRefCount--;
}
inline void *getData() {
return mpData;
}
inline EGG::Archive *getArc() {
return mpArc;
}
private:
static void searchCallback(void *, void *, const ARCDirEntry *, const char *, bool);
static void searchCallback1(void *, void *, const ARCDirEntry *, const char *);
static void searchCallback2(void *, void *, const ARCDirEntry *, const char *);
private:
/* 0x00 */ char mArcName[0x20];
/* 0x20 */ u16 mRefCount;
/* 0x24 */ mDvd_mountMemArchive_c *mpDvdReq;
/* 0x28 */ EGG::Archive *mpArc;
/* 0x2C */ EGG::Heap *mpCommandHeap;
/* 0x30 */ void *mpData;
/* 0x34 */ u32 mAmountRead;
/* 0x38 */ u32 mChecksum;
/* 0x3C */ EGG::FrmHeap *mpFrmHeap;
};
// Ghidra: ArcManagerEntryTable
// size: 0xC
class dRawArcTable_c {
public:
dRawArcTable_c();
~dRawArcTable_c();
bool init(u16 count, void *callbackArg, EGG::Heap *heap);
bool getArcOrLoadFromDisk(const char *name, const char *dirName, u8 mountDirection, EGG::Heap *heap);
bool addEntryFromSuperArc(const char *name, void *data, u8 mountDirection, EGG::Heap *heap);
int ensureLoadedMaybe2(const char *name);
int ensureLoadedMaybe(const char *name);
bool hasEntry(const char *name);
bool decreaseRefCount(const char *name);
void *getDataFromOarc(const char *name, const char *path);
void *getSubEntryData(const char *name, const char *path);
void *getLoadedArcData(const char *name);
int ensureAllEntriesLoaded();
dRawArcEntry_c *findEntry(const char *name) const;
dRawArcEntry_c *findEmptySlot();
dRawArcEntry_c *findLoadedEntry(const char *name);
private:
/* 0x0 */ dRawArcEntry_c *mpEntries;
/* 0x4 */ u16 mCount;
/* 0x8 */ void *mCallbackArg;
};
#endif;
+1 -1
View File
@@ -45,7 +45,7 @@ public:
/* 80493a40 */ static Archive *mountNandFile(NANDFileInfo *, Heap *heap, s32 align);
/* 80493ac0 */ static Archive *loadFST(const char *fileName, Heap *heap, s32 align);
/* 80493b80 */ void unmount();
/* 80493c20 */ u32 getFile(const char *name, FileInfo *out);
/* 80493c20 */ void *getFile(const char *name, FileInfo *out);
/* 80493cf0 */ s32 convertPathToEntryID(const char *path);
/* 80493d00 */ void *getFileFast(s32 entryId, FileInfo *fileinfo);
/* 80493dc0 */ void *getFileFast(s32 entryId, Heap *heap, s32 align);
+1 -1
View File
@@ -44,7 +44,7 @@ public:
/* 802f1590 */ static void createCommandHeap(size_t size, EGG::Heap *parentHeap);
/* 802f15c0 */ static void createDylinkHeap(size_t size, EGG::Heap *parentHeap);
/* 802f15f0 */ static EGG::AssertHeap *createAssertHeap(EGG::Heap *parentHeap);
/* 802f1640 */ static EGG::Heap *makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, u32 flags);
/* 802f1640 */ static EGG::FrmHeap *makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, u32 flags);
static int getDefaultGameHeapId();
+3 -3
View File
@@ -74,9 +74,9 @@ typedef struct ARCEntry {
typedef struct ARCDirEntry {
ARCHandle *handle; // at 0x0
u32 path_begin; // at 0x4
u32 path_it; // at 0x8
u32 path_end; // at 0xC
u32 entryNum; // at 0x4
u32 isDir; // at 0x8
const char *name; // at 0xC
} ARCDirEntry;
BOOL ARCGetCurrentDir(ARCHandle *handle, char *string, u32 maxlen);
-37
View File
@@ -1,37 +0,0 @@
#ifndef ARC_MANAGER_H
#define ARC_MANAGER_H
#include <common.h>
// Ghidra: ArcManagerEntry
// size: 0x40
struct ArcManagerEntry {
/* 0x00 */ char arc_name[0x20];
/* 0x20 */ u16 ref_count;
/* 0x24 */ int dvd_req_ptr;
/* 0x28 */ int archive_ptr;
/* 0x2C */ int heap_ptr_0;
/* 0x30 */ char field_0x30[0x3C - 0x30];
/* 0x3C */ int heap_ptr_1;
};
// Ghidra: ArcManagerEntryTable
// size: 0xC
class ArcMangerEntryTable {
public:
/* 0x0 */ ArcManagerEntry *entries;
/* 0x4 */ u16 count;
/* 0x8 */ u32 field_0x8;
public:
ArcMangerEntryTable();
};
class OarcManager {
public:
void *getDataFromOarc(char *oarcName, char *fileName);
};
OarcManager g_OarcManager;
#endif;