From 8533f01be57d725e9c8e779869761f8f5d859b2e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 5 Apr 2015 01:25:25 -0700 Subject: [PATCH] GBA Video: Ability to hide individual background layers, or OBJs --- CHANGES | 2 ++ src/gba/renderers/video-software.c | 18 +++++++++++++----- src/gba/video.h | 3 +++ src/platform/qt/Window.cpp | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 916258735..4aacbb2bb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ 0.3.0: (Future) +Features: + - Ability to hide individual background layers, or OBJs Bugfixes: - GBA: Fix timers not updating timing when writing to only the reload register - All: Fix sanitize-deb script not cleaning up after itself diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index eb8a1d193..54a409724 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -87,6 +87,12 @@ void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) { renderer->d.finishFrame = GBAVideoSoftwareRendererFinishFrame; renderer->d.getPixels = GBAVideoSoftwareRendererGetPixels; renderer->d.putPixels = GBAVideoSoftwareRendererPutPixels; + + renderer->d.disableBG[0] = false; + renderer->d.disableBG[1] = false; + renderer->d.disableBG[2] = false; + renderer->d.disableBG[3] = false; + renderer->d.disableOBJ = false; } static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) { @@ -522,6 +528,8 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render softwareRenderer->windows[0].control.packed = 0xFF; } + GBAVideoSoftwareRendererUpdateDISPCNT(softwareRenderer); + int w; x = 0; for (w = 0; w < softwareRenderer->nWindows; ++w) { @@ -599,10 +607,10 @@ static void GBAVideoSoftwareRendererPutPixels(struct GBAVideoRenderer* renderer, } static void GBAVideoSoftwareRendererUpdateDISPCNT(struct GBAVideoSoftwareRenderer* renderer) { - renderer->bg[0].enabled = GBARegisterDISPCNTGetBg0Enable(renderer->dispcnt); - renderer->bg[1].enabled = GBARegisterDISPCNTGetBg1Enable(renderer->dispcnt); - renderer->bg[2].enabled = GBARegisterDISPCNTGetBg2Enable(renderer->dispcnt); - renderer->bg[3].enabled = GBARegisterDISPCNTGetBg3Enable(renderer->dispcnt); + renderer->bg[0].enabled = GBARegisterDISPCNTGetBg0Enable(renderer->dispcnt) && !renderer->d.disableBG[0]; + renderer->bg[1].enabled = GBARegisterDISPCNTGetBg1Enable(renderer->dispcnt) && !renderer->d.disableBG[1]; + renderer->bg[2].enabled = GBARegisterDISPCNTGetBg2Enable(renderer->dispcnt) && !renderer->d.disableBG[2]; + renderer->bg[3].enabled = GBARegisterDISPCNTGetBg3Enable(renderer->dispcnt) && !renderer->d.disableBG[3]; } static void GBAVideoSoftwareRendererWriteBGCNT(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* bg, uint16_t value) { @@ -691,7 +699,7 @@ static void _drawScanline(struct GBAVideoSoftwareRenderer* renderer, int y) { int w; renderer->end = 0; int spriteLayers = 0; - if (GBARegisterDISPCNTIsObjEnable(renderer->dispcnt)) { + if (GBARegisterDISPCNTIsObjEnable(renderer->dispcnt) && !renderer->d.disableOBJ) { if (renderer->oamDirty) { _cleanOAM(renderer); } diff --git a/src/gba/video.h b/src/gba/video.h index b7648719e..774f8de99 100644 --- a/src/gba/video.h +++ b/src/gba/video.h @@ -167,6 +167,9 @@ struct GBAVideoRenderer { uint16_t* palette; uint16_t* vram; union GBAOAM* oam; + + bool disableBG[4]; + bool disableOBJ; }; struct GBAVideo { diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index b9f7fffb8..01e21d221 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -799,6 +799,25 @@ void Window::setupMenu(QMenuBar* menubar) { addControlledAction(avMenu, recordGIF, "recordGIF"); #endif + avMenu->addSeparator(); + QMenu* videoLayers = avMenu->addMenu(tr("Video layers")); + + for (int i = 0; i < 4; ++i) { + QAction* enableBg = new QAction(tr("Background %0").arg(i), videoLayers); + enableBg->setCheckable(true); + enableBg->setChecked(true); + connect(enableBg, &QAction::triggered, [this, i](bool enable) { m_controller->thread()->gba->video.renderer->disableBG[i] = !enable; }); + m_gameActions.append(enableBg); + addControlledAction(videoLayers, enableBg, QString("enableBG%0").arg(i)); + } + + QAction* enableObj = new QAction(tr("OBJ (sprites)"), videoLayers); + enableObj->setCheckable(true); + enableObj->setChecked(true); + connect(enableObj, &QAction::triggered, [this](bool enable) { m_controller->thread()->gba->video.renderer->disableOBJ = !enable; }); + m_gameActions.append(enableObj); + addControlledAction(videoLayers, enableObj, "enableOBJ"); + QMenu* toolsMenu = menubar->addMenu(tr("&Tools")); m_shortcutController->addMenu(toolsMenu); QAction* viewLogs = new QAction(tr("View &logs..."), toolsMenu);