diff --git a/LEGO1/legovideomanager.cpp b/LEGO1/legovideomanager.cpp index 92440dd4..167b81a3 100644 --- a/LEGO1/legovideomanager.cpp +++ b/LEGO1/legovideomanager.cpp @@ -75,10 +75,53 @@ void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable) EnableFullScreenMovie(p_enable, TRUE); } -// STUB: LEGO1 0x1007c310 +// FUNCTION: LEGO1 0x1007c310 void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable, MxBool p_scale) { - // TODO + if (m_isFullscreenMovie != p_enable) { + m_isFullscreenMovie = p_enable; + + if (p_enable) { + m_palette = m_videoParam.GetPalette()->Clone(); + OverrideSkyColor(FALSE); + + m_displaySurface->GetVideoParam().Flags().SetF1bit3(p_scale); + + m_unk0xe4 = FALSE; + m_unk0x500 = TRUE; + } + else { + m_displaySurface->FUN_100ba640(); + m_displaySurface->GetVideoParam().Flags().SetF1bit3(FALSE); + + // restore previous pallete + RealizePalette(m_palette); + delete m_palette; + m_palette = NULL; + + // update region where video used to be + MxRect32 rect( + 0, + 0, + m_videoParam.GetRect().GetRight() - m_videoParam.GetRect().GetLeft(), + m_videoParam.GetRect().GetBottom() - m_videoParam.GetRect().GetTop() + ); + + InvalidateRect(rect); + UpdateRegion(); + OverrideSkyColor(TRUE); + + m_unk0xe4 = TRUE; + m_unk0x500 = FALSE; + } + } + + if (p_enable) { + m_displaySurface->GetVideoParam().Flags().SetF1bit3(p_scale); + } + else { + m_displaySurface->GetVideoParam().Flags().SetF1bit3(FALSE); + } } // FUNCTION: LEGO1 0x1007c440 @@ -97,6 +140,12 @@ void LegoVideoManager::SetSkyColor(float p_red, float p_green, float p_blue) // m_3dManager->m_pViewport->VTable0x1c(red, green, blue) } +// FUNCTION: LEGO1 0x1007c4c0 +void LegoVideoManager::OverrideSkyColor(MxBool p_shouldOverride) +{ + this->m_videoParam.GetPalette()->SetOverrideSkyColor(p_shouldOverride); +} + // STUB: LEGO1 0x1007c560 int LegoVideoManager::EnableRMDevice() { diff --git a/LEGO1/legovideomanager.h b/LEGO1/legovideomanager.h index 02558785..11501e2d 100644 --- a/LEGO1/legovideomanager.h +++ b/LEGO1/legovideomanager.h @@ -21,20 +21,15 @@ class LegoVideoManager : public MxVideoManager { __declspec(dllexport) void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale); __declspec(dllexport) void MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY); - inline Lego3DManager* Get3DManager() { return this->m_3dManager; } - inline MxDirect3D* GetDirect3D() { return this->m_direct3d; } + virtual void Destroy() override; // vtable+0x18 void SetSkyColor(float p_red, float p_green, float p_blue); + void OverrideSkyColor(MxBool p_shouldOverride); + + inline Lego3DManager* Get3DManager() { return this->m_3dManager; } + inline MxDirect3D* GetDirect3D() { return this->m_direct3d; } inline void SetUnkE4(MxBool p_unk0xe4) { this->m_unk0xe4 = p_unk0xe4; } - // FUNCTION: LEGO1 0x1007c4c0 - void OverrideSkyColor(MxBool p_shouldOverride) - { - this->m_videoParam.GetPalette()->SetOverrideSkyColor(p_shouldOverride); - } - - virtual void Destroy() override; // vtable+0x18 - private: undefined4 m_unk0x64; Lego3DManager* m_3dManager; // 0x68 diff --git a/LEGO1/mxdisplaysurface.cpp b/LEGO1/mxdisplaysurface.cpp index 957bc568..bc1d2078 100644 --- a/LEGO1/mxdisplaysurface.cpp +++ b/LEGO1/mxdisplaysurface.cpp @@ -28,10 +28,47 @@ void MxDisplaySurface::Reset() memset(&this->m_surfaceDesc, 0, sizeof(this->m_surfaceDesc)); } -// STUB: LEGO1 0x100ba640 +// FUNCTION: LEGO1 0x100ba640 void MxDisplaySurface::FUN_100ba640() { - // TODO + MxS32 backBuffers; + DDSURFACEDESC desc; + HRESULT hr; + + if (!m_videoParam.Flags().GetFlipSurfaces()) { + backBuffers = 1; + } + else { + backBuffers = m_videoParam.GetBackBuffers() + 1; + } + + for (MxS32 i = 0; i < backBuffers; i++) { + memset(&desc, 0, sizeof(DDSURFACEDESC)); + + desc.dwSize = sizeof(DDSURFACEDESC); + hr = m_ddSurface2->Lock(NULL, &desc, DDLOCK_WAIT, NULL); + if (hr == DDERR_SURFACELOST) { + m_ddSurface2->Restore(); + hr = m_ddSurface2->Lock(NULL, &desc, DDLOCK_WAIT, NULL); + } + + if (hr != S_OK) { + return; + } + + MxU8* surface = (MxU8*) desc.lpSurface; + MxS32 height = m_videoParam.GetRect().GetHeight(); + + while (height--) { + memset(surface, 0, m_videoParam.GetRect().GetWidth() * desc.ddpfPixelFormat.dwRGBBitCount / 8); + surface += desc.lPitch; + } + + m_ddSurface2->Unlock(desc.lpSurface); + if (m_videoParam.Flags().GetFlipSurfaces()) { + m_ddSurface1->Flip(NULL, 1); + } + } } // FUNCTION: LEGO1 0x100ba790 diff --git a/LEGO1/mxdisplaysurface.h b/LEGO1/mxdisplaysurface.h index 280100f4..3d386bb4 100644 --- a/LEGO1/mxdisplaysurface.h +++ b/LEGO1/mxdisplaysurface.h @@ -69,6 +69,7 @@ class MxDisplaySurface : public MxCore { inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; } + inline MxVideoParam& GetVideoParam() { return this->m_videoParam; } private: MxVideoParam m_videoParam; diff --git a/LEGO1/mxpalette.h b/LEGO1/mxpalette.h index d63b061c..90ffa605 100644 --- a/LEGO1/mxpalette.h +++ b/LEGO1/mxpalette.h @@ -25,6 +25,7 @@ class MxPalette : public MxCore { MxResult SetSkyColor(LPPALETTEENTRY p_skyColor); void Reset(MxBool p_ignoreSkyColor); LPDIRECTDRAWPALETTE CreateNativePalette(); + inline void SetOverrideSkyColor(MxBool p_value) { this->m_overrideSkyColor = p_value; } private: