From 91515b6b1077e863ea9265022340cd9ff4874bcf Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sat, 23 May 2020 01:55:40 +0300 Subject: [PATCH] core/gpu: Ignore top bit when reading colors from the palette According to CowBite, the top bit is supposed to be ignored. fixes #99 Former-commit-id: 28a43311726f9ce5ef26c77687fedecc33b286e0 Former-commit-id: df0b025ed6d51e36bcffd4c91250858167b42f40 --- rustboyadvance-core/src/gpu/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rustboyadvance-core/src/gpu/mod.rs b/rustboyadvance-core/src/gpu/mod.rs index 7854893..1302560 100644 --- a/rustboyadvance-core/src/gpu/mod.rs +++ b/rustboyadvance-core/src/gpu/mod.rs @@ -340,14 +340,14 @@ impl Gpu { } #[inline(always)] - pub fn get_palette_color(&self, index: u32, palette_index: u32, offset: u32) -> Rgb15 { - if index == 0 || (palette_index != 0 && index % 16 == 0) { + pub fn get_palette_color(&self, index: u32, palette_bank: u32, offset: u32) -> Rgb15 { + if index == 0 || (palette_bank != 0 && index % 16 == 0) { return Rgb15::TRANSPARENT; } - Rgb15( - self.palette_ram - .read_16(offset + 2 * index + 0x20 * palette_index), - ) + let value = self.palette_ram.read_16(offset + 2 * index + 0x20 * palette_bank); + + // top bit is ignored + Rgb15(value & 0x7FFF) } #[inline]