sram word and halfword reads

This commit is contained in:
Matthew Berry 2021-02-26 21:39:49 -08:00
parent 625b79fc35
commit a26a170284
2 changed files with 10 additions and 2 deletions

View file

@ -43,7 +43,7 @@ class Bus
when 0x8, 0x9,
0xA, 0xB,
0xC, 0xD then (@gba.cartridge.rom.to_unsafe + (index & 0x01FFFFFF)).as(HalfWord*).value
when 0xE, 0xF then read_half_slow(index)
when 0xE, 0xF then @gba.storage.read_half(index)
else abort "Unmapped read: #{hex_str index.to_u32}"
end
end
@ -81,7 +81,7 @@ class Bus
when 0x8, 0x9,
0xA, 0xB,
0xC, 0xD then (@gba.cartridge.rom.to_unsafe + (index & 0x01FFFFFF)).as(Word*).value
when 0xE, 0xF then read_word_slow(index)
when 0xE, 0xF then @gba.storage.read_word(index)
else abort "Unmapped read: #{hex_str index.to_u32}"
end
end

View file

@ -49,6 +49,14 @@ abstract class Storage
abstract def [](index : Int) : Byte
def read_half(index : Int) : HalfWord
0x0101_u16 * self[index & ~1]
end
def read_word(index : Int) : Word
0x01010101_u32 * self[index & ~3]
end
abstract def []=(index : Int, value : Byte) : Nil
private def self.find_type(file : File) : Type?