From 08bda05d52cd4155f06ff959b3b88f5e6a7df155 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Thu, 30 Apr 2020 08:41:57 +0300 Subject: [PATCH] gpu: Fix blending problems for light/darken This issue rised in Pokemon Emerald main menu, where all the menu items are highlighted and not just the selected one. Former-commit-id: 503652ad5d8fccb37603a1c5df670632e02b2f14 --- rustboyadvance-core/src/core/gpu/sfx.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/rustboyadvance-core/src/core/gpu/sfx.rs b/rustboyadvance-core/src/core/gpu/sfx.rs index f05b902..3eca48c 100644 --- a/rustboyadvance-core/src/core/gpu/sfx.rs +++ b/rustboyadvance-core/src/core/gpu/sfx.rs @@ -200,23 +200,21 @@ impl Gpu { if !(top_layer_flags.contains_render_layer(&layers[0]) || obj_sfx) { break 'blend; } - if layers.len() > 1 && !(bot_layer_flags.contains_render_layer(&layers[1])) { - break 'blend; - } - let mut blend_mode = self.bldcnt.mode(); - // push another backdrop layer in case there is only 1 layer - // unsafe { layers.push_unchecked(RenderLayer::backdrop(backdrop_color)); } // if this is object alpha blending, ensure that the bottom layer contains a color to blend with - if obj_sfx && layers.len() > 1 && bot_layer_flags.contains_render_layer(&layers[1]) - { - blend_mode = BldMode::BldAlpha; - } + let blend_mode = if obj_sfx && layers.len() > 1 && bot_layer_flags.contains_render_layer(&layers[1]) { + BldMode::BldAlpha + } else { + self.bldcnt.mode() + }; match blend_mode { BldMode::BldAlpha => { let bot_pixel = if layers.len() > 1 { + if !(bot_layer_flags.contains_render_layer(&layers[1])) { + break 'blend; + } layers[1].pixel //self.layer_to_pixel(x, y, &layers[1]) } else { backdrop_color