resonance 1.0.1
Loading...
Searching...
No Matches
IOBPreallocMemStream Class Reference

Bidirectional stream over a caller-supplied byte buffer. More...

#include <iobpreallocmemstream.h>

Inheritance diagram for IOBPreallocMemStream:
Collaboration diagram for IOBPreallocMemStream:

Public Member Functions

 IOBPreallocMemStream (char *pBuffer, int nCapacity)
 Open a stream over a caller-owned buffer.
virtual ~IOBPreallocMemStream ()
 Close the stream.
virtual IBStream & Read (void *pDest, int nSize)
virtual IBStream & Seek (int nOffset, int nWhence)
virtual int Tell ()
virtual int Eof ()
virtual int Fail ()
 Test whether a transfer has failed.
virtual IBStream & Flush ()
virtual void SetSize (int nSize)
 Record how many bytes a reader may consume.
virtual char * Buffer ()
 Report the caller-owned buffer.
int Size ()
 Report how many bytes have been written.
int Capacity ()
 Report the buffer size passed to the constructor.
virtual OBStream & Write (const void *pSrc, int nSize)
virtual OBStream & Reset ()
Public Member Functions inherited from IBStream
virtual IBStream & ReadLE (void *pDest, int nSize)
 Move nSize bytes into pDest through the virtual Read().
virtual ~IBStream ()
 Close the stream.
Public Member Functions inherited from OBStream
virtual OBStream & WriteLE (const void *pSrc, int nSize)
 Move nSize bytes out of pSrc through the virtual Write().

Public Attributes

char * mBuffer
 Caller-owned byte buffer, which the constructor records and the destructor does not release.

Detailed Description

Bidirectional stream over a caller-supplied byte buffer.

Its RTTI descriptor is at 0x008ef160. The base list at 0x008242c8 records two bases, IBStream at offset 0 and OBStream at offset 4, both public and non-virtual. IOBStream shares that base list and is not in the chain. This class is therefore a sibling of IOBStream rather than a subclass, and the type function at 0x004eda70 confirms it.

The object is 0x20 bytes. Two vtable pointers occupy +0x00 and +0x04, addressing 0x00824110 for the IBStream subobject and 0x008240e0 for the OBStream subobject, whose entries adjust this by -0x04. The six data members follow at +0x08 through +0x1f.

Nothing is allocated. The constructor records the buffer and its capacity, and the destructor releases nothing, so the caller owns the storage for the life of the stream. Reads consume up to the write position rather than up to the capacity, which makes the stream a first-in first-out buffer with a separate read cursor.

The two halves report failure differently, and the difference is in the binary rather than in this reconstruction. A short read is clamped and sets both the end flag and the failure flag, while a write that would pass the capacity transfers nothing and sets only the failure flag.

Twelve call sites construct one. Globals::InitServices() allocates a stream over the 0x19000 byte log buffer at 0x0086f7d0, and eleven memory card task constructors build one over the 0xf000 byte buffer at 0x008f2aa0. The memory card tasks embed the stream as a member and destroy it inline.

Constructor & Destructor Documentation

◆ IOBPreallocMemStream()

IOBPreallocMemStream::IOBPreallocMemStream ( char * pBuffer,
int nCapacity )

Open a stream over a caller-owned buffer.

Parameters
pBufferThe buffer to read and write. The stream does not take ownership.
nCapacityThe buffer size in bytes.
Ghidra address:
NTSC-U/C: 0x004ee2f8
Ghidra address:
PAL: 0x0052cea0

◆ ~IOBPreallocMemStream()

virtual IOBPreallocMemStream::~IOBPreallocMemStream ( )
virtual

Close the stream.

IBStream vtable slot 8. The buffer is not released.

Ghidra address:
NTSC-U/C: 0x004edb00
Ghidra address:
PAL: 0x0052c6a8

Member Function Documentation

◆ Read()

virtual IBStream & IOBPreallocMemStream::Read ( void * pDest,
int nSize )
virtual
Ghidra address:
NTSC-U/C: 0x004ee330
Ghidra address:
PAL: 0x0052ced8

Implements IBStream.

◆ Seek()

virtual IBStream & IOBPreallocMemStream::Seek ( int nOffset,
int nWhence )
virtual
Ghidra address:
NTSC-U/C: 0x004ee3a8
Ghidra address:
PAL: 0x0052cf50

Implements IBStream.

◆ Tell()

virtual int IOBPreallocMemStream::Tell ( )
virtual
Ghidra address:
NTSC-U/C: 0x004edb48
Ghidra address:
PAL: 0x0052c6f0

Implements IBStream.

◆ Eof()

virtual int IOBPreallocMemStream::Eof ( )
virtual
Ghidra address:
NTSC-U/C: 0x004edb50
Ghidra address:
PAL: 0x0052c6f8

Implements IBStream.

◆ Fail()

virtual int IOBPreallocMemStream::Fail ( )
virtual

Test whether a transfer has failed.

One body serves IBStream vtable slot 5 and OBStream vtable slot 3, which is what the two tables record: both entries address the same routine, with the second adjusting this by -0x04.

Returns
Non-zero once a transfer has failed.
Ghidra address:
NTSC-U/C: 0x004edb58
Ghidra address:
PAL: 0x0052c700

Implements IBStream.

◆ Flush()

virtual IBStream & IOBPreallocMemStream::Flush ( )
virtual
Ghidra address:
NTSC-U/C: 0x004ee420
Ghidra address:
PAL: 0x0052cfc8

Implements IBStream.

◆ SetSize()

virtual void IOBPreallocMemStream::SetSize ( int nSize)
virtual

Record how many bytes a reader may consume.

IBStream vtable slot 9, the first virtual this class adds. The write position is overwritten with no bounds test against the capacity.

Parameters
nSizeThe new write position.
Ghidra address:
NTSC-U/C: 0x004edb40
Ghidra address:
PAL: 0x0052c6e8

◆ Buffer()

virtual char * IOBPreallocMemStream::Buffer ( )
virtual

Report the caller-owned buffer.

IBStream vtable slot 10, the second virtual this class adds. GrooveWorld::FinishSong() dispatches it at 0x0018e91c to write the log's length back into its first word. The one call goes through the table. The vtable entry is its only direct reference.

Returns
The buffer passed to the constructor.
Ghidra address:
NTSC-U/C: 0x004edb60
Ghidra address:
PAL: 0x0052c708

◆ Size()

int IOBPreallocMemStream::Size ( )
inline

Report how many bytes have been written.

Not virtual, and inline. The out-of-line copy at the address below has no call site. GrooveWorld::FinishSong() at 0x0018e90c expands it.

Returns
The write position.
Ghidra address:
NTSC-U/C: 0x004edb68
Ghidra address:
PAL: 0x0052c710

◆ Capacity()

int IOBPreallocMemStream::Capacity ( )

Report the buffer size passed to the constructor.

Not virtual, and inlined at every call site in the same way as Size().

Returns
The capacity in bytes.
Ghidra address:
NTSC-U/C: 0x004edb70
Ghidra address:
PAL: 0x0052c718

◆ Write()

virtual OBStream & IOBPreallocMemStream::Write ( const void * pSrc,
int nSize )
virtual
Ghidra address:
NTSC-U/C: 0x004ee428
Ghidra address:
PAL: 0x0052cfd0

Implements OBStream.

◆ Reset()

virtual OBStream & IOBPreallocMemStream::Reset ( )
virtual
Ghidra address:
NTSC-U/C: 0x004ee498
Ghidra address:
PAL: 0x0052d040

Implements OBStream.

Member Data Documentation

◆ mBuffer

char* IOBPreallocMemStream::mBuffer

Caller-owned byte buffer, which the constructor records and the destructor does not release.

Public because three memory card task constructors load it directly out of the embedded stream immediately after constructing it, at 0x0017e5c8 in ListRemixesMCT, 0x0017bed0 in LoadRemixMCT, and 0x0017cee4 in DeleteRemixMCT. Each one is a plain word load at offset 8 with no dispatch through Buffer(), and none of the three derives from this class.

Two further readings fit the image equally well. A friend declaration per task class gives the same instructions. And a devirtualised inline Buffer() call would also compile to the one load, which is why the promotion is recorded as an inference rather than as a measurement.

+0x08


The documentation for this class was generated from the following file: