Implement MxDisplaySurface::FUN_100bc8b0

This commit is contained in:
Anonymous Maarten 2024-12-20 02:19:05 +01:00
parent e70e120c0f
commit 8008a01109
3 changed files with 32 additions and 7 deletions

View File

@ -417,7 +417,7 @@ void LegoVideoManager::DrawFPS()
SelectObject(dc, m_arialFont); SelectObject(dc, m_arialFont);
GetTextExtentPointA(dc, zeros, strlen(zeros), &m_fpsSize); GetTextExtentPointA(dc, zeros, strlen(zeros), &m_fpsSize);
ReleaseDC(NULL, dc); 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); SetRect(&this->m_fpsRect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
if (m_unk0x528 == NULL) { if (m_unk0x528 == NULL) {
DeleteObject(m_arialFont); DeleteObject(m_arialFont);
@ -428,7 +428,8 @@ void LegoVideoManager::DrawFPS()
color_key.dwColorSpaceHighValue = 0; color_key.dwColorSpaceHighValue = 0;
color_key.dwColorSpaceLowValue = 0; color_key.dwColorSpaceLowValue = 0;
m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &color_key); m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &color_key);
DDSURFACEDESC surfaceDesc = {0}; DDSURFACEDESC surfaceDesc;
memset(&surfaceDesc, 0, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc); surfaceDesc.dwSize = sizeof(surfaceDesc);
if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK) { if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK) {
m_unk0x528->Release(); m_unk0x528->Release();
@ -457,7 +458,8 @@ void LegoVideoManager::DrawFPS()
char buffer[32]; char buffer[32];
int nb = sprintf(buffer, "%.02f", m_unk0x550 / (Timer()->GetTime() - m_unk0x54c) / 1000.f); int nb = sprintf(buffer, "%.02f", m_unk0x550 / (Timer()->GetTime() - m_unk0x54c) / 1000.f);
m_unk0x54c = Timer()->GetTime(); m_unk0x54c = Timer()->GetTime();
DDSURFACEDESC surfaceDesc = {0}; DDSURFACEDESC surfaceDesc;
memset(&surfaceDesc, 0, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc); surfaceDesc.dwSize = sizeof(surfaceDesc);
if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) == DD_OK) { if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) == DD_OK) {
DWORD i; DWORD i;

View File

@ -109,7 +109,7 @@ class MxDisplaySurface : public MxCore {
MxU8 p_bpp MxU8 p_bpp
); );
IDirectDrawSurface* FUN_100bc8b0(void); IDirectDrawSurface* FUN_100bc8b0(int width, int height);
private: private:
MxU8 CountTotalBitsSetTo1(MxU32 p_param); MxU8 CountTotalBitsSetTo1(MxU32 p_param);

View File

@ -1093,8 +1093,31 @@ MxBool MxDisplaySurface::VTable0x2c(
return 0; return 0;
} }
// STUB: LEGO1 0x100bc8b0 // FUNCTION: LEGO1 0x100bc8b0
IDirectDrawSurface* MxDisplaySurface::FUN_100bc8b0(void) IDirectDrawSurface* MxDisplaySurface::FUN_100bc8b0(int width, int height)
{ {
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; 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;
} }