From 42e75032fbde665d3e7adff862df2046fed2a14f Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 2 Apr 2015 15:47:05 +0600 Subject: [PATCH] Correct previous width calculation in VI_UpdateSize(). Now buffers removed when old and new VI width is not zero. Fixed knockout 2000, issue #294 --- VI.cpp | 11 +++++------ VI.h | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/VI.cpp b/VI.cpp index 4df30f9d..85d1ee40 100644 --- a/VI.cpp +++ b/VI.cpp @@ -31,8 +31,8 @@ void VI_UpdateSize() const u32 vEnd = _SHIFTR( *REG.VI_V_START, 0, 10 ); const u32 vStart = _SHIFTR( *REG.VI_V_START, 16, 10 ); const bool interlacedPrev = VI.interlaced; - const u32 widthPrev = VI.width; - const u32 heightPrev = VI.height; + if (VI.width > 0) + VI.widthPrev = VI.width; VI.real_height = vEnd > vStart ? (((vEnd - vStart) >> 1) * vScale) >> 10 : 0; VI.width = *REG.VI_WIDTH; @@ -66,10 +66,9 @@ void VI_UpdateSize() // const int fsaa = ((*REG.VI_STATUS) >> 8) & 3; // const int divot = ((*REG.VI_STATUS) >> 4) & 1; - FrameBufferList & fbList = frameBufferList(); - FrameBuffer * pBuffer = fbList.findBuffer(VI.lastOrigin); - if (config.frameBufferEmulation.enable && ((interlacedPrev != VI.interlaced) || (pBuffer != NULL && pBuffer->m_width != VI.width))) { - fbList.removeBuffers(widthPrev); + if (config.frameBufferEmulation.enable && ((interlacedPrev != VI.interlaced) || (VI.width > 0 && VI.width != VI.widthPrev))) { + FrameBufferList & fbList = frameBufferList(); + fbList.removeBuffers(VI.widthPrev); fbList.removeBuffers(VI.width); depthBufferList().destroy(); depthBufferList().init(); diff --git a/VI.h b/VI.h index a1804708..29048bd4 100644 --- a/VI.h +++ b/VI.h @@ -4,14 +4,13 @@ struct VIInfo { - u32 width; - u32 height, real_height; + u32 width, widthPrev, height, real_height; f32 rwidth, rheight; u32 lastOrigin; bool interlaced; VIInfo() : - width(0), height(0), real_height(0), + width(0), widthPrev(0), height(0), real_height(0), lastOrigin(-1), interlaced(false) {} };