mirror of
https://github.com/SMGCommunity/Petari.git
synced 2024-11-28 16:00:22 +00:00
Change to spaces
This commit is contained in:
parent
a43a4f4a8f
commit
98c9e0a3a1
@ -330,9 +330,9 @@ __sinit_\JKRDvdAramRipper_cpp,JKRDvdAramRipper.o,JKernel.a,false
|
||||
__dt__18JSUFileInputStreamFv,JKRDvdAramRipper.o,JKernel.a,false
|
||||
__ct__23JSUList<12JKRADCommand>Fv,JKRDvdAramRipper.o,JKernel.a,false
|
||||
__dt__23JSUList<12JKRADCommand>Fv,JKRDvdAramRipper.o,JKernel.a,false
|
||||
create__9JKRDecompFl,JKRDecomp.o,JKernel.a,false
|
||||
__ct__9JKRDecompFl,JKRDecomp.o,JKernel.a,false
|
||||
__dt__9JKRDecompFv,JKRDecomp.o,JKernel.a,false
|
||||
create__9JKRDecompFl,JKRDecomp.o,JKernel.a,true
|
||||
__ct__9JKRDecompFl,JKRDecomp.o,JKernel.a,true
|
||||
__dt__9JKRDecompFv,JKRDecomp.o,JKernel.a,true
|
||||
run__9JKRDecompFv,JKRDecomp.o,JKernel.a,false
|
||||
prepareCommand__9JKRDecompFPUcPUcUlUlPFUl_v,JKRDecomp.o,JKernel.a,false
|
||||
sendCommand__9JKRDecompFP16JKRDecompCommand,JKRDecomp.o,JKernel.a,false
|
||||
|
|
@ -4,16 +4,16 @@
|
||||
|
||||
class JKRAramArchive : public JKRArchive {
|
||||
public:
|
||||
JKRAramArchive(long, EMountDirection);
|
||||
virtual ~JKRAramArchive(void);
|
||||
JKRAramArchive(long, EMountDirection);
|
||||
virtual ~JKRAramArchive(void);
|
||||
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
|
||||
void open(long);
|
||||
void fetchResource_subroutine(unsigned long, unsigned long, unsigned char *, unsigned long, int);
|
||||
void fetchResource_subroutine(unsigned long, unsigned long, JKRHeap *, int, unsigned char **);
|
||||
void open(long);
|
||||
void fetchResource_subroutine(unsigned long, unsigned long, unsigned char *, unsigned long, int);
|
||||
void fetchResource_subroutine(unsigned long, unsigned long, JKRHeap *, int, unsigned char **);
|
||||
|
||||
u8 _64[8];
|
||||
u8 _64[8];
|
||||
};
|
@ -106,8 +106,8 @@ public:
|
||||
virtual ~JKRArchive();
|
||||
|
||||
virtual bool becomeCurrent(const char *);
|
||||
virtual void* getResource(const char *);
|
||||
virtual void* getResource(unsigned long, const char *);
|
||||
virtual void *getResource(const char *);
|
||||
virtual void *getResource(unsigned long, const char *);
|
||||
virtual u32 readResource(void *, unsigned long, const char *);
|
||||
virtual u32 readResource(void *, unsigned long, unsigned long, const char *);
|
||||
virtual void removeResourceAll();
|
||||
|
@ -4,16 +4,16 @@
|
||||
|
||||
class JKRCompArchive : public JKRArchive {
|
||||
public:
|
||||
JKRCompArchive(long, EMountDirection);
|
||||
virtual ~JKRCompArchive(void);
|
||||
JKRCompArchive(long, EMountDirection);
|
||||
virtual ~JKRCompArchive(void);
|
||||
|
||||
virtual void removeResourceAll();
|
||||
virtual bool removeResource(void *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
virtual void removeResourceAll();
|
||||
virtual bool removeResource(void *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
|
||||
void open(long);
|
||||
void open(long);
|
||||
|
||||
u8 _64[0x1C];
|
||||
u8 _64[0x1C];
|
||||
};
|
35
include/JSystem/JKernel/JKRDecomp.h
Normal file
35
include/JSystem/JKernel/JKRDecomp.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
|
||||
enum EJKRCompression {
|
||||
JKR_COMPRESSION_NONE = 0,
|
||||
JKR_COMPRESSION_SZP = 1,
|
||||
JKR_COMPRESSION_SZS = 2,
|
||||
};
|
||||
|
||||
class JKRDecompCommand {
|
||||
public:
|
||||
JKRDecompCommand();
|
||||
};
|
||||
|
||||
class JKRDecomp : public JKRThread {
|
||||
public:
|
||||
JKRDecomp(long);
|
||||
virtual ~JKRDecomp();
|
||||
|
||||
virtual s32 run();
|
||||
|
||||
static JKRDecomp *create(long);
|
||||
|
||||
void prepareCommand(unsigned char *, unsigned char *, unsigned long, unsigned long, void(unsigned long));
|
||||
void sendCommand(JKRDecompCommand *);
|
||||
void sync(JKRDecompCommand *, int);
|
||||
void orderSync(unsigned char *, unsigned char *, unsigned long, unsigned long);
|
||||
void decode(unsigned char *, unsigned char *, unsigned long, unsigned long);
|
||||
void decodeSZP(unsigned char *, unsigned char *, unsigned long, unsigned long);
|
||||
void decodeSZS(unsigned char *, unsigned char *, unsigned long, unsigned long);
|
||||
EJKRCompression checkCompressed(unsigned char *);
|
||||
|
||||
static JKRDecomp *sDecompInstance; // _806B71D8
|
||||
};
|
@ -9,8 +9,6 @@ public:
|
||||
JKRDisposer();
|
||||
virtual ~JKRDisposer();
|
||||
|
||||
virtual void unmount() = 0;
|
||||
|
||||
JKRHeap* mHeap; // _4
|
||||
JKRHeap *mHeap; // _4
|
||||
JSULink<JKRDisposer> mLink; // _8
|
||||
};
|
@ -4,16 +4,16 @@
|
||||
|
||||
class JKRDvdArchive : public JKRArchive {
|
||||
public:
|
||||
JKRDvdArchive(long, EMountDirection);
|
||||
virtual ~JKRDvdArchive();
|
||||
JKRDvdArchive(long, EMountDirection);
|
||||
virtual ~JKRDvdArchive();
|
||||
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
|
||||
void open(long);
|
||||
void fetchResource_subroutine(long, unsigned long, unsigned long, unsigned char *, unsigned long, int, int);
|
||||
void fetchResource_subroutine(long, unsigned long, unsigned long, JKRHeap *, int, int, unsigned char **);
|
||||
void open(long);
|
||||
void fetchResource_subroutine(long, unsigned long, unsigned long, unsigned char *, unsigned long, int, int);
|
||||
void fetchResource_subroutine(long, unsigned long, unsigned long, JKRHeap *, int, int, unsigned char **);
|
||||
|
||||
u8 _64[8];
|
||||
u8 _64[8];
|
||||
};
|
@ -6,30 +6,30 @@ class JKRArchive;
|
||||
|
||||
class JKRFileFinder {
|
||||
public:
|
||||
char *mName; // _0
|
||||
s32 mDirIndex; // _4
|
||||
u16 mFileID; // _8
|
||||
u16 mFileFlag; // _A
|
||||
char *mName; // _0
|
||||
s32 mDirIndex; // _4
|
||||
u16 mFileID; // _8
|
||||
u16 mFileFlag; // _A
|
||||
|
||||
JKRFileFinder();
|
||||
virtual ~JKRFileFinder();
|
||||
JKRFileFinder();
|
||||
virtual ~JKRFileFinder();
|
||||
|
||||
virtual bool findNextFile() = 0;
|
||||
virtual bool findNextFile() = 0;
|
||||
|
||||
bool mHasMoreFiles; // _10
|
||||
bool mFileIsFolder; // _11
|
||||
u8 _12[2];
|
||||
bool mHasMoreFiles; // _10
|
||||
bool mFileIsFolder; // _11
|
||||
u8 _12[2];
|
||||
};
|
||||
|
||||
class JKRArcFinder : public JKRFileFinder {
|
||||
public:
|
||||
JKRArcFinder(JKRArchive *, long, long);
|
||||
virtual ~JKRArcFinder();
|
||||
JKRArcFinder(JKRArchive *, long, long);
|
||||
virtual ~JKRArcFinder();
|
||||
|
||||
virtual bool findNextFile();
|
||||
virtual bool findNextFile();
|
||||
|
||||
JKRArchive *mArchive; // _14
|
||||
s32 mFirstIndex; // _18
|
||||
s32 mLastIndex; // _1C
|
||||
s32 mCurrentIndex; // _20
|
||||
JKRArchive *mArchive; // _14
|
||||
s32 mFirstIndex; // _18
|
||||
s32 mLastIndex; // _1C
|
||||
s32 mCurrentIndex; // _20
|
||||
};
|
@ -6,14 +6,14 @@ class JKRArcFinder;
|
||||
|
||||
class JKRFileLoader : public JKRDisposer {
|
||||
public:
|
||||
JKRFileLoader();
|
||||
JKRFileLoader();
|
||||
virtual ~JKRFileLoader();
|
||||
|
||||
virtual void unmount();
|
||||
|
||||
virtual bool becomeCurrent(const char *) = 0;
|
||||
virtual void* getResource(const char *) = 0;
|
||||
virtual void* getResource(unsigned long, const char *) = 0;
|
||||
virtual void *getResource(const char *) = 0;
|
||||
virtual void *getResource(unsigned long, const char *) = 0;
|
||||
virtual u32 readResource(void *, unsigned long, const char *) = 0;
|
||||
virtual u32 readResource(void *, unsigned long, unsigned long, const char *) = 0;
|
||||
virtual void removeResourceAll() = 0;
|
||||
|
@ -8,21 +8,21 @@ enum JKRMemBreakFlag {
|
||||
|
||||
class JKRMemArchive : public JKRArchive {
|
||||
public:
|
||||
JKRMemArchive();
|
||||
JKRMemArchive(long, EMountDirection);
|
||||
virtual ~JKRMemArchive();
|
||||
JKRMemArchive();
|
||||
JKRMemArchive(long, EMountDirection);
|
||||
virtual ~JKRMemArchive();
|
||||
|
||||
virtual void removeResourceAll();
|
||||
virtual bool removeResource(void *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
virtual void removeResourceAll();
|
||||
virtual bool removeResource(void *);
|
||||
virtual s32 getExpandedResSize(const void *) const;
|
||||
virtual void *fetchResource(SDIFileEntry *, unsigned long *);
|
||||
virtual void fetchResource(void *, unsigned long, SDIFileEntry *, unsigned long *);
|
||||
|
||||
void fixedInit(long);
|
||||
void mountFixed(void *, JKRMemBreakFlag);
|
||||
void open(long, EMountDirection);
|
||||
void open(void *, JKRMemBreakFlag);
|
||||
void fetchResource_subroutine(unsigned char *, unsigned long, unsigned char *, unsigned long, int);
|
||||
void fixedInit(long);
|
||||
void mountFixed(void *, JKRMemBreakFlag);
|
||||
void open(long, EMountDirection);
|
||||
void open(void *, JKRMemBreakFlag);
|
||||
void fetchResource_subroutine(unsigned char *, unsigned long, unsigned char *, unsigned long, int);
|
||||
|
||||
u8 _64[12];
|
||||
u8 _64[12];
|
||||
};
|
@ -24,6 +24,8 @@ public:
|
||||
u32 _10;
|
||||
};
|
||||
|
||||
JKRThread(unsigned long, int, int);
|
||||
|
||||
virtual ~JKRThread();
|
||||
virtual s32 run();
|
||||
|
||||
|
@ -6,75 +6,75 @@
|
||||
#ifdef NON_MATCHING
|
||||
// tolower() is inlined
|
||||
const char *JKRArchive::CArcName::store(const char *pName) {
|
||||
mHash = 0;
|
||||
u32 length = 0;
|
||||
mHash = 0;
|
||||
u32 length = 0;
|
||||
|
||||
for (; *pName != 0; pName++) {
|
||||
char lowerChar = tolower(*pName);
|
||||
for (; *pName != 0; pName++) {
|
||||
char lowerChar = tolower(*pName);
|
||||
|
||||
mHash = lowerChar + mHash * 3;
|
||||
mHash = lowerChar + mHash * 3;
|
||||
|
||||
if (length < MAX_NAME_LENGTH) {
|
||||
mName[length++] = lowerChar;
|
||||
}
|
||||
}
|
||||
if (length < MAX_NAME_LENGTH) {
|
||||
mName[length++] = lowerChar;
|
||||
}
|
||||
}
|
||||
|
||||
mLength = static_cast<u16>(length);
|
||||
mName[length] = 0;
|
||||
mLength = static_cast<u16>(length);
|
||||
mName[length] = 0;
|
||||
|
||||
return &mLength[length];
|
||||
return &mLength[length];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// tolower() is inlined
|
||||
const char *JKRArchive::CArcName::store(const char *pName, char stopChar) {
|
||||
mHash = 0;
|
||||
u32 length = 0;
|
||||
mHash = 0;
|
||||
u32 length = 0;
|
||||
|
||||
for (; *pName != stopChar; pName++) {
|
||||
char lowerChar = tolower(*pName);
|
||||
for (; *pName != stopChar; pName++) {
|
||||
char lowerChar = tolower(*pName);
|
||||
|
||||
mHash = lowerChar + mHash * 3;
|
||||
mHash = lowerChar + mHash * 3;
|
||||
|
||||
if (length < MAX_NAME_LENGTH) {
|
||||
mName[length++] = lowerChar;
|
||||
}
|
||||
}
|
||||
if (length < MAX_NAME_LENGTH) {
|
||||
mName[length++] = lowerChar;
|
||||
}
|
||||
}
|
||||
|
||||
mLength = static_cast<u16>(length);
|
||||
mName[length] = 0;
|
||||
mLength = static_cast<u16>(length);
|
||||
mName[length] = 0;
|
||||
|
||||
if (*pName == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (*pName == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pName + 1;
|
||||
return pName + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
JKRArchive::JKRArchive() {
|
||||
_30 = false;
|
||||
_60 = 1;
|
||||
_30 = false;
|
||||
_60 = 1;
|
||||
}
|
||||
|
||||
JKRArchive::JKRArchive(long a1, EMountMode mountMode) {
|
||||
_30 = false;
|
||||
mMountMode = mountMode;
|
||||
_34 = 1;
|
||||
_58 = 1;
|
||||
mHeap = JKRHeap::findFromRoot(this);
|
||||
_30 = false;
|
||||
mMountMode = mountMode;
|
||||
_34 = 1;
|
||||
_58 = 1;
|
||||
mHeap = JKRHeap::findFromRoot(this);
|
||||
|
||||
if (mHeap == NULL) {
|
||||
mHeap = JKRHeap::sCurrentHeap;
|
||||
}
|
||||
if (mHeap == NULL) {
|
||||
mHeap = JKRHeap::sCurrentHeap;
|
||||
}
|
||||
|
||||
_40 = a1;
|
||||
_40 = a1;
|
||||
|
||||
if (gCurrentFileLoader == NULL) {
|
||||
sCurrentDirIndex = 0;
|
||||
gCurrentFileLoader = this;
|
||||
}
|
||||
if (gCurrentFileLoader == NULL) {
|
||||
sCurrentDirIndex = 0;
|
||||
gCurrentFileLoader = this;
|
||||
}
|
||||
}
|
||||
|
||||
JKRArchive::~JKRArchive() {
|
||||
@ -84,200 +84,200 @@ JKRArchive::~JKRArchive() {
|
||||
#ifdef NON_MATCHING
|
||||
// blt ..., blr is optimized to bgelr
|
||||
void JKRArchive::setExpandSize(SDIFileEntry *pFile, unsigned long size) {
|
||||
u32 fileIndex = static_cast<u32>(pFile - mFiles);
|
||||
u32 fileIndex = static_cast<u32>(pFile - mFiles);
|
||||
|
||||
if (mExpandSizes == NULL) {
|
||||
return;
|
||||
}
|
||||
if (mExpandSizes == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileIndex >= mInfoBlock->mNrFiles) {
|
||||
return;
|
||||
}
|
||||
if (fileIndex >= mInfoBlock->mNrFiles) {
|
||||
return;
|
||||
}
|
||||
|
||||
mExpandSizes[fileIndex] = size;
|
||||
mExpandSizes[fileIndex] = size;
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 JKRArchive::getExpandSize(SDIFileEntry *pFile) const {
|
||||
u32 fileIndex = static_cast<u32>(pFile - mFiles);
|
||||
u32 fileIndex = static_cast<u32>(pFile - mFiles);
|
||||
|
||||
if (mExpandSizes == NULL || fileIndex >= mInfoBlock->mNrFiles) {
|
||||
return 0;
|
||||
}
|
||||
if (mExpandSizes == NULL || fileIndex >= mInfoBlock->mNrFiles) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mExpandSizes[fileIndex];
|
||||
return mExpandSizes[fileIndex];
|
||||
}
|
||||
|
||||
|
||||
bool JKRArchive::isSameName(CArcName &rName, unsigned long nameOffset, unsigned short hash) const {
|
||||
if (rName.mHash != hash) {
|
||||
return false;
|
||||
}
|
||||
if (rName.mHash != hash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strcmp(mStringTable + nameOffset, rName.mName) == 0;
|
||||
return strcmp(mStringTable + nameOffset, rName.mName) == 0;
|
||||
}
|
||||
|
||||
JKRArchive::SDIDirEntry *JKRArchive::findResType(unsigned long a1) const {
|
||||
SDIDirEntry *current = mDirs;
|
||||
SDIDirEntry *current = mDirs;
|
||||
|
||||
for (u32 i = 0; i < mInfoBlock->mNrDirs; i++) {
|
||||
if (current->mID == a1) {
|
||||
return current;
|
||||
}
|
||||
for (u32 i = 0; i < mInfoBlock->mNrDirs; i++) {
|
||||
if (current->mID == a1) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// Register mismatch
|
||||
JKRArchive::SDIDirEntry *JKRArchive::findDirectory(const char *pName, unsigned long dirIndex) const {
|
||||
SDIDirEntry *dir;
|
||||
SDIFileEntry *currentFile;
|
||||
s32 i;
|
||||
SDIDirEntry *dir;
|
||||
SDIFileEntry *currentFile;
|
||||
s32 i;
|
||||
|
||||
if (pName == NULL) {
|
||||
return &mDirs[dirIndex];
|
||||
}
|
||||
if (pName == NULL) {
|
||||
return &mDirs[dirIndex];
|
||||
}
|
||||
|
||||
CArcName name;
|
||||
const char *next = name.store(pName, '/');
|
||||
CArcName name;
|
||||
const char *next = name.store(pName, '/');
|
||||
|
||||
dir = &mDirs[dirIndex];
|
||||
currentFile = &mFiles[dir->mFirstFileIndex];
|
||||
dir = &mDirs[dirIndex];
|
||||
currentFile = &mFiles[dir->mFirstFileIndex];
|
||||
|
||||
for (i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, currentFile->mNameOffset, currentFile->mHash)) {
|
||||
if ((currentFile->mFlag & FILE_FLAG_FOLDER) != 0) {
|
||||
return findDirectory(next, currentFile->mDirIndex);
|
||||
}
|
||||
for (i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, currentFile->mNameOffset, currentFile->mHash)) {
|
||||
if ((currentFile->mFlag & FILE_FLAG_FOLDER) != 0) {
|
||||
return findDirectory(next, currentFile->mDirIndex);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
currentFile++;
|
||||
}
|
||||
currentFile++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findTypeResource(unsigned long a1, const char *pName) const {
|
||||
if (a1 != 0) {
|
||||
CArcName name;
|
||||
name.store(pName);
|
||||
if (a1 != 0) {
|
||||
CArcName name;
|
||||
name.store(pName);
|
||||
|
||||
SDIDirEntry *dir = findResType(a1);
|
||||
SDIDirEntry *dir = findResType(a1);
|
||||
|
||||
if (dir != NULL) {
|
||||
SDIFileEntry *current = &mFiles[dir->mFirstFileIndex];
|
||||
if (dir != NULL) {
|
||||
SDIFileEntry *current = &mFiles[dir->mFirstFileIndex];
|
||||
|
||||
for (s32 i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, current->mNameOffset, current->mHash)) {
|
||||
return current;
|
||||
}
|
||||
for (s32 i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, current->mNameOffset, current->mHash)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// Register mismatch
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findFsResource(const char *pName, unsigned long dirIndex) const {
|
||||
if (pName != NULL) {
|
||||
SDIDirEntry *dir;
|
||||
SDIFileEntry *currentFile;
|
||||
s32 i;
|
||||
if (pName != NULL) {
|
||||
SDIDirEntry *dir;
|
||||
SDIFileEntry *currentFile;
|
||||
s32 i;
|
||||
|
||||
CArcName name;
|
||||
const char *next = name.store(pName, '/');
|
||||
CArcName name;
|
||||
const char *next = name.store(pName, '/');
|
||||
|
||||
dir = &mDirs[dirIndex];
|
||||
currentFile = &mFiles[dir->mFirstFileIndex];
|
||||
dir = &mDirs[dirIndex];
|
||||
currentFile = &mFiles[dir->mFirstFileIndex];
|
||||
|
||||
for (s32 i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, currentFile->mNameOffset, currentFile->mHash)) {
|
||||
if ((currentFile->mFlag & FILE_FLAG_FOLDER) != 0) {
|
||||
return findFsResource(next, currentFile->mDirIndex);
|
||||
}
|
||||
else if (next == NULL) {
|
||||
return currentFile;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
for (s32 i = 0; i < dir->mNrFiles; i++) {
|
||||
if (isSameName(name, currentFile->mNameOffset, currentFile->mHash)) {
|
||||
if ((currentFile->mFlag & FILE_FLAG_FOLDER) != 0) {
|
||||
return findFsResource(next, currentFile->mDirIndex);
|
||||
}
|
||||
else if (next == NULL) {
|
||||
return currentFile;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
currentFile++;
|
||||
}
|
||||
}
|
||||
currentFile++;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findIdxResource(unsigned long index) const {
|
||||
if (index < mInfoBlock->mNrFiles) {
|
||||
return &mFiles[index];
|
||||
}
|
||||
if (index < mInfoBlock->mNrFiles) {
|
||||
return &mFiles[index];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findNameResource(const char *pName) const {
|
||||
SDIFileEntry *current = mFiles;
|
||||
SDIFileEntry *current = mFiles;
|
||||
|
||||
CArcName name;
|
||||
name.store(pName);
|
||||
CArcName name;
|
||||
name.store(pName);
|
||||
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (isSameName(name, current->mNameOffset, current->mHash)) {
|
||||
return current;
|
||||
}
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (isSameName(name, current->mNameOffset, current->mHash)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findPtrResource(const void *pResource) const {
|
||||
SDIFileEntry *current = mFiles;
|
||||
SDIFileEntry *current = mFiles;
|
||||
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mAllocatedData == pResource) {
|
||||
return current;
|
||||
}
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mAllocatedData == pResource) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JKRArchive::SDIFileEntry *JKRArchive::findIdResource(unsigned short fileID) const {
|
||||
if (fileID != 0xFFFF) {
|
||||
SDIFileEntry *current = mFiles;
|
||||
SDIFileEntry *indexed = &mFiles[fileID];
|
||||
if (fileID != 0xFFFF) {
|
||||
SDIFileEntry *current = mFiles;
|
||||
SDIFileEntry *indexed = &mFiles[fileID];
|
||||
|
||||
if (indexed->mFileID == fileID && (indexed->mFlag & FILE_FLAG_FILE) != 0) {
|
||||
return indexed;
|
||||
}
|
||||
if (indexed->mFileID == fileID && (indexed->mFlag & FILE_FLAG_FILE) != 0) {
|
||||
return indexed;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mFileID == fileID && (current->mFlag & FILE_FLAG_FILE) != 0) {
|
||||
return current;
|
||||
}
|
||||
for (s32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mFileID == fileID && (current->mFlag & FILE_FLAG_FILE) != 0) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
}
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -8,349 +8,349 @@
|
||||
#include "revolution.h"
|
||||
|
||||
bool JKRArchive::becomeCurrent(const char *pName) {
|
||||
SDIDirEntry *dir;
|
||||
SDIDirEntry *dir;
|
||||
|
||||
if (*pName == '/') {
|
||||
const char *pDir = pName + 1;
|
||||
if (*pName == '/') {
|
||||
const char *pDir = pName + 1;
|
||||
|
||||
if (*pDir == 0) {
|
||||
pDir = NULL;
|
||||
}
|
||||
if (*pDir == 0) {
|
||||
pDir = NULL;
|
||||
}
|
||||
|
||||
dir = findDirectory(pDir, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
dir = findDirectory(pDir, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
|
||||
bool validDir = dir != NULL;
|
||||
bool validDir = dir != NULL;
|
||||
|
||||
if (validDir) {
|
||||
JKRFileLoader::gCurrentFileLoader = this;
|
||||
sCurrentDirIndex = static_cast<u32>(dir - mDirs);
|
||||
}
|
||||
if (validDir) {
|
||||
JKRFileLoader::gCurrentFileLoader = this;
|
||||
sCurrentDirIndex = static_cast<u32>(dir - mDirs);
|
||||
}
|
||||
|
||||
return validDir;
|
||||
return validDir;
|
||||
}
|
||||
|
||||
void *JKRArchive::getResource(const char *pName) {
|
||||
SDIFileEntry *file;
|
||||
|
||||
if (*pName == '/') {
|
||||
file = findFsResource(pName + 1, 0);
|
||||
}
|
||||
else {
|
||||
file = findFsResource(pName, sCurrentDirIndex);
|
||||
}
|
||||
SDIFileEntry *file;
|
||||
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, NULL);
|
||||
}
|
||||
if (*pName == '/') {
|
||||
file = findFsResource(pName + 1, 0);
|
||||
}
|
||||
else {
|
||||
file = findFsResource(pName, sCurrentDirIndex);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *JKRArchive::getResource(unsigned long a1, const char *pName) {
|
||||
SDIFileEntry *file;
|
||||
SDIFileEntry *file;
|
||||
|
||||
if (a1 == NULL_MAGIC || a1 == QUESTIONMARK_MAGIC) {
|
||||
file = findNameResource(pName);
|
||||
}
|
||||
else {
|
||||
file = findTypeResource(a1, pName);
|
||||
}
|
||||
if (a1 == NULL_MAGIC || a1 == QUESTIONMARK_MAGIC) {
|
||||
file = findNameResource(pName);
|
||||
}
|
||||
else {
|
||||
file = findTypeResource(a1, pName);
|
||||
}
|
||||
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, NULL);
|
||||
}
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 JKRArchive::readResource(void *a1, unsigned long a2, const char *pName) {
|
||||
SDIFileEntry *file;
|
||||
SDIFileEntry *file;
|
||||
|
||||
if (*pName == '/') {
|
||||
file = findFsResource(pName + 1, 0);
|
||||
}
|
||||
else {
|
||||
file = findFsResource(pName, sCurrentDirIndex);
|
||||
}
|
||||
if (*pName == '/') {
|
||||
file = findFsResource(pName + 1, 0);
|
||||
}
|
||||
else {
|
||||
file = findFsResource(pName, sCurrentDirIndex);
|
||||
}
|
||||
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(a1, a2, file, &local_18);
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(a1, a2, file, &local_18);
|
||||
|
||||
return local_18;
|
||||
}
|
||||
return local_18;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 JKRArchive::readResource(void *a1, unsigned long a2, unsigned long a3, const char *pName) {
|
||||
SDIFileEntry *file;
|
||||
SDIFileEntry *file;
|
||||
|
||||
if (a3 == NULL_MAGIC || a3 == QUESTIONMARK_MAGIC) {
|
||||
file = findNameResource(pName);
|
||||
}
|
||||
else {
|
||||
file = findTypeResource(a3, pName);
|
||||
}
|
||||
if (a3 == NULL_MAGIC || a3 == QUESTIONMARK_MAGIC) {
|
||||
file = findNameResource(pName);
|
||||
}
|
||||
else {
|
||||
file = findTypeResource(a3, pName);
|
||||
}
|
||||
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(a1, a2, file, &local_18);
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(a1, a2, file, &local_18);
|
||||
|
||||
return local_18;
|
||||
}
|
||||
return local_18;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void JKRArchive::removeResourceAll() {
|
||||
if (mInfoBlock != NULL && mMountMode != MOUNT_MODE_DVD) {
|
||||
SDIFileEntry *current = mFiles;
|
||||
if (mInfoBlock != NULL && mMountMode != MOUNT_MODE_DVD) {
|
||||
SDIFileEntry *current = mFiles;
|
||||
|
||||
for (u32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mAllocatedData != NULL) {
|
||||
JKRHeap::free(current->mAllocatedData, mHeap);
|
||||
current->mAllocatedData = NULL;
|
||||
}
|
||||
for (u32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if (current->mAllocatedData != NULL) {
|
||||
JKRHeap::free(current->mAllocatedData, mHeap);
|
||||
current->mAllocatedData = NULL;
|
||||
}
|
||||
|
||||
current++;
|
||||
}
|
||||
}
|
||||
current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool JKRArchive::removeResource(void *pResource) {
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
file->mAllocatedData = NULL;
|
||||
JKRHeap::free(pResource, mHeap);
|
||||
file->mAllocatedData = NULL;
|
||||
JKRHeap::free(pResource, mHeap);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JKRArchive::detachResource(void *pResource) {
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
file->mAllocatedData = NULL;
|
||||
file->mAllocatedData = NULL;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
s32 JKRArchive::getResSize(const void *pResource) const {
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
SDIFileEntry *file = findPtrResource(pResource);
|
||||
|
||||
if (file == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (file == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return file->mDataSize;
|
||||
return file->mDataSize;
|
||||
}
|
||||
|
||||
s32 JKRArchive::countFile(const char *pName) const {
|
||||
SDIDirEntry *dir;
|
||||
SDIDirEntry *dir;
|
||||
|
||||
if (*pName == '/') {
|
||||
pName++;
|
||||
if (*pName == '/') {
|
||||
pName++;
|
||||
|
||||
if (*pName == 0) {
|
||||
pName = NULL;
|
||||
}
|
||||
if (*pName == 0) {
|
||||
pName = NULL;
|
||||
}
|
||||
|
||||
dir = findDirectory(pName, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
dir = findDirectory(pName, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
|
||||
if (dir != NULL) {
|
||||
return dir->mNrFiles;
|
||||
}
|
||||
if (dir != NULL) {
|
||||
return dir->mNrFiles;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
JKRArcFinder *JKRArchive::getFirstFile(const char *pName) const {
|
||||
SDIDirEntry *dir;
|
||||
SDIDirEntry *dir;
|
||||
|
||||
if (*pName == '/') {
|
||||
pName++;
|
||||
if (*pName == '/') {
|
||||
pName++;
|
||||
|
||||
if (*pName == 0) {
|
||||
pName = NULL;
|
||||
}
|
||||
if (*pName == 0) {
|
||||
pName = NULL;
|
||||
}
|
||||
|
||||
dir = findDirectory(pName, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
dir = findDirectory(pName, 0);
|
||||
}
|
||||
else {
|
||||
dir = findDirectory(pName, sCurrentDirIndex);
|
||||
}
|
||||
|
||||
if (dir != NULL) {
|
||||
// Bad to cast to non-const
|
||||
return new(JKRHeap::sGameHeap, 0) JKRArcFinder(const_cast<JKRArchive *>(this), dir->mFirstFileIndex, dir->mNrFiles);
|
||||
}
|
||||
if (dir != NULL) {
|
||||
// Bad to cast to non-const
|
||||
return new(JKRHeap::sGameHeap, 0) JKRArcFinder(const_cast<JKRArchive *>(this), dir->mFirstFileIndex, dir->mNrFiles);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JKRArchive *JKRArchive::check_mount_already(long entryNum) {
|
||||
JSUPtrLink *current = JKRFileLoader::sFileLoaderList.mHead;
|
||||
JSUPtrLink *current = JKRFileLoader::sFileLoaderList.mHead;
|
||||
|
||||
while (current != NULL) {
|
||||
JKRArchive *archive = reinterpret_cast<JKRArchive *>(current->mData);
|
||||
while (current != NULL) {
|
||||
JKRArchive *archive = reinterpret_cast<JKRArchive *>(current->mData);
|
||||
|
||||
if (archive->_2C == RARC_MAGIC && archive->_40 == entryNum) {
|
||||
archive->_34++;
|
||||
return archive;
|
||||
}
|
||||
if (archive->_2C == RARC_MAGIC && archive->_40 == entryNum) {
|
||||
archive->_34++;
|
||||
return archive;
|
||||
}
|
||||
|
||||
current = current->mNext;
|
||||
}
|
||||
current = current->mNext;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JKRArchive *JKRArchive::check_mount_already(long entryNum, JKRHeap *pHeap) {
|
||||
if (pHeap == NULL) {
|
||||
pHeap = JKRHeap::sCurrentHeap;
|
||||
}
|
||||
if (pHeap == NULL) {
|
||||
pHeap = JKRHeap::sCurrentHeap;
|
||||
}
|
||||
|
||||
JSUPtrLink *current = JKRFileLoader::sFileLoaderList.mHead;
|
||||
JSUPtrLink *current = JKRFileLoader::sFileLoaderList.mHead;
|
||||
|
||||
while (current != NULL) {
|
||||
JKRArchive *archive = reinterpret_cast<JKRArchive *>(current->mData);
|
||||
while (current != NULL) {
|
||||
JKRArchive *archive = reinterpret_cast<JKRArchive *>(current->mData);
|
||||
|
||||
if (archive->_2C == RARC_MAGIC && archive->_40 == entryNum && archive->mHeap == pHeap) {
|
||||
archive->_34++;
|
||||
return archive;
|
||||
}
|
||||
if (archive->_2C == RARC_MAGIC && archive->_40 == entryNum && archive->mHeap == pHeap) {
|
||||
archive->_34++;
|
||||
return archive;
|
||||
}
|
||||
|
||||
current = current->mNext;
|
||||
}
|
||||
current = current->mNext;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void JKRArchive::mount(const char *pName, EMountMode mountMode, JKRHeap *pHeap, EMountDirection mountDir) {
|
||||
s32 entryNum = DVDConvertPathToEntrynum(pName);
|
||||
s32 entryNum = DVDConvertPathToEntrynum(pName);
|
||||
|
||||
if (entryNum >= 0) {
|
||||
mount(entryNum, mountMode, pHeap, mountDir);
|
||||
}
|
||||
if (entryNum >= 0) {
|
||||
mount(entryNum, mountMode, pHeap, mountDir);
|
||||
}
|
||||
}
|
||||
|
||||
JKRArchive *JKRArchive::mount(long entryNum, EMountMode mountMode, JKRHeap *pHeap, EMountDirection mountDir) {
|
||||
JKRArchive *archive = check_mount_already(entryNum, pHeap);
|
||||
JKRArchive *archive = check_mount_already(entryNum, pHeap);
|
||||
|
||||
if (archive != NULL) {
|
||||
return archive;
|
||||
}
|
||||
if (archive != NULL) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
s32 uVar1 = -4;
|
||||
s32 uVar1 = -4;
|
||||
|
||||
if (mountDir == MOUNT_DIRECTION_1) {
|
||||
uVar1 = 4;
|
||||
}
|
||||
if (mountDir == MOUNT_DIRECTION_1) {
|
||||
uVar1 = 4;
|
||||
}
|
||||
|
||||
switch (mountMode) {
|
||||
case MOUNT_MODE_MEM:
|
||||
archive = new(pHeap, uVar1) JKRMemArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_ARAM:
|
||||
archive = new(pHeap, uVar1) JKRAramArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_DVD:
|
||||
archive = new(pHeap, uVar1) JKRDvdArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_COMP:
|
||||
archive = new(pHeap, uVar1) JKRCompArchive(entryNum, mountDir);
|
||||
break;
|
||||
}
|
||||
switch (mountMode) {
|
||||
case MOUNT_MODE_MEM:
|
||||
archive = new(pHeap, uVar1) JKRMemArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_ARAM:
|
||||
archive = new(pHeap, uVar1) JKRAramArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_DVD:
|
||||
archive = new(pHeap, uVar1) JKRDvdArchive(entryNum, mountDir);
|
||||
break;
|
||||
case MOUNT_MODE_COMP:
|
||||
archive = new(pHeap, uVar1) JKRCompArchive(entryNum, mountDir);
|
||||
break;
|
||||
}
|
||||
|
||||
if (archive != NULL && archive->mMountMode == MOUNT_MODE_0) {
|
||||
delete archive;
|
||||
archive = NULL;
|
||||
}
|
||||
if (archive != NULL && archive->mMountMode == MOUNT_MODE_0) {
|
||||
delete archive;
|
||||
archive = NULL;
|
||||
}
|
||||
|
||||
return archive;
|
||||
return archive;
|
||||
}
|
||||
|
||||
bool JKRArchive::getDirEntry(SDirEntry *pDir, unsigned long fileIndex) const {
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pDir->mFileFlag = file->mFlag;
|
||||
pDir->mFileID = file->mFileID;
|
||||
pDir->mName = mStringTable + file->mNameOffset;
|
||||
pDir->mFileFlag = file->mFlag;
|
||||
pDir->mFileID = file->mFileID;
|
||||
pDir->mName = mStringTable + file->mNameOffset;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void *JKRArchive::getIdxResource(unsigned long fileIndex) {
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, 0);
|
||||
}
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, 0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *JKRArchive::getResource(unsigned short fileID) {
|
||||
SDIFileEntry *file = findIdResource(fileID);
|
||||
SDIFileEntry *file = findIdResource(fileID);
|
||||
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, 0);
|
||||
}
|
||||
if (file != NULL) {
|
||||
return fetchResource(file, 0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 JKRArchive::readResource(void *pResource, unsigned long a2, unsigned short fileID) {
|
||||
SDIFileEntry *file = findIdResource(fileID);
|
||||
SDIFileEntry *file = findIdResource(fileID);
|
||||
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(pResource, a2, file, &local_18);
|
||||
if (file != NULL) {
|
||||
u32 local_18;
|
||||
fetchResource(pResource, a2, file, &local_18);
|
||||
|
||||
return local_18;
|
||||
}
|
||||
return local_18;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 JKRArchive::countResource() const {
|
||||
u32 count = 0;
|
||||
|
||||
for (u32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if ((mFiles[i].mFlag & FILE_FLAG_FILE) != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
u32 count = 0;
|
||||
|
||||
return count;
|
||||
for (u32 i = 0; i < mInfoBlock->mNrFiles; i++) {
|
||||
if ((mFiles[i].mFlag & FILE_FLAG_FILE) != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 JKRArchive::getFileAttribute(unsigned long fileIndex) const {
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
SDIFileEntry *file = findIdxResource(fileIndex);
|
||||
|
||||
if (file != NULL) {
|
||||
return file->mFlag;
|
||||
}
|
||||
if (file != NULL) {
|
||||
return file->mFlag;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
26
source/JSystem/JKernel/JKRDecomp.cpp
Normal file
26
source/JSystem/JKernel/JKRDecomp.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "JSystem/JKernel/JKRDecomp.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "revolution.h"
|
||||
|
||||
JKRDecomp::JKRDecomp(long a1) : JKRThread(0x4000, 0x10, a1) {
|
||||
OSResumeThread(mThread);
|
||||
}
|
||||
|
||||
JKRDecomp::~JKRDecomp() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKRDecomp *JKRDecomp::create(long a1) {
|
||||
if (sDecompInstance == NULL) {
|
||||
sDecompInstance = new(JKRHeap::sGameHeap, 0) JKRDecomp(a1);
|
||||
}
|
||||
|
||||
return sDecompInstance;
|
||||
}
|
@ -13,4 +13,4 @@ JKRDisposer::~JKRDisposer() {
|
||||
if (mHeap) {
|
||||
mHeap->mDisposerList.remove(&mLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@
|
||||
#include "JSystem/JKernel/JKRFileFinder.h"
|
||||
|
||||
JKRFileFinder::JKRFileFinder() {
|
||||
mHasMoreFiles = false;
|
||||
mFileIsFolder = false;
|
||||
mHasMoreFiles = false;
|
||||
mFileIsFolder = false;
|
||||
}
|
||||
|
||||
JKRArcFinder::JKRArcFinder(JKRArchive *pArchive, long firstFileIndex, long nrFiles) {
|
||||
mArchive = pArchive;
|
||||
mHasMoreFiles = nrFiles > 0;
|
||||
mFirstIndex = firstFileIndex;
|
||||
mLastIndex = firstFileIndex + nrFiles - 1;
|
||||
mCurrentIndex = firstFileIndex;
|
||||
mArchive = pArchive;
|
||||
mHasMoreFiles = nrFiles > 0;
|
||||
mFirstIndex = firstFileIndex;
|
||||
mLastIndex = firstFileIndex + nrFiles - 1;
|
||||
mCurrentIndex = firstFileIndex;
|
||||
|
||||
findNextFile();
|
||||
findNextFile();
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
@ -24,24 +24,24 @@ JKRArcFinder::~JKRArcFinder() {
|
||||
#endif
|
||||
|
||||
bool JKRArcFinder::findNextFile() {
|
||||
if (mHasMoreFiles) {
|
||||
bool moreFiles = mCurrentIndex <= mLastIndex;
|
||||
mHasMoreFiles = moreFiles;
|
||||
if (mHasMoreFiles) {
|
||||
bool moreFiles = mCurrentIndex <= mLastIndex;
|
||||
mHasMoreFiles = moreFiles;
|
||||
|
||||
// Weird code
|
||||
if (moreFiles & 0xFF) {
|
||||
JKRArchive::SDirEntry dir;
|
||||
mHasMoreFiles = mArchive->getDirEntry(&dir, mCurrentIndex);
|
||||
// Weird code
|
||||
if (moreFiles & 0xFF) {
|
||||
JKRArchive::SDirEntry dir;
|
||||
mHasMoreFiles = mArchive->getDirEntry(&dir, mCurrentIndex);
|
||||
|
||||
mName = dir.mName;
|
||||
mDirIndex = mCurrentIndex;
|
||||
mFileID = dir.mFileID;
|
||||
mFileFlag = dir.mFileFlag;
|
||||
mFileIsFolder = ((mFileFlag >> 1) & 1) != 0;
|
||||
|
||||
mCurrentIndex++;
|
||||
}
|
||||
}
|
||||
mName = dir.mName;
|
||||
mDirIndex = mCurrentIndex;
|
||||
mFileID = dir.mFileID;
|
||||
mFileFlag = dir.mFileFlag;
|
||||
mFileIsFolder = ((mFileFlag >> 1) & 1) != 0;
|
||||
|
||||
return mHasMoreFiles;
|
||||
mCurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return mHasMoreFiles;
|
||||
}
|
||||
|
@ -2,74 +2,74 @@
|
||||
#include "revolution.h"
|
||||
|
||||
namespace {
|
||||
OSMutex gLoaderMutex; // _8060CFA8
|
||||
OSMutex gLoaderMutex; // _8060CFA8
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader> JKRFileLoader::sFileLoaderList = JSUList<JKRFileLoader>();
|
||||
|
||||
JKRFileLoader::JKRFileLoader() : JKRDisposer(), _18(this) {
|
||||
_28 = 0;
|
||||
_2C = 0;
|
||||
_34 = 0;
|
||||
_28 = 0;
|
||||
_2C = 0;
|
||||
_34 = 0;
|
||||
}
|
||||
|
||||
JKRFileLoader::~JKRFileLoader() {
|
||||
if (gCurrentFileLoader == this) {
|
||||
gCurrentFileLoader = NULL;
|
||||
}
|
||||
if (gCurrentFileLoader == this) {
|
||||
gCurrentFileLoader = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void JKRFileLoader::unmount() {
|
||||
if (_34 == 0) {
|
||||
return;
|
||||
}
|
||||
if (_34 == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (--_34 != 0) {
|
||||
return;
|
||||
}
|
||||
if (--_34 != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete this;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void *JKRFileLoader::getGlbResource(const char *pName, JKRFileLoader *pLoader) {
|
||||
void *resource = NULL;
|
||||
void *resource = NULL;
|
||||
|
||||
if (pLoader != NULL) {
|
||||
resource = pLoader->getResource(0, pName);
|
||||
}
|
||||
else {
|
||||
JSUPtrLink *current = sFileLoaderList.mHead;
|
||||
if (pLoader != NULL) {
|
||||
resource = pLoader->getResource(0, pName);
|
||||
}
|
||||
else {
|
||||
JSUPtrLink *current = sFileLoaderList.mHead;
|
||||
|
||||
while (current != NULL) {
|
||||
resource = reinterpret_cast<JKRFileLoader *>(current->mData)->getResource(0, pName);
|
||||
while (current != NULL) {
|
||||
resource = reinterpret_cast<JKRFileLoader *>(current->mData)->getResource(0, pName);
|
||||
|
||||
if (resource != NULL) {
|
||||
break;
|
||||
}
|
||||
if (resource != NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
current = current->mNext;
|
||||
}
|
||||
}
|
||||
current = current->mNext;
|
||||
}
|
||||
}
|
||||
|
||||
return resource;
|
||||
return resource;
|
||||
}
|
||||
|
||||
void JKRFileLoader::initializeVolumeList() {
|
||||
OSInitMutex(&gLoaderMutex);
|
||||
OSInitMutex(&gLoaderMutex);
|
||||
}
|
||||
|
||||
void JKRFileLoader::prependVolumeList(JSULink<JKRFileLoader> *pLoader) {
|
||||
OSLockMutex(&gLoaderMutex);
|
||||
OSLockMutex(&gLoaderMutex);
|
||||
|
||||
sFileLoaderList.prepend(pLoader);
|
||||
sFileLoaderList.prepend(pLoader);
|
||||
|
||||
OSUnlockMutex(&gLoaderMutex);
|
||||
OSUnlockMutex(&gLoaderMutex);
|
||||
}
|
||||
|
||||
void JKRFileLoader::removeVolumeList(JSULink<JKRFileLoader> *pLoader) {
|
||||
OSLockMutex(&gLoaderMutex);
|
||||
OSLockMutex(&gLoaderMutex);
|
||||
|
||||
sFileLoaderList.remove(pLoader);
|
||||
sFileLoaderList.remove(pLoader);
|
||||
|
||||
OSUnlockMutex(&gLoaderMutex);
|
||||
OSUnlockMutex(&gLoaderMutex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user