Match functions

This commit is contained in:
Christian Semmler 2024-12-20 08:43:04 -07:00
parent 8008a01109
commit a0233ffe65
3 changed files with 44 additions and 21 deletions

View File

@ -396,6 +396,7 @@ inline void LegoVideoManager::DrawCursor()
void LegoVideoManager::DrawFPS() void LegoVideoManager::DrawFPS()
{ {
char zeros[8] = "0000.00"; char zeros[8] = "0000.00";
if (m_unk0x528 == NULL) { if (m_unk0x528 == NULL) {
m_arialFont = CreateFontA( m_arialFont = CreateFontA(
12, 12,
@ -413,24 +414,29 @@ void LegoVideoManager::DrawFPS()
FF_DONTCARE | VARIABLE_PITCH, FF_DONTCARE | VARIABLE_PITCH,
"Arial" "Arial"
); );
HDC dc = GetDC(NULL); HDC dc = GetDC(NULL);
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_fpsSize.cx, m_fpsSize.cy); 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(&m_fpsRect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
if (m_unk0x528 == NULL) { if (m_unk0x528 == NULL) {
DeleteObject(m_arialFont); DeleteObject(m_arialFont);
m_arialFont = NULL; m_arialFont = NULL;
return; return;
} }
DDCOLORKEY color_key;
color_key.dwColorSpaceHighValue = 0; DDCOLORKEY colorKey;
color_key.dwColorSpaceLowValue = 0; memset(&colorKey, 0, sizeof(colorKey));
m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &color_key); m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &colorKey);
DDSURFACEDESC surfaceDesc; DDSURFACEDESC surfaceDesc;
memset(&surfaceDesc, 0, sizeof(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();
DeleteObject(m_arialFont); DeleteObject(m_arialFont);
@ -440,36 +446,40 @@ void LegoVideoManager::DrawFPS()
else { else {
DWORD i; DWORD i;
char* ptr = (char*) surfaceDesc.lpSurface; char* ptr = (char*) surfaceDesc.lpSurface;
for (i = 0; i < surfaceDesc.dwHeight; i++) { for (i = 0; i < surfaceDesc.dwHeight; i++) {
memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8); memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
ptr += surfaceDesc.lPitch; ptr += surfaceDesc.lPitch;
} }
m_unk0x528->Unlock(surfaceDesc.lpSurface); m_unk0x528->Unlock(surfaceDesc.lpSurface);
m_unk0x54c = Timer()->GetTime(); m_unk0x54c = Timer()->GetTime();
m_unk0x550 = 1.f; m_unk0x550 = 1.f;
} }
} }
else { else {
MxTimer* timer = Timer(); if (Timer()->GetTime() > m_unk0x54c + 5000.f) {
if (timer->GetTime() <= m_unk0x54c + 5000.f) {
m_unk0x550 += 1.f;
}
else {
char buffer[32]; char buffer[32];
int nb = sprintf(buffer, "%.02f", m_unk0x550 / (Timer()->GetTime() - m_unk0x54c) / 1000.f); MxFloat time = (Timer()->GetTime() - m_unk0x54c) / 1000.0f;
MxS32 nb = sprintf(buffer, "%.02f", m_unk0x550 / time);
m_unk0x54c = Timer()->GetTime(); m_unk0x54c = Timer()->GetTime();
DDSURFACEDESC surfaceDesc; DDSURFACEDESC surfaceDesc;
memset(&surfaceDesc, 0, sizeof(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;
char* ptr = (char*) surfaceDesc.lpSurface; char* ptr = (char*) surfaceDesc.lpSurface;
for (i = 0; i < surfaceDesc.dwHeight; i++) { for (i = 0; i < surfaceDesc.dwHeight; i++) {
memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8); memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
ptr += surfaceDesc.lPitch; ptr += surfaceDesc.lPitch;
} }
m_unk0x528->Unlock(surfaceDesc.lpSurface); m_unk0x528->Unlock(surfaceDesc.lpSurface);
} }
HDC dc; HDC dc;
if (m_unk0x528->GetDC(&dc) != DD_OK) { if (m_unk0x528->GetDC(&dc) != DD_OK) {
m_unk0x528->Release(); m_unk0x528->Release();
@ -478,17 +488,23 @@ void LegoVideoManager::DrawFPS()
m_arialFont = NULL; m_arialFont = NULL;
return; return;
} }
SelectObject(dc, m_arialFont); SelectObject(dc, m_arialFont);
SetTextColor(dc, RGB(0xff, 0xff, 0x00)); SetTextColor(dc, RGB(255, 255, 0));
SetBkColor(dc, RGB(0x00, 0x00, 0x00)); SetBkColor(dc, RGB(0, 0, 0));
SetBkMode(dc, OPAQUE); SetBkMode(dc, OPAQUE);
GetTextExtentPoint32A(dc, buffer, nb, &m_fpsSize); GetTextExtentPoint32A(dc, buffer, nb, &m_fpsSize);
RECT rect; RECT rect;
SetRect(&rect, 0, 0, m_fpsSize.cx, m_fpsSize.cy); SetRect(&rect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
ExtTextOutA(dc, 0, 0, ETO_OPAQUE, &rect, buffer, nb, NULL); ExtTextOutA(dc, 0, 0, ETO_OPAQUE, &rect, buffer, nb, NULL);
m_unk0x528->ReleaseDC(dc); m_unk0x528->ReleaseDC(dc);
m_unk0x550 = 1.f; m_unk0x550 = 1.f;
} }
else {
m_unk0x550 += 1.f;
}
if (m_unk0x528 != NULL) { if (m_unk0x528 != NULL) {
m_displaySurface->GetDirectDrawSurface2() m_displaySurface->GetDirectDrawSurface2()
->BltFast(20, 20, m_unk0x528, &m_fpsRect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY); ->BltFast(20, 20, m_unk0x528, &m_fpsRect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
@ -632,7 +648,7 @@ void LegoVideoManager::SetSkyColor(float p_red, float p_green, float p_blue)
// FUNCTION: LEGO1 0x1007c4c0 // FUNCTION: LEGO1 0x1007c4c0
void LegoVideoManager::OverrideSkyColor(MxBool p_shouldOverride) void LegoVideoManager::OverrideSkyColor(MxBool p_shouldOverride)
{ {
this->m_videoParam.GetPalette()->SetOverrideSkyColor(p_shouldOverride); m_videoParam.GetPalette()->SetOverrideSkyColor(p_shouldOverride);
} }
// FUNCTION: LEGO1 0x1007c4d0 // FUNCTION: LEGO1 0x1007c4d0

View File

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

View File

@ -1094,30 +1094,37 @@ MxBool MxDisplaySurface::VTable0x2c(
} }
// FUNCTION: LEGO1 0x100bc8b0 // FUNCTION: LEGO1 0x100bc8b0
IDirectDrawSurface* MxDisplaySurface::FUN_100bc8b0(int width, int height) LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bc8b0(int width, int height)
{ {
MxVideoManager *video_manager = MVideoManager(); LPDIRECTDRAWSURFACE surface = NULL;
IDirectDraw *ddraw = video_manager->GetDirectDraw();
MVideoManager(); LPDIRECTDRAW ddraw = MVideoManager()->GetDirectDraw();
MxVideoParam& unused = MVideoManager()->GetVideoParam();
DDSURFACEDESC surfaceDesc; DDSURFACEDESC surfaceDesc;
memset(&surfaceDesc, 0, sizeof(surfaceDesc)); memset(&surfaceDesc, 0, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc); surfaceDesc.dwSize = sizeof(surfaceDesc);
if (ddraw->GetDisplayMode(&surfaceDesc) != DD_OK) { if (ddraw->GetDisplayMode(&surfaceDesc) != DD_OK) {
return NULL; return NULL;
} }
if (surfaceDesc.ddpfPixelFormat.dwRGBBitCount != 16) { if (surfaceDesc.ddpfPixelFormat.dwRGBBitCount != 16) {
return NULL; return NULL;
} }
surfaceDesc.dwWidth = width; surfaceDesc.dwWidth = width;
surfaceDesc.dwHeight = height; surfaceDesc.dwHeight = height;
surfaceDesc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; surfaceDesc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
surfaceDesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN; surfaceDesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN;
IDirectDrawSurface *surface = NULL;
if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) { if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) {
surfaceDesc.ddsCaps.dwCaps = (surfaceDesc.ddsCaps.dwCaps & ~DDSCAPS_VIDEOMEMORY) | DDSCAPS_SYSTEMMEMORY; surfaceDesc.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
surfaceDesc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) { if (ddraw->CreateSurface(&surfaceDesc, &surface, NULL) != DD_OK) {
return NULL; return NULL;
} }
} }
return surface; return surface;
} }