JKRAramArchive work

This commit is contained in:
Jasper St. Pierre
2023-10-29 12:56:44 -07:00
parent 5ecfe0da71
commit a58edb2a24
6 changed files with 33 additions and 33 deletions
+1 -1
View File
@@ -787,7 +787,7 @@ config.libs = [
Object(Matching, "JSystem/JKernel/JKRFile.cpp"),
Object(NonMatching, "JSystem/JKernel/JKRDvdFile.cpp"),
Object(Matching, "JSystem/JKernel/JKRDvdRipper.cpp"),
Object(NonMatching, "JSystem/JKernel/JKRDvdAramRipper.cpp", extra_cflags=["-sym off"]),
Object(Matching, "JSystem/JKernel/JKRDvdAramRipper.cpp", extra_cflags=["-sym off"]),
Object(Matching, "JSystem/JKernel/JKRDecomp.cpp"),
],
),
+3 -3
View File
@@ -193,12 +193,12 @@ public:
static JKRCompression convertAttrToCompressionType(u32 attr) {
#define JKRARCHIVE_ATTR_COMPRESSION 0x04
#define JKRARCHIVE_ATTR_YAY0 0x80
#define JKRARCHIVE_ATTR_YAZ0 0x80
JKRCompression compression;
if (FLAG_ON(attr, JKRARCHIVE_ATTR_COMPRESSION)) {
if (!(attr & JKRARCHIVE_ATTR_COMPRESSION)) {
compression = COMPRESSION_NONE;
} else if (!FLAG_ON(attr, JKRARCHIVE_ATTR_YAY0)) {
} else if (attr & JKRARCHIVE_ATTR_YAZ0) {
compression = COMPRESSION_YAZ0;
} else {
compression = COMPRESSION_YAY0;
+1 -1
View File
@@ -23,7 +23,7 @@ public:
private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x64 */ s32 field_0x64;
/* 0x64 */ s32 mDataOffset;
/* 0x68 */ JKRDvdFile* mDvdFile;
};
-1
View File
@@ -15,7 +15,6 @@
#define JUT_EXPECT(...)
#define ASSERT(...)
#define LOGF(FMT, ...)
#define FLAG_ON(V, F) (((V) & (F)) == 0)
#define FLOAT_LABEL(x) (*(f32*)&x)
#define DOUBLE_LABEL(x) (*(f64*)&x)
+19 -18
View File
@@ -249,31 +249,32 @@ u32 JKRAramArchive::fetchResource_subroutine(u32 srcAram, u32 srcLength, u8* dst
/* 802BA894-802BAA48 .text fetchResource_subroutine__14JKRAramArchiveFUlUlP7JKRHeapiPPUc */
u32 JKRAramArchive::fetchResource_subroutine(u32 entryNum, u32 length, JKRHeap* pHeap, int compression, u8** out) {
/* Nonmatching */
u32 readLen;
u32 alignedLen = ALIGN_NEXT(length, 0x20);
u8* buffer;
switch (compression) {
case COMPRESSION_NONE:
buffer = static_cast<u8*>(JKRAllocFromHeap(pHeap, alignedLen, 0x20));
JUT_ASSERT(662, buffer != 0);
JKRAramToMainRam(entryNum, buffer, alignedLen, EXPAND_SWITCH_UNKNOWN0, alignedLen,
NULL, -1, NULL);
*out = buffer;
return length;
{
buffer = (u8*)(JKRAllocFromHeap(pHeap, alignedLen, 0x20));
JUT_ASSERT(662, buffer != 0);
JKRAramToMainRam(entryNum, buffer, alignedLen, EXPAND_SWITCH_UNKNOWN0, alignedLen, NULL, -1, NULL);
*out = buffer;
return length;
}
case COMPRESSION_YAY0:
case COMPRESSION_YAZ0:
u8 tmpBuf[0x40];
u8* buf = (u8*)ALIGN_PREV((s32)&tmpBuf[0x1F], sizeof(SArcHeader));
JKRAramToMainRam(entryNum, buf, sizeof(SArcHeader), EXPAND_SWITCH_UNKNOWN0, 0, NULL, -1, NULL);
length = ALIGN_NEXT(JKRDecompExpandSize(buf), sizeof(SArcHeader));
buffer = static_cast<u8*>(JKRAllocFromHeap(pHeap, length, sizeof(SArcHeader)));
JUT_ASSERT(688, buffer);
JKRAramToMainRam(entryNum, buffer, alignedLen, EXPAND_SWITCH_UNKNOWN1, length, pHeap,
-1, &readLen);
*out = buffer;
return readLen;
{
u8 headerBuf[0x40];
u8* alignHeader = (u8*)ALIGN_NEXT((s32)&headerBuf[0], sizeof(SArcHeader));
JKRAramToMainRam(entryNum, alignHeader, sizeof(SArcHeader), EXPAND_SWITCH_UNKNOWN0, 0, NULL, -1, NULL);
u32 decompressedLen = ALIGN_NEXT(JKRDecompExpandSize(alignHeader), sizeof(SArcHeader));
buffer = (u8*)(JKRAllocFromHeap(pHeap, decompressedLen, sizeof(SArcHeader)));
JUT_ASSERT(688, buffer);
u32 readLen;
JKRAramToMainRam(entryNum, buffer, alignedLen, EXPAND_SWITCH_UNKNOWN1, decompressedLen, pHeap, -1, &readLen);
*out = buffer;
return readLen;
}
default:
OSPanic(__FILE__, 698, ":::??? bad sequence\n");
return 0;
+9 -9
View File
@@ -65,7 +65,7 @@ static void dummy() {
/* 802BAD98-802BB024 .text open__13JKRDvdArchiveFl */
bool JKRDvdArchive::open(s32 entryNum) {
mArcInfoBlock = NULL;
field_0x64 = NULL;
mDataOffset = NULL;
mNodes = NULL;
mFiles = NULL;
mStringTable = NULL;
@@ -125,7 +125,7 @@ bool JKRDvdArchive::open(s32 entryNum) {
memset(mExpandedSize, 0, sizeof(s32) * mArcInfoBlock->num_file_entries);
}
field_0x64 = arcHeader->header_length + arcHeader->file_data_offset;
mDataOffset = arcHeader->header_length + arcHeader->file_data_offset;
cleanup:
if (arcHeader) {
@@ -155,7 +155,7 @@ void* JKRDvdArchive::fetchResource(SDIFileEntry* fileEntry, u32* returnSize) {
if (!fileEntry->data) {
u8* resourcePtr;
u32 resourceSize = fetchResource_subroutine(
mEntryNum, this->field_0x64 + fileEntry->data_offset, fileEntry->data_size, mHeap,
mEntryNum, this->mDataOffset + fileEntry->data_offset, fileEntry->data_size, mHeap,
fileCompression, mCompression, &resourcePtr);
*returnSize = resourceSize;
if (resourceSize == 0) {
@@ -182,20 +182,20 @@ void* JKRDvdArchive::fetchResource(SDIFileEntry* fileEntry, u32* returnSize) {
void* JKRDvdArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* fileEntry, u32* returnSize) {
/* Nonmatching */
JUT_ASSERT(489, isMounted());
u32 otherSize;
u32 expandSize;
u32 size = fileEntry->data_size;
JKRCompression fileCompression = JKRConvertAttrToCompressionType(fileEntry->getAttr());
if (!fileEntry->data) {
bufferSize = ALIGN_PREV(bufferSize, 0x20);
size = fetchResource_subroutine(mEntryNum, field_0x64 + fileEntry->data_offset,
size = fetchResource_subroutine(mEntryNum, mDataOffset + fileEntry->data_offset,
fileEntry->data_size, (u8*)buffer, bufferSize, fileCompression,
mCompression);
} else {
if (fileCompression == COMPRESSION_YAZ0) {
otherSize = getExpandSize(fileEntry);
if (otherSize) {
size = otherSize;
expandSize = getExpandSize(fileEntry);
if (expandSize) {
size = expandSize;
}
}
@@ -360,7 +360,7 @@ u32 JKRDvdArchive::getExpandedResSize(const void* resource) const {
u8* arcHeader = (u8*)ALIGN_NEXT((u32)buffer, 0x20);
JKRDvdToMainRam(mEntryNum, arcHeader, EXPAND_SWITCH_UNKNOWN2, sizeof(SArcHeader), NULL,
JKRDvdRipper::ALLOC_DIRECTION_FORWARD,
this->field_0x64 + fileEntry->data_offset, NULL);
this->mDataOffset + fileEntry->data_offset, NULL);
DCInvalidateRange(arcHeader, sizeof(SArcHeader));
resourceSize = JKRDecompExpandSize(arcHeader);