From 1d2d95072919cb1450936c659f7593ebc21c899c Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sat, 24 Aug 2019 00:33:01 +0300 Subject: [PATCH] Fix IoRegs::write_8 Former-commit-id: 9877e7f42fefafb71dd319287e01d55926d4d12c --- src/core/gpu/{blend.rs => sfx.rs} | 0 src/core/ioregs.rs | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) rename src/core/gpu/{blend.rs => sfx.rs} (100%) diff --git a/src/core/gpu/blend.rs b/src/core/gpu/sfx.rs similarity index 100% rename from src/core/gpu/blend.rs rename to src/core/gpu/sfx.rs diff --git a/src/core/ioregs.rs b/src/core/ioregs.rs index 193fbbc..abf1edc 100644 --- a/src/core/ioregs.rs +++ b/src/core/ioregs.rs @@ -286,8 +286,18 @@ impl Bus for IoRegs { } fn write_8(&mut self, addr: Addr, value: u8) { - let t = self.read_16(addr); - self.write_16(addr, (t & 0xff) | ((value as u16) << 8)); + if addr & 1 != 0 { + let addr = addr & !1; + let t = self.read_16(addr); + let upper = (value as u16); + let lower = t & 0xff; + self.write_16(addr, (upper << 8) | lower); + } else { + let t = self.read_16(addr); + let upper = t << 8; + let lower = (value as u16); + self.write_16(addr, (upper << 8) | lower); + } } }