From 724c9539473214e975f228cf133e5ef458398b9d Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:58:05 -0400 Subject: [PATCH] Implement MxDSBuffer constructor, match MxDSSource::FUN_100bffd0 (#235) * Implement MxDSBuffer constructor, match FUN_100bffd0 * Match to 100%, minor style fixes --------- Co-authored-by: Christian Semmler --- LEGO1/mxdsbuffer.cpp | 26 +++++++++++++++++++++++++- LEGO1/mxdsbuffer.h | 25 +++++++++++++++++++++++-- LEGO1/mxdssource.cpp | 8 ++++---- LEGO1/mxdssource.h | 6 ++++-- 4 files changed, 56 insertions(+), 9 deletions(-) diff --git a/LEGO1/mxdsbuffer.cpp b/LEGO1/mxdsbuffer.cpp index 686627a4..b01be21a 100644 --- a/LEGO1/mxdsbuffer.cpp +++ b/LEGO1/mxdsbuffer.cpp @@ -1,9 +1,21 @@ #include "mxdsbuffer.h" +DECOMP_SIZE_ASSERT(MxDSBuffer, 0x34); + // OFFSET: LEGO1 0x100c6470 MxDSBuffer::MxDSBuffer() { - // TODO + m_unk20 = 0; + m_pBuffer = NULL; + m_pIntoBuffer = NULL; + m_pIntoBuffer2 = NULL; + m_unk14 = 0; + m_unk18 = 0; + m_unk1c = 0; + m_writeOffset = 0; + m_bytesRemaining = 0; + m_mode = 2; + m_unk30 = 0; } // OFFSET: LEGO1 0x100c6530 @@ -11,3 +23,15 @@ MxDSBuffer::~MxDSBuffer() { // TODO } + +// OFFSET: LEGO1 0x100c6780 +MxResult MxDSBuffer::FUN_100c6780(void* p_buffer, MxU32 p_size) +{ + m_pBuffer = p_buffer; + m_pIntoBuffer = p_buffer; + m_pIntoBuffer2 = p_buffer; + m_bytesRemaining = p_size; + m_writeOffset = p_size; + m_mode = 2; + return SUCCESS; +} diff --git a/LEGO1/mxdsbuffer.h b/LEGO1/mxdsbuffer.h index cb962cea..a48c4727 100644 --- a/LEGO1/mxdsbuffer.h +++ b/LEGO1/mxdsbuffer.h @@ -12,9 +12,30 @@ class MxDSBuffer : public MxCore MxDSBuffer(); virtual ~MxDSBuffer() override; -private: - undefined m_unk08[0x2C]; + // OFFSET: LEGO1 0x100c6500 + inline virtual const char *ClassName() const override // vtable+0x0c + { + // 0x100f0568 + return "MxDSBuffer"; + } + MxResult FUN_100c6780(void* p_buffer, MxU32 p_size); + + inline void* GetBuffer() { return m_pBuffer;} + inline MxU32 GetWriteOffset() { return m_writeOffset;} + +private: + void* m_pBuffer; + void* m_pIntoBuffer; + void* m_pIntoBuffer2; + undefined4 m_unk14; + undefined4 m_unk18; + undefined4 m_unk1c; + undefined2 m_unk20; + undefined4 m_mode; + MxU32 m_writeOffset; + MxU32 m_bytesRemaining; + undefined4 m_unk30; }; #endif // MXDSBUFFER_H diff --git a/LEGO1/mxdssource.cpp b/LEGO1/mxdssource.cpp index 0ede6402..3c725a81 100644 --- a/LEGO1/mxdssource.cpp +++ b/LEGO1/mxdssource.cpp @@ -1,10 +1,10 @@ #include "mxdssource.h" +#include "mxdsbuffer.h" // OFFSET: LEGO1 0x100bffd0 -void MxDSSource::FUN_100bffd0(void* p_unk) +void MxDSSource::ReadToBuffer(MxDSBuffer* p_buffer) { - // TODO: Calls read, reading into a buffer somewhere in p_unk. - Read(NULL, 0); + Read((unsigned char*)p_buffer->GetBuffer(), p_buffer->GetWriteOffset()); } // OFFSET: LEGO1 0x100bfff0 @@ -17,4 +17,4 @@ MxLong MxDSSource::GetLengthInDWords() MxU32 *MxDSSource::GetBuffer() { return m_pBuffer; -} \ No newline at end of file +} diff --git a/LEGO1/mxdssource.h b/LEGO1/mxdssource.h index 2891f426..9c404ad0 100644 --- a/LEGO1/mxdssource.h +++ b/LEGO1/mxdssource.h @@ -3,13 +3,15 @@ #include "mxcore.h" +class MxDSBuffer; + // VTABLE 0x100dc8c8 class MxDSSource : public MxCore { public: MxDSSource() : m_lengthInDWords(0) - , m_pBuffer(0) + , m_pBuffer(NULL) , m_position(-1) {} @@ -28,7 +30,7 @@ class MxDSSource : public MxCore virtual MxLong Open(MxULong) = 0; virtual MxLong Close() = 0; - virtual void FUN_100bffd0(void* p_unk); + virtual void ReadToBuffer(MxDSBuffer* p_buffer); virtual MxResult Read(unsigned char *, MxULong) = 0; virtual MxLong Seek(MxLong, int) = 0; virtual MxULong GetBufferSize() = 0;