From 9064cb107be54ba78c0652e88d2eee5608754725 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 21 Oct 2020 22:03:29 -0700 Subject: [PATCH] Qt: Add background and window toggling to frame viewer --- src/platform/qt/FrameView.cpp | 26 ++++++++++++++++++++++++++ src/platform/qt/FrameView.h | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/platform/qt/FrameView.cpp b/src/platform/qt/FrameView.cpp index 9e32d692d..3d33a97de 100644 --- a/src/platform/qt/FrameView.cpp +++ b/src/platform/qt/FrameView.cpp @@ -24,6 +24,7 @@ #endif #ifdef M_CORE_GB #include +#include #include #endif @@ -286,6 +287,9 @@ void FrameView::updateTilesGB(bool) { m_queue.clear(); { CoreController::Interrupter interrupter(m_controller); + uint8_t* io = static_cast(m_controller->thread()->core->board)->memory.io; + GBRegisterLCDC lcdc = io[GB_REG_LCDC]; + for (int sprite = 0; sprite < 40; ++sprite) { ObjInfo info; lookupObj(sprite, &info); @@ -312,6 +316,22 @@ void FrameView::updateTilesGB(bool) { } } + if (GBRegisterLCDCIsWindow(lcdc)) { + m_queue.append({ + { LayerId::WINDOW }, + !m_disabled.contains({ LayerId::WINDOW }), + {}, + {}, {0, 0}, false, false + }); + } + + m_queue.append({ + { LayerId::BACKGROUND }, + !m_disabled.contains({ LayerId::BACKGROUND }), + {}, + {}, {0, 0}, false, false + }); + updateRendered(); } invalidateQueue(m_controller->screenDimensions()); @@ -328,6 +348,12 @@ void FrameView::injectGB() { mVideoLoggerInjectOAM(logger, layer.id.index << 2, 0); } break; + case LayerId::BACKGROUND: + m_vl->enableVideoLayer(m_vl, GB_LAYER_BACKGROUND, layer.enabled); + break; + case LayerId::WINDOW: + m_vl->enableVideoLayer(m_vl, GB_LAYER_WINDOW, layer.enabled); + break; } } } diff --git a/src/platform/qt/FrameView.h b/src/platform/qt/FrameView.h index 5074a42bf..96794005b 100644 --- a/src/platform/qt/FrameView.h +++ b/src/platform/qt/FrameView.h @@ -72,7 +72,7 @@ private: int index = -1; bool operator!=(const LayerId& other) const { return other.type != type || other.index != index; } - operator uint() const { return (type << 8) | index; } + operator uint() const { return (type << 12) | (index & 0xFFF); } QString readable() const; };