Implement MxStreamController::FUN_100c1a00 (#357)

* Implement MxStreamController::FUN_100c1a00

* Move include
This commit is contained in:
Christian Semmler 2023-12-24 15:00:20 -05:00 committed by GitHub
parent 84056c6ea2
commit afd24fbe18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 14 deletions

View file

@ -784,11 +784,11 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
LegoOmni::GetInstance()->CreateBackgroundAudio();
BackgroundAudioManager()->Enable(this->m_useMusic);
MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0);
MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", MxStreamer::e_DiskStream);
MxDSAction ds;
if (!stream) {
stream = Streamer()->Open("\\lego\\scripts\\nocd", 0);
stream = Streamer()->Open("\\lego\\scripts\\nocd", MxStreamer::e_DiskStream);
if (!stream) {
return;
}

View file

@ -41,14 +41,14 @@ class MxDSStreamingAction : public MxDSAction {
inline void SetBufferOffset(MxU32 p_bufferOffset) { m_bufferOffset = p_bufferOffset; }
private:
MxU32 m_unk0x94;
MxU32 m_bufferOffset;
MxS32 m_unk0x9c;
MxDSBuffer* m_unk0xa0;
MxDSBuffer* m_unk0xa4;
MxLong m_unk0xa8;
undefined2 m_unk0xac;
MxDSAction* m_internalAction;
MxU32 m_unk0x94; // 0x94
MxU32 m_bufferOffset; // 0x98
MxS32 m_unk0x9c; // 0x9c
MxDSBuffer* m_unk0xa0; // 0xa0
MxDSBuffer* m_unk0xa4; // 0xa4
MxLong m_unk0xa8; // 0xa8
undefined2 m_unk0xac; // 0xac
MxDSAction* m_internalAction; // 0xb0
};
#endif // MXDSSTREAMINGACTION_H

View file

@ -36,6 +36,9 @@ class MxDSSubscriber : public MxCore {
MxStreamChunk* FUN_100b8360();
void FUN_100b8390(MxStreamChunk* p_chunk);
inline MxU32 GetObjectId() { return m_objectId; }
inline MxS16 GetUnknown48() { return m_unk0x48; }
private:
MxStreamChunkList m_unk0x08; // 0x08
MxStreamChunkListCursor* m_unk0x20; // 0x20

View file

@ -1,10 +1,12 @@
#include "mxstreamcontroller.h"
#include "legoomni.h"
#include "legoutil.h"
#include "mxautolocker.h"
#include "mxdsstreamingaction.h"
#include "mxnextactiondatastart.h"
#include "mxstreamchunk.h"
#include "mxtimer.h"
DECOMP_SIZE_ASSERT(MxStreamController, 0x64)
DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14)
@ -138,12 +140,62 @@ MxResult MxStreamController::FUN_100c1800(MxDSAction* p_action, MxU32 p_val)
return SUCCESS;
}
// STUB: LEGO1 0x100c1a00
MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval)
// FUNCTION: LEGO1 0x100c1a00
MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset)
{
if (p_action->GetUnknown24() == -1) {
MxS16 newUnknown24 = -1;
// These loops might be a template function in the list classes
for (MxStreamListMxDSAction::iterator it = m_unk0x54.begin(); it != m_unk0x54.end(); it++) {
MxDSAction* action = *it;
if (action->GetObjectId() == p_action->GetObjectId())
newUnknown24 = Max(newUnknown24, action->GetUnknown24());
}
if (newUnknown24 == -1) {
for (MxStreamListMxDSAction::iterator it = m_unk0x3c.begin(); it != m_unk0x3c.end(); it++) {
MxDSAction* action = *it;
if (action->GetObjectId() == p_action->GetObjectId())
newUnknown24 = Max(newUnknown24, action->GetUnknown24());
}
if (newUnknown24 == -1) {
for (MxStreamListMxDSSubscriber::iterator it = m_subscriberList.begin(); it != m_subscriberList.end();
it++) {
MxDSSubscriber* subscriber = *it;
if (subscriber->GetObjectId() == p_action->GetObjectId())
newUnknown24 = Max(newUnknown24, subscriber->GetUnknown48());
}
}
}
p_action->SetUnknown24(newUnknown24 + 1);
}
else {
if (m_unk0x3c.Find(p_action, FALSE))
return FAILURE;
}
MxDSStreamingAction* streamingAction = new MxDSStreamingAction(*p_action, p_offset);
if (!streamingAction)
return FAILURE;
MxU32 fileSize = m_provider->GetFileSize();
streamingAction->SetBufferOffset(fileSize * (p_offset / fileSize));
streamingAction->SetObjectId(p_action->GetObjectId());
MxLong time = Timer()->GetTime();
streamingAction->SetUnknown90(time);
m_unk0x3c.push_back(streamingAction);
return SUCCESS;
}
// FUNCTION: LEGO1 0x100c1c10
MxResult MxStreamController::VTable0x2c(MxDSAction* p_action, MxU32 p_bufferval)
{

View file

@ -46,7 +46,7 @@ class MxStreamController : public MxCore {
void FUN_100c15d0(MxDSSubscriber* p_subscriber);
void FUN_100c1620(MxDSSubscriber* p_subscriber);
MxResult FUN_100c1800(MxDSAction* p_action, MxU32 p_val);
MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval);
MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset);
MxPresenter* FUN_100c1e70(MxDSAction& p_action);
MxResult FUN_100c1f00(MxDSAction* p_action);
MxBool FUN_100c20d0(MxDSObject& p_obj);