From a13590ff2133bed4d56ceb027628bdb38b11c53d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 24 Sep 2023 12:14:12 -0700 Subject: [PATCH] JKRStdHeap, JKRArchive match --- configure.py | 6 +++--- include/JSystem/JKernel/JKRArchive.h | 8 ++++---- include/JSystem/JKernel/JKRArchivePri.h | 5 ----- include/JSystem/JKernel/JKRArchivePub.h | 5 ----- include/JSystem/JKernel/JKRCompArchive.h | 2 +- src/JSystem/JKernel/JKRArchivePub.cpp | 23 ++++++++++++----------- src/JSystem/JKernel/JKRStdHeap.cpp | 2 +- 7 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 include/JSystem/JKernel/JKRArchivePri.h delete mode 100644 include/JSystem/JKernel/JKRArchivePub.h diff --git a/configure.py b/configure.py index abe117f60..962df3413 100644 --- a/configure.py +++ b/configure.py @@ -756,7 +756,7 @@ config.libs = [ "JKernel", [ Object(Matching, "JSystem/JKernel/JKRHeap.cpp"), - Object(NonMatching, "JSystem/JKernel/JKRStdHeap.cpp"), + Object(Matching, "JSystem/JKernel/JKRStdHeap.cpp"), Object(NonMatching, "JSystem/JKernel/JKRExpHeap.cpp"), Object(Matching, "JSystem/JKernel/JKRSolidHeap.cpp"), Object(Matching, "JSystem/JKernel/JKRDisposer.cpp"), @@ -769,8 +769,8 @@ config.libs = [ Object(Matching, "JSystem/JKernel/JKRFileLoader.cpp"), Object(Matching, "JSystem/JKernel/JKRFileFinder.cpp"), Object(Matching, "JSystem/JKernel/JKRFileCache.cpp"), - Object(NonMatching, "JSystem/JKernel/JKRArchivePub.cpp"), - Object(NonMatching, "JSystem/JKernel/JKRArchivePri.cpp"), + Object(Matching, "JSystem/JKernel/JKRArchivePub.cpp"), + Object(Matching, "JSystem/JKernel/JKRArchivePri.cpp"), Object(Matching, "JSystem/JKernel/JKRMemArchive.cpp"), Object(NonMatching, "JSystem/JKernel/JKRAramArchive.cpp"), Object(NonMatching, "JSystem/JKernel/JKRDvdArchive.cpp"), diff --git a/include/JSystem/JKernel/JKRArchive.h b/include/JSystem/JKernel/JKRArchive.h index ca184c2e7..f3bb0f5bd 100644 --- a/include/JSystem/JKernel/JKRArchive.h +++ b/include/JSystem/JKernel/JKRArchive.h @@ -41,8 +41,6 @@ inline u16 read_big_endian_u16(void* ptr) { return ((u16)uptr[0] << 8) | ((u16)uptr[1]); } -extern u32 sCurrentDirID__10JKRArchive; // JKRArchive::sCurrentDirID - class JKRArchive : public JKRFileLoader { public: struct SDirEntry { @@ -118,7 +116,6 @@ public: protected: JKRArchive(); JKRArchive(long, EMountMode); - virtual ~JKRArchive(); public: bool getDirEntry(SDirEntry*, u32) const; @@ -165,6 +162,9 @@ public: u8 getMountMode() const { return mMountMode; } bool isFileEntry(u32 param_0) { return getFileAttribute(param_0) & 1; } +protected: + virtual ~JKRArchive(); + public: /* 0x00 */ // vtable /* 0x04 */ // JKRFileLoader @@ -189,7 +189,7 @@ public: static JKRArchive* mount(void*, JKRHeap*, EMountDirection); static JKRArchive* mount(s32, EMountMode, JKRHeap*, EMountDirection); static void* getGlbResource(u32, const char*, JKRArchive*); - static void readTypeResource(void*, u32, u32, const char*, JKRArchive*); + static u32 readTypeResource(void*, u32, u32, const char*, JKRArchive*); static JKRCompression convertAttrToCompressionType(u32 attr) { #define JKRARCHIVE_ATTR_COMPRESSION 0x04 diff --git a/include/JSystem/JKernel/JKRArchivePri.h b/include/JSystem/JKernel/JKRArchivePri.h deleted file mode 100644 index a2cb65220..000000000 --- a/include/JSystem/JKernel/JKRArchivePri.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef JKRARCHIVEPRI_H -#define JKRARCHIVEPRI_H - - -#endif /* JKRARCHIVEPRI_H */ diff --git a/include/JSystem/JKernel/JKRArchivePub.h b/include/JSystem/JKernel/JKRArchivePub.h deleted file mode 100644 index bd2bdfa8a..000000000 --- a/include/JSystem/JKernel/JKRArchivePub.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef JKRARCHIVEPUB_H -#define JKRARCHIVEPUB_H - - -#endif /* JKRARCHIVEPUB_H */ diff --git a/include/JSystem/JKernel/JKRCompArchive.h b/include/JSystem/JKernel/JKRCompArchive.h index 338332fb6..4fb13152a 100644 --- a/include/JSystem/JKernel/JKRCompArchive.h +++ b/include/JSystem/JKernel/JKRCompArchive.h @@ -16,7 +16,7 @@ public: /* vt[09] */ void removeResourceAll(void); /* override */ /* vt[10] */ bool removeResource(void*); /* override */ - /* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */ + /* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */ /* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */ /* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */ diff --git a/src/JSystem/JKernel/JKRArchivePub.cpp b/src/JSystem/JKernel/JKRArchivePub.cpp index f080e84ad..23852d895 100644 --- a/src/JSystem/JKernel/JKRArchivePub.cpp +++ b/src/JSystem/JKernel/JKRArchivePub.cpp @@ -168,21 +168,22 @@ void* JKRArchive::getResource(u32 type, const char* path) { /* 802B8528-802B85F0 .text readTypeResource__10JKRArchiveFPvUlUlPCcP10JKRArchive */ // missing instructions -void JKRArchive::readTypeResource(void* buffer, u32 bufferSize, u32 type, const char* path, JKRArchive* archive) { - /* Nonmatching */ +u32 JKRArchive::readTypeResource(void* buffer, u32 bufferSize, u32 type, const char* path, JKRArchive* archive) { + u32 ret = 0; + if (archive) { - archive->readResource(buffer, bufferSize, type, path); - return; - } - JSUListIterator iterator; - for (iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); iterator++) { - if (iterator->getVolumeType() == 'RARC') { - u32 result = iterator->readResource(buffer, bufferSize, type, path); - if (result != 0) { - return; + ret = archive->readResource(buffer, bufferSize, type, path); + } else { + for (JSUListIterator it = sVolumeList.getFirst(); it != sVolumeList.getEnd(); it++) { + if (it->getVolumeType() == 'RARC') { + ret = it->readResource(buffer, bufferSize, type, path); + if (ret != 0) + break; } } } + + return ret; } /* 802B85F0-802B86DC .text readResource__10JKRArchiveFPvUlUlPCc */ diff --git a/src/JSystem/JKernel/JKRStdHeap.cpp b/src/JSystem/JKernel/JKRStdHeap.cpp index 015167447..147e417e4 100644 --- a/src/JSystem/JKernel/JKRStdHeap.cpp +++ b/src/JSystem/JKernel/JKRStdHeap.cpp @@ -24,10 +24,10 @@ JKRStdHeap* JKRStdHeap::create(u32 size, JKRHeap* parent, bool errorFlag) { } u8* memory = (u8*)JKRAllocFromHeap(parent, alignedSize, 0x20); u32 stdHeapSize = ALIGN_NEXT(sizeof(JKRStdHeap), 0x20); + u8* dataPtr = (memory + stdHeapSize); if (!memory) { return NULL; } - u8* dataPtr = (memory + stdHeapSize); JKRStdHeap* newHeap = new(memory) JKRStdHeap(dataPtr, alignedSize - stdHeapSize, parent, errorFlag); return newHeap; }