Compare commits

...

2 Commits

Author SHA1 Message Date
superp00t
8adf3a0061 feat(d3d): clean up hardware cursor stuff 2025-04-01 12:43:55 -04:00
superp00t
f4e9f86ca6 refactor(client): wow launch flags should have the CMDOPT type 2025-04-01 11:08:45 -04:00
4 changed files with 77 additions and 70 deletions

View File

@ -1,5 +1,4 @@
#include "client/CmdLine.hpp" #include "client/CmdLine.hpp"
#include <storm/Command.hpp> #include <storm/Command.hpp>
int32_t CmdLineProcess() { int32_t CmdLineProcess() {
@ -32,23 +31,23 @@ int32_t CmdLineProcess() {
void ProcessCommandLine() { void ProcessCommandLine() {
static ARGLIST s_wowArgList[] = { static ARGLIST s_wowArgList[] = {
{ 0x0, WOWCMD_RES_800x600, "800x600", nullptr }, { 0x0, CMD_RES_800x600, "800x600", nullptr },
{ 0x0, WOWCMD_RES_1024x768, "1024x768", nullptr }, { 0x0, CMD_RES_1024x768, "1024x768", nullptr },
{ 0x0, WOWCMD_RES_1280x960, "1280x960", nullptr }, { 0x0, CMD_RES_1280x960, "1280x960", nullptr },
{ 0x0, WOWCMD_RES_1280x1024, "1280x1024", nullptr }, { 0x0, CMD_RES_1280x1024, "1280x1024", nullptr },
{ 0x0, WOWCMD_RES_1600x1200, "1600x1200", nullptr }, { 0x0, CMD_RES_1600x1200, "1600x1200", nullptr },
{ 0x0, WOWCMD_16_BIT, "16bit", nullptr }, { 0x0, CMD_16_BIT, "16bit", nullptr },
{ 0x0, WOWCMD_UP_TO_DATE, "uptodate", nullptr }, { 0x0, CMD_UP_TO_DATE, "uptodate", nullptr },
{ 0x0, WOWCMD_NO_SOUND, "nosound", nullptr }, { 0x0, CMD_NO_SOUND, "nosound", nullptr },
{ 0x0, WOWCMD_SOUND_CHAOS, "soundchaos", nullptr }, { 0x0, CMD_SOUND_CHAOS, "soundchaos", nullptr },
{ 0x0, WOWCMD_NO_FIX_LAG, "nofixlag", nullptr }, { 0x0, CMD_NO_FIX_LAG, "nofixlag", nullptr },
{ 0x0, WOWCMD_DEPTH_16, "d16", nullptr }, { 0x0, CMD_DEPTH_16, "d16", nullptr },
{ 0x0, WOWCMD_DEPTH_24, "d24", nullptr }, { 0x0, CMD_DEPTH_24, "d24", nullptr },
{ 0x0, WOWCMD_DEPTH_32, "d32", nullptr }, { 0x0, CMD_DEPTH_32, "d32", nullptr },
{ 0x0, WOWCMD_WINDOWED, "windowed", nullptr }, { 0x0, CMD_WINDOWED, "windowed", nullptr },
{ 0x0, WOWCMD_HW_DETECT, "hwdetect", nullptr }, { 0x0, CMD_HW_DETECT, "hwdetect", nullptr },
{ 0x0, WOWCMD_CONSOLE, "console", nullptr }, { 0x0, CMD_CONSOLE, "console", nullptr },
{ STORM_COMMAND_TYPE_STRING, WOWCMD_GX_OVERRIDE, "gxoverride", nullptr } { STORM_COMMAND_TYPE_STRING, CMD_GX_OVERRIDE, "gxoverride", nullptr }
}; };
// Load wow-specific launch flags // Load wow-specific launch flags
@ -57,7 +56,7 @@ void ProcessCommandLine() {
CmdLineProcess(); CmdLineProcess();
} }
const char* CmdLineGetString(uint32_t opt) { const char* CmdLineGetString(CMDOPT opt) {
static char buffer[260] = {0}; static char buffer[260] = {0};
SCmdGetString(opt, buffer, 260); SCmdGetString(opt, buffer, 260);
@ -65,10 +64,10 @@ const char* CmdLineGetString(uint32_t opt) {
return buffer; return buffer;
} }
uint32_t CmdLineGetUint(uint32_t opt) { uint32_t CmdLineGetUint(CMDOPT opt) {
return SCmdGetNum(opt); return SCmdGetNum(opt);
} }
int32_t CmdLineGetBool(uint32_t opt) { int32_t CmdLineGetBool(CMDOPT opt) {
return SCmdGetBool(opt); return SCmdGetBool(opt);
} }

View File

@ -23,35 +23,32 @@ enum CMDOPT {
CMDOPTS CMDOPTS
}; };
enum WOWCMDOPT { #define CMD_RES_800x600 static_cast<CMDOPT>(16)
WOWCMD_RES_800x600 = 16, #define CMD_RES_1024x768 static_cast<CMDOPT>(17)
WOWCMD_RES_1024x768 = 17, #define CMD_RES_1280x960 static_cast<CMDOPT>(18)
WOWCMD_RES_1280x960 = 18, #define CMD_RES_1280x1024 static_cast<CMDOPT>(19)
WOWCMD_RES_1280x1024 = 19, #define CMD_RES_1600x1200 static_cast<CMDOPT>(20)
WOWCMD_RES_1600x1200 = 20, #define CMD_UP_TO_DATE static_cast<CMDOPT>(21)
WOWCMD_UP_TO_DATE = 21, #define CMD_16_BIT static_cast<CMDOPT>(22)
WOWCMD_16_BIT = 22, #define CMD_NO_FIX_LAG static_cast<CMDOPT>(24)
WOWCMD_NO_FIX_LAG = 24, #define CMD_NO_SOUND static_cast<CMDOPT>(26)
WOWCMD_NO_SOUND = 26, #define CMD_SOUND_CHAOS static_cast<CMDOPT>(27)
WOWCMD_SOUND_CHAOS = 27, #define CMD_DEPTH_16 static_cast<CMDOPT>(29)
WOWCMD_DEPTH_16 = 29, #define CMD_DEPTH_24 static_cast<CMDOPT>(30)
WOWCMD_DEPTH_24 = 30, #define CMD_DEPTH_32 static_cast<CMDOPT>(31)
WOWCMD_DEPTH_32 = 31, #define CMD_WINDOWED static_cast<CMDOPT>(32)
WOWCMD_WINDOWED = 32, #define CMD_CONSOLE static_cast<CMDOPT>(35)
WOWCMD_CONSOLE = 35, #define CMD_HW_DETECT static_cast<CMDOPT>(36)
WOWCMD_HW_DETECT = 36, #define CMD_GX_OVERRIDE static_cast<CMDOPT>(39)
WOWCMD_GX_OVERRIDE = 39,
WOWCMD_OPTS
};
int32_t CmdLineProcess(); int32_t CmdLineProcess();
void ProcessCommandLine(); void ProcessCommandLine();
const char* CmdLineGetString(uint32_t opt); const char* CmdLineGetString(CMDOPT opt);
uint32_t CmdLineGetUint(uint32_t opt); uint32_t CmdLineGetUint(CMDOPT opt);
int32_t CmdLineGetBool(uint32_t opt); int32_t CmdLineGetBool(CMDOPT opt);
#endif #endif

View File

@ -336,7 +336,7 @@ LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (device) { if (device) {
if (device->m_d3dDevice && LOWORD(lParam) == HTCLIENT) { if (device->m_d3dDevice && LOWORD(lParam) == HTCLIENT) {
SetCursor(nullptr); SetCursor(nullptr);
BOOL show = device->m_cursorVisible && device->m_hardwareCursor ? TRUE : FALSE; BOOL show = device->m_cursorVisible && device->m_hwCursor ? TRUE : FALSE;
device->m_d3dDevice->ShowCursor(show); device->m_d3dDevice->ShowCursor(show);
return 1; return 1;
} }
@ -487,15 +487,7 @@ int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
CGxFormat createFormat = format; CGxFormat createFormat = format;
if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) { if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) {
this->intF64 = 1; this->ICursorClip(1);
this->m_hwCursorNeedsUpdate = 1;
if (this->m_format.window == 0) {
RECT windowRect;
GetWindowRect(this->m_hwnd, &windowRect);
ClipCursor(&windowRect);
}
return 1; return 1;
} else { } else {
CGxDevice::Log("CGxDeviceD3d::DeviceSetFormat(): unable to set format!"); CGxDevice::Log("CGxDeviceD3d::DeviceSetFormat(): unable to set format!");
@ -1015,6 +1007,20 @@ bool CGxDeviceD3d::ICreateWindow(CGxFormat& format) {
return this->m_hwnd != nullptr; return this->m_hwnd != nullptr;
} }
void CGxDeviceD3d::ICursorClip(int32_t a1) {
this->intF64 = a1;
if (a1) {
this->m_hwCursorNeedsUpdate = 1;
if (this->m_format.window) {
RECT windowRect;
GetWindowRect(this->m_hwnd, &windowRect);
ClipCursor(&windowRect);
}
}
}
void CGxDeviceD3d::IDestroyD3d() { void CGxDeviceD3d::IDestroyD3d() {
this->IDestroyD3dDevice(); this->IDestroyD3dDevice();
CGxDeviceD3d::IUnloadD3dLib(this->m_d3dLib, this->m_d3d); CGxDeviceD3d::IUnloadD3dLib(this->m_d3dLib, this->m_d3d);
@ -1220,7 +1226,7 @@ void CGxDeviceD3d::IRsSendToHw(EGxRenderState which) {
void CGxDeviceD3d::ICursorCreate(const CGxFormat& format) { void CGxDeviceD3d::ICursorCreate(const CGxFormat& format) {
CGxDevice::ICursorCreate(format); CGxDevice::ICursorCreate(format);
if (this->m_hardwareCursor && this->m_hwCursorTexture == nullptr) { if (this->m_hwCursor && this->m_hwCursorTexture == nullptr) {
this->m_d3dDevice->CreateTexture( this->m_d3dDevice->CreateTexture(
32, 32,
32, 32,
@ -1257,7 +1263,7 @@ void CGxDeviceD3d::ICursorDestroy() {
void CGxDeviceD3d::CursorSetVisible(int32_t visible) { void CGxDeviceD3d::CursorSetVisible(int32_t visible) {
CGxDevice::CursorSetVisible(visible); CGxDevice::CursorSetVisible(visible);
if (this->m_hardwareCursor && this->m_context) { if (this->m_hwCursor && this->m_context) {
POINT point; POINT point;
RECT rect; RECT rect;
GetCursorPos(&point); GetCursorPos(&point);
@ -1276,15 +1282,15 @@ void CGxDeviceD3d::CursorUnlock(uint32_t x, uint32_t y) {
} }
void CGxDeviceD3d::ICursorDraw() { void CGxDeviceD3d::ICursorDraw() {
if (!this->m_hardwareCursor) { if (!this->m_hwCursor) {
this->ISceneBegin(); this->ISceneBegin();
} }
CGxDevice::ICursorDraw(); CGxDevice::ICursorDraw();
if (!this->m_hardwareCursor) { if (!this->m_hwCursor) {
this->ISceneEnd(); this->ISceneEnd();
if (!this->m_hardwareCursor) { if (!this->m_hwCursor) {
return; return;
} }
} }
@ -1312,16 +1318,19 @@ void CGxDeviceD3d::ICursorDraw() {
void CGxDeviceD3d::ISceneBegin() { void CGxDeviceD3d::ISceneBegin() {
if (!this->m_context) { if (!this->m_context) {
auto result = this->m_d3dDevice->TestCooperativeLevel(); if (this->m_d3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
if (result == D3DERR_DEVICENOTRESET) {
this->IReleaseD3dResources(0);
D3DPRESENT_PARAMETERS d3dpp; D3DPRESENT_PARAMETERS d3dpp;
this->IReleaseD3dResources(0);
this->ISetPresentParms(d3dpp, this->m_format); this->ISetPresentParms(d3dpp, this->m_format);
result = this->m_d3dDevice->Reset(&d3dpp); if (this->m_d3dDevice->Reset(&d3dpp) == D3D_OK) {
if (result == D3D_OK) {
this->IStateSetD3dDefaults(); this->IStateSetD3dDefaults();
// TODO: CGxDeviceD3d::ICursorClip this->ICursorClip(1);
// TODO: this->NotifyOnDeviceRestored() this->m_context = 1;
// TODO
// this->intF5C = 0;
// this->unk3ACC = 1;
// this->NotifyOnDeviceRestored();
} }
} }
} }
@ -1427,7 +1436,7 @@ void CGxDeviceD3d::ISetCaps(const CGxFormat& format) {
// Detect hardware cursor // Detect hardware cursor
this->m_caps.m_hardwareCursor = this->m_d3dCaps.CursorCaps & D3DCURSORCAPS_COLOR; this->m_caps.m_hwCursor = this->m_d3dCaps.CursorCaps & D3DCURSORCAPS_COLOR;
// Texture formats // Texture formats
@ -2191,8 +2200,9 @@ void CGxDeviceD3d::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const
} }
int32_t CGxDeviceD3d::StereoEnabled() { int32_t CGxDeviceD3d::StereoEnabled() {
// TODO CGxDevice::CursorUnlock(x, y);
return 0; this->m_hwCursorNeedsUpdate = 1;
} }
void CGxDeviceD3d::XformSetProjection(const C44Matrix& matrix) { void CGxDeviceD3d::XformSetProjection(const C44Matrix& matrix) {

View File

@ -252,7 +252,6 @@ class CGxDeviceD3d : public CGxDevice {
virtual void ICursorDestroy(); virtual void ICursorDestroy();
virtual void ICursorDraw(); virtual void ICursorDraw();
virtual void CursorSetVisible(int32_t visible); virtual void CursorSetVisible(int32_t visible);
virtual void CursorUnlock(uint32_t x, uint32_t y);
virtual int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format); virtual int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat& format);
virtual int32_t DeviceSetFormat(const CGxFormat& format); virtual int32_t DeviceSetFormat(const CGxFormat& format);
virtual void* DeviceWindow(); virtual void* DeviceWindow();
@ -270,6 +269,7 @@ class CGxDeviceD3d : public CGxDevice {
virtual void IShaderCreate(CGxShader* shader); virtual void IShaderCreate(CGxShader* shader);
virtual void ShaderCreate(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations); virtual void ShaderCreate(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations);
virtual int32_t StereoEnabled(); virtual int32_t StereoEnabled();
virtual void CursorUnlock(uint32_t x, uint32_t y);
// Member functions // Member functions
CGxDeviceD3d(); CGxDeviceD3d();
@ -283,6 +283,7 @@ class CGxDeviceD3d : public CGxDevice {
LPDIRECT3DVERTEXBUFFER9 ICreateD3dVB(EGxPoolUsage usage, uint32_t size); LPDIRECT3DVERTEXBUFFER9 ICreateD3dVB(EGxPoolUsage usage, uint32_t size);
LPDIRECT3DVERTEXDECLARATION9 ICreateD3dVertexDecl(D3DVERTEXELEMENT9 elements[], uint32_t count); LPDIRECT3DVERTEXDECLARATION9 ICreateD3dVertexDecl(D3DVERTEXELEMENT9 elements[], uint32_t count);
bool ICreateWindow(CGxFormat& format); bool ICreateWindow(CGxFormat& format);
void ICursorClip(int32_t a1);
void ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format); void ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format);
void IDestroyD3d(); void IDestroyD3d();
void IDestroyD3dDevice(); void IDestroyD3dDevice();