Match and link all remaining stream classes

This commit is contained in:
Phillip Stephens 2022-10-12 23:09:15 -07:00
parent ef751ff69f
commit 55617d2753
32 changed files with 75 additions and 91 deletions

View File

@ -10,12 +10,6 @@
"editor.tabSize": 2, "editor.tabSize": 2,
"files.associations": { "files.associations": {
"source_location": "cpp", "source_location": "cpp",
"console_io.h": "c",
"file_struc.h": "c",
"osreset.h": "c",
"vi.h": "c",
"gxstruct.h": "c",
"vifuncs.h": "c"
}, },
"files.autoSave": "onFocusChange", "files.autoSave": "onFocusChange",
"files.insertFinalNewline": true, "files.insertFinalNewline": true,

View File

@ -3,8 +3,8 @@
.section .data .section .data
.balign 8 .balign 8
.global lbl_803EE3A8 .global __vt__16CMemoryStreamOut
lbl_803EE3A8: __vt__16CMemoryStreamOut:
# ROM: 0x3EB3A8 # ROM: 0x3EB3A8
.4byte 0 .4byte 0
.4byte 0 .4byte 0
@ -56,8 +56,8 @@ __dt__16CMemoryStreamOutFv:
/* 8033F2D4 0033C234 93 C1 00 08 */ stw r30, 8(r1) /* 8033F2D4 0033C234 93 C1 00 08 */ stw r30, 8(r1)
/* 8033F2D8 0033C238 7C 7E 1B 79 */ or. r30, r3, r3 /* 8033F2D8 0033C238 7C 7E 1B 79 */ or. r30, r3, r3
/* 8033F2DC 0033C23C 41 82 00 44 */ beq lbl_8033F320 /* 8033F2DC 0033C23C 41 82 00 44 */ beq lbl_8033F320
/* 8033F2E0 0033C240 3C 80 80 3F */ lis r4, lbl_803EE3A8@ha /* 8033F2E0 0033C240 3C 80 80 3F */ lis r4, __vt__16CMemoryStreamOut@ha
/* 8033F2E4 0033C244 38 04 E3 A8 */ addi r0, r4, lbl_803EE3A8@l /* 8033F2E4 0033C244 38 04 E3 A8 */ addi r0, r4, __vt__16CMemoryStreamOut@l
/* 8033F2E8 0033C248 90 1E 00 00 */ stw r0, 0(r30) /* 8033F2E8 0033C248 90 1E 00 00 */ stw r0, 0(r30)
/* 8033F2EC 0033C24C 48 00 02 89 */ bl Flush__13COutputStreamFv /* 8033F2EC 0033C24C 48 00 02 89 */ bl Flush__13COutputStreamFv
/* 8033F2F0 0033C250 88 1E 00 88 */ lbz r0, 0x88(r30) /* 8033F2F0 0033C250 88 1E 00 88 */ lbz r0, 0x88(r30)
@ -97,9 +97,9 @@ __ct__16CMemoryStreamOutFPvUlQ216CMemoryStreamOut10EOwnerShipi:
/* 8033F364 0033C2C4 93 81 00 10 */ stw r28, 0x10(r1) /* 8033F364 0033C2C4 93 81 00 10 */ stw r28, 0x10(r1)
/* 8033F368 0033C2C8 7C 7C 1B 78 */ mr r28, r3 /* 8033F368 0033C2C8 7C 7C 1B 78 */ mr r28, r3
/* 8033F36C 0033C2CC 48 00 03 91 */ bl __ct__13COutputStreamFi /* 8033F36C 0033C2CC 48 00 03 91 */ bl __ct__13COutputStreamFi
/* 8033F370 0033C2D0 3C 60 80 3F */ lis r3, lbl_803EE3A8@ha /* 8033F370 0033C2D0 3C 60 80 3F */ lis r3, __vt__16CMemoryStreamOut@ha
/* 8033F374 0033C2D4 7F E0 00 34 */ cntlzw r0, r31 /* 8033F374 0033C2D4 7F E0 00 34 */ cntlzw r0, r31
/* 8033F378 0033C2D8 38 63 E3 A8 */ addi r3, r3, lbl_803EE3A8@l /* 8033F378 0033C2D8 38 63 E3 A8 */ addi r3, r3, __vt__16CMemoryStreamOut@l
/* 8033F37C 0033C2DC 38 80 00 00 */ li r4, 0 /* 8033F37C 0033C2DC 38 80 00 00 */ li r4, 0
/* 8033F380 0033C2E0 90 7C 00 00 */ stw r3, 0(r28) /* 8033F380 0033C2E0 90 7C 00 00 */ stw r3, 0(r28)
/* 8033F384 0033C2E4 54 00 D9 7E */ srwi r0, r0, 5 /* 8033F384 0033C2E4 54 00 D9 7E */ srwi r0, r0, 5

View File

@ -38,7 +38,5 @@ Alloc__11CZipSupportFPvUiUi:
lbl_803D7A88: lbl_803D7A88:
# ROM: 0x3D4A88 # ROM: 0x3D4A88
.asciz "??(??)" .asciz "??(??)"
.byte 0x31 .asciz "1.1.3"
.asciz ".1.3"
.balign 4 .balign 4

View File

@ -619,10 +619,10 @@ LIBS = [
"Kyoto/rstl/RstlExtras", "Kyoto/rstl/RstlExtras",
["Kyoto/Streams/CInputStream", True], ["Kyoto/Streams/CInputStream", True],
["Kyoto/Streams/CMemoryInStream", True], ["Kyoto/Streams/CMemoryInStream", True],
"Kyoto/Streams/CMemoryStreamOut", ["Kyoto/Streams/CMemoryStreamOut", True],
"Kyoto/Streams/COutputStream", ["Kyoto/Streams/COutputStream", True],
"Kyoto/Streams/CZipInputStream", ["Kyoto/Streams/CZipInputStream", True],
"Kyoto/Streams/CZipSupport", ["Kyoto/Streams/CZipSupport", True],
"Kyoto/CSimplePool", "Kyoto/CSimplePool",
"Kyoto/CToken", "Kyoto/CToken",
["Kyoto/IObj", True], ["Kyoto/IObj", True],

View File

@ -14,7 +14,7 @@ public:
CInputStream(int len); CInputStream(int len);
CInputStream(const void* ptr, int len, bool owned); CInputStream(const void* ptr, int len, bool owned);
virtual ~CInputStream(); virtual ~CInputStream();
virtual uint Read(void* dest, uint len) = 0; virtual size_t Read(void* dest, size_t len) = 0;
float ReadFloat(); float ReadFloat();
u64 ReadLongLong(); u64 ReadLongLong();
@ -23,7 +23,7 @@ public:
bool ReadBool(); bool ReadBool();
uchar ReadChar(); uchar ReadChar();
uint ReadBits(uint len); uint ReadBits(uint len);
uint ReadBytes(void* dest, unsigned long len); size_t ReadBytes(void* dest, size_t len);
void Get(void* dest, unsigned long len); void Get(void* dest, unsigned long len);
template < typename T > template < typename T >

View File

@ -13,7 +13,7 @@ public:
CMemoryInStream(const void* ptr, unsigned long len); CMemoryInStream(const void* ptr, unsigned long len);
CMemoryInStream(const void* ptr, unsigned long len, EOwnerShip ownership); CMemoryInStream(const void* ptr, unsigned long len, EOwnerShip ownership);
virtual ~CMemoryInStream() override {} virtual ~CMemoryInStream() override {}
virtual uint Read(void* dest, uint len) override; virtual size_t Read(void* dest, size_t len) override;
}; };
#endif // _CMEMORYINSTREAM #endif // _CMEMORYINSTREAM

View File

@ -10,14 +10,17 @@ public:
kOS_NotOwned, kOS_NotOwned,
}; };
CMemoryStreamOut(void* buffer, size_t len, EOwnerShip ownerShip = kOS_NotOwned, int blockLen = 4096); CMemoryStreamOut(void* buffer, size_t len, EOwnerShip ownerShip = kOS_NotOwned,
int blockLen = 4096);
virtual ~CMemoryStreamOut(); virtual ~CMemoryStreamOut();
void Write(const void* ptr, size_t len);
private: private:
u8* x7c_ptr; void* mOutPtr;
u32 x80_len; size_t mOutLength;
u32 x84_position; size_t mCurrentPosition;
bool x88_owned; bool mBufferOwned;
}; };
#endif // _CMEMORYSTREAMOUT #endif // _CMEMORYSTREAMOUT

View File

@ -11,15 +11,15 @@ void coutput_stream_helper(const T& t, COutputStream& out);
class COutputStream { class COutputStream {
void DoPut(const void* ptr, size_t len); void DoPut(const void* ptr, size_t len);
void Flush();
void DoFlush(); void DoFlush();
public: public:
COutputStream(int len); COutputStream(int len);
virtual ~COutputStream(); virtual ~COutputStream();
virtual void Write(const void* ptr, u32 len); virtual void Write(const void* ptr, size_t len) = 0;
void WriteBits(uint val, uint bitCount); void WriteBits(uint val, uint bitCount);
void Flush();
void FlushShiftRegister(); void FlushShiftRegister();
void Put(const void* ptr, size_t len) { void Put(const void* ptr, size_t len) {
FlushShiftRegister(); FlushShiftRegister();

View File

@ -6,17 +6,20 @@
#include "Kyoto/Streams/CInputStream.hpp" #include "Kyoto/Streams/CInputStream.hpp"
#include "rstl/auto_ptr.hpp" #include "rstl/auto_ptr.hpp"
#include "rstl/single_ptr.hpp"
#include "zlib/zlib.h"
class CZipInputStream : public CInputStream { class CZipInputStream : public CInputStream {
public: public:
CZipInputStream(rstl::auto_ptr< CInputStream > in); CZipInputStream(rstl::auto_ptr< CInputStream > in);
~CZipInputStream() override; ~CZipInputStream() override;
uint Read(void* dest, uint len) override; size_t Read(void* dest, size_t len) override;
private: private:
uchar* x24_compBuf; rstl::single_ptr<uchar> mCompBuf;
rstl::auto_ptr< CInputStream > x28_stream; rstl::auto_ptr< CInputStream > mStream;
unkptr x30_zstream; rstl::single_ptr<z_stream_s> mZStream;
}; };
#endif // _CZIPINPUTSTREAM #endif // _CZIPINPUTSTREAM

View File

@ -28,8 +28,8 @@
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
*/ */
#ifndef _ZLIB_H #ifndef _ZLIB
#define _ZLIB_H #define _ZLIB
#include "zconf.h" #include "zconf.h"
@ -890,4 +890,4 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
} }
#endif #endif
#endif /* _ZLIB_H */ #endif // _ZLIB

View File

@ -558,10 +558,10 @@ KYOTO_1 :=\
$(BUILD_DIR)/asm/Kyoto/rstl/RstlExtras.o\ $(BUILD_DIR)/asm/Kyoto/rstl/RstlExtras.o\
$(BUILD_DIR)/src/Kyoto/Streams/CInputStream.o\ $(BUILD_DIR)/src/Kyoto/Streams/CInputStream.o\
$(BUILD_DIR)/src/Kyoto/Streams/CMemoryInStream.o\ $(BUILD_DIR)/src/Kyoto/Streams/CMemoryInStream.o\
$(BUILD_DIR)/asm/Kyoto/Streams/CMemoryStreamOut.o\ $(BUILD_DIR)/src/Kyoto/Streams/CMemoryStreamOut.o\
$(BUILD_DIR)/asm/Kyoto/Streams/COutputStream.o\ $(BUILD_DIR)/src/Kyoto/Streams/COutputStream.o\
$(BUILD_DIR)/asm/Kyoto/Streams/CZipInputStream.o\ $(BUILD_DIR)/src/Kyoto/Streams/CZipInputStream.o\
$(BUILD_DIR)/asm/Kyoto/Streams/CZipSupport.o\ $(BUILD_DIR)/src/Kyoto/Streams/CZipSupport.o\
$(BUILD_DIR)/asm/Kyoto/CSimplePool.o\ $(BUILD_DIR)/asm/Kyoto/CSimplePool.o\
$(BUILD_DIR)/asm/Kyoto/CToken.o\ $(BUILD_DIR)/asm/Kyoto/CToken.o\
$(BUILD_DIR)/src/Kyoto/IObj.o\ $(BUILD_DIR)/src/Kyoto/IObj.o\

View File

@ -65,7 +65,7 @@ void CInputStream::Get(void* dest, unsigned long len) {
x18_readPosition += readCount; x18_readPosition += readCount;
} }
uint CInputStream::ReadBytes(void* dest, unsigned long len) { size_t CInputStream::ReadBytes(void* dest, size_t len) {
if (len == 0) { if (len == 0) {
return 0; return 0;
} }

View File

@ -6,4 +6,4 @@ CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len, EOwnerShip
CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len) CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len)
: CInputStream(ptr, len, false) {} : CInputStream(ptr, len, false) {}
uint CMemoryInStream::Read(void* dest, uint len) { return 0; } size_t CMemoryInStream::Read(void* dest, size_t len) { return 0; }

View File

@ -75,32 +75,18 @@ void COutputStream::WriteBits(uint value, uint bitCount) {
uint registerOffset = mShiftRegisterOffset; uint registerOffset = mShiftRegisterOffset;
if (registerOffset >= bitCount) { if (registerOffset >= bitCount) {
registerOffset -= bitCount; int off = registerOffset - bitCount;
uint mask = 0xffffffff; mShiftRegister |= ((value & (bitCount != 32 ? (1 << bitCount) - 1 : 0xffffffff)) << off);
uint shiftRegister = mShiftRegister;
if (bitCount != 32) {
mask = (1 << bitCount) - 1;
}
mShiftRegister = shiftRegister | ((value & mask) << registerOffset);
mShiftRegisterOffset -= bitCount; mShiftRegisterOffset -= bitCount;
} else { } else {
uint shiftAmt = bitCount - registerOffset; uint shiftAmt = bitCount - registerOffset;
uint shiftRegister = mShiftRegister; uint shiftA = value >> shiftAmt;
uint mask = 0xffffffff;
if (registerOffset != 0x20) {
mask = (1 << registerOffset) - 1;
}
shiftRegister |= (value >> shiftAmt); mShiftRegister |= (shiftA & (registerOffset != 0x20 ? (1 << registerOffset) - 1 : 0xffffffff));
shiftRegister &= mask;
mShiftRegister = shiftRegister;
mShiftRegisterOffset = 0; mShiftRegisterOffset = 0;
FlushShiftRegister(); FlushShiftRegister();
uint mask2 = 0xffffffff; int shift = (32 - shiftAmt);
if (shiftAmt != 32) { mShiftRegister = (value & (shiftAmt != 32 ? (1 << shiftAmt) - 1 : 0xffffffff)) << shift;
mask2 = (1 << shiftAmt) - 1;
}
mShiftRegister = (value & mask2) << (32 - shiftAmt);
mShiftRegisterOffset -= shiftAmt; mShiftRegisterOffset -= shiftAmt;
} }
} }

View File

@ -5,7 +5,7 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib/zlib.h"
#define BASE 65521L /* largest prime smaller than 65536 */ #define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5552 #define NMAX 5552

View File

@ -3,11 +3,11 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "infblock.h" #include "zlib/infblock.h"
#include "inftrees.h" #include "zlib/inftrees.h"
#include "infcodes.h" #include "zlib/infcodes.h"
#include "infutil.h" #include "zlib/infutil.h"
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ struct inflate_codes_state {int dummy;}; /* for buggy compilers */

View File

@ -3,12 +3,12 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "inftrees.h" #include "zlib/inftrees.h"
#include "infblock.h" #include "zlib/infblock.h"
#include "infcodes.h" #include "zlib/infcodes.h"
#include "infutil.h" #include "zlib/infutil.h"
#include "inffast.h" #include "zlib/inffast.h"
/* simplify the use of the inflate_huft type with some defines */ /* simplify the use of the inflate_huft type with some defines */
#define exop word.what.Exop #define exop word.what.Exop

View File

@ -3,12 +3,12 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "inftrees.h" #include "zlib/inftrees.h"
#include "infblock.h" #include "zlib/infblock.h"
#include "infcodes.h" #include "zlib/infcodes.h"
#include "infutil.h" #include "zlib/infutil.h"
#include "inffast.h" #include "zlib/inffast.h"
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ struct inflate_codes_state {int dummy;}; /* for buggy compilers */

View File

@ -3,8 +3,8 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "infblock.h" #include "zlib/infblock.h"
struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ struct inflate_blocks_state {int dummy;}; /* for buggy compilers */

View File

@ -3,8 +3,8 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "inftrees.h" #include "zlib/inftrees.h"
#if !defined(BUILDFIXED) && !defined(STDC) #if !defined(BUILDFIXED) && !defined(STDC)
# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ # define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
@ -392,7 +392,7 @@ local uInt fixed_bd;
local inflate_huft *fixed_tl; local inflate_huft *fixed_tl;
local inflate_huft *fixed_td; local inflate_huft *fixed_td;
#else #else
#include "inffixed.h" #include "zlib/inffixed.h"
#endif #endif

View File

@ -3,11 +3,11 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zutil.h" #include "zlib/zutil.h"
#include "infblock.h" #include "zlib/infblock.h"
#include "inftrees.h" #include "zlib/inftrees.h"
#include "infcodes.h" #include "zlib/infcodes.h"
#include "infutil.h" #include "zlib/infutil.h"
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ struct inflate_codes_state {int dummy;}; /* for buggy compilers */

View File

@ -5,7 +5,7 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zutil.h" #include "zlib/zutil.h"
struct internal_state {int dummy;}; /* for buggy compilers */ struct internal_state {int dummy;}; /* for buggy compilers */