From 4981503bfc5773d7b39033774748c38792b7979f Mon Sep 17 00:00:00 2001 From: gizmo98 Date: Wed, 21 Oct 2020 19:34:08 +0200 Subject: [PATCH] Code refactor: add vi status constants --- src/FrameBuffer.cpp | 4 ++-- src/PostProcessor.cpp | 3 ++- src/VI.cpp | 6 +++--- src/VI.h | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index a35cab31..f503613d 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -1077,7 +1077,7 @@ bool FrameBufferList::RdpUpdate::update(RdpUpdateResult & _result) const s32 delta_y = y2 - y1; const u32 vitype = _SHIFTR( *REG.VI_STATUS, 0, 2 ); - const bool serration_pulses = (*REG.VI_STATUS & 0x40) != 0; + const bool serration_pulses = (*REG.VI_STATUS & VI_STATUS_SERRATE_ENABLED) != 0; const bool validinterlace = ((vitype & 2) != 0 ) && serration_pulses; if (validinterlace && prevserrate && emucontrolsvicurrent < 0) emucontrolsvicurrent = (*REG.VI_V_CURRENT_LINE & 1) != prevvicurrent ? 1 : 0; @@ -1167,7 +1167,7 @@ bool FrameBufferList::RdpUpdate::update(RdpUpdateResult & _result) _result.vi_lowerfield = lowerfield; _result.vi_origin = _SHIFTR(*REG.VI_ORIGIN, 0, 24); _result.vi_fsaa = (*REG.VI_STATUS & 512) == 0; - _result.vi_divot = (*REG.VI_STATUS & 16) != 0; + _result.vi_divot = (*REG.VI_STATUS & VI_STATUS_DIVOT_ENABLED) != 0; return true; #if 0 diff --git a/src/PostProcessor.cpp b/src/PostProcessor.cpp index d48a72b0..7bfe2af0 100644 --- a/src/PostProcessor.cpp +++ b/src/PostProcessor.cpp @@ -5,6 +5,7 @@ #include "PostProcessor.h" #include "FrameBuffer.h" #include "Config.h" +#include "VI.h" #include #include @@ -156,7 +157,7 @@ FrameBuffer * PostProcessor::_doGammaCorrection(FrameBuffer * _pBuffer) if (_pBuffer == nullptr) return nullptr; - if (((*REG.VI_STATUS & 8) | config.gammaCorrection.force) == 0) + if (((*REG.VI_STATUS & VI_STATUS_GAMMA_ENABLED) | config.gammaCorrection.force) == 0) return _pBuffer; return _doPostProcessing(_pBuffer, m_gammaCorrectionProgram.get()); diff --git a/src/VI.cpp b/src/VI.cpp index 92ebaadd..c299fd95 100644 --- a/src/VI.cpp +++ b/src/VI.cpp @@ -49,7 +49,7 @@ void VI_UpdateSize() VI.real_height = vEnd > vStart ? (((vEnd - vStart) >> 1) * vScale) >> 10 : 0; VI.width = *REG.VI_WIDTH; - VI.interlaced = (*REG.VI_STATUS & 0x40) != 0; + VI.interlaced = (*REG.VI_STATUS & VI_STATUS_SERRATE_ENABLED) != 0; if (VI.interlaced) { f32 fullWidth = 640.0f; @@ -164,13 +164,13 @@ void VI_UpdateScreen() wnd.updateScale(); bVIUpdated = true; } - const u32 size = *REG.VI_STATUS & 3; + const u32 size = *REG.VI_STATUS & VI_STATUS_TYPE_32; if (VI.height > 0 && size > G_IM_SIZ_8b && VI.width > 0) frameBufferList().saveBuffer(*REG.VI_ORIGIN & 0xffffff, G_IM_FMT_RGBA, size, VI.width, true); } } // if ((((*REG.VI_STATUS) & 3) > 0) && (gDP.colorImage.changed || bCFB)) { // Does not work in release build!!! - if (((*REG.VI_STATUS) & 3) > 0) { + if (((*REG.VI_STATUS) & VI_STATUS_TYPE_32) > 0) { if (!bVIUpdated) { VI_UpdateSize(); bVIUpdated = true; diff --git a/src/VI.h b/src/VI.h index b8f29d9b..440ed83c 100644 --- a/src/VI.h +++ b/src/VI.h @@ -2,6 +2,22 @@ #define VI_H #include "Types.h" +// VI status register +#define VI_STATUS_TYPE_16 0x000002 /* 16 bit 5/5/5/3 */ +#define VI_STATUS_TYPE_32 0x000003 /* 32 bit 8/8/8/8 */ +#define VI_STATUS_GAMMA_DITHER_ENABLED 0x000004 +#define VI_STATUS_GAMMA_ENABLED 0x000008 +#define VI_STATUS_DIVOT_ENABLED 0x000010 +#define VI_STATUS_SERRATE_ENABLED 0x000040 +#define VI_STATUS_AA_MASK 0x000300 /* see AA modes */ +#define VI_STATUS_DITHER_FILTER_ENABLED 0x010000 + +// AA modes +#define AA_MODE_AA_RESAMPLE_ALWAYS_FETCH 0x000000 /* Always fetch lines */ +#define AA_MODE_AA_RESAMPLE 0x000100 /* Fetch extra line if needed */ +#define AA_MODE_RESAMPLE_ONLY 0x000200 +#define AA_MODE_NEITHER 0x000300 /* Replicate pixels, no interpolation */ + struct VIInfo { u32 width, widthPrev, height, real_height;