stop crashing on attempted open bus reads

This commit is contained in:
Matthew Berry 2021-02-28 17:46:30 -08:00
parent 893ab68622
commit dd2bbc20c1
2 changed files with 4 additions and 1 deletions

View file

@ -10,6 +10,7 @@ class Bus
def [](index : Int) : Byte
case bits(index, 24..27)
when 0x0 then @bios[index & 0x3FFF]
when 0x1 then 0_u8 # todo: open bus
when 0x2 then @wram_board[index & 0x3FFFF]
when 0x3 then @wram_chip[index & 0x7FFF]
when 0x4 then @gba.mmio[index]
@ -31,6 +32,7 @@ class Bus
index &= ~1
case bits(index, 24..27)
when 0x0 then (@bios.to_unsafe + (index & 0x3FFF)).as(HalfWord*).value
when 0x1 then 0_u16 # todo: open bus
when 0x2 then (@wram_board.to_unsafe + (index & 0x3FFFF)).as(HalfWord*).value
when 0x3 then (@wram_chip.to_unsafe + (index & 0x7FFF)).as(HalfWord*).value
when 0x4 then read_half_slow(index)
@ -69,6 +71,7 @@ class Bus
index &= ~3
case bits(index, 24..27)
when 0x0 then (@bios.to_unsafe + (index & 0x3FFF)).as(Word*).value
when 0x1 then 0_u32 # todo: open bus
when 0x2 then (@wram_board.to_unsafe + (index & 0x3FFFF)).as(Word*).value
when 0x3 then (@wram_chip.to_unsafe + (index & 0x7FFF)).as(Word*).value
when 0x4 then read_word_slow(index)

View file

@ -408,7 +408,7 @@ class PPU
when 0x053 then 0xFF_u8 & @bldalpha.value >> 8
when 0x054 then 0xFF_u8 & @bldy.value
when 0x055 then 0xFF_u8 & @bldy.value >> 8
else abort "Unmapped PPU read ~ addr:#{hex_str io_addr.to_u8}"
else log "Unmapped PPU read ~ addr:#{hex_str io_addr.to_u8}"; 0_u8 # todo: open bus
end
end