make io register byte accesses respect non-writable bits (FIX SUPERSTAR SAGA)

The fact that this fixes Supestar Saga is both happy and sad for me. I spent so
much time trying to fix that game before, but I didn't even mean to fix it this
time. Either way, it works now. Finally.
This commit is contained in:
Matthew Berry 2022-08-17 17:06:57 -07:00
parent 7c45654b16
commit 73712b10ba

View file

@ -2,26 +2,26 @@ module GBA
module Reg
module Base16
def read_byte(byte_num : Int) : Byte
(@value >> (8 * byte_num)).to_u8!
(value >> (8 * byte_num)).to_u8!
end
def write_byte(byte_num : Int, byte : Byte) : Byte
shift = 8 * byte_num
mask = ~(0xFF_u16 << shift)
@value = (@value & mask) | byte.to_u16 << shift
self.value = (@value & mask) | byte.to_u16 << shift
byte
end
end
module Base32
def read_byte(byte_num : Int) : Byte
(@value >> (8 * byte_num)).to_u8!
(value >> (8 * byte_num)).to_u8!
end
def write_byte(byte_num : Int, byte : Byte) : Byte
shift = 8 * byte_num
mask = ~(0xFF_u32 << shift)
@value = (@value & mask) | byte.to_u32 << shift
self.value = (@value & mask) | byte.to_u32 << shift
byte
end
end