Fix crashes when booting non XDK titles

This commit is contained in:
Luke Usher 2017-06-05 20:57:47 +01:00
parent 4d219a5fbe
commit ab80810bab
2 changed files with 15 additions and 10 deletions

View File

@ -2161,7 +2161,9 @@ HRESULT WINAPI XTL::EMUPATCH(Direct3D_CreateDevice)
Sleep(10); Sleep(10);
// Set the Xbox g_pD3DDevice pointer to our D3D Device object // Set the Xbox g_pD3DDevice pointer to our D3D Device object
*((DWORD*)XRefDataBase[XREF_D3DDEVICE]) = (DWORD)g_XboxD3DDevice; if (XRefDataBase[XREF_D3DDEVICE] != (xbaddr)nullptr) {
*((DWORD*)XRefDataBase[XREF_D3DDEVICE]) = (DWORD)g_XboxD3DDevice;
}
return g_EmuCDPD.hRet; return g_EmuCDPD.hRet;
} }

View File

@ -199,15 +199,15 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
// Fix up Render state and Texture States // Fix up Render state and Texture States
if (g_SymbolAddresses.find("D3DDeferredRenderState") == g_SymbolAddresses.end()) { if (g_SymbolAddresses.find("D3DDeferredRenderState") == g_SymbolAddresses.end()) {
CxbxKrnlCleanup("EmuD3DDeferredRenderState was not found!"); EmuWarning("EmuD3DDeferredRenderState was not found!");
} }
if (g_SymbolAddresses.find("D3DDeferredTextureState") == g_SymbolAddresses.end()) { if (g_SymbolAddresses.find("D3DDeferredTextureState") == g_SymbolAddresses.end()) {
CxbxKrnlCleanup("EmuD3DDeferredTextureState was not found!"); EmuWarning("EmuD3DDeferredTextureState was not found!");
} }
if (g_SymbolAddresses.find("D3DDEVICE") == g_SymbolAddresses.end()) { if (g_SymbolAddresses.find("D3DDEVICE") == g_SymbolAddresses.end()) {
CxbxKrnlCleanup("D3DDEVICE was not found!"); EmuWarning("D3DDEVICE was not found!");
} }
XTL::EmuD3DDeferredRenderState = (DWORD*)g_SymbolAddresses["D3DDeferredRenderState"]; XTL::EmuD3DDeferredRenderState = (DWORD*)g_SymbolAddresses["D3DDeferredRenderState"];
@ -215,14 +215,17 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
XRefDataBase[XREF_D3DDEVICE] = g_SymbolAddresses["D3DDEVICE"]; XRefDataBase[XREF_D3DDEVICE] = g_SymbolAddresses["D3DDEVICE"];
// TODO: Move this into a function rather than duplicating from HLE scanning code // TODO: Move this into a function rather than duplicating from HLE scanning code
for (int v = 0; v<44; v++) { if (XTL::EmuD3DDeferredRenderState != nullptr) {
XTL::EmuD3DDeferredRenderState[v] = XTL::X_D3DRS_UNK; for (int v = 0; v<44; v++) {
} XTL::EmuD3DDeferredRenderState[v] = XTL::X_D3DRS_UNK;
}
for (int s = 0; s<4; s++) { for (int s = 0; s<4; s++) {
for (int v = 0; v<32; v++) for (int v = 0; v<32; v++)
XTL::EmuD3DDeferredTextureState[v + s * 32] = X_D3DTSS_UNK; XTL::EmuD3DDeferredTextureState[v + s * 32] = X_D3DTSS_UNK;
}
} }
g_HLECacheUsed = true; g_HLECacheUsed = true;
} }