mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-10 12:22:12 -04:00
Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DManage.h"
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include <cstring>
|
||||
|
||||
void* J2DDataManage::get(char const* name) {
|
||||
J2DataManageLink* link;
|
||||
for (link = mList; link != NULL; link = link->mNext) {
|
||||
if (strcmp(link->mName, name) == 0) {
|
||||
return link->mData;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* J2DDataManage::get(JSUInputStream* inputStream) {
|
||||
inputStream->skip(1);
|
||||
u8 nameLen = inputStream->readU8();
|
||||
|
||||
if (nameLen == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char nameBuffer[257];
|
||||
inputStream->read(&nameBuffer, nameLen);
|
||||
nameBuffer[nameLen] = 0;
|
||||
return this->get(nameBuffer);
|
||||
}
|
||||
|
||||
char* J2DResReference::getResReference(u16 idx) const {
|
||||
if (mCount <= idx || idx == 0xFFFF) {
|
||||
return NULL;
|
||||
}
|
||||
u16 offset = mOffsets[idx];
|
||||
return ((char*)this) + offset;
|
||||
}
|
||||
|
||||
char* J2DResReference::getName(u16 idx) const {
|
||||
static char p_name[257];
|
||||
|
||||
char* resRef = (char*)this->getResReference(idx);
|
||||
|
||||
if (resRef == NULL) {
|
||||
p_name[0] = 0;
|
||||
return p_name;
|
||||
} else {
|
||||
switch (resRef[0]) {
|
||||
case 2:
|
||||
case 3:
|
||||
for (s32 i = 0; i < resRef[1]; i++) {
|
||||
p_name[i] = resRef[2 + i];
|
||||
}
|
||||
p_name[resRef[1]] = 0;
|
||||
break;
|
||||
case 4: {
|
||||
s32 tmp = resRef[1];
|
||||
s32 pos = tmp + 1;
|
||||
for (; pos >= 2; pos--) {
|
||||
if (resRef[pos] == '\\' || resRef[pos] == '/') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s32 i = 0;
|
||||
pos++;
|
||||
for (; pos < resRef[1] + 2; i++, pos++) {
|
||||
p_name[i] = resRef[pos];
|
||||
}
|
||||
p_name[i] = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
p_name[0] = 0;
|
||||
}
|
||||
return p_name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user