mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
sram word and halfword reads
This commit is contained in:
parent
625b79fc35
commit
a26a170284
2 changed files with 10 additions and 2 deletions
|
@ -43,7 +43,7 @@ class Bus
|
||||||
when 0x8, 0x9,
|
when 0x8, 0x9,
|
||||||
0xA, 0xB,
|
0xA, 0xB,
|
||||||
0xC, 0xD then (@gba.cartridge.rom.to_unsafe + (index & 0x01FFFFFF)).as(HalfWord*).value
|
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}"
|
else abort "Unmapped read: #{hex_str index.to_u32}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ class Bus
|
||||||
when 0x8, 0x9,
|
when 0x8, 0x9,
|
||||||
0xA, 0xB,
|
0xA, 0xB,
|
||||||
0xC, 0xD then (@gba.cartridge.rom.to_unsafe + (index & 0x01FFFFFF)).as(Word*).value
|
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}"
|
else abort "Unmapped read: #{hex_str index.to_u32}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,6 +49,14 @@ abstract class Storage
|
||||||
|
|
||||||
abstract def [](index : Int) : Byte
|
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
|
abstract def []=(index : Int, value : Byte) : Nil
|
||||||
|
|
||||||
private def self.find_type(file : File) : Type?
|
private def self.find_type(file : File) : Type?
|
||||||
|
|
Loading…
Add table
Reference in a new issue