🩹 fix: apply all requests

This commit is contained in:
Helloyunho 2025-07-03 02:02:18 +09:00
parent d2cef9829b
commit e1adfd264e
No known key found for this signature in database
GPG Key ID: 6AFA210B0150BE47
8 changed files with 134 additions and 8134 deletions

View File

@ -1,6 +0,0 @@
struct CursorBitmap {
const unsigned char* bitmap;
int x;
int y;
int channels;
};

View File

@ -37,10 +37,6 @@
#include "tgl/d3drm/impl.h"
#include "viewmanager/viewmanager.h"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_BMP
#include "stb_image.h"
#include <miniwin/miniwindevice.h>
#define SDL_MAIN_USE_CALLBACKS
@ -669,33 +665,44 @@ MxResult IsleApp::SetupWindow()
SDL_SetCursor(m_cursorCurrent);
if (g_isle->GetDrawCursor()) {
SDL_HideCursor();
m_cursorCurrentBitmap = m_cursorArrowBitmap = new CursorBitmap();
m_cursorArrowBitmap->bitmap = stbi_load_from_memory(
arrow_bmp,
arrow_bmp_len,
&m_cursorArrowBitmap->x,
&m_cursorArrowBitmap->y,
&m_cursorArrowBitmap->channels,
0
);
m_cursorBusyBitmap = new CursorBitmap();
m_cursorBusyBitmap->bitmap = stbi_load_from_memory(
busy_bmp,
busy_bmp_len,
&m_cursorBusyBitmap->x,
&m_cursorBusyBitmap->y,
&m_cursorBusyBitmap->channels,
0
);
m_cursorNoBitmap = new CursorBitmap();
m_cursorNoBitmap->bitmap = stbi_load_from_memory(
no_bmp,
no_bmp_len,
&m_cursorNoBitmap->x,
&m_cursorNoBitmap->y,
&m_cursorNoBitmap->channels,
0
);
SDL_IOStream* arrow_stream = SDL_IOFromMem(arrow_bmp, arrow_bmp_len);
if (!arrow_stream) {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"Failed to open SDL_IOStream for arrow cursor: %s",
SDL_GetError()
);
return FAILURE;
}
SDL_IOStream* busy_stream = SDL_IOFromMem(busy_bmp, busy_bmp_len);
if (!busy_stream) {
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"Failed to open SDL_IOStream for busy cursor: %s",
SDL_GetError()
);
return FAILURE;
}
SDL_IOStream* no_stream = SDL_IOFromMem(no_bmp, no_bmp_len);
if (!no_stream) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to open SDL_IOStream for no cursor: %s", SDL_GetError());
return FAILURE;
}
m_cursorCurrentBitmap = m_cursorArrowBitmap = SDL_LoadBMP_IO(arrow_stream, true);
if (!m_cursorCurrentBitmap) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load arrow cursor bitmap: %s", SDL_GetError());
return FAILURE;
}
m_cursorBusyBitmap = SDL_LoadBMP_IO(busy_stream, true);
if (!m_cursorBusyBitmap) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load busy cursor bitmap: %s", SDL_GetError());
return FAILURE;
}
m_cursorNoBitmap = SDL_LoadBMP_IO(no_stream, true);
if (!m_cursorNoBitmap) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load no cursor bitmap: %s", SDL_GetError());
return FAILURE;
}
}
SDL_PropertiesID props = SDL_CreateProperties();
@ -781,12 +788,7 @@ MxResult IsleApp::SetupWindow()
LegoOmni::GetInstance()->GetInputManager()->SetJoystickIndex(m_joystickIndex);
}
if (LegoOmni::GetInstance()->GetVideoManager() && g_isle->GetDrawCursor()) {
LegoOmni::GetInstance()->GetVideoManager()->SetCursorBitmap(
m_cursorCurrentBitmap->bitmap,
m_cursorCurrentBitmap->x,
m_cursorCurrentBitmap->y,
m_cursorCurrentBitmap->channels
);
LegoOmni::GetInstance()->GetVideoManager()->SetCursorBitmap(m_cursorCurrentBitmap);
}
MxDirect3D* d3d = LegoOmni::GetInstance()->GetVideoManager()->GetDirect3D();
if (d3d) {
@ -1098,15 +1100,10 @@ void IsleApp::SetupCursor(Cursor p_cursor)
if (g_isle->GetDrawCursor()) {
if (m_cursorCurrentBitmap == NULL) {
VideoManager()->SetCursorBitmap(0, 0, 0, 0);
VideoManager()->SetCursorBitmap(0);
}
else {
VideoManager()->SetCursorBitmap(
m_cursorCurrentBitmap->bitmap,
m_cursorCurrentBitmap->x,
m_cursorCurrentBitmap->y,
m_cursorCurrentBitmap->channels
);
VideoManager()->SetCursorBitmap(m_cursorCurrentBitmap);
}
}
else {

View File

@ -1,7 +1,6 @@
#ifndef ISLEAPP_H
#define ISLEAPP_H
#include "cursor.h"
#include "lego1_export.h"
#include "legoutils.h"
#include "mxtransitionmanager.h"
@ -88,10 +87,10 @@ class IsleApp {
SDL_Cursor* m_cursorBusy; // 0x80
SDL_Cursor* m_cursorNo; // 0x84
SDL_Cursor* m_cursorCurrent; // 0x88
CursorBitmap* m_cursorArrowBitmap;
CursorBitmap* m_cursorBusyBitmap;
CursorBitmap* m_cursorNoBitmap;
CursorBitmap* m_cursorCurrentBitmap;
SDL_Surface* m_cursorArrowBitmap;
SDL_Surface* m_cursorBusyBitmap;
SDL_Surface* m_cursorNoBitmap;
SDL_Surface* m_cursorCurrentBitmap;
char* m_mediaPath;
char* m_iniPath;

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,8 @@
#include "legophonemelist.h"
#include "mxvideomanager.h"
#include <SDL3/SDL.h>
#ifdef MINIWIN
#include "miniwin/d3drm.h"
#include "miniwin/ddraw.h"
@ -37,7 +39,7 @@ class LegoVideoManager : public MxVideoManager {
void EnableFullScreenMovie(MxBool p_enable);
LEGO1_EXPORT void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale);
LEGO1_EXPORT void MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY);
LEGO1_EXPORT void SetCursorBitmap(const MxU8* p_cursorBitmap, MxS32 p_x, MxS32 p_y, MxS32 p_channels);
LEGO1_EXPORT void SetCursorBitmap(const SDL_Surface* p_cursorBitmap);
void ToggleFPS(MxBool p_visible);
MxResult Tickle() override; // vtable+0x08

View File

@ -282,33 +282,6 @@ void LegoVideoManager::MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY)
}
}
void LegoVideoManager::SetCursorBitmap(const MxU8* p_cursorBitmap, MxS32 p_x, MxS32 p_y, MxS32 p_channels)
{
if (p_cursorBitmap == NULL) {
m_drawCursor = FALSE;
return;
}
if (m_cursorSurface != NULL) {
m_cursorSurface->Release();
m_cursorSurface = NULL;
}
m_cursorRect.top = 0;
m_cursorRect.left = 0;
m_cursorRect.bottom = p_x;
m_cursorRect.right = p_y;
m_cursorSurface = MxDisplaySurface::CreateCursorSurface(p_cursorBitmap, p_x, p_y, p_channels);
if (m_cursorSurface == NULL) {
m_drawCursor = FALSE;
return;
}
m_drawCursor = TRUE;
}
// FUNCTION: LEGO1 0x1007b6f0
void LegoVideoManager::ToggleFPS(MxBool p_visible)
{
@ -862,3 +835,30 @@ void LegoVideoManager::DrawTextToSurface32(
++p_text;
}
}
void LegoVideoManager::SetCursorBitmap(const SDL_Surface* p_cursorBitmap)
{
if (p_cursorBitmap == NULL) {
m_drawCursor = FALSE;
return;
}
if (m_cursorSurface != NULL) {
m_cursorSurface->Release();
m_cursorSurface = NULL;
}
m_cursorRect.top = 0;
m_cursorRect.left = 0;
m_cursorRect.bottom = p_cursorBitmap->h;
m_cursorRect.right = p_cursorBitmap->w;
m_cursorSurface = MxDisplaySurface::CreateCursorSurface(p_cursorBitmap);
if (m_cursorSurface == NULL) {
m_drawCursor = FALSE;
return;
}
m_drawCursor = TRUE;
}

View File

@ -5,6 +5,8 @@
#include "mxcore.h"
#include "mxvideoparam.h"
#include <SDL3/SDL.h>
#ifdef MINIWIN
#include "miniwin/ddraw.h"
#else
@ -97,7 +99,7 @@ class MxDisplaySurface : public MxCore {
void ClearScreen();
static LPDIRECTDRAWSURFACE CreateCursorSurface();
static LPDIRECTDRAWSURFACE CreateCursorSurface(const MxU8* p_cursorBitmap, MxS32 p_x, MxS32 p_y, MxS32 p_channels);
static LPDIRECTDRAWSURFACE CreateCursorSurface(const SDL_Surface* p_cursorBitmap);
static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src);
LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; }

View File

@ -1098,67 +1098,6 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
return NULL;
}
LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(
const MxU8* p_cursorBitmap,
MxS32 p_x,
MxS32 p_y,
MxS32 p_channels
)
{
if (p_channels != 4) {
MxTrace("MxDisplaySurface::CreateCursorSurface: unsupported channel count %d", p_channels);
return NULL;
}
LPDIRECTDRAWSURFACE newSurface = NULL;
IDirectDraw* draw = MVideoManager()->GetDirectDraw();
MVideoManager();
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (draw->GetDisplayMode(&ddsd) != DD_OK) {
return NULL;
}
ddsd.dwWidth = p_x;
ddsd.dwHeight = p_y;
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN;
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
goto done;
}
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (newSurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL) != DD_OK) {
goto done;
}
else {
MxU32* surface = (MxU32*) ddsd.lpSurface;
memcpy(surface, p_cursorBitmap, p_x * p_y * sizeof(MxU32));
newSurface->Unlock(ddsd.lpSurface);
return newSurface;
}
done:
if (newSurface) {
newSurface->Release();
}
return NULL;
}
// FUNCTION: LEGO1 0x100bc200
void MxDisplaySurface::VTable0x24(
LPDDSURFACEDESC p_desc,
@ -1360,3 +1299,59 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bc8b0(MxS32 p_width, MxS32 p_height
return surface;
}
LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const SDL_Surface* p_cursorBitmap)
{
if (p_cursorBitmap->format != SDL_PIXELFORMAT_ARGB8888) {
MxTrace("MxDisplaySurface::CreateCursorSurface: unsupported channel count %d", p_channels);
return NULL;
}
LPDIRECTDRAWSURFACE newSurface = NULL;
IDirectDraw* draw = MVideoManager()->GetDirectDraw();
MVideoManager();
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (draw->GetDisplayMode(&ddsd) != DD_OK) {
return NULL;
}
ddsd.dwWidth = p_cursorBitmap->w;
ddsd.dwHeight = p_cursorBitmap->h;
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN;
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
goto done;
}
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (newSurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL) != DD_OK) {
goto done;
}
else {
MxU32* surface = (MxU32*) ddsd.lpSurface;
memcpy(surface, p_cursorBitmap->pixels, p_cursorBitmap->w * p_cursorBitmap->h * sizeof(MxU32));
newSurface->Unlock(ddsd.lpSurface);
return newSurface;
}
done:
if (newSurface) {
newSurface->Release();
}
return NULL;
}