JKRDecomp: main.dol: OK

This commit is contained in:
SwareJonge 2023-01-22 01:59:03 +01:00
parent a6b5757bc1
commit 5f9072975f
7 changed files with 479 additions and 118 deletions

View File

@ -35,14 +35,21 @@ JSystem/JUtility/JUTProcBar.cpp:
JSystem/JSupport/JSUList.cpp:
.text: [0x80078b2c, 0x800790d0]
JSystem/JKernel/JKRDecomp.cpp:
.text: [0x8007e550, 0x8007ec74]
.rodata: [0x80366aa0, 0x80366ac8]
.data: [0x8038b280, 0x8038b2d0]
.sbss: [0x804158f8, 0x80415900]
.sdata2: [0x80417a58, 0x80417a68]
JSystem/JKernel/JKRDvdFile.cpp:
.text: [0x8007ed58, 0x8007f33c] #0x8007f33c
.text: [0x8007ed58, 0x8007f33c]
.ctors: [0x803160dc, 0x803160e0]
.rodata: [0x80366ac8, 0x80366b08]
.data: [0x8038b2e0, 0x8038b308]
.bss: [0x803ae950, 0x803ae960] # hooray! common on!!!!
.bss: [0x803ae950, 0x803ae960]
#.bss: [0x803fa944, 0x803fa950]
.sdata2: [0x80417a68, 0x80417a78]
.sdata2: [0x80417a68, 0x80417a78]
Dolphin/__ppc_eabi_init.s:
.text: [0x800f31d8, 0x800f322c]

View File

@ -322,11 +322,30 @@ global:
# JKRAram.cpp
0x8007949c: create__7JKRAramFUlUllll
0x8007b588: sendCommand__12JKRAramPieceFP12JKRAMCommand
0x8038b110: __vt__7JKRFile
# JKRAramArchive.cpp
0x8007a584: __dt__7JKRFileFv
# JKRDecomp.cpp
0x8007e550: create__9JKRDecompFl
0x8007e5b0: __ct__9JKRDecompFl
0x8007e600: __dt__9JKRDecompFv
0x8007e658: run__9JKRDecompFv
0x8007e71c: sendCommand__9JKRDecompFP16JKRDecompCommand
0x8007e790: orderSync__9JKRDecompFPUcPUcUlUl
0x8007e874: decode__9JKRDecompFPUcPUcUlUl
0x8007e8e8: decodeSZP__9JKRDecompFPUcPUcUlUl
0x8007ea8c: decodeSZS__9JKRDecompFPUcPUcUlUl
0x8007eb70: checkCompressed__9JKRDecompFPUc
0x8007ebe8: __ct__16JKRDecompCommandFv
0x8007ec38: __dt__16JKRDecompCommandFv
0x8038b280: sMessageBuffer__9JKRDecomp
0x8038b2a0: sMessageQueue__9JKRDecomp
0x804158f8: sDecompObject__9JKRDecomp
# JKRDisposer.cpp
0x8007ecdc: __dt__11JKRDisposerFv
0x8007ec74: __ct__11JKRDisposerFv
@ -426,8 +445,25 @@ global:
0x80081c4c: create__10JKRExpHeapFUlP7JKRHeapb
0x80081d18: create__10JKRExpHeapFPvUlP7JKRHeapb
# JKRThread.h
# JKRThread.cpp
0x80086734: __ct__9JKRThreadFUlii
0x800867d4: __ct__9JKRThreadFP7JKRHeapUlii
0x80086874: __ct__9JKRThreadFP8OSThreadi
0x8008690c: __dt__9JKRThreadFv
0x800869dc: setCommon_mesgQueue__9JKRThreadFP7JKRHeapi
0x80086a94: setCommon_heapSpecified__9JKRThreadFP7JKRHeapUli
0x80086b9c: start__9JKRThreadFPv
0x80086bc8: run__9JKRThreadFv
0x80086bd0: enter__15JKRThreadSwitchFP9JKRThreadi
0x80086c48: __dt__7JKRTaskFv
0x80086d50: create__7JKRTaskFiiUlP7JKRHeap
0x8008700c: run__7JKRTaskFv
0x800870a0: request__7JKRTaskFPFPv_vPvPv
0x800871b4: __dt__17JSUList<7JKRTask>Fv
0x80087200: __dt__19JSUList<9JKRThread>Fv
0x803fa974: sThreadList__9JKRThread
0x803fa9ac: sTaskList__7JKRTask
0x804159d0: sManager__15JKRThreadSwitch
# JASHeapCtrl.cpp
0x800902a0: showAssert__12JUTAssertionFUlPCciPCc
@ -2280,49 +2316,6 @@ global:
0x801d7a80: getAppHeap__6SystemF
0x801d7a88: getHeap__7GameAppFv
# AppMgr.cpp
0x80200a28: draw__6AppMgrFv
0x80200a80: calc__6AppMgrFv
0x80200c90: setNextApp__6AppMgrFQ26AppMgr11KartAppEnum
0x80200cd4: insertErrorViewApp__6AppMgrFv
0x80200d08: createApp__6AppMgrFQ26AppMgr11KartAppEnum
0x80200db4: restartApp__6AppMgrFv
0x80200fb0: isRestartable__6AppMgrFv
0x80416998: msGameApp__6AppMgr
0x8041699c: msNextGameApp__6AppMgr
0x804169a0: msNextNextGameApp__6AppMgr
0x804169a4: msPrevGameApp__6AppMgr
0x804169a8: mspGameApp__6AppMgr
0x804169ac: msRequest__6AppMgr
0x804169b0: msDrawStallFrame__6AppMgr
0x804169b1: msCalcStallFrame__6AppMgr
0x804169b2: msChangeStallFrame__6AppMgr
# systemData.cpp
0x8037d938: sc3DViewPort__10SystemData
0x8037d948: sc3DScissor__10SystemData
0x8037d958: sc3DAwardScissor__10SystemData
0x8037d968: scOrtho__10SystemData
0x8037d978: sc3DViewPortSub__10SystemData
0x8037d988: sc3DScissorSub__10SystemData
0x8037d998: scNtscInt448Df__10SystemData
0x8037d9d4: scNtscInt448__10SystemData
0x8037da10: scNtscProg448Soft__10SystemData
0x8037da4c: scNtscProg448__10SystemData
0x8039cd28: sca3DViewPortDiv2__10SystemData
0x8039cd48: sca3DScissorDiv2__10SystemData
0x8039cd68: sca3DViewPortDiv4__10SystemData
0x8039cda8: sca3DScissorDiv4__10SystemData
0x80416a00: scAspect__10SystemData
0x80416a04: scAspectDiv2__10SystemData
0x80416a08: scAspectSub__10SystemData
0x8041b758: scNumStandardHeaps__10SystemData
0x8041b75c: scDefaultFifoSize__10SystemData
0x8041b760: scSystemHeapSize__10SystemData
0x8041b764: scAudioHeapSize__10SystemData
0x8041b768: scAudioAramSize__10SystemData
# TestApp.cpp
0x801f6fc0: create__7TestAppFv
0x801f7010: __ct__7TestAppFv
@ -2493,6 +2486,49 @@ global:
0x804009f8: gKartPad15P
0x80400ab0: gKartPad16P
# AppMgr.cpp
0x80200a28: draw__6AppMgrFv
0x80200a80: calc__6AppMgrFv
0x80200c90: setNextApp__6AppMgrFQ26AppMgr11KartAppEnum
0x80200cd4: insertErrorViewApp__6AppMgrFv
0x80200d08: createApp__6AppMgrFQ26AppMgr11KartAppEnum
0x80200db4: restartApp__6AppMgrFv
0x80200fb0: isRestartable__6AppMgrFv
0x80416998: msGameApp__6AppMgr
0x8041699c: msNextGameApp__6AppMgr
0x804169a0: msNextNextGameApp__6AppMgr
0x804169a4: msPrevGameApp__6AppMgr
0x804169a8: mspGameApp__6AppMgr
0x804169ac: msRequest__6AppMgr
0x804169b0: msDrawStallFrame__6AppMgr
0x804169b1: msCalcStallFrame__6AppMgr
0x804169b2: msChangeStallFrame__6AppMgr
# systemData.cpp
0x8037d938: sc3DViewPort__10SystemData
0x8037d948: sc3DScissor__10SystemData
0x8037d958: sc3DAwardScissor__10SystemData
0x8037d968: scOrtho__10SystemData
0x8037d978: sc3DViewPortSub__10SystemData
0x8037d988: sc3DScissorSub__10SystemData
0x8037d998: scNtscInt448Df__10SystemData
0x8037d9d4: scNtscInt448__10SystemData
0x8037da10: scNtscProg448Soft__10SystemData
0x8037da4c: scNtscProg448__10SystemData
0x8039cd28: sca3DViewPortDiv2__10SystemData
0x8039cd48: sca3DScissorDiv2__10SystemData
0x8039cd68: sca3DViewPortDiv4__10SystemData
0x8039cda8: sca3DScissorDiv4__10SystemData
0x80416a00: scAspect__10SystemData
0x80416a04: scAspectDiv2__10SystemData
0x80416a08: scAspectSub__10SystemData
0x8041b758: scNumStandardHeaps__10SystemData
0x8041b75c: scDefaultFifoSize__10SystemData
0x8041b760: scSystemHeapSize__10SystemData
0x8041b764: scAudioHeapSize__10SystemData
0x8041b768: scAudioAramSize__10SystemData
# TARecord.cpp
0x8020b458: __ct__8TARecordFUcUcUcUc
0x8020b494: setName__8TARecordFPCc
@ -2511,7 +2547,7 @@ global:
0x80407334: msaCRCTable__8SaveFile
0x80416a48: msCRCTableComputed__8SaveFile
# screenshot.c
# screenshot.c
0x80219f50: SCREENSHOTService
0x80414890: g_usb_channel
0x80416a98: g_connected

View File

@ -0,0 +1,78 @@
#ifndef JKRARAMPIECE_H
#define JKRARAMPIECE_H
#include "JSystem/JSupport/JSUList.h"
//#include "dolphin/arq.h"
#include "dolphin/OS.h"
#include "dolphin/types.h"
class JKRAramBlock;
class JKRDecompCommand;
class JKRAMCommand
{
public:
typedef void (*AsyncCallback)(u32);
JKRAMCommand();
~JKRAMCommand();
public:
/* 0x00 ARQRequest mRequest;*/
u8 _0[0x20]; // filler for now, kinda lazy
/* 0x20 */ JSULink<JKRAMCommand> mPieceLink;
/* 0x30 */ JSULink<JKRAMCommand> field_0x30;
/* 0x40 */ s32 mTransferDirection;
/* 0x44 */ u32 mDataLength;
/* 0x48 */ u32 mSrc;
/* 0x4C */ u32 mDst;
/* 0x50 */ JKRAramBlock *mAramBlock;
/* 0x54 */ u32 field_0x54;
/* 0x58 */ AsyncCallback mCallback;
/* 0x5C */ OSMessageQueue *field_0x5C;
/* 0x60 */ s32 field_0x60;
/* 0x64 */ JKRDecompCommand *mDecompCommand;
/* 0x68 */ OSMessageQueue mMessageQueue;
/* 0x88 */ OSMessage mMessage;
/* 0x8C */ void *field_0x8C;
/* 0x90 */ void *field_0x90;
/* 0x94 */ void *field_0x94;
};
class JKRAramPiece
{
public:
static OSMutex mMutex;
// TODO: fix type
static JSUList<JKRAMCommand> sAramPieceCommandList;
public:
struct Message
{
s32 field_0x00;
JKRAMCommand *command;
};
public:
static JKRAMCommand *prepareCommand(int, u32, u32, u32, JKRAramBlock *,
JKRAMCommand::AsyncCallback);
static void sendCommand(JKRAMCommand *);
static JKRAMCommand *orderAsync(int, u32, u32, u32, JKRAramBlock *, JKRAMCommand::AsyncCallback);
static BOOL sync(JKRAMCommand *, int);
static BOOL orderSync(int, u32, u32, u32, JKRAramBlock *);
static void startDMA(JKRAMCommand *);
static void doneDMA(u32);
private:
static void lock() { OSLockMutex(&mMutex); }
static void unlock() { OSUnlockMutex(&mMutex); }
};
inline BOOL JKRAramPcs(int direction, u32 source, u32 destination, u32 length,
JKRAramBlock *block)
{
return JKRAramPiece::orderSync(direction, source, destination, length, block);
}
#endif /* JKRARAMPIECE_H */

View File

@ -10,6 +10,16 @@ class SArcDataInfo;
class SDirEntry;
class SDIFileEntry;
inline u16 read_big_endian_u16(void *ptr) {
u8 *uptr = (u8 *)ptr;
return ((u16)uptr[0] << 8) | ((u16)uptr[1]);
}
inline u32 read_big_endian_u32(void *ptr) {
u8 *uptr = (u8 *)ptr;
return ((u32)uptr[0] << 0x18) | ((u32)uptr[1] << 0x10) | ((u32)uptr[2] << 8) | (u32)uptr[3];
}
class JKRArchive : public JKRFileLoader {
public:
enum EMountMode {

View File

@ -6,22 +6,48 @@
#include "types.h"
enum CompressionMethod {
TYPE_UNK,
TYPE_NONE,
TYPE_YAY0,
TYPE_YAZ0,
TYPE_ASR
};
class JKRDecomp : public JKRThread {
public:
static void create();
#define JKRDECOMP_SYNC_BLOCKING 0
#define JKRDECOMP_SYNC_NON_BLOCKING 1
class JKRAMCommand;
struct JKRDecompCommand {
typedef void (*AsyncCallback)(u32);
JKRDecompCommand();
~JKRDecompCommand();
u8 _0[4]; // perhaps file magic
u8 *mSrcBuffer; // 4
u8 *mDstBuffer; // 8
u32 mSrcLength; // C
u32 mDstLength; // 10
AsyncCallback mCb;
JKRDecompCommand *mThis; // 18
OSMessageQueue *_1C;
s32 _20;
JKRAMCommand *mAramCmd; // 24
OSMessageQueue mMessageQueue; // 28
OSMessage mMessageBuf;
};
class JKRDecomp : public JKRThread {
JKRDecomp(s32);
virtual ~JKRDecomp();
virtual void *run();
public:
static JKRDecomp *create(s32);
static JKRDecompCommand *prepareCommand(u8 *, u8 *, u32, u32, JKRDecompCommand::AsyncCallback);
static void sendCommand(JKRDecompCommand *);
static int orderSync(u8 *, u8 *, u32, u32);
static bool sync(JKRDecompCommand *, int);
static JKRDecompCommand *orderAsync(u8 *, u8 *, u32, u32, JKRDecompCommand::AsyncCallback);
static bool orderSync(u8 *, u8 *, u32, u32);
static void decode(u8 *, u8 *, u32, u32);
static void decodeSZP(u8 *, u8 *, u32, u32);
static void decodeSZS(u8 *, u8 *, u32, u32);
@ -30,29 +56,6 @@ public:
static OSMessage sMessageBuffer[8];
static OSMessageQueue sMessageQueue;
static JKRDecomp *sDecompObject;
private:
OSThread * mThread;
};
struct JKRDecompCommand {
typedef void DecompCmdCb();
JKRDecompCommand();
~JKRDecompCommand();
u8 _0[4]; //
u8 *mSrc; // 4
u8 *mDst; // 8
u32 mCompressedSize; // C
u32 mDecompressedSize; // 10
DecompCmdCb *mCb;
JKRDecompCommand *mChild; // 18
OSMessageQueue * _1C;
u32 _20;
void* mAramCmd; // 24
OSMessageQueue mMessageQueue; // 28
OSMessage mMessageBuf;
};
#endif

View File

@ -60,6 +60,8 @@ struct JKRThread : public JKRDisposer
void searchThreadLoad(OSThread *);
void dump();
void resume() { OSResumeThread(m_thread); }
JSULink<JKRThread> m_link; // _18
JKRHeap *m_heap; // _28
OSThread *m_thread; // _2C

View File

@ -1,66 +1,291 @@
#include "JSystem/JUtility/JUTDbg.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRAramPiece.h"
#include "JSystem/JKernel/JKRArchive.h"
#include "JSystem/JKernel/JKRDecomp.h"
// WIP, missing classes
// most copied from TP Decomp, i did put in some effort myself but since TP already had most matching, i opted to use that instead
JKRDecomp *JKRDecomp::sDecompObject;
OSMessage JKRDecomp::sMessageBuffer[8] = {0};
OSMessageQueue JKRDecomp::sMessageQueue = {0};
JKRDecomp *JKRDecomp::create(s32 priority) {
if (!sDecompObject)
sDecompObject = new (JKRHeap::getSystemHeap(), 0) JKRDecomp(priority);
return sDecompObject;
}
JKRDecomp::JKRDecomp(s32 threadPriority) : JKRThread(0x4000, 16, threadPriority) {
OSResumeThread(mThread);
resume();
}
JKRDecomp::~JKRDecomp() {}
void * JKRDecomp::run() {
OSMessage msg;
JKRDecompCommand *decompCmd;
void *JKRDecomp::run() {
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8);
while (true) {
while(true) {
OSReceiveMessage(&sMessageQueue, &msg, OS_MESSAGE_BLOCK);
decompCmd = reinterpret_cast<JKRDecompCommand*>(&msg);
decode(decompCmd->mSrc, decompCmd->mDst, decompCmd->mCompressedSize, decompCmd->mDecompressedSize);
if (decompCmd->_20 == 0)
break;
if (decompCmd->_20 == 1) {
decompCmd->_24->sendCommand();
}
for (;;) {
OSMessage msg;
OSReceiveMessage(&sMessageQueue, &msg, OS_MESSAGE_BLOCK);
JKRDecompCommand *decompCmd = (JKRDecompCommand *)(msg);
decode(decompCmd->mSrcBuffer, decompCmd->mDstBuffer, decompCmd->mSrcLength, decompCmd->mDstLength);
if (decompCmd->_20 != 0) {
if (decompCmd->_20 == 1)
JKRAramPiece::sendCommand(decompCmd->mAramCmd);
continue;
}
if (decompCmd->mCb == nullptr)
break;
decompCmd->mCb();
}
if (decompCmd->_1C == nullptr) {
OSSendMessage(&decompCmd->mMessageQueue, (void*)1, 0);
}
else {
OSSendMessage(decompCmd->_1C, (void *)1, 0);
if (decompCmd->mCb) {
(*decompCmd->mCb)((u32)decompCmd);
continue;
}
if (decompCmd->_1C)
OSSendMessage(decompCmd->_1C, (OSMessage)1, OS_MESSAGE_NOBLOCK);
else
OSSendMessage(&decompCmd->mMessageQueue, (OSMessage)1, OS_MESSAGE_NOBLOCK);
}
}
void JKRDecomp::sendCommand(JKRDecompCommand * decompCmd) {
JKRDecompCommand *JKRDecomp::prepareCommand(u8 *srcBuffer, u8 *dstBuffer, u32 srcLength,
u32 dstLength,
JKRDecompCommand::AsyncCallback callback)
{
JKRDecompCommand *command = new (JKRHeap::getSystemHeap(), -4) JKRDecompCommand();
command->mSrcBuffer = srcBuffer;
command->mDstBuffer = dstBuffer;
command->mSrcLength = srcLength;
command->mDstLength = dstLength;
command->mCb = callback;
return command;
}
void JKRDecomp::sendCommand(JKRDecompCommand *decompCmd) {
BOOL msgret = OSSendMessage(&sMessageQueue, decompCmd, 0);
JUT_ASSERT_MSG(142, msgret, "Decomp MesgBuf FULL!");
}
int JKRDecomp::orderSync(u8 * src, u8 * dst, u32 srcSize, u32 dstSize) {
JKRDecompCommand *decompCmd = new(JKRHeap::getSystemHeap(), -4);
decompCmd->mSrc = src;
decompCmd->mDst = dst;
decompCmd->mCompressedSize = srcSize;
decompCmd->mDecompressedSize = dstSize;
decompCmd->mCb = nullptr;
sendCommand(decompCmd);
JKRDecompCommand *JKRDecomp::orderAsync(u8 *srcBuffer, u8 *dstBuffer, u32 srcLength, u32 dstLength,
JKRDecompCommand::AsyncCallback callback)
{
JKRDecompCommand *command =
prepareCommand(srcBuffer, dstBuffer, srcLength, dstLength, callback);
sendCommand(command);
return command;
}
OSMessage* msg;
OSReceiveMessage(&decompCmd->mMessageQueue, msg, OS_MESSAGE_BLOCK);
delete decompCmd;
bool JKRDecomp::sync(JKRDecompCommand *command, int isNonBlocking) {
OSMessage message;
bool result;
if (isNonBlocking == JKRDECOMP_SYNC_BLOCKING) {
OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_BLOCK);
result = true;
}
else {
result = OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_NOBLOCK) != FALSE;
}
return result;
}
bool JKRDecomp::orderSync(u8 *srcBuffer, u8 *dstBuffer, u32 srcLength, u32 dstLength) {
JKRDecompCommand *command = orderAsync(srcBuffer, dstBuffer, srcLength, dstLength, NULL);
bool result = sync(command, JKRDECOMP_SYNC_BLOCKING);
delete command;
return result;
}
void JKRDecomp::decode(u8 *src, u8 *dst, u32 srcSize, u32 dstSize) {
switch(checkCompressed(src)) {
case TYPE_YAY0:
decodeSZP(src, dst, srcSize, dstSize);
case TYPE_YAZ0:
decodeSZS(src, dst, srcSize, dstSize);
}
CompressionMethod compression = checkCompressed(src);
if (compression == TYPE_YAY0)
decodeSZP(src, dst, srcSize, dstSize);
else if (compression == TYPE_YAZ0)
decodeSZS(src, dst, srcSize, dstSize);
}
void JKRDecomp::decodeSZP(u8 *src, u8 *dst, u32 srcLength, u32 dstLength)
{
// s32 decodedSize;
s32 srcChunkOffset;
u32 count;
s32 dstOffset;
u32 length;
s32 linkInfo;
s32 offset;
s32 i;
s32 decodedSize = read_big_endian_u32(src + 4);
s32 linkTableOffset = read_big_endian_u32(src + 8);
s32 srcDataOffset = read_big_endian_u32(src + 12);
dstOffset = 0;
u32 counter = 0;
srcChunkOffset = 16;
u32 chunkBits;
if (srcLength == 0)
return;
if (dstLength > decodedSize)
return;
length = srcLength;
do
{
if (counter == 0)
{
chunkBits = read_big_endian_u32(src + srcChunkOffset);
srcChunkOffset += sizeof(u32);
counter = sizeof(u32) * 8;
}
if (chunkBits & 0x80000000)
{
if (dstLength == 0)
{
dst[dstOffset] = src[srcDataOffset];
length--;
if (length == 0)
return;
}
else
{
dstLength--;
}
dstOffset++;
srcDataOffset++;
}
else
{
linkInfo = src[linkTableOffset] << 8 | src[linkTableOffset + 1];
linkTableOffset += sizeof(u16);
offset = dstOffset - (linkInfo & 0xFFF);
// rlwinm. r28,r29,0x14,0x1c,0x1f
count = (linkInfo >> 12);
if (count == 0)
{
count = (u32)src[srcDataOffset] + 0x12;
srcDataOffset++;
}
else
count += 2;
if ((s32)count > decodedSize - dstOffset)
count = decodedSize - dstOffset;
for (i = 0; i < (s32)count; i++, dstOffset++, offset++)
{
if (dstLength == 0)
{
dst[dstOffset] = dst[offset - 1];
length--;
if (length == 0)
return;
}
else
dstLength--;
}
}
chunkBits <<= 1;
counter--;
} while (dstOffset < decodedSize);
}
void JKRDecomp::decodeSZS(u8 *src_buffer, u8 *dst_buffer, u32 srcSize, u32 dstSize) {
u8 *decompEnd = dst_buffer + *(int *)(src_buffer + 4) - dstSize;
u8 *copyStart;
s32 copyByteCount;
s32 chunkBitsLeft = 0;
s32 chunkBits;
if (srcSize == 0)
return;
if (dstSize > *(u32 *)src_buffer)
return;
u8 *curSrcPos = src_buffer + 0x10;
do {
if (chunkBitsLeft == 0) {
chunkBits = *curSrcPos;
chunkBitsLeft = 8;
curSrcPos++;
}
if ((chunkBits & 0x80) != 0) {
if (dstSize == 0)
{
*dst_buffer = *curSrcPos;
srcSize--;
dst_buffer++;
if (srcSize == 0)
return;
}
else {
dstSize--;
}
curSrcPos++;
}
else {
u8 curVal = *curSrcPos;
// load is inversed
copyStart = dst_buffer - ((curVal & 0xF) << 8 | curSrcPos[1]);
// copyByteCount = ;
curSrcPos += 2;
// instruction order differences
if (curVal >> 4 == 0) {
copyByteCount = *curSrcPos + 0x12;
curSrcPos++;
}
else {
copyByteCount = (curVal >> 4) + 2;
}
do {
if (dstSize == 0) {
*dst_buffer = *(copyStart - 1);
srcSize--;
dst_buffer++;
if (srcSize == 0)
return;
}
else {
dstSize--;
}
copyByteCount--;
copyStart++;
} while (copyByteCount != 0);
}
chunkBits <<= 1;
chunkBitsLeft--;
} while (dst_buffer != decompEnd);
}
CompressionMethod JKRDecomp::checkCompressed(u8 *src)
{
if ((src[0] == 'Y') && (src[1] == 'a') && (src[3] == '0'))
{
if (src[2] == 'y')
return TYPE_YAY0;
if (src[2] == 'z')
return TYPE_YAZ0;
}
if ((src[0] == 'A') && (src[1] == 'S') && (src[2] == 'R'))
return TYPE_ASR;
return TYPE_NONE;
}
JKRDecompCommand::JKRDecompCommand() {
OSInitMessageQueue(&mMessageQueue, &mMessageBuf, 1);
mCb = nullptr;
_1C = nullptr;
mThis = this;
_20 = 0;
}
JKRDecompCommand::~JKRDecompCommand() {}