Yipee
This commit is contained in:
parent
60652d2cac
commit
1eaaddb78b
|
@ -0,0 +1,24 @@
|
||||||
|
Direct3D resources are going to be a little bit of a hack.
|
||||||
|
There is a tough situation, because precompiled resources
|
||||||
|
(XPR) can be loaded into memory manually by an Xbox Game,
|
||||||
|
and then "Registered" with pResource->Register(addr);
|
||||||
|
|
||||||
|
This is a problem because we never have an opportunity to
|
||||||
|
intercept the "this" pointer for this datatype. The base
|
||||||
|
resource class looks like this:
|
||||||
|
|
||||||
|
DWORD Common;
|
||||||
|
DWORD Data;
|
||||||
|
DWORD Lock;
|
||||||
|
|
||||||
|
The first idea is to tuck away the PC Direct3D resource
|
||||||
|
pointer inside of pResource->Data. The trouble with this
|
||||||
|
is that some Xbox Games will directly access and modify
|
||||||
|
this member.
|
||||||
|
|
||||||
|
Another technique is to hide the PC Direct3D resource pointer
|
||||||
|
inside of the buffer allocated by Data. This could work, as
|
||||||
|
long as Xbox Games do not access the resource Data after the
|
||||||
|
initial Register function is called.
|
||||||
|
|
||||||
|
I am currently using the first idea until we run into trouble.
|
|
@ -1,5 +1,13 @@
|
||||||
Cxbx Todo (* denotes high priority)
|
Cxbx Todo (* denotes high priority)
|
||||||
|
|
||||||
|
* When in critical section, do not print debug trace
|
||||||
|
|
||||||
|
* Functions like GetRenderTarget need to return a special temporary
|
||||||
|
X_D3DSurface that will somehow be cleaned up along with the "real"
|
||||||
|
X_D3DSurface pointer. Perhaps maintain a cache of all the current
|
||||||
|
temporary buffers, and whenever a resource has it's final Release(),
|
||||||
|
go through and check if any other handles reference that resource.
|
||||||
|
|
||||||
* Register() probably needn't re-unswizzle each time. cache a copy of
|
* Register() probably needn't re-unswizzle each time. cache a copy of
|
||||||
the address it was registered to (or a global table) and simply update
|
the address it was registered to (or a global table) and simply update
|
||||||
the data pointer to that IDirect3DTexture8 instance.
|
the data pointer to that IDirect3DTexture8 instance.
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef signed long sint32;
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Define this to trace intercepted function calls
|
// * Define this to trace intercepted function calls
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
#define _DEBUG_TRACE
|
//#define _DEBUG_TRACE
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Round up dwValue to nearest multiple of dwMult
|
// * Round up dwValue to nearest multiple of dwMult
|
||||||
|
|
|
@ -166,18 +166,17 @@ X_D3DPRESENT_PARAMETERS;
|
||||||
struct X_D3DResource
|
struct X_D3DResource
|
||||||
{
|
{
|
||||||
DWORD Common;
|
DWORD Common;
|
||||||
|
DWORD Data;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
DWORD Data;
|
DWORD Lock;
|
||||||
IDirect3DResource8 *EmuResource8;
|
IDirect3DResource8 *EmuResource8;
|
||||||
IDirect3DBaseTexture8 *EmuBaseTexture8;
|
IDirect3DBaseTexture8 *EmuBaseTexture8;
|
||||||
IDirect3DTexture8 *EmuTexture8;
|
IDirect3DTexture8 *EmuTexture8;
|
||||||
IDirect3DSurface8 *EmuSurface8;
|
IDirect3DSurface8 *EmuSurface8;
|
||||||
IDirect3DVertexBuffer8 *EmuVertexBuffer8;
|
IDirect3DVertexBuffer8 *EmuVertexBuffer8;
|
||||||
};
|
};
|
||||||
|
|
||||||
DWORD Lock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -298,6 +297,32 @@ HRESULT WINAPI EmuIDirect3D8_GetAdapterDisplayMode
|
||||||
X_D3DDISPLAYMODE *pMode
|
X_D3DDISPLAYMODE *pMode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetRenderTarget
|
||||||
|
// ******************************************************************
|
||||||
|
HRESULT WINAPI EmuIDirect3DDevice8_GetRenderTarget
|
||||||
|
(
|
||||||
|
X_D3DSurface **ppRenderTarget
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetRenderTarget
|
||||||
|
// ******************************************************************
|
||||||
|
X_D3DSurface * WINAPI EmuIDirect3DDevice8_GetRenderTarget2();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
// ******************************************************************
|
||||||
|
HRESULT WINAPI EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
(
|
||||||
|
X_D3DSurface **ppZStencilSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
// ******************************************************************
|
||||||
|
X_D3DSurface * WINAPI EmuIDirect3DDevice8_GetDepthStencilSurface2();
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * func: EmuIDirect3DDevice8_CreateVertexShader
|
// * func: EmuIDirect3DDevice8_CreateVertexShader
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
|
@ -642,6 +642,18 @@ typedef NTSTATUS (NTAPI *FPTR_NtWriteFile)
|
||||||
IN PULONG Key OPTIONAL
|
IN PULONG Key OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtSetInformationFile
|
||||||
|
// ******************************************************************
|
||||||
|
typedef NTSTATUS (NTAPI *FPTR_NtSetInformationFile)
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle, // TODO: correct paramters
|
||||||
|
OUT PVOID IoStatusBlock,
|
||||||
|
IN PVOID FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN ULONG FileInformationClass
|
||||||
|
);
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * NtQueryInformationFile
|
// * NtQueryInformationFile
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
|
@ -91,6 +91,62 @@ SOOVPA<13> IDirect3D8_GetAdapterDisplayMode_1_0_4361 =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IDirect3DDevice8_GetRenderTarget
|
||||||
|
// ******************************************************************
|
||||||
|
SOOVPA<9> IDirect3DDevice8_GetRenderTarget_1_0_4361 =
|
||||||
|
{
|
||||||
|
0, // Large == 0
|
||||||
|
9, // Count == 9
|
||||||
|
|
||||||
|
{
|
||||||
|
// IDirect3DDevice8_GetRenderTarget+0x00 : mov eax, [addr]
|
||||||
|
{ 0x00, 0xA1 }, // (Offset,Value)-Pair #1
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget+0x05 : mov eax, [eax + 0x2070]
|
||||||
|
{ 0x05, 0x8B }, // (Offset,Value)-Pair #2
|
||||||
|
{ 0x06, 0x80 }, // (Offset,Value)-Pair #3
|
||||||
|
{ 0x07, 0x70 }, // (Offset,Value)-Pair #4
|
||||||
|
{ 0x08, 0x20 }, // (Offset,Value)-Pair #5
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget+0x11 : mov [ecx], eax
|
||||||
|
{ 0x11, 0x89 }, // (Offset,Value)-Pair #6
|
||||||
|
{ 0x12, 0x01 }, // (Offset,Value)-Pair #7
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget+0x1D : retn 0x04
|
||||||
|
{ 0x1D, 0xC2 }, // (Offset,Value)-Pair #8
|
||||||
|
{ 0x1E, 0x04 }, // (Offset,Value)-Pair #9
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
// ******************************************************************
|
||||||
|
SOOVPA<9> IDirect3DDevice8_GetDepthStencilSurface_1_0_4361 =
|
||||||
|
{
|
||||||
|
0, // Large == 0
|
||||||
|
9, // Count == 9
|
||||||
|
|
||||||
|
{
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface+0x00 : mov eax, [addr]
|
||||||
|
{ 0x00, 0xA1 }, // (Offset,Value)-Pair #1
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface+0x05 : mov eax, [eax + 0x2074]
|
||||||
|
{ 0x05, 0x8B }, // (Offset,Value)-Pair #2
|
||||||
|
{ 0x06, 0x80 }, // (Offset,Value)-Pair #3
|
||||||
|
{ 0x07, 0x74 }, // (Offset,Value)-Pair #4
|
||||||
|
{ 0x08, 0x20 }, // (Offset,Value)-Pair #5
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface+0x11 : mov [ecx], eax
|
||||||
|
{ 0x11, 0x89 }, // (Offset,Value)-Pair #6
|
||||||
|
{ 0x12, 0x01 }, // (Offset,Value)-Pair #7
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface+0x1D : retn 0x04
|
||||||
|
{ 0x1D, 0xC2 }, // (Offset,Value)-Pair #8
|
||||||
|
{ 0x1E, 0x04 }, // (Offset,Value)-Pair #9
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * IDirect3DDevice8_CreateVertexShader
|
// * IDirect3DDevice8_CreateVertexShader
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -989,6 +1045,26 @@ OOVPATable D3D8_1_0_4361[] =
|
||||||
"EmuIDirect3D8_GetAdapterDisplayMode"
|
"EmuIDirect3D8_GetAdapterDisplayMode"
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
|
// IDirect3DDevice8::GetRenderTarget
|
||||||
|
{
|
||||||
|
(OOVPA*)&IDirect3DDevice8_GetRenderTarget_1_0_4361,
|
||||||
|
|
||||||
|
xd3d8::EmuIDirect3DDevice8_GetRenderTarget,
|
||||||
|
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
"EmuIDirect3DDevice8_GetRenderTarget"
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
// IDirect3DDevice8::GetDepthStencilSurface
|
||||||
|
{
|
||||||
|
(OOVPA*)&IDirect3DDevice8_GetDepthStencilSurface_1_0_4361,
|
||||||
|
|
||||||
|
xd3d8::EmuIDirect3DDevice8_GetDepthStencilSurface,
|
||||||
|
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
"EmuIDirect3DDevice8_GetDepthStencilSurface"
|
||||||
|
#endif
|
||||||
|
},
|
||||||
// IDirect3DDevice8::CreateVertexShader
|
// IDirect3DDevice8::CreateVertexShader
|
||||||
{
|
{
|
||||||
(OOVPA*)&IDirect3DDevice8_CreateVertexShader_1_0_4361,
|
(OOVPA*)&IDirect3DDevice8_CreateVertexShader_1_0_4361,
|
||||||
|
|
|
@ -91,6 +91,72 @@ SOOVPA<13> IDirect3D8_GetAdapterDisplayMode_1_0_4627 =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IDirect3DDevice8_GetRenderTarget2
|
||||||
|
// ******************************************************************
|
||||||
|
SOOVPA<10> IDirect3DDevice8_GetRenderTarget2_1_0_4627 =
|
||||||
|
{
|
||||||
|
0, // Large == 0
|
||||||
|
10, // Count == 10
|
||||||
|
|
||||||
|
{
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x00 : mov eax, [addr]
|
||||||
|
{ 0x00, 0xA1 }, // (Offset,Value)-Pair #1
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x05 : push esi
|
||||||
|
{ 0x05, 0x56 }, // (Offset,Value)-Pair #2
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x06 : mov esi, [eax + 0x21B4]
|
||||||
|
{ 0x06, 0x8B }, // (Offset,Value)-Pair #3
|
||||||
|
{ 0x07, 0xB0 }, // (Offset,Value)-Pair #4
|
||||||
|
{ 0x08, 0xB4 }, // (Offset,Value)-Pair #5
|
||||||
|
{ 0x09, 0x21 }, // (Offset,Value)-Pair #6
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x0E : jz + 0x06
|
||||||
|
{ 0x0E, 0x74 }, // (Offset,Value)-Pair #7
|
||||||
|
{ 0x0F, 0x06 }, // (Offset,Value)-Pair #8
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x11 : call [addr]
|
||||||
|
{ 0x11, 0xE8 }, // (Offset,Value)-Pair #9
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetRenderTarget2+0x19 : retn
|
||||||
|
{ 0x19, 0xC3 }, // (Offset,Value)-Pair #10
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IDirect3DDevice8_GetDepthStencilSurface2
|
||||||
|
// ******************************************************************
|
||||||
|
SOOVPA<10> IDirect3DDevice8_GetDepthStencilSurface2_1_0_4627 =
|
||||||
|
{
|
||||||
|
0, // Large == 0
|
||||||
|
10, // Count == 10
|
||||||
|
|
||||||
|
{
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x00 : mov eax, [addr]
|
||||||
|
{ 0x00, 0xA1 }, // (Offset,Value)-Pair #1
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x05 : push esi
|
||||||
|
{ 0x05, 0x56 }, // (Offset,Value)-Pair #2
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x06 : mov esi, [eax + 0x21B8]
|
||||||
|
{ 0x06, 0x8B }, // (Offset,Value)-Pair #3
|
||||||
|
{ 0x07, 0xB0 }, // (Offset,Value)-Pair #4
|
||||||
|
{ 0x08, 0xB8 }, // (Offset,Value)-Pair #5
|
||||||
|
{ 0x09, 0x21 }, // (Offset,Value)-Pair #6
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x0E : jnz +0x04
|
||||||
|
{ 0x0E, 0x75 }, // (Offset,Value)-Pair #7
|
||||||
|
{ 0x0F, 0x04 }, // (Offset,Value)-Pair #8
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x15 : call [addr]
|
||||||
|
{ 0x15, 0xE8 }, // (Offset,Value)-Pair #9
|
||||||
|
|
||||||
|
// IDirect3DDevice8_GetDepthStencilSurface2+0x1D : retn
|
||||||
|
{ 0x1D, 0xC3 }, // (Offset,Value)-Pair #10
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * IDirect3DDevice8_SetVertexShaderConstant
|
// * IDirect3DDevice8_SetVertexShaderConstant
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -504,6 +570,26 @@ OOVPATable D3D8_1_0_4627[] =
|
||||||
"EmuIDirect3D8_GetAdapterDisplayMode"
|
"EmuIDirect3D8_GetAdapterDisplayMode"
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
|
// IDirect3DDevice8::GetRenderTarget2
|
||||||
|
{
|
||||||
|
(OOVPA*)&IDirect3DDevice8_GetRenderTarget2_1_0_4627,
|
||||||
|
|
||||||
|
xd3d8::EmuIDirect3DDevice8_GetRenderTarget2,
|
||||||
|
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
"EmuIDirect3DDevice8_GetRenderTarget2"
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
// IDirect3DDevice8::GetDepthStencilSurface2
|
||||||
|
{
|
||||||
|
(OOVPA*)&IDirect3DDevice8_GetDepthStencilSurface2_1_0_4627,
|
||||||
|
|
||||||
|
xd3d8::EmuIDirect3DDevice8_GetDepthStencilSurface2,
|
||||||
|
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
"EmuIDirect3DDevice8_GetDepthStencilSurface2"
|
||||||
|
#endif
|
||||||
|
},
|
||||||
// IDirect3DDevice8::CreateVertexShader (* unchanged since 4361 *)
|
// IDirect3DDevice8::CreateVertexShader (* unchanged since 4361 *)
|
||||||
{
|
{
|
||||||
(OOVPA*)&IDirect3DDevice8_CreateVertexShader_1_0_4361,
|
(OOVPA*)&IDirect3DDevice8_CreateVertexShader_1_0_4361,
|
||||||
|
|
|
@ -364,6 +364,8 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
||||||
{
|
{
|
||||||
EmuSwapFS(); // XBox FS
|
EmuSwapFS(); // XBox FS
|
||||||
|
|
||||||
|
// __asm int 3
|
||||||
|
|
||||||
Entry();
|
Entry();
|
||||||
|
|
||||||
EmuSwapFS(); // Win2k/XP FS
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
|
|
@ -88,14 +88,20 @@ static DWORD WINAPI EmuUpdateTickCount(LPVOID);
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
static xd3d8::LPDIRECT3D8 g_pD3D8 = NULL; // Direct3D8
|
static xd3d8::LPDIRECT3D8 g_pD3D8 = NULL; // Direct3D8
|
||||||
static xd3d8::LPDIRECT3DDEVICE8 g_pD3DDevice8 = NULL; // Direct3D8 Device
|
static xd3d8::LPDIRECT3DDEVICE8 g_pD3DDevice8 = NULL; // Direct3D8 Device
|
||||||
static DWORD g_VertexShaderUsage = 0; // Vertex Shader Usage Param
|
|
||||||
static Xbe::Header *g_XbeHeader = NULL; // XbeHeader
|
static Xbe::Header *g_XbeHeader = NULL; // XbeHeader
|
||||||
static uint32 g_XbeHeaderSize = 0; // XbeHeaderSize
|
static uint32 g_XbeHeaderSize = 0; // XbeHeaderSize
|
||||||
static xd3d8::D3DCAPS8 g_D3DCaps; // Direct3D8 Caps
|
static xd3d8::D3DCAPS8 g_D3DCaps; // Direct3D8 Caps
|
||||||
static HBRUSH g_hBgBrush = NULL; // Background Brush
|
static HBRUSH g_hBgBrush = NULL; // Background Brush
|
||||||
static volatile bool g_ThreadInitialized = false;
|
static volatile bool g_bThreadInitialized = false;
|
||||||
static XBVideo g_XBVideo;
|
static XBVideo g_XBVideo;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Cached Direct3D State Variable(s)
|
||||||
|
// ******************************************************************
|
||||||
|
static xd3d8::X_D3DSurface *g_pCachedRenderTarget = NULL;
|
||||||
|
static xd3d8::X_D3DSurface *g_pCachedZStencilSurface = NULL;
|
||||||
|
static DWORD g_dwVertexShaderUsage = 0;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * EmuD3DDefferedRenderState
|
// * EmuD3DDefferedRenderState
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -114,7 +120,7 @@ VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize)
|
||||||
g_XbeHeader = XbeHeader;
|
g_XbeHeader = XbeHeader;
|
||||||
g_XbeHeaderSize = XbeHeaderSize;
|
g_XbeHeaderSize = XbeHeaderSize;
|
||||||
|
|
||||||
g_ThreadInitialized = false;
|
g_bThreadInitialized = false;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Create a thread dedicated to timing
|
// * Create a thread dedicated to timing
|
||||||
|
@ -133,7 +139,7 @@ VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize)
|
||||||
|
|
||||||
CreateThread(NULL, NULL, EmuRenderWindow, NULL, NULL, &dwThreadId);
|
CreateThread(NULL, NULL, EmuRenderWindow, NULL, NULL, &dwThreadId);
|
||||||
|
|
||||||
while(!g_ThreadInitialized)
|
while(!g_bThreadInitialized)
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
|
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
|
@ -290,7 +296,7 @@ DWORD WINAPI EmuRenderWindow(LPVOID)
|
||||||
{
|
{
|
||||||
if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
{
|
{
|
||||||
g_ThreadInitialized = true;
|
g_bThreadInitialized = true;
|
||||||
|
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
|
@ -399,6 +405,20 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
|
||||||
// TODO: This should be detected from D3DCAPS8 ? (FrameSkip?)
|
// TODO: This should be detected from D3DCAPS8 ? (FrameSkip?)
|
||||||
pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
|
pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
|
||||||
|
|
||||||
|
// TODO: Support Xbox extensions if possible
|
||||||
|
if(pPresentationParameters->MultiSampleType != 0)
|
||||||
|
{
|
||||||
|
printf("Warning: MultiSampleType (0x%.08X) Not Supported!\n", pPresentationParameters->MultiSampleType);
|
||||||
|
|
||||||
|
pPresentationParameters->MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||||
|
|
||||||
|
// TODO: Check card for multisampling abilities
|
||||||
|
// if(pPresentationParameters->MultiSampleType == 0x00001121)
|
||||||
|
// pPresentationParameters->MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
|
||||||
|
// else
|
||||||
|
// EmuCleanup("Unknown MultiSampleType (0x%.08X)", pPresentationParameters->MultiSampleType);
|
||||||
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Retrieve Resolution from Configuration
|
// * Retrieve Resolution from Configuration
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -412,6 +432,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
|
||||||
|
|
||||||
pPresentationParameters->BackBufferFormat = D3DDisplayMode.Format;
|
pPresentationParameters->BackBufferFormat = D3DDisplayMode.Format;
|
||||||
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
|
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
|
||||||
|
pPresentationParameters->hDeviceWindow = hFocusWindow;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -443,7 +464,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
|
||||||
printf("EmuD3D8 (0x%X): Using hardware vertex processing\n", GetCurrentThreadId());
|
printf("EmuD3D8 (0x%X): Using hardware vertex processing\n", GetCurrentThreadId());
|
||||||
#endif
|
#endif
|
||||||
BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||||
g_VertexShaderUsage = 0;
|
g_dwVertexShaderUsage = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -451,7 +472,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
|
||||||
printf("EmuD3D8 (0x%X): Using software vertex processing\n", GetCurrentThreadId());
|
printf("EmuD3D8 (0x%X): Using software vertex processing\n", GetCurrentThreadId());
|
||||||
#endif
|
#endif
|
||||||
BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||||
g_VertexShaderUsage = D3DUSAGE_SOFTWAREPROCESSING;
|
g_dwVertexShaderUsage = D3DUSAGE_SOFTWAREPROCESSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -472,6 +493,17 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
g_pD3DDevice8 = *ppReturnedDeviceInterface;
|
g_pD3DDevice8 = *ppReturnedDeviceInterface;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Update Caches
|
||||||
|
// ******************************************************************
|
||||||
|
{
|
||||||
|
g_pCachedRenderTarget = new X_D3DSurface();
|
||||||
|
g_pD3DDevice8->GetRenderTarget(&g_pCachedRenderTarget->EmuSurface8);
|
||||||
|
|
||||||
|
g_pCachedZStencilSurface = new X_D3DSurface();
|
||||||
|
g_pD3DDevice8->GetDepthStencilSurface(&g_pCachedZStencilSurface->EmuSurface8);
|
||||||
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * I guess we have to call this
|
// * I guess we have to call this
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -535,6 +567,118 @@ HRESULT WINAPI xd3d8::EmuIDirect3D8_GetAdapterDisplayMode
|
||||||
return hRet;
|
return hRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetRenderTarget
|
||||||
|
// ******************************************************************
|
||||||
|
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_GetRenderTarget
|
||||||
|
(
|
||||||
|
X_D3DSurface **ppRenderTarget
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * debug trace
|
||||||
|
// ******************************************************************
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
{
|
||||||
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetRenderTarget\n"
|
||||||
|
"(\n"
|
||||||
|
" ppRenderTarget : 0x%.08X\n"
|
||||||
|
");\n",
|
||||||
|
GetCurrentThreadId(), ppRenderTarget);
|
||||||
|
EmuSwapFS(); // Xbox FS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDirect3DSurface8 *pSurface8 = g_pCachedRenderTarget->EmuSurface8;
|
||||||
|
|
||||||
|
pSurface8->AddRef();
|
||||||
|
|
||||||
|
*ppRenderTarget = g_pCachedRenderTarget;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetRenderTarget2
|
||||||
|
// ******************************************************************
|
||||||
|
xd3d8::X_D3DSurface * WINAPI xd3d8::EmuIDirect3DDevice8_GetRenderTarget2()
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * debug trace
|
||||||
|
// ******************************************************************
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
{
|
||||||
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetRenderTarget2()\n",
|
||||||
|
GetCurrentThreadId());
|
||||||
|
EmuSwapFS(); // Xbox FS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDirect3DSurface8 *pSurface8 = g_pCachedRenderTarget->EmuSurface8;
|
||||||
|
|
||||||
|
pSurface8->AddRef();
|
||||||
|
|
||||||
|
return g_pCachedRenderTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
// ******************************************************************
|
||||||
|
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
(
|
||||||
|
X_D3DSurface **ppZStencilSurface
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * debug trace
|
||||||
|
// ******************************************************************
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
{
|
||||||
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetDepthStencilSurface\n"
|
||||||
|
"(\n"
|
||||||
|
" ppZStencilSurface : 0x%.08X\n"
|
||||||
|
");\n",
|
||||||
|
GetCurrentThreadId(), ppZStencilSurface);
|
||||||
|
EmuSwapFS(); // Xbox FS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDirect3DSurface8 *pSurface8 = g_pCachedZStencilSurface->EmuSurface8;
|
||||||
|
|
||||||
|
pSurface8->AddRef();
|
||||||
|
|
||||||
|
*ppZStencilSurface = g_pCachedZStencilSurface;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * func: EmuIDirect3DDevice8_GetDepthStencilSurface
|
||||||
|
// ******************************************************************
|
||||||
|
xd3d8::X_D3DSurface * WINAPI xd3d8::EmuIDirect3DDevice8_GetDepthStencilSurface2()
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * debug trace
|
||||||
|
// ******************************************************************
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
{
|
||||||
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetDepthStencilSurface2()\n",
|
||||||
|
GetCurrentThreadId());
|
||||||
|
EmuSwapFS(); // Xbox FS
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDirect3DSurface8 *pSurface8 = g_pCachedZStencilSurface->EmuSurface8;
|
||||||
|
|
||||||
|
pSurface8->AddRef();
|
||||||
|
|
||||||
|
return g_pCachedZStencilSurface;
|
||||||
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * func: EmuIDirect3DDevice8_CreateVertexShader
|
// * func: EmuIDirect3DDevice8_CreateVertexShader
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -572,7 +716,7 @@ HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_CreateVertexShader
|
||||||
pDeclaration,
|
pDeclaration,
|
||||||
pFunction,
|
pFunction,
|
||||||
pHandle,
|
pHandle,
|
||||||
g_VertexShaderUsage // TODO: HACK: Xbox has extensions!
|
g_dwVertexShaderUsage // TODO: HACK: Xbox has extensions!
|
||||||
);
|
);
|
||||||
|
|
||||||
// hey look, we lied
|
// hey look, we lied
|
||||||
|
|
|
@ -80,6 +80,7 @@ xntdll::FPTR_NtCreateEvent NT_NtCreateEvent = (x
|
||||||
xntdll::FPTR_NtCreateFile NT_NtCreateFile = (xntdll::FPTR_NtCreateFile)GetProcAddress(hNtDll, "NtCreateFile");
|
xntdll::FPTR_NtCreateFile NT_NtCreateFile = (xntdll::FPTR_NtCreateFile)GetProcAddress(hNtDll, "NtCreateFile");
|
||||||
xntdll::FPTR_NtReadFile NT_NtReadFile = (xntdll::FPTR_NtReadFile)GetProcAddress(hNtDll, "NtReadFile");
|
xntdll::FPTR_NtReadFile NT_NtReadFile = (xntdll::FPTR_NtReadFile)GetProcAddress(hNtDll, "NtReadFile");
|
||||||
xntdll::FPTR_NtWriteFile NT_NtWriteFile = (xntdll::FPTR_NtWriteFile)GetProcAddress(hNtDll, "NtWriteFile");
|
xntdll::FPTR_NtWriteFile NT_NtWriteFile = (xntdll::FPTR_NtWriteFile)GetProcAddress(hNtDll, "NtWriteFile");
|
||||||
|
xntdll::FPTR_NtSetInformationFile NT_NtSetInformationFile = (xntdll::FPTR_NtSetInformationFile)GetProcAddress(hNtDll, "NtSetInformationFile");
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * (Helper) PCSTProxyParam
|
// * (Helper) PCSTProxyParam
|
||||||
|
@ -1019,6 +1020,43 @@ XBSYSAPI EXPORTNUM(219) NTSTATUS NTAPI xboxkrnl::NtReadFile
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * 0x00E2 - NtSetInformationFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(226) NTSTATUS NTAPI xboxkrnl::NtSetInformationFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle, // TODO: correct paramters
|
||||||
|
OUT PVOID IoStatusBlock,
|
||||||
|
IN PVOID FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN ULONG FileInformationClass
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EmuSwapFS(); // Win2k/XP FS
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * debug trace
|
||||||
|
// ******************************************************************
|
||||||
|
#ifdef _DEBUG_TRACE
|
||||||
|
{
|
||||||
|
printf("EmuKrnl (0x%X): NtSetInformationFile\n"
|
||||||
|
"(\n"
|
||||||
|
" FileHandle : 0x%.08X\n"
|
||||||
|
" IoStatusBlock : 0x%.08X\n"
|
||||||
|
" FileInformation : 0x%.08X\n"
|
||||||
|
" Length : 0x%.08X\n"
|
||||||
|
" FileInformationClass : 0x%.08X\n"
|
||||||
|
");\n",
|
||||||
|
GetCurrentThreadId(), FileHandle, IoStatusBlock, FileInformation,
|
||||||
|
Length, FileInformationClass);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NTSTATUS ret = NT_NtSetInformationFile(FileHandle, IoStatusBlock, FileInformation, Length, FileInformationClass);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * 0x00DA - NtWriteFile
|
// * 0x00DA - NtWriteFile
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -1180,6 +1218,7 @@ XBSYSAPI EXPORTNUM(277) VOID NTAPI xboxkrnl::RtlEnterCriticalSection
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This seems redundant, but xbox software doesn't always do it
|
// This seems redundant, but xbox software doesn't always do it
|
||||||
|
if(CriticalSection->LockCount == -1)
|
||||||
NT_RtlInitializeCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
|
NT_RtlInitializeCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
|
||||||
|
|
||||||
NT_RtlEnterCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
|
NT_RtlEnterCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
|
||||||
|
|
|
@ -291,7 +291,7 @@ extern "C" CXBXKRNL_API uint32 KernelThunkTable[367] =
|
||||||
(uint32)PANIC(0x00DF), // 0x00DF (223)
|
(uint32)PANIC(0x00DF), // 0x00DF (223)
|
||||||
(uint32)PANIC(0x00E0), // 0x00E0 (224)
|
(uint32)PANIC(0x00E0), // 0x00E0 (224)
|
||||||
(uint32)PANIC(0x00E1), // 0x00E1 (225)
|
(uint32)PANIC(0x00E1), // 0x00E1 (225)
|
||||||
(uint32)PANIC(0x00E2), // 0x00E2 (226)
|
(uint32)&xboxkrnl::NtSetInformationFile, // 0x00E2 (226)
|
||||||
(uint32)PANIC(0x00E3), // 0x00E3 (227)
|
(uint32)PANIC(0x00E3), // 0x00E3 (227)
|
||||||
(uint32)PANIC(0x00E4), // 0x00E4 (228)
|
(uint32)PANIC(0x00E4), // 0x00E4 (228)
|
||||||
(uint32)PANIC(0x00E5), // 0x00E5 (229)
|
(uint32)PANIC(0x00E5), // 0x00E5 (229)
|
||||||
|
|
Loading…
Reference in New Issue