From ab0680c19afe6185bb6c3e039bf20e3831b4321e Mon Sep 17 00:00:00 2001 From: jarupxx Date: Mon, 9 Apr 2018 19:40:13 +0900 Subject: [PATCH] Fix patch for LTCG optimized functions TODO: This function works only on debug build, should be fix on release build. --- src/CxbxKrnl/EmuD3D8.cpp | 40 +++++++++++++++++++++++----------------- src/CxbxKrnl/EmuD3D8.h | 12 +++--------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/CxbxKrnl/EmuD3D8.cpp b/src/CxbxKrnl/EmuD3D8.cpp index ecaff9fac..98dad4b81 100755 --- a/src/CxbxKrnl/EmuD3D8.cpp +++ b/src/CxbxKrnl/EmuD3D8.cpp @@ -4784,22 +4784,25 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVerticalBlankCallback) } // LTCG specific D3DDevice_SetTextureState_TexCoordIndex function... -// This uses a custom calling convention where parameter is passed in EAX, Value +// TODO: This function works only on debug build, should be fix on release build. // Test-case: Metal Wolf Chaos -VOID XTL::EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex_4) +VOID __stdcall XTL::EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex_4) ( - DWORD Stage ) { FUNC_EXPORTS; - DWORD Value; + static uint32 returnAddr; + __asm { - mov Value, eax; + add esp, 4 + pop returnAddr + push esi + call EmuPatch_D3DDevice_SetTextureState_TexCoordIndex + mov eax, 0 + push returnAddr + ret } - - return EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex)(Stage, Value); - } // ****************************************************************** @@ -4955,24 +4958,27 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetTextureState_ColorKeyColor) } // LTCG specific D3DDevice_SetTextureState_BumpEnv function... -// This uses a custom calling convention where parameter is passed in Stage, Type, EAX +// TODO: This function works only on debug build, should be fix on release build. // Test-case: Metal Wolf Chaos -VOID XTL::EMUPATCH(D3DDevice_SetTextureState_BumpEnv_8) +VOID __stdcall XTL::EMUPATCH(D3DDevice_SetTextureState_BumpEnv_8) ( - X_D3DTEXTURESTAGESTATETYPE Type, - DWORD Stage ) { FUNC_EXPORTS; - DWORD Value; + static uint32 returnAddr; + __asm { - mov Value, eax; + add esp, 4 + pop returnAddr + push eax + call EmuPatch_D3DDevice_SetTextureState_BumpEnv + mov eax, 0 + push returnAddr + ret } - - return EMUPATCH(D3DDevice_SetTextureState_BumpEnv)(Stage, Type, Value); - } + // ****************************************************************** // * patch: D3DDevice_SetTextureState_BumpEnv // ****************************************************************** diff --git a/src/CxbxKrnl/EmuD3D8.h b/src/CxbxKrnl/EmuD3D8.h index 040c183ea..bd0310340 100644 --- a/src/CxbxKrnl/EmuD3D8.h +++ b/src/CxbxKrnl/EmuD3D8.h @@ -935,10 +935,7 @@ VOID WINAPI EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex) DWORD Value ); -VOID EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex_4) -( - DWORD Stage -); +VOID __stdcall EMUPATCH(D3DDevice_SetTextureState_TexCoordIndex_4)(); // ****************************************************************** // * patch: D3DDevice_SetRenderState_TwoSidedLighting @@ -988,11 +985,8 @@ VOID WINAPI EMUPATCH(D3DDevice_SetTextureState_BumpEnv) DWORD Value ); -VOID EMUPATCH(D3DDevice_SetTextureState_BumpEnv_8) -( - X_D3DTEXTURESTAGESTATETYPE Type, - DWORD Stage -); +VOID __stdcall EMUPATCH(D3DDevice_SetTextureState_BumpEnv_8)(); + // ****************************************************************** // * patch: D3DDevice_SetRenderState_FrontFace // ******************************************************************