From 433a5d2382c9fa571a65943b2d908c4d1695f3f9 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:22:38 -0400 Subject: [PATCH] Implement MxDisplaySurface::CopySurface 100% match --- LEGO1/omni/include/mxdisplaysurface.h | 2 +- LEGO1/omni/src/video/mxdisplaysurface.cpp | 27 +++++++++++++++++++---- LEGO1/omni/src/video/mxstillpresenter.cpp | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/LEGO1/omni/include/mxdisplaysurface.h b/LEGO1/omni/include/mxdisplaysurface.h index 4e107f60..61b35eec 100644 --- a/LEGO1/omni/include/mxdisplaysurface.h +++ b/LEGO1/omni/include/mxdisplaysurface.h @@ -92,7 +92,7 @@ class MxDisplaySurface : public MxCore { void ClearScreen(); static LPDIRECTDRAWSURFACE CreateCursorSurface(); - static LPDIRECTDRAWSURFACE FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und); + static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src); inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; } diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index c599b131..8ba60a75 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -701,11 +701,30 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44( return surface; } -// STUB: LEGO1 0x100bbfb0 -LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und) +// FUNCTION: LEGO1 0x100bbfb0 +LPDIRECTDRAWSURFACE MxDisplaySurface::CopySurface(LPDIRECTDRAWSURFACE p_src) { - // TODO - return NULL; + LPDIRECTDRAWSURFACE newSurface = NULL; + IDirectDraw* draw = MVideoManager()->GetDirectDraw(); + + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + p_src->GetSurfaceDesc(&ddsd); + + if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) { + return NULL; + } + + RECT rect = {0, 0, ddsd.dwWidth, ddsd.dwHeight}; + + if (newSurface->BltFast(0, 0, p_src, &rect, 16) != DD_OK) { + newSurface->Release(); + return NULL; + } + + return newSurface; } // FUNCTION: LEGO1 0x100bc070 diff --git a/LEGO1/omni/src/video/mxstillpresenter.cpp b/LEGO1/omni/src/video/mxstillpresenter.cpp index a144e7c1..3908aadb 100644 --- a/LEGO1/omni/src/video/mxstillpresenter.cpp +++ b/LEGO1/omni/src/video/mxstillpresenter.cpp @@ -249,7 +249,7 @@ MxStillPresenter* MxStillPresenter::Clone() } if (m_unk0x58) { - presenter->m_unk0x58 = MxDisplaySurface::FUN_100bbfb0(m_unk0x58); + presenter->m_unk0x58 = MxDisplaySurface::CopySurface(m_unk0x58); } if (m_alpha) {