diff --git a/CHANGES b/CHANGES index a8121ee70..99e2f192a 100644 --- a/CHANGES +++ b/CHANGES @@ -91,8 +91,9 @@ Emulation fixes: - ARM: Partially fix LDM/STM writeback with empty register list - ARM: Fix stepping when events are pending - GBA DMA: Fix case where DMAs could get misaligned (fixes mgba.io/i/1092) - - GBA Video: Fix OpenGL renderer 512x512 backgrounds (fixes mgba.io/i/1572) - GBA Memory: Fix open bus from IWRAM (fixes mgba.io/i/1575) + - GBA Video: Fix OpenGL renderer 512x512 backgrounds (fixes mgba.io/i/1572) + - GBA Video: Fix BLDY for semitransparent sprite on non-target-2 backgrounds Other fixes: - 3DS: Fix screen darkening (fixes mgba.io/i/1562) - Core: Fix uninitialized memory issues with graphics caches diff --git a/cinema/gba/blend/obj-semitrans-brighten/baseline_0000.png b/cinema/gba/blend/obj-semitrans-brighten/baseline_0000.png new file mode 100644 index 000000000..65cca4f0a Binary files /dev/null and b/cinema/gba/blend/obj-semitrans-brighten/baseline_0000.png differ diff --git a/cinema/gba/blend/obj-semitrans-brighten/baseline_0001.png b/cinema/gba/blend/obj-semitrans-brighten/baseline_0001.png new file mode 100644 index 000000000..65cca4f0a Binary files /dev/null and b/cinema/gba/blend/obj-semitrans-brighten/baseline_0001.png differ diff --git a/cinema/gba/blend/obj-semitrans-brighten/test.mvl b/cinema/gba/blend/obj-semitrans-brighten/test.mvl new file mode 100644 index 000000000..966724a7d Binary files /dev/null and b/cinema/gba/blend/obj-semitrans-brighten/test.mvl differ diff --git a/include/mgba/internal/gba/renderers/video-software.h b/include/mgba/internal/gba/renderers/video-software.h index b15dc47b4..59c2a7ce8 100644 --- a/include/mgba/internal/gba/renderers/video-software.h +++ b/include/mgba/internal/gba/renderers/video-software.h @@ -131,7 +131,8 @@ struct GBAVideoSoftwareRenderer { struct GBAVideoSoftwareBackground bg[4]; - int oamDirty; + bool forceTarget1; + bool oamDirty; int oamMax; struct GBAVideoRendererSprite sprites[128]; int16_t objOffsetX; diff --git a/src/gba/renderers/software-obj.c b/src/gba/renderers/software-obj.c index d638dd332..cbc050fc8 100644 --- a/src/gba/renderers/software-obj.c +++ b/src/gba/renderers/software-obj.c @@ -165,7 +165,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re } int objwinSlowPath = GBARegisterDISPCNTIsObjwinEnable(renderer->dispcnt) && GBAWindowControlGetBlendEnable(renderer->objwin.packed) != GBAWindowControlIsBlendEnable(renderer->currentWindow.packed); - int variant = renderer->target1Obj && + int variant = (renderer->target1Obj || GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_SEMITRANSPARENT) && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); if (GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_SEMITRANSPARENT || objwinSlowPath) { @@ -175,6 +175,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re target2 |= renderer->bg[2].target2; target2 |= renderer->bg[3].target2; if (target2) { + renderer->forceTarget1 = true; flags |= FLAG_REBLEND; variant = 0; } else { diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index bd47ad2b2..6be917d93 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -592,6 +592,7 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render _updatePalettes(softwareRenderer); softwareRenderer->blendDirty = false; } + softwareRenderer->forceTarget1 = false; int w; x = 0; @@ -622,7 +623,7 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render _drawScanline(softwareRenderer, y); - if (softwareRenderer->target2Bd) { + if (softwareRenderer->forceTarget1 && softwareRenderer->target2Bd) { x = 0; for (w = 0; w < softwareRenderer->nWindows; ++w) { uint32_t backdrop = 0; @@ -640,9 +641,9 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render } } } - if (softwareRenderer->target1Obj && (softwareRenderer->blendEffect == BLEND_DARKEN || softwareRenderer->blendEffect == BLEND_BRIGHTEN)) { + if (softwareRenderer->forceTarget1 && (softwareRenderer->blendEffect == BLEND_DARKEN || softwareRenderer->blendEffect == BLEND_BRIGHTEN)) { x = 0; - uint32_t mask = FLAG_REBLEND | FLAG_TARGET_1 | FLAG_IS_BACKGROUND; + uint32_t mask = FLAG_REBLEND | FLAG_IS_BACKGROUND; uint32_t match = FLAG_REBLEND; if (GBARegisterDISPCNTIsObjwinEnable(softwareRenderer->dispcnt)) { mask |= FLAG_OBJWIN;