D3D Lights!

This commit is contained in:
Aaron Robinson 2003-05-28 07:21:41 +00:00
parent a04f2f3d36
commit 4582cd686b
10 changed files with 343 additions and 24 deletions

View File

@ -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!

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
},
};
// ******************************************************************

View File

@ -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
},
};
// ******************************************************************

View File

@ -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;
}

View File

@ -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