diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt index 2028f0a5d..2f9f2c354 100644 --- a/Doc/Changelog.txt +++ b/Doc/Changelog.txt @@ -1,6 +1,6 @@ cxbx website: http://www.caustik.com/xbox/ -version: 0.7.0 (??/??/??) +version: 0.7.0 (05/27/03) -------------------------------- - Magically shrunk cxbx.dll/cxbx.exe file sizes enormously! diff --git a/Include/Cxbx.h b/Include/Cxbx.h index a93ede82c..3e0ede3ca 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-pre3" +#define _CXBX_VERSION "0.7.1-pre1" // ****************************************************************** // * Define this to trace intercepted function calls diff --git a/Include/Win32/CxbxKrnl/xd3d8.h b/Include/Win32/CxbxKrnl/xd3d8.h index be55403a8..88a646759 100644 --- a/Include/Win32/CxbxKrnl/xd3d8.h +++ b/Include/Win32/CxbxKrnl/xd3d8.h @@ -231,4 +231,30 @@ HRESULT WINAPI EmuIDirect3DDevice8_DrawVertices UINT VertexCount ); +// ****************************************************************** +// * func: EmuIDirect3DDevice8_SetLight +// ****************************************************************** +HRESULT WINAPI EmuIDirect3DDevice8_SetLight +( + DWORD Index, + CONST D3DLIGHT8 *pLight +); + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_SetMaterial +// ****************************************************************** +HRESULT WINAPI EmuIDirect3DDevice8_SetMaterial +( + CONST D3DMATERIAL8 *pMaterial +); + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_LightEnable +// ****************************************************************** +HRESULT WINAPI EmuIDirect3DDevice8_LightEnable +( + DWORD Index, + BOOL bEnable +); + #endif diff --git a/Resource/Cxbx.rc b/Resource/Cxbx.rc index 27869f9da..a7e24fa8c 100644 --- a/Resource/Cxbx.rc +++ b/Resource/Cxbx.rc @@ -160,7 +160,7 @@ BEGIN MENUITEM "Config &Audio...", ID_SETTINGS_CONFIGURESOUND , GRAYED MENUITEM "Config &Video...", ID_SETTINGS_CONFIGUREGRAPHICS - + , GRAYED MENUITEM "", 1 MENUITEM "Generate &Exe Automatically", ID_SETTINGS_AUTOGEN END diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl index b2f781484..2608babdb 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl @@ -370,6 +370,102 @@ SOOVPA<12> IDirect3DDevice8_DrawVertices_1_0_4361 = } }; +// ****************************************************************** +// * IDirect3DDevice8_SetLight +// ****************************************************************** +SOOVPA<12> IDirect3DDevice8_SetLight_1_0_4361 = +{ + 0, // Large == 0 + 12, // Count == 12 + + { + // IDirect3DDevice8_SetLight+0x11 : mov edi, [ebp+0x394] + { 0x11, 0x8B }, // (Offset,Value)-Pair #1 + { 0x12, 0xBD }, // (Offset,Value)-Pair #2 + { 0x13, 0x94 }, // (Offset,Value)-Pair #3 + { 0x14, 0x03 }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_SetLight+0x30 : shl eax, 0x04 + { 0x30, 0xC1 }, // (Offset,Value)-Pair #5 + { 0x31, 0xE0 }, // (Offset,Value)-Pair #6 + { 0x32, 0x04 }, // (Offset,Value)-Pair #7 + + // IDirect3DDevice8_SetLight+0xBD : rep stosb + { 0xBD, 0xF3 }, // (Offset,Value)-Pair #8 + { 0xBE, 0xAB }, // (Offset,Value)-Pair #9 + + // IDirect3DDevice8_SetLight+0xFD : mov ecx, [ebx+0x68] + { 0xFD, 0x8B }, // (Offset,Value)-Pair #10 + { 0xFE, 0x4B }, // (Offset,Value)-Pair #11 + { 0xFF, 0x68 }, // (Offset,Value)-Pair #12 + } +}; + +// ****************************************************************** +// * IDirect3DDevice8_SetMaterial +// ****************************************************************** +SOOVPA<12> IDirect3DDevice8_SetMaterial_1_0_4361 = +{ + 0, // Large == 0 + 12, // Count == 12 + + { + // IDirect3DDevice8_SetMaterial+0x0C : add edi, 0x0940 + { 0x0C, 0x81 }, // (Offset,Value)-Pair #1 + { 0x0D, 0xC7 }, // (Offset,Value)-Pair #2 + { 0x0E, 0xF0 }, // (Offset,Value)-Pair #3 + { 0x0F, 0x09 }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_SetMaterial+0x12 : mov ecx, 0x11 + { 0x12, 0xB9 }, // (Offset,Value)-Pair #5 + { 0x13, 0x11 }, // (Offset,Value)-Pair #6 + + // IDirect3DDevice8_SetMaterial+0x1F : or ecx, 0x1000 + { 0x1F, 0x81 }, // (Offset,Value)-Pair #7 + { 0x20, 0xC9 }, // (Offset,Value)-Pair #8 + { 0x21, 0x00 }, // (Offset,Value)-Pair #9 + { 0x22, 0x10 }, // (Offset,Value)-Pair #10 + + // IDirect3DDevice8_SetMaterial+0x2D : retn 0x04 + { 0x2D, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x2E, 0x04 }, // (Offset,Value)-Pair #12 + } +}; + +// ****************************************************************** +// * IDirect3DDevice8_LightEnable +// ****************************************************************** +SOOVPA<13> IDirect3DDevice8_LightEnable_1_0_4361 = +{ + 0, // Large == 0 + 13, // Count == 13 + + { + // IDirect3DDevice8_LightEnable+0x0F : cmp ebx, [esi+0x0394] + { 0x0F, 0x3B }, // (Offset,Value)-Pair #1 + { 0x10, 0x9E }, // (Offset,Value)-Pair #2 + { 0x11, 0x94 }, // (Offset,Value)-Pair #3 + { 0x12, 0x03 }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_LightEnable+0x6B : test eax, eax + { 0x6B, 0x85 }, // (Offset,Value)-Pair #5 + { 0x6C, 0xC0 }, // (Offset,Value)-Pair #6 + + // IDirect3DDevice8_LightEnable+0x9E : mov eax, [eax+0x8C] + { 0x9E, 0x8B }, // (Offset,Value)-Pair #7 + { 0x9F, 0x80 }, // (Offset,Value)-Pair #8 + { 0xA0, 0x8C }, // (Offset,Value)-Pair #9 + + // IDirect3DDevice8_LightEnable+0xBC : jz +0x12 + { 0xBC, 0x74 }, // (Offset,Value)-Pair #10 + { 0xBD, 0x12 }, // (Offset,Value)-Pair #11 + + // IDirect3DDevice8_LightEnable+0xE1 : retn 0x08 + { 0xE1, 0xC2 }, // (Offset,Value)-Pair #12 + { 0xE2, 0x08 }, // (Offset,Value)-Pair #13 + } +}; + // ****************************************************************** // * D3D8_1_0_4361 // ****************************************************************** @@ -465,16 +561,6 @@ OOVPATable D3D8_1_0_4361[] = "EmuIDirect3DDevice8_SetStreamSource" #endif }, - // IDirect3DDevice8::DrawVertices - { - (OOVPA*)&IDirect3DDevice8_DrawVertices_1_0_4361, - - xd3d8::EmuIDirect3DDevice8_DrawVertices, - - #ifdef _DEBUG_TRACE - "EmuIDirect3DDevice8_DrawVertices" - #endif - }, // IDirect3DDevice8::SetVertexShader { (OOVPA*)&IDirect3DDevice8_SetVertexShader_1_0_4361, @@ -485,6 +571,46 @@ OOVPATable D3D8_1_0_4361[] = "EmuIDirect3DDevice8_SetVertexShader" #endif }, + // IDirect3DDevice8::DrawVertices + { + (OOVPA*)&IDirect3DDevice8_DrawVertices_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_DrawVertices, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_DrawVertices" + #endif + }, + // IDirect3DDevice8::SetLight + { + (OOVPA*)&IDirect3DDevice8_SetLight_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_SetLight, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetLight" + #endif + }, + // IDirect3DDevice8::SetMaterial + { + (OOVPA*)&IDirect3DDevice8_SetMaterial_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_SetMaterial, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetMaterial" + #endif + }, + // IDirect3DDevice8::LightEnable + { + (OOVPA*)&IDirect3DDevice8_LightEnable_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_LightEnable, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_LightEnable" + #endif + }, }; // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl index 2c7640806..3338d230a 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl @@ -210,6 +210,38 @@ SOOVPA<11> IDirect3DVertexBuffer8_Lock2_1_0_4627 = } }; + +// ****************************************************************** +// * IDirect3DDevice8_SetMaterial +// ****************************************************************** +SOOVPA<12> IDirect3DDevice8_SetMaterial_1_0_4627 = +{ + 0, // Large == 0 + 12, // Count == 12 + + { + // IDirect3DDevice8_SetMaterial+0x0C : add edi, 0x0AB0 + { 0x0C, 0x81 }, // (Offset,Value)-Pair #1 + { 0x0D, 0xC7 }, // (Offset,Value)-Pair #2 + { 0x0E, 0xB0 }, // (Offset,Value)-Pair #3 + { 0x0F, 0x0A }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_SetMaterial+0x12 : mov ecx, 0x11 + { 0x12, 0xB9 }, // (Offset,Value)-Pair #5 + { 0x13, 0x11 }, // (Offset,Value)-Pair #6 + + // IDirect3DDevice8_SetMaterial+0x1F : or ecx, 0x1000 + { 0x1F, 0x81 }, // (Offset,Value)-Pair #7 + { 0x20, 0xC9 }, // (Offset,Value)-Pair #8 + { 0x21, 0x00 }, // (Offset,Value)-Pair #9 + { 0x22, 0x10 }, // (Offset,Value)-Pair #10 + + // IDirect3DDevice8_SetMaterial+0x2D : retn 0x04 + { 0x2D, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x2E, 0x04 }, // (Offset,Value)-Pair #12 + } +}; + // ****************************************************************** // * D3D8_1_0_4627 // ****************************************************************** @@ -325,6 +357,36 @@ OOVPATable D3D8_1_0_4627[] = "EmuIDirect3DDevice8_DrawVertices" #endif }, + // IDirect3DDevice8::SetLight (* unchanged since 4361 *) + { + (OOVPA*)&IDirect3DDevice8_SetLight_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_SetLight, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetLight" + #endif + }, + // IDirect3DDevice8::SetMaterial + { + (OOVPA*)&IDirect3DDevice8_SetMaterial_1_0_4627, + + xd3d8::EmuIDirect3DDevice8_SetMaterial, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetMaterial" + #endif + }, + // IDirect3DDevice8::LightEnable (* unchanged since 4361 *) + { + (OOVPA*)&IDirect3DDevice8_LightEnable_1_0_4361, + + xd3d8::EmuIDirect3DDevice8_LightEnable, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_LightEnable" + #endif + }, }; // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index f7da852d2..8805ec728 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -397,7 +397,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit { EmuSwapFS(); // XBox FS - Entry(); + Entry(); EmuSwapFS(); // Win2k/XP FS } diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index e2c809b35..68676ce47 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -108,7 +108,7 @@ DWORD *xd3d8::EmuD3DDefferedRenderState; // ****************************************************************** xd3d8::D3DRENDERSTATETYPE D3DRenderState2PC[160] = { - // NOTE: We may not need this... + // NOTE: We may not need this... /* 0->123 */ (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, @@ -130,7 +130,7 @@ xd3d8::D3DRENDERSTATETYPE D3DRenderState2PC[160] = (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, - (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, + (xd3d8::D3DRENDERSTATETYPE)0, (xd3d8::D3DRENDERSTATETYPE)0, /* D3DRS_LIGHTING = 124 */ xd3d8::D3DRS_LIGHTING }; @@ -510,7 +510,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_Clear Color, Z, Stencil); } #endif - + // ****************************************************************** // * make adjustments to parameters to make sense with windows d3d // ****************************************************************** @@ -600,7 +600,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_Swap // TODO: Ensure this flag is always the same across library versions if(Flags != 0) - EmuCleanup("xd3d8::EmuIDirect3DDevice8_Swap: Flags != 0"); + EmuCleanup("xd3d8::EmuIDirect3DDevice8_Swap: Flags != 0"); // Swap(0) is equivalent to present(0,0,0,0) HRESULT ret = g_pD3D8Device->Present(0, 0, 0, 0); @@ -954,8 +954,8 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices #endif // Certain D3DRS values need to be checked on each Draw[Indexed]Vertices - g_pD3D8Device->SetRenderState(D3DRS_LIGHTING, xd3d8::EmuD3DDefferedRenderState[10]); - g_pD3D8Device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, xd3d8::EmuD3DDefferedRenderState[20]); + g_pD3D8Device->SetRenderState(D3DRS_LIGHTING, xd3d8::EmuD3DDefferedRenderState[10]); + g_pD3D8Device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, xd3d8::EmuD3DDefferedRenderState[20]); g_pD3D8Device->SetRenderState(D3DRS_AMBIENT, xd3d8::EmuD3DDefferedRenderState[23]); UINT PrimitiveCount = D3DVertex2PrimitiveCount(PrimitiveType, VertexCount); @@ -974,3 +974,108 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices return hRet; } + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_SetLight +// ****************************************************************** +HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetLight +( + DWORD Index, + CONST D3DLIGHT8 *pLight +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetLight\n" + "(\n" + " Index : 0x%.08X\n" + " pLight : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), Index, pLight); + } + #endif + + D3DMATERIAL8 Material; + + ZeroMemory(&Material, sizeof(D3DMATERIAL8)); + + Material.Diffuse.r = Material.Ambient.r = 1.0f; + Material.Diffuse.g = Material.Ambient.g = 1.0f; + Material.Diffuse.b = Material.Ambient.b = 0.0f; + Material.Diffuse.a = Material.Ambient.a = 1.0f; + + g_pD3D8Device->SetMaterial(&Material); + + HRESULT hRet = g_pD3D8Device->SetLight(Index, pLight); + + EmuSwapFS(); // XBox FS + + return hRet; +} + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_SetMaterial +// ****************************************************************** +HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetMaterial +( + CONST D3DMATERIAL8 *pMaterial +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetMaterial\n" + "(\n" + " pMaterial : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pMaterial); + } + #endif + + HRESULT hRet = g_pD3D8Device->SetMaterial(pMaterial); + + EmuSwapFS(); // XBox FS + + return hRet; +} + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_LightEnable +// ****************************************************************** +HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_LightEnable +( + DWORD Index, + BOOL bEnable +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_LightEnable\n" + "(\n" + " Index : 0x%.08X\n" + " bEnable : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), Index, bEnable); + } + #endif + + HRESULT hRet = g_pD3D8Device->LightEnable(Index, bEnable); + + EmuSwapFS(); // XBox FS + + return hRet; +} diff --git a/Source/Win32/CxbxKrnl/EmuLDT.cpp b/Source/Win32/CxbxKrnl/EmuLDT.cpp index 5ecbdf8f1..fc57a05f5 100644 --- a/Source/Win32/CxbxKrnl/EmuLDT.cpp +++ b/Source/Win32/CxbxKrnl/EmuLDT.cpp @@ -53,7 +53,7 @@ namespace xntdll // ****************************************************************** // * Maximum number of threads this LDT system will handle // ****************************************************************** -#define MAXIMUM_XBOX_THREADS 128 +#define MAXIMUM_XBOX_THREADS 256 // ****************************************************************** // * Table of free LDT entries @@ -70,7 +70,7 @@ static CRITICAL_SECTION EmuLDTLock; // ****************************************************************** static HMODULE hNtDll = GetModuleHandle("ntdll"); -xntdll::FPTR_NtSetLdtEntries NT_NtSetLdtEntries = (xntdll::FPTR_NtSetLdtEntries)GetProcAddress(hNtDll, "NtSetLdtEntries"); +static xntdll::FPTR_NtSetLdtEntries NT_NtSetLdtEntries = (xntdll::FPTR_NtSetLdtEntries)GetProcAddress(hNtDll, "NtSetLdtEntries"); // ****************************************************************** // * func: EmuInitLDT diff --git a/Source/Win32/CxbxKrnl/EmuXapi.cpp b/Source/Win32/CxbxKrnl/EmuXapi.cpp index e87d43689..802acd2cb 100644 --- a/Source/Win32/CxbxKrnl/EmuXapi.cpp +++ b/Source/Win32/CxbxKrnl/EmuXapi.cpp @@ -301,9 +301,9 @@ VOID WINAPI xapi::EmuXapiInitProcess() PVOID dwResult = 0; - __asm + __asm { - xor ecx, ecx + xor ecx, ecx push pSomeStruct push ecx