From db3be711aef592a4e1ec1475f663d10a843b1731 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Sat, 16 May 2020 11:30:16 +0200 Subject: [PATCH] core: Clamp BLDY to 0..16 As per the GBATEK docs. Fixes the fadeout animations in Ice Age. Former-commit-id: 0bc54ab594ba19347a4b6d1b681ccf37da4d7910 Former-commit-id: 33b732e7f990c312bf92bcc21797df35b3d2ce56 --- rustboyadvance-core/src/iodev.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rustboyadvance-core/src/iodev.rs b/rustboyadvance-core/src/iodev.rs index 120e340..3f20ce2 100644 --- a/rustboyadvance-core/src/iodev.rs +++ b/rustboyadvance-core/src/iodev.rs @@ -1,3 +1,5 @@ +use std::cmp; + use super::dma::DmaController; use super::gpu::regs::WindowFlags; use super::gpu::*; @@ -216,7 +218,7 @@ impl Bus for IoDevices { REG_MOSAIC => io.gpu.mosaic.0 = value, REG_BLDCNT => io.gpu.bldcnt.0 = value, REG_BLDALPHA => io.gpu.bldalpha.0 = value, - REG_BLDY => io.gpu.bldy = value & 0b11111, + REG_BLDY => io.gpu.bldy = cmp::min(value & 0b11111, 16), REG_IME => io.intc.interrupt_master_enable = value != 0, REG_IE => io.intc.interrupt_enable.0 = value,