2023-10-08 16:41:34 -04:00
|
|
|
#include "mxramstreamprovider.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-10-08 16:41:34 -04:00
|
|
|
#include "decomp.h"
|
2023-12-13 18:11:07 -05:00
|
|
|
#include "mxomni.h"
|
|
|
|
#include "mxstreamcontroller.h"
|
2023-10-08 16:41:34 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxRAMStreamProvider, 0x24);
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0730
|
2023-10-08 16:41:34 -04:00
|
|
|
MxRAMStreamProvider::MxRAMStreamProvider()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
m_bufferSize = 0;
|
|
|
|
m_fileSize = 0;
|
|
|
|
m_pBufferOfFileSize = NULL;
|
|
|
|
m_lengthInDWords = 0;
|
|
|
|
m_bufferForDWords = NULL;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0930
|
2023-10-08 16:41:34 -04:00
|
|
|
MxU32 MxRAMStreamProvider::GetFileSize()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
return m_fileSize;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0940
|
2023-12-22 14:03:55 -05:00
|
|
|
MxS32 MxRAMStreamProvider::GetStreamBuffersNum()
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
return 1;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0950
|
2023-10-08 16:41:34 -04:00
|
|
|
MxU32 MxRAMStreamProvider::GetLengthInDWords()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
return m_lengthInDWords;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0960
|
2023-10-10 04:27:00 -04:00
|
|
|
MxU32* MxRAMStreamProvider::GetBufferForDWords()
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
return m_bufferForDWords;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0a50
|
2023-11-21 03:44:45 -05:00
|
|
|
MxRAMStreamProvider::~MxRAMStreamProvider()
|
|
|
|
{
|
|
|
|
m_bufferSize = 0;
|
|
|
|
m_fileSize = 0;
|
|
|
|
|
|
|
|
free(m_pBufferOfFileSize);
|
|
|
|
m_pBufferOfFileSize = NULL;
|
|
|
|
|
|
|
|
m_lengthInDWords = 0;
|
|
|
|
|
|
|
|
free(m_bufferForDWords);
|
|
|
|
m_bufferForDWords = NULL;
|
|
|
|
}
|
|
|
|
|
2023-12-13 18:11:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x100d0ae0
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult MxRAMStreamProvider::SetResourceToGet(MxStreamController* p_resource)
|
|
|
|
{
|
2023-12-13 18:11:07 -05:00
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxString path;
|
|
|
|
m_pLookup = p_resource;
|
|
|
|
|
|
|
|
path = (MxString(MxOmni::GetHD()) + p_resource->GetAtom().GetInternal() + ".si");
|
|
|
|
|
|
|
|
m_pFile = new MxDSFile(path.GetData(), 0);
|
|
|
|
if (m_pFile != NULL) {
|
|
|
|
if (m_pFile->Open(0) != 0) {
|
|
|
|
path = MxString(MxOmni::GetCD()) + p_resource->GetAtom().GetInternal() + ".si";
|
|
|
|
m_pFile->SetFileName(path.GetData());
|
|
|
|
|
|
|
|
if (m_pFile->Open(0) != 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fileSize = m_pFile->CalcFileSize();
|
|
|
|
if (m_fileSize != 0) {
|
|
|
|
m_bufferSize = m_pFile->GetBufferSize();
|
|
|
|
m_pBufferOfFileSize = new MxU32[m_fileSize];
|
|
|
|
if (m_pBufferOfFileSize != NULL &&
|
|
|
|
m_pFile->Read((unsigned char*) m_pBufferOfFileSize, m_fileSize) == SUCCESS) {
|
|
|
|
m_lengthInDWords = m_pFile->GetLengthInDWords();
|
|
|
|
m_bufferForDWords = new MxU32[m_lengthInDWords * sizeof(MxU32)];
|
|
|
|
|
|
|
|
if (m_bufferForDWords != NULL) {
|
|
|
|
memcpy(m_bufferForDWords, m_pFile->GetBuffer(), m_lengthInDWords);
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
delete m_pFile;
|
|
|
|
m_pFile = NULL;
|
|
|
|
return result;
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|