all repos — mgba @ 1f0f943526b06790aaf9dfaffa9538f21988af19

mGBA Game Boy Advance Emulator

GB Video: Clear screen when LCDC is off
Jeffrey Pfau jeffrey@endrift.com
Wed, 21 Sep 2016 14:34:50 -0700
commit

1f0f943526b06790aaf9dfaffa9538f21988af19

parent

bf9017c89bc8a008a3afbd68d58851fb10f1f473

2 files changed, 30 insertions(+), 8 deletions(-)

jump to
M CHANGESCHANGES

@@ -8,6 +8,7 @@ - Qt: Fix saving overrides

- FFmpeg: Fix encoding AAC - GB Video: Fix video frames getting missed when LCDC is off - LR35902: Fix events running with the wrong cycle active + - GB Video: Clear screen when LCDC is off Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -21,6 +21,31 @@

static void GBVideoSoftwareRendererDrawBackground(struct GBVideoSoftwareRenderer* renderer, uint8_t* maps, int startX, int endX, int sx, int sy); static void GBVideoSoftwareRendererDrawObj(struct GBVideoSoftwareRenderer* renderer, struct GBObj* obj, int startX, int endX, int y); +static void _clearScreen(struct GBVideoSoftwareRenderer* renderer) { + // TODO: Dynamic from dmgPalette +#ifdef COLOR_16_BIT +#ifdef COLOR_5_6_5 + color_t palette0 = 0xFFDF; +#else + color_t palette0 = 0x7FFF; +#endif +#else + color_t palette0 = 0xF8F8F8; +#endif + + int y; + for (y = 0; y < GB_VIDEO_VERTICAL_PIXELS; ++y) { + color_t* row = &renderer->outputBuffer[renderer->outputBufferStride * y]; + int x; + for (x = 0; x < GB_VIDEO_HORIZONTAL_PIXELS; x += 4) { + row[x + 0] = palette0; + row[x + 1] = palette0; + row[x + 2] = palette0; + row[x + 3] = palette0; + } + } +} + void GBVideoSoftwareRendererCreate(struct GBVideoSoftwareRenderer* renderer) { renderer->d.init = GBVideoSoftwareRendererInit; renderer->d.deinit = GBVideoSoftwareRendererDeinit;

@@ -44,14 +69,7 @@ softwareRenderer->currentWy = 0;

softwareRenderer->wx = 0; softwareRenderer->model = model; - int y; - for (y = 0; y < GB_VIDEO_VERTICAL_PIXELS; ++y) { - color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; - int x; - for (x = 0; x < GB_VIDEO_HORIZONTAL_PIXELS; ++x) { - row[x] = softwareRenderer->palette[0]; - } - } + _clearScreen(softwareRenderer); } static void GBVideoSoftwareRendererDeinit(struct GBVideoRenderer* renderer) {

@@ -63,6 +81,9 @@ static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer* renderer, uint16_t address, uint8_t value) {

struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer; switch (address) { case REG_LCDC: + if (GBRegisterLCDCIsEnable(softwareRenderer->lcdc) && !GBRegisterLCDCIsEnable(value)) { + _clearScreen(softwareRenderer); + } softwareRenderer->lcdc = value; break; case REG_SCY: