Qt: Add background and window toggling to frame viewer
Vicki Pfau vi@endrift.com
Wed, 21 Oct 2020 22:03:29 -0700
2 files changed,
27 insertions(+),
1 deletions(-)
M
src/platform/qt/FrameView.cpp
→
src/platform/qt/FrameView.cpp
@@ -24,6 +24,7 @@ #include <mgba/internal/gba/video.h>
#endif #ifdef M_CORE_GB #include <mgba/internal/gb/gb.h> +#include <mgba/internal/gb/io.h> #include <mgba/internal/gb/memory.h> #endif@@ -286,6 +287,9 @@ }
m_queue.clear(); { CoreController::Interrupter interrupter(m_controller); + uint8_t* io = static_cast<GB*>(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 @@ m_queue.back().mask = QRegion(0, 0, m_queue.back().image.width(), m_queue.back().image.height());
} } + 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());@@ -327,6 +347,12 @@ case LayerId::SPRITE:
if (!layer.enabled) { 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; } }
M
src/platform/qt/FrameView.h
→
src/platform/qt/FrameView.h
@@ -72,7 +72,7 @@ } type = NONE;
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; };