From 7dca7f8f4d9ea8727b539b58962e910d5808422f Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Tue, 6 Sep 2016 19:37:11 +0700 Subject: [PATCH] Implement depth buffer copy for Mario Golf. Fix Mario Golf: Animated effects render in front of course #312 --- src/FrameBuffer.cpp | 16 ++++++++++------ src/RSP.cpp | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 3aab5da0..00b91df8 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -382,19 +382,23 @@ CachedTexture * FrameBuffer::_getSubTexture(u32 _t) CachedTexture * FrameBuffer::getTexture(u32 _t) { + const bool getDepthTexture = m_isDepthBuffer && + gDP.colorImage.address == gDP.depthImageAddress && + m_pDepthBuffer != nullptr; + CachedTexture *pTexture = getDepthTexture ? m_pDepthBuffer->m_pDepthBufferTexture : m_pTexture; + const u32 shift = (gSP.textureTile[_t]->imageAddress - m_startAddress) >> (m_size - 1); const u32 factor = m_width; if (m_loadType == LOADTYPE_TILE) { - m_pTexture->offsetS = (float)(m_loadTileOrigin.uls + (shift % factor)); - m_pTexture->offsetT = (float)(m_height - (m_loadTileOrigin.ult + shift / factor)); + pTexture->offsetS = (float)(m_loadTileOrigin.uls + (shift % factor)); + pTexture->offsetT = (float)(m_height - (m_loadTileOrigin.ult + shift / factor)); } else { - m_pTexture->offsetS = (float)(shift % factor); - m_pTexture->offsetT = (float)(m_height - shift / factor); + pTexture->offsetS = (float)(shift % factor); + pTexture->offsetT = (float)(m_height - shift / factor); } - CachedTexture *pTexture = m_pTexture; // if (gSP.textureTile[_t]->loadType == LOADTYPE_TILE && pTexture->size > 1) - if (gSP.textureTile[_t]->clamps == 0 || gSP.textureTile[_t]->clampt == 0) + if (!getDepthTexture && (gSP.textureTile[_t]->clamps == 0 || gSP.textureTile[_t]->clampt == 0)) pTexture = _getSubTexture(_t); pTexture->scaleS = m_scaleX / (float)pTexture->realWidth; diff --git a/src/RSP.cpp b/src/RSP.cpp index 58290c2b..311260b7 100644 --- a/src/RSP.cpp +++ b/src/RSP.cpp @@ -321,8 +321,7 @@ void RSP_Init() config.generalEmulation.hacks = 0; if (strstr(RSP.romname, (const char *)"OgreBattle64") != nullptr) config.generalEmulation.hacks |= hack_Ogre64; - else if (strstr(RSP.romname, (const char *)"MarioGolf64") != nullptr || - strstr(RSP.romname, (const char *)"F1 POLE POSITION 64") != nullptr) + else if (strstr(RSP.romname, (const char *)"F1 POLE POSITION 64") != nullptr) config.generalEmulation.hacks |= hack_noDepthFrameBuffers; else if (strstr(RSP.romname, (const char *)"CONKER BFD") != nullptr) config.generalEmulation.hacks |= hack_blurPauseScreen | hack_rectDepthBufferCopyCBFD;