all repos — mgba @ 3a8c5c4bf16e87f115aa7d960c53ba2f20cb1155

mGBA Game Boy Advance Emulator

GB: Video/audio channel enabling/disabling
Vicki Pfau vi@endrift.com
Fri, 21 Apr 2017 17:30:30 -0700
commit

3a8c5c4bf16e87f115aa7d960c53ba2f20cb1155

parent

2a7f642d4cba0e962520135a1dff47095dd78c75

4 files changed, 32 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -14,6 +14,7 @@ - Qt: German translation (by Lothar Serra Mari)

- Savestates now contain any RTC override data - Command line ability to override configuration values - Add option to allow preloading the entire ROM before running + - GB: Video/audio channel enabling/disabling Bugfixes: - LR35902: Fix core never exiting with certain event patterns - GB Timer: Improve DIV reset behavior
M include/mgba/internal/gb/video.hinclude/mgba/internal/gb/video.h

@@ -71,6 +71,10 @@

uint8_t* vram; union GBOAM* oam; struct mTileCache* cache; + + bool disableBG; + bool disableOBJ; + bool disableWIN; }; DECL_BITFIELD(GBRegisterLCDC, uint8_t);
M src/gb/core.csrc/gb/core.c

@@ -606,7 +606,19 @@ }

static void _GBCoreEnableVideoLayer(struct mCore* core, size_t id, bool enable) { struct GB* gb = core->board; - // TODO + switch (id) { + case 0: + gb->video.renderer->disableBG = !enable; + break; + case 1: + gb->video.renderer->disableOBJ = !enable; + break; + case 2: + gb->video.renderer->disableWIN = !enable; + break; + default: + break; + } } static void _GBCoreEnableAudioChannel(struct mCore* core, size_t id, bool enable) {
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -49,6 +49,10 @@ renderer->d.finishFrame = GBVideoSoftwareRendererFinishFrame;

renderer->d.getPixels = GBVideoSoftwareRendererGetPixels; renderer->d.putPixels = GBVideoSoftwareRendererPutPixels; + renderer->d.disableBG = false; + renderer->d.disableOBJ = false; + renderer->d.disableWIN = false; + renderer->temporaryBuffer = 0; }

@@ -128,9 +132,12 @@ uint8_t* maps = &softwareRenderer->d.vram[GB_BASE_MAP];

if (GBRegisterLCDCIsTileMap(softwareRenderer->lcdc)) { maps += GB_SIZE_MAP; } + if (softwareRenderer->d.disableBG) { + memset(&softwareRenderer->row[startX], 0, endX - startX); + } if (GBRegisterLCDCIsBgEnable(softwareRenderer->lcdc) || softwareRenderer->model >= GB_MODEL_CGB) { if (GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && softwareRenderer->wy <= y && endX >= softwareRenderer->wx - 7) { - if (softwareRenderer->wx - 7 > 0) { + if (softwareRenderer->wx - 7 > 0 && !softwareRenderer->d.disableBG) { GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, startX, softwareRenderer->wx - 7, softwareRenderer->scx, softwareRenderer->scy + y); }

@@ -138,15 +145,17 @@ maps = &softwareRenderer->d.vram[GB_BASE_MAP];

if (GBRegisterLCDCIsWindowTileMap(softwareRenderer->lcdc)) { maps += GB_SIZE_MAP; } - GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, softwareRenderer->wx - 7, endX, 7 - softwareRenderer->wx, softwareRenderer->currentWy); - } else { + if (!softwareRenderer->d.disableWIN) { + GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, softwareRenderer->wx - 7, endX, 7 - softwareRenderer->wx, softwareRenderer->currentWy); + } + } else if (!softwareRenderer->d.disableBG) { GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, startX, endX, softwareRenderer->scx, softwareRenderer->scy + y); } - } else { + } else if (!softwareRenderer->d.disableBG) { memset(&softwareRenderer->row[startX], 0, endX - startX); } - if (GBRegisterLCDCIsObjEnable(softwareRenderer->lcdc)) { + if (GBRegisterLCDCIsObjEnable(softwareRenderer->lcdc) && !softwareRenderer->d.disableOBJ) { size_t i; for (i = 0; i < oamMax; ++i) { GBVideoSoftwareRendererDrawObj(softwareRenderer, &obj[i], startX, endX, y);