all repos — mgba @ 9064cb107be54ba78c0652e88d2eee5608754725

mGBA Game Boy Advance Emulator

Qt: Add background and window toggling to frame viewer
Vicki Pfau vi@endrift.com
Wed, 21 Oct 2020 22:03:29 -0700
commit

9064cb107be54ba78c0652e88d2eee5608754725

parent

9dfa8f753ff466e92be2052db771dff0ae9df240

2 files changed, 27 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/FrameView.cppsrc/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.hsrc/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; };