diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 87f3ebe2..9aefae60 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -104,7 +104,7 @@ void IsleApp::Close() Lego()->RemoveWorld(ds.GetAtomId(), ds.GetObjectId()); Lego()->DeleteObject(ds); TransitionManager()->SetWaitIndicator(NULL); - Lego()->vtable0x3c(); + Lego()->StopTimer(); MxLong lVar8; do { @@ -243,7 +243,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_reqEnableRMDevice = 0; VideoManager()->EnableRMDevice(); g_rmDisabled = 0; - Lego()->vtable0x3c(); + Lego()->StopTimer(); } if (g_closed) { diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 2bff73af..f4480bb8 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -3,6 +3,7 @@ #include "mxbackgroundaudiomanager.h" #include "mxdsfile.h" #include "legogamestate.h" +#include "legoutil.h" // 0x100f4588 char *g_nocdSourceName = NULL; @@ -307,14 +308,18 @@ void LegoOmni::NotifyCurrentEntity() // FIXME: Stub } +// OFFSET: LEGO1 0x1005b640 void LegoOmni::StartTimer() { - // FIXME: Stub + MxOmni::StartTimer(); + SetAppCursor(2); } -void LegoOmni::vtable0x3c() +// OFFSET: LEGO1 0x1005b650 +void LegoOmni::StopTimer() { - // FIXME: Stub + MxOmni::StopTimer(); + SetAppCursor(0); } MxBool LegoOmni::vtable40() diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 122c77de..4de0d1b5 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -61,7 +61,7 @@ class LegoOmni : public MxOmni virtual int vtable0x30(char*, int, MxCore*) override; virtual void NotifyCurrentEntity() override; virtual void StartTimer() override; - virtual void vtable0x3c() override; + virtual void StopTimer() override; virtual MxBool vtable40(); LegoVideoManager *GetVideoManager() { return (LegoVideoManager *) m_videoManager; } diff --git a/LEGO1/mxbitmap.h b/LEGO1/mxbitmap.h index ba90b7da..791581c6 100644 --- a/LEGO1/mxbitmap.h +++ b/LEGO1/mxbitmap.h @@ -25,6 +25,8 @@ struct MxBITMAPINFO { #define LOWCOLOR 0 // 256 color #define HIGHCOLOR 1 // High Color (16-bit) +// SIZE 0x20 +// VTABLE 0x100dc7b0 class MxBitmap : public MxCore { public: @@ -44,6 +46,8 @@ class MxBitmap : public MxCore virtual MxResult SetBitDepth(MxBool); // vtable+3c virtual MxResult StretchBits(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight); // vtable+40 + inline BITMAPINFOHEADER *GetBmiHeader() const { return m_bmiHeader; } + private: MxResult ImportColorsToPalette(RGBQUAD*, MxPalette*); diff --git a/LEGO1/mxdisplaysurface.cpp b/LEGO1/mxdisplaysurface.cpp index 05a50475..af7e57db 100644 --- a/LEGO1/mxdisplaysurface.cpp +++ b/LEGO1/mxdisplaysurface.cpp @@ -176,7 +176,7 @@ void MxDisplaySurface::SetPalette(MxPalette *p_palette) } // OFFSET: LEGO1 0x100bc200 STUB -void MxDisplaySurface::vtable24(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4) +void MxDisplaySurface::vtable24(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4) { } @@ -188,7 +188,7 @@ MxBool MxDisplaySurface::vtable28(undefined4, undefined4, undefined4, undefined4 } // OFFSET: LEGO1 0x100bc630 STUB -MxBool MxDisplaySurface::vtable2c(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool) +MxBool MxDisplaySurface::vtable2c(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool) { return 0; } diff --git a/LEGO1/mxdisplaysurface.h b/LEGO1/mxdisplaysurface.h index 8e79f6e8..8a80a0f4 100644 --- a/LEGO1/mxdisplaysurface.h +++ b/LEGO1/mxdisplaysurface.h @@ -3,6 +3,7 @@ #include +#include "mxbitmap.h" #include "mxcore.h" #include "mxpalette.h" #include "mxvideoparam.h" @@ -25,9 +26,9 @@ class MxDisplaySurface : public MxCore virtual MxResult Create(MxVideoParam &p_videoParam); virtual void Clear(); virtual void SetPalette(MxPalette *p_palette); - virtual void vtable24(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); + virtual void vtable24(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); virtual MxBool vtable28(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); - virtual MxBool vtable2c(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); + virtual MxBool vtable2c(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); virtual MxBool vtable30(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); virtual undefined4 vtable34(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); virtual void Display(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index 39c2beb3..fa76d8a5 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -52,7 +52,7 @@ void MxOmni::Init() m_timer = NULL; m_streamer = NULL; m_atomIdCounterSet = NULL; - m_unk64 = NULL; + m_timerRunning = NULL; } // OFFSET: LEGO1 0x100b0090 @@ -99,16 +99,26 @@ void MxOmni::NotifyCurrentEntity() // TODO } -// OFFSET: LEGO1 0x100b09d0 STUB +// OFFSET: LEGO1 0x100b09d0 void MxOmni::StartTimer() { - // TODO + if (m_timerRunning == FALSE && m_timer != NULL && m_soundManager != NULL) + { + m_timer->Start(); + m_soundManager->vtable0x34(); + m_timerRunning = TRUE; + } } -// OFFSET: LEGO1 0x100b0a00 STUB -void MxOmni::vtable0x3c() +// OFFSET: LEGO1 0x100b0a00 +void MxOmni::StopTimer() { - // TODO + if (m_timerRunning != FALSE && m_timer != NULL && m_soundManager != NULL) + { + m_timer->Stop(); + m_soundManager->vtable0x38(); + m_timerRunning = FALSE; + } } // OFFSET: LEGO1 0x100b0690 diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 4475148f..274458ed 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -47,7 +47,7 @@ class MxOmni : public MxCore virtual int vtable0x30(char*, int, MxCore*); // vtable+30 virtual void NotifyCurrentEntity(); // vtable+34 virtual void StartTimer(); // vtable+38 - virtual void vtable0x3c(); // vtable+3c + virtual void StopTimer(); // vtable+3c static void SetInstance(MxOmni* instance); HWND GetWindowHandle() const { return this->m_windowHandle; } MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; } @@ -82,7 +82,7 @@ class MxOmni : public MxCore MxCriticalSection m_criticalsection; // 0x48 - unsigned char m_unk64; // 0x64 + MxBool m_timerRunning; // 0x64 }; __declspec(dllexport) MxTickleManager * TickleManager(); __declspec(dllexport) MxTimer * Timer(); diff --git a/LEGO1/mxpresenter.h b/LEGO1/mxpresenter.h index 81ea14ad..156065f4 100644 --- a/LEGO1/mxpresenter.h +++ b/LEGO1/mxpresenter.h @@ -68,17 +68,19 @@ class MxPresenter : public MxCore MxBool IsEnabled(); - inline MxS32 GetCurrentTickleState() { return this->m_currentTickleState; } - inline MxPoint32 GetLocation() { return this->m_location; } - inline MxS32 GetDisplayZ() { return this->m_displayZ; } - inline MxDSAction *GetAction() { return this->m_action; } + inline MxS32 GetCurrentTickleState() const { return this->m_currentTickleState; } + inline MxPoint32 GetLocation() const { return this->m_location; } + inline MxS32 GetLocationX() const { return this->m_location.m_x; } + inline MxS32 GetLocationY() const { return this->m_location.m_y; } + inline MxS32 GetDisplayZ() const { return this->m_displayZ; } + inline MxDSAction *GetAction() const { return this->m_action; } protected: __declspec(dllexport) void Init(); void SendTo_unkPresenter(MxOmni *); private: - MxS32 m_currentTickleState; // 0x8 + TickleState m_currentTickleState; // 0x8 MxU32 m_previousTickleStates; MxPoint32 m_location; MxS32 m_displayZ; diff --git a/LEGO1/mxsmkpresenter.cpp b/LEGO1/mxsmkpresenter.cpp index cc7efec1..99faae22 100644 --- a/LEGO1/mxsmkpresenter.cpp +++ b/LEGO1/mxsmkpresenter.cpp @@ -15,3 +15,14 @@ void MxSmkPresenter::Init() { // TODO } + +// OFFSET: LEGO1 0x100b3960 +void MxSmkPresenter::VTable0x60() +{ + if (m_bitmap) { + delete m_bitmap; + } + + m_bitmap = new MxBitmap(); + m_bitmap->SetSize(m_smkWidth, m_smkHeight, NULL, NULL); +} diff --git a/LEGO1/mxsmkpresenter.h b/LEGO1/mxsmkpresenter.h index 325091bb..34a78dab 100644 --- a/LEGO1/mxsmkpresenter.h +++ b/LEGO1/mxsmkpresenter.h @@ -12,7 +12,12 @@ class MxSmkPresenter : public MxVideoPresenter public: MxSmkPresenter(); - undefined4 m_unk64[430]; + virtual void VTable0x60() override; + + undefined4 m_unk64; + MxS32 m_smkWidth; // 0x68 + MxS32 m_smkHeight; // 0x6c + undefined4 m_unk70[427]; undefined4 m_unk71c; private: void Init(); diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index c858226b..e34534f9 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -49,7 +49,7 @@ void MxSoundManager::Destroy(MxBool p_param) } // OFFSET: LEGO1 0x100ae8b0 STUB -MxResult MxSoundManager::StartDirectSound(undefined4 p_unknown1, undefined p_unknown2) +MxResult MxSoundManager::StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2) { // TODO STUB return FAILURE; diff --git a/LEGO1/mxsoundmanager.h b/LEGO1/mxsoundmanager.h index 4a6ba5f8..46eef2e7 100644 --- a/LEGO1/mxsoundmanager.h +++ b/LEGO1/mxsoundmanager.h @@ -14,9 +14,10 @@ class MxSoundManager : public MxAudioManager MxSoundManager(); virtual ~MxSoundManager() override; // vtable+0x0 - virtual MxResult StartDirectSound(undefined4 p_unknown1, undefined p_unknown2); //vtable+0x30 + virtual MxResult StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2); //vtable+0x30 virtual void vtable0x34(); // vtable+0x34 virtual void vtable0x38(); // vtable+0x38 + private: void Init(); void Destroy(MxBool); diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index 8d52266c..d7d16544 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -29,7 +29,7 @@ MxTransitionManager::MxTransitionManager() // OFFSET: LEGO1 0x1004ba00 MxTransitionManager::~MxTransitionManager() { - free(m_copyBuffer); + delete[] m_copyBuffer; if (m_waitIndicator != NULL) { delete m_waitIndicator->GetAction(); @@ -324,17 +324,17 @@ void MxTransitionManager::SubmitCopyRect(LPDDSURFACEDESC ddsc) } // Copy the copy rect onto the surface - char *dst; + MxU8 *dst; - DWORD bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; + MxU32 bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; - const char *src = (const char *)m_copyBuffer; + const MxU8 *src = (const MxU8 *)m_copyBuffer; - LONG copyPitch; + MxS32 copyPitch; copyPitch = ((m_copyRect.right - m_copyRect.left) + 1) * bytesPerPixel; - LONG y; - dst = (char *)ddsc->lpSurface + (ddsc->lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left); + MxS32 y; + dst = (MxU8 *)ddsc->lpSurface + (ddsc->lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left); for (y = 0; y < m_copyRect.bottom - m_copyRect.top + 1; ++y) { memcpy(dst, src, copyPitch); @@ -343,7 +343,7 @@ void MxTransitionManager::SubmitCopyRect(LPDDSURFACEDESC ddsc) } // Free the copy buffer - free(m_copyBuffer); + delete[] m_copyBuffer; m_copyBuffer = NULL; } @@ -361,11 +361,11 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) // Check if wait indicator has started if (m_waitIndicator->GetCurrentTickleState() >= MxPresenter::TickleState_Streaming) { // Setup the copy rect - DWORD copyPitch = (ddsc->ddpfPixelFormat.dwRGBBitCount / 8) * (m_copyRect.right - m_copyRect.left + 1); // This uses m_copyRect, seemingly erroneously - DWORD bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; + MxU32 copyPitch = (ddsc->ddpfPixelFormat.dwRGBBitCount / 8) * (m_copyRect.right - m_copyRect.left + 1); // This uses m_copyRect, seemingly erroneously + MxU32 bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; - m_copyRect.left = m_waitIndicator->GetLocation().m_x; - m_copyRect.top = m_waitIndicator->GetLocation().m_y; + m_copyRect.left = m_waitIndicator->GetLocationX(); + m_copyRect.top = m_waitIndicator->GetLocationY(); MxS32 height = m_waitIndicator->GetHeight(); MxS32 width = m_waitIndicator->GetWidth(); @@ -374,14 +374,14 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) m_copyRect.bottom = m_copyRect.top + height - 1; // Allocate the copy buffer - const char *src = (const char*)ddsc->lpSurface + m_copyRect.top * ddsc->lPitch + bytesPerPixel * m_copyRect.left; + const MxU8 *src = (const MxU8*)ddsc->lpSurface + m_copyRect.top * ddsc->lPitch + bytesPerPixel * m_copyRect.left; - m_copyBuffer = malloc(bytesPerPixel * width * height); + m_copyBuffer = new MxU8[bytesPerPixel * width * height]; if (!m_copyBuffer) return; // Copy into the copy buffer - char *dst = (char*)m_copyBuffer; + MxU8 *dst = m_copyBuffer; for (MxS32 i = 0; i < (m_copyRect.bottom - m_copyRect.top + 1); i++) { @@ -396,11 +396,11 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) { MxDisplaySurface *displaySurface = VideoManager()->GetDisplaySurface(); MxBool unkbool = FALSE; - displaySurface->vtable2c(ddsc, m_waitIndicator->m_unk50, 0, 0, m_waitIndicator->GetLocation().m_x, m_waitIndicator->GetLocation().m_y, m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight(), unkbool); + displaySurface->vtable2c(ddsc, m_waitIndicator->m_bitmap, 0, 0, m_waitIndicator->GetLocationX(), m_waitIndicator->GetLocationY(), m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight(), unkbool); } else { MxDisplaySurface *displaySurface = VideoManager()->GetDisplaySurface(); - displaySurface->vtable24(ddsc, m_waitIndicator->m_unk50, 0, 0, m_waitIndicator->GetLocation().m_x, m_waitIndicator->GetLocation().m_y, m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight()); + displaySurface->vtable24(ddsc, m_waitIndicator->m_bitmap, 0, 0, m_waitIndicator->GetLocationX(), m_waitIndicator->GetLocationY(), m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight()); } } diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index b4a9ba30..58a8079e 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -59,7 +59,7 @@ class MxTransitionManager : public MxCore MxVideoPresenter *m_waitIndicator; RECT m_copyRect; - void *m_copyBuffer; + MxU8 *m_copyBuffer; flag_bitfield m_copyFlags; undefined4 m_unk24; diff --git a/LEGO1/mxvideopresenter.cpp b/LEGO1/mxvideopresenter.cpp index fe83a2dc..42dc34f3 100644 --- a/LEGO1/mxvideopresenter.cpp +++ b/LEGO1/mxvideopresenter.cpp @@ -8,10 +8,10 @@ void MxVideoPresenter::VTable0x5c() // TODO } -// OFFSET: LEGO1 0x1000c710 STUB +// OFFSET: LEGO1 0x1000c710 void MxVideoPresenter::VTable0x60() { - // TODO + // Empty } // OFFSET: LEGO1 0x1000c720 STUB @@ -44,24 +44,24 @@ void MxVideoPresenter::VTable0x78() // TODO } -// OFFSET: LEGO1 0x1000c7c0 STUB -void MxVideoPresenter::VTable0x7c() +// OFFSET: LEGO1 0x1000c7c0 +MxBool MxVideoPresenter::VTable0x7c() { - // TODO + return (m_bitmap != NULL) || (m_unk54 != NULL); } -// OFFSET: LEGO1 0x1000c7e0 STUB +// OFFSET: LEGO1 0x1000c7e0 MxS32 MxVideoPresenter::GetWidth() { - // TODO - return 0; + return m_unk54 ? m_unk54->width + : m_bitmap->GetBmiHeader()->biWidth; } -// OFFSET: LEGO1 0x1000c800 STUB +// OFFSET: LEGO1 0x1000c800 MxS32 MxVideoPresenter::GetHeight() { - // TODO - return 0; + return m_unk54 ? m_unk54->height + : m_bitmap->GetBmiHeader()->biHeight; } // OFFSET: LEGO1 0x100b2760 STUB diff --git a/LEGO1/mxvideopresenter.h b/LEGO1/mxvideopresenter.h index 84822f71..9c9a21a3 100644 --- a/LEGO1/mxvideopresenter.h +++ b/LEGO1/mxvideopresenter.h @@ -2,9 +2,11 @@ #define MXVIDEOPRESENTER_H #include "mxmediapresenter.h" +#include "mxbitmap.h" #include "decomp.h" +// VTABLE 0x100d4be8 class MxVideoPresenter : public MxMediaPresenter { public: @@ -41,12 +43,20 @@ class MxVideoPresenter : public MxMediaPresenter virtual void VTable0x70(); // vtable+0x70 virtual void VTable0x74(); // vtable+0x74 virtual void VTable0x78(); // vtable+0x78 - virtual void VTable0x7c(); // vtable+0x7c + virtual MxBool VTable0x7c(); // vtable+0x7c virtual MxS32 GetWidth(); // vtable+0x80 virtual MxS32 GetHeight(); // vtable+0x84 - undefined4 m_unk50; - undefined4 m_unk54; + // TODO: Not sure what this is. Seems to have size of 12 bytes + // based on 0x100b9e9a. Values are copied from the bitmap header. + typedef struct { + undefined unk0[8]; + MxU16 width; + MxU16 height; + } unknown_meta_struct; + + MxBitmap *m_bitmap; + unknown_meta_struct *m_unk54; undefined4 m_unk58; undefined2 m_unk5c; unsigned char m_flags; // 0x5e