Next Generation Emulation banner

1 - 5 of 5 Posts

·
Registered
Joined
·
80 Posts
Discussion Starter #1
I'm looking to implement the hooks for SetRenderTarget_LineWidth on XDK 5849. With an IDA Pro dump of the function, I have implemented what I understand to be a unique set of OOVPAs in D3D8LTCG.1.0.5849.inl

With a basic implementation of the hooked function in CxbxKrnl\EmuD3D8.cpp, I am presently not seeing the Kernel Debug log indicate that the function was found and hooked.

Can anyone provide some pointers on the best way to debug this type of problem? Has it found the function, but not on a unique basis within the Xbe? Has it struggled to use the OOVPA at all? Have I picked poor operands within the function?

Code:
diff --git a/src/CxbxKrnl/HLEDataBase/D3D8LTCG.1.0.5849.inl b/src/CxbxKrnl/HLEDataBase/D3D8LTCG.1.0.5849.inl
index 893ca3d..ae54525 100644
--- a/src/CxbxKrnl/HLEDataBase/D3D8LTCG.1.0.5849.inl
+++ b/src/CxbxKrnl/HLEDataBase/D3D8LTCG.1.0.5849.inl
@@ -875,6 +875,43 @@ SOOVPA<13> IDirect3DDevice8_SetRenderState_ShadowFunc_1_0_5849_LTCG =
 };
 
 // ******************************************************************
+// * IDirect3DDevice8_SetRenderState_LineWidth
+// ******************************************************************
+SOOVPA<13> IDirect3DDevice8_SetRenderState_LineWidth_1_0_5849_LTCG =
+{
+    0,  // Large == 0
+    13, // Count == 13
+
+    -1, // XRef Not Saved
+    0,  // XRef Not Used
+
+    {
+        // IDirect3DDevice8_SetRenderState_LineWidth+0x00 : push ebx
+        { 0x00, 0x53 }, // (Offset,Value)-Pair #1
+
+        // IDirect3DDevice8_SetRenderState_LineWidth+0x0C : mov [esp+8+argo_0], ebx
+        { 0x0C, 0x89 }, // (Offset,Value)-Pair #2
+        { 0x0D, 0x5C }, // (Offset,Value)-Pair #3
+        { 0x0E, 0x24 }, // (Offset,Value)-Pair #4
+        { 0x0F, 0x0C }, // (Offset,Value)-Pair #5
+
+        // IDirect3DDevice8_SetRenderState_LineWidth+0x28 : fstp [esp+10h+var_10]
+        { 0x28, 0xD9 }, // (Offset,Value)-Pair #6
+        { 0x29, 0x1C }, // (Offset,Value)-Pair #7
+        { 0x2A, 0x24 }, // (Offset,Value)-Pair #8
+
+        // IDirect3DDevice8_SetRenderState_LineWidth+0x30 : mov edi, eax
+        { 0x30, 0x8B }, // (Offset,Value)-Pair #9
+        { 0x31, 0xF8 }, // (Offset,Value)-Pair #10
+
+        // IDirect3DDevice8_SetRenderState_LineWidth+0x41 : cmp eax, [esi+4]
+        { 0x41, 0x3B }, // (Offset,Value)-Pair #11
+        { 0x42, 0x46 }, // (Offset,Value)-Pair #12
+        { 0x43, 0x04 }, // (Offset,Value)-Pair #13
+    }
+};
+
+// ******************************************************************
 // * IDirect3DDevice8_SetRenderState_OcclusionCullEnable
 // ******************************************************************
 SOOVPA<12> IDirect3DDevice8_SetRenderState_OcclusionCullEnable_1_0_5849_LTCG =
@@ -1623,6 +1660,16 @@ OOVPATable D3D8LTCG_1_0_5849[] =
         "EmuIDirect3DDevice8_SetRenderState_ShadowFunc"
         #endif
     },
+    // IDirect3DDevice8::SetRenderState_LineWidth
+    {
+        (OOVPA*)&IDirect3DDevice8_SetRenderState_LineWidth_1_0_5849_LTCG,
+        
+        XTL::EmuIDirect3DDevice8_SetRenderState_LineWidth,
+            
+        #ifdef _DEBUG_TRACE
+        "EmuIDirect3DDevice8_SetRenderState_LineWidth"
+        #endif
+    },
     // IDirect3DDevice8::SetRenderState_OcclusionCullEnable
     {
         (OOVPA*)&IDirect3DDevice8_SetRenderState_OcclusionCullEnable_1_0_5849_LTCG,
Code:
D3D:003B7A20 sub_3B7A20      proc near               ; CODE XREF: sub_25800+1C2p
D3D:003B7A20                                         ; .text:0004B831p ...
D3D:003B7A20
D3D:003B7A20 var_10          = dword ptr -10h
D3D:003B7A20 arg_0           = dword ptr  4
D3D:003B7A20
D3D:003B7A20                 push    ebx			<==
D3D:003B7A21                 mov     ebx, [esp+4+arg_0]
D3D:003B7A25                 push    esi
D3D:003B7A26                 mov     esi, ds:dword_3C8A48
D3D:003B7A2C                 mov     [esp+8+arg_0], ebx		<==
D3D:003B7A30                 fld     [esp+8+arg_0]
D3D:003B7A34                 push    edi
D3D:003B7A35                 fmul    dword ptr [esi+964h]
D3D:003B7A3B                 push    ecx
D3D:003B7A3C                 fmul    ds:dword_495A68
D3D:003B7A42                 fadd    ds:dword_487264
D3D:003B7A48                 fstp    [esp+10h+var_10]		<==
D3D:003B7A4B                 call    sub_3C0290
D3D:003B7A50                 mov     edi, eax			<==
D3D:003B7A52                 cmp     edi, 1FFh
D3D:003B7A58                 jbe     short loc_3B7A5F
D3D:003B7A5A                 mov     edi, 1FFh
D3D:003B7A5F
D3D:003B7A5F loc_3B7A5F:                             ; CODE XREF: sub_3B7A20+38j
D3D:003B7A5F                 mov     eax, [esi]
D3D:003B7A61                 cmp     eax, [esi+4]		<==
D3D:003B7A64                 jb      short loc_3B7A6B
D3D:003B7A66                 call    sub_3BD800
D3D:003B7A6B
D3D:003B7A6B loc_3B7A6B:                             ; CODE XREF: sub_3B7A20+44j
D3D:003B7A6B                 mov     dword ptr [eax], offset dword_40380
D3D:003B7A71                 mov     [eax+4], edi
D3D:003B7A74                 add     eax, 8
D3D:003B7A77                 pop     edi
D3D:003B7A78                 mov     [esi], eax
D3D:003B7A7A                 pop     esi
D3D:003B7A7B                 mov     ds:dword_3C8A24, ebx
D3D:003B7A81                 pop     ebx
D3D:003B7A82                 retn    4
D3D:003B7A82 sub_3B7A20      endp
 

·
Premium Member
Joined
·
423 Posts
With LTCG, don't rely on code using some given register (usage of eax, ebx and ecx may interchange unpredictably). This is especially true for the first few opcodes.

Opcodes using the stackpointer might use different offsets, so avoid those. Also, avoid searches on relative jumps/calls, since with LTCG you can't tell how far away those targets will be in the final executable.

Try to search for opcodes that use segment registers, and/or constants. Inline conditional jumps may also be reliable, as are floating-point instructions.

Just referencing constants (and not the opcodes itself) could help too.

Good luck.
 

·
Registered
Joined
·
80 Posts
Discussion Starter #4

·
Registered
Joined
·
18 Posts
1 - 5 of 5 Posts
Top