Fix IoRegs::write_8

Former-commit-id: 9877e7f42fefafb71dd319287e01d55926d4d12c
This commit is contained in:
Michel Heily 2019-08-24 00:33:01 +03:00
parent f40ee148ea
commit 1d2d950729
2 changed files with 12 additions and 2 deletions

View file

@ -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);
}
}
}