Finalise JUtility cleanup

This commit is contained in:
intns 2024-05-02 12:46:06 +01:00
parent 71a46aa225
commit 08d4ec0d57
5 changed files with 21 additions and 20 deletions

View File

@ -8,11 +8,11 @@ struct JKRArchive;
struct JUTResReference {
enum ResType {
RESTYPE_Null = 0,
RESTYPE_Unk1 = 1,
RESTYPE_Unk2 = 2,
RESTYPE_Unk3 = 3,
RESTYPE_Unk4 = 4,
RESTYPE_Null = 0,
RESTYPE_None = 1,
RESTYPE_GlobalArchive = 2,
RESTYPE_FileLoaderArchive = 3,
RESTYPE_FileLoader = 4,
};
JUTResReference() { mType = 0; }

View File

@ -16,7 +16,7 @@ int JUTDirectFile::fetch32byte()
// Enable interrupts, read data asynchronously from the DVD into the buffer, then restore the previous interrupt state
int interrupts = OSEnableInterrupts();
int readRes = DVDReadAsync(&mFileInfo, mSectorStart, ALIGN_NEXT(mToRead, DVD_MIN_TRANSFER_SIZE),
ALIGN_PREV(mPos, DVD_MIN_TRANSFER_SIZE), nullptr);
ALIGN_PREV(mPos, DVD_MIN_TRANSFER_SIZE), nullptr);
OSRestoreInterrupts(interrupts);
// If the read operation failed, return -1. Otherwise, wait for the command block to finish and return the number of bytes read

View File

@ -13,7 +13,7 @@ void* JUTResReference::getResource(JSUInputStream* stream, u32 resType, JKRArchi
stream->read(&mNameLength, 1);
stream->read(&mName, mNameLength);
if (mType == RESTYPE_Unk2 || mType == RESTYPE_Unk3 || mType == RESTYPE_Unk4) {
if (mType == RESTYPE_GlobalArchive || mType == RESTYPE_FileLoaderArchive || mType == RESTYPE_FileLoader) {
mName[mNameLength] = 0;
}
@ -32,7 +32,7 @@ void* JUTResReference::getResource(const void* data, u32 resType, JKRArchive* ar
memcpy(&mName, &((u8*)data)[2], mNameLength);
}
if (mType == RESTYPE_Unk2 || mType == RESTYPE_Unk3 || mType == RESTYPE_Unk4) {
if (mType == RESTYPE_GlobalArchive || mType == RESTYPE_FileLoaderArchive || mType == RESTYPE_FileLoader) {
mName[mNameLength] = 0;
}
@ -47,15 +47,15 @@ void* JUTResReference::getResource(u32 resType, JKRArchive* archive)
{
void* res = nullptr;
switch (mType) {
case RESTYPE_Unk1:
case RESTYPE_None:
break;
case RESTYPE_Unk2:
case RESTYPE_GlobalArchive:
res = JKRArchive::getGlbResource(resType, mName, archive);
break;
case RESTYPE_Unk3:
case RESTYPE_FileLoaderArchive:
res = JKRFileLoader::getGlbResource(mName, archive);
break;
case RESTYPE_Unk4:
case RESTYPE_FileLoader:
res = JKRFileLoader::getGlbResource(mName);
break;
}

View File

@ -44,6 +44,7 @@ JUTRomFont::~JUTRomFont()
spFontHeader_ = nullptr;
spAboutEncoding_ = nullptr;
}
mIsValid = false;
}

View File

@ -87,21 +87,21 @@ void JUTXfb::destroyManager()
* @note Address: 0x80033E48
* @note Size: 0xE8
*/
void JUTXfb::initiate(u16 p1, u16 p2, JKRHeap* heap, JUTXfb::EXfbNumber number)
void JUTXfb::initiate(u16 width, u16 height, JKRHeap* heap, JUTXfb::EXfbNumber number)
{
if (heap == nullptr) {
heap = JKRHeap::getSystemHeap();
}
u16 v2 = ALIGN_NEXT(p1, 0x10);
u32 v1 = v2 * p2;
int flags = 0x20;
v1 <<= 1;
u16 alignedWidth = ALIGN_NEXT(width, 0x10);
u32 alignedHeight = alignedWidth * height;
int flags = 0x20;
alignedHeight <<= 1;
mBuffers[0] = new (heap, flags) u8[v1];
mBuffers[0] = new (heap, flags) u8[alignedHeight];
mEnabled[0] = true;
if (number >= DoubleBuffer) {
mBuffers[1] = new (heap, flags) u8[v1];
mBuffers[1] = new (heap, flags) u8[alignedHeight];
mEnabled[1] = true;
} else {
mBuffers[1] = nullptr;
@ -109,7 +109,7 @@ void JUTXfb::initiate(u16 p1, u16 p2, JKRHeap* heap, JUTXfb::EXfbNumber number)
}
if (number >= TripleBuffer) {
mBuffers[2] = new (heap, flags) u8[v1];
mBuffers[2] = new (heap, flags) u8[alignedHeight];
mEnabled[2] = true;
} else {
mBuffers[2] = nullptr;