diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 62f5c10bf..4c753369e 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -9076,8 +9076,9 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetModelView) LOG_FUNC_ARG(pComposite) LOG_FUNC_END; - // TODO: Implement - LOG_UNIMPLEMENTED(); + // TODO handle other matrices + d3d8TransformState.SetWorldView(0, pModelView); + LOG_TEST_CASE("SetModelView"); } // ****************************************************************** @@ -9097,13 +9098,7 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(D3DDevice_GetModelView)(D3DXMATRIX* pMode { LOG_FUNC_ONE_ARG(pModelView); - D3DXMATRIX mtxWorld, mtxView; - - // I hope this is right - g_pD3DDevice->GetTransform( D3DTS_WORLD, &mtxWorld ); - g_pD3DDevice->GetTransform( D3DTS_VIEW, &mtxView ); - - *pModelView = mtxWorld * mtxView; + *pModelView = *d3d8TransformState.GetWorldView(0); return D3D_OK; } diff --git a/src/core/hle/D3D8/FixedFunctionState.cpp b/src/core/hle/D3D8/FixedFunctionState.cpp index c11f76fa2..ab7c8fbc2 100644 --- a/src/core/hle/D3D8/FixedFunctionState.cpp +++ b/src/core/hle/D3D8/FixedFunctionState.cpp @@ -144,6 +144,22 @@ D3DMATRIX* D3D8TransformState::GetWorldView(unsigned i) return &WorldView[i]; } +void D3D8TransformState::SetWorldView(unsigned i, const D3DMATRIX* pMatrix) +{ + assert(i < 4); + + if (!pMatrix) { + // null indicates the title is done with setting + // the worldview matrix explicitly + bWorldViewDirty[i] = true; + return; + } + else { + bWorldViewDirty[i] = false; + WorldView[i] = *pMatrix; + } +} + D3DMATRIX* D3D8TransformState::GetWorldViewInverseTranspose(unsigned i) { assert(i < 4); diff --git a/src/core/hle/D3D8/FixedFunctionState.h b/src/core/hle/D3D8/FixedFunctionState.h index d2dfee9e2..796f20a40 100644 --- a/src/core/hle/D3D8/FixedFunctionState.h +++ b/src/core/hle/D3D8/FixedFunctionState.h @@ -28,6 +28,7 @@ public: D3D8TransformState(); void SetTransform(xbox::X_D3DTRANSFORMSTATETYPE state, const D3DMATRIX* pMatrix); D3DMATRIX* GetWorldView(unsigned i); + void SetWorldView(unsigned i, const D3DMATRIX* pMatrix); D3DMATRIX* GetWorldViewInverseTranspose(unsigned i); // The transforms set by the Xbox title