mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-30 00:16:19 -04:00
Copy JKernel (#126)
* start JSystem * JKRAram and JUTGamePad * started heap and thread * more JKernel * mostly finished JKernel * delete unused asm * JKRFileFinder * delete unused asm and match findNextFile * format * fix mtx_vec
This commit is contained in:
@@ -4,87 +4,12 @@
|
||||
//
|
||||
|
||||
#include "JSystem/JKernel/JKRFileCache.h"
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
#include "JSystem/JKernel/JKRFileFinder.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dol2asm.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
//
|
||||
// Types:
|
||||
//
|
||||
|
||||
struct JSUPtrLink {
|
||||
/* 802DBDFC */ JSUPtrLink(void*);
|
||||
/* 802DBE14 */ ~JSUPtrLink();
|
||||
};
|
||||
|
||||
struct JSUPtrList {
|
||||
/* 802DBEAC */ ~JSUPtrList();
|
||||
/* 802DBF14 */ void initiate();
|
||||
/* 802DBF4C */ void append(JSUPtrLink*);
|
||||
/* 802DBFF0 */ void prepend(JSUPtrLink*);
|
||||
/* 802DC15C */ void remove(JSUPtrLink*);
|
||||
};
|
||||
|
||||
struct JKRHeap {
|
||||
/* 802CE4D4 */ void alloc(u32, int);
|
||||
/* 802CE474 */ void alloc(u32, int, JKRHeap*);
|
||||
/* 802CE500 */ void free(void*, JKRHeap*);
|
||||
/* 802CE548 */ void free(void*);
|
||||
/* 802CE83C */ void findFromRoot(void*);
|
||||
|
||||
static u8 sSystemHeap[4];
|
||||
};
|
||||
|
||||
struct JKRFileLoader {
|
||||
/* 802D40F0 */ JKRFileLoader();
|
||||
/* 802D4148 */ ~JKRFileLoader();
|
||||
/* 802D41D4 */ void unmount();
|
||||
|
||||
static u8 sVolumeList[12];
|
||||
static u8 sCurrentVolume[4 + 4 /* padding */];
|
||||
};
|
||||
|
||||
struct JKRFileCache {
|
||||
struct CCacheBlock {
|
||||
/* 802D566C */ CCacheBlock(u32, u32, void const*);
|
||||
};
|
||||
|
||||
/* 802D49B4 */ void mount(char const*, JKRHeap*, char const*);
|
||||
/* 802D4AB4 */ JKRFileCache(char const*, char const*);
|
||||
/* 802D4C70 */ ~JKRFileCache();
|
||||
/* 802D4D44 */ void becomeCurrent(char const*);
|
||||
/* 802D4DD8 */ void getResource(char const*);
|
||||
/* 802D4EDC */ void getResource(u32, char const*);
|
||||
/* 802D503C */ void readResource(void*, u32, u32, char const*);
|
||||
/* 802D4F64 */ void readResource(void*, u32, char const*);
|
||||
/* 802D50D4 */ void removeResourceAll();
|
||||
/* 802D5164 */ void removeResource(void*);
|
||||
/* 802D51F8 */ void detachResource(void*);
|
||||
/* 802D526C */ void getResSize(void const*) const;
|
||||
/* 802D52A0 */ void countFile(char const*) const;
|
||||
/* 802D531C */ void getFirstFile(char const*) const;
|
||||
/* 802D53B8 */ void findCacheBlock(void const*) const;
|
||||
/* 802D53E4 */ void findCacheBlock(u32) const;
|
||||
/* 802D5410 */ void findFile(char*, char const*) const;
|
||||
/* 802D551C */ void getDvdPathName(char const*) const;
|
||||
/* 802D5624 */ void convStrLower(char*) const;
|
||||
/* 802D56C8 */ void getFsResource(char const*);
|
||||
/* 802D56F4 */ void getNameResource(u32, char const*);
|
||||
/* 802D5720 */ void readFsResource(void*, u32, char const*);
|
||||
/* 802D574C */ void readNameResource(void*, u32, u32, char const*);
|
||||
};
|
||||
|
||||
struct JKRFile {
|
||||
/* 802D9518 */ void read(void*, s32, s32);
|
||||
};
|
||||
|
||||
struct JKRDvdFinder {
|
||||
/* 802D4770 */ JKRDvdFinder(char const*);
|
||||
};
|
||||
|
||||
struct JKRDvdFile {
|
||||
/* 802D95F8 */ JKRDvdFile(char const*);
|
||||
/* 802D9748 */ ~JKRDvdFile();
|
||||
};
|
||||
#include "global.h"
|
||||
#include "msl_c/string.h"
|
||||
|
||||
//
|
||||
// Forward References:
|
||||
@@ -120,7 +45,6 @@ extern "C" extern char const* const JKRFileCache__stringBase0;
|
||||
// External References:
|
||||
//
|
||||
|
||||
SECTION_INIT void memcpy();
|
||||
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
|
||||
extern "C" void alloc__7JKRHeapFUli();
|
||||
extern "C" void free__7JKRHeapFPvP7JKRHeap();
|
||||
@@ -142,10 +66,6 @@ extern "C" void initiate__10JSUPtrListFv();
|
||||
extern "C" void append__10JSUPtrListFP10JSUPtrLink();
|
||||
extern "C" void prepend__10JSUPtrListFP10JSUPtrLink();
|
||||
extern "C" void remove__10JSUPtrListFP10JSUPtrLink();
|
||||
extern "C" void DVDChangeDir();
|
||||
extern "C" void DVDOpenDir();
|
||||
extern "C" void DVDReadDir();
|
||||
extern "C" bool DVDCloseDir();
|
||||
extern "C" void _savegpr_26();
|
||||
extern "C" void _savegpr_27();
|
||||
extern "C" void _savegpr_28();
|
||||
@@ -154,12 +74,6 @@ extern "C" void _restgpr_26();
|
||||
extern "C" void _restgpr_27();
|
||||
extern "C" void _restgpr_28();
|
||||
extern "C" void _restgpr_29();
|
||||
extern "C" void tolower();
|
||||
extern "C" void strrchr();
|
||||
extern "C" void strcmp();
|
||||
extern "C" void strcat();
|
||||
extern "C" void strcpy();
|
||||
extern "C" void strlen();
|
||||
extern "C" u8 sVolumeList__13JKRFileLoader[12];
|
||||
extern "C" u8 sSystemHeap__7JKRHeap[4];
|
||||
extern "C" u8 sCurrentVolume__13JKRFileLoader[4 + 4 /* padding */];
|
||||
@@ -169,124 +83,248 @@ extern "C" u8 sCurrentVolume__13JKRFileLoader[4 + 4 /* padding */];
|
||||
//
|
||||
|
||||
/* 802D49B4-802D4AB4 2CF2F4 0100+00 0/0 2/2 0/0 .text mount__12JKRFileCacheFPCcP7JKRHeapPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::mount(char const* param_0, JKRHeap* param_1, char const* param_2) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/mount__12JKRFileCacheFPCcP7JKRHeapPCc.s"
|
||||
JKRFileCache* JKRFileCache::mount(const char* path, JKRHeap* heap, const char* param_3) {
|
||||
if (!path || *path != '/') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 pathLength = strlen(path);
|
||||
if (pathLength != 1 && path[pathLength - 1] == '/') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'CASH') {
|
||||
JKRFileCache* fileCache = (JKRFileCache*)iterator.getObject();
|
||||
if (fileCache->mRootPath) {
|
||||
if (strcmp(fileCache->mRootPath, path) == 0) {
|
||||
fileCache->mMountCount++;
|
||||
return fileCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new (heap, 0) JKRFileCache(path, param_3);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 8039D158-8039D158 0297B8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
|
||||
#pragma push
|
||||
#pragma force_active on
|
||||
SECTION_DEAD static char const* const stringBase_8039D158 = "/";
|
||||
SECTION_DEAD static char const* const stringBase_8039D15A = "dvd";
|
||||
/* @stringBase0 padding */
|
||||
SECTION_DEAD static char const* const pad_8039D15E = "\0";
|
||||
#pragma pop
|
||||
|
||||
/* 803CC238-803CC288 029358 004C+04 2/2 0/0 0/0 .data __vt__12JKRFileCache */
|
||||
SECTION_DATA extern void* __vt__12JKRFileCache[19 + 1 /* padding */] = {
|
||||
(void*)NULL /* RTTI */,
|
||||
(void*)NULL,
|
||||
(void*)__dt__12JKRFileCacheFv,
|
||||
(void*)unmount__13JKRFileLoaderFv,
|
||||
(void*)becomeCurrent__12JKRFileCacheFPCc,
|
||||
(void*)getResource__12JKRFileCacheFPCc,
|
||||
(void*)getResource__12JKRFileCacheFUlPCc,
|
||||
(void*)readResource__12JKRFileCacheFPvUlPCc,
|
||||
(void*)readResource__12JKRFileCacheFPvUlUlPCc,
|
||||
(void*)removeResourceAll__12JKRFileCacheFv,
|
||||
(void*)removeResource__12JKRFileCacheFPv,
|
||||
(void*)detachResource__12JKRFileCacheFPv,
|
||||
(void*)getResSize__12JKRFileCacheCFPCv,
|
||||
(void*)countFile__12JKRFileCacheCFPCc,
|
||||
(void*)getFirstFile__12JKRFileCacheCFPCc,
|
||||
(void*)getFsResource__12JKRFileCacheFPCc,
|
||||
(void*)getNameResource__12JKRFileCacheFUlPCc,
|
||||
(void*)readFsResource__12JKRFileCacheFPvUlPCc,
|
||||
(void*)readNameResource__12JKRFileCacheFPvUlUlPCc,
|
||||
/* padding */
|
||||
NULL,
|
||||
};
|
||||
// #pragma push
|
||||
// #pragma force_active on
|
||||
// SECTION_DEAD static char const* const stringBase_8039D158 = "/";
|
||||
// SECTION_DEAD static char const* const stringBase_8039D15A = "dvd";
|
||||
// /* @stringBase0 padding */
|
||||
// SECTION_DEAD static char const* const pad_8039D15E = "\0";
|
||||
// #pragma pop
|
||||
|
||||
/* 802D4AB4-802D4C70 2CF3F4 01BC+00 1/1 0/0 0/0 .text __ct__12JKRFileCacheFPCcPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm JKRFileCache::JKRFileCache(char const* param_0, char const* param_1) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/__ct__12JKRFileCacheFPCcPCc.s"
|
||||
JKRFileCache::JKRFileCache(const char* path, const char* volume) : mCacheBlockList() {
|
||||
mParentHeap = JKRHeap::findFromRoot(this);
|
||||
mMountCount = 1;
|
||||
mVolumeType = 'CASH';
|
||||
|
||||
u32 pathLength = strlen(path);
|
||||
mRootPath = (char*)JKRAllocFromHeap(mParentHeap, pathLength + 1, 1);
|
||||
mCurrentPath = (char*)JKRAllocFromSysHeap(pathLength + 2, 1);
|
||||
strcpy(mRootPath, path);
|
||||
strcpy(mCurrentPath, path);
|
||||
|
||||
if (path[1] != '\0') {
|
||||
convStrLower(mRootPath);
|
||||
convStrLower(mCurrentPath);
|
||||
strcat(mCurrentPath, "/");
|
||||
|
||||
const char* volumePath = volume;
|
||||
if (!volume) {
|
||||
volumePath = strrchr(mRootPath, '/');
|
||||
volumePath++;
|
||||
}
|
||||
|
||||
u32 volumeLength = strlen(volumePath) + 1;
|
||||
mVolumePath = (char*)JKRAllocFromSysHeap(volumeLength, 0);
|
||||
strcpy(mVolumePath, volumePath);
|
||||
convStrLower(mVolumePath);
|
||||
mVolumeName = mVolumePath;
|
||||
} else {
|
||||
const char* volumePath = volume;
|
||||
if (!volume) {
|
||||
volumePath = "dvd";
|
||||
}
|
||||
|
||||
u32 volumeLength = strlen(volumePath) + 1;
|
||||
mVolumePath = (char*)JKRAllocFromSysHeap(volumeLength, 0);
|
||||
strcpy(mVolumePath, volumePath);
|
||||
convStrLower(mVolumePath);
|
||||
mVolumeName = mVolumePath;
|
||||
}
|
||||
|
||||
getVolumeList().prepend(&mFileLoaderLink);
|
||||
mIsMounted = true;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D4C70-802D4D44 2CF5B0 00D4+00 1/0 0/0 0/0 .text __dt__12JKRFileCacheFv */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm JKRFileCache::~JKRFileCache() {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/__dt__12JKRFileCacheFv.s"
|
||||
JKRFileCache::~JKRFileCache() {
|
||||
removeResourceAll();
|
||||
if (mRootPath)
|
||||
JKRFreeToHeap(mParentHeap, mRootPath);
|
||||
if (mCurrentPath)
|
||||
JKRFreeToSysHeap(mCurrentPath);
|
||||
if (mVolumePath)
|
||||
JKRFreeToSysHeap(mVolumePath);
|
||||
|
||||
getVolumeList().remove(&mFileLoaderLink);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D4D44-802D4DD8 2CF684 0094+00 1/0 0/0 0/0 .text becomeCurrent__12JKRFileCacheFPCc
|
||||
*/
|
||||
#ifdef NONMATCHING
|
||||
bool JKRFileCache::becomeCurrent(const char* path) {
|
||||
char* name = getDvdPathName(path);
|
||||
BOOL result = DVDChangeDir(name);
|
||||
bool didChangeDir = (result != 0);
|
||||
if (didChangeDir) {
|
||||
setCurrentVolume(this);
|
||||
JKRFreeToSysHeap(mCurrentPath);
|
||||
|
||||
mCurrentPath = name;
|
||||
if (mCurrentPath[1]) {
|
||||
strcat(mCurrentPath, "/");
|
||||
}
|
||||
} else {
|
||||
JKRFreeToSysHeap(name);
|
||||
}
|
||||
|
||||
return didChangeDir;
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::becomeCurrent(char const* param_0) {
|
||||
asm bool JKRFileCache::becomeCurrent(char const* param_0) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/becomeCurrent__12JKRFileCacheFPCc.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 802D4DD8-802D4EDC 2CF718 0104+00 1/0 0/0 0/0 .text getResource__12JKRFileCacheFPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getResource(char const* param_0) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getResource__12JKRFileCacheFPCc.s"
|
||||
void* JKRFileCache::getResource(const char* path) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
void* buffer = NULL;
|
||||
char* name = getDvdPathName(path);
|
||||
JKRDvdFile dvdFile(name);
|
||||
if (dvdFile.isAvailable()) {
|
||||
CCacheBlock* cacheBlock = findCacheBlock(dvdFile.getFileID());
|
||||
if (!cacheBlock) {
|
||||
// dvdFile.getFileSize() not inlined
|
||||
u32 fileSize = dvdFile.getFileInfo().length;
|
||||
u32 alignedSize = ALIGN_NEXT(fileSize, 0x20);
|
||||
buffer = JKRAllocFromHeap(mParentHeap, alignedSize, 0x20);
|
||||
if (buffer) {
|
||||
dvdFile.read(buffer, alignedSize, 0);
|
||||
|
||||
cacheBlock = new (JKRHeap::getSystemHeap(), 0)
|
||||
CCacheBlock(dvdFile.getFileID(), dvdFile.getFileInfo().length, buffer);
|
||||
mCacheBlockList.append(&cacheBlock->mCacheBlockLink);
|
||||
}
|
||||
} else {
|
||||
cacheBlock->mReferenceCount++;
|
||||
buffer = cacheBlock->mMemoryPtr;
|
||||
}
|
||||
}
|
||||
|
||||
JKRFreeToSysHeap(name);
|
||||
return buffer;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D4EDC-802D4F64 2CF81C 0088+00 1/0 0/0 0/0 .text getResource__12JKRFileCacheFUlPCc
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getResource(u32 param_0, char const* param_1) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getResource__12JKRFileCacheFUlPCc.s"
|
||||
void* JKRFileCache::getResource(u32, const char* path) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
char finalPath[256];
|
||||
u32 rootLength = strlen(mRootPath);
|
||||
char* filePath = finalPath + rootLength;
|
||||
strcpy(finalPath, mRootPath);
|
||||
|
||||
bool found = findFile(finalPath, path);
|
||||
if (!found)
|
||||
return NULL;
|
||||
|
||||
return getResource(filePath);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D4F64-802D503C 2CF8A4 00D8+00 1/0 0/0 0/0 .text readResource__12JKRFileCacheFPvUlPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::readResource(void* param_0, u32 param_1, char const* param_2) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/readResource__12JKRFileCacheFPvUlPCc.s"
|
||||
u32 JKRFileCache::readResource(void* dst, u32 dstLength, const char* path) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
char* name = getDvdPathName(path);
|
||||
JKRDvdFile dvdFile(name);
|
||||
|
||||
u32 resourceSize = 0;
|
||||
|
||||
// !@bug: (maybe?) Infinite Loop: Because dvdFile.isAvailable() is never updated in the loop-body
|
||||
// will would never exit the loop.
|
||||
loop:
|
||||
if (dvdFile.isAvailable()) {
|
||||
// dvdFile.getFileSize() not inlined
|
||||
u32 fileSize = dvdFile.getFileInfo().length;
|
||||
resourceSize = ALIGN_NEXT(fileSize, 0x20);
|
||||
dstLength = ALIGN_PREV(dstLength, 0x20);
|
||||
if (resourceSize > dstLength) {
|
||||
resourceSize = dstLength;
|
||||
}
|
||||
|
||||
CCacheBlock* cacheBlock = findCacheBlock(dvdFile.getFileID());
|
||||
if (!cacheBlock) {
|
||||
dvdFile.read(dst, resourceSize, 0);
|
||||
} else {
|
||||
memcpy(dst, cacheBlock->mMemoryPtr, resourceSize);
|
||||
}
|
||||
goto loop;
|
||||
}
|
||||
|
||||
JKRFreeToSysHeap(name);
|
||||
return resourceSize;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D503C-802D50D4 2CF97C 0098+00 1/0 0/0 0/0 .text readResource__12JKRFileCacheFPvUlUlPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::readResource(void* param_0, u32 param_1, u32 param_2, char const* param_3) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/readResource__12JKRFileCacheFPvUlUlPCc.s"
|
||||
u32 JKRFileCache::readResource(void* dst, u32 dstLength, u32, const char* path) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
char finalPath[256];
|
||||
u32 rootLength = strlen(mRootPath);
|
||||
char* filePath = finalPath + rootLength;
|
||||
strcpy(finalPath, mRootPath);
|
||||
|
||||
bool found = findFile(finalPath, path);
|
||||
if (!found)
|
||||
return NULL;
|
||||
|
||||
return readResource(dst, dstLength, filePath);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D50D4-802D5164 2CFA14 0090+00 1/0 0/0 0/0 .text removeResourceAll__12JKRFileCacheFv
|
||||
*/
|
||||
#ifdef NONMATCHING
|
||||
void JKRFileCache::removeResourceAll(void) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
JSUListIterator<CCacheBlock> iterator;
|
||||
iterator = mCacheBlockList.getFirst();
|
||||
while (iterator != mCacheBlockList.getEnd()) {
|
||||
JKRFreeToHeap(mParentHeap, iterator->mMemoryPtr);
|
||||
mCacheBlockList.remove(&iterator->mLink);
|
||||
JSUListIterator<CCacheBlock> next = iterator++;
|
||||
CCacheBlock* cacheBlock = next.getObject();
|
||||
delete cacheBlock;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
@@ -295,165 +333,214 @@ asm void JKRFileCache::removeResourceAll() {
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/removeResourceAll__12JKRFileCacheFv.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 802D5164-802D51F8 2CFAA4 0094+00 1/0 0/0 0/0 .text removeResource__12JKRFileCacheFPv
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::removeResource(void* param_0) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/removeResource__12JKRFileCacheFPv.s"
|
||||
bool JKRFileCache::removeResource(void* resource) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
CCacheBlock* cacheBlock = findCacheBlock(resource);
|
||||
if (!cacheBlock)
|
||||
return false;
|
||||
|
||||
u32 referenceCount = cacheBlock->mReferenceCount - 1;
|
||||
cacheBlock->mReferenceCount = referenceCount;
|
||||
if (referenceCount == 0) {
|
||||
JKRFreeToHeap(mParentHeap, resource);
|
||||
mCacheBlockList.remove(&cacheBlock->mCacheBlockLink);
|
||||
delete cacheBlock;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D51F8-802D526C 2CFB38 0074+00 1/0 0/0 0/0 .text detachResource__12JKRFileCacheFPv
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::detachResource(void* param_0) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/detachResource__12JKRFileCacheFPv.s"
|
||||
bool JKRFileCache::detachResource(void* resource) {
|
||||
ASSERT(isMounted());
|
||||
|
||||
CCacheBlock* cacheBlock = findCacheBlock(resource);
|
||||
if (!cacheBlock)
|
||||
return false;
|
||||
|
||||
mCacheBlockList.remove(&cacheBlock->mCacheBlockLink);
|
||||
delete cacheBlock;
|
||||
return true;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D526C-802D52A0 2CFBAC 0034+00 1/0 0/0 0/0 .text getResSize__12JKRFileCacheCFPCv */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getResSize(void const* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getResSize__12JKRFileCacheCFPCv.s"
|
||||
u32 JKRFileCache::getResSize(const void* resource) const {
|
||||
ASSERT(isMounted());
|
||||
|
||||
CCacheBlock* cacheBlock = findCacheBlock(resource);
|
||||
if (cacheBlock == NULL) {
|
||||
return -1;
|
||||
} else {
|
||||
return cacheBlock->mFileSize;
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D52A0-802D531C 2CFBE0 007C+00 1/0 0/0 0/0 .text countFile__12JKRFileCacheCFPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::countFile(char const* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/countFile__12JKRFileCacheCFPCc.s"
|
||||
u32 JKRFileCache::countFile(const char* path) const {
|
||||
ASSERT(isMounted());
|
||||
|
||||
DVDDirectory dir;
|
||||
DVDDirectoryEntry dirEntry;
|
||||
|
||||
u32 count = 0;
|
||||
char* name = getDvdPathName(path);
|
||||
BOOL result = DVDOpenDir(name, &dir);
|
||||
if (result != 0) {
|
||||
while (result = DVDReadDir(&dir, &dirEntry), result != FALSE) {
|
||||
count = count + 1;
|
||||
}
|
||||
|
||||
DVDCloseDir(&dir);
|
||||
}
|
||||
|
||||
JKRFreeToSysHeap(name);
|
||||
return count;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D531C-802D53B8 2CFC5C 009C+00 1/0 0/0 0/0 .text getFirstFile__12JKRFileCacheCFPCc
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getFirstFile(char const* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getFirstFile__12JKRFileCacheCFPCc.s"
|
||||
JKRFileFinder* JKRFileCache::getFirstFile(const char* path) const {
|
||||
char* name = getDvdPathName(path);
|
||||
JKRHeap* systemHeap = JKRHeap::getSystemHeap();
|
||||
JKRDvdFinder* finder = new (systemHeap, 0) JKRDvdFinder(name);
|
||||
JKRFreeToSysHeap(name);
|
||||
|
||||
if (finder->isAvailable() != true) {
|
||||
delete finder;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return finder;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D53B8-802D53E4 2CFCF8 002C+00 3/3 0/0 0/0 .text findCacheBlock__12JKRFileCacheCFPCv
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::findCacheBlock(void const* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/findCacheBlock__12JKRFileCacheCFPCv.s"
|
||||
JKRFileCache::CCacheBlock* JKRFileCache::findCacheBlock(const void* resource) const {
|
||||
JSUListIterator<CCacheBlock> iterator;
|
||||
for (iterator = mCacheBlockList.getFirst(); iterator != mCacheBlockList.getEnd(); ++iterator) {
|
||||
if (iterator->mMemoryPtr == resource) {
|
||||
return iterator.getObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D53E4-802D5410 2CFD24 002C+00 2/2 0/0 0/0 .text findCacheBlock__12JKRFileCacheCFUl
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::findCacheBlock(u32 param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/findCacheBlock__12JKRFileCacheCFUl.s"
|
||||
JKRFileCache::CCacheBlock* JKRFileCache::findCacheBlock(u32 fileID) const {
|
||||
JSUListIterator<CCacheBlock> iterator;
|
||||
for (iterator = mCacheBlockList.getFirst(); iterator != mCacheBlockList.getEnd(); ++iterator) {
|
||||
if (iterator->mFileId == fileID) {
|
||||
return iterator.getObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D5410-802D551C 2CFD50 010C+00 2/2 0/0 0/0 .text findFile__12JKRFileCacheCFPcPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::findFile(char* param_0, char const* param_1) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/findFile__12JKRFileCacheCFPcPCc.s"
|
||||
bool JKRFileCache::findFile(char* path, const char* fileName) const {
|
||||
DVDDirectory dir;
|
||||
DVDDirectoryEntry dirEntry;
|
||||
|
||||
bool result = false;
|
||||
u32 pathLength = strlen(path);
|
||||
if (DVDOpenDir(path, &dir)) {
|
||||
while (DVDReadDir(&dir, &dirEntry)) {
|
||||
if (dirEntry.is_directory) {
|
||||
char* endOfPath = path + pathLength;
|
||||
*endOfPath = '/';
|
||||
strcpy(path + pathLength + 1, dirEntry.name);
|
||||
result = findFile(path, fileName);
|
||||
if (result)
|
||||
break;
|
||||
*endOfPath = '\0';
|
||||
} else {
|
||||
result = (strcmp(fileName, dirEntry.name) == 0);
|
||||
if (result) {
|
||||
strcat(path, "/");
|
||||
strcat(path, fileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DVDCloseDir(&dir);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D551C-802D5624 2CFE5C 0108+00 5/5 0/0 0/0 .text getDvdPathName__12JKRFileCacheCFPCc
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getDvdPathName(char const* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getDvdPathName__12JKRFileCacheCFPCc.s"
|
||||
char* JKRFileCache::getDvdPathName(const char* path) const {
|
||||
char* newPath;
|
||||
if (path[0] == '/') {
|
||||
u32 length = strlen(mRootPath) + strlen(path) + 2;
|
||||
newPath = (char*)JKRAllocFromSysHeap(length, 1);
|
||||
strcpy(newPath, mRootPath);
|
||||
if (path[1]) {
|
||||
if (mRootPath[1] == 0) {
|
||||
strcat(newPath, path + 1);
|
||||
} else {
|
||||
strcat(newPath, path);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
u32 length = strlen(mCurrentPath) + strlen(path) + 2;
|
||||
newPath = (char*)JKRAllocFromSysHeap(length, 1);
|
||||
strcpy(newPath, mCurrentPath);
|
||||
strcat(newPath, path);
|
||||
}
|
||||
|
||||
convStrLower(newPath);
|
||||
return newPath;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D5624-802D566C 2CFF64 0048+00 2/2 0/0 0/0 .text convStrLower__12JKRFileCacheCFPc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::convStrLower(char* param_0) const {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/convStrLower__12JKRFileCacheCFPc.s"
|
||||
void JKRFileCache::convStrLower(char* buffer) const {
|
||||
while (*buffer) {
|
||||
*buffer++ = tolower(*buffer);
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D566C-802D56C8 2CFFAC 005C+00 1/1 0/0 0/0 .text __ct__Q212JKRFileCache11CCacheBlockFUlUlPCv
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm JKRFileCache::CCacheBlock::CCacheBlock(u32 param_0, u32 param_1, void const* param_2) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/__ct__Q212JKRFileCache11CCacheBlockFUlUlPCv.s"
|
||||
JKRFileCache::CCacheBlock::CCacheBlock(u32 fileId, u32 fileSize, const void* resource)
|
||||
: mCacheBlockLink(this) {
|
||||
mReferenceCount = 1;
|
||||
mFileId = fileId;
|
||||
mFileSize = fileSize;
|
||||
mMemoryPtr = (void*)resource; // todo: don't cast away const
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D56C8-802D56F4 2D0008 002C+00 1/0 0/0 0/0 .text getFsResource__12JKRFileCacheFPCc
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getFsResource(char const* param_0) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getFsResource__12JKRFileCacheFPCc.s"
|
||||
void* JKRFileCache::getFsResource(const char* path) {
|
||||
return getResource(path);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D56F4-802D5720 2D0034 002C+00 1/0 0/0 0/0 .text getNameResource__12JKRFileCacheFUlPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::getNameResource(u32 param_0, char const* param_1) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/getNameResource__12JKRFileCacheFUlPCc.s"
|
||||
void* JKRFileCache::getNameResource(u32 type, const char* path) {
|
||||
return getResource(type, path);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D5720-802D574C 2D0060 002C+00 1/0 0/0 0/0 .text readFsResource__12JKRFileCacheFPvUlPCc */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::readFsResource(void* param_0, u32 param_1, char const* param_2) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/readFsResource__12JKRFileCacheFPvUlPCc.s"
|
||||
u32 JKRFileCache::readFsResource(void* dst, u32 dstLength, const char* path) {
|
||||
return readResource(dst, dstLength, path);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 802D574C-802D5778 2D008C 002C+00 1/0 0/0 0/0 .text readNameResource__12JKRFileCacheFPvUlUlPCc
|
||||
*/
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void JKRFileCache::readNameResource(void* param_0, u32 param_1, u32 param_2,
|
||||
char const* param_3) {
|
||||
nofralloc
|
||||
#include "asm/JSystem/JKernel/JKRFileCache/readNameResource__12JKRFileCacheFPvUlUlPCc.s"
|
||||
u32 JKRFileCache::readNameResource(void* dst, u32 dstLength, u32 type, const char* path) {
|
||||
return readResource(dst, dstLength, type, path);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8039D158-8039D158 0297B8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
|
||||
|
||||
Reference in New Issue
Block a user