mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-12 04:57:06 -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,91 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#ifdef __REVOLUTION_SDK__
|
||||
#include <revolution.h>
|
||||
#else
|
||||
#include <dolphin.h>
|
||||
#endif
|
||||
|
||||
JSUInputStream::~JSUInputStream() {
|
||||
if (!isGood()) {
|
||||
OS_REPORT("JSUInputStream: occur error.\n");
|
||||
}
|
||||
}
|
||||
|
||||
s32 JSUInputStream::read(void* buffer, s32 numBytes) {
|
||||
s32 bytesRead = readData(buffer, numBytes);
|
||||
if (bytesRead != numBytes) {
|
||||
setState(IOS_STATE_1);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
char* JSUInputStream::read(char* str) {
|
||||
u16 sp8;
|
||||
if (readData(&sp8, sizeof(sp8)) != sizeof(sp8)) {
|
||||
*str = 0;
|
||||
setState(IOS_STATE_1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 len = readData(str, sp8);
|
||||
str[len] = 0;
|
||||
if (len != sp8) {
|
||||
setState(IOS_STATE_1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
s32 JSUInputStream::skip(s32 count) {
|
||||
s32 skipCount;
|
||||
for (skipCount = 0; skipCount < count; skipCount++) {
|
||||
u8 buffer;
|
||||
if (readData(&buffer, sizeof(buffer)) != sizeof(buffer)) {
|
||||
setState(IOS_STATE_1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return skipCount;
|
||||
}
|
||||
|
||||
s32 JSURandomInputStream::align(s32 alignment) {
|
||||
s32 seekLen = 0;
|
||||
s32 currentPos = getPosition();
|
||||
|
||||
s32 offset = (alignment - 1 + currentPos) & ~(alignment - 1);
|
||||
s32 alignmentOffset = offset - currentPos;
|
||||
|
||||
if (alignmentOffset != 0) {
|
||||
seekLen = seekPos(offset, JSUStreamSeekFrom_SET);
|
||||
if (seekLen != alignmentOffset) {
|
||||
setState(IOS_STATE_1);
|
||||
}
|
||||
}
|
||||
return alignmentOffset;
|
||||
}
|
||||
|
||||
s32 JSURandomInputStream::skip(s32 param_0) {
|
||||
s32 val = seekPos(param_0, JSUStreamSeekFrom_CUR);
|
||||
if (val != param_0) {
|
||||
setState(IOS_STATE_1);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
s32 JSURandomInputStream::peek(void* buffer, s32 numBytes) {
|
||||
s32 oldPos = getPosition();
|
||||
s32 bytesRead = read(buffer, numBytes);
|
||||
if (bytesRead != 0) {
|
||||
seekPos(oldPos, JSUStreamSeekFrom_SET);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
s32 JSURandomInputStream::seek(s32 param_0, JSUStreamSeekFrom param_1) {
|
||||
s32 seekResult = seekPos(param_0, param_1);
|
||||
clrState(IOS_STATE_1);
|
||||
return seekResult;
|
||||
}
|
||||
Reference in New Issue
Block a user