From 6c94e96ca44e201c8ee4a6ad1e063b5ab7440a9e Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Sat, 24 May 2003 06:06:35 +0000 Subject: [PATCH] hi --- Doc/Todo.txt | 6 +--- Include/Cxbx.h | 2 +- Include/Win32/CxbxKrnl/xd3d8.h | 4 +-- Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl | 1 - Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl | 43 +++++++++++++++++++++++++ Source/Win32/CxbxKrnl/Emu.cpp | 27 ++++++++-------- Source/Win32/CxbxKrnl/EmuD3D8.cpp | 6 ++-- Source/Win32/CxbxKrnl/EmuFS.cpp | 2 +- Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl | 10 ++++++ 9 files changed, 74 insertions(+), 27 deletions(-) diff --git a/Doc/Todo.txt b/Doc/Todo.txt index 6ccfbaf29..3c44f1d48 100644 --- a/Doc/Todo.txt +++ b/Doc/Todo.txt @@ -1,10 +1,8 @@ Cxbx Todo (* denotes high priority) - * D3D8.lib D3DDevice_SetRenderState_ZEnable@4 for 4627 - * XAPILIB XapiThreadStartup for 4627 - * Stabilize Heap Allocation (i.e. new) -> Crashes after initial commit is full + * Stabilize Heap Allocation (i.e. operator new) -> Crashes after initial commit is full * Stabilize TLS (it's close...) @@ -12,8 +10,6 @@ Cxbx Todo (* denotes high priority) * Retail Games (esp. XDK 4361) - * SetRenderState Simple for 4627 (Draw[Indexed]Vertices states are +10 up to 116, then some new ones?) - * What does SetLastError check Irql for? Should this be emulated? Perfect the timing on KeTickCount diff --git a/Include/Cxbx.h b/Include/Cxbx.h index dcd847182..12dc4d1c8 100644 --- a/Include/Cxbx.h +++ b/Include/Cxbx.h @@ -61,7 +61,7 @@ typedef signed long sint32; // ****************************************************************** // * Version information // ****************************************************************** -#define _CXBX_VERSION "0.7.0-pre2" +#define _CXBX_VERSION "0.7.0-pre3" // ****************************************************************** // * Define this to trace intercepted function calls diff --git a/Include/Win32/CxbxKrnl/xd3d8.h b/Include/Win32/CxbxKrnl/xd3d8.h index 0d0bf8836..be55403a8 100644 --- a/Include/Win32/CxbxKrnl/xd3d8.h +++ b/Include/Win32/CxbxKrnl/xd3d8.h @@ -72,9 +72,9 @@ extern UINT D3DVertexToPrimitive[11][2]; extern D3DRENDERSTATETYPE D3DRenderState2PC[160]; // ****************************************************************** -// * EmuD3DRenderState +// * EmuD3DDefferedRenderState // ****************************************************************** -extern DWORD *EmuD3DRenderState; +extern DWORD *EmuD3DDefferedRenderState; // ****************************************************************** // * EmuPrimitiveType diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl index 25bca5870..b2f781484 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl @@ -180,7 +180,6 @@ SOOVPA<13> IDirect3DDevice8_SetRenderState_CullMode_1_0_4361 = } }; - // ****************************************************************** // * IDirect3DDevice8_SetRenderState_ZEnable // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl index 10fbf71c4..2c7640806 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl @@ -147,6 +147,39 @@ SOOVPA<13> IDirect3DDevice8_CreateVertexBuffer2_1_0_4627 = } }; + +// ****************************************************************** +// * IDirect3DDevice8_SetRenderState_ZEnable +// ****************************************************************** +SOOVPA<13> IDirect3DDevice8_SetRenderState_ZEnable_1_0_4627 = +{ + 0, // Large == 0 + 13, // Count == 13 + + { + // IDirect3DDevice8_SetRenderState_CullMode+0x0C : jb +0x05 + { 0x0C, 0x72 }, // (Offset,Value)-Pair #1 + { 0x0D, 0x05 }, // (Offset,Value)-Pair #2 + + // IDirect3DDevice8_SetRenderState_CullMode+0x1B : mov ecx, [esi+0x21B8h] + { 0x1B, 0x8B }, // (Offset,Value)-Pair #3 + { 0x1C, 0x8E }, // (Offset,Value)-Pair #4 + { 0x1D, 0xB8 }, // (Offset,Value)-Pair #5 + { 0x1E, 0x21 }, // (Offset,Value)-Pair #6 + + // IDirect3DDevice8_SetRenderState_CullMode+0x2E : mov dword ptr [eax], 0x4030 + { 0x2E, 0xC7 }, // (Offset,Value)-Pair #7 + { 0x2F, 0x00 }, // (Offset,Value)-Pair #8 + { 0x30, 0x0C }, // (Offset,Value)-Pair #9 + { 0x31, 0x03 }, // (Offset,Value)-Pair #10 + { 0x32, 0x04 }, // (Offset,Value)-Pair #11 + + // IDirect3DDevice8_SetRenderState_CullMode+0x8C : retn 0x04 + { 0x8C, 0xC2 }, // (Offset,Value)-Pair #12 + { 0x8D, 0x04 }, // (Offset,Value)-Pair #13 + } +}; + // ****************************************************************** // * IDirect3DVertexBuffer8_Lock2 // ****************************************************************** @@ -232,6 +265,16 @@ OOVPATable D3D8_1_0_4627[] = "EmuIDirect3DDevice8_SetRenderState_CullMode" #endif }, + // IDirect3DDevice8::SetRenderState_ZEnable + { + (OOVPA*)&IDirect3DDevice8_SetRenderState_ZEnable_1_0_4627, + + xd3d8::EmuIDirect3DDevice8_SetRenderState_ZEnable, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetRenderState_ZEnable" + #endif + }, // IDirect3DDevice8::SetTransform (* unchanged since 4361 *) { (OOVPA*)&IDirect3DDevice8_SetTransform_1_0_4361, diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 1629af7a2..f7da852d2 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -333,24 +333,25 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit } } } - else if(strcmp("D3D8", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 4361)) + else if(strcmp("D3D8", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 4361 || BuildVersion == 4627)) { uint32 lower = pXbeHeader->dwBaseAddr; uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; - // ****************************************************************** - // * Locate IDirect3DDevice8_SetRenderState_CullMode - // ****************************************************************** - { - void *pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4361, lower, upper); + void *pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4361, lower, upper); - if(pFunc != 0) - { - xd3d8::EmuD3DRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x200); + // ****************************************************************** + // * Locate D3DRenderState + // ****************************************************************** + if(pFunc != 0) + { + if(BuildVersion == 4361) + xd3d8::EmuD3DDefferedRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x200 + 82*4); + else if(BuildVersion == 4627) + xd3d8::EmuD3DDefferedRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x24C + 92*4); - printf("Emu (0x%X): 0x%.08X -> EmuD3DRenderState\n", GetCurrentThreadId(), xd3d8::EmuD3DRenderState); - } - } + printf("Emu (0x%X): 0x%.08X -> EmuD3DDefferedRenderState\n", GetCurrentThreadId(), xd3d8::EmuD3DDefferedRenderState); + } } } @@ -396,8 +397,6 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit { EmuSwapFS(); // XBox FS - _asm int 3 - Entry(); EmuSwapFS(); // Win2k/XP FS diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 9d9ad2854..a03589dcb 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -99,9 +99,9 @@ UINT xd3d8::D3DVertexToPrimitive[11][2] = }; // ****************************************************************** -// * EmuD3DRenderState +// * EmuD3DDefferedRenderState // ****************************************************************** -DWORD *xd3d8::EmuD3DRenderState; +DWORD *xd3d8::EmuD3DDefferedRenderState; // ****************************************************************** // * D3DRenderState2PC (Convert Xbox->PC RenderState enum values) @@ -931,7 +931,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices #endif // Certain D3DRS values need to be checked on each Draw[Indexed]Vertices - g_pD3D8Device->SetRenderState(D3DRS_LIGHTING, xd3d8::EmuD3DRenderState[92]); + g_pD3D8Device->SetRenderState(D3DRS_LIGHTING, xd3d8::EmuD3DDefferedRenderState[10]); UINT PrimitiveCount = D3DVertex2PrimitiveCount(PrimitiveType, VertexCount); diff --git a/Source/Win32/CxbxKrnl/EmuFS.cpp b/Source/Win32/CxbxKrnl/EmuFS.cpp index 922f02183..212ca7e95 100644 --- a/Source/Win32/CxbxKrnl/EmuFS.cpp +++ b/Source/Win32/CxbxKrnl/EmuFS.cpp @@ -73,7 +73,7 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData) // * Copy Global TLS to Local // ****************************************************************** { - uint32 dwCopySize = RoundUp(pTLS->dwDataEndAddr - pTLS->dwDataStartAddr, 0x04); + uint32 dwCopySize = pTLS->dwDataEndAddr - pTLS->dwDataStartAddr; uint32 dwZeroSize = pTLS->dwSizeofZeroFill; pNewTLS = new uint08[dwCopySize + dwZeroSize]; diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl index c53d132df..41077926f 100644 --- a/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl @@ -111,6 +111,16 @@ OOVPATable XAPI_1_0_4627[] = #endif }, //*/ + // XapiThreadStartup (* unchanged since 1.0.4361 *) + { + (OOVPA*)&XapiThreadStartup_1_0_4361, + + xapi::EmuXapiThreadStartup, + + #ifdef _DEBUG_TRACE + "XapiThreadStartup" + #endif + }, //* Too High Level // XapiInitProcess (* unchanged since 1.0.4361 *) {