From d80bd636e228edcb827cb77ebfcd9fa8946e214c Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sun, 28 Aug 2016 18:22:44 +0700 Subject: [PATCH] Emulate crazy way of shifting image horizontally, which bottom of the 9th uses. Fixed bottom of the 9th: screen not centered #862 --- src/FrameBuffer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 6c23edb2..9a6f154e 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -791,6 +791,7 @@ void FrameBufferList::renderBuffer(u32 _address) OGLRender & render = ogl.getRender(); GLint srcY0, srcY1, dstY0, dstY1; GLint X0, X1, Xwidth; + GLint Xoffset = 0; GLint srcPartHeight = 0; GLint dstPartHeight = 0; @@ -817,7 +818,10 @@ void FrameBufferList::renderBuffer(u32 _address) isLowerField = vStart > vStartPrev; vStartPrev = vStart; - srcY0 = ((_address - pBuffer->m_startAddress) << 1 >> pBuffer->m_size) / (*REG.VI_WIDTH); + const u32 addrOffset = ((_address - pBuffer->m_startAddress) << 1 >> pBuffer->m_size); + srcY0 = addrOffset / (*REG.VI_WIDTH); + if (addrOffset % (*REG.VI_WIDTH) != 0) + Xoffset = (*REG.VI_WIDTH) - addrOffset % (*REG.VI_WIDTH); if (isLowerField) { if (srcY0 > 0) --srcY0; @@ -846,8 +850,8 @@ void FrameBufferList::renderBuffer(u32 _address) const s32 h0 = (isPAL ? 128 : 108); const s32 hx0 = max(0, hStart - h0); const s32 hx1 = max(0, h0 + 640 - hEnd); - X0 = (GLint)(hx0 * viScaleX * dstScaleX); - Xwidth = (GLint)((min((f32)VI.width, (hEnd - hStart)*viScaleX)) * srcScaleX); + X0 = (GLint)((hx0 * viScaleX + Xoffset) * dstScaleX); + Xwidth = (GLint)((min((f32)VI.width, (hEnd - hStart)*viScaleX - Xoffset)) * srcScaleX); X1 = ogl.getWidth() - (GLint)(hx1 *viScaleX * dstScaleX); const f32 srcScaleY = pFilteredBuffer->m_scaleY;