mirror of
https://github.com/encounter/tp.git
synced 2026-07-11 06:18:46 -07:00
JKRArchive (#63)
* JKRArchivePri OK * JKRArchivePub OK * formatting * removed unused asm files and tried to fixed setExpandSize and getExpandSize Co-authored-by: Julgodis <>
This commit is contained in:
co-authored by
Julgodis <>
parent
7215cc6a51
commit
b9ef1d7f4a
@@ -18,17 +18,17 @@ asm void JKRAramArchive::open(long) {
|
||||
#include "JSystem/JKernel/JKRAramArchive/asm/func_802D72A8.s"
|
||||
}
|
||||
|
||||
asm void JKRAramArchive::fetchResource(JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRAramArchive::fetchResource(SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRAramArchive/asm/func_802D75E0.s"
|
||||
}
|
||||
|
||||
asm void JKRAramArchive::fetchResource(void*, u32, JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRAramArchive::fetchResource(void*, u32, SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRAramArchive/asm/func_802D76F4.s"
|
||||
}
|
||||
|
||||
asm void JKRAramArchive::getAramAddress_Entry(JKRArchive::SDIFileEntry*) {
|
||||
asm void JKRAramArchive::getAramAddress_Entry(SDIFileEntry*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRAramArchive/asm/func_802D77F8.s"
|
||||
}
|
||||
|
||||
@@ -1,78 +1,221 @@
|
||||
#include "JSystem/JKernel/JKRArchive/JKRArchive.h"
|
||||
#include "global.h"
|
||||
|
||||
asm JKRArchive::JKRArchive(long, JKRArchive::EMountMode) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6294.s"
|
||||
JKRArchive::JKRArchive(long 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);
|
||||
}
|
||||
}
|
||||
|
||||
asm JKRArchive::~JKRArchive() {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6334.s"
|
||||
JKRArchive::~JKRArchive() {}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::isSameName(JKRArchive::CArcName&, u32, unsigned short) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6394.s"
|
||||
SDirEntry* JKRArchive::findResType(u32 type) const {
|
||||
SDirEntry* node = mNodes;
|
||||
u32 count = 0;
|
||||
while (count < mArcInfoBlock->num_nodes) {
|
||||
if (node->type == type) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node++;
|
||||
count++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findResType(u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D63E0.s"
|
||||
SDirEntry* JKRArchive::findDirectory(const char* name, u32 directoryId) const {
|
||||
if (name == NULL) {
|
||||
return mNodes + directoryId;
|
||||
}
|
||||
|
||||
CArcName arcName(&name, '/');
|
||||
SDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
// regalloc doesn't like fileEntry->getNameHash()
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
return findDirectory(name, fileEntry->data_offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findDirectory(char const*, u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D641C.s"
|
||||
SDIFileEntry* JKRArchive::findTypeResource(u32 type, const char* name) const {
|
||||
if (type) {
|
||||
CArcName arcName(name);
|
||||
SDirEntry* 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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findTypeResource(u32, char const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D64F4.s"
|
||||
SDIFileEntry* JKRArchive::findFsResource(const char* name, u32 directoryId) const {
|
||||
if (name) {
|
||||
CArcName arcName(&name, '/');
|
||||
SDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
// regalloc doesn't like fileEntry->getNameHash()
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
return findFsResource(name, fileEntry->data_offset);
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
return fileEntry;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findFsResource(char const*, u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D65A4.s"
|
||||
SDIFileEntry* JKRArchive::findIdxResource(u32 fileIndex) const {
|
||||
if (fileIndex < mArcInfoBlock->num_file_entries) {
|
||||
return mFiles + fileIndex;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findIdxResource(u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6684.s"
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findNameResource(char const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D66AC.s"
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findPtrResource(void const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6734.s"
|
||||
SDIFileEntry* JKRArchive::findIdResource(u16 id) const {
|
||||
if (id != 0xFFFF) {
|
||||
if (id < mArcInfoBlock->num_file_entries) {
|
||||
SDIFileEntry* fileEntry = mFiles + id;
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::findIdResource(unsigned short) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6770.s"
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::CArcName::store(char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D67F4.s"
|
||||
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;
|
||||
}
|
||||
|
||||
asm const char* JKRArchive::CArcName::store(char const*, char) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6884.s"
|
||||
}
|
||||
// using include vs the JKRArchivePri.s file yields different code
|
||||
// super weird...
|
||||
#if 0
|
||||
#if NONMATCHING
|
||||
void JKRArchive::setExpandSize(SDIFileEntry* fileEntry, u32 expandSize) {
|
||||
int index = fileEntry - mFiles;
|
||||
if (!mExpandedSize)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
asm void JKRArchive::setExpandSize(JKRArchive::SDIFileEntry*, u32) {
|
||||
if (index <= mArcInfoBlock->num_file_entries)
|
||||
return;
|
||||
|
||||
mExpandedSize[index] = expandSize;
|
||||
}
|
||||
#else
|
||||
asm void JKRArchive::setExpandSize(SDIFileEntry* fileEntry, u32 expandSize) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D693C.s"
|
||||
}
|
||||
|
||||
asm void JKRArchive::getExpandSize(JKRArchive::SDIFileEntry*) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
asm void JKRArchive::getExpandSize(SDIFileEntry*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6978.s"
|
||||
}
|
||||
|
||||
@@ -1,119 +1,346 @@
|
||||
#include "JSystem/JKernel/JKRAramArchive/JKRAramArchive.h"
|
||||
#include "JSystem/JKernel/JKRArchive/JKRArchive.h"
|
||||
#include "JSystem/JKernel/JKRCompArchive/JKRCompArchive.h"
|
||||
#include "JSystem/JKernel/JKRDvdArchive/JKRDvdArchive.h"
|
||||
#include "JSystem/JKernel/JKRFileFinder/JKRFileFinder.h"
|
||||
#include "JSystem/JKernel/JKRFileLoader/JKRFileLoader.h"
|
||||
#include "JSystem/JKernel/JKRMemArchive/JKRMemArchive.h"
|
||||
#include "dvd/dvd.h"
|
||||
#include "global.h"
|
||||
|
||||
asm void JKRArchive::check_mount_already(long, JKRHeap*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5778.s"
|
||||
JKRArchive* JKRArchive::check_mount_already(s32 entryNum, JKRHeap* heap) {
|
||||
if (heap == NULL) {
|
||||
heap = JKRHeap::getCurrentHeap();
|
||||
}
|
||||
|
||||
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->mHeap == heap) {
|
||||
archive->mMountCount++;
|
||||
return archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::mount(char const*, JKRArchive::EMountMode, JKRHeap*,
|
||||
JKRArchive::EMountDirection) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D57E4.s"
|
||||
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);
|
||||
}
|
||||
|
||||
asm void JKRArchive::mount(void*, JKRHeap*, JKRArchive::EMountDirection) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5840.s"
|
||||
JKRArchive* JKRArchive::mount(void* ptr, JKRHeap* heap,
|
||||
JKRArchive::EMountDirection mountDirection) {
|
||||
JKRArchive* archive = check_mount_already((s32)ptr, heap);
|
||||
if (archive)
|
||||
return archive;
|
||||
|
||||
int alignment;
|
||||
if (mountDirection == JKRArchive::HEAD) {
|
||||
alignment = 4;
|
||||
} else {
|
||||
alignment = -4;
|
||||
}
|
||||
|
||||
archive = new (heap, alignment) JKRMemArchive(ptr, 0xFFFF, JKRMEMBREAK_FLAG_UNKNOWN0);
|
||||
return archive;
|
||||
}
|
||||
|
||||
asm void JKRArchive::mount(long, JKRArchive::EMountMode, JKRHeap*, JKRArchive::EMountDirection) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D58C8.s"
|
||||
JKRArchive* JKRArchive::mount(s32 entryNum, JKRArchive::EMountMode mountMode, JKRHeap* heap,
|
||||
JKRArchive::EMountDirection mountDirection) {
|
||||
JKRArchive* archive = check_mount_already(entryNum, heap);
|
||||
if (archive != NULL) {
|
||||
return archive;
|
||||
} else {
|
||||
int alignment;
|
||||
if (mountDirection == JKRArchive::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;
|
||||
}
|
||||
}
|
||||
|
||||
asm void JKRArchive::becomeCurrent(char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5A38.s"
|
||||
bool JKRArchive::becomeCurrent(const char* path) {
|
||||
SDirEntry* 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;
|
||||
}
|
||||
|
||||
asm bool JKRArchive::getDirEntry(JKRArchive::SDirEntry*, u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5AC0.s"
|
||||
bool JKRArchive::getDirEntry(SDirEntry* dirEntry, u32 index) const {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (!fileEntry)
|
||||
return false;
|
||||
|
||||
dirEntry->other.flags = fileEntry->getFlags();
|
||||
dirEntry->other.id = fileEntry->getFileID();
|
||||
dirEntry->name = mStringTable + fileEntry->getNameOffset();
|
||||
return true;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getGlbResource(u32, char const*, JKRArchive*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5B38.s"
|
||||
void* JKRArchive::getGlbResource(u32 param_1, const char* path, JKRArchive* archive) {
|
||||
void* resource = NULL;
|
||||
if (archive) {
|
||||
return archive->getResource(param_1, path);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
resource = iterator->getResource(param_1, path);
|
||||
if (resource)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
asm void* JKRArchive::getResource(char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5BE8.s"
|
||||
void* JKRArchive::getResource(const char* path) {
|
||||
SDIFileEntry* fileEntry;
|
||||
if (*path == '/') {
|
||||
fileEntry = findFsResource(path + 1, 0);
|
||||
} else {
|
||||
fileEntry = findFsResource(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void* JKRArchive::getResource(u32, char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5C64.s"
|
||||
void* JKRArchive::getResource(u32 type, const char* path) {
|
||||
SDIFileEntry* fileEntry;
|
||||
if (type == 0 || type == '????') {
|
||||
fileEntry = findNameResource(path);
|
||||
} else {
|
||||
fileEntry = findTypeResource(type, path);
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getIdxResource(u32) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5CE4.s"
|
||||
void* JKRArchive::getIdxResource(u32 index) {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getResource(unsigned short) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5D38.s"
|
||||
void* JKRArchive::getResource(u16 id) {
|
||||
SDIFileEntry* fileEntry = findIdResource(id);
|
||||
if (fileEntry) {
|
||||
return fetchResource(fileEntry, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::readResource(void*, u32, u32, char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5D8C.s"
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u32 type, const char* path) {
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::readResource(void*, u32, char const*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5E30.s"
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, const char* path) {
|
||||
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;
|
||||
}
|
||||
|
||||
asm void JKRArchive::readIdxResource(void*, u32, u32) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5ECC.s"
|
||||
u32 JKRArchive::readIdxResource(void* buffer, u32 bufferSize, u32 index) {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
asm void JKRArchive::readResource(void*, u32, unsigned short) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5F40.s"
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u16 id) {
|
||||
SDIFileEntry* fileEntry = findIdResource(id);
|
||||
if (fileEntry) {
|
||||
u32 resourceSize;
|
||||
fetchResource(buffer, bufferSize, fileEntry, &resourceSize);
|
||||
return resourceSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
asm void JKRArchive::removeResourceAll(void) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D5FB4.s"
|
||||
void JKRArchive::removeResourceAll(void) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asm bool JKRArchive::removeResource(void*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D603C.s"
|
||||
bool JKRArchive::removeResource(void* resource) {
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return false;
|
||||
|
||||
fileEntry->data = NULL;
|
||||
JKRFreeToHeap(mHeap, resource);
|
||||
return true;
|
||||
}
|
||||
|
||||
asm bool JKRArchive::detachResource(void*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D609C.s"
|
||||
bool JKRArchive::detachResource(void* resource) {
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return false;
|
||||
|
||||
fileEntry->data = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getResSize(void const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D60D8.s"
|
||||
u32 JKRArchive::getResSize(const void* resource) const {
|
||||
SDIFileEntry* fileEntry = findPtrResource(resource);
|
||||
if (fileEntry == NULL)
|
||||
return -1;
|
||||
|
||||
return fileEntry->data_size;
|
||||
}
|
||||
|
||||
asm void JKRArchive::countResource(void) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D610C.s"
|
||||
u32 JKRArchive::countResource(void) const {
|
||||
u32 count = 0;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (mFiles[i].isUnknownFlag1()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
asm void JKRArchive::countFile(char const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D6150.s"
|
||||
u32 JKRArchive::countFile(const char* path) const {
|
||||
SDirEntry* dirEntry;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
if (*path == '\0')
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
return dirEntry->num_entries;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getFirstFile(char const*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D61B0.s"
|
||||
JKRArcFinder* JKRArchive::getFirstFile(const char* path) const {
|
||||
SDirEntry* dirEntry;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
if (*path == '\0')
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
// don't know what is correct here... for now we're casting away const
|
||||
return new (JKRHeap::getSystemHeap(), 0)
|
||||
JKRArcFinder((JKRArchive*)this, dirEntry->first_file_index, (u32)dirEntry->num_entries);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asm void JKRArchive::getFileAttribute(u32) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRArchive/asm/func_802D625C.s"
|
||||
u32 JKRArchive::getFileAttribute(u32 index) const {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
return fileEntry->getFlags();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ asm void JKRCompArchive::open(long) {
|
||||
#include "JSystem/JKernel/JKRCompArchive/asm/func_802D89BC.s"
|
||||
}
|
||||
|
||||
asm void JKRCompArchive::fetchResource(JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRCompArchive::fetchResource(SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRCompArchive/asm/func_802D8F40.s"
|
||||
}
|
||||
|
||||
asm void JKRCompArchive::fetchResource(void*, u32, JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRCompArchive::fetchResource(void*, u32, SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRCompArchive/asm/func_802D90C0.s"
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ asm void JKRDvdArchive::open(long) {
|
||||
#include "JSystem/JKernel/JKRDvdArchive/asm/func_802D7DB4.s"
|
||||
}
|
||||
|
||||
asm void JKRDvdArchive::fetchResource(JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRDvdArchive::fetchResource(SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRDvdArchive/asm/func_802D8050.s"
|
||||
}
|
||||
|
||||
asm void JKRDvdArchive::fetchResource(void*, u32, JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRDvdArchive::fetchResource(void*, u32, SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRDvdArchive/asm/func_802D8168.s"
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
#include "dvd/dvd.h"
|
||||
#include "global.h"
|
||||
|
||||
JKRArcFinder::JKRArcFinder(JKRArchive* archive, long startIndex, long numEntries)
|
||||
: JKRFileFinder() {
|
||||
JKRArcFinder::JKRArcFinder(JKRArchive* archive, s32 startIndex, u32 numEntries) : JKRFileFinder() {
|
||||
mArchive = archive;
|
||||
mIsAvailable = numEntries > 0;
|
||||
mIsAvailable = (s32)numEntries > 0;
|
||||
mStartIndex = startIndex;
|
||||
mEndIndex = startIndex + numEntries - 1;
|
||||
mNextIndex = mStartIndex;
|
||||
@@ -14,7 +13,7 @@ JKRArcFinder::JKRArcFinder(JKRArchive* archive, long startIndex, long numEntries
|
||||
}
|
||||
|
||||
bool JKRArcFinder::findNextFile(void) {
|
||||
JKRArchive::SDirEntry entry;
|
||||
SDirEntry entry;
|
||||
|
||||
if (mIsAvailable) {
|
||||
mIsAvailable = !(mNextIndex > mEndIndex);
|
||||
@@ -22,8 +21,8 @@ bool JKRArcFinder::findNextFile(void) {
|
||||
mIsAvailable = mArchive->getDirEntry(&entry, mNextIndex);
|
||||
mEntryName = entry.name;
|
||||
mEntryFileIndex = mNextIndex;
|
||||
mEntryId = entry.id;
|
||||
mEntryTypeFlags = entry.type_flags;
|
||||
mEntryId = entry.other.id;
|
||||
mEntryTypeFlags = entry.other.flags;
|
||||
mIsFileOrDirectory = (mEntryTypeFlags >> 1) & 1;
|
||||
mNextIndex++;
|
||||
}
|
||||
@@ -63,7 +62,7 @@ bool JKRDvdFinder::findNextFile(void) {
|
||||
|
||||
if (mIsAvailable) {
|
||||
mIsFileOrDirectory = directoryEntry.is_directory != 0;
|
||||
mEntryName = directoryEntry.name;
|
||||
mEntryNameOffset = directoryEntry.name;
|
||||
mEntryFileIndex = directoryEntry.entry_number;
|
||||
mEntryId = 0;
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ asm void JKRMemArchive::open(void*, u32, JKRMemBreakFlag) {
|
||||
#include "JSystem/JKernel/JKRMemArchive/asm/func_802D6D30.s"
|
||||
}
|
||||
|
||||
asm void JKRMemArchive::fetchResource(JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRMemArchive::fetchResource(SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRMemArchive/asm/func_802D6DDC.s"
|
||||
}
|
||||
|
||||
asm void JKRMemArchive::fetchResource(void*, u32, JKRArchive::SDIFileEntry*, u32*) {
|
||||
asm void* JKRMemArchive::fetchResource(void*, u32, SDIFileEntry*, u32*) {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRMemArchive/asm/func_802D6E10.s"
|
||||
}
|
||||
@@ -51,7 +51,7 @@ asm void JKRMemArchive::fetchResource_subroutine(u8*, u32, u8*, u32, int) {
|
||||
#include "JSystem/JKernel/JKRMemArchive/asm/func_802D6F5C.s"
|
||||
}
|
||||
|
||||
asm void JKRMemArchive::getExpandedResSize(void const*) const {
|
||||
asm void JKRMemArchive::getExpandedResSize(const void*) const {
|
||||
nofralloc
|
||||
#include "JSystem/JKernel/JKRMemArchive/asm/func_802D7030.s"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user