NBA Jam 2004

This commit is contained in:
Aaron Robinson 2004-06-02 04:46:12 +00:00
parent 197c813ea4
commit 0debb092df
8 changed files with 298 additions and 35 deletions

BIN
Cxbx.opt

Binary file not shown.

View File

@ -45,9 +45,25 @@ Message("}\n");
<begin c code>
for(int v=0;v<sizeof(funcAddr)/sizeof(uint32);v++)
{
Where funcExclude is an array of uint32 addresses to exclude from the search...
for(int v=0;v<sizeof(funcAddr)/sizeof(uint32);v++)
{
bool bExclude = false;
for(int r=0;r<sizeof(funcExclude)/sizeof(uint32);r++)
{
if(funcAddr[v] == funcExclude[r])
{
bExclude = true;
break;
}
}
if(!bExclude)
{
*(uint08*)(funcAddr[v]) = 0xCC;
}
}
}
</end c code>

View File

@ -48,9 +48,6 @@ extern VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize);
// cleanup direct3d
extern VOID EmuD3DCleanup();
// is this texture linear?
extern GUID hRefGUID_bTexIsLinear;
// EmuD3DTileCache (8 tiles maximum)
extern X_D3DTILE EmuD3DTileCache[0x08];

View File

@ -86,7 +86,7 @@ extern class ResourceTracker : public Mutex
}
g_VBTrackTotal, g_VBTrackDisable,
g_PBTrackTotal, g_PBTrackDisable, g_PBTrackShowOnce,
g_PatchedStreamsCache;
g_PatchedStreamsCache, g_DataToTexture;
struct RTNode
{

View File

@ -427,8 +427,8 @@ void ToggleFauxFullscreen(HWND hWnd)
}
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
ShowWindow(hWnd, SW_MAXIMIZE);
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
else
{
@ -1343,6 +1343,10 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SelectVertexShader
VERTEX_SHADER *pVertexShader = (VERTEX_SHADER *)(((X_D3DVertexShader *)(Handle & 0x7FFFFFFF))->Handle);
g_pD3DDevice8->SetVertexShader(pVertexShader->Handle);
}
else if(Handle == NULL)
{
g_pD3DDevice8->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX0);
}
else if(Address < 136)
{
X_D3DVertexShader *pVertexShader = (X_D3DVertexShader*)g_VertexShaderSlots[Address];
@ -2227,6 +2231,16 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_CreateVertexShader
ZeroMemory(pD3DVertexShader, sizeof(X_D3DVertexShader));
ZeroMemory(pVertexShader, sizeof(VERTEX_SHADER));
// HACK: TODO: support this situation
if(pDeclaration == NULL)
{
*pHandle = NULL;
EmuSwapFS(); // Win2k/XP FS
return S_OK;
}
LPD3DXBUFFER pRecompiledBuffer = NULL;
DWORD *pRecompiledDeclaration;
DWORD *pRecompiledFunction = NULL;
@ -2768,7 +2782,22 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_CreateTexture
);
if(FAILED(hRet))
{
EmuWarning("CreateTexture Failed!");
(*ppTexture)->Data = 0xBEADBEAD;
}
else
{
D3DLOCKED_RECT LockedRect;
(*ppTexture)->EmuTexture8->LockRect(0, &LockedRect, NULL, NULL);
(*ppTexture)->Data = (DWORD)LockedRect.pBits;
g_DataToTexture.insert((*ppTexture)->Data, *ppTexture);
(*ppTexture)->EmuTexture8->UnlockRect(0);
}
DbgPrintf("EmuD3D8 (0x%X): Created Texture : 0x%.08X (0x%.08X)\n", GetCurrentThreadId(), *ppTexture, (*ppTexture)->EmuTexture8);
}
@ -3120,7 +3149,9 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SetTexture
char szBuffer[255];
sprintf(szBuffer, "C:\\Aaron\\Textures\\0x%.08X-Texture%.03d.bmp", pTexture, dwDumpTexture++);
sprintf(szBuffer, "C:\\Aaron\\Textures\\0x%.08X-SetTexture%.03d.bmp", pTexture, dwDumpTexture++);
pTexture->EmuTexture8->UnlockRect(0);
D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pBaseTexture8, NULL);
}
@ -3154,28 +3185,48 @@ VOID __fastcall XTL::EmuIDirect3DDevice8_SwitchTexture
");\n",
GetCurrentThreadId(), Method, Data, Format);
EmuWarning("EmuIDirect3DDevice8_SwitchTexture is not implemented!");
DWORD StageLookup[] = { 0x00081b00, 0x00081b40, 0x00081b80, 0x00081bc0 };
DWORD Stage = -1;
for(int v=0;v<4;v++)
{
if(StageLookup[v] == Method)
{
Stage = v;
}
}
if(Stage == -1)
{
EmuWarning("Unknown Method (0x%.08X)", Method);
}
else
{
//
// TODO: Crawl list of active X_D3DTexture's, searching for Data..
// we're basically screwed in the event that the texture is
// not _Register'd (should never happen though)
// WARNING: TODO: Correct reference counting has not been completely verified for this code
//
X_D3DTexture *pTexture = (X_D3DTexture *)g_DataToTexture.get(Data);
EmuWarning("Switching Texture 0x%.08X (0x%.08X) @ Stage %d", pTexture, pTexture->EmuBaseTexture8, Stage);
HRESULT hRet = g_pD3DDevice8->SetTexture(Stage, pTexture->EmuBaseTexture8);
/*
IDirect3DBaseTexture8 *pBaseTexture8 = pTexture->EmuBaseTexture8;
IDirect3DBaseTexture8 *pPrevTexture8 = NULL;
if(pTexture->EmuBaseTexture8 != NULL)
{
static int dwDumpTexture = 0;
// Xbox SwitchTexture does not decrement the reference count on the
// old texture, but SetTexture does, so we need to pre-increment
g_pD3DDevice8->GetTexture(Stage, &pPrevTexture8);
char szBuffer[255];
HRESULT hRet = g_pD3DDevice8->SetTexture(Stage, pBaseTexture8);
sprintf(szBuffer, "C:\\Aaron\\Textures\\0x%.08X-SwitchTexture%.03d.bmp", pTexture, dwDumpTexture++);
// Xbox SwitchTexture does not increment reference count, but the
// above SetTexture does, so we need to remove it.
pBaseTexture8->Release();
pTexture->EmuTexture8->UnlockRect(0);
D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pTexture->EmuBaseTexture8, NULL);
}
//*/
}
EmuSwapFS(); // XBox FS
@ -4089,7 +4140,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
char szBuffer[255];
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-Surface%.03d.bmp", X_Format, dwDumpSurface++);
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-RegSurface%.03d.bmp", X_Format, dwDumpSurface++);
D3DXSaveSurfaceToFile(szBuffer, D3DXIFF_BMP, pResource->EmuSurface8, NULL, NULL);
}
@ -4105,7 +4156,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
{
IDirect3DSurface8 *pSurface=0;
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-CubeTex%.03d-%d.bmp", X_Format, dwDumpCube++, v);
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-RegCubeTex%.03d-%d.bmp", X_Format, dwDumpCube++, v);
pResource->EmuCubeTexture8->GetCubeMapSurface((D3DCUBEMAP_FACES)v, 0, &pSurface);
@ -4118,7 +4169,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
char szBuffer[255];
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-Texture%.03d.bmp", X_Format, dwDumpTex++);
sprintf(szBuffer, "C:\\Aaron\\Textures\\%.03d-RegTexture%.03d.bmp", X_Format, dwDumpTex++);
D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pResource->EmuTexture8, NULL);
}
@ -4337,7 +4388,7 @@ VOID WINAPI XTL::EmuGet2DSurfaceDesc
char szBuffer[255];
sprintf(szBuffer, "C:\\Aaron\\Textures\\Texture%.03d.bmp", dwDumpTexture++);
sprintf(szBuffer, "C:\\Aaron\\Textures\\GetDescTexture%.03d.bmp", dwDumpTexture++);
D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pPixelContainer->EmuTexture8, NULL);
*/
@ -6134,7 +6185,7 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_SetRenderState_YuvEnable
");\n",
GetCurrentThreadId(), Value);
EmuWarning("YuvEnable not implemented");
EmuWarning("YuvEnable not implemented (0x%.08X)", Value);
EmuSwapFS(); // XBox FS

View File

@ -197,7 +197,7 @@ void XTL::EmuUpdateDeferredStates()
// TODO: Use a lookup table, this is not always a 1:1 map
if(pCur[12] != X_D3DTSS_UNK)
{
if(pCur[12] > 12)
if(pCur[12] > 12 && !(pCur[12] >= 17 && pCur[12] <= 21))
EmuCleanup("(Temporarily) Unsupported D3DTSS_COLOROP Value (%d)", pCur[12]);
g_pD3DDevice8->SetTextureStageState(v, D3DTSS_COLOROP, pCur[12]);

View File

@ -185,6 +185,42 @@ SOOVPA<11> IDirect3DDevice8_SelectVertexShader_1_0_5558 =
}
};
// ******************************************************************
// * IDirect3DDevice8_CreateVertexShader
// ******************************************************************
SOOVPA<12> IDirect3DDevice8_CreateVertexShader_1_0_5558 =
{
0, // Large == 0
12, // Count == 12
-1, // XRef Not Saved
0, // XRef Not Used
{
// IDirect3DDevice8_CreateVertexShader+0x00 : push ecx; push ebx; push ebp
{ 0x00, 0x51 }, // (Offset,Value)-Pair #1
{ 0x01, 0x53 }, // (Offset,Value)-Pair #2
{ 0x02, 0x55 }, // (Offset,Value)-Pair #3
// IDirect3DDevice8_CreateVertexShader+0x0A : jz +0x10
{ 0x0A, 0x74 }, // (Offset,Value)-Pair #4
{ 0x0B, 0x10 }, // (Offset,Value)-Pair #5
// IDirect3DDevice8_CreateVertexShader+0x43 : shl eax, 0x02
{ 0x43, 0xC1 }, // (Offset,Value)-Pair #6
{ 0x44, 0xE0 }, // (Offset,Value)-Pair #7
{ 0x45, 0x02 }, // (Offset,Value)-Pair #8
// IDirect3DDevice8_CreateVertexShader+0x73 : mov eax, 0x8007000E
{ 0x65, 0x07 }, // (Offset,Value)-Pair #11
{ 0x66, 0x80 }, // (Offset,Value)-Pair #12
// IDirect3DDevice8_CreateVertexShader+0x69 : retn 0x10
{ 0x69, 0xC2 }, // (Offset,Value)-Pair #9
{ 0x6A, 0x10 }, // (Offset,Value)-Pair #10
}
};
// ******************************************************************
// * IDirect3DDevice8_SetVertexShaderConstant1
// ******************************************************************
@ -302,6 +338,28 @@ LOOVPA<8> IDirect3DDevice8_Clear_1_0_5558 =
}
};
// ******************************************************************
// * IDirect3DDevice8_CreateVertexBuffer2
// ******************************************************************
SOOVPA<17> IDirect3DDevice8_CreateVertexBuffer2_1_0_5558 =
{
0, // Large == 0
7, // Count == 7
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x08, 0xE8 },
{ 0x12, 0x1E },
{ 0x1C, 0x50 },
{ 0x26, 0x68 },
{ 0x31, 0x33 },
{ 0x3A, 0xFF },
{ 0x44, 0x01 },
}
};
// ******************************************************************
// * IDirect3DDevice8_UpdateOverlay
// ******************************************************************
@ -411,6 +469,29 @@ SOOVPA<7> IDirect3DDevice8_SetPixelShader_1_0_5558 =
}
};
// ******************************************************************
// * IDirect3DDevice8_CreateTexture2
// ******************************************************************
SOOVPA<8> IDirect3DDevice8_CreateTexture2_1_0_5558 =
{
0, // Large == 0
8, // Count == 8
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x14, 0x4C },
{ 0x2A, 0x8B },
{ 0x42, 0x8B },
{ 0x56, 0x80 },
{ 0x70, 0x85 },
{ 0x82, 0x5E },
{ 0x98, 0x89 },
{ 0xAE, 0x1C },
}
};
// ******************************************************************
// * IDirect3DDevice8_End
// ******************************************************************
@ -584,6 +665,28 @@ SOOVPA<8> IDirect3DDevice8_SetVertexShader_1_0_5558 =
}
};
// ******************************************************************
// * IDirect3DDevice8_SetIndices
// ******************************************************************
SOOVPA<7> IDirect3DDevice8_SetIndices_1_0_5558 =
{
0, // Large == 0
7, // Count == 7
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x0F, 0x10 },
{ 0x20, 0xC7 },
{ 0x31, 0xC0 },
{ 0x42, 0x78 },
{ 0x53, 0xBE },
{ 0x64, 0x89 },
{ 0x75, 0x10 },
}
};
// ******************************************************************
// * IDirect3DDevice8_SetTexture
// ******************************************************************
@ -705,6 +808,29 @@ SOOVPA<11> IDirect3DDevice8_BlockUntilVerticalBlank_1_0_5558 =
}
};
// ******************************************************************
// * IDirect3DDevice8_DrawIndexedVertices
// ******************************************************************
SOOVPA<8> IDirect3DDevice8_DrawIndexedVertices_1_0_5558 =
{
0, // Large == 0
8, // Count == 8
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x1E, 0x5E },
{ 0x3E, 0x17 },
{ 0x5E, 0x00 },
{ 0x7E, 0x8B },
{ 0x9E, 0x89 },
{ 0xBE, 0x2B },
{ 0xDE, 0x00 },
{ 0xFE, 0x04 },
}
};
// ******************************************************************
// * IDirect3DDevice8_DrawIndexedVerticesUP
// ******************************************************************
@ -915,12 +1041,23 @@ OOVPATable D3D8_1_0_5558[] =
// D3DDevice_RunVertexStateShader (* unchanged since 4627 *)
{
(OOVPA*)&X_D3DDevice_RunVertexStateShader_1_0_4627,
XTL::EmuIDirect3DDevice8_RunVertexStateShader,
#ifdef _DEBUG_TRACE
"D3DDevice_RunVertexStateShader"
#endif
},
// D3DDevice_GetVertexShaderSize (* unchanged since 4627 *)
{
(OOVPA*)&X_D3DDevice_GetVertexShaderSize_1_0_4627,
XTL::EmuIDirect3DDevice8_GetVertexShaderSize,
#ifdef _DEBUG_TRACE
"D3DDevice_GetVertexShaderSize"
#endif
},
// IDirect3DDevice8::LoadVertexShader
{
(OOVPA*)&IDirect3DDevice8_LoadVertexShader_1_0_5558,
@ -941,6 +1078,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_SelectVertexShader"
#endif
},
// IDirect3DDevice8::CreateVertexShader
{
(OOVPA*)&IDirect3DDevice8_CreateVertexShader_1_0_5558,
XTL::EmuIDirect3DDevice8_CreateVertexShader,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_CreateVertexShader"
#endif
},
// IDirect3DDevice8::SetVertexShaderConstant1
{
(OOVPA*)&IDirect3DDevice8_SetVertexShaderConstant1_1_0_5558,
@ -961,6 +1108,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_SetVertexShaderConstantNotInlineFast"
#endif
},
// IDirect3DDevice8::CreateVertexBuffer2
{
(OOVPA*)&IDirect3DDevice8_CreateVertexBuffer2_1_0_5558,
XTL::EmuIDirect3DDevice8_CreateVertexBuffer2,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_CreateVertexBuffer2"
#endif
},
// IDirect3DDevice8::UpdateOverlay
{
(OOVPA*)&IDirect3DDevice8_UpdateOverlay_1_0_5558,
@ -1031,6 +1188,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_BlockUntilVerticalBlank"
#endif
},
// IDirect3DDevice8::DrawIndexedVertices
{
(OOVPA*)&IDirect3DDevice8_DrawIndexedVertices_1_0_5558,
XTL::EmuIDirect3DDevice8_DrawIndexedVertices,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_DrawIndexedVertices"
#endif
},
// IDirect3DDevice8::DrawIndexedVerticesUP
{
(OOVPA*)&IDirect3DDevice8_DrawIndexedVerticesUP_1_0_5558,
@ -1051,6 +1218,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_SetPixelShader"
#endif
},
// IDirect3DDevice8::CreateTexture2
{
(OOVPA*)&IDirect3DDevice8_CreateTexture2_1_0_5558,
XTL::EmuIDirect3DDevice8_CreateTexture2,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_CreateTexture2"
#endif
},
// IDirect3DDevice8::GetDisplayMode (* unchanged since 4627 *)
{
(OOVPA*)&IDirect3DDevice8_GetDisplayMode_1_0_4627,
@ -1301,6 +1478,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_SetVertexShader"
#endif
},
// IDirect3DDevice8::SetIndices
{
(OOVPA*)&IDirect3DDevice8_SetIndices_1_0_5558,
XTL::EmuIDirect3DDevice8_SetIndices,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_SetIndices"
#endif
},
// IDirect3DDevice8::SetTexture
{
(OOVPA*)&IDirect3DDevice8_SetTexture_1_0_5558,
@ -1381,6 +1568,16 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_SetShaderConstantMode"
#endif
},
// IDirect3DResource8::Register (* unchanged since 3925 *)
{
(OOVPA*)&IDirect3DResource8_Register_1_0_3925,
XTL::EmuIDirect3DResource8_Register,
#ifdef _DEBUG_TRACE
"EmuIDirect3DResource8_Register"
#endif
},
// IDirect3DResource8::AddRef (* unchanged since 3925 *)
{
(OOVPA*)&IDirect3DResource8_AddRef_1_0_3925,

View File

@ -47,6 +47,8 @@ ResourceTracker g_PBTrackShowOnce;
ResourceTracker g_PatchedStreamsCache;
ResourceTracker g_DataToTexture;
ResourceTracker::~ResourceTracker()
{
clear();