mirror of
https://github.com/zeldaret/tww.git
synced 2026-06-17 23:01:06 -04:00
JKRThread, JKRExpHeap, JKRFileLoader, JKRArchive (#42)
* JKRThread * JKRExpHeap * JKRFileLoader * JKRArchive
This commit is contained in:
+2
-2
@@ -760,13 +760,13 @@ config.libs = [
|
||||
Object(NonMatching, "JSystem/JKernel/JKRExpHeap.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRSolidHeap.cpp"),
|
||||
Object(Matching, "JSystem/JKernel/JKRDisposer.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRThread.cpp"),
|
||||
Object(Matching, "JSystem/JKernel/JKRThread.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRAram.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRAramHeap.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRAramBlock.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRAramPiece.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRAramStream.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRFileLoader.cpp"),
|
||||
Object(Matching, "JSystem/JKernel/JKRFileLoader.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRFileFinder.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRFileCache.cpp"),
|
||||
Object(NonMatching, "JSystem/JKernel/JKRArchivePub.cpp"),
|
||||
|
||||
@@ -27,8 +27,6 @@ public:
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
/* 0x5C */ JKRCompression mCompression;
|
||||
/* 0x60 */ EMountDirection mMountDirection;
|
||||
/* 0x64 */ JKRAramBlock* mBlock;
|
||||
/* 0x68 */ JKRDvdFile* mDvdFile;
|
||||
}; // Size = 0x6C
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
#include "global.h"
|
||||
|
||||
class JKRArcFinder;
|
||||
class JKRHeap;
|
||||
|
||||
struct SArcHeader {
|
||||
@@ -129,7 +130,8 @@ public:
|
||||
void* getResource(u16);
|
||||
u32 readIdxResource(void*, u32, u32);
|
||||
u32 readResource(void*, u32, u16);
|
||||
u32 countResource(void) const;
|
||||
u32 countResource(u32) const;
|
||||
JKRArcFinder* getFirstResource(u32) const;
|
||||
u32 getFileAttribute(u32) const;
|
||||
|
||||
SDIFileEntry* findNameResource(const char*) const;
|
||||
@@ -182,13 +184,16 @@ public:
|
||||
|
||||
protected:
|
||||
/* 0x58 */ u32 field_0x58;
|
||||
/* 0x5C */ JKRCompression mCompression;
|
||||
/* 0x60 */ EMountDirection mMountDirection;
|
||||
|
||||
public:
|
||||
static JKRArchive* check_mount_already(s32, JKRHeap*);
|
||||
static JKRArchive* check_mount_already(s32);
|
||||
static JKRArchive* mount(const char*, EMountMode, JKRHeap*, EMountDirection);
|
||||
static JKRArchive* mount(void*, JKRHeap*, EMountDirection);
|
||||
static JKRArchive* mount(s32, EMountMode, JKRHeap*, EMountDirection);
|
||||
static void* getGlbResource(u32, const char*, JKRArchive*);
|
||||
static void readTypeResource(void*, u32, u32, const char*, JKRArchive*);
|
||||
|
||||
static JKRCompression convertAttrToCompressionType(u32 attr) {
|
||||
#define JKRARCHIVE_ATTR_COMPRESSION 0x04
|
||||
|
||||
@@ -24,8 +24,6 @@ public:
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
/* 0x5C */ int mCompression;
|
||||
/* 0x60 */ EMountDirection mMountDirection;
|
||||
/* 0x64 */ int field_0x64;
|
||||
/* 0x68 */ JKRAramBlock* mAramPart;
|
||||
/* 0x6C */ int field_0x6c;
|
||||
|
||||
@@ -23,8 +23,6 @@ public:
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
/* 0x5C */ JKRCompression mCompression;
|
||||
/* 0x60 */ EMountDirection mMountDirection;
|
||||
/* 0x64 */ s32 field_0x64;
|
||||
/* 0x68 */ JKRDvdFile* mDvdFile;
|
||||
};
|
||||
|
||||
@@ -56,11 +56,12 @@ protected:
|
||||
void removeUsedBlock(CMemBlock* block);
|
||||
void recycleFreeBlock(CMemBlock* block);
|
||||
void joinTwoBlocks(CMemBlock* block);
|
||||
bool dump_sort_by_address();
|
||||
|
||||
public:
|
||||
s32 getUsedSize(u8 groupId) const;
|
||||
s32 getTotalUsedSize(void) const;
|
||||
|
||||
|
||||
CMemBlock* getHeadUsedList() const { return mHeadUsedList; }
|
||||
void setAllocationMode(EAllocMode mode) {
|
||||
mAllocMode = mode;
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
/* vt[10] */ virtual void do_free(void* ptr); /* override */
|
||||
/* vt[11] */ virtual void do_freeAll(); /* override */
|
||||
/* vt[12] */ virtual void do_freeTail(); /* override */
|
||||
/* vt[13] */ virtual void do_fillFreeArea(); /* override */
|
||||
/* vt[13] */ virtual void do_freeFill(); /* override */
|
||||
/* vt[14] */ virtual s32 do_resize(void* ptr, u32 size); /* override */
|
||||
/* vt[15] */ virtual s32 do_getSize(void* ptr); /* override */
|
||||
/* vt[16] */ virtual s32 do_getFreeSize(); /* override */
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
/* vt[18] */ virtual s32 do_getTotalFreeSize(); /* override */
|
||||
/* vt[19] */ virtual s32 do_changeGroupID(u8 newGroupID); /* override */
|
||||
/* vt[20] */ virtual u8 do_getCurrentGroupId(); /* override */
|
||||
/* vt[21] */ virtual u32 state_register(JKRHeap::TState* p, u32 id) const; /* override */
|
||||
/* vt[21] */ virtual void state_register(JKRHeap::TState* p, u32 id) const; /* override */
|
||||
/* vt[22] */ virtual bool state_compare(JKRHeap::TState const& r1,
|
||||
JKRHeap::TState const& r2) const; /* override */
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/* vt[10] */ virtual void do_free(void* ptr) = 0;
|
||||
/* vt[11] */ virtual void do_freeAll() = 0;
|
||||
/* vt[12] */ virtual void do_freeTail() = 0;
|
||||
/* vt[13] */ virtual void do_fillFreeArea() = 0;
|
||||
/* vt[13] */ virtual void do_freeFill() = 0;
|
||||
/* vt[14] */ virtual s32 do_resize(void* ptr, u32 size) = 0;
|
||||
/* vt[15] */ virtual s32 do_getSize(void* ptr) = 0;
|
||||
/* vt[16] */ virtual s32 do_getFreeSize() = 0;
|
||||
|
||||
@@ -31,8 +31,6 @@ public:
|
||||
private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ // JKRArchive
|
||||
/* 0x5C */ JKRCompression mCompression;
|
||||
/* 0x60 */ EMountDirection mMountDirection;
|
||||
/* 0x64 */ SArcHeader* mArcHeader;
|
||||
/* 0x68 */ u8* mArchiveData;
|
||||
/* 0x6C */ bool mIsOpen;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
/* vt[10] */ virtual void do_free(void*); /* override */
|
||||
/* vt[11] */ virtual void do_freeAll(void); /* override */
|
||||
/* vt[12] */ virtual void do_freeTail(void); /* override */
|
||||
/* vt[13] */ virtual void do_fillFreeArea(void); /* override */
|
||||
/* vt[13] */ virtual void do_freeFill(void); /* override */
|
||||
/* vt[14] */ virtual s32 do_resize(void*, u32); /* override */
|
||||
/* vt[15] */ virtual s32 do_getSize(void*); /* override */
|
||||
/* vt[16] */ virtual s32 do_getFreeSize(void); /* override */
|
||||
|
||||
@@ -14,53 +14,11 @@ struct JKRThreadName_ {
|
||||
class JUTConsole;
|
||||
class JKRThread : JKRDisposer {
|
||||
public:
|
||||
class TLoad {
|
||||
public:
|
||||
TLoad() {
|
||||
clear();
|
||||
mValid = false;
|
||||
mThreadId = 0;
|
||||
}
|
||||
|
||||
bool isValid() const { return mValid; }
|
||||
u32 getCost() const { return mCost; }
|
||||
u32 getCount() const { return mSwitchCount; }
|
||||
s32 getId() const { return mThreadId; }
|
||||
|
||||
void setValid(bool valid) { mValid = valid; }
|
||||
void setId(s32 id) { mThreadId = id; }
|
||||
void setCurrentTime() { mLastTick = OSGetTick(); }
|
||||
|
||||
void resetCost() { mCost = 0; }
|
||||
void resetCount() { mSwitchCount = 0; }
|
||||
|
||||
void incCount() { mSwitchCount++; }
|
||||
void addCurrentCost() { mCost = mCost + (OSGetTick() - mLastTick); }
|
||||
|
||||
void clear() {
|
||||
resetCount();
|
||||
resetCost();
|
||||
mLastTick = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
/* 0x00 */ bool mValid;
|
||||
/* 0x01 */ u8 padding_0x61[3];
|
||||
/* 0x04 */ u32 mCost;
|
||||
/* 0x08 */ u32 mSwitchCount;
|
||||
/* 0x0C */ OSTick mLastTick;
|
||||
/* 0x10 */ s32 mThreadId;
|
||||
};
|
||||
|
||||
JKRThread(u32 stack_size, int message_count, int param_3);
|
||||
JKRThread(JKRHeap* heap, u32 stack_size, int message_count, int param_4);
|
||||
JKRThread(OSThread* thread, int message_count);
|
||||
virtual ~JKRThread();
|
||||
|
||||
/* vt[03] */ virtual void* run();
|
||||
|
||||
void setCommon_mesgQueue(JKRHeap* heap, int message_count);
|
||||
void setCommon_heapSpecified(JKRHeap* heap, u32 stack_size, int param_3);
|
||||
/* vt[03] */ virtual void* run() { return NULL; }
|
||||
|
||||
OSThread* getThreadRecord() const { return mThreadRecord; }
|
||||
void* getStack() const { return mStackMemory; }
|
||||
@@ -122,9 +80,6 @@ typedef void (*JKRThreadSwitch_PostCallback)(OSThread* current, OSThread* next);
|
||||
class JKRThreadSwitch {
|
||||
public:
|
||||
JKRThreadSwitch(JKRHeap*);
|
||||
virtual void draw(JKRThreadName_* param_1, JUTConsole* param_2);
|
||||
virtual void draw(JKRThreadName_* param_1);
|
||||
virtual ~JKRThreadSwitch();
|
||||
|
||||
static JKRThreadSwitch* createManager(JKRHeap* heap);
|
||||
|
||||
@@ -145,13 +100,9 @@ private:
|
||||
/* 0x00 */ // vtable
|
||||
/* 0x04 */ JKRHeap* mHeap;
|
||||
/* 0x08 */ bool mSetNextHeap;
|
||||
/* 0x09 */ u8 field_0x9[3];
|
||||
/* 0x0C */ u32 field_0xC;
|
||||
/* 0x10 */ u32 field_0x10;
|
||||
/* 0x14 */ u8 field_0x14[4];
|
||||
/* 0x18 */ s64 field_0x18;
|
||||
/* 0x20 */ u32 field_0x20;
|
||||
/* 0x24 */ u32 field_0x24;
|
||||
|
||||
public:
|
||||
virtual ~JKRThreadSwitch() {}
|
||||
};
|
||||
|
||||
struct JKRTask {
|
||||
|
||||
@@ -3,85 +3,238 @@
|
||||
// Translation Unit: JKRArchivePri.cpp
|
||||
//
|
||||
|
||||
#include "JSystem/JKernel/JKRArchivePri.h"
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "MSL_C/MSL_Common/Src/ctype.h"
|
||||
#include "MSL_C/string.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
u32 JKRArchive::sCurrentDirID;
|
||||
|
||||
/* 802B8DFC-802B8E48 .text __ct__10JKRArchiveFv */
|
||||
JKRArchive::JKRArchive() {
|
||||
/* Nonmatching */
|
||||
mIsMounted = false;
|
||||
mMountDirection = MOUNT_DIRECTION_HEAD;
|
||||
}
|
||||
|
||||
/* 802B8E48-802B8EE8 .text __ct__10JKRArchiveFlQ210JKRArchive10EMountMode */
|
||||
JKRArchive::JKRArchive(long, JKRArchive::EMountMode) {
|
||||
/* Nonmatching */
|
||||
JKRArchive::JKRArchive(s32 entryNumber, JKRArchive::EMountMode mountMode) {
|
||||
mIsMounted = false;
|
||||
mMountMode = mountMode;
|
||||
mMountCount = 1;
|
||||
field_0x58 = 1;
|
||||
|
||||
mHeap = JKRHeap::findFromRoot(this);
|
||||
if (mHeap == NULL) {
|
||||
mHeap = JKRHeap::getCurrentHeap();
|
||||
}
|
||||
|
||||
mEntryNum = entryNumber;
|
||||
if (getCurrentVolume() == NULL) {
|
||||
setCurrentVolume(this);
|
||||
setCurrentDirID(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B8EE8-802B8F48 .text __dt__10JKRArchiveFv */
|
||||
JKRArchive::~JKRArchive() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
JKRArchive::~JKRArchive() {}
|
||||
|
||||
/* 802B8F48-802B8F94 .text isSameName__10JKRArchiveCFRQ210JKRArchive8CArcNameUlUs */
|
||||
void JKRArchive::isSameName(JKRArchive::CArcName&, unsigned long, unsigned short) const {
|
||||
/* Nonmatching */
|
||||
bool JKRArchive::isSameName(JKRArchive::CArcName& name, u32 nameOffset, u16 nameHash) const {
|
||||
u16 hash = name.getHash();
|
||||
if (hash != nameHash)
|
||||
return false;
|
||||
return strcmp(mStringTable + nameOffset, name.getString()) == 0;
|
||||
}
|
||||
|
||||
/* 802B8F94-802B8FD0 .text findResType__10JKRArchiveCFUl */
|
||||
void JKRArchive::findResType(unsigned long) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIDirEntry* JKRArchive::findResType(u32 type) const {
|
||||
SDIDirEntry* node = mNodes;
|
||||
u32 count = 0;
|
||||
while (count < mArcInfoBlock->num_nodes) {
|
||||
if (node->type == type) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node++;
|
||||
count++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B8FD0-802B90A8 .text findDirectory__10JKRArchiveCFPCcUl */
|
||||
void JKRArchive::findDirectory(const char*, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIDirEntry* JKRArchive::findDirectory(const char* name, u32 directoryId) const {
|
||||
if (name == NULL) {
|
||||
return mNodes + directoryId;
|
||||
}
|
||||
|
||||
CArcName arcName(&name, '/');
|
||||
SDIDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
return findDirectory(name, fileEntry->data_offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B90A8-802B9158 .text findTypeResource__10JKRArchiveCFUlPCc */
|
||||
void JKRArchive::findTypeResource(unsigned long, const char*) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findTypeResource(u32 type, const char* name) const {
|
||||
if (type) {
|
||||
CArcName arcName(name);
|
||||
SDIDirEntry* dirEntry = findResType(type);
|
||||
|
||||
if (dirEntry) {
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->getNameHash())) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B9158-802B9238 .text findFsResource__10JKRArchiveCFPCcUl */
|
||||
void JKRArchive::findFsResource(const char*, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findFsResource(const char* name, u32 directoryId) const {
|
||||
if (name) {
|
||||
CArcName arcName(&name, '/');
|
||||
SDIDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
return findFsResource(name, fileEntry->data_offset);
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
return fileEntry;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B9238-802B9260 .text findIdxResource__10JKRArchiveCFUl */
|
||||
void JKRArchive::findIdxResource(unsigned long) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findIdxResource(u32 fileIndex) const {
|
||||
if (fileIndex < mArcInfoBlock->num_file_entries) {
|
||||
return mFiles + fileIndex;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B9260-802B92E8 .text findNameResource__10JKRArchiveCFPCc */
|
||||
void JKRArchive::findNameResource(const char*) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findNameResource(const char* name) const {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
|
||||
CArcName arcName(name);
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->getNameHash())) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B92E8-802B9324 .text findPtrResource__10JKRArchiveCFPCv */
|
||||
void JKRArchive::findPtrResource(const void*) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findPtrResource(const void* resource) const {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (fileEntry->data == resource) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B9324-802B93A4 .text findIdResource__10JKRArchiveCFUs */
|
||||
void JKRArchive::findIdResource(unsigned short) const {
|
||||
/* Nonmatching */
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findIdResource(u16 id) const {
|
||||
if (id != 0xFFFF) {
|
||||
SDIFileEntry* fileEntry = mFiles + id;
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
return fileEntry;
|
||||
}
|
||||
|
||||
fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B93A4-802B9434 .text store__Q210JKRArchive8CArcNameFPCc */
|
||||
void JKRArchive::CArcName::store(const char*) {
|
||||
/* Nonmatching */
|
||||
void JKRArchive::CArcName::store(const char* name) {
|
||||
mHash = 0;
|
||||
s32 length = 0;
|
||||
while (*name) {
|
||||
s32 ch = tolower(*name);
|
||||
mHash = ch + mHash * 3;
|
||||
if (length < (s32)ARRAY_SIZE(mData)) {
|
||||
mData[length++] = ch;
|
||||
}
|
||||
name++;
|
||||
}
|
||||
|
||||
mLength = (u16)length;
|
||||
mData[length] = 0;
|
||||
}
|
||||
|
||||
/* 802B9434-802B94EC .text store__Q210JKRArchive8CArcNameFPCcc */
|
||||
void JKRArchive::CArcName::store(const char*, char) {
|
||||
/* Nonmatching */
|
||||
const char* JKRArchive::CArcName::store(const char* name, char endChar) {
|
||||
mHash = 0;
|
||||
s32 length = 0;
|
||||
while (*name && *name != endChar) {
|
||||
s32 lch = tolower((int)*name);
|
||||
mHash = lch + mHash * 3;
|
||||
if (length < (s32)ARRAY_SIZE(mData)) {
|
||||
mData[length++] = lch;
|
||||
}
|
||||
name++;
|
||||
}
|
||||
|
||||
mLength = (u16)length;
|
||||
mData[length] = 0;
|
||||
|
||||
if (*name == 0)
|
||||
return NULL;
|
||||
return name + 1;
|
||||
}
|
||||
|
||||
/* 802B94EC-802B9528 .text setExpandSize__10JKRArchiveFPQ210JKRArchive12SDIFileEntryUl */
|
||||
void JKRArchive::setExpandSize(JKRArchive::SDIFileEntry*, unsigned long) {
|
||||
/* Nonmatching */
|
||||
void JKRArchive::setExpandSize(SDIFileEntry* fileEntry, u32 expandSize) {
|
||||
int index = fileEntry - mFiles;
|
||||
if (!mExpandedSize || index >= mArcInfoBlock->num_file_entries)
|
||||
return;
|
||||
|
||||
mExpandedSize[index] = expandSize;
|
||||
}
|
||||
|
||||
/* 802B9528-802B9568 .text getExpandSize__10JKRArchiveCFPQ210JKRArchive12SDIFileEntry */
|
||||
void JKRArchive::getExpandSize(JKRArchive::SDIFileEntry*) const {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::getExpandSize(SDIFileEntry* fileEntry) const {
|
||||
int index = fileEntry - mFiles;
|
||||
if (!mExpandedSize || index >= mArcInfoBlock->num_file_entries)
|
||||
return 0;
|
||||
|
||||
return mExpandedSize[index];
|
||||
}
|
||||
|
||||
@@ -3,115 +3,368 @@
|
||||
// Translation Unit: JKRArchivePub.cpp
|
||||
//
|
||||
|
||||
#include "JSystem/JKernel/JKRArchivePub.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "JSystem/JKernel/JKRAramArchive.h"
|
||||
#include "JSystem/JKernel/JKRCompArchive.h"
|
||||
#include "JSystem/JKernel/JKRDvdArchive.h"
|
||||
#include "JSystem/JKernel/JKRFileFinder.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRMemArchive.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "dolphin/dvd/dvd.h"
|
||||
|
||||
/* 802B7FB4-802B8008 .text check_mount_already__10JKRArchiveFl */
|
||||
void JKRArchive::check_mount_already(long) {
|
||||
/* Nonmatching */
|
||||
JKRArchive* JKRArchive::check_mount_already(s32 entryNum) {
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
JKRArchive* archive = (JKRArchive*)iterator.getObject();
|
||||
if (archive->mEntryNum == entryNum) {
|
||||
archive->mMountCount++;
|
||||
return archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B8008-802B8064 .text mount__10JKRArchiveFPCcQ210JKRArchive10EMountModeP7JKRHeapQ210JKRArchive15EMountDirection */
|
||||
void JKRArchive::mount(const char*, JKRArchive::EMountMode, JKRHeap*, JKRArchive::EMountDirection) {
|
||||
/* Nonmatching */
|
||||
JKRArchive* JKRArchive::mount(const char* path, JKRArchive::EMountMode mountMode, JKRHeap* heap, JKRArchive::EMountDirection mountDirection) {
|
||||
s32 entryNum = DVDConvertPathToEntrynum(path);
|
||||
if (entryNum < 0)
|
||||
return NULL;
|
||||
|
||||
return mount(entryNum, mountMode, heap, mountDirection);
|
||||
}
|
||||
|
||||
/* 802B8064-802B81D0 .text mount__10JKRArchiveFlQ210JKRArchive10EMountModeP7JKRHeapQ210JKRArchive15EMountDirection */
|
||||
void JKRArchive::mount(long, JKRArchive::EMountMode, JKRHeap*, JKRArchive::EMountDirection) {
|
||||
/* Nonmatching */
|
||||
JKRArchive* JKRArchive::mount(s32 entryNum, JKRArchive::EMountMode mountMode, JKRHeap* heap, JKRArchive::EMountDirection mountDirection) {
|
||||
JKRArchive* archive = check_mount_already(entryNum);
|
||||
if (archive != NULL) {
|
||||
return archive;
|
||||
} else {
|
||||
int alignment;
|
||||
if (mountDirection == JKRArchive::MOUNT_DIRECTION_HEAD) {
|
||||
alignment = 4;
|
||||
} else {
|
||||
alignment = -4;
|
||||
}
|
||||
|
||||
JKRArchive* archive;
|
||||
switch (mountMode) {
|
||||
case JKRArchive::MOUNT_MEM:
|
||||
archive = new (heap, alignment) JKRMemArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_ARAM:
|
||||
archive = new (heap, alignment) JKRAramArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_DVD:
|
||||
archive = new (heap, alignment) JKRDvdArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_COMP:
|
||||
archive = new (heap, alignment) JKRCompArchive(entryNum, mountDirection);
|
||||
break;
|
||||
}
|
||||
|
||||
if (archive && archive->getMountMode() == JKRArchive::UNKNOWN_MOUNT_MODE) {
|
||||
delete archive;
|
||||
archive = NULL;
|
||||
}
|
||||
|
||||
return archive;
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B81D0-802B8258 .text becomeCurrent__10JKRArchiveFPCc */
|
||||
void JKRArchive::becomeCurrent(const char*) {
|
||||
/* Nonmatching */
|
||||
bool JKRArchive::becomeCurrent(const char* path) {
|
||||
SDIDirEntry* dirEntry;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
if (*path == '\0')
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
bool found = dirEntry != NULL;
|
||||
if (found) {
|
||||
setCurrentVolume(this);
|
||||
setCurrentDirID(dirEntry - mNodes);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* 802B8258-802B82D0 .text getDirEntry__10JKRArchiveCFPQ210JKRArchive9SDirEntryUl */
|
||||
void JKRArchive::getDirEntry(JKRArchive::SDirEntry*, unsigned long) const {
|
||||
/* Nonmatching */
|
||||
bool JKRArchive::getDirEntry(SDirEntry* dirEntry, u32 index) const {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (!fileEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dirEntry->flags = fileEntry->getFlags();
|
||||
dirEntry->id = fileEntry->getFileID();
|
||||
dirEntry->name = mStringTable + fileEntry->getNameOffset();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 802B82D0-802B8380 .text getGlbResource__10JKRArchiveFUlPCcP10JKRArchive */
|
||||
void JKRArchive::getGlbResource(unsigned long, const char*, JKRArchive*) {
|
||||
/* Nonmatching */
|
||||
void* JKRArchive::getGlbResource(u32 param_0, const char* path, JKRArchive* archive) {
|
||||
void* resource = NULL;
|
||||
if (archive) {
|
||||
return archive->getResource(param_0, path);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
resource = iterator->getResource(param_0, path);
|
||||
if (resource)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
/* 802B8380-802B8450 .text getResource__10JKRArchiveFPCc */
|
||||
void JKRArchive::getResource(const char*) {
|
||||
/* Nonmatching */
|
||||
void* JKRArchive::getResource(const char* path) {
|
||||
JUT_ASSERT(285, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
if (*path == '/') {
|
||||
fileEntry = findFsResource(path + 1, 0);
|
||||
} else {
|
||||
fileEntry = findFsResource(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B8450-802B8528 .text getResource__10JKRArchiveFUlPCc */
|
||||
void JKRArchive::getResource(unsigned long, const char*) {
|
||||
/* Nonmatching */
|
||||
void* JKRArchive::getResource(u32 type, const char* path) {
|
||||
JUT_ASSERT(332, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
if (type == 0 || type == '????') {
|
||||
fileEntry = findNameResource(path);
|
||||
} else {
|
||||
fileEntry = findTypeResource(type, path);
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B8528-802B85F0 .text readTypeResource__10JKRArchiveFPvUlUlPCcP10JKRArchive */
|
||||
void JKRArchive::readTypeResource(void*, unsigned long, unsigned long, const char*, JKRArchive*) {
|
||||
// missing instructions
|
||||
void JKRArchive::readTypeResource(void* buffer, u32 bufferSize, u32 type, const char* path, JKRArchive* archive) {
|
||||
/* Nonmatching */
|
||||
if (archive) {
|
||||
archive->readResource(buffer, bufferSize, type, path);
|
||||
return;
|
||||
}
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); iterator++) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
u32 result = iterator->readResource(buffer, bufferSize, type, path);
|
||||
if (result != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B85F0-802B86DC .text readResource__10JKRArchiveFPvUlUlPCc */
|
||||
void JKRArchive::readResource(void*, unsigned long, unsigned long, const char*) {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u32 type, const char* path) {
|
||||
JUT_ASSERT(491, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
if (type == 0 || type == '????') {
|
||||
fileEntry = findNameResource(path);
|
||||
} else {
|
||||
fileEntry = findTypeResource(type, path);
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B86DC-802B87C0 .text readResource__10JKRArchiveFPvUlPCc */
|
||||
void JKRArchive::readResource(void*, unsigned long, const char*) {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, const char* path) {
|
||||
JUT_ASSERT(537, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
if (*path == '/') {
|
||||
fileEntry = findFsResource(path + 1, 0);
|
||||
} else {
|
||||
fileEntry = findFsResource(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B87C0-802B8878 .text readIdxResource__10JKRArchiveFPvUlUl */
|
||||
void JKRArchive::readIdxResource(void*, unsigned long, unsigned long) {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::readIdxResource(void* buffer, u32 bufferSize, u32 index) {
|
||||
JUT_ASSERT(593, isMounted());
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B8878-802B8930 .text readResource__10JKRArchiveFPvUlUs */
|
||||
void JKRArchive::readResource(void*, unsigned long, unsigned short) {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u16 id) {
|
||||
JUT_ASSERT(627, isMounted());
|
||||
SDIFileEntry* fileEntry = findIdResource(id);
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B8930-802B89B8 .text removeResourceAll__10JKRArchiveFv */
|
||||
void JKRArchive::removeResourceAll() {
|
||||
/* Nonmatching */
|
||||
if (mArcInfoBlock && mMountMode != MOUNT_MEM) {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (fileEntry->data) {
|
||||
JKRFreeToHeap(mHeap, fileEntry->data);
|
||||
fileEntry->data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B89B8-802B8A54 .text removeResource__10JKRArchiveFPv */
|
||||
void JKRArchive::removeResource(void*) {
|
||||
/* Nonmatching */
|
||||
bool JKRArchive::removeResource(void* resource) {
|
||||
JUT_ASSERT(687, resource != 0);
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return false;
|
||||
|
||||
fileEntry->data = NULL;
|
||||
JKRFreeToHeap(mHeap, resource);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 802B8A54-802B8AE4 .text detachResource__10JKRArchiveFPv */
|
||||
void JKRArchive::detachResource(void*) {
|
||||
/* Nonmatching */
|
||||
bool JKRArchive::detachResource(void* resource) {
|
||||
JUT_ASSERT(719, resource != 0);
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return false;
|
||||
|
||||
fileEntry->data = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 802B8AE4-802B8B6C .text getResSize__10JKRArchiveCFPCv */
|
||||
void JKRArchive::getResSize(const void*) const {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::getResSize(const void* resource) const {
|
||||
JUT_ASSERT(746, resource != 0);
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return -1;
|
||||
|
||||
return fileEntry->data_size;
|
||||
}
|
||||
|
||||
/* 802B8B6C-802B8BF0 .text countResource__10JKRArchiveCFUl */
|
||||
void JKRArchive::countResource(unsigned long) const {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::countResource(u32 type) const {
|
||||
SDIDirEntry* dirEntry = findResType(type);
|
||||
if (dirEntry) {
|
||||
int count = 0;
|
||||
for (int i = dirEntry->first_file_index; i < dirEntry->first_file_index + dirEntry->num_entries; i++) {
|
||||
if (mFiles[i].isUnknownFlag1()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B8BF0-802B8C50 .text countFile__10JKRArchiveCFPCc */
|
||||
void JKRArchive::countFile(const char*) const {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::countFile(const char* path) const {
|
||||
SDIDirEntry* dirEntry;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
if (*path == '\0')
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
return dirEntry->num_entries;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 802B8C50-802B8CFC .text getFirstFile__10JKRArchiveCFPCc */
|
||||
void JKRArchive::getFirstFile(const char*) const {
|
||||
/* Nonmatching */
|
||||
JKRFileFinder* JKRArchive::getFirstFile(const char* path) const {
|
||||
SDIDirEntry* dirEntry;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
if (*path == '\0')
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
return new (JKRHeap::sSystemHeap, 0) JKRArcFinder((JKRArchive*)this, dirEntry->first_file_index, dirEntry->num_entries);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 802B8CFC-802B8DC4 .text getFirstResource__10JKRArchiveCFUl */
|
||||
void JKRArchive::getFirstResource(unsigned long) const {
|
||||
/* Nonmatching */
|
||||
JKRArcFinder* JKRArchive::getFirstResource(u32 type) const {
|
||||
SDIDirEntry* dirEntry = findResType(type);
|
||||
if (dirEntry && (getFileAttribute(dirEntry->first_file_index) & 1)) {
|
||||
return new (JKRHeap::sSystemHeap, 0) JKRArcFinder((JKRArchive*)this, dirEntry->first_file_index, countResource(type));
|
||||
}
|
||||
return new (JKRHeap::sSystemHeap, 0) JKRArcFinder((JKRArchive*)this, 0, 0);
|
||||
}
|
||||
|
||||
/* 802B8DC4-802B8DFC .text getFileAttribute__10JKRArchiveCFUl */
|
||||
void JKRArchive::getFileAttribute(unsigned long) const {
|
||||
/* Nonmatching */
|
||||
u32 JKRArchive::getFileAttribute(u32 index) const {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
return fileEntry->getFlags();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,54 +4,157 @@
|
||||
//
|
||||
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "MSL_C/string.h"
|
||||
#include "MSL_C/MSL_Common/Src/ctype.h"
|
||||
#include "global.h"
|
||||
|
||||
JKRFileLoader* JKRFileLoader::sCurrentVolume;
|
||||
JSUList<JKRFileLoader> JKRFileLoader::sVolumeList;
|
||||
|
||||
/* 802B6770-802B67C8 .text __ct__13JKRFileLoaderFv */
|
||||
JKRFileLoader::JKRFileLoader() {
|
||||
/* Nonmatching */
|
||||
JKRFileLoader::JKRFileLoader() : mFileLoaderLink(this) {
|
||||
mVolumeName = NULL;
|
||||
mVolumeType = 0;
|
||||
mMountCount = 0;
|
||||
}
|
||||
|
||||
/* 802B67C8-802B6854 .text __dt__13JKRFileLoaderFv */
|
||||
JKRFileLoader::~JKRFileLoader() {
|
||||
/* Nonmatching */
|
||||
if (getCurrentVolume() == this) {
|
||||
setCurrentVolume(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B6854-802B68A4 .text unmount__13JKRFileLoaderFv */
|
||||
void JKRFileLoader::unmount() {
|
||||
/* Nonmatching */
|
||||
s32 count = mMountCount;
|
||||
if (mMountCount != 0) {
|
||||
count--;
|
||||
mMountCount = count;
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B68A4-802B68F0 .text getGlbResource__13JKRFileLoaderFPCc */
|
||||
void JKRFileLoader::getGlbResource(const char*) {
|
||||
/* Nonmatching */
|
||||
void* JKRFileLoader::getGlbResource(const char* name) {
|
||||
const char* name_reference[1];
|
||||
name_reference[0] = name;
|
||||
|
||||
JKRFileLoader* fileLoader = findVolume(name_reference);
|
||||
void* resource;
|
||||
if (fileLoader == NULL) {
|
||||
resource = NULL;
|
||||
} else {
|
||||
resource = fileLoader->getResource(name_reference[0]);
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
/* 802B68F0-802B6988 .text getGlbResource__13JKRFileLoaderFPCcP13JKRFileLoader */
|
||||
void JKRFileLoader::getGlbResource(const char*, JKRFileLoader*) {
|
||||
/* Nonmatching */
|
||||
void* JKRFileLoader::getGlbResource(const char* name, JKRFileLoader* fileLoader) {
|
||||
void* resource = NULL;
|
||||
if (fileLoader) {
|
||||
return fileLoader->getResource(0, name);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
resource = iterator->getResource(0, name);
|
||||
if (resource)
|
||||
break;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
/* 802B6988-802B6A20 .text removeResource__13JKRFileLoaderFPvP13JKRFileLoader */
|
||||
void JKRFileLoader::removeResource(void*, JKRFileLoader*) {
|
||||
/* Nonmatching */
|
||||
bool JKRFileLoader::removeResource(void* resource, JKRFileLoader* fileLoader) {
|
||||
if (fileLoader) {
|
||||
return fileLoader->removeResource(resource);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->removeResource(resource)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 802B6A20-802B6AB8 .text detachResource__13JKRFileLoaderFPvP13JKRFileLoader */
|
||||
void JKRFileLoader::detachResource(void*, JKRFileLoader*) {
|
||||
/* Nonmatching */
|
||||
bool JKRFileLoader::detachResource(void* resource, JKRFileLoader* fileLoader) {
|
||||
if (fileLoader) {
|
||||
return fileLoader->detachResource(resource);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->detachResource(resource)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 802B6AB8-802B6B44 .text findVolume__13JKRFileLoaderFPPCc */
|
||||
void JKRFileLoader::findVolume(const char**) {
|
||||
/* Nonmatching */
|
||||
JKRFileLoader* JKRFileLoader::findVolume(const char** volumeName) {
|
||||
if (*volumeName[0] != '/') {
|
||||
return getCurrentVolume();
|
||||
}
|
||||
|
||||
char volumeNameBuffer[0x101];
|
||||
*volumeName = fetchVolumeName(volumeNameBuffer, ARRAY_SIZE(volumeNameBuffer), *volumeName);
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (strcmp(volumeNameBuffer, iterator->mVolumeName) == 0) {
|
||||
return iterator.getObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char rootPath[2] = "/";
|
||||
|
||||
/* 802B6B44-802B6C20 .text fetchVolumeName__13JKRFileLoaderFPclPCc */
|
||||
void JKRFileLoader::fetchVolumeName(char*, long, const char*) {
|
||||
/* Nonmatching */
|
||||
}
|
||||
const char* JKRFileLoader::fetchVolumeName(char* buffer, long bufferSize, const char* path) {
|
||||
if (strcmp(path, "/") == 0) {
|
||||
strcpy(buffer, rootPath);
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
/* 802B6C64-802B6CB8 .text __dt__24JSUList<13JKRFileLoader>Fv */
|
||||
JSUList<JKRFileLoader>::~JSUList() {
|
||||
/* Nonmatching */
|
||||
path++;
|
||||
while (*path != 0 && *path != '/') {
|
||||
if (1 < bufferSize) {
|
||||
int lower_char;
|
||||
int ch = (int)*path;
|
||||
if (ch == -1) {
|
||||
lower_char = -1;
|
||||
} else {
|
||||
lower_char = __lower_map[ch & 0xFF];
|
||||
}
|
||||
|
||||
*buffer = lower_char;
|
||||
buffer++;
|
||||
bufferSize--;
|
||||
}
|
||||
path++;
|
||||
}
|
||||
|
||||
*buffer = '\0';
|
||||
if (*path == '\0') {
|
||||
path = rootPath;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -4,54 +4,135 @@
|
||||
//
|
||||
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
JSUList<JKRThread> JKRThread::sThreadList;
|
||||
JKRThreadSwitch* JKRThreadSwitch::sManager;
|
||||
OSThread* preEnd;
|
||||
JKRThreadSwitch_PreCallback JKRThreadSwitch::mUserPreCallback;
|
||||
JKRThreadSwitch_PostCallback JKRThreadSwitch::mUserPostCallback;
|
||||
|
||||
/* 802B3D1C-802B3E38 .text __ct__9JKRThreadFUlii */
|
||||
JKRThread::JKRThread(unsigned long, int, int) {
|
||||
/* Nonmatching */
|
||||
JKRThread::JKRThread(u32 stack_size, int message_count, int param_3) : mThreadListLink(this) {
|
||||
mHeap = JKRHeap::findFromRoot(this);
|
||||
if (mHeap == NULL) {
|
||||
mHeap = JKRGetSystemHeap();
|
||||
}
|
||||
|
||||
mStackSize = stack_size & 0xffffffe0;
|
||||
mStackMemory = JKRAllocFromHeap(mHeap, mStackSize, 0x20);
|
||||
mThreadRecord = (OSThread*)JKRAllocFromHeap(mHeap, sizeof(OSThread), 0x20);
|
||||
|
||||
void* stackBase = (void*)((int)mStackMemory + mStackSize);
|
||||
OSCreateThread(mThreadRecord, start, this, stackBase, mStackSize, param_3, 1);
|
||||
|
||||
mMessageCount = message_count;
|
||||
mMessages = (OSMessage*)JKRAllocFromHeap(mHeap, mMessageCount * sizeof(OSMessage), 0);
|
||||
|
||||
OSInitMessageQueue(&mMessageQueue, mMessages, mMessageCount);
|
||||
getList().append(&mThreadListLink);
|
||||
|
||||
mCurrentHeap = NULL;
|
||||
mCurrentHeapError = NULL;
|
||||
}
|
||||
|
||||
/* 802B3E38-802B3EFC .text __ct__9JKRThreadFP8OSThreadi */
|
||||
JKRThread::JKRThread(OSThread*, int) {
|
||||
/* Nonmatching */
|
||||
JKRThread::JKRThread(OSThread* thread, int message_count) : mThreadListLink(this) {
|
||||
mHeap = NULL;
|
||||
mThreadRecord = thread;
|
||||
mStackSize = (u32)thread->stack_end - (u32)thread->stack_base;
|
||||
mStackMemory = thread->stack_base;
|
||||
|
||||
mMessageCount = message_count;
|
||||
mMessages = (OSMessage*)JKRGetSystemHeap()->alloc(mMessageCount * sizeof(OSMessage), 4);
|
||||
|
||||
OSInitMessageQueue(&mMessageQueue, mMessages, mMessageCount);
|
||||
getList().append(&mThreadListLink);
|
||||
|
||||
mCurrentHeap = NULL;
|
||||
mCurrentHeapError = NULL;
|
||||
}
|
||||
|
||||
/* 802B3EFC-802B3FD4 .text __dt__9JKRThreadFv */
|
||||
JKRThread::~JKRThread() {
|
||||
/* Nonmatching */
|
||||
getList().remove(&mThreadListLink);
|
||||
|
||||
if (mHeap) {
|
||||
BOOL result = OSIsThreadTerminated(mThreadRecord);
|
||||
if (result == FALSE) {
|
||||
OSDetachThread(mThreadRecord);
|
||||
OSCancelThread(mThreadRecord);
|
||||
}
|
||||
JKRFreeToHeap(mHeap, mStackMemory);
|
||||
JKRFreeToHeap(mHeap, mThreadRecord);
|
||||
}
|
||||
i_JKRFree(mMessages);
|
||||
}
|
||||
|
||||
/* 802B3FD4-802B4000 .text start__9JKRThreadFPv */
|
||||
void JKRThread::start(void*) {
|
||||
/* Nonmatching */
|
||||
void* JKRThread::start(void* param) {
|
||||
JKRThread* thread = (JKRThread*)param;
|
||||
return thread->run();
|
||||
}
|
||||
|
||||
/* 802B4000-802B4050 .text __ct__15JKRThreadSwitchFP7JKRHeap */
|
||||
JKRThreadSwitch::JKRThreadSwitch(JKRHeap*) {
|
||||
/* Nonmatching */
|
||||
JKRThreadSwitch::JKRThreadSwitch(JKRHeap* param_0) {
|
||||
mHeap = param_0;
|
||||
OSSetSwitchThreadCallback(JKRThreadSwitch::callback);
|
||||
mSetNextHeap = true;
|
||||
}
|
||||
|
||||
/* 802B4050-802B40EC .text createManager__15JKRThreadSwitchFP7JKRHeap */
|
||||
void JKRThreadSwitch::createManager(JKRHeap*) {
|
||||
/* Nonmatching */
|
||||
JKRThreadSwitch* JKRThreadSwitch::createManager(JKRHeap* heap) {
|
||||
JUT_ASSERT(184, sManager == 0);
|
||||
|
||||
if (!heap) {
|
||||
heap = JKRGetCurrentHeap();
|
||||
}
|
||||
|
||||
sManager = new (heap, 0) JKRThreadSwitch(heap);
|
||||
return sManager;
|
||||
}
|
||||
|
||||
/* 802B40EC-802B41DC .text callback__15JKRThreadSwitchFP8OSThreadP8OSThread */
|
||||
void JKRThreadSwitch::callback(OSThread*, OSThread*) {
|
||||
/* Nonmatching */
|
||||
void JKRThreadSwitch::callback(OSThread* current, OSThread* next) {
|
||||
if (mUserPreCallback) {
|
||||
(*mUserPreCallback)(current, next);
|
||||
}
|
||||
|
||||
if (!current && !next) {
|
||||
preEnd = current;
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
if (!current && !next) {
|
||||
current = preEnd;
|
||||
preEnd = NULL;
|
||||
}
|
||||
|
||||
JSUList<JKRThread>& threadList = JKRThread::getList();
|
||||
JSUListIterator<JKRThread> iterator;
|
||||
for (iterator = threadList.getFirst(); iterator != threadList.getEnd(); ++iterator) {
|
||||
JKRThread* thread = iterator.getObject();
|
||||
|
||||
if (thread->getThreadRecord() == current) {
|
||||
thread->setCurrentHeap(JKRHeap::getCurrentHeap());
|
||||
}
|
||||
|
||||
if (thread->getThreadRecord() == next) {
|
||||
if (sManager->mSetNextHeap) {
|
||||
thread->getCurrentHeap()->becomeCurrentHeap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mUserPostCallback) {
|
||||
(*mUserPostCallback)(current, next);
|
||||
}
|
||||
}
|
||||
|
||||
/* 802B41DC-802B41E4 .text run__9JKRThreadFv */
|
||||
void JKRThread::run() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802B41E4-802B422C .text __dt__15JKRThreadSwitchFv */
|
||||
JKRThreadSwitch::~JKRThreadSwitch() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
|
||||
/* 802B4270-802B42C4 .text __dt__19JSUList<9JKRThread>Fv */
|
||||
JSUList<JKRThread>::~JSUList() {
|
||||
/* Nonmatching */
|
||||
}
|
||||
static void dummy() {
|
||||
OSReport("Cannot create JKRTask Manager.");
|
||||
OSReport("sManager != 0");
|
||||
}
|
||||
Reference in New Issue
Block a user