Fix JKRArchive on 64-bit

They store the data address in the same struct that's directly loaded from archive files. This means it's impossible to expand to 64-bit directly, and instead we need to allocate the data pointers in a separate array.
This commit is contained in:
PJB3005
2026-02-24 19:55:15 +01:00
parent 4e0a8292e9
commit cf5eca0910
8 changed files with 127 additions and 43 deletions
+10 -7
View File
@@ -31,8 +31,8 @@ JKRAramArchive::~JKRAramArchive() {
if (mArcInfoBlock != NULL) {
SDIFileEntry* entry = mFiles;
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
if (entry->data != NULL) {
JKRFreeToHeap(mHeap, entry->data);
if (JKAR_DATA(entry) != NULL) {
JKRFreeToHeap(mHeap, JKAR_DATA(entry));
}
entry++;
}
@@ -135,6 +135,9 @@ bool JKRAramArchive::open(s32 entryNum) {
mFiles = (SDIFileEntry*)((u8*)mArcInfoBlock + mArcInfoBlock->file_entry_offset);
mStringTable = (char*)((u8*)mArcInfoBlock + mArcInfoBlock->string_table_offset);
mExpandedSize = NULL;
#if TARGET_PC
initFileDataPointers();
#endif
u8 compressedFiles = 0; // maybe a check for if the last file is compressed?
@@ -199,7 +202,7 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) {
}
JKRCompression compression = JKRConvertAttrToCompressionType(u8(pEntry->type_flags_and_name_offset >> 24));
if (pEntry->data == NULL) {
if (JKAR_DATA(pEntry) == NULL) {
u32 size = JKRAramArchive::fetchResource_subroutine(
pEntry->data_offset + mBlock->getAddress(), pEntry->data_size, mHeap, compression,
&outBuf);
@@ -209,7 +212,7 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) {
return NULL;
}
pEntry->data = outBuf;
JKAR_DATA(pEntry) = outBuf;
if (compression == COMPRESSION_YAZ0) {
this->setExpandSize(pEntry, *pOutSize);
}
@@ -221,7 +224,7 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) {
}
}
return pEntry->data;
return JKAR_DATA(pEntry);
}
void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* pEntry,
@@ -233,7 +236,7 @@ void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry*
}
JKRCompression compression = JKRConvertAttrToCompressionType(u8(pEntry->type_flags_and_name_offset >> 24));
if (pEntry->data == NULL) {
if (JKAR_DATA(pEntry) == NULL) {
bufferSize = (s32)ALIGN_PREV(bufferSize, 0x20);
size = JKRAramArchive::fetchResource_subroutine(pEntry->data_offset + mBlock->getAddress(),
size, (u8*)buffer, bufferSize, compression);
@@ -247,7 +250,7 @@ void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry*
if (size > bufferSize) {
size = bufferSize;
}
JKRHeap::copyMemory(buffer, pEntry->data, size);
JKRHeap::copyMemory(buffer, JKAR_DATA(pEntry), size);
}
if (resourceSize != NULL) {