Skip to content

Commit

Permalink
Implement MxStreamController::FUN_100c1a00 (#357)
Browse files Browse the repository at this point in the history
* Implement MxStreamController::FUN_100c1a00

* Move include
  • Loading branch information
foxtacles authored Dec 24, 2023
1 parent 84056c6 commit afd24fb
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ISLE/isleapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions LEGO1/mxdsstreamingaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions LEGO1/mxdssubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 55 additions & 3 deletions LEGO1/mxstreamcontroller.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -138,10 +140,60 @@ 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)
{
return FAILURE;
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
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/mxstreamcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit afd24fb

Please sign in to comment.