From 8008a011097cc5bedb00bc7e83f482edbbda8714 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 20 Dec 2024 02:19:05 +0100 Subject: [PATCH] Implement MxDisplaySurface::FUN_100bc8b0 --- .../legoomni/src/video/legovideomanager.cpp | 8 +++-- LEGO1/omni/include/mxdisplaysurface.h | 2 +- LEGO1/omni/src/video/mxdisplaysurface.cpp | 29 +++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp index e4c2a662..7805671a 100644 --- a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp +++ b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp @@ -417,7 +417,7 @@ void LegoVideoManager::DrawFPS() SelectObject(dc, m_arialFont); GetTextExtentPointA(dc, zeros, strlen(zeros), &m_fpsSize); ReleaseDC(NULL, dc); - m_unk0x528 = m_displaySurface->FUN_100bc8b0(); + m_unk0x528 = m_displaySurface->FUN_100bc8b0(m_fpsSize.cx, m_fpsSize.cy); SetRect(&this->m_fpsRect, 0, 0, m_fpsSize.cx, m_fpsSize.cy); if (m_unk0x528 == NULL) { DeleteObject(m_arialFont); @@ -428,7 +428,8 @@ void LegoVideoManager::DrawFPS() color_key.dwColorSpaceHighValue = 0; color_key.dwColorSpaceLowValue = 0; m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &color_key); - DDSURFACEDESC surfaceDesc = {0}; + DDSURFACEDESC surfaceDesc; + memset(&surfaceDesc, 0, sizeof(surfaceDesc)); surfaceDesc.dwSize = sizeof(surfaceDesc); if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK) { m_unk0x528->Release(); @@ -457,7 +458,8 @@ void LegoVideoManager::DrawFPS() char buffer[32]; int nb = sprintf(buffer, "%.02f", m_unk0x550 / (Timer()->GetTime() - m_unk0x54c) / 1000.f); m_unk0x54c = Timer()->GetTime(); - DDSURFACEDESC surfaceDesc = {0}; + DDSURFACEDESC surfaceDesc; + memset(&surfaceDesc, 0, sizeof(surfaceDesc)); surfaceDesc.dwSize = sizeof(surfaceDesc); if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) == DD_OK) { DWORD i; diff --git a/LEGO1/omni/include/mxdisplaysurface.h b/LEGO1/omni/include/mxdisplaysurface.h index ba458d28..a3083f77 100644 --- a/LEGO1/omni/include/mxdisplaysurface.h +++ b/LEGO1/omni/include/mxdisplaysurface.h @@ -109,7 +109,7 @@ class MxDisplaySurface : public MxCore { MxU8 p_bpp ); - IDirectDrawSurface* FUN_100bc8b0(void); + IDirectDrawSurface* FUN_100bc8b0(int width, int height); private: MxU8 CountTotalBitsSetTo1(MxU32 p_param); diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index 4ff4f382..d3bf5677 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -1093,8 +1093,31 @@ MxBool MxDisplaySurface::VTable0x2c( return 0; } -// STUB: LEGO1 0x100bc8b0 -IDirectDrawSurface* MxDisplaySurface::FUN_100bc8b0(void) +// FUNCTION: LEGO1 0x100bc8b0 +IDirectDrawSurface* MxDisplaySurface::FUN_100bc8b0(int width, int height) { - return NULL; + MxVideoManager *video_manager = MVideoManager(); + IDirectDraw *ddraw = video_manager->GetDirectDraw(); + MVideoManager(); + DDSURFACEDESC surfaceDesc; + memset(&surfaceDesc, 0, sizeof(surfaceDesc)); + surfaceDesc.dwSize = sizeof(surfaceDesc); + if (ddraw->GetDisplayMode(&surfaceDesc) != DD_OK) { + return NULL; + } + if (surfaceDesc.ddpfPixelFormat.dwRGBBitCount != 16) { + return NULL; + } + surfaceDesc.dwWidth = width; + surfaceDesc.dwHeight = height; + surfaceDesc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; + surfaceDesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN; + IDirectDrawSurface *surface = NULL; + if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) { + surfaceDesc.ddsCaps.dwCaps = (surfaceDesc.ddsCaps.dwCaps & ~DDSCAPS_VIDEOMEMORY) | DDSCAPS_SYSTEMMEMORY; + if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) { + return NULL; + } + } + return surface; }