diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 9fb0f306e..02893a8e2 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -4409,9 +4409,9 @@ xbox::void_xt __fastcall xbox::EMUPATCH(D3DDevice_SetVertexShaderConstant4) // ****************************************************************** xbox::void_xt __fastcall xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline) ( - int_xt Register, + int_xt Register, CONST PVOID pConstantData, - dword_xt ConstantCount + dword_xt ConstantCount ) { LOG_FORWARD("D3DDevice_SetVertexShaderConstant"); @@ -4422,6 +4422,42 @@ xbox::void_xt __fastcall xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInli EMUPATCH(D3DDevice_SetVertexShaderConstant)(Register - X_D3DSCM_CORRECTION, pConstantData, ConstantCount / 4); } +// ****************************************************************** +// * patch: D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3 +// ****************************************************************** +// Overload for logging +static void D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3() +{ + LOG_FORWARD("D3DDevice_SetVertexShaderConstant"); +} + +// This uses a custom calling convention where parameter is passed in EBX, EDX, EAX +__declspec(naked) xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3)() +{ + int_xt Register; + PVOID pConstantData; + dword_xt ConstantCount; + __asm { + LTCG_PROLOGUE + mov Register, ebx + mov pConstantData, edx + mov ConstantCount, eax + } + + // Log + D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3(); + + // The XDK uses a macro to automatically adjust to 0..191 range + // but D3DDevice_SetVertexShaderConstant expects -96..95 range + // so we adjust before forwarding + EMUPATCH(D3DDevice_SetVertexShaderConstant)(Register - X_D3DSCM_CORRECTION, pConstantData, ConstantCount / 4); + + __asm { + LTCG_EPILOGUE + ret + } +} + // ****************************************************************** // * patch: D3DDevice_SetVertexShaderConstantNotInlineFast // ****************************************************************** diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.h b/src/core/hle/D3D8/Direct3D9/Direct3D9.h index 7502e94f1..860bdb982 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.h +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.h @@ -483,6 +483,11 @@ xbox::void_xt __fastcall EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline) dword_xt ConstantCount ); +// ****************************************************************** +// * patch: D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3 +// ****************************************************************** +xbox::void_xt WINAPI EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3)(); + // ****************************************************************** // * patch: D3DDevice_SetVertexShaderConstantNotInlineFast // ****************************************************************** diff --git a/src/core/hle/Patches.cpp b/src/core/hle/Patches.cpp index 0d1be2802..bfc30563c 100644 --- a/src/core/hle/Patches.cpp +++ b/src/core/hle/Patches.cpp @@ -188,6 +188,7 @@ std::map g_PatchTable = { PATCH_ENTRY("D3DDevice_SetVertexShaderConstant1Fast", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstant1Fast), PATCH_HLE_D3D), PATCH_ENTRY("D3DDevice_SetVertexShaderConstant4", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstant4), PATCH_HLE_D3D), PATCH_ENTRY("D3DDevice_SetVertexShaderConstantNotInline", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline), PATCH_HLE_D3D), + PATCH_ENTRY("D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInline_0__LTCG_ebx1_edx2_eax3), PATCH_HLE_D3D), PATCH_ENTRY("D3DDevice_SetVertexShaderConstantNotInlineFast", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInlineFast), PATCH_HLE_D3D), PATCH_ENTRY("D3DDevice_SetVertexShaderConstant_8__LTCG_edx3", xbox::EMUPATCH(D3DDevice_SetVertexShaderConstant_8__LTCG_edx3), PATCH_HLE_D3D), PATCH_ENTRY("D3DDevice_SetVertexShaderInput", xbox::EMUPATCH(D3DDevice_SetVertexShaderInput), PATCH_HLE_D3D),