mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-24 08:41:16 +00:00
Merge branch 'isledecomp:master' into impl/legosoundmanager
This commit is contained in:
commit
5fc3117f6f
@ -179,6 +179,7 @@ add_library(lego1 SHARED
|
||||
LEGO1/mxtimer.cpp
|
||||
LEGO1/mxtransitionmanager.cpp
|
||||
LEGO1/mxtype17notificationparam.cpp
|
||||
LEGO1/mxunknown100dbdbc.cpp
|
||||
LEGO1/mxvariable.cpp
|
||||
LEGO1/mxvariabletable.cpp
|
||||
LEGO1/mxvideomanager.cpp
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "mxomnicreateparam.h"
|
||||
#include "mxticklemanager.h"
|
||||
#include "mxtransitionmanager.h"
|
||||
#include "mxunknown100dbdbc.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoWorldList, 0x18);
|
||||
|
||||
@ -385,7 +386,7 @@ void LegoOmni::Init()
|
||||
MxOmni::Init();
|
||||
m_unk0x68 = 0;
|
||||
m_inputMgr = NULL;
|
||||
m_unk0x6c = 0;
|
||||
m_renderMgr = NULL;
|
||||
m_gifManager = NULL;
|
||||
m_worldList = NULL;
|
||||
m_currentWorld = NULL;
|
||||
@ -443,9 +444,9 @@ void LegoOmni::Destroy()
|
||||
m_gifManager = NULL;
|
||||
}
|
||||
|
||||
if (m_unk0x6c) {
|
||||
// delete m_unk0x6c; // TODO
|
||||
m_unk0x6c = NULL;
|
||||
if (m_renderMgr) {
|
||||
delete m_renderMgr;
|
||||
m_renderMgr = NULL;
|
||||
}
|
||||
|
||||
if (m_inputMgr) {
|
||||
@ -523,15 +524,16 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: there are a few more classes here
|
||||
m_renderMgr = new MxUnknown100dbdbc();
|
||||
m_gifManager = new GifManager();
|
||||
// TODO: there is another class here
|
||||
m_plantManager = new LegoPlantManager();
|
||||
m_animationManager = new LegoAnimationManager();
|
||||
m_buildingManager = new LegoBuildingManager();
|
||||
m_gameState = new LegoGameState();
|
||||
m_worldList = new LegoWorldList(TRUE);
|
||||
|
||||
if (m_unk0x6c && m_gifManager && m_worldList && m_plantManager && m_animationManager && m_buildingManager) {
|
||||
if (m_renderMgr && m_gifManager && m_worldList && m_plantManager && m_animationManager && m_buildingManager) {
|
||||
// TODO: initialize a bunch of MxVariables
|
||||
RegisterScripts();
|
||||
FUN_1001a700();
|
||||
|
||||
@ -27,6 +27,7 @@ class MxAtomId;
|
||||
class MxBackgroundAudioManager;
|
||||
class MxDSFile;
|
||||
class MxTransitionManager;
|
||||
class MxUnknown100dbdbc;
|
||||
|
||||
extern MxAtomId* g_copterScript;
|
||||
extern MxAtomId* g_dunecarScript;
|
||||
@ -116,7 +117,7 @@ class LegoOmni : public MxOmni {
|
||||
|
||||
private:
|
||||
undefined4* m_unk0x68; // 0x68
|
||||
undefined4 m_unk0x6c; // 0x6c
|
||||
MxUnknown100dbdbc* m_renderMgr; // 0x6c
|
||||
LegoInputManager* m_inputMgr; // 0x70
|
||||
GifManager* m_gifManager; // 0x74
|
||||
LegoWorldList* m_worldList; // 0x78
|
||||
|
||||
@ -6,7 +6,7 @@ DECOMP_SIZE_ASSERT(SmackTag, 0x390);
|
||||
DECOMP_SIZE_ASSERT(MxSmack, 0x6b8);
|
||||
|
||||
// FUNCTION: LEGO1 0x100c5a90
|
||||
MxResult MxSmack::LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack)
|
||||
MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack)
|
||||
{
|
||||
// Macros for readability
|
||||
#define FRAME_COUNT(mxSmack) (p_mxSmack->m_smackTag.Frames + (p_mxSmack->m_smackTag.SmackerType & 1))
|
||||
@ -82,8 +82,7 @@ MxResult MxSmack::LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack)
|
||||
p_mxSmack->m_smackTag.typesize
|
||||
);
|
||||
|
||||
MxU32 size =
|
||||
::SmackGetSizeDeltas(p_mxSmack->m_smackTag.Width, p_mxSmack->m_smackTag.Height) + 32;
|
||||
MxU32 size = SmackGetSizeDeltas(p_mxSmack->m_smackTag.Width, p_mxSmack->m_smackTag.Height) + 32;
|
||||
p_mxSmack->m_unk0x6b4 = new MxU8[size];
|
||||
memset(p_mxSmack->m_unk0x6b4, 0, size);
|
||||
|
||||
@ -92,7 +91,7 @@ MxResult MxSmack::LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack)
|
||||
|
||||
*data = 1;
|
||||
data++;
|
||||
*data = 0;
|
||||
*data = NULL; // MxU8* bitmapData
|
||||
data++;
|
||||
*data = p_mxSmack->m_smackTag.Width / 4;
|
||||
data++;
|
||||
@ -140,15 +139,114 @@ void MxSmack::Destroy(MxSmack* p_mxSmack)
|
||||
delete[] p_mxSmack->m_unk0x6b4;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100c5db0
|
||||
void MxSmack::FUN_100c5db0(
|
||||
// This should be refactored to somewhere else
|
||||
inline MxLong AbsFlipped(MxLong p_value)
|
||||
{
|
||||
return p_value > 0 ? p_value : -p_value;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c5db0
|
||||
MxResult MxSmack::LoadFrame(
|
||||
MxBITMAPINFO* p_bitmapInfo,
|
||||
MxU8* p_bitmapData,
|
||||
MxSmack* p_mxSmack,
|
||||
MxU8* p_chunkData,
|
||||
MxBool p_und,
|
||||
MxBool p_paletteChanged,
|
||||
MxRectList* p_list
|
||||
)
|
||||
{
|
||||
// TODO
|
||||
p_bitmapInfo->m_bmiHeader.biHeight = -AbsFlipped(p_bitmapInfo->m_bmiHeader.biHeight);
|
||||
*(MxU8**) (p_mxSmack->m_unk0x6b4 + 4) = p_bitmapData;
|
||||
|
||||
// Reference: https://wiki.multimedia.cx/index.php/Smacker#Palette_Chunk
|
||||
if (p_paletteChanged) {
|
||||
MxU8 palette[772];
|
||||
|
||||
MxU8* intoChunk = p_chunkData + 1;
|
||||
MxU8* intoPalette = palette;
|
||||
MxU16 paletteIndex = 0;
|
||||
// TODO: struct incorrect, Palette at wrong offset?
|
||||
MxU8* currentPalette = &p_mxSmack->m_smackTag.Palette[4];
|
||||
|
||||
do {
|
||||
if (*intoChunk & 0x80) {
|
||||
MxU8 length = (*intoChunk & 0x7f) + 1;
|
||||
memcpy(intoPalette, ¤tPalette[paletteIndex * 3], length * 3);
|
||||
intoPalette += length * 3;
|
||||
paletteIndex += length;
|
||||
intoChunk++;
|
||||
}
|
||||
else {
|
||||
if (*intoChunk & 0x40) {
|
||||
MxU8 length = (*intoChunk & 0x3f) + 1;
|
||||
memcpy(intoPalette, ¤tPalette[*(intoChunk + 1) * 3], length * 3);
|
||||
intoPalette += length * 3;
|
||||
paletteIndex += length;
|
||||
intoChunk += 2;
|
||||
}
|
||||
else {
|
||||
*(MxU32*) intoPalette = *(MxU32*) intoChunk;
|
||||
intoPalette += 3;
|
||||
paletteIndex++;
|
||||
intoChunk += 3;
|
||||
}
|
||||
}
|
||||
} while (paletteIndex < 256);
|
||||
|
||||
for (MxU32 i = 0; i < 256; i++) {
|
||||
memcpy(currentPalette, &palette[i * 3], 3);
|
||||
currentPalette += 3;
|
||||
p_bitmapInfo->m_bmiColors[i].rgbBlue = palette[i * 3 + 2] * 4;
|
||||
p_bitmapInfo->m_bmiColors[i].rgbGreen = palette[i * 3 + 1] * 4;
|
||||
p_bitmapInfo->m_bmiColors[i].rgbRed = palette[i * 3] * 4;
|
||||
}
|
||||
|
||||
p_chunkData += *p_chunkData * 4;
|
||||
}
|
||||
|
||||
SmackDoFrameToBuffer(p_chunkData, p_mxSmack->m_huffmanTables, p_mxSmack->m_unk0x6b4);
|
||||
|
||||
MxU16 und = 1;
|
||||
u32 smackRect[4];
|
||||
MxRect32 rect;
|
||||
|
||||
while (GetRect(p_mxSmack->m_unk0x6b4, &und, smackRect, &rect)) {
|
||||
MxRect32* newRect = new MxRect32(rect);
|
||||
p_list->Append(newRect);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c6050
|
||||
MxBool MxSmack::GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect32* p_rect)
|
||||
{
|
||||
u32 left, bottom, top, right;
|
||||
|
||||
if (!*p_und)
|
||||
return FALSE;
|
||||
|
||||
if (*p_und == 1) {
|
||||
if (!SmackGetRect(p_unk0x6b4, p_smackRect))
|
||||
return FALSE;
|
||||
*p_und = 2;
|
||||
}
|
||||
|
||||
left = p_smackRect[0];
|
||||
top = p_smackRect[1];
|
||||
right = p_smackRect[2] + p_smackRect[0];
|
||||
bottom = p_smackRect[3] + p_smackRect[1];
|
||||
|
||||
while (SmackGetRect(p_unk0x6b4, p_smackRect)) {
|
||||
if (left > p_smackRect[0])
|
||||
left = p_smackRect[0];
|
||||
if (right < p_smackRect[0] + p_smackRect[2])
|
||||
right = p_smackRect[0] + p_smackRect[2];
|
||||
|
||||
bottom = p_smackRect[1] + p_smackRect[3];
|
||||
}
|
||||
|
||||
*p_und = 0;
|
||||
*p_rect = MxRect32(left, top, right, bottom);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -25,8 +25,14 @@ extern "C"
|
||||
u32 p_typeSize
|
||||
);
|
||||
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100cda83
|
||||
void SmackDoFrameToBuffer(u8* p_source, u8* p_huffmanTables, u8* p_unk0x6b4);
|
||||
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100d052c
|
||||
u32 SmackGetSizeDeltas(u32 p_width, u32 p_height);
|
||||
|
||||
// (SMACK.LIB) FUNCTION: LEGO1 0x100d0543
|
||||
u8 SmackGetRect(u8* p_unk0x6b4, u32* p_rect);
|
||||
}
|
||||
|
||||
// SIZE 0x6b8
|
||||
@ -40,16 +46,17 @@ struct MxSmack {
|
||||
MxU32 m_maxFrameSize; // 0x6b0
|
||||
MxU8* m_unk0x6b4; // 0x6b4
|
||||
|
||||
static MxResult LoadHeaderAndTrees(MxU8* p_data, MxSmack* p_mxSmack);
|
||||
static MxResult LoadHeader(MxU8* p_data, MxSmack* p_mxSmack);
|
||||
static void Destroy(MxSmack* p_mxSmack);
|
||||
static void FUN_100c5db0(
|
||||
static MxResult LoadFrame(
|
||||
MxBITMAPINFO* p_bitmapInfo,
|
||||
MxU8* p_bitmapData,
|
||||
MxSmack* p_mxSmack,
|
||||
MxU8* p_chunkData,
|
||||
MxBool p_und,
|
||||
MxBool p_paletteChanged,
|
||||
MxRectList* p_list
|
||||
);
|
||||
static MxBool GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect32* p_rect);
|
||||
};
|
||||
|
||||
#endif // MXSMACK_H
|
||||
|
||||
@ -45,7 +45,7 @@ void MxSmkPresenter::Destroy(MxBool p_fromDestructor)
|
||||
// FUNCTION: LEGO1 0x100b3940
|
||||
void MxSmkPresenter::LoadHeader(MxStreamChunk* p_chunk)
|
||||
{
|
||||
MxSmack::LoadHeaderAndTrees(p_chunk->GetData(), &m_mxSmack);
|
||||
MxSmack::LoadHeader(p_chunk->GetData(), &m_mxSmack);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b3960
|
||||
@ -65,14 +65,14 @@ void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk)
|
||||
MxU8* bitmapData = m_bitmap->GetBitmapData();
|
||||
MxU8* chunkData = p_chunk->GetData();
|
||||
|
||||
MxBool und = m_mxSmack.m_frameTypes[m_unk0x71c] & 1;
|
||||
MxBool paletteChanged = m_mxSmack.m_frameTypes[m_unk0x71c] & 1;
|
||||
m_unk0x71c++;
|
||||
VTable0x88();
|
||||
|
||||
MxRectList list(TRUE);
|
||||
MxSmack::FUN_100c5db0(bitmapInfo, bitmapData, &m_mxSmack, chunkData, und, &list);
|
||||
MxSmack::LoadFrame(bitmapInfo, bitmapData, &m_mxSmack, chunkData, paletteChanged, &list);
|
||||
|
||||
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && und)
|
||||
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && paletteChanged)
|
||||
RealizePalette();
|
||||
|
||||
MxRect32 invalidateRect;
|
||||
@ -98,7 +98,7 @@ void MxSmkPresenter::VTable0x88()
|
||||
if (m_mxSmack.m_smackTag.Frames == m_unk0x71c) {
|
||||
m_unk0x71c = 0;
|
||||
// TODO: struct incorrect, Palette at wrong offset?
|
||||
memset(m_mxSmack.m_smackTag.Palette, 0, sizeof(m_mxSmack.m_smackTag.Palette));
|
||||
memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
LEGO1/mxunknown100dbdbc.cpp
Normal file
11
LEGO1/mxunknown100dbdbc.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mxunknown100dbdbc.h"
|
||||
|
||||
#include "decomp.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxUnknown100dbdbc, 0x14)
|
||||
|
||||
// STUB: LEGO1 0x100a6fd0
|
||||
MxUnknown100dbdbc::MxUnknown100dbdbc()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
17
LEGO1/mxunknown100dbdbc.h
Normal file
17
LEGO1/mxunknown100dbdbc.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef MXUNKNOWN100DBDBC_H
|
||||
#define MXUNKNOWN100DBDBC_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100dbdbc
|
||||
// SIZE 0x14
|
||||
class MxUnknown100dbdbc {
|
||||
public:
|
||||
MxUnknown100dbdbc();
|
||||
|
||||
private:
|
||||
undefined m_unk0x4[0x14]; // TODO: change to 0x10 once scalar deconstructor is added
|
||||
};
|
||||
|
||||
#endif // MXUNKNOWN100DBDBC_H
|
||||
Loading…
Reference in New Issue
Block a user