mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-14 00:17:38 +00:00
🩹 fix: apply all requests
This commit is contained in:
parent
d2cef9829b
commit
e1adfd264e
@ -1,6 +0,0 @@
|
|||||||
struct CursorBitmap {
|
|
||||||
const unsigned char* bitmap;
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int channels;
|
|
||||||
};
|
|
||||||
@ -37,10 +37,6 @@
|
|||||||
#include "tgl/d3drm/impl.h"
|
#include "tgl/d3drm/impl.h"
|
||||||
#include "viewmanager/viewmanager.h"
|
#include "viewmanager/viewmanager.h"
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
|
||||||
#define STBI_ONLY_BMP
|
|
||||||
#include "stb_image.h"
|
|
||||||
|
|
||||||
#include <miniwin/miniwindevice.h>
|
#include <miniwin/miniwindevice.h>
|
||||||
|
|
||||||
#define SDL_MAIN_USE_CALLBACKS
|
#define SDL_MAIN_USE_CALLBACKS
|
||||||
@ -669,33 +665,44 @@ MxResult IsleApp::SetupWindow()
|
|||||||
SDL_SetCursor(m_cursorCurrent);
|
SDL_SetCursor(m_cursorCurrent);
|
||||||
if (g_isle->GetDrawCursor()) {
|
if (g_isle->GetDrawCursor()) {
|
||||||
SDL_HideCursor();
|
SDL_HideCursor();
|
||||||
m_cursorCurrentBitmap = m_cursorArrowBitmap = new CursorBitmap();
|
SDL_IOStream* arrow_stream = SDL_IOFromMem(arrow_bmp, arrow_bmp_len);
|
||||||
m_cursorArrowBitmap->bitmap = stbi_load_from_memory(
|
if (!arrow_stream) {
|
||||||
arrow_bmp,
|
SDL_LogError(
|
||||||
arrow_bmp_len,
|
SDL_LOG_CATEGORY_APPLICATION,
|
||||||
&m_cursorArrowBitmap->x,
|
"Failed to open SDL_IOStream for arrow cursor: %s",
|
||||||
&m_cursorArrowBitmap->y,
|
SDL_GetError()
|
||||||
&m_cursorArrowBitmap->channels,
|
);
|
||||||
0
|
return FAILURE;
|
||||||
);
|
}
|
||||||
m_cursorBusyBitmap = new CursorBitmap();
|
SDL_IOStream* busy_stream = SDL_IOFromMem(busy_bmp, busy_bmp_len);
|
||||||
m_cursorBusyBitmap->bitmap = stbi_load_from_memory(
|
if (!busy_stream) {
|
||||||
busy_bmp,
|
SDL_LogError(
|
||||||
busy_bmp_len,
|
SDL_LOG_CATEGORY_APPLICATION,
|
||||||
&m_cursorBusyBitmap->x,
|
"Failed to open SDL_IOStream for busy cursor: %s",
|
||||||
&m_cursorBusyBitmap->y,
|
SDL_GetError()
|
||||||
&m_cursorBusyBitmap->channels,
|
);
|
||||||
0
|
return FAILURE;
|
||||||
);
|
}
|
||||||
m_cursorNoBitmap = new CursorBitmap();
|
SDL_IOStream* no_stream = SDL_IOFromMem(no_bmp, no_bmp_len);
|
||||||
m_cursorNoBitmap->bitmap = stbi_load_from_memory(
|
if (!no_stream) {
|
||||||
no_bmp,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to open SDL_IOStream for no cursor: %s", SDL_GetError());
|
||||||
no_bmp_len,
|
return FAILURE;
|
||||||
&m_cursorNoBitmap->x,
|
}
|
||||||
&m_cursorNoBitmap->y,
|
m_cursorCurrentBitmap = m_cursorArrowBitmap = SDL_LoadBMP_IO(arrow_stream, true);
|
||||||
&m_cursorNoBitmap->channels,
|
if (!m_cursorCurrentBitmap) {
|
||||||
0
|
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();
|
SDL_PropertiesID props = SDL_CreateProperties();
|
||||||
@ -781,12 +788,7 @@ MxResult IsleApp::SetupWindow()
|
|||||||
LegoOmni::GetInstance()->GetInputManager()->SetJoystickIndex(m_joystickIndex);
|
LegoOmni::GetInstance()->GetInputManager()->SetJoystickIndex(m_joystickIndex);
|
||||||
}
|
}
|
||||||
if (LegoOmni::GetInstance()->GetVideoManager() && g_isle->GetDrawCursor()) {
|
if (LegoOmni::GetInstance()->GetVideoManager() && g_isle->GetDrawCursor()) {
|
||||||
LegoOmni::GetInstance()->GetVideoManager()->SetCursorBitmap(
|
LegoOmni::GetInstance()->GetVideoManager()->SetCursorBitmap(m_cursorCurrentBitmap);
|
||||||
m_cursorCurrentBitmap->bitmap,
|
|
||||||
m_cursorCurrentBitmap->x,
|
|
||||||
m_cursorCurrentBitmap->y,
|
|
||||||
m_cursorCurrentBitmap->channels
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
MxDirect3D* d3d = LegoOmni::GetInstance()->GetVideoManager()->GetDirect3D();
|
MxDirect3D* d3d = LegoOmni::GetInstance()->GetVideoManager()->GetDirect3D();
|
||||||
if (d3d) {
|
if (d3d) {
|
||||||
@ -1098,15 +1100,10 @@ void IsleApp::SetupCursor(Cursor p_cursor)
|
|||||||
|
|
||||||
if (g_isle->GetDrawCursor()) {
|
if (g_isle->GetDrawCursor()) {
|
||||||
if (m_cursorCurrentBitmap == NULL) {
|
if (m_cursorCurrentBitmap == NULL) {
|
||||||
VideoManager()->SetCursorBitmap(0, 0, 0, 0);
|
VideoManager()->SetCursorBitmap(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VideoManager()->SetCursorBitmap(
|
VideoManager()->SetCursorBitmap(m_cursorCurrentBitmap);
|
||||||
m_cursorCurrentBitmap->bitmap,
|
|
||||||
m_cursorCurrentBitmap->x,
|
|
||||||
m_cursorCurrentBitmap->y,
|
|
||||||
m_cursorCurrentBitmap->channels
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#ifndef ISLEAPP_H
|
#ifndef ISLEAPP_H
|
||||||
#define ISLEAPP_H
|
#define ISLEAPP_H
|
||||||
|
|
||||||
#include "cursor.h"
|
|
||||||
#include "lego1_export.h"
|
#include "lego1_export.h"
|
||||||
#include "legoutils.h"
|
#include "legoutils.h"
|
||||||
#include "mxtransitionmanager.h"
|
#include "mxtransitionmanager.h"
|
||||||
@ -88,10 +87,10 @@ class IsleApp {
|
|||||||
SDL_Cursor* m_cursorBusy; // 0x80
|
SDL_Cursor* m_cursorBusy; // 0x80
|
||||||
SDL_Cursor* m_cursorNo; // 0x84
|
SDL_Cursor* m_cursorNo; // 0x84
|
||||||
SDL_Cursor* m_cursorCurrent; // 0x88
|
SDL_Cursor* m_cursorCurrent; // 0x88
|
||||||
CursorBitmap* m_cursorArrowBitmap;
|
SDL_Surface* m_cursorArrowBitmap;
|
||||||
CursorBitmap* m_cursorBusyBitmap;
|
SDL_Surface* m_cursorBusyBitmap;
|
||||||
CursorBitmap* m_cursorNoBitmap;
|
SDL_Surface* m_cursorNoBitmap;
|
||||||
CursorBitmap* m_cursorCurrentBitmap;
|
SDL_Surface* m_cursorCurrentBitmap;
|
||||||
char* m_mediaPath;
|
char* m_mediaPath;
|
||||||
|
|
||||||
char* m_iniPath;
|
char* m_iniPath;
|
||||||
|
|||||||
7989
ISLE/stb_image.h
7989
ISLE/stb_image.h
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,8 @@
|
|||||||
#include "legophonemelist.h"
|
#include "legophonemelist.h"
|
||||||
#include "mxvideomanager.h"
|
#include "mxvideomanager.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#ifdef MINIWIN
|
#ifdef MINIWIN
|
||||||
#include "miniwin/d3drm.h"
|
#include "miniwin/d3drm.h"
|
||||||
#include "miniwin/ddraw.h"
|
#include "miniwin/ddraw.h"
|
||||||
@ -37,7 +39,7 @@ class LegoVideoManager : public MxVideoManager {
|
|||||||
void EnableFullScreenMovie(MxBool p_enable);
|
void EnableFullScreenMovie(MxBool p_enable);
|
||||||
LEGO1_EXPORT void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale);
|
LEGO1_EXPORT void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale);
|
||||||
LEGO1_EXPORT void MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY);
|
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);
|
void ToggleFPS(MxBool p_visible);
|
||||||
|
|
||||||
MxResult Tickle() override; // vtable+0x08
|
MxResult Tickle() override; // vtable+0x08
|
||||||
|
|||||||
@ -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
|
// FUNCTION: LEGO1 0x1007b6f0
|
||||||
void LegoVideoManager::ToggleFPS(MxBool p_visible)
|
void LegoVideoManager::ToggleFPS(MxBool p_visible)
|
||||||
{
|
{
|
||||||
@ -862,3 +835,30 @@ void LegoVideoManager::DrawTextToSurface32(
|
|||||||
++p_text;
|
++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;
|
||||||
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
#include "mxcore.h"
|
#include "mxcore.h"
|
||||||
#include "mxvideoparam.h"
|
#include "mxvideoparam.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#ifdef MINIWIN
|
#ifdef MINIWIN
|
||||||
#include "miniwin/ddraw.h"
|
#include "miniwin/ddraw.h"
|
||||||
#else
|
#else
|
||||||
@ -97,7 +99,7 @@ class MxDisplaySurface : public MxCore {
|
|||||||
|
|
||||||
void ClearScreen();
|
void ClearScreen();
|
||||||
static LPDIRECTDRAWSURFACE CreateCursorSurface();
|
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);
|
static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src);
|
||||||
|
|
||||||
LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; }
|
LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; }
|
||||||
|
|||||||
@ -1098,67 +1098,6 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
|
|||||||
return NULL;
|
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
|
// FUNCTION: LEGO1 0x100bc200
|
||||||
void MxDisplaySurface::VTable0x24(
|
void MxDisplaySurface::VTable0x24(
|
||||||
LPDDSURFACEDESC p_desc,
|
LPDDSURFACEDESC p_desc,
|
||||||
@ -1360,3 +1299,59 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bc8b0(MxS32 p_width, MxS32 p_height
|
|||||||
|
|
||||||
return surface;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user