MxDiskStreamController vtable (#197)

* mxdiskstreamcontroller vtable + MxStreamController::vtable0x20

* stub MxDiskStreamController::Open

* MxDiskStreamProvider

* MxNextActionDataStart

* Revert "MxNextActionDataStart"

This reverts commit 41e8cfa2f1.

* Match MxStreamController::vtable0x20

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2023-10-10 04:27:00 -04:00 committed by GitHub
parent 49efa02eaa
commit 114a959741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 21 deletions

View file

@ -16,6 +16,52 @@ MxDiskStreamController::~MxDiskStreamController()
MxResult MxDiskStreamController::Tickle()
{
// TODO
return 0;
}
// OFFSET: LEGO1 0x100c7790 STUB
MxResult MxDiskStreamController::Open(const char *p_filename)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100c7880
MxResult MxDiskStreamController::vtable0x18(undefined4 p_unknown, undefined4 p_unknown2)
{
return SUCCESS;
}
// OFFSET: LEGO1 0x100c7ff0 STUB
MxResult MxDiskStreamController::vtable0x20(MxDSAction* p_action)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100c8160 STUB
MxResult MxDiskStreamController::vtable0x24(undefined4 p_unknown)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100c7ac0 STUB
MxResult MxDiskStreamController::vtable0x28()
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100c7c00 STUB
MxResult MxDiskStreamController::vtable0x30(undefined4 p_unknown)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100c7960
MxResult MxDiskStreamController::vtable0x34(undefined4 p_unknown)
{
return FAILURE;
}

View file

@ -15,6 +15,13 @@ class MxDiskStreamController : public MxStreamController
virtual ~MxDiskStreamController() override;
virtual MxResult Tickle() override; // vtable+0x8
virtual MxResult Open(const char *p_filename) override; // vtable+0x14
virtual MxResult vtable0x18(undefined4 p_unknown, undefined4 p_unknown2) override; //vtable+0x18
virtual MxResult vtable0x20(MxDSAction* p_action) override; //vtable+0x20
virtual MxResult vtable0x24(undefined4 p_unknown) override; //vtable+0x24
virtual MxResult vtable0x28() override; //vtable+0x28
virtual MxResult vtable0x30(undefined4 p_unknown) override; //vtable+0x30
virtual MxResult vtable0x34(undefined4 p_unknown); //vtable+0x34
// OFFSET: LEGO1 0x100c7360
inline virtual const char *ClassName() const override // vtable+0x0c

View file

@ -45,4 +45,41 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete()
void MxDiskStreamProvider::PerformWork()
{
// TODO
}
}
// OFFSET: LEGO1 0x100d13d0 STUB
MxResult MxDiskStreamProvider::SetResourceToGet(void* p_resource)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100d1e90
MxU32 MxDiskStreamProvider::GetFileSize()
{
return m_pFile->GetBufferSize();
}
// OFFSET: LEGO1 0x100d1ea0
MxU32 MxDiskStreamProvider::GetStreamBuffersNum()
{
return m_pFile->GetStreamBuffersNum();
}
// OFFSET: LEGO1 0x100d15e0 STUB
void MxDiskStreamProvider::vtable0x20(undefined4 p_unknown1)
{
// TODO
}
// OFFSET: LEGO1 0x100d1eb0
MxU32 MxDiskStreamProvider::GetLengthInDWords()
{
return m_pFile->GetLengthInDWords();
}
// OFFSET: LEGO1 0x100d1ec0
MxU32* MxDiskStreamProvider::GetBufferForDWords()
{
return m_pFile->GetBuffer();
}

View file

@ -49,6 +49,13 @@ class MxDiskStreamProvider : public MxStreamProvider
void PerformWork();
virtual MxResult SetResourceToGet(void* p_resource) override; //vtable+0x14
virtual MxU32 GetFileSize() override; //vtable+0x18
virtual MxU32 GetStreamBuffersNum() override; //vtable+0x1c
virtual void vtable0x20(undefined4 p_unknown1) override; //vtable+0x20
virtual MxU32 GetLengthInDWords() override; //vtable+0x24
virtual MxU32* GetBufferForDWords()override; //vtable+0x28
private:
MxDiskStreamProviderThread m_thread; // 0x10
MxSemaphore m_busySemaphore; // 0x2c

View file

@ -81,7 +81,7 @@ MxLong MxDSFile::ReadChunks()
}
MxULong* pLengthInDWords = &m_lengthInDWords;
m_io.Read(pLengthInDWords, 4);
m_pBuffer = malloc(*pLengthInDWords * 4);
m_pBuffer = new MxU32[*pLengthInDWords];
m_io.Read(m_pBuffer, *pLengthInDWords * 4);
return 0;
}
@ -120,7 +120,7 @@ MxLong MxDSFile::Close()
if (m_lengthInDWords != 0)
{
m_lengthInDWords = 0;
free(m_pBuffer);
delete[] m_pBuffer;
m_pBuffer = NULL;
}
return 0;

View file

@ -14,7 +14,7 @@ MxLong MxDSSource::GetLengthInDWords()
}
// OFFSET: LEGO1 0x100c0000
void *MxDSSource::GetBuffer()
MxU32 *MxDSSource::GetBuffer()
{
return m_pBuffer;
}

View file

@ -34,11 +34,11 @@ class MxDSSource : public MxCore
virtual MxULong GetBufferSize() = 0;
virtual MxULong GetStreamBuffersNum() = 0;
virtual MxLong GetLengthInDWords();
virtual void* GetBuffer(); // 0x34
virtual MxU32* GetBuffer(); // 0x34
protected:
MxULong m_lengthInDWords;
void* m_pBuffer;
MxU32* m_pBuffer;
MxLong m_position;
};

View file

@ -41,7 +41,7 @@ MxU32 MxRAMStreamProvider::GetFileSize()
}
// OFFSET: LEGO1 0x100d0940
MxU32 MxRAMStreamProvider::vtable0x1C()
MxU32 MxRAMStreamProvider::GetStreamBuffersNum()
{
return 1;
}
@ -53,7 +53,7 @@ MxU32 MxRAMStreamProvider::GetLengthInDWords()
}
// OFFSET: LEGO1 0x100d0960
void* MxRAMStreamProvider::GetBufferForDWords()
MxU32* MxRAMStreamProvider::GetBufferForDWords()
{
return m_bufferForDWords;
}

View file

@ -9,19 +9,19 @@ class MxRAMStreamProvider : public MxStreamProvider
public:
MxRAMStreamProvider();
virtual ~MxRAMStreamProvider() override;
virtual MxResult SetResourceToGet(void* p_resource) override; //vtable+0x14
virtual MxU32 GetFileSize() override; //vtable+0x18
virtual MxU32 vtable0x1C() override; //vtable+0x1c
virtual MxU32 GetStreamBuffersNum() override; //vtable+0x1c
virtual MxU32 GetLengthInDWords() override; //vtable+0x24
virtual void* GetBufferForDWords() override; //vtable+0x28
virtual MxU32* GetBufferForDWords() override; //vtable+0x28
protected:
MxU32 m_bufferSize;
MxU32 m_fileSize;
void* m_pBufferOfFileSize;
MxU32 m_lengthInDWords;
void* m_bufferForDWords;
MxU32* m_bufferForDWords;
};
#endif // MXRAMSTREAMPROVIDER_H

View file

@ -45,11 +45,26 @@ MxResult MxStreamController::vtable0x1C(undefined4 p_unknown, undefined4 p_unkno
return FAILURE;
}
// OFFSET: LEGO1 0x100c1690 STUB
// OFFSET: LEGO1 0x100c1690
MxResult MxStreamController::vtable0x20(MxDSAction* p_action)
{
// TODO STUB
return FAILURE;
MxAutoLocker locker(&m_criticalSection);
MxResult result;
MxU32 offset = 0;
MxS32 objectId = p_action->GetObjectId();
MxStreamProvider *provider = m_provider;
if ((MxS32) provider->GetLengthInDWords() > objectId)
offset = provider->GetBufferForDWords()[objectId];
if (offset)
result = vtable0x2c(p_action, offset);
else
result = FAILURE;
return result;
}
// OFFSET: LEGO1 0x100c1740 STUB
@ -66,7 +81,7 @@ MxResult MxStreamController::vtable0x28()
}
// OFFSET: LEGO1 0x100c1c10 STUB
MxResult MxStreamController::vtable0x2c(undefined4 p_unknown1, undefined4 p_unknow2)
MxResult MxStreamController::vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval)
{
return FAILURE;
}

View file

@ -7,6 +7,7 @@
#include "mxcore.h"
#include "mxdsobject.h"
#include "mxdsaction.h"
#include "mxstreamprovider.h"
// VTABLE 0x100dc968
// SIZE 0x64
@ -36,7 +37,7 @@ class MxStreamController : public MxCore
virtual MxResult vtable0x20(MxDSAction* p_action); //vtable+0x20
virtual MxResult vtable0x24(undefined4 p_unknown); //vtable+0x24
virtual MxResult vtable0x28(); //vtable+0x28
virtual MxResult vtable0x2c(undefined4 p_unknown1, undefined4 p_unknow2); //vtable+0x2c
virtual MxResult vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval); //vtable+0x2c
virtual MxResult vtable0x30(undefined4 p_unknown); //vtable+0x30
MxBool FUN_100c20d0(MxDSObject &p_obj);
@ -45,7 +46,7 @@ class MxStreamController : public MxCore
protected:
MxCriticalSection m_criticalSection;
MxAtomId atom;
undefined4 m_unk28; // MxStreamProvider*
MxStreamProvider* m_provider; // MxStreamProvider*
undefined4 m_unk2c;
undefined m_unk30[0x34];
};

View file

@ -26,10 +26,10 @@ class MxStreamProvider : public MxCore
virtual MxResult SetResourceToGet(void* p_resource); //vtable+0x14
virtual MxU32 GetFileSize() = 0; //vtable+0x18
virtual MxU32 vtable0x1C() = 0; //vtable+0x1c
virtual MxU32 GetStreamBuffersNum() = 0; //vtable+0x1c
virtual void vtable0x20(undefined4 p_unknown1); //vtable+0x20
virtual MxU32 GetLengthInDWords() = 0; //vtable+0x24
virtual void* GetBufferForDWords() = 0; //vtable+0x28
virtual MxU32* GetBufferForDWords() = 0; //vtable+0x28
protected:
void *m_pLookup;