clean JKernel

This commit is contained in:
TakaRikka
2023-02-26 17:50:56 -08:00
parent c54f0816ea
commit 090dcee012
30 changed files with 609 additions and 1285 deletions
+4 -4
View File
@@ -9,12 +9,12 @@ public:
JKRCompArchive(long, JKRArchive::EMountDirection); JKRCompArchive(long, JKRArchive::EMountDirection);
virtual ~JKRCompArchive(); virtual ~JKRCompArchive();
void open(long); bool open(long);
/* vt[09] */ void removeResourceAll(void); /* override */ /* vt[09] */ void removeResourceAll(void); /* override */
/* vt[10] */ bool removeResource(void*); /* override */ /* vt[10] */ bool removeResource(void*); /* override */
/* vt[15] */ u32 getExpandedResSize(const void*); /* override */ /* vt[15] */ u32 getExpandedResSize(const void*) const; /* override */
/* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */ /* vt[16] */ void* fetchResource(SDIFileEntry*, u32*); /* override */
/* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */ /* vt[17] */ void* fetchResource(void*, u32, SDIFileEntry*, u32*); /* override */
@@ -23,9 +23,9 @@ private:
/* 0x00 */ // vtable /* 0x00 */ // vtable
/* 0x04 */ // JKRArchive /* 0x04 */ // JKRArchive
/* 0x5C */ int field_0x5c; /* 0x5C */ int field_0x5c;
/* 0x60 */ int field_0x60; /* 0x60 */ EMountDirection mMountDirection;
/* 0x64 */ int field_0x64; /* 0x64 */ int field_0x64;
/* 0x68 */ int field_0x68; /* 0x68 */ JKRAramBlock* field_0x68;
/* 0x6C */ int field_0x6c; /* 0x6C */ int field_0x6c;
/* 0x70 */ JKRDvdFile* field_0x70; /* 0x70 */ JKRDvdFile* field_0x70;
/* 0x74 */ u32 mSizeOfMemPart; /* 0x74 */ u32 mSizeOfMemPart;
+10
View File
@@ -1,6 +1,8 @@
#ifndef JSUPPORT_H #ifndef JSUPPORT_H
#define JSUPPORT_H #define JSUPPORT_H
#include "dolphin/types.h"
template <typename T> template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) { T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
if (offset == NULL) { if (offset == NULL) {
@@ -10,4 +12,12 @@ T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
} }
} }
inline u8 JSULoByte(u16 in) {
return in & 0xff;
}
inline u8 JSUHiByte(u16 in) {
return in >> 8;
}
#endif #endif
+1
View File
@@ -147,5 +147,6 @@ extern "C" void JUTSetWarningConsole(JUTConsole*);
extern "C" JUTConsole* JUTGetWarningConsole(); extern "C" JUTConsole* JUTGetWarningConsole();
extern "C" void JUTReportConsole_f_va(const char*, va_list); extern "C" void JUTReportConsole_f_va(const char*, va_list);
extern "C" void JUTReportConsole_f(const char*, ...); extern "C" void JUTReportConsole_f(const char*, ...);
extern "C" void JUTWarningConsole(const char* message);
#endif /* JUTCONSOLE_H */ #endif /* JUTCONSOLE_H */
+2 -1
View File
@@ -26,7 +26,8 @@ typedef u32 OSHeapHandle;
extern volatile s32 __OSCurrHeap; extern volatile s32 __OSCurrHeap;
#define OSRoundUp32B(v) (((u32)(v + 31) & ~31)) #define OSRoundUp32B(x) (((u32)(x) + 0x1F) & ~(0x1F))
#define OSRoundDown32B(x) (((u32)(x)) & ~(0x1F))
#define OSRoundUp(x, align) (((x) + (align)-1) & (-(align))) #define OSRoundUp(x, align) (((x) + (align)-1) & (-(align)))
#define OSRoundUpPtr(x, align) ((void*)((((u32)(x)) + (align)-1) & (~((align)-1)))) #define OSRoundUpPtr(x, align) ((void*)((((u32)(x)) + (align)-1) & (~((align)-1))))
+3 -14
View File
@@ -124,7 +124,7 @@ JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, long priority)
u32 aramSize = ARGetSize(); u32 aramSize = ARGetSize();
mAudioMemorySize = audio_buffer_size; mAudioMemorySize = audio_buffer_size;
if (audio_graph_size == 0xffffffff) { if (audio_graph_size == 0xFFFFFFFF) {
mGraphMemorySize = (aramSize - audio_buffer_size) - aramBase; mGraphMemorySize = (aramSize - audio_buffer_size) - aramBase;
mAramMemorySize = 0; mAramMemorySize = 0;
} else { } else {
@@ -171,24 +171,15 @@ void* JKRAram::run(void) {
} while (true); } while (true);
} }
/* ############################################################################################## */
/* 8039D078-8039D078 0296D8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
// #pragma push
// #pragma force_active on
// SECTION_DEAD static char const* const stringBase_8039D078 = "JKRAram.cpp";
// SECTION_DEAD static char const* const stringBase_8039D084 = "%s";
// SECTION_DEAD static char const* const stringBase_8039D087 = ":::address not 32Byte aligned.";
// #pragma pop
/* 802D2248-802D22DC 2CCB88 0094+00 2/2 0/0 0/0 .text /* 802D2248-802D22DC 2CCB88 0094+00 2/2 0/0 0/0 .text
* checkOkAddress__7JKRAramFPUcUlP12JKRAramBlockUl */ * checkOkAddress__7JKRAramFPUcUlP12JKRAramBlockUl */
void JKRAram::checkOkAddress(u8* addr, u32 size, JKRAramBlock* block, u32 param_4) { void JKRAram::checkOkAddress(u8* addr, u32 size, JKRAramBlock* block, u32 param_4) {
if (!IS_ALIGNED((u32)addr, 0x20) && !IS_ALIGNED(size, 0x20)) { if (!IS_ALIGNED((u32)addr, 0x20) && !IS_ALIGNED(size, 0x20)) {
JUTException::panic_f("JKRAram.cpp", 0xdb, "%s", ":::address not 32Byte aligned."); JUTException::panic_f(__FILE__, 219, "%s", ":::address not 32Byte aligned.");
} }
if (block && !IS_ALIGNED((u32)block->getAddress() + param_4, 0x20)) { if (block && !IS_ALIGNED((u32)block->getAddress() + param_4, 0x20)) {
JUTException::panic_f("JKRAram.cpp", 0xe3, "%s", ":::address not 32Byte aligned."); JUTException::panic_f(__FILE__, 227, "%s", ":::address not 32Byte aligned.");
} }
} }
@@ -445,5 +436,3 @@ SECTION_DEAD static char const* const stringBase_8039D0A6 = "bad aramSync\n";
/* @stringBase0 padding */ /* @stringBase0 padding */
SECTION_DEAD static char const* const pad_8039D0B4 = "\0\0\0"; SECTION_DEAD static char const* const pad_8039D0B4 = "\0\0\0";
#pragma pop #pragma pop
/* 8039D078-8039D078 0296D8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+23 -19
View File
@@ -8,19 +8,11 @@
#include "JSystem/JKernel/JKRDvdAramRipper.h" #include "JSystem/JKernel/JKRDvdAramRipper.h"
#include "JSystem/JKernel/JKRDvdRipper.h" #include "JSystem/JKernel/JKRDvdRipper.h"
#include "JSystem/JKernel/JKRFile.h" #include "JSystem/JKernel/JKRFile.h"
#include "JSystem/JUtility/JUTException.h"
#include "MSL_C/MSL_Common/Src/string.h" #include "MSL_C/MSL_Common/Src/string.h"
#include "MSL_C/math.h" #include "MSL_C/math.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/os/OSCache.h" #include "dolphin/os/OSCache.h"
#include "dolphin/types.h"
//
// Types:
//
struct JUTException {
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
};
// //
// Forward References: // Forward References:
@@ -112,9 +104,11 @@ SECTION_DATA extern void* __vt__7JKRFile[8] = {
JKRAramArchive::JKRAramArchive(s32 param_0, JKRArchive::EMountDirection mountDirection) JKRAramArchive::JKRAramArchive(s32 param_0, JKRArchive::EMountDirection mountDirection)
: JKRArchive(param_0, MOUNT_ARAM) { : JKRArchive(param_0, MOUNT_ARAM) {
mMountDirection = mountDirection; mMountDirection = mountDirection;
if (!this->open(param_0)) { if (!this->open(param_0)) {
return; return;
} }
mVolumeType = 'RARC'; mVolumeType = 'RARC';
mVolumeName = mStringTable + mNodes->name_offset; mVolumeName = mStringTable + mNodes->name_offset;
JKRFileLoader::sVolumeList.prepend(&mFileLoaderLink); JKRFileLoader::sVolumeList.prepend(&mFileLoaderLink);
@@ -131,19 +125,24 @@ JKRAramArchive::~JKRAramArchive() {
JKRHeap::free(entry->data, mHeap); JKRHeap::free(entry->data, mHeap);
} }
} }
JKRHeap::free(mArcInfoBlock, mHeap); JKRHeap::free(mArcInfoBlock, mHeap);
mArcInfoBlock = NULL; mArcInfoBlock = NULL;
} }
if (mExpandedSize != NULL) { if (mExpandedSize != NULL) {
JKRHeap::free(mExpandedSize, NULL); JKRHeap::free(mExpandedSize, NULL);
mExpandedSize = NULL; mExpandedSize = NULL;
} }
if (mDvdFile != NULL) { if (mDvdFile != NULL) {
delete mDvdFile; delete mDvdFile;
} }
if (mBlock != NULL) { if (mBlock != NULL) {
delete mBlock; delete mBlock;
} }
JKRFileLoader::sVolumeList.remove(&mFileLoaderLink); JKRFileLoader::sVolumeList.remove(&mFileLoaderLink);
mIsMounted = false; mIsMounted = false;
} }
@@ -174,6 +173,7 @@ bool JKRAramArchive::open(s32 entryNum) {
mMountMode = UNKNOWN_MOUNT_MODE; mMountMode = UNKNOWN_MOUNT_MODE;
return false; return false;
} }
SArcHeader* header = static_cast<SArcHeader*>(JKRAllocFromSysHeap(0x20, -0x20)); SArcHeader* header = static_cast<SArcHeader*>(JKRAllocFromSysHeap(0x20, -0x20));
if (header == NULL) { if (header == NULL) {
mMountMode = UNKNOWN_MOUNT_MODE; mMountMode = UNKNOWN_MOUNT_MODE;
@@ -263,15 +263,18 @@ void* JKRAramArchive::fetchResource(JKRArchive::SDIFileEntry* pEntry, u32* pOutS
if (pOutSize == NULL) { if (pOutSize == NULL) {
pOutSize = &outSize; pOutSize = &outSize;
} }
JKRCompression compression = JKRConvertAttrToCompressionType(pEntry->getFlags()); JKRCompression compression = JKRConvertAttrToCompressionType(pEntry->getFlags());
if (pEntry->data == NULL) { if (pEntry->data == NULL) {
u32 size = JKRAramArchive::fetchResource_subroutine( u32 size = JKRAramArchive::fetchResource_subroutine(
pEntry->data_offset + mBlock->getAddress(), pEntry->data_size, mHeap, compression, pEntry->data_offset + mBlock->getAddress(), pEntry->data_size, mHeap, compression,
&outBuf); &outBuf);
*pOutSize = size; *pOutSize = size;
if (size == NULL) { if (size == NULL) {
return NULL; return NULL;
} }
pEntry->data = outBuf; pEntry->data = outBuf;
if (compression == COMPRESSION_YAZ0) { if (compression == COMPRESSION_YAZ0) {
this->setExpandSize(pEntry, *pOutSize); this->setExpandSize(pEntry, *pOutSize);
@@ -283,6 +286,7 @@ void* JKRAramArchive::fetchResource(JKRArchive::SDIFileEntry* pEntry, u32* pOutS
*pOutSize = pEntry->data_size; *pOutSize = pEntry->data_size;
} }
} }
return pEntry->data; return pEntry->data;
} }
@@ -352,6 +356,7 @@ u32 JKRAramArchive::fetchResource_subroutine(u32 src, u32 srcLength, u8* dst, u3
u32 outLen; u32 outLen;
u32 srcSize = ALIGN_NEXT(srcLength, 0x20); u32 srcSize = ALIGN_NEXT(srcLength, 0x20);
u32 dstSize = ALIGN_PREV(dstLength, 0x20); u32 dstSize = ALIGN_PREV(dstLength, 0x20);
switch (compression) { switch (compression) {
case COMPRESSION_NONE: case COMPRESSION_NONE:
if (srcSize > dstSize) { if (srcSize > dstSize) {
@@ -366,7 +371,7 @@ u32 JKRAramArchive::fetchResource_subroutine(u32 src, u32 srcLength, u8* dst, u3
&outLen); &outLen);
return outLen; return outLen;
default: default:
JUTException::panic_f("JKRAramArchive.cpp", 0x28F, "%s", "??? bad sequence\n"); JUTException::panic_f(__FILE__, 655, "%s", "??? bad sequence\n");
return 0; return 0;
} }
} }
@@ -400,7 +405,7 @@ u32 JKRAramArchive::fetchResource_subroutine(u32 entryNum, u32 length, JKRHeap*
*out = tmpBufAligned; *out = tmpBufAligned;
return readLen; return readLen;
default: default:
JUTException::panic_f("JKRAramArchive.cpp", 0x2c9, "%s", "??? bad sequence\n"); JUTException::panic_f(__FILE__, 0x2c9, "%s", "??? bad sequence\n");
return 0; return 0;
} }
} }
@@ -420,18 +425,22 @@ asm u32 JKRAramArchive::fetchResource_subroutine(u32 param_0, u32 param_1, JKRHe
u32 JKRAramArchive::getExpandedResSize(void const* ptr) const { u32 JKRAramArchive::getExpandedResSize(void const* ptr) const {
if (mExpandedSize == NULL) { if (mExpandedSize == NULL) {
return this->getResSize(ptr); return this->getResSize(ptr);
} else { }
JKRArchive::SDIFileEntry* entry = this->findPtrResource(ptr); JKRArchive::SDIFileEntry* entry = this->findPtrResource(ptr);
if (entry == NULL) { if (entry == NULL) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} else { }
if (entry->getCompressFlag() == 0) { if (entry->getCompressFlag() == 0) {
return this->getResSize(ptr); return this->getResSize(ptr);
} else { }
u32 expandSize = this->getExpandSize(entry); u32 expandSize = this->getExpandSize(entry);
if (expandSize != 0) { if (expandSize != 0) {
return expandSize; return expandSize;
} }
u8 tmpBuf[0x40]; u8 tmpBuf[0x40];
SArcHeader* buf = (SArcHeader*)ALIGN_PREV((s32)&tmpBuf[0x1F], 0x20); SArcHeader* buf = (SArcHeader*)ALIGN_PREV((s32)&tmpBuf[0x1F], 0x20);
JKRAramToMainRam(entry->data_offset + mBlock->getAddress(), (u8*)buf, 0x20, JKRAramToMainRam(entry->data_offset + mBlock->getAddress(), (u8*)buf, 0x20,
@@ -441,9 +450,6 @@ u32 JKRAramArchive::getExpandedResSize(void const* ptr) const {
((JKRArchive*)this)->setExpandSize(entry, expandSize); ((JKRArchive*)this)->setExpandSize(entry, expandSize);
return expandSize; return expandSize;
} }
}
}
}
/* 802D7B90-802D7BF0 2D24D0 0060+00 1/0 0/0 0/0 .text __dt__7JKRFileFv */ /* 802D7B90-802D7BF0 2D24D0 0060+00 1/0 0/0 0/0 .text __dt__7JKRFileFv */
#pragma push #pragma push
@@ -455,5 +461,3 @@ extern "C" asm void __dt__7JKRFileFv() {
#include "asm/JSystem/JKernel/JKRAramArchive/__dt__7JKRFileFv.s" #include "asm/JSystem/JKernel/JKRAramArchive/__dt__7JKRFileFv.s"
} }
#pragma pop #pragma pop
/* 8039D188-8039D188 0297E8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+1 -6
View File
@@ -6,12 +6,6 @@
#include "JSystem/JKernel/JKRAramBlock.h" #include "JSystem/JKernel/JKRAramBlock.h"
#include "JSystem/JKernel/JKRAramHeap.h" #include "JSystem/JKernel/JKRAramHeap.h"
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Declarations:
//
/* 802D3304-802D3378 2CDC44 0074+00 2/2 1/1 0/0 .text __ct__12JKRAramBlockFUlUlUlUcb */ /* 802D3304-802D3378 2CDC44 0074+00 2/2 1/1 0/0 .text __ct__12JKRAramBlockFUlUlUlUcb */
JKRAramBlock::JKRAramBlock(u32 address, u32 size, u32 freeSize, u8 groupId, bool isTempMemory) JKRAramBlock::JKRAramBlock(u32 address, u32 size, u32 freeSize, u8 groupId, bool isTempMemory)
@@ -27,6 +21,7 @@ JKRAramBlock::JKRAramBlock(u32 address, u32 size, u32 freeSize, u8 groupId, bool
JKRAramBlock::~JKRAramBlock() { JKRAramBlock::~JKRAramBlock() {
JSUList<JKRAramBlock>* list = mBlockLink.getSupervisor(); JSUList<JKRAramBlock>* list = mBlockLink.getSupervisor();
JSULink<JKRAramBlock>* prev = mBlockLink.getPrev(); JSULink<JKRAramBlock>* prev = mBlockLink.getPrev();
if (prev) { if (prev) {
JKRAramBlock* block = prev->getObject(); JKRAramBlock* block = prev->getObject();
block->mFreeSize = mSize + mFreeSize + block->mFreeSize; block->mFreeSize = mSize + mFreeSize + block->mFreeSize;
+1 -34
View File
@@ -5,48 +5,20 @@
#include "JSystem/JKernel/JKRAramHeap.h" #include "JSystem/JKernel/JKRAramHeap.h"
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "dol2asm.h"
#include "global.h"
// //
// Forward References: // Forward References:
// //
extern "C" void __ct__11JKRAramHeapFUlUl();
extern "C" void __dt__11JKRAramHeapFv();
extern "C" void alloc__11JKRAramHeapFUlQ211JKRAramHeap10EAllocMode();
extern "C" void allocFromHead__11JKRAramHeapFUl();
extern "C" void allocFromTail__11JKRAramHeapFUl();
extern "C" void getFreeSize__11JKRAramHeapFv();
extern "C" void getTotalFreeSize__11JKRAramHeapFv();
extern "C" void dump__11JKRAramHeapFv();
extern "C" void __sinit_JKRAramHeap_cpp();
extern "C" void func_802D32B0(void* _this);
extern "C" u8 sAramList__11JKRAramHeap[12]; extern "C" u8 sAramList__11JKRAramHeap[12];
extern "C" void* __vt__11JKRAramHeap; extern "C" void* __vt__11JKRAramHeap;
// //
// External References: // External References:
// //
// TODO: move to JKRHeap
void* operator new(u32 size);
void* operator new(u32 size, int alignment);
void* operator new(u32 size, JKRHeap* heap, int alignment);
extern "C" void findFromRoot__7JKRHeapFPv();
extern "C" void* __nw__FUlP7JKRHeapi();
extern "C" void __dl__FPv(); extern "C" void __dl__FPv();
extern "C" void __ct__11JKRDisposerFv();
extern "C" void __dt__11JKRDisposerFv(); extern "C" void __dt__11JKRDisposerFv();
extern "C" void __ct__12JKRAramBlockFUlUlUlUcb();
extern "C" void allocHead__12JKRAramBlockFUlUcP11JKRAramHeap();
extern "C" void allocTail__12JKRAramBlockFUlUcP11JKRAramHeap();
extern "C" void __dt__10JSUPtrListFv();
extern "C" void initiate__10JSUPtrListFv();
extern "C" void append__10JSUPtrListFP10JSUPtrLink();
extern "C" void __register_global_object();
extern "C" void _savegpr_29(); extern "C" void _savegpr_29();
extern "C" void _restgpr_29(); extern "C" void _restgpr_29();
@@ -54,9 +26,6 @@ extern "C" void _restgpr_29();
// Declarations: // Declarations:
// //
/* 80434300-8043430C 061020 000C+00 1/1 0/0 0/0 .bss @297 */
static u8 lit_297[12];
/* 8043430C-80434318 06102C 000C+00 8/8 0/0 0/0 .bss sAramList__11JKRAramHeap */ /* 8043430C-80434318 06102C 000C+00 8/8 0/0 0/0 .bss sAramList__11JKRAramHeap */
JSUList<JKRAramBlock> JKRAramHeap::sAramList; JSUList<JKRAramBlock> JKRAramHeap::sAramList;
@@ -206,9 +175,7 @@ void JKRAramHeap::dump(void) {
JSUList<JKRAramBlock>* list = &sAramList; JSUList<JKRAramBlock>* list = &sAramList;
JSUListIterator<JKRAramBlock> iterator = list; JSUListIterator<JKRAramBlock> iterator = list;
for (; iterator != list->getEnd(); ++iterator) { for (; iterator != list->getEnd(); ++iterator) {}
// The debug version calls OSReport
}
unlock(); unlock();
} }
+2 -10
View File
@@ -8,13 +8,7 @@
#include "JSystem/JKernel/JKRDecomp.h" #include "JSystem/JKernel/JKRDecomp.h"
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTException.h" #include "JSystem/JUtility/JUTException.h"
#include "dol2asm.h"
#include "dolphin/os/OSCache.h" #include "dolphin/os/OSCache.h"
#include "dolphin/types.h"
//
// Declarations:
//
/* 802D3574-802D35F4 2CDEB4 0080+00 1/1 0/0 0/0 .text /* 802D3574-802D35F4 2CDEB4 0080+00 1/1 0/0 0/0 .text
* prepareCommand__12JKRAramPieceFiUlUlUlP12JKRAramBlockPFUl_v */ * prepareCommand__12JKRAramPieceFiUlUlUlP12JKRAramBlockPFUl_v */
@@ -49,12 +43,12 @@ OSMutex JKRAramPiece::mMutex;
JKRAMCommand* JKRAramPiece::orderAsync(int direction, u32 source, u32 destination, u32 length, JKRAMCommand* JKRAramPiece::orderAsync(int direction, u32 source, u32 destination, u32 length,
JKRAramBlock* block, JKRAMCommand::AsyncCallback callback) { JKRAramBlock* block, JKRAMCommand::AsyncCallback callback) {
lock(); lock();
if (((source & 0x1f) != 0) || ((destination & 0x1f) != 0)) { if ((source & 0x1f) != 0 || (destination & 0x1f) != 0) {
OSReport("direction = %x\n", direction); OSReport("direction = %x\n", direction);
OSReport("source = %x\n", source); OSReport("source = %x\n", source);
OSReport("destination = %x\n", destination); OSReport("destination = %x\n", destination);
OSReport("length = %x\n", length); OSReport("length = %x\n", length);
JUTException::panic_f("JKRAramPiece.cpp", 0x6c, "%s", "illegal address. abort."); JUTException::panic_f(__FILE__, 108, "%s", "illegal address. abort.");
} }
Message* message = new (JKRHeap::getSystemHeap(), -4) Message(); Message* message = new (JKRHeap::getSystemHeap(), -4) Message();
@@ -167,5 +161,3 @@ JKRAMCommand::~JKRAMCommand() {
if (field_0x94) if (field_0x94)
JKRHeap::free(field_0x94, NULL); JKRHeap::free(field_0x94, NULL);
} }
/* 8039D0B8-8039D0B8 029718 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+16 -105
View File
@@ -9,57 +9,6 @@
#include "JSystem/JSupport/JSUFileStream.h" #include "JSystem/JSupport/JSUFileStream.h"
#include "JSystem/JSupport/JSURandomInputStream.h" #include "JSystem/JSupport/JSURandomInputStream.h"
#include "JSystem/JUtility/JUTException.h" #include "JSystem/JUtility/JUTException.h"
#include "dol2asm.h"
#include "global.h"
//
// Forward References:
//
extern "C" void create__13JKRAramStreamFl();
extern "C" void __ct__13JKRAramStreamFl();
extern "C" void __dt__13JKRAramStreamFv();
extern "C" void run__13JKRAramStreamFv();
extern "C" bool readFromAram__13JKRAramStreamFv();
extern "C" void writeToAram__13JKRAramStreamFP20JKRAramStreamCommand();
extern "C" void write_StreamToAram_Async__13JKRAramStreamFP18JSUFileInputStreamUlUlUlPUl();
extern "C" void sync__13JKRAramStreamFP20JKRAramStreamCommandi();
extern "C" void setTransBuffer__13JKRAramStreamFPUcUlP7JKRHeap();
extern "C" void __ct__20JKRAramStreamCommandFv();
extern "C" s32 getAvailable__20JSURandomInputStreamCFv(JSURandomInputStream*);
extern "C" extern char const* const JKRAramStream__stringBase0;
extern "C" u8 sMessageBuffer__13JKRAramStream[16];
extern "C" u8 sMessageQueue__13JKRAramStream[32];
extern "C" u8 sAramStreamObject__13JKRAramStream[4];
extern "C" u8 transBuffer__13JKRAramStream[4];
extern "C" u8 transSize__13JKRAramStream[4];
extern "C" u8 transHeap__13JKRAramStream[4];
//
// External References:
//
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void alloc__7JKRHeapFUli();
extern "C" void free__7JKRHeapFPvP7JKRHeap();
extern "C" void* __nw__FUlP7JKRHeapi();
extern "C" void __dl__FPv();
extern "C" void __ct__9JKRThreadFUlii();
extern "C" void __dt__9JKRThreadFv();
extern "C" void orderSync__12JKRAramPieceFiUlUlUlP12JKRAramBlock();
extern "C" void read__14JSUInputStreamFPvl();
extern "C" void seek__20JSURandomInputStreamFl17JSUStreamSeekFrom();
extern "C" void panic_f__12JUTExceptionFPCciPCce();
extern "C" void _savegpr_24();
extern "C" void _savegpr_26();
extern "C" void _restgpr_24();
extern "C" void _restgpr_26();
extern "C" u8 sSystemHeap__7JKRHeap[4];
extern "C" u8 sCurrentHeap__7JKRHeap[4];
//
// Declarations:
//
/* ############################################################################################## */ /* ############################################################################################## */
/* 80451408-8045140C 000908 0004+00 1/1 0/0 0/0 .sbss sAramStreamObject__13JKRAramStream /* 80451408-8045140C 000908 0004+00 1/1 0/0 0/0 .sbss sAramStreamObject__13JKRAramStream
@@ -97,7 +46,7 @@ JKRAramStream::JKRAramStream(long priority) : JKRThread(0xc00, 0x10, priority) {
JKRAramStream::~JKRAramStream() {} JKRAramStream::~JKRAramStream() {}
/* 802D3C68-802D3CD8 2CE5A8 0070+00 1/0 0/0 0/0 .text run__13JKRAramStreamFv */ /* 802D3C68-802D3CD8 2CE5A8 0070+00 1/0 0/0 0/0 .text run__13JKRAramStreamFv */
void* JKRAramStream::run(void) { void* JKRAramStream::run() {
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, ARRAY_SIZE(sMessageBuffer)); OSInitMessageQueue(&sMessageQueue, sMessageBuffer, ARRAY_SIZE(sMessageBuffer));
for (;;) { for (;;) {
@@ -117,16 +66,13 @@ void* JKRAramStream::run(void) {
} }
/* 802D3CD8-802D3CE0 2CE618 0008+00 1/1 0/0 0/0 .text readFromAram__13JKRAramStreamFv */ /* 802D3CD8-802D3CE0 2CE618 0008+00 1/1 0/0 0/0 .text readFromAram__13JKRAramStreamFv */
s32 JKRAramStream::readFromAram(void) { s32 JKRAramStream::readFromAram() {
return 1; return 1;
} }
/* ############################################################################################## */ /* ############################################################################################## */
/* 8039D120-8039D120 029780 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ /* 8039D120-8039D120 029780 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
// regalloc problems
#ifdef NONMATCHING
s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) { s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
u32 size;
u32 dstSize = command->mSize; u32 dstSize = command->mSize;
u32 offset = command->mOffset; u32 offset = command->mOffset;
u32 writtenLength = 0; u32 writtenLength = 0;
@@ -134,31 +80,24 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
u8* buffer = command->mTransferBuffer; u8* buffer = command->mTransferBuffer;
u32 bufferSize = command->mTransferBufferSize; u32 bufferSize = command->mTransferBufferSize;
JKRHeap* heap = command->mHeap; JKRHeap* heap = command->mHeap;
if (buffer) {
if (bufferSize) {
size = bufferSize;
} else {
size = 0x8000;
}
command->mTransferBufferSize = size; if (buffer) {
bufferSize = (bufferSize) ? bufferSize : 0x8000;
command->mTransferBufferSize = bufferSize;
command->mAllocatedTransferBuffer = false; command->mAllocatedTransferBuffer = false;
} else { } else {
if (bufferSize) { bufferSize = (bufferSize) ? bufferSize : 0x8000;
size = bufferSize;
} else {
size = 0x8000;
}
if (heap) { if (heap) {
buffer = (u8*)JKRAllocFromHeap(heap, size, -0x20); buffer = (u8*)JKRAllocFromHeap(heap, bufferSize, -0x20);
command->mTransferBuffer = buffer; command->mTransferBuffer = buffer;
} else { } else {
buffer = (u8*)JKRAllocFromSysHeap(size, -0x20); buffer = (u8*)JKRAllocFromSysHeap(bufferSize, -0x20);
command->mTransferBuffer = buffer; command->mTransferBuffer = buffer;
} }
command->mTransferBufferSize = size; command->mTransferBufferSize = bufferSize;
command->mAllocatedTransferBuffer = true; command->mAllocatedTransferBuffer = true;
} }
@@ -169,20 +108,15 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
heap->dump(); heap->dump();
} }
JUTException::panic_f("JKRAramStream.cpp", 0xac, "%s", ":::Cannot alloc memory\n"); JUTException::panic_f(__FILE__, 172, "%s", ":::Cannot alloc memory\n");
} }
if (buffer) { if (buffer) {
((JSURandomInputStream*)command->mStream)->seek(offset, JSUStreamSeekFrom_SET); command->mStream->seek(offset, JSUStreamSeekFrom_SET);
while (dstSize != 0) { while (dstSize != 0) {
u32 length; u32 length = (dstSize > bufferSize) ? bufferSize : dstSize;
if (dstSize > size) {
length = size;
} else {
length = dstSize;
}
s32 readLength = ((JSURandomInputStream*)command->mStream)->read(buffer, length); s32 readLength = command->mStream->read(buffer, length);
if (readLength == 0) { if (readLength == 0) {
writtenLength = 0; writtenLength = 0;
break; break;
@@ -190,7 +124,7 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
JKRAramPcs(0, (u32)buffer, destination, length, NULL); JKRAramPcs(0, (u32)buffer, destination, length, NULL);
dstSize -= length; dstSize -= length;
writtenLength += writtenLength; writtenLength += length;
destination += length; destination += length;
if (command->mReturnSize) { if (command->mReturnSize) {
@@ -204,30 +138,9 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
} }
} }
OSSendMessage(&command->mMessageQueue, (OSMessage)writtenLength, OS_MESSAGE_NON_BLOCKING); OSSendMessage(&command->mMessageQueue, (OSMessage)writtenLength, OS_MESSAGE_NOBLOCK);
return writtenLength; return writtenLength;
} }
#else
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039D120 = "JKRAramStream.cpp";
SECTION_DEAD static char const* const stringBase_8039D132 = "%s";
SECTION_DEAD static char const* const stringBase_8039D135 = ":::Cannot alloc memory\n";
/* @stringBase0 padding */
SECTION_DEAD static char const* const pad_8039D14D = "\0\0";
#pragma pop
/* 802D3CE0-802D3ED0 2CE620 01F0+00 1/1 0/0 0/0 .text
* writeToAram__13JKRAramStreamFP20JKRAramStreamCommand */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm s32 JKRAramStream::writeToAram(JKRAramStreamCommand* param_0) {
nofralloc
#include "asm/JSystem/JKernel/JKRAramStream/writeToAram__13JKRAramStreamFP20JKRAramStreamCommand.s"
}
#pragma pop
#endif
/* ############################################################################################## */ /* ############################################################################################## */
/* 8045140C-80451410 00090C 0004+00 2/2 0/0 0/0 .sbss transBuffer__13JKRAramStream */ /* 8045140C-80451410 00090C 0004+00 2/2 0/0 0/0 .sbss transBuffer__13JKRAramStream */
@@ -322,5 +235,3 @@ JKRAramStreamCommand::JKRAramStreamCommand() {
extern "C" s32 getAvailable__20JSURandomInputStreamCFv(JSURandomInputStream* self) { extern "C" s32 getAvailable__20JSURandomInputStreamCFv(JSURandomInputStream* self) {
return self->getLength() - self->getPosition(); return self->getLength() - self->getPosition();
} }
/* 8039D120-8039D120 029780 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+2 -8
View File
@@ -7,12 +7,6 @@
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "MSL_C/MSL_Common/Src/ctype.h" #include "MSL_C/MSL_Common/Src/ctype.h"
#include "MSL_C/MSL_Common/Src/string.h" #include "MSL_C/MSL_Common/Src/string.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Declarations:
//
/* ############################################################################################## */ /* ############################################################################################## */
/* 80451420-80451428 000920 0004+04 1/1 5/5 0/0 .sbss sCurrentDirID__10JKRArchive */ /* 80451420-80451428 000920 0004+04 1/1 5/5 0/0 .sbss sCurrentDirID__10JKRArchive */
@@ -78,7 +72,6 @@ JKRArchive::SDIDirEntry* JKRArchive::findDirectory(const char* name, u32 directo
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index; SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) { for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
// regalloc doesn't like fileEntry->getNameHash()
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) { if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
if (fileEntry->isDirectory()) { if (fileEntry->isDirectory()) {
return findDirectory(name, fileEntry->data_offset); return findDirectory(name, fileEntry->data_offset);
@@ -95,6 +88,7 @@ JKRArchive::SDIFileEntry* JKRArchive::findTypeResource(u32 type, const char* nam
if (type) { if (type) {
CArcName arcName(name); CArcName arcName(name);
SDIDirEntry* dirEntry = findResType(type); SDIDirEntry* dirEntry = findResType(type);
if (dirEntry) { if (dirEntry) {
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index; SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) { for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
@@ -115,8 +109,8 @@ JKRArchive::SDIFileEntry* JKRArchive::findFsResource(const char* name, u32 direc
CArcName arcName(&name, '/'); CArcName arcName(&name, '/');
SDIDirEntry* dirEntry = mNodes + directoryId; SDIDirEntry* dirEntry = mNodes + directoryId;
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index; SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) { for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
// regalloc doesn't like fileEntry->getNameHash()
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) { if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
if (fileEntry->isDirectory()) { if (fileEntry->isDirectory()) {
return findFsResource(name, fileEntry->data_offset); return findFsResource(name, fileEntry->data_offset);
+2 -8
View File
@@ -12,12 +12,6 @@
#include "JSystem/JKernel/JKRFileLoader.h" #include "JSystem/JKernel/JKRFileLoader.h"
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRMemArchive.h" #include "JSystem/JKernel/JKRMemArchive.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Declarations:
//
/* 802D5778-802D57E4 2D00B8 006C+00 2/2 0/0 0/0 .text check_mount_already__10JKRArchiveFlP7JKRHeap /* 802D5778-802D57E4 2D00B8 006C+00 2/2 0/0 0/0 .text check_mount_already__10JKRArchiveFlP7JKRHeap
*/ */
@@ -283,7 +277,7 @@ u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u16 id) {
/* 802D5FB4-802D603C 2D08F4 0088+00 1/0 2/0 0/0 .text removeResourceAll__10JKRArchiveFv /* 802D5FB4-802D603C 2D08F4 0088+00 1/0 2/0 0/0 .text removeResourceAll__10JKRArchiveFv
*/ */
void JKRArchive::removeResourceAll(void) { void JKRArchive::removeResourceAll() {
if (mArcInfoBlock && mMountMode != MOUNT_MEM) { if (mArcInfoBlock && mMountMode != MOUNT_MEM) {
SDIFileEntry* fileEntry = mFiles; SDIFileEntry* fileEntry = mFiles;
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) { for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
@@ -326,7 +320,7 @@ u32 JKRArchive::getResSize(const void* resource) const {
} }
/* 802D610C-802D6150 2D0A4C 0044+00 0/0 1/1 0/0 .text countResource__10JKRArchiveCFv */ /* 802D610C-802D6150 2D0A4C 0044+00 0/0 1/1 0/0 .text countResource__10JKRArchiveCFv */
u32 JKRArchive::countResource(void) const { u32 JKRArchive::countResource() const {
u32 count = 0; u32 count = 0;
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) { for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
if (mFiles[i].isUnknownFlag1()) { if (mFiles[i].isUnknownFlag1()) {
+11 -69
View File
@@ -4,56 +4,6 @@
// //
#include "JSystem/JKernel/JKRAssertHeap.h" #include "JSystem/JKernel/JKRAssertHeap.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Types:
//
//
// Forward References:
//
extern "C" void __ct__13JKRAssertHeapFPvUlP7JKRHeapb();
extern "C" void __dt__13JKRAssertHeapFv();
extern "C" void create__13JKRAssertHeapFP7JKRHeap();
extern "C" void do_destroy__13JKRAssertHeapFv();
extern "C" void getHeapType__13JKRAssertHeapFv();
extern "C" bool check__13JKRAssertHeapFv();
extern "C" bool dump__13JKRAssertHeapFv();
extern "C" bool dump_sort__13JKRAssertHeapFv();
extern "C" bool do_changeGroupID__13JKRAssertHeapFUc();
extern "C" bool do_getCurrentGroupId__13JKRAssertHeapFv();
extern "C" bool do_alloc__13JKRAssertHeapFUli();
extern "C" void do_free__13JKRAssertHeapFPv();
extern "C" void do_freeAll__13JKRAssertHeapFv();
extern "C" void do_freeTail__13JKRAssertHeapFv();
extern "C" void do_fillFreeArea__13JKRAssertHeapFv();
extern "C" bool do_resize__13JKRAssertHeapFPvUl();
extern "C" bool do_getSize__13JKRAssertHeapFPv();
extern "C" bool do_getFreeSize__13JKRAssertHeapFv();
extern "C" bool do_getMaxFreeBlock__13JKRAssertHeapFv();
extern "C" bool do_getTotalFreeSize__13JKRAssertHeapFv();
//
// External References:
//
extern "C" void __ct__7JKRHeapFPvUlP7JKRHeapb();
extern "C" void __dt__7JKRHeapFv();
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void callAllDisposer__7JKRHeapFv();
extern "C" void dispose__7JKRHeapFv();
extern "C" void __dl__FPv();
extern "C" void state_register__7JKRHeapCFPQ27JKRHeap6TStateUl();
extern "C" void state_compare__7JKRHeapCFRCQ27JKRHeap6TStateRCQ27JKRHeap6TState();
extern "C" void state_dump__7JKRHeapCFRCQ27JKRHeap6TState();
extern "C" u8 sRootHeap__7JKRHeap[4];
//
// Declarations:
//
/* 802D12C4-802D1300 2CBC04 003C+00 1/1 0/0 0/0 .text __ct__13JKRAssertHeapFPvUlP7JKRHeapb */ /* 802D12C4-802D1300 2CBC04 003C+00 1/1 0/0 0/0 .text __ct__13JKRAssertHeapFPvUlP7JKRHeapb */
JKRAssertHeap::JKRAssertHeap(void* data, unsigned long size, JKRHeap* parent, bool errorFlag) JKRAssertHeap::JKRAssertHeap(void* data, unsigned long size, JKRHeap* parent, bool errorFlag)
@@ -83,17 +33,17 @@ JKRAssertHeap* JKRAssertHeap::create(JKRHeap* parent) {
} }
/* 802D13D8-802D1408 2CBD18 0030+00 1/0 0/0 0/0 .text do_destroy__13JKRAssertHeapFv */ /* 802D13D8-802D1408 2CBD18 0030+00 1/0 0/0 0/0 .text do_destroy__13JKRAssertHeapFv */
void JKRAssertHeap::do_destroy(void) { void JKRAssertHeap::do_destroy() {
this->~JKRAssertHeap(); this->~JKRAssertHeap();
} }
/* 802D1408-802D1414 2CBD48 000C+00 1/0 0/0 0/0 .text getHeapType__13JKRAssertHeapFv */ /* 802D1408-802D1414 2CBD48 000C+00 1/0 0/0 0/0 .text getHeapType__13JKRAssertHeapFv */
u32 JKRAssertHeap::getHeapType(void) { u32 JKRAssertHeap::getHeapType() {
return 'ASTH'; return 'ASTH';
} }
/* 802D1414-802D141C 2CBD54 0008+00 1/0 0/0 0/0 .text check__13JKRAssertHeapFv */ /* 802D1414-802D141C 2CBD54 0008+00 1/0 0/0 0/0 .text check__13JKRAssertHeapFv */
bool JKRAssertHeap::check(void) { bool JKRAssertHeap::check() {
return true; return true;
} }
@@ -114,7 +64,7 @@ s32 JKRAssertHeap::do_changeGroupID(u8) {
} }
/* 802D1434-802D143C 2CBD74 0008+00 1/0 0/0 0/0 .text do_getCurrentGroupId__13JKRAssertHeapFv */ /* 802D1434-802D143C 2CBD74 0008+00 1/0 0/0 0/0 .text do_getCurrentGroupId__13JKRAssertHeapFv */
u8 JKRAssertHeap::do_getCurrentGroupId(void) { u8 JKRAssertHeap::do_getCurrentGroupId() {
return 0; return 0;
} }
@@ -124,25 +74,17 @@ void* JKRAssertHeap::do_alloc(u32, int) {
} }
/* 802D1444-802D1448 2CBD84 0004+00 1/0 0/0 0/0 .text do_free__13JKRAssertHeapFPv */ /* 802D1444-802D1448 2CBD84 0004+00 1/0 0/0 0/0 .text do_free__13JKRAssertHeapFPv */
void JKRAssertHeap::do_free(void* param_0) { void JKRAssertHeap::do_free(void* param_0) {}
/* empty function */
}
/* 802D1448-802D144C 2CBD88 0004+00 1/0 0/0 0/0 .text do_freeAll__13JKRAssertHeapFv */ /* 802D1448-802D144C 2CBD88 0004+00 1/0 0/0 0/0 .text do_freeAll__13JKRAssertHeapFv */
void JKRAssertHeap::do_freeAll() { void JKRAssertHeap::do_freeAll() {}
/* empty function */
}
/* 802D144C-802D1450 2CBD8C 0004+00 1/0 0/0 0/0 .text do_freeTail__13JKRAssertHeapFv */ /* 802D144C-802D1450 2CBD8C 0004+00 1/0 0/0 0/0 .text do_freeTail__13JKRAssertHeapFv */
void JKRAssertHeap::do_freeTail() { void JKRAssertHeap::do_freeTail() {}
/* empty function */
}
/* 802D1450-802D1454 2CBD90 0004+00 1/0 0/0 0/0 .text do_fillFreeArea__13JKRAssertHeapFv /* 802D1450-802D1454 2CBD90 0004+00 1/0 0/0 0/0 .text do_fillFreeArea__13JKRAssertHeapFv
*/ */
void JKRAssertHeap::do_fillFreeArea() { void JKRAssertHeap::do_fillFreeArea() {}
/* empty function */
}
/* 802D1454-802D145C 2CBD94 0008+00 1/0 0/0 0/0 .text do_resize__13JKRAssertHeapFPvUl */ /* 802D1454-802D145C 2CBD94 0008+00 1/0 0/0 0/0 .text do_resize__13JKRAssertHeapFPvUl */
s32 JKRAssertHeap::do_resize(void*, u32) { s32 JKRAssertHeap::do_resize(void*, u32) {
@@ -156,16 +98,16 @@ s32 JKRAssertHeap::do_getSize(void*) {
/* 802D1464-802D146C 2CBDA4 0008+00 1/0 0/0 0/0 .text do_getFreeSize__13JKRAssertHeapFv /* 802D1464-802D146C 2CBDA4 0008+00 1/0 0/0 0/0 .text do_getFreeSize__13JKRAssertHeapFv
*/ */
s32 JKRAssertHeap::do_getFreeSize(void) { s32 JKRAssertHeap::do_getFreeSize() {
return 0; return 0;
} }
/* 802D146C-802D1474 2CBDAC 0008+00 1/0 0/0 0/0 .text do_getMaxFreeBlock__13JKRAssertHeapFv */ /* 802D146C-802D1474 2CBDAC 0008+00 1/0 0/0 0/0 .text do_getMaxFreeBlock__13JKRAssertHeapFv */
void* JKRAssertHeap::do_getMaxFreeBlock(void) { void* JKRAssertHeap::do_getMaxFreeBlock() {
return NULL; return NULL;
} }
/* 802D1474-802D147C 2CBDB4 0008+00 1/0 0/0 0/0 .text do_getTotalFreeSize__13JKRAssertHeapFv */ /* 802D1474-802D147C 2CBDB4 0008+00 1/0 0/0 0/0 .text do_getTotalFreeSize__13JKRAssertHeapFv */
s32 JKRAssertHeap::do_getTotalFreeSize(void) { s32 JKRAssertHeap::do_getTotalFreeSize() {
return 0; return 0;
} }
+80 -175
View File
@@ -3,122 +3,15 @@
// Translation Unit: JKRCompArchive // Translation Unit: JKRCompArchive
// //
// #include "JSystem/JKernel/JKRCompArchive.h" #include "JSystem/JKernel/JKRCompArchive.h"
#include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JKernel/JKRDvdAramRipper.h"
#include "JSystem/JKernel/JKRDvdArchive.h"
#include "JSystem/JKernel/JKRMemArchive.h"
#include "JSystem/JUtility/JUTException.h"
#include "MSL_C/MSL_Common/Src/string.h"
#include "MSL_C/math.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/types.h"
//
// Types:
//
struct JUTException {
/* 802E21FC */ void panic_f(char const*, int, char const*, ...);
};
struct JSUPtrLink {};
struct JSUPtrList {
/* 802DBFF0 */ void prepend(JSUPtrLink*);
/* 802DC15C */ void remove(JSUPtrLink*);
};
struct JKRMemArchive {
/* 802D6F5C */ void fetchResource_subroutine(u8*, u32, u8*, u32, int);
};
struct JKRHeap {
/* 802CE4D4 */ void alloc(u32, int);
/* 802CE474 */ void alloc(u32, int, JKRHeap*);
/* 802CE500 */ void free(void*, JKRHeap*);
/* 802CE548 */ void free(void*);
/* 802CEB18 */ void copyMemory(void*, void*, u32);
static u8 sSystemHeap[4];
};
struct JKRFileLoader {
/* 802D41D4 */ void unmount();
static u8 sVolumeList[12];
};
struct JKRExpandSwitch {};
struct JKRDvdRipper {
struct EAllocDirection {};
/* 802D9C54 */ void loadToMainRAM(s32, u8*, JKRExpandSwitch, u32, JKRHeap*,
JKRDvdRipper::EAllocDirection, u32, int*, u32*);
};
struct JKRDvdFile {
/* 802D96A0 */ JKRDvdFile(s32);
};
struct JKRDvdArchive {
/* 802D8474 */ void fetchResource_subroutine(s32, u32, u32, JKRHeap*, int, int, u8**);
/* 802D826C */ void fetchResource_subroutine(s32, u32, u32, u8*, u32, int, int);
};
struct JKRDvdAramRipper {
/* 802DA874 */ void loadToAram(s32, u32, JKRExpandSwitch, u32, u32, u32*);
};
struct JKRDecomp {
/* 802DB988 */ void orderSync(u8*, u8*, u32, u32);
};
struct JKRArchive {
struct EMountDirection {};
struct SDIFileEntry {};
struct EMountMode {};
/* 802D5A38 */ void becomeCurrent(char const*);
/* 802D5C64 */ void getResource(u32, char const*);
/* 802D5BE8 */ void getResource(char const*);
/* 802D5D8C */ void readResource(void*, u32, u32, char const*);
/* 802D5E30 */ void readResource(void*, u32, char const*);
/* 802D609C */ void detachResource(void*);
/* 802D60D8 */ void getResSize(void const*) const;
/* 802D6150 */ void countFile(char const*) const;
/* 802D61B0 */ void getFirstFile(char const*) const;
/* 802D6294 */ JKRArchive(s32, JKRArchive::EMountMode);
/* 802D6334 */ ~JKRArchive();
/* 802D6734 */ void findPtrResource(void const*) const;
/* 802D693C */ void setExpandSize(JKRArchive::SDIFileEntry*, u32);
/* 802D6978 */ void getExpandSize(JKRArchive::SDIFileEntry*) const;
};
struct JKRCompArchive {
/* 802D87D4 */ JKRCompArchive(s32, JKRArchive::EMountDirection);
/* 802D887C */ ~JKRCompArchive();
/* 802D89BC */ void open(s32);
/* 802D8F40 */ void fetchResource(JKRArchive::SDIFileEntry*, u32*);
/* 802D90C0 */ void fetchResource(void*, u32, JKRArchive::SDIFileEntry*, u32*);
/* 802D9260 */ void removeResourceAll();
/* 802D92F4 */ void removeResource(void*);
/* 802D9360 */ void getExpandedResSize(void const*) const;
};
struct JKRAramHeap {
struct EAllocMode {};
/* 802D2FBC */ void alloc(u32, JKRAramHeap::EAllocMode);
};
struct JKRAramArchive {
/* 802D7858 */ void fetchResource_subroutine(u32, u32, u8*, u32, int);
/* 802D7914 */ void fetchResource_subroutine(u32, u32, JKRHeap*, int, u8**);
};
struct JKRAram {
/* 802D233C */ void mainRamToAram(u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
/* 802D25B4 */ void aramToMainRam(u32, u8*, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
static u8 sAramObject[4];
};
// //
// Forward References: // Forward References:
@@ -138,7 +31,6 @@ extern "C" extern char const* const JKRCompArchive__stringBase0;
// External References: // External References:
// //
SECTION_INIT void memset();
extern "C" void alloc__7JKRHeapFUliP7JKRHeap(); extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void alloc__7JKRHeapFUli(); extern "C" void alloc__7JKRHeapFUli();
extern "C" void free__7JKRHeapFPvP7JKRHeap(); extern "C" void free__7JKRHeapFPvP7JKRHeap();
@@ -177,7 +69,6 @@ extern "C" void orderSync__9JKRDecompFPUcPUcUlUl();
extern "C" void prepend__10JSUPtrListFP10JSUPtrLink(); extern "C" void prepend__10JSUPtrListFP10JSUPtrLink();
extern "C" void remove__10JSUPtrListFP10JSUPtrLink(); extern "C" void remove__10JSUPtrListFP10JSUPtrLink();
extern "C" void panic_f__12JUTExceptionFPCciPCce(); extern "C" void panic_f__12JUTExceptionFPCciPCce();
extern "C" void DCInvalidateRange();
extern "C" void _savegpr_25(); extern "C" void _savegpr_25();
extern "C" void _savegpr_26(); extern "C" void _savegpr_26();
extern "C" void _savegpr_28(); extern "C" void _savegpr_28();
@@ -186,7 +77,6 @@ extern "C" void _restgpr_25();
extern "C" void _restgpr_26(); extern "C" void _restgpr_26();
extern "C" void _restgpr_28(); extern "C" void _restgpr_28();
extern "C" void _restgpr_29(); extern "C" void _restgpr_29();
extern "C" void abs();
extern "C" u8 sVolumeList__13JKRFileLoader[12]; extern "C" u8 sVolumeList__13JKRFileLoader[12];
extern "C" u8 sSystemHeap__7JKRHeap[4]; extern "C" u8 sSystemHeap__7JKRHeap[4];
extern "C" u8 sAramObject__7JKRAram[4]; extern "C" u8 sAramObject__7JKRAram[4];
@@ -195,57 +85,60 @@ extern "C" u8 sAramObject__7JKRAram[4];
// Declarations: // Declarations:
// //
/* ############################################################################################## */
/* 803CC3E8-803CC438 029508 0050+00 2/2 0/0 0/0 .data __vt__14JKRCompArchive */
SECTION_DATA extern void* __vt__14JKRCompArchive[20] = {
(void*)NULL /* RTTI */,
(void*)NULL,
(void*)__dt__14JKRCompArchiveFv,
(void*)unmount__13JKRFileLoaderFv,
(void*)becomeCurrent__10JKRArchiveFPCc,
(void*)getResource__10JKRArchiveFPCc,
(void*)getResource__10JKRArchiveFUlPCc,
(void*)readResource__10JKRArchiveFPvUlPCc,
(void*)readResource__10JKRArchiveFPvUlUlPCc,
(void*)removeResourceAll__14JKRCompArchiveFv,
(void*)removeResource__14JKRCompArchiveFPv,
(void*)detachResource__10JKRArchiveFPv,
(void*)getResSize__10JKRArchiveCFPCv,
(void*)countFile__10JKRArchiveCFPCc,
(void*)getFirstFile__10JKRArchiveCFPCc,
(void*)getExpandedResSize__14JKRCompArchiveCFPCv,
(void*)fetchResource__14JKRCompArchiveFPQ210JKRArchive12SDIFileEntryPUl,
(void*)fetchResource__14JKRCompArchiveFPvUlPQ210JKRArchive12SDIFileEntryPUl,
(void*)setExpandSize__10JKRArchiveFPQ210JKRArchive12SDIFileEntryUl,
(void*)getExpandSize__10JKRArchiveCFPQ210JKRArchive12SDIFileEntry,
};
/* 802D87D4-802D887C 2D3114 00A8+00 0/0 1/1 0/0 .text /* 802D87D4-802D887C 2D3114 00A8+00 0/0 1/1 0/0 .text
* __ct__14JKRCompArchiveFlQ210JKRArchive15EMountDirection */ * __ct__14JKRCompArchiveFlQ210JKRArchive15EMountDirection */
#pragma push JKRCompArchive::JKRCompArchive(s32 entryNum, JKRArchive::EMountDirection eMountDirection)
#pragma optimization_level 0 : JKRArchive(entryNum, MOUNT_COMP) {
#pragma optimizewithasm off mMountDirection = eMountDirection;
asm JKRCompArchive::JKRCompArchive(s32 param_0, JKRArchive::EMountDirection param_1) {
nofralloc if (!open(entryNum)) {
#include "asm/JSystem/JKernel/JKRCompArchive/__ct__14JKRCompArchiveFlQ210JKRArchive15EMountDirection.s" return;
}
mVolumeType = 'RARC';
mVolumeName = &mStringTable[mNodes->name_offset];
sVolumeList.prepend(&mFileLoaderLink);
mIsMounted = true;
} }
#pragma pop
/* 802D887C-802D89BC 2D31BC 0140+00 1/0 0/0 0/0 .text __dt__14JKRCompArchiveFv */ /* 802D887C-802D89BC 2D31BC 0140+00 1/0 0/0 0/0 .text __dt__14JKRCompArchiveFv */
#pragma push JKRCompArchive::~JKRCompArchive() {
#pragma optimization_level 0 if (mArcInfoBlock != NULL) {
#pragma optimizewithasm off SDIFileEntry* file = mFiles;
asm JKRCompArchive::~JKRCompArchive() { for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
nofralloc if (!((file->type_flags_and_name_offset >> 0x18) & 0x10) && file->data != NULL) {
#include "asm/JSystem/JKernel/JKRCompArchive/__dt__14JKRCompArchiveFv.s" JKRFreeToHeap(mHeap, file->data);
}
file++;
}
JKRFreeToHeap(mHeap, mArcInfoBlock);
mArcInfoBlock = NULL;
}
if (field_0x68 != NULL) {
delete field_0x68;
}
if (mExpandedSize != NULL) {
i_JKRFree(mExpandedSize);
mExpandedSize = NULL;
}
if (field_0x70 != NULL) {
delete field_0x70;
}
sVolumeList.remove(&mFileLoaderLink);
mIsMounted = false;
} }
#pragma pop
/* 802D89BC-802D8F40 2D32FC 0584+00 1/1 0/0 0/0 .text open__14JKRCompArchiveFl */ /* 802D89BC-802D8F40 2D32FC 0584+00 1/1 0/0 0/0 .text open__14JKRCompArchiveFl */
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void JKRCompArchive::open(s32 param_0) { asm bool JKRCompArchive::open(s32 param_0) {
nofralloc nofralloc
#include "asm/JSystem/JKernel/JKRCompArchive/open__14JKRCompArchiveFl.s" #include "asm/JSystem/JKernel/JKRCompArchive/open__14JKRCompArchiveFl.s"
} }
@@ -256,7 +149,7 @@ asm void JKRCompArchive::open(s32 param_0) {
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void JKRCompArchive::fetchResource(JKRArchive::SDIFileEntry* param_0, u32* param_1) { asm void* JKRCompArchive::fetchResource(JKRArchive::SDIFileEntry* param_0, u32* param_1) {
nofralloc nofralloc
#include "asm/JSystem/JKernel/JKRCompArchive/fetchResource__14JKRCompArchiveFPQ210JKRArchive12SDIFileEntryPUl.s" #include "asm/JSystem/JKernel/JKRCompArchive/fetchResource__14JKRCompArchiveFPQ210JKRArchive12SDIFileEntryPUl.s"
} }
@@ -276,7 +169,7 @@ SECTION_DEAD static char const* const stringBase_8039D236 = "illegal archive.";
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void JKRCompArchive::fetchResource(void* param_0, u32 param_1, asm void* JKRCompArchive::fetchResource(void* param_0, u32 param_1,
JKRArchive::SDIFileEntry* param_2, u32* param_3) { JKRArchive::SDIFileEntry* param_2, u32* param_3) {
nofralloc nofralloc
#include "asm/JSystem/JKernel/JKRCompArchive/fetchResource__14JKRCompArchiveFPvUlPQ210JKRArchive12SDIFileEntryPUl.s" #include "asm/JSystem/JKernel/JKRCompArchive/fetchResource__14JKRCompArchiveFPvUlPQ210JKRArchive12SDIFileEntryPUl.s"
@@ -284,25 +177,37 @@ asm void JKRCompArchive::fetchResource(void* param_0, u32 param_1,
#pragma pop #pragma pop
/* 802D9260-802D92F4 2D3BA0 0094+00 1/0 0/0 0/0 .text removeResourceAll__14JKRCompArchiveFv */ /* 802D9260-802D92F4 2D3BA0 0094+00 1/0 0/0 0/0 .text removeResourceAll__14JKRCompArchiveFv */
#pragma push void JKRCompArchive::removeResourceAll() {
#pragma optimization_level 0 if (mArcInfoBlock != NULL && mMountMode != MOUNT_MEM) {
#pragma optimizewithasm off SDIFileEntry* fileEntry = mFiles;
asm void JKRCompArchive::removeResourceAll() { for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
nofralloc int tmp = fileEntry->type_flags_and_name_offset >> 0x18;
#include "asm/JSystem/JKernel/JKRCompArchive/removeResourceAll__14JKRCompArchiveFv.s"
if (fileEntry->data != NULL) {
if (!(tmp & 0x10)) {
JKRFreeToHeap(mHeap, fileEntry->data);
}
fileEntry->data = NULL;
}
}
}
} }
#pragma pop
/* 802D92F4-802D9360 2D3C34 006C+00 1/0 0/0 0/0 .text removeResource__14JKRCompArchiveFPv /* 802D92F4-802D9360 2D3C34 006C+00 1/0 0/0 0/0 .text removeResource__14JKRCompArchiveFPv
*/ */
#pragma push bool JKRCompArchive::removeResource(void* resource) {
#pragma optimization_level 0 SDIFileEntry* fileEntry = findPtrResource(resource);
#pragma optimizewithasm off if (!fileEntry)
asm void JKRCompArchive::removeResource(void* param_0) { return false;
nofralloc
#include "asm/JSystem/JKernel/JKRCompArchive/removeResource__14JKRCompArchiveFPv.s" if (!((fileEntry->type_flags_and_name_offset >> 0x18) & 0x10)) {
JKRFreeToHeap(mHeap, resource);
}
fileEntry->data = NULL;
return true;
} }
#pragma pop
/* ############################################################################################## */ /* ############################################################################################## */
/* 8039D220-8039D220 029880 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ /* 8039D220-8039D220 029880 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
@@ -317,7 +222,7 @@ SECTION_DEAD static char const* const pad_8039D259 = "\0\0\0\0\0\0";
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void JKRCompArchive::getExpandedResSize(void const* param_0) const { asm u32 JKRCompArchive::getExpandedResSize(void const* param_0) const {
nofralloc nofralloc
#include "asm/JSystem/JKernel/JKRCompArchive/getExpandedResSize__14JKRCompArchiveCFPCv.s" #include "asm/JSystem/JKernel/JKRCompArchive/getExpandedResSize__14JKRCompArchiveCFPCv.s"
} }
+44 -51
View File
@@ -5,10 +5,9 @@
#include "JSystem/JKernel/JKRDecomp.h" #include "JSystem/JKernel/JKRDecomp.h"
#include "JSystem/JKernel/JKRAramPiece.h" #include "JSystem/JKernel/JKRAramPiece.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRArchive.h" #include "JSystem/JKernel/JKRArchive.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/types.h"
// //
// Forward References: // Forward References:
@@ -80,7 +79,7 @@ JKRDecomp::JKRDecomp(long priority) : JKRThread(0x800, 0x10, priority) {
JKRDecomp::~JKRDecomp() {} JKRDecomp::~JKRDecomp() {}
/* 802DB790-802DB858 2D60D0 00C8+00 1/0 0/0 0/0 .text run__9JKRDecompFv */ /* 802DB790-802DB858 2D60D0 00C8+00 1/0 0/0 0/0 .text run__9JKRDecompFv */
void* JKRDecomp::run(void) { void* JKRDecomp::run() {
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8); OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8);
for (;;) { for (;;) {
OSMessage message; OSMessage message;
@@ -172,26 +171,23 @@ void JKRDecomp::decode(u8* srcBuffer, u8* dstBuffer, u32 srcLength, u32 dstLengt
} }
/* 802DBA58-802DBC14 2D6398 01BC+00 1/1 0/0 0/0 .text decodeSZP__9JKRDecompFPUcPUcUlUl */ /* 802DBA58-802DBC14 2D6398 01BC+00 1/1 0/0 0/0 .text decodeSZP__9JKRDecompFPUcPUcUlUl */
// All instructions match. Wrong registers are used. // 2 extra mr instructions
#ifdef NONMATCHING #ifdef NONMATCHING
void JKRDecomp::decodeSZP(u8* src, u8* dst, u32 srcLength, u32 dstLength) { void JKRDecomp::decodeSZP(u8* src, u8* dst, u32 srcLength, u32 dstLength) {
u32 decodedSize; // s32 decodedSize;
s32 srcChunkOffset; s32 srcChunkOffset;
s32 count; u32 count;
s32 dstOffset; s32 dstOffset;
u32 length; u32 length;
u32 counter; s32 linkInfo;
u32 srcDataOffset;
u32 linkTableOffset;
s32 offset; s32 offset;
s32 i; s32 i;
s32 decodedSize = read_big_endian_u32(src + 4);
decodedSize = read_big_endian_u32(src + 4); s32 linkTableOffset = read_big_endian_u32(src + 8);
linkTableOffset = read_big_endian_u32(src + 8); s32 srcDataOffset = read_big_endian_u32(src + 12);
srcDataOffset = read_big_endian_u32(src + 12);
dstOffset = 0; dstOffset = 0;
counter = 0; u32 counter = 0;
srcChunkOffset = 16; srcChunkOffset = 16;
u32 chunkBits; u32 chunkBits;
@@ -204,55 +200,50 @@ void JKRDecomp::decodeSZP(u8* src, u8* dst, u32 srcLength, u32 dstLength) {
do { do {
if (counter == 0) { if (counter == 0) {
chunkBits = read_big_endian_u32(src + srcChunkOffset); chunkBits = read_big_endian_u32(src + srcChunkOffset);
srcChunkOffset += 4; srcChunkOffset += sizeof(u32);
counter = 32; counter = sizeof(u32) * 8;
} }
if (chunkBits & 0x80000000) { if (chunkBits & 0x80000000) {
if (dstLength == 0) { if (dstLength == 0) {
dst[dstOffset] = src[srcDataOffset]; dst[dstOffset] = src[srcDataOffset];
length--; length--;
if (length == 0) { if (length == 0)
return; return;
}
} else { } else {
dstLength--; dstLength--;
} }
dstOffset++; dstOffset++;
srcDataOffset++; srcDataOffset++;
} else { } else {
u32 linkInfo = read_big_endian_u16(src + linkTableOffset); linkInfo = src[linkTableOffset] << 8 | src[linkTableOffset + 1];
linkTableOffset += 2; linkTableOffset += sizeof(u16);
offset = dstOffset - (linkInfo & 0xFFF); offset = dstOffset - (linkInfo & 0xFFF);
count = ((s32)linkInfo) >> 12; count = (linkInfo >> 12);
if (count == 0) { if (count == 0) {
count = (u32)src[srcDataOffset] + 0x12; count = (u32)src[srcDataOffset] + 0x12;
srcDataOffset++; srcDataOffset++;
} else { } else
count += 2; count += 2;
}
if (count > decodedSize - dstOffset) { if ((s32)count > decodedSize - dstOffset)
count = decodedSize - dstOffset; count = decodedSize - dstOffset;
}
for (i = 0; i < count; i++, dstOffset++, offset++) { for (i = 0; i < (s32)count; i++, dstOffset++, offset++) {
if (dstLength == 0) { if (dstLength == 0) {
dst[dstOffset] = dst[offset - 1]; dst[dstOffset] = dst[offset - 1];
length--; length--;
if (length == 0) { if (length == 0)
return; return;
} } else
} else {
dstLength--; dstLength--;
} }
} }
}
chunkBits <<= 1; chunkBits <<= 1;
counter--; counter--;
} while ((s32)dstLength < decodedSize); } while (dstOffset < decodedSize);
} }
#else #else
#pragma push #pragma push
@@ -267,19 +258,20 @@ asm void JKRDecomp::decodeSZP(u8* param_0, u8* param_1, u32 param_2, u32 param_3
/* 802DBC14-802DBCF8 2D6554 00E4+00 1/1 0/0 0/0 .text decodeSZS__9JKRDecompFPUcPUcUlUl */ /* 802DBC14-802DBCF8 2D6554 00E4+00 1/1 0/0 0/0 .text decodeSZS__9JKRDecompFPUcPUcUlUl */
#ifdef NONMATCHING #ifdef NONMATCHING
void JKRDecomp::decodeSZS(u8* src_buffer, u8* dst_buffer, u32 param_3, u32 param_4) { void JKRDecomp::decodeSZS(u8* src_buffer, u8* dst_buffer, u32 srcSize, u32 dstSize) {
int copyByteCount;
u8* decompEnd; u8* decompEnd;
u8* copyStart; u8* copyStart;
int chunkBitsLeft = 0; s32 copyByteCount;
int chunkBits; s32 chunkBitsLeft = 0;
decompEnd = dst_buffer + *(int*)(src_buffer + 4) - param_4; s32 chunkBits;
if (param_3 == 0) {
decompEnd = dst_buffer + *(int*)(src_buffer + 4) - dstSize;
if (srcSize == 0)
return; return;
} if (dstSize > *(u32*)src_buffer)
if (param_4 > *(u32*)src_buffer) {
return; return;
}
u8* curSrcPos = src_buffer + 0x10; u8* curSrcPos = src_buffer + 0x10;
do { do {
if (chunkBitsLeft == 0) { if (chunkBitsLeft == 0) {
@@ -288,19 +280,18 @@ void JKRDecomp::decodeSZS(u8* src_buffer, u8* dst_buffer, u32 param_3, u32 param
curSrcPos++; curSrcPos++;
} }
if ((chunkBits & 0x80) != 0) { if ((chunkBits & 0x80) != 0) {
if (param_4 == 0) { if (dstSize == 0) {
*dst_buffer = *curSrcPos; *dst_buffer = *curSrcPos;
param_3--; srcSize--;
dst_buffer++; dst_buffer++;
if (param_3 == 0) { if (srcSize == 0)
return; return;
}
} else { } else {
param_4--; dstSize--;
} }
curSrcPos++; curSrcPos++;
} else { } else {
int curVal = *curSrcPos; u8 curVal = *curSrcPos;
// load is inversed // load is inversed
copyStart = dst_buffer - ((curVal & 0xF) << 8 | curSrcPos[1]); copyStart = dst_buffer - ((curVal & 0xF) << 8 | curSrcPos[1]);
// copyByteCount = ; // copyByteCount = ;
@@ -313,15 +304,14 @@ void JKRDecomp::decodeSZS(u8* src_buffer, u8* dst_buffer, u32 param_3, u32 param
copyByteCount = (curVal >> 4) + 2; copyByteCount = (curVal >> 4) + 2;
} }
do { do {
if (param_4 == 0) { if (dstSize == 0) {
*dst_buffer = *(copyStart - 1); *dst_buffer = *(copyStart - 1);
param_3--; srcSize--;
dst_buffer++; dst_buffer++;
if (param_3 == 0) { if (srcSize == 0)
return; return;
}
} else { } else {
param_4--; dstSize--;
} }
copyByteCount--; copyByteCount--;
copyStart++; copyStart++;
@@ -348,13 +338,16 @@ JKRCompression JKRDecomp::checkCompressed(u8* src) {
if (src[2] == 'y') { if (src[2] == 'y') {
return COMPRESSION_YAY0; return COMPRESSION_YAY0;
} }
if (src[2] == 'z') { if (src[2] == 'z') {
return COMPRESSION_YAZ0; return COMPRESSION_YAZ0;
} }
} }
if ((src[0] == 'A') && (src[1] == 'S') && (src[2] == 'R')) { if ((src[0] == 'A') && (src[1] == 'S') && (src[2] == 'R')) {
return COMPRESSION_ASR; return COMPRESSION_ASR;
} }
return COMPRESSION_NONE; return COMPRESSION_NONE;
} }
-6
View File
@@ -5,12 +5,6 @@
#include "JSystem/JKernel/JKRDisposer.h" #include "JSystem/JKernel/JKRDisposer.h"
#include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JKernel/JKRHeap.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Declarations:
//
/* 802D147C-802D14E4 2CBDBC 0068+00 0/0 12/12 0/0 .text __ct__11JKRDisposerFv */ /* 802D147C-802D14E4 2CBDBC 0068+00 0/0 12/12 0/0 .text __ct__11JKRDisposerFv */
JKRDisposer::JKRDisposer() : mLink(this) { JKRDisposer::JKRDisposer() : mLink(this) {
+30 -15
View File
@@ -7,10 +7,10 @@
#include "JSystem/JKernel/JKRAram.h" #include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JKernel/JKRAramStream.h" #include "JSystem/JKernel/JKRAramStream.h"
#include "JSystem/JKernel/JKRDvdFile.h" #include "JSystem/JKernel/JKRDvdFile.h"
// #include "JSystem/JSupport/JSUFileStream.h" #include "JSystem/JSupport/JSUFileStream.h"
#include "JSystem/JSupport/JSUList.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/os/OSCache.h" #include "dolphin/os/OSCache.h"
#include "dolphin/types.h"
#include "dolphin/vi/vi.h" #include "dolphin/vi/vi.h"
#include "global.h" #include "global.h"
@@ -23,16 +23,6 @@ struct JSUList__template10 {
/* 802DB62C */ void func_802DB62C(void* _this); /* 802DB62C */ void func_802DB62C(void* _this);
}; };
struct JSUInputStream {
/* 802DC23C */ ~JSUInputStream();
};
struct JSUFileInputStream {
/* 802DADD8 */ ~JSUFileInputStream();
/* 802DC638 */ JSUFileInputStream(JKRFile*);
int padding[4];
};
struct JKRAramPiece { struct JKRAramPiece {
/* 802D3838 */ void orderSync(int, u32, u32, u32, JKRAramBlock*); /* 802D3838 */ void orderSync(int, u32, u32, u32, JKRAramBlock*);
}; };
@@ -120,14 +110,17 @@ JKRAramBlock* JKRDvdAramRipper::loadToAram(JKRDvdFile* dvdFile, u32 param_1,
JKRADCommand* command = JKRADCommand* command =
loadToAram_Async(dvdFile, param_1, param_2, NULL, param_3, param_4, param_5); loadToAram_Async(dvdFile, param_1, param_2, NULL, param_3, param_4, param_5);
syncAram(command, 0); syncAram(command, 0);
if (command->field_0x48 < 0) { if (command->field_0x48 < 0) {
delete command; delete command;
return NULL; return NULL;
} }
if (param_1) { if (param_1) {
delete command; delete command;
return (JKRAramBlock*)-1; return (JKRAramBlock*)-1;
} }
JKRAramBlock* result = command->mBlock; JKRAramBlock* result = command->mBlock;
delete command; delete command;
return result; return result;
@@ -147,10 +140,12 @@ JKRADCommand* JKRDvdAramRipper::loadToAram_Async(JKRDvdFile* dvdFile, u32 param_
command->field_0x3c = param_4; command->field_0x3c = param_4;
command->field_0x40 = param_5; command->field_0x40 = param_5;
command->field_0x44 = param_6; command->field_0x44 = param_6;
if (!callCommand_Async(command)) { if (!callCommand_Async(command)) {
delete command; delete command;
return NULL; return NULL;
} }
return command; return command;
} }
@@ -176,6 +171,7 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
if (command->field_0x44) { if (command->field_0x44) {
*command->field_0x44 = 0; *command->field_0x44 = 0;
} }
if (dvdFile->field_0x50) { if (dvdFile->field_0x50) {
bVar1 = false; bVar1 = false;
} else { } else {
@@ -194,17 +190,21 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
if (DVDReadPrio(&dvdFile->mFileInfo, bufPtr, 0x20, 0, 2) >= 0) { if (DVDReadPrio(&dvdFile->mFileInfo, bufPtr, 0x20, 0, 2) >= 0) {
break; break;
} }
if (data_804508D0 == 0) { if (data_804508D0 == 0) {
delete stream; delete stream;
return NULL; return NULL;
} }
VIWaitForRetrace(); VIWaitForRetrace();
} }
DCInvalidateRange(bufPtr, 0x20); DCInvalidateRange(bufPtr, 0x20);
JKRCompression tmpCompression = JKRDecomp::checkCompressed(bufPtr); JKRCompression tmpCompression = JKRDecomp::checkCompressed(bufPtr);
if (tmpCompression == 3) { if (tmpCompression == 3) {
tmpCompression = 0; tmpCompression = 0;
} }
compression = tmpCompression; compression = tmpCompression;
uncompressedSize = uncompressedSize =
bufPtr[4] << 0x18 | bufPtr[5] << 0x10 | bufPtr[6] << 0x08 | bufPtr[7]; bufPtr[4] << 0x18 | bufPtr[5] << 0x10 | bufPtr[6] << 0x08 | bufPtr[7];
@@ -212,9 +212,11 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
uncompressedSize = command->field_0x40; uncompressedSize = command->field_0x40;
} }
} }
if (compression == 0) { if (compression == 0) {
command->field_0x34 = 0; command->field_0x34 = 0;
} }
if (command->field_0x34 == 1) { if (command->field_0x34 == 1) {
if (command->field_0x2c == 0 && command->mBlock == NULL) { if (command->field_0x2c == 0 && command->mBlock == NULL) {
command->mBlock = command->mBlock =
@@ -224,9 +226,11 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
} }
dvdFile->mBlock = command->mBlock; dvdFile->mBlock = command->mBlock;
} }
if (command->mBlock) { if (command->mBlock) {
command->field_0x2c = command->mBlock->mAddress; command->field_0x2c = command->mBlock->mAddress;
} }
if (command->field_0x2c == 0) { if (command->field_0x2c == 0) {
dvdFile->field_0x50 = NULL; dvdFile->field_0x50 = NULL;
return NULL; return NULL;
@@ -235,14 +239,17 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
if (command->field_0x2c == 0 && !command->mBlock) { if (command->field_0x2c == 0 && !command->mBlock) {
command->mBlock = JKRAram::getAramHeap()->alloc(fileSize, JKRAramHeap::HEAD); command->mBlock = JKRAram::getAramHeap()->alloc(fileSize, JKRAramHeap::HEAD);
} }
if (command->mBlock) { if (command->mBlock) {
command->field_0x2c = command->mBlock->mAddress; command->field_0x2c = command->mBlock->mAddress;
} }
if (command->field_0x2c == 0) { if (command->field_0x2c == 0) {
dvdFile->field_0x50 = NULL; dvdFile->field_0x50 = NULL;
return NULL; return NULL;
} }
} }
if (compression == 0) { if (compression == 0) {
command->mStreamCommand = JKRAramStream::write_StreamToAram_Async( command->mStreamCommand = JKRAramStream::write_StreamToAram_Async(
stream, command->field_0x2c, fileSize - command->field_0x3c, command->field_0x3c, stream, command->field_0x2c, fileSize - command->field_0x3c, command->field_0x3c,
@@ -257,12 +264,14 @@ JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
uncompressedSize, command->field_0x3c, 0, uncompressedSize, command->field_0x3c, 0,
command->field_0x44); command->field_0x44);
} }
if (!command->field_0x38) { if (!command->field_0x38) {
(*((JSUList<JKRADCommand>*)&sDvdAramAsyncList)).append(&command->mLink); (*((JSUList<JKRADCommand>*)&sDvdAramAsyncList)).append(&command->mLink);
} else { } else {
command->field_0x38((u32)command); command->field_0x38((u32)command);
} }
} }
OSUnlockMutex(&dvdFile->mMutex2); OSUnlockMutex(&dvdFile->mMutex2);
return bVar1 == true ? command : NULL; return bVar1 == true ? command : NULL;
} }
@@ -281,7 +290,8 @@ asm JKRADCommand* JKRDvdAramRipper::callCommand_Async(JKRADCommand* command) {
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm JSUFileInputStream::~JSUFileInputStream() { // asm JSUFileInputStream::~JSUFileInputStream() {
extern "C" asm void __dt__18JSUFileInputStreamFv() {
nofralloc nofralloc
#include "asm/JSystem/JKernel/JKRDvdAramRipper/__dt__18JSUFileInputStreamFv.s" #include "asm/JSystem/JKernel/JKRDvdAramRipper/__dt__18JSUFileInputStreamFv.s"
} }
@@ -289,22 +299,27 @@ asm JSUFileInputStream::~JSUFileInputStream() {
/* 802DAE48-802DAF1C 2D5788 00D4+00 1/1 0/0 0/0 .text /* 802DAE48-802DAF1C 2D5788 00D4+00 1/1 0/0 0/0 .text
* syncAram__16JKRDvdAramRipperFP12JKRADCommandi */ * syncAram__16JKRDvdAramRipperFP12JKRADCommandi */
// should match when other functions using sDvdAramAsyncList are decompiled
#ifdef NONMATCHING #ifdef NONMATCHING
bool JKRDvdAramRipper::syncAram(JKRADCommand* command, int param_1) { bool JKRDvdAramRipper::syncAram(JKRADCommand* command, int param_1) {
JKRDvdFile* dvdFile = command->mDvdFile; JKRDvdFile* dvdFile = command->mDvdFile;
OSLockMutex(&dvdFile->mMutex2); OSLockMutex(&dvdFile->mMutex2);
if (command->mStreamCommand) { if (command->mStreamCommand) {
JKRAramStreamCommand* var1 = JKRAramStream::sync(command->mStreamCommand, param_1); JKRAramStreamCommand* var1 = JKRAramStream::sync(command->mStreamCommand, param_1);
command->field_0x48 = -(var1 == NULL); command->field_0x48 = -(var1 == NULL);
if (param_1 != 0 && var1 == NULL) { if (param_1 != 0 && var1 == NULL) {
OSUnlockMutex(&dvdFile->mMutex2); OSUnlockMutex(&dvdFile->mMutex2);
return false; return false;
} }
} }
(*((JSUList<JKRADCommand>*)&sDvdAramAsyncList)).remove(&command->mLink); (*((JSUList<JKRADCommand>*)&sDvdAramAsyncList)).remove(&command->mLink);
if (command->mStreamCommand) { if (command->mStreamCommand) {
delete command->mStreamCommand; delete command->mStreamCommand;
} }
delete dvdFile->mFileStream; delete dvdFile->mFileStream;
dvdFile->field_0x50 = NULL; dvdFile->field_0x50 = NULL;
OSUnlockMutex(&dvdFile->mMutex2); OSUnlockMutex(&dvdFile->mMutex2);
@@ -405,6 +420,7 @@ int JKRDecompressFromDVDToAram(JKRDvdFile* dvdFile, u32 param_1, u32 fileSize, u
OSInitMutex(&decompMutex); OSInitMutex(&decompMutex);
data_804514A4 = true; data_804514A4 = true;
} }
OSRestoreInterrupts(level); OSRestoreInterrupts(level);
OSLockMutex(&decompMutex); OSLockMutex(&decompMutex);
u32 bufferSize = JKRDvdAramRipper::sSZSBufferSize; u32 bufferSize = JKRDvdAramRipper::sSZSBufferSize;
@@ -478,8 +494,7 @@ static asm int dmaBufferFlush(u32 param_0) {
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void __sinit_JKRDvdAramRipper_cpp() { asm void __sinit_JKRDvdAramRipper_cpp(){nofralloc
nofralloc
#include "asm/JSystem/JKernel/JKRDvdAramRipper/__sinit_JKRDvdAramRipper_cpp.s" #include "asm/JSystem/JKernel/JKRDvdAramRipper/__sinit_JKRDvdAramRipper_cpp.s"
} }
#pragma pop #pragma pop
+6 -13
View File
@@ -11,6 +11,7 @@
#include "MSL_C/math.h" #include "MSL_C/math.h"
#include "MSL_C/string.h" #include "MSL_C/string.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/os/OS.h"
#include "global.h" #include "global.h"
// //
@@ -74,11 +75,6 @@ extern "C" void _restgpr_29();
extern "C" u8 sVolumeList__13JKRFileLoader[12]; extern "C" u8 sVolumeList__13JKRFileLoader[12];
extern "C" u8 sSystemHeap__7JKRHeap[4]; extern "C" u8 sSystemHeap__7JKRHeap[4];
extern "C" {
void DCInvalidateRange(void*, u32);
void DCStoreRange(void*, u32);
}
// //
// Declarations: // Declarations:
// //
@@ -226,6 +222,7 @@ void* JKRDvdArchive::fetchResource(SDIFileEntry* fileEntry, u32* returnSize) {
if (resourceSize == 0) { if (resourceSize == 0) {
return NULL; return NULL;
} }
fileEntry->data = resourcePtr; fileEntry->data = resourcePtr;
if (fileCompression == COMPRESSION_YAZ0) { if (fileCompression == COMPRESSION_YAZ0) {
setExpandSize(fileEntry, *returnSize); setExpandSize(fileEntry, *returnSize);
@@ -346,12 +343,11 @@ u32 JKRDvdArchive::fetchResource_subroutine(s32 entryNum, u32 offset, u32 size,
} }
case COMPRESSION_YAY0: { case COMPRESSION_YAY0: {
JUTException::panic_f("JKRDvdArchive.cpp", 0x289, "%s", JUTException::panic_f(__FILE__, 649, "%s", "Sorry, not applied for SZP archive.\n");
"Sorry, not applied for SZP archive.\n");
} }
default: { default: {
JUTException::panic_f("JKRDvdArchive.cpp", 0x28d, "%s", "??? bad sequence\n"); JUTException::panic_f(__FILE__, 653, "%s", "??? bad sequence\n");
return 0; return 0;
} }
} }
@@ -414,12 +410,11 @@ u32 JKRDvdArchive::fetchResource_subroutine(s32 entryNum, u32 offset, u32 size,
} }
case COMPRESSION_YAY0: { case COMPRESSION_YAY0: {
JUTException::panic_f("JKRDvdArchive.cpp", 0x2f2, "%s", JUTException::panic_f(__FILE__, 754, "%s", "Sorry, not applied SZP archive.\n");
"Sorry, not applied SZP archive.\n");
} }
default: { default: {
JUTException::panic_f("JKRDvdArchive.cpp", 0x2f6, "%s", "??? bad sequence\n"); JUTException::panic_f(__FILE__, 758, "%s", "??? bad sequence\n");
return 0; return 0;
} }
} }
@@ -461,5 +456,3 @@ u32 JKRDvdArchive::getExpandedResSize(const void* resource) const {
return resourceSize; return resourceSize;
} }
/* 8039D1B0-8039D1B0 029810 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+2 -8
View File
@@ -9,10 +9,6 @@
#include "dol2asm.h" #include "dol2asm.h"
#include "global.h" #include "global.h"
//
// Declarations:
//
/* 8043436C-80434378 06108C 000C+00 4/4 0/0 0/0 .bss sDvdList__10JKRDvdFile */ /* 8043436C-80434378 06108C 000C+00 4/4 0/0 0/0 .bss sDvdList__10JKRDvdFile */
JSUList<JKRDvdFile> JKRDvdFile::sDvdList; JSUList<JKRDvdFile> JKRDvdFile::sDvdList;
@@ -94,7 +90,7 @@ void JKRDvdFile::close() {
mIsAvailable = false; mIsAvailable = false;
getDvdList().remove(&mDvdLink); getDvdList().remove(&mDvdLink);
} else { } else {
JUTException::panic_f("JKRDvdFile.cpp", 0xd5, "%s", "cannot close DVD file\n"); JUTException::panic_f(__FILE__, 213, "%s", "cannot close DVD file\n");
} }
} }
} }
@@ -105,7 +101,7 @@ s32 JKRDvdFile::readData(void* param_1, long length, long param_3) {
// The assert condition gets stringified as "( length & 0x1f ) == 0", // The assert condition gets stringified as "( length & 0x1f ) == 0",
// with out disabling clang-format the spaces in the condition will // with out disabling clang-format the spaces in the condition will
// get removed and the string will be incorrect. // get removed and the string will be incorrect.
JUT_ASSERT("JKRDvdFile.cpp", 0xee, ( length & 0x1f ) == 0); JUT_ASSERT(__FILE__, 238, ( length & 0x1f ) == 0);
/* clang-format on */ /* clang-format on */
OSLockMutex(&mMutex1); OSLockMutex(&mMutex1);
@@ -155,5 +151,3 @@ void JKRDvdFile::doneProcess(long id, DVDFileInfo* fileInfo) {
s32 JKRDvdFile::getFileSize(void) const { s32 JKRDvdFile::getFileSize(void) const {
return mFileInfo.length; return mFileInfo.length;
} }
/* 8039D260-8039D260 0298C0 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
+41 -13
View File
@@ -9,7 +9,6 @@
#include "MSL_C/MSL_Common/Src/string.h" #include "MSL_C/MSL_Common/Src/string.h"
#include "dol2asm.h" #include "dol2asm.h"
#include "dolphin/os/OSCache.h" #include "dolphin/os/OSCache.h"
#include "dolphin/types.h"
#include "global.h" #include "global.h"
// //
@@ -107,7 +106,7 @@ void* JKRDvdRipper::loadToMainRAM(s32 entryNumber, u8* dst, JKRExpandSwitch expa
/* 8039D290-8039D290 0298F0 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ /* 8039D290-8039D290 0298F0 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
#pragma push #pragma push
#pragma force_active on #pragma force_active on
SECTION_DEAD static char const* const stringBase_8039D290 = "JKRDvdRipper.cpp"; SECTION_DEAD static char const* const stringBase_8039D290 = __FILE__;
SECTION_DEAD static char const* const stringBase_8039D2A1 = "%s"; SECTION_DEAD static char const* const stringBase_8039D2A1 = "%s";
SECTION_DEAD static char const* const stringBase_8039D2A4 = "Sorry, not applied for SZP archive."; SECTION_DEAD static char const* const stringBase_8039D2A4 = "Sorry, not applied for SZP archive.";
SECTION_DEAD static char const* const stringBase_8039D2C8 = "Not support SZP with offset read"; SECTION_DEAD static char const* const stringBase_8039D2C8 = "Not support SZP with offset read";
@@ -151,21 +150,26 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
} }
r26 = (bufPtr[4] << 0x18) | (bufPtr[5] << 0x10) | (bufPtr[6] << 0x08) | (bufPtr[7]); r26 = (bufPtr[4] << 0x18) | (bufPtr[5] << 0x10) | (bufPtr[6] << 0x08) | (bufPtr[7]);
} }
if (pCompression) { if (pCompression) {
*pCompression = compression; *pCompression = compression;
} }
if (expandSwitch == EXPAND_SWITCH_UNKNOWN1 && compression) { if (expandSwitch == EXPAND_SWITCH_UNKNOWN1 && compression) {
if (dstLength != 0 && r26 > dstLength) { if (dstLength != 0 && r26 > dstLength) {
r26 = dstLength; r26 = dstLength;
} }
if (!dst) { if (!dst) {
dst = (u8*)JKRHeap::alloc(r26, allocDirection == ALLOC_DIRECTION_FORWARD ? 0x20 : -0x20, dst = (u8*)JKRHeap::alloc(r26, allocDirection == ALLOC_DIRECTION_FORWARD ? 0x20 : -0x20,
heap); heap);
did_alloc = true; did_alloc = true;
} }
if (!dst) { if (!dst) {
return NULL; return NULL;
} }
if (compression == 1) { if (compression == 1) {
mem = (u8*)JKRHeap::alloc(fileSizeAligned, 0x20, heap); mem = (u8*)JKRHeap::alloc(fileSizeAligned, 0x20, heap);
if (mem == NULL && did_alloc == true) { if (mem == NULL && did_alloc == true) {
@@ -183,10 +187,12 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
var2, allocDirection == ALLOC_DIRECTION_FORWARD ? 0x20 : -0x20, heap); var2, allocDirection == ALLOC_DIRECTION_FORWARD ? 0x20 : -0x20, heap);
did_alloc = true; did_alloc = true;
} }
if (!dst) { if (!dst) {
return NULL; return NULL;
} }
} }
if (compression == 0) { if (compression == 0) {
int count = 0; int count = 0;
if (offset != 0) { if (offset != 0) {
@@ -197,31 +203,38 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
if (count >= 0) { if (count >= 0) {
break; break;
} }
if (count == -3 || !data_804508C8) { if (count == -3 || !data_804508C8) {
if (did_alloc == true) { if (did_alloc == true) {
JKRHeap::free(dst, NULL); JKRHeap::free(dst, NULL);
} }
return NULL; return NULL;
} }
VIWaitForRetrace(); VIWaitForRetrace();
} }
DCInvalidateRange(bufPtr, 0x20); DCInvalidateRange(bufPtr, 0x20);
count = JKRDecomp::checkCompressed(bufPtr); count = JKRDecomp::checkCompressed(bufPtr);
if (count == 3) { if (count == 3) {
count = 0; count = 0;
} }
} }
if (count == 0 || expandSwitch == EXPAND_SWITCH_UNKNOWN2 || if (count == 0 || expandSwitch == EXPAND_SWITCH_UNKNOWN2 ||
expandSwitch == EXPAND_SWITCH_UNKNOWN0) { expandSwitch == EXPAND_SWITCH_UNKNOWN0)
{
fileSizeAligned -= offset; fileSizeAligned -= offset;
if (dstLength != 0 && dstLength < fileSizeAligned) { if (dstLength != 0 && dstLength < fileSizeAligned) {
fileSizeAligned = dstLength; fileSizeAligned = dstLength;
} }
while (true) { while (true) {
count = DVDReadPrio(dvdFile->getFileInfo(), dst, fileSizeAligned, offset, 2); count = DVDReadPrio(dvdFile->getFileInfo(), dst, fileSizeAligned, offset, 2);
if (count >= 0) { if (count >= 0) {
break; break;
} }
if (count == -3 || !data_804508C8) { if (count == -3 || !data_804508C8) {
if (did_alloc == true) { if (did_alloc == true) {
JKRHeap::free(dst, NULL); JKRHeap::free(dst, NULL);
@@ -230,6 +243,7 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
} }
VIWaitForRetrace(); VIWaitForRetrace();
} }
if (param_8) { if (param_8) {
*param_8 = fileSizeAligned; *param_8 = fileSizeAligned;
} }
@@ -237,24 +251,25 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
} else if (count == 2) { } else if (count == 2) {
JKRDecompressFromDVD(dvdFile, dst, fileSizeAligned, dstLength, 0, offset, param_8); JKRDecompressFromDVD(dvdFile, dst, fileSizeAligned, dstLength, 0, offset, param_8);
} else { } else {
JUTException::panic_f("JKRDvdRipper.cpp", 0x143, "%s", JUTException::panic_f(__FILE__, 0x143, "%s", "Sorry, not applied for SZP archive.");
"Sorry, not applied for SZP archive.");
} }
return dst; return dst;
} else if (compression == 1) { } else if (compression == 1) {
if (offset) { if (offset) {
JUTException::panic_f("JKRDvdRipper.cpp", 0x14d, "%s", JUTException::panic_f(__FILE__, 0x14d, "%s", "Not support SZP with offset read");
"Not support SZP with offset read");
} }
while (true) { while (true) {
int count = DVDReadPrio(dvdFile->getFileInfo(), mem, fileSizeAligned, 0, 2); int count = DVDReadPrio(dvdFile->getFileInfo(), mem, fileSizeAligned, 0, 2);
if (count >= 0) { if (count >= 0) {
break; break;
} }
if (count == -3 || !data_804508C8) { if (count == -3 || !data_804508C8) {
if (did_alloc == true) { if (did_alloc == true) {
JKRHeap::free(dst, NULL); JKRHeap::free(dst, NULL);
} }
JKRHeap::free(mem, NULL); JKRHeap::free(mem, NULL);
return NULL; return NULL;
} }
@@ -356,6 +371,7 @@ static u32 tsArea;
/* 802DA1E4-802DA35C 2D4B24 0178+00 1/1 0/0 0/0 .text /* 802DA1E4-802DA35C 2D4B24 0178+00 1/1 0/0 0/0 .text
* JKRDecompressFromDVD__FP10JKRDvdFilePvUlUlUlUlPUl */ * JKRDecompressFromDVD__FP10JKRDvdFilePvUlUlUlUlPUl */
// wrong reg at the end
#ifdef NONMATCHING #ifdef NONMATCHING
static int JKRDecompressFromDVD(JKRDvdFile* dvdFile, void* dst, u32 fileSize, u32 param_3, static int JKRDecompressFromDVD(JKRDvdFile* dvdFile, void* dst, u32 fileSize, u32 param_3,
u32 param_4, u32 param_5, u32* param_6) { u32 param_4, u32 param_5, u32* param_6) {
@@ -364,11 +380,13 @@ static int JKRDecompressFromDVD(JKRDvdFile* dvdFile, void* dst, u32 fileSize, u3
OSInitMutex(&decompMutex); OSInitMutex(&decompMutex);
data_80451458 = true; data_80451458 = true;
} }
OSRestoreInterrupts(level); OSRestoreInterrupts(level);
OSLockMutex(&decompMutex); OSLockMutex(&decompMutex);
u32 bufferSize = JKRDvdRipper::sSZSBufferSize; u32 bufferSize = JKRDvdRipper::sSZSBufferSize;
szpBuf = (u8*)JKRHeap::sSystemHeap->alloc(bufferSize, -0x20); szpBuf = (u8*)JKRHeap::sSystemHeap->alloc(bufferSize, -0x20);
szpEnd = szpBuf + bufferSize; szpEnd = szpBuf + bufferSize;
if (param_4) { if (param_4) {
refBuf = (u8*)JKRHeap::sSystemHeap->alloc(0x1120, -4); refBuf = (u8*)JKRHeap::sSystemHeap->alloc(0x1120, -4);
refEnd = refBuf + 0x1120; refEnd = refBuf + 0x1120;
@@ -376,24 +394,29 @@ static int JKRDecompressFromDVD(JKRDvdFile* dvdFile, void* dst, u32 fileSize, u3
} else { } else {
refBuf = NULL; refBuf = NULL;
} }
srcFile = dvdFile; srcFile = dvdFile;
srcOffset = param_5; srcOffset = param_5;
transLeft = fileSize - param_5; transLeft = fileSize - param_5;
fileOffset = param_4; fileOffset = param_4;
readCount = 0; readCount = 0;
maxDest = param_3; maxDest = param_3;
if (!param_6) { if (!param_6) {
tsPtr = &tsArea; tsPtr = &tsArea;
} else { } else {
tsPtr = param_6; tsPtr = param_6;
} }
*tsPtr = 0; *tsPtr = 0;
u8* first = firstSrcData(); u8* first = firstSrcData();
int result = first ? decompSZS_subroutine(first, (u8*)dst) : -1; int result = first ? decompSZS_subroutine(first, (u8*)dst) : -1;
JKRHeap::free(szpBuf, 0); i_JKRFree(szpBuf);
if (refBuf) { if (refBuf) {
JKRHeap::free(refBuf, 0); i_JKRFree(refBuf);
} }
DCStoreRangeNoSync(dst, *tsPtr); DCStoreRangeNoSync(dst, *tsPtr);
OSUnlockMutex(&decompMutex); OSUnlockMutex(&decompMutex);
return result; return result;
@@ -542,16 +565,19 @@ static u8* firstSrcData() {
u8* buffer = szpBuf; u8* buffer = szpBuf;
u32 bufSize = szpEnd - buffer; u32 bufSize = szpEnd - buffer;
u32 length = transLeft < bufSize ? transLeft : bufSize; u32 length = transLeft < bufSize ? transLeft : bufSize;
while (true) { while (true) {
int result = DVDReadPrio(srcFile->getFileInfo(), buffer, length, srcOffset, 2); int result = DVDReadPrio(srcFile->getFileInfo(), buffer, length, srcOffset, 2);
if (result >= 0) { if (result >= 0) {
break; break;
} }
if (result == -3 || !data_804508C8) { if (result == -3 || !data_804508C8) {
return NULL; return NULL;
} }
VIWaitForRetrace(); VIWaitForRetrace();
} }
DCInvalidateRange(buffer, length); DCInvalidateRange(buffer, length);
srcOffset += length; srcOffset += length;
transLeft -= length; transLeft -= length;
@@ -566,9 +592,11 @@ static u8* nextSrcData(u8* param_0) {
memcpy(dest, param_0, size); memcpy(dest, param_0, size);
u8* end = dest + size; u8* end = dest + size;
u32 transSize = szpEnd - end; u32 transSize = szpEnd - end;
if (transSize > transLeft) { if (transSize > transLeft) {
transSize = transLeft; transSize = transLeft;
} }
while (true) { while (true) {
s32 result = DVDReadPrio(srcFile->getFileInfo(), end, transSize, srcOffset, 2); s32 result = DVDReadPrio(srcFile->getFileInfo(), end, transSize, srcOffset, 2);
if (result >= 0) { if (result >= 0) {
@@ -580,12 +608,15 @@ static u8* nextSrcData(u8* param_0) {
} }
VIWaitForRetrace(); VIWaitForRetrace();
} }
DCInvalidateRange(end, transSize); DCInvalidateRange(end, transSize);
srcOffset += transSize; srcOffset += transSize;
transLeft -= transSize; transLeft -= transSize;
if (transLeft == 0) { if (transLeft == 0) {
srcLimit = end + transSize; srcLimit = end + transSize;
} }
return dest; return dest;
} }
#else #else
@@ -608,8 +639,7 @@ u8 JKRDvdRipper::isErrorRetry() {
#pragma push #pragma push
#pragma optimization_level 0 #pragma optimization_level 0
#pragma optimizewithasm off #pragma optimizewithasm off
asm void __sinit_JKRDvdRipper_cpp() { asm void __sinit_JKRDvdRipper_cpp(){nofralloc
nofralloc
#include "asm/JSystem/JKernel/JKRDvdRipper/__sinit_JKRDvdRipper_cpp.s" #include "asm/JSystem/JKernel/JKRDvdRipper/__sinit_JKRDvdRipper_cpp.s"
} }
#pragma pop #pragma pop
@@ -629,5 +659,3 @@ extern "C" asm void func_802DA820(void* _this) {
#include "asm/JSystem/JKernel/JKRDvdRipper/func_802DA820.s" #include "asm/JSystem/JKernel/JKRDvdRipper/func_802DA820.s"
} }
#pragma pop #pragma pop
/* 8039D290-8039D290 0298F0 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */

Some files were not shown because too many files have changed in this diff Show More