2023-09-25 22:30:56 -04:00
|
|
|
#include "mxstreamcontroller.h"
|
|
|
|
|
2023-10-07 14:05:45 -04:00
|
|
|
#include "legoomni.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxautolocker.h"
|
2023-11-05 10:25:38 -05:00
|
|
|
#include "mxnextactiondatastart.h"
|
2023-11-28 08:26:39 -05:00
|
|
|
#include "mxstreamchunk.h"
|
2023-11-05 10:25:38 -05:00
|
|
|
|
2023-11-28 08:26:39 -05:00
|
|
|
DECOMP_SIZE_ASSERT(MxStreamController, 0x64)
|
2023-11-05 10:25:38 -05:00
|
|
|
DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14)
|
2023-09-25 22:30:56 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b9400
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxStreamController::vtable0x18(undefined4 p_unknown, undefined4 p_unknown2)
|
|
|
|
{
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b9410
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxStreamController::vtable0x1C(undefined4 p_unknown, undefined4 p_unknown2)
|
|
|
|
{
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b9420
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxStreamController::vtable0x28()
|
|
|
|
{
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c0b90
|
2023-09-25 22:30:56 -04:00
|
|
|
MxStreamController::MxStreamController()
|
|
|
|
{
|
2023-11-28 08:26:39 -05:00
|
|
|
m_provider = NULL;
|
|
|
|
m_unk2c = 0; // TODO: probably also NULL
|
|
|
|
m_action0x60 = NULL;
|
2023-09-25 22:30:56 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x100c1290
|
2023-09-25 22:30:56 -04:00
|
|
|
MxStreamController::~MxStreamController()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// TODO
|
2023-09-25 22:30:56 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1520
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult MxStreamController::Open(const char* p_filename)
|
2023-09-25 22:30:56 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
char sourceName[256];
|
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
2023-09-25 22:30:56 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MakeSourceName(sourceName, p_filename);
|
|
|
|
this->atom = MxAtomId(sourceName, LookupMode_LowerCase2);
|
|
|
|
return SUCCESS;
|
2023-09-25 22:30:56 -04:00
|
|
|
}
|
2023-10-07 09:05:44 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1690
|
2023-10-08 16:41:34 -04:00
|
|
|
MxResult MxStreamController::vtable0x20(MxDSAction* p_action)
|
2023-10-07 09:05:44 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
2023-10-10 04:27:00 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult result;
|
|
|
|
MxU32 offset = 0;
|
2023-10-10 04:27:00 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxS32 objectId = p_action->GetObjectId();
|
|
|
|
MxStreamProvider* provider = m_provider;
|
2023-10-10 04:27:00 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if ((MxS32) provider->GetLengthInDWords() > objectId)
|
|
|
|
offset = provider->GetBufferForDWords()[objectId];
|
2023-10-10 04:27:00 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
if (offset)
|
|
|
|
result = vtable0x2c(p_action, offset);
|
|
|
|
else
|
|
|
|
result = FAILURE;
|
2023-10-10 04:27:00 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return result;
|
2023-10-07 09:05:44 -04:00
|
|
|
}
|
2023-10-08 16:41:34 -04:00
|
|
|
|
2023-12-11 16:17:25 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1740
|
|
|
|
MxResult MxStreamController::vtable0x24(MxDSAction* p_action)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-12-11 16:17:25 -05:00
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
vtable0x30(p_action);
|
|
|
|
m_action0x60 = m_unkList0x54.Find(p_action, TRUE);
|
|
|
|
if (m_action0x60 == NULL) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p_action->SetUnknown24(m_action0x60->GetUnknown24());
|
|
|
|
p_action->SetObjectId(m_action0x60->GetObjectId());
|
|
|
|
return FUN_100c1f00(m_action0x60);
|
|
|
|
}
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1800
|
2023-11-05 10:25:38 -05:00
|
|
|
MxResult MxStreamController::FUN_100c1800(MxDSAction* p_action, MxU32 p_val)
|
|
|
|
{
|
|
|
|
MxNextActionDataStart* dataActionStart =
|
|
|
|
new MxNextActionDataStart(p_action->GetObjectId(), p_action->GetUnknown24(), p_val);
|
|
|
|
if (dataActionStart == NULL) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2023-11-28 08:26:39 -05:00
|
|
|
|
|
|
|
m_nextActionList.push_back(dataActionStart);
|
|
|
|
return SUCCESS;
|
2023-11-05 10:25:38 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x100c1a00
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-11-21 03:44:45 -05:00
|
|
|
return FAILURE;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1c10
|
2023-10-10 04:27:00 -04:00
|
|
|
MxResult MxStreamController::vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-11-05 10:25:38 -05:00
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
if (FUN_100c1a00(p_action, p_bufferval) != SUCCESS) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
return FUN_100c1800(p_action, (p_bufferval / m_provider->GetFileSize()) * m_provider->GetFileSize());
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-11 16:17:25 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c1ce0
|
|
|
|
MxResult MxStreamController::vtable0x30(MxDSAction* p_unknown)
|
|
|
|
{
|
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxDSAction* action = m_unkList0x3c.Find(p_unknown, TRUE);
|
|
|
|
if (action != NULL) {
|
|
|
|
MxNextActionDataStart* data = m_nextActionList.Find(action->GetObjectId(), action->GetUnknown24());
|
|
|
|
delete action;
|
|
|
|
delete data;
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x100c1f00
|
|
|
|
MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-12-11 16:17:25 -05:00
|
|
|
// TODO
|
2023-10-24 19:38:27 -04:00
|
|
|
return FAILURE;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
2023-11-05 10:25:38 -05:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x100c20d0
|
2023-11-21 03:44:45 -05:00
|
|
|
MxBool MxStreamController::FUN_100c20d0(MxDSObject& p_obj)
|
2023-11-05 10:25:38 -05:00
|
|
|
{
|
2023-11-21 03:44:45 -05:00
|
|
|
// TODO
|
|
|
|
return TRUE;
|
2023-11-05 10:25:38 -05:00
|
|
|
}
|