From 7ef0c5074c7064e0a3509d8d9ecd03061f1abf07 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 29 Oct 2019 19:32:52 -0700 Subject: [PATCH] 3DS: Fix screen darkening (fixes #1562) --- CHANGES | 1 + src/platform/3ds/main.c | 79 ++++++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/CHANGES b/CHANGES index a5de79b90..d0965c4fc 100644 --- a/CHANGES +++ b/CHANGES @@ -87,6 +87,7 @@ Misc: - Vita: L2/R2 and L3/R3 can now be mapped on PSTV (fixes mgba.io/i/1292) Changes from beta 1: Other fixes: + - 3DS: Fix screen darkening (fixes mgba.io/i/1562) - Vita: Fix analog controls (fixes mgba.io/i/1554) 0.8 beta 1: (2019-10-20) diff --git a/src/platform/3ds/main.c b/src/platform/3ds/main.c index f5af6d50b..a89dfcc8b 100644 --- a/src/platform/3ds/main.c +++ b/src/platform/3ds/main.c @@ -417,6 +417,46 @@ static void _gameUnloaded(struct mGUIRunner* runner) { } } +static u32 _setupTex(int out, bool faded) { + ctrActivateTexture(&outputTexture[out]); + u32 color; + if (!faded) { + color = 0xFFFFFFFF; + switch (darkenMode) { + case DM_NATIVE: + case DM_MAX: + break; + case DM_MULT_SCALE_BIAS: + ctrTextureBias(0x070707); + // Fall through + case DM_MULT_SCALE: + color = 0xFF707070; + // Fall through + case DM_MULT: + ctrTextureMultiply(); + break; + } + } else { + color = 0xFF484848; + switch (darkenMode) { + case DM_NATIVE: + case DM_MAX: + break; + case DM_MULT_SCALE_BIAS: + ctrTextureBias(0x030303); + // Fall through + case DM_MULT_SCALE: + color = 0xFF303030; + // Fall through + case DM_MULT: + ctrTextureMultiply(); + break; + } + + } + return color; +} + static void _drawTex(struct mCore* core, bool faded, bool both) { unsigned screen_w, screen_h; switch (screenMode) { @@ -485,45 +525,10 @@ static void _drawTex(struct mCore* core, bool faded, bool both) { break; } - u32 color; - if (!faded) { - color = 0xFFFFFFFF; - switch (darkenMode) { - case DM_NATIVE: - case DM_MAX: - break; - case DM_MULT_SCALE_BIAS: - ctrTextureBias(0x070707); - // Fall through - case DM_MULT_SCALE: - color = 0xFF707070; - // Fall through - case DM_MULT: - ctrTextureMultiply(); - break; - } - } else { - color = 0xFF484848; - switch (darkenMode) { - case DM_NATIVE: - case DM_MAX: - break; - case DM_MULT_SCALE_BIAS: - ctrTextureBias(0x030303); - // Fall through - case DM_MULT_SCALE: - color = 0xFF303030; - // Fall through - case DM_MULT: - ctrTextureMultiply(); - break; - } - - } - ctrActivateTexture(&outputTexture[activeOutputTexture]); + uint32_t color = _setupTex(activeOutputTexture, faded); ctrAddRectEx(color, x, y, w, h, 0, 0, corew, coreh, 0); if (both) { - ctrActivateTexture(&outputTexture[activeOutputTexture ^ 1]); + color = _setupTex(activeOutputTexture ^ 1, faded); ctrAddRectEx(color & 0x7FFFFFFF, x, y, w, h, 0, 0, corew, coreh, 0); } ctrFlushBatch();