diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-01-19 21:05:53 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 22:05:53 -0700 |
| commit | e0824a15908f4e6ad70d3d0f2364efe043a98c0f (patch) | |
| tree | 3e85ea5ea5282c7ca3397a3adc1535674fc496aa /include/JSystem/JSupport | |
| parent | 7137f49bfc9535d95f980fb92552adf7b7c3c3ce (diff) | |
most of JHostIO / m_Do_hostIO done (#2288)
Diffstat (limited to 'include/JSystem/JSupport')
| -rw-r--r-- | include/JSystem/JSupport/JSUInputStream.h | 34 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSUIosBase.h | 13 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSUMemoryStream.h | 28 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSUOutputStream.h | 52 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSURandomOutputStream.h | 24 |
5 files changed, 137 insertions, 14 deletions
diff --git a/include/JSystem/JSupport/JSUInputStream.h b/include/JSystem/JSupport/JSUInputStream.h index 411f8c02ad..dc35d5ab91 100644 --- a/include/JSystem/JSupport/JSUInputStream.h +++ b/include/JSystem/JSupport/JSUInputStream.h @@ -3,12 +3,6 @@ #include "JSystem/JSupport/JSUIosBase.h" -enum JSUStreamSeekFrom { - JSUStreamSeekFrom_SET = 0, // absolute - JSUStreamSeekFrom_CUR = 1, // relative - JSUStreamSeekFrom_END = 2, // relative to end -}; - /** * @ingroup jsystem-jsupport * @@ -70,18 +64,38 @@ public: return val; } - JSUInputStream* operator>>(u8& dest) { + JSUInputStream& operator>>(u32& dest) { + read(&dest, 4); + return *this; + } + + JSUInputStream& operator>>(u16& dest) { + read(&dest, 2); + return *this; + } + + JSUInputStream& operator>>(u8& dest) { read(&dest, 1); - return this; + return *this; } - JSUInputStream* operator>>(s16& dest) { + JSUInputStream& operator>>(s16& dest) { read(&dest, 2); - return this; + return *this; + } + + JSUInputStream& operator>>(char* dest) { + read(dest); + return *this; + } + + s32 read(u32& param_0) { + return read(¶m_0, 4); } // TODO: return value probably wrong /* 802DC298 */ s32 read(void*, s32); + char* read(char*); }; // Size = 0x8 // move? diff --git a/include/JSystem/JSupport/JSUIosBase.h b/include/JSystem/JSupport/JSUIosBase.h index 761c1d61df..5164cc5a2a 100644 --- a/include/JSystem/JSupport/JSUIosBase.h +++ b/include/JSystem/JSupport/JSUIosBase.h @@ -3,8 +3,10 @@ #include "dolphin/types.h" -enum EIoState { - IOS_STATE_1 = 1, +enum JSUStreamSeekFrom { + JSUStreamSeekFrom_SET = 0, // absolute + JSUStreamSeekFrom_CUR = 1, // relative + JSUStreamSeekFrom_END = 2, // relative to end }; /** @@ -13,6 +15,11 @@ enum EIoState { */ class JSUIosBase { public: + enum EIoState { + IOS_STATE_1 = 1, + IOS_STATE_2 = 2, + }; + JSUIosBase() { mState = false; } virtual ~JSUIosBase() {} @@ -22,7 +29,7 @@ public: void setState(EIoState state) { mState |= state; } private: - u8 mState; + bool mState; }; // Size = 0x8 #endif diff --git a/include/JSystem/JSupport/JSUMemoryStream.h b/include/JSystem/JSupport/JSUMemoryStream.h index 0ef4703555..51b6fb601a 100644 --- a/include/JSystem/JSupport/JSUMemoryStream.h +++ b/include/JSystem/JSupport/JSUMemoryStream.h @@ -2,6 +2,7 @@ #define JSUMEMORYSTREAM_H #include "JSystem/JSupport/JSURandomInputStream.h" +#include "JSystem/JSupport/JSURandomOutputStream.h" /** * @ingroup jsystem-jsupport @@ -9,7 +10,7 @@ */ class JSUMemoryInputStream : public JSURandomInputStream { public: - JSUMemoryInputStream(const void* res, u32 size) { setBuffer(res, size); } + JSUMemoryInputStream(const void* res, s32 size) { setBuffer(res, size); } /* 802552B8 */ virtual ~JSUMemoryInputStream() {} /* 802DC520 */ void setBuffer(void const*, s32); @@ -18,10 +19,35 @@ public: /* 802DC628 */ s32 getLength() const; /* 802DC630 */ s32 getPosition() const; + void* getPointer() const { + return (u8*)mBuffer + mPosition; + } + private: /* 0x08 */ const void* mBuffer; /* 0x0C */ s32 mLength; /* 0x10 */ s32 mPosition; }; // Size = 0x14 +class JSUMemoryOutputStream : public JSURandomOutputStream { +public: + JSUMemoryOutputStream() { setBuffer(NULL, 0); } + JSUMemoryOutputStream(void* buffer, s32 len) { setBuffer(buffer, len); } + + void setBuffer(void* buffer, s32 len); + + virtual ~JSUMemoryOutputStream() {} + virtual s32 writeData(const void*, s32); + virtual s32 getLength() const; + virtual s32 getPosition() const; + virtual s32 seek(s32, JSUStreamSeekFrom); + virtual s32 getAvailable() const; + virtual s32 seekPos(s32, JSUStreamSeekFrom); + +private: + /* 0x08 */ void* mBuffer; + /* 0x0C */ s32 mLength; + /* 0x10 */ s32 mPosition; +}; // Size = 0x14 + #endif /* JSUMEMORYSTREAM_H */ diff --git a/include/JSystem/JSupport/JSUOutputStream.h b/include/JSystem/JSupport/JSUOutputStream.h new file mode 100644 index 0000000000..43d9d37ef0 --- /dev/null +++ b/include/JSystem/JSupport/JSUOutputStream.h @@ -0,0 +1,52 @@ +#ifndef JSUOUTPUTSTREAM_H +#define JSUOUTPUTSTREAM_H + +#include "JSystem/JSupport/JSUIosBase.h" + +/** +* @ingroup jsystem-jsupport +* +*/ +class JSUOutputStream : public JSUIosBase { +public: + JSUOutputStream() {} + virtual ~JSUOutputStream(); + + virtual s32 skip(s32, s8) = 0; + virtual s32 writeData(const void*, s32) = 0; + + s32 write(const void*, s32); + void write(const char*); + + JSUOutputStream& operator<<(u32 param_0) { + write(¶m_0, sizeof(u32)); + return *this; + } + + JSUOutputStream& operator<<(s32 param_0) { + write(¶m_0, sizeof(s32)); + return *this; + } + + JSUOutputStream& operator<<(s16 param_0) { + write(¶m_0, sizeof(s16)); + return *this; + } + + JSUOutputStream& operator<<(u16 param_0) { + write(¶m_0, sizeof(u16)); + return *this; + } + + JSUOutputStream& operator<<(u8 param_0) { + write(¶m_0, sizeof(u8)); + return *this; + } + + JSUOutputStream& operator<<(const char* param_0) { + write(param_0); + return *this; + } +}; // Size = 0x8 + +#endif /* JSUOUTPUTSTREAM_H */ diff --git a/include/JSystem/JSupport/JSURandomOutputStream.h b/include/JSystem/JSupport/JSURandomOutputStream.h new file mode 100644 index 0000000000..1b2648fabb --- /dev/null +++ b/include/JSystem/JSupport/JSURandomOutputStream.h @@ -0,0 +1,24 @@ +#ifndef JSURANDOMOUTPUTSTREAM_H_ +#define JSURANDOMOUTPUTSTREAM_H_ + +#include "JSystem/JSupport/JSUOutputStream.h" + +/** +* @ingroup jsystem-jsupport +* +*/ +class JSURandomOutputStream : public JSUOutputStream { +public: + JSURandomOutputStream() {} + virtual ~JSURandomOutputStream() {} + + /* vt[3] */ virtual s32 skip(s32, s8); + /* vt[4] */ virtual s32 writeData(const void*, s32) = 0; + /* vt[5] */ virtual s32 getLength() const = 0; + /* vt[6] */ virtual s32 getPosition() const = 0; + /* vt[7] */ virtual s32 seek(s32, JSUStreamSeekFrom); + /* vt[8] */ virtual s32 getAvailable() const; + /* vt[9] */ virtual s32 seekPos(s32, JSUStreamSeekFrom) = 0; +}; // Size = 0x8 + +#endif |
