From 091ecd5935c1b61f42dc8a55c0793154708d14d3 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 8 Jan 2024 06:45:07 -0500 Subject: [PATCH] Move some classes to LegoOmni (#417) --- CMakeLists.txt | 7 +- LEGO1/lego/legoomni/include/legoomni.h | 17 -- LEGO1/lego/legoomni/include/legoutil.h | 51 +----- .../include/mxbackgroundaudiomanager.h | 0 .../include/mxcompositemediapresenter.h | 0 .../legoomni}/include/mxtransitionmanager.h | 0 .../src/audio/mxbackgroundaudiomanager.cpp | 0 .../src/common/mxcompositemediapresenter.cpp | 0 LEGO1/lego/legoomni/src/main/legoomni.cpp | 144 ----------------- .../src/video/mxtransitionmanager.cpp | 0 LEGO1/omni/include/mxutil.h | 75 +++++++++ LEGO1/omni/src/action/mxdsaction.cpp | 2 +- LEGO1/omni/src/action/mxdsmediaaction.cpp | 2 +- LEGO1/omni/src/action/mxdsobject.cpp | 2 +- LEGO1/omni/src/action/mxdssound.cpp | 2 +- LEGO1/omni/src/audio/mxmidipresenter.cpp | 1 - LEGO1/omni/src/audio/mxwavepresenter.cpp | 2 +- LEGO1/omni/src/common/mxpresenter.cpp | 4 +- LEGO1/omni/src/common/mxutil.cpp | 149 ++++++++++++++++++ LEGO1/omni/src/control/mxcontrolpresenter.cpp | 1 - .../omni/src/notify/mxnotificationmanager.cpp | 2 +- LEGO1/omni/src/stream/mxstreamchunk.cpp | 2 +- LEGO1/omni/src/stream/mxstreamcontroller.cpp | 4 +- LEGO1/omni/src/stream/mxstreamer.cpp | 2 +- LEGO1/omni/src/video/mxdisplaysurface.cpp | 2 +- LEGO1/omni/src/video/mxstillpresenter.cpp | 2 +- LEGO1/omni/src/video/mxvideomanager.cpp | 1 - 27 files changed, 245 insertions(+), 229 deletions(-) rename LEGO1/{omni => lego/legoomni}/include/mxbackgroundaudiomanager.h (100%) rename LEGO1/{omni => lego/legoomni}/include/mxcompositemediapresenter.h (100%) rename LEGO1/{omni => lego/legoomni}/include/mxtransitionmanager.h (100%) rename LEGO1/{omni => lego/legoomni}/src/audio/mxbackgroundaudiomanager.cpp (100%) rename LEGO1/{omni => lego/legoomni}/src/common/mxcompositemediapresenter.cpp (100%) rename LEGO1/{omni => lego/legoomni}/src/video/mxtransitionmanager.cpp (100%) create mode 100644 LEGO1/omni/include/mxutil.h create mode 100644 LEGO1/omni/src/common/mxutil.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 10f30c5b..eb5f1c25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/audio/legocachesound.cpp LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp + LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp LEGO1/lego/legoomni/src/build/buildingentity.cpp LEGO1/lego/legoomni/src/build/dunebuggy.cpp LEGO1/lego/legoomni/src/build/helicopter.cpp @@ -41,6 +42,7 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/common/legostream.cpp LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp LEGO1/lego/legoomni/src/common/legoutil.cpp + LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp LEGO1/lego/legoomni/src/entity/legoactor.cpp LEGO1/lego/legoomni/src/entity/legoanimactor.cpp @@ -114,6 +116,7 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp LEGO1/lego/legoomni/src/video/legovideomanager.cpp + LEGO1/lego/legoomni/src/video/mxtransitionmanager.cpp LEGO1/lego/sources/3dmanager/lego3dmanager.cpp LEGO1/lego/sources/3dmanager/lego3dview.cpp LEGO1/lego/sources/3dmanager/legoview1.cpp @@ -136,7 +139,6 @@ add_library(lego1 SHARED LEGO1/omni/src/action/mxdsstreamingaction.cpp LEGO1/omni/src/audio/mxaudiomanager.cpp LEGO1/omni/src/audio/mxaudiopresenter.cpp - LEGO1/omni/src/audio/mxbackgroundaudiomanager.cpp LEGO1/omni/src/audio/mxloopingmidipresenter.cpp LEGO1/omni/src/audio/mxmidipresenter.cpp LEGO1/omni/src/audio/mxmusicmanager.cpp @@ -146,7 +148,6 @@ add_library(lego1 SHARED LEGO1/omni/src/audio/mxwavepresenter.cpp LEGO1/omni/src/common/mxatomidcounter.cpp LEGO1/omni/src/common/mxatomid.cpp - LEGO1/omni/src/common/mxcompositemediapresenter.cpp LEGO1/omni/src/common/mxcompositepresenter.cpp LEGO1/omni/src/common/mxcore.cpp LEGO1/omni/src/common/mxmediamanager.cpp @@ -156,6 +157,7 @@ add_library(lego1 SHARED LEGO1/omni/src/common/mxstring.cpp LEGO1/omni/src/common/mxticklemanager.cpp LEGO1/omni/src/common/mxtimer.cpp + LEGO1/omni/src/common/mxutil.cpp LEGO1/omni/src/common/mxvariable.cpp LEGO1/omni/src/common/mxvariabletable.cpp LEGO1/omni/src/control/mxcontrolpresenter.cpp @@ -201,7 +203,6 @@ add_library(lego1 SHARED LEGO1/omni/src/video/mxsmack.cpp LEGO1/omni/src/video/mxsmkpresenter.cpp LEGO1/omni/src/video/mxstillpresenter.cpp - LEGO1/omni/src/video/mxtransitionmanager.cpp LEGO1/omni/src/video/mxvideomanager.cpp LEGO1/omni/src/video/mxvideoparam.cpp LEGO1/omni/src/video/mxvideoparamflags.cpp diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 613ddd85..77cf47f5 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -140,15 +140,12 @@ class LegoOmni : public MxOmni { }; __declspec(dllexport) MxBackgroundAudioManager* BackgroundAudioManager(); -__declspec(dllexport) MxDSObject* CreateStreamObject(MxDSFile*, MxS16); __declspec(dllexport) LegoGameState* GameState(); __declspec(dllexport) const char* GetNoCD_SourceName(); __declspec(dllexport) LegoInputManager* InputManager(); __declspec(dllexport) LegoOmni* Lego(); -__declspec(dllexport) void MakeSourceName(char*, const char*); __declspec(dllexport) LegoEntity* PickEntity(MxLong, MxLong); __declspec(dllexport) LegoROI* PickROI(MxLong, MxLong); -__declspec(dllexport) void SetOmniUserMessage(void (*)(const char*, int)); __declspec(dllexport) LegoSoundManager* SoundManager(); __declspec(dllexport) MxResult Start(MxDSAction*); __declspec(dllexport) MxTransitionManager* TransitionManager(); @@ -159,26 +156,12 @@ LegoBuildingManager* BuildingManager(); LegoControlManager* ControlManager(); IslePathActor* GetCurrentVehicle(); LegoPlantManager* PlantManager(); -MxBool KeyValueStringParse(char*, const char*, const char*); LegoWorld* GetCurrentWorld(); GifManager* GetGifManager(); void FUN_10015820(MxU32, MxU32); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); MxDSAction& GetCurrentAction(); -MxBool FUN_100b6e10( - MxS32 p_bitmapWidth, - MxS32 p_bitmapHeight, - MxS32 p_videoParamWidth, - MxS32 p_videoParamHeight, - MxS32* p_left, - MxS32* p_top, - MxS32* p_right, - MxS32* p_bottom, - MxS32* p_width, - MxS32* p_height -); - void PlayMusic(MxU32 p_index); void SetIsWorldActive(MxBool p_isWorldActive); void RegisterScripts(); diff --git a/LEGO1/lego/legoomni/include/legoutil.h b/LEGO1/lego/legoomni/include/legoutil.h index 827b8488..1539f28f 100644 --- a/LEGO1/lego/legoomni/include/legoutil.h +++ b/LEGO1/lego/legoomni/include/legoutil.h @@ -2,58 +2,13 @@ #define LEGOUTIL_H #include "extra.h" -#include "legoentity.h" -#include "mxatomid.h" #include "mxtypes.h" +#include "mxutil.h" #include -template -inline T Abs(T p_t) -{ - return p_t < 0 ? -p_t : p_t; -} - -template -inline T Min(T p_t1, T p_t2) -{ - return p_t1 < p_t2 ? p_t1 : p_t2; -} - -template -inline T Max(T p_t1, T p_t2) -{ - return p_t1 > p_t2 ? p_t1 : p_t2; -} - -template -inline void GetScalar(MxU8** p_source, T& p_dest) -{ - p_dest = *(T*) *p_source; - *p_source += sizeof(T); -} - -template -inline T GetScalar(T** p_source) -{ - T val = **p_source; - *p_source += 1; - return val; -} - -template -inline void GetDouble(MxU8** p_source, T& p_dest) -{ - p_dest = *(double*) *p_source; - *p_source += sizeof(double); -} - -template -inline void GetString(MxU8** p_source, char** p_dest, T* p_obj, void (T::*p_setter)(const char*)) -{ - (p_obj->*p_setter)((char*) *p_source); - *p_source += strlen(*p_dest) + 1; -} +class MxAtomId; +class LegoEntity; ExtraActionType MatchActionString(const char*); void InvokeAction(ExtraActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender); diff --git a/LEGO1/omni/include/mxbackgroundaudiomanager.h b/LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h similarity index 100% rename from LEGO1/omni/include/mxbackgroundaudiomanager.h rename to LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h diff --git a/LEGO1/omni/include/mxcompositemediapresenter.h b/LEGO1/lego/legoomni/include/mxcompositemediapresenter.h similarity index 100% rename from LEGO1/omni/include/mxcompositemediapresenter.h rename to LEGO1/lego/legoomni/include/mxcompositemediapresenter.h diff --git a/LEGO1/omni/include/mxtransitionmanager.h b/LEGO1/lego/legoomni/include/mxtransitionmanager.h similarity index 100% rename from LEGO1/omni/include/mxtransitionmanager.h rename to LEGO1/lego/legoomni/include/mxtransitionmanager.h diff --git a/LEGO1/omni/src/audio/mxbackgroundaudiomanager.cpp b/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp similarity index 100% rename from LEGO1/omni/src/audio/mxbackgroundaudiomanager.cpp rename to LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp diff --git a/LEGO1/omni/src/common/mxcompositemediapresenter.cpp b/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp similarity index 100% rename from LEGO1/omni/src/common/mxcompositemediapresenter.cpp rename to LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 29150f95..9f27a980 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -111,9 +111,6 @@ MxAtomId* g_nocdSourceName = NULL; // GLOBAL: LEGO1 0x100f6718 const char* g_current = "current"; -// GLOBAL: LEGO1 0x101020e8 -void (*g_omniUserMessage)(const char*, int); - // GLOBAL: LEGO1 0x100f4c58 MxBool g_isWorldActive = TRUE; @@ -694,144 +691,3 @@ MxResult Start(MxDSAction* p_dsAction) { return MxOmni::GetInstance()->Start(p_dsAction); } - -// Probably should be somewhere else -// FUNCTION: LEGO1 0x100b6e10 -MxBool FUN_100b6e10( - MxS32 p_bitmapWidth, - MxS32 p_bitmapHeight, - MxS32 p_videoParamWidth, - MxS32 p_videoParamHeight, - MxS32* p_left, - MxS32* p_top, - MxS32* p_right, - MxS32* p_bottom, - MxS32* p_width, - MxS32* p_height -) -{ - MxPoint32 topLeft(*p_left, *p_top); - MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight)); - - MxPoint32 bottomRight(*p_right, *p_bottom); - MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight)); - - MxRect32 rect(0, 0, *p_width, *p_height); - rect.AddPoint(topLeft); - - if (!rect.IntersectsWith(bitmapRect)) - return FALSE; - - rect.Intersect(bitmapRect); - rect.SubtractPoint(topLeft); - rect.AddPoint(bottomRight); - - if (!rect.IntersectsWith(videoParamRect)) - return FALSE; - - rect.Intersect(videoParamRect); - rect.SubtractPoint(bottomRight); - - *p_left += rect.GetLeft(); - *p_top += rect.GetTop(); - *p_right += rect.GetLeft(); - *p_bottom += rect.GetTop(); - *p_width = rect.GetWidth(); - *p_height = rect.GetHeight(); - return TRUE; -} - -// FUNCTION: LEGO1 0x100b6ff0 -void MakeSourceName(char* p_output, const char* p_input) -{ - const char* cln = strchr(p_input, ':'); - if (cln) { - p_input = cln + 1; - } - - strcpy(p_output, p_input); - - strlwr(p_output); - - char* extLoc = strstr(p_output, ".si"); - if (extLoc) { - *extLoc = 0; - } -} - -// FUNCTION: LEGO1 0x100b7050 -MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p_source) -{ - MxBool didMatch = FALSE; - - MxS16 len = strlen(p_source); - char* temp = new char[len + 1]; - strcpy(temp, p_source); - - char* token = strtok(temp, ", \t\r\n:"); - while (token) { - len -= (strlen(token) + 1); - - if (strcmpi(token, p_key) == 0) { - if (p_outputValue && len > 0) { - char* cur = &token[strlen(p_key)]; - cur++; - while (*cur != ',') { - if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r') - break; - *p_outputValue++ = *cur++; - } - *p_outputValue = '\0'; - } - - didMatch = TRUE; - break; - } - - token = strtok(NULL, ", \t\r\n:"); - } - - delete[] temp; - return didMatch; -} - -// FUNCTION: LEGO1 0x100b7210 -void SetOmniUserMessage(void (*p_userMsg)(const char*, int)) -{ - g_omniUserMessage = p_userMsg; -} - -// FUNCTION: LEGO1 0x100c0280 -MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) -{ - MxU8* buf; - _MMCKINFO tmpChunk; - - if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) { - return NULL; - } - - if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) { - if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) { - - buf = new MxU8[tmpChunk.cksize]; - if (!buf) { - return NULL; - } - - if (p_file->Read(buf, tmpChunk.cksize) != 0) { - return NULL; - } - - // Save a copy so we can clean up properly, because - // this function will alter the pointer value. - MxU8* copy = buf; - MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1); - delete[] copy; - return obj; - } - return NULL; - } - - return NULL; -} diff --git a/LEGO1/omni/src/video/mxtransitionmanager.cpp b/LEGO1/lego/legoomni/src/video/mxtransitionmanager.cpp similarity index 100% rename from LEGO1/omni/src/video/mxtransitionmanager.cpp rename to LEGO1/lego/legoomni/src/video/mxtransitionmanager.cpp diff --git a/LEGO1/omni/include/mxutil.h b/LEGO1/omni/include/mxutil.h new file mode 100644 index 00000000..f9febef1 --- /dev/null +++ b/LEGO1/omni/include/mxutil.h @@ -0,0 +1,75 @@ +#ifndef MXUTIL_H +#define MXUTIL_H + +#include "mxtypes.h" + +class MxDSFile; +class MxDSObject; + +template +inline T Abs(T p_t) +{ + return p_t < 0 ? -p_t : p_t; +} + +template +inline T Min(T p_t1, T p_t2) +{ + return p_t1 < p_t2 ? p_t1 : p_t2; +} + +template +inline T Max(T p_t1, T p_t2) +{ + return p_t1 > p_t2 ? p_t1 : p_t2; +} + +template +inline void GetScalar(MxU8** p_source, T& p_dest) +{ + p_dest = *(T*) *p_source; + *p_source += sizeof(T); +} + +template +inline T GetScalar(T** p_source) +{ + T val = **p_source; + *p_source += 1; + return val; +} + +template +inline void GetDouble(MxU8** p_source, T& p_dest) +{ + p_dest = *(double*) *p_source; + *p_source += sizeof(double); +} + +template +inline void GetString(MxU8** p_source, char** p_dest, T* p_obj, void (T::*p_setter)(const char*)) +{ + (p_obj->*p_setter)((char*) *p_source); + *p_source += strlen(*p_dest) + 1; +} + +MxBool FUN_100b6e10( + MxS32 p_bitmapWidth, + MxS32 p_bitmapHeight, + MxS32 p_videoParamWidth, + MxS32 p_videoParamHeight, + MxS32* p_left, + MxS32* p_top, + MxS32* p_right, + MxS32* p_bottom, + MxS32* p_width, + MxS32* p_height +); + +__declspec(dllexport) void MakeSourceName(char*, const char*); +__declspec(dllexport) void SetOmniUserMessage(void (*)(const char*, int)); +__declspec(dllexport) MxDSObject* CreateStreamObject(MxDSFile*, MxS16); + +MxBool KeyValueStringParse(char*, const char*, const char*); + +#endif // MXUTIL_H diff --git a/LEGO1/omni/src/action/mxdsaction.cpp b/LEGO1/omni/src/action/mxdsaction.cpp index 36533a1a..b24ff347 100644 --- a/LEGO1/omni/src/action/mxdsaction.cpp +++ b/LEGO1/omni/src/action/mxdsaction.cpp @@ -1,8 +1,8 @@ #include "mxdsaction.h" -#include "legoutil.h" #include "mxomni.h" #include "mxtimer.h" +#include "mxutil.h" #include #include diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index fb9425d2..c631dec8 100644 --- a/LEGO1/omni/src/action/mxdsmediaaction.cpp +++ b/LEGO1/omni/src/action/mxdsmediaaction.cpp @@ -1,6 +1,6 @@ #include "mxdsmediaaction.h" -#include "legoutil.h" +#include "mxutil.h" DECOMP_SIZE_ASSERT(MxDSMediaAction, 0xb8) diff --git a/LEGO1/omni/src/action/mxdsobject.cpp b/LEGO1/omni/src/action/mxdsobject.cpp index 9a5801d1..7ee92937 100644 --- a/LEGO1/omni/src/action/mxdsobject.cpp +++ b/LEGO1/omni/src/action/mxdsobject.cpp @@ -1,6 +1,5 @@ #include "mxdsobject.h" -#include "legoutil.h" #include "mxdsaction.h" #include "mxdsanim.h" #include "mxdsevent.h" @@ -13,6 +12,7 @@ #include "mxdssound.h" #include "mxdsstill.h" #include "mxdstypes.h" +#include "mxutil.h" #include #include diff --git a/LEGO1/omni/src/action/mxdssound.cpp b/LEGO1/omni/src/action/mxdssound.cpp index 359ff906..49806ce0 100644 --- a/LEGO1/omni/src/action/mxdssound.cpp +++ b/LEGO1/omni/src/action/mxdssound.cpp @@ -1,6 +1,6 @@ #include "mxdssound.h" -#include "legoutil.h" +#include "mxutil.h" DECOMP_SIZE_ASSERT(MxDSSound, 0xc0) diff --git a/LEGO1/omni/src/audio/mxmidipresenter.cpp b/LEGO1/omni/src/audio/mxmidipresenter.cpp index b648eff7..ebf6ab68 100644 --- a/LEGO1/omni/src/audio/mxmidipresenter.cpp +++ b/LEGO1/omni/src/audio/mxmidipresenter.cpp @@ -1,7 +1,6 @@ #include "mxmidipresenter.h" #include "decomp.h" -#include "legoomni.h" #include "mxautolocker.h" #include "mxdssound.h" #include "mxmusicmanager.h" diff --git a/LEGO1/omni/src/audio/mxwavepresenter.cpp b/LEGO1/omni/src/audio/mxwavepresenter.cpp index 6d08a899..9c141781 100644 --- a/LEGO1/omni/src/audio/mxwavepresenter.cpp +++ b/LEGO1/omni/src/audio/mxwavepresenter.cpp @@ -2,11 +2,11 @@ #include "decomp.h" #include "define.h" -#include "legoomni.h" #include "mxautolocker.h" #include "mxdssound.h" #include "mxomni.h" #include "mxsoundmanager.h" +#include "mxutil.h" DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c); DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x1c); diff --git a/LEGO1/omni/src/common/mxpresenter.cpp b/LEGO1/omni/src/common/mxpresenter.cpp index 0640d550..0595aee7 100644 --- a/LEGO1/omni/src/common/mxpresenter.cpp +++ b/LEGO1/omni/src/common/mxpresenter.cpp @@ -2,8 +2,6 @@ #include "decomp.h" #include "define.h" -#include "legoobjectfactory.h" -#include "legoomni.h" #include "mxactionnotificationparam.h" #include "mxautolocker.h" #include "mxcompositepresenter.h" @@ -11,8 +9,10 @@ #include "mxdssound.h" #include "mxentity.h" #include "mxnotificationmanager.h" +#include "mxobjectfactory.h" #include "mxparam.h" #include "mxstreamer.h" +#include "mxutil.h" #include diff --git a/LEGO1/omni/src/common/mxutil.cpp b/LEGO1/omni/src/common/mxutil.cpp new file mode 100644 index 00000000..538368d1 --- /dev/null +++ b/LEGO1/omni/src/common/mxutil.cpp @@ -0,0 +1,149 @@ +#include "mxutil.h" + +#include "mxdsfile.h" +#include "mxdsobject.h" +#include "mxrect32.h" + +// GLOBAL: LEGO1 0x101020e8 +void (*g_omniUserMessage)(const char*, int); + +// FUNCTION: LEGO1 0x100b6e10 +MxBool FUN_100b6e10( + MxS32 p_bitmapWidth, + MxS32 p_bitmapHeight, + MxS32 p_videoParamWidth, + MxS32 p_videoParamHeight, + MxS32* p_left, + MxS32* p_top, + MxS32* p_right, + MxS32* p_bottom, + MxS32* p_width, + MxS32* p_height +) +{ + MxPoint32 topLeft(*p_left, *p_top); + MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight)); + + MxPoint32 bottomRight(*p_right, *p_bottom); + MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight)); + + MxRect32 rect(0, 0, *p_width, *p_height); + rect.AddPoint(topLeft); + + if (!rect.IntersectsWith(bitmapRect)) + return FALSE; + + rect.Intersect(bitmapRect); + rect.SubtractPoint(topLeft); + rect.AddPoint(bottomRight); + + if (!rect.IntersectsWith(videoParamRect)) + return FALSE; + + rect.Intersect(videoParamRect); + rect.SubtractPoint(bottomRight); + + *p_left += rect.GetLeft(); + *p_top += rect.GetTop(); + *p_right += rect.GetLeft(); + *p_bottom += rect.GetTop(); + *p_width = rect.GetWidth(); + *p_height = rect.GetHeight(); + return TRUE; +} + +// FUNCTION: LEGO1 0x100b6ff0 +void MakeSourceName(char* p_output, const char* p_input) +{ + const char* cln = strchr(p_input, ':'); + if (cln) { + p_input = cln + 1; + } + + strcpy(p_output, p_input); + + strlwr(p_output); + + char* extLoc = strstr(p_output, ".si"); + if (extLoc) { + *extLoc = 0; + } +} + +// FUNCTION: LEGO1 0x100b7050 +MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p_source) +{ + MxBool didMatch = FALSE; + + MxS16 len = strlen(p_source); + char* temp = new char[len + 1]; + strcpy(temp, p_source); + + char* token = strtok(temp, ", \t\r\n:"); + while (token) { + len -= (strlen(token) + 1); + + if (strcmpi(token, p_key) == 0) { + if (p_outputValue && len > 0) { + char* cur = &token[strlen(p_key)]; + cur++; + while (*cur != ',') { + if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r') + break; + *p_outputValue++ = *cur++; + } + *p_outputValue = '\0'; + } + + didMatch = TRUE; + break; + } + + token = strtok(NULL, ", \t\r\n:"); + } + + delete[] temp; + return didMatch; +} + +// FUNCTION: LEGO1 0x100b7210 +void SetOmniUserMessage(void (*p_userMsg)(const char*, int)) +{ + g_omniUserMessage = p_userMsg; +} + +// Should probably be somewhere else +// FUNCTION: LEGO1 0x100c0280 +MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) +{ + MxU8* buf; + _MMCKINFO tmpChunk; + + if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) { + return NULL; + } + + if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) { + if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) { + + buf = new MxU8[tmpChunk.cksize]; + if (!buf) { + return NULL; + } + + if (p_file->Read(buf, tmpChunk.cksize) != 0) { + return NULL; + } + + // Save a copy so we can clean up properly, because + // this function will alter the pointer value. + MxU8* copy = buf; + MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1); + delete[] copy; + return obj; + } + return NULL; + } + + return NULL; +} diff --git a/LEGO1/omni/src/control/mxcontrolpresenter.cpp b/LEGO1/omni/src/control/mxcontrolpresenter.cpp index 47e8a720..2c7fb81d 100644 --- a/LEGO1/omni/src/control/mxcontrolpresenter.cpp +++ b/LEGO1/omni/src/control/mxcontrolpresenter.cpp @@ -1,6 +1,5 @@ #include "mxcontrolpresenter.h" -#include "legoomni.h" #include "mxticklemanager.h" DECOMP_SIZE_ASSERT(MxControlPresenter, 0x5c) diff --git a/LEGO1/omni/src/notify/mxnotificationmanager.cpp b/LEGO1/omni/src/notify/mxnotificationmanager.cpp index cc9f3930..37eab387 100644 --- a/LEGO1/omni/src/notify/mxnotificationmanager.cpp +++ b/LEGO1/omni/src/notify/mxnotificationmanager.cpp @@ -2,8 +2,8 @@ #include "compat.h" #include "decomp.h" -#include "legoomni.h" #include "mxautolocker.h" +#include "mxomni.h" #include "mxparam.h" #include "mxticklemanager.h" #include "mxtypes.h" diff --git a/LEGO1/omni/src/stream/mxstreamchunk.cpp b/LEGO1/omni/src/stream/mxstreamchunk.cpp index 57945957..4dceabec 100644 --- a/LEGO1/omni/src/stream/mxstreamchunk.cpp +++ b/LEGO1/omni/src/stream/mxstreamchunk.cpp @@ -1,8 +1,8 @@ #include "mxstreamchunk.h" -#include "legoutil.h" #include "mxdsbuffer.h" #include "mxstreamlist.h" +#include "mxutil.h" // FUNCTION: LEGO1 0x100c2fe0 MxStreamChunk::~MxStreamChunk() diff --git a/LEGO1/omni/src/stream/mxstreamcontroller.cpp b/LEGO1/omni/src/stream/mxstreamcontroller.cpp index 4e054b98..caacbb5f 100644 --- a/LEGO1/omni/src/stream/mxstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxstreamcontroller.cpp @@ -1,14 +1,14 @@ #include "mxstreamcontroller.h" -#include "legoomni.h" -#include "legoutil.h" #include "mxautolocker.h" #include "mxdsmultiaction.h" #include "mxdsstreamingaction.h" #include "mxnextactiondatastart.h" +#include "mxomni.h" #include "mxstl/stlcompat.h" #include "mxstreamchunk.h" #include "mxtimer.h" +#include "mxutil.h" DECOMP_SIZE_ASSERT(MxStreamController, 0x64) DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14) diff --git a/LEGO1/omni/src/stream/mxstreamer.cpp b/LEGO1/omni/src/stream/mxstreamer.cpp index 49fb31c3..245a757f 100644 --- a/LEGO1/omni/src/stream/mxstreamer.cpp +++ b/LEGO1/omni/src/stream/mxstreamer.cpp @@ -1,8 +1,8 @@ #include "mxstreamer.h" -#include "legoomni.h" #include "mxdiskstreamcontroller.h" #include "mxnotificationmanager.h" +#include "mxomni.h" #include "mxramstreamcontroller.h" #include diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index 69d28822..e05b0816 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -1,6 +1,6 @@ #include "mxdisplaysurface.h" -#include "legoomni.h" +#include "mxutil.h" #include "mxvideomanager.h" #include diff --git a/LEGO1/omni/src/video/mxstillpresenter.cpp b/LEGO1/omni/src/video/mxstillpresenter.cpp index ee659827..8e81f498 100644 --- a/LEGO1/omni/src/video/mxstillpresenter.cpp +++ b/LEGO1/omni/src/video/mxstillpresenter.cpp @@ -2,10 +2,10 @@ #include "decomp.h" #include "define.h" -#include "legoomni.h" #include "mxcompositepresenter.h" #include "mxdsmediaaction.h" #include "mxomni.h" +#include "mxutil.h" #include "mxvideomanager.h" DECOMP_SIZE_ASSERT(MxStillPresenter, 0x6c); diff --git a/LEGO1/omni/src/video/mxvideomanager.cpp b/LEGO1/omni/src/video/mxvideomanager.cpp index 5ce00bab..f58ff13f 100644 --- a/LEGO1/omni/src/video/mxvideomanager.cpp +++ b/LEGO1/omni/src/video/mxvideomanager.cpp @@ -1,6 +1,5 @@ #include "mxvideomanager.h" -#include "legoomni.h" #include "mxautolocker.h" #include "mxpresenter.h" #include "mxticklemanager.h"