don't crash on unmapped apu reads

This commit is contained in:
Matthew Berry 2021-03-02 00:01:08 -08:00
parent c56a26994e
commit f3e049b7d7
5 changed files with 5 additions and 5 deletions

View file

@ -163,7 +163,7 @@ class APU
when 0x85 then 0_u8 # unused
when 0x88 then @soundbias.value.to_u8!
when 0x89 then (@soundbias.value >> 8).to_u8!
else abort "Unmapped APU read ~ addr:#{hex_str io_addr.to_u8}"
else puts "Unmapped APU read ~ addr:#{hex_str io_addr.to_u8}".colorize.fore(:red); 0_u8 # todo: open bus
end
end

View file

@ -83,7 +83,7 @@ class Channel1 < VolumeEnvelopeChannel
when 0x63 then read_NRx2
when 0x64 then 0xFF_u8 # write-only
when 0x65 then 0xBF_u8 | (@length_enable ? 0x40 : 0)
else raise "Reading from invalid Channel1 register: #{hex_str index.to_u16}"
else puts "Reading from invalid Channel1 register: #{hex_str index.to_u16}".colorize.fore(:red); 0_u8 # todo: open bus
end
end

View file

@ -48,7 +48,7 @@ class Channel2 < VolumeEnvelopeChannel
when 0x69 then read_NRx2
when 0x6C then 0xFF_u8 # write-only
when 0x6D then 0xBF_u8 | (@length_enable ? 0x40 : 0)
else raise "Reading from invalid Channel2 register: #{hex_str index.to_u16}"
else puts "Reading from invalid Channel2 register: #{hex_str index.to_u16}".colorize.fore(:red); 0_u8 # todo: open bus
end
end

View file

@ -61,7 +61,7 @@ class Channel3 < SoundChannel
else
@wave_ram[@wave_ram_bank][index - WAVE_RAM_RANGE.begin]
end
else raise "Reading from invalid Channel3 register: #{hex_str index.to_u16}"
else puts "Reading from invalid Channel3 register: #{hex_str index.to_u16}".colorize.fore(:red); 0_u8 # todo: open bus
end.to_u8
end

View file

@ -48,7 +48,7 @@ class Channel4 < VolumeEnvelopeChannel
when 0x79 then read_NRx2
when 0x7C then @clock_shift << 4 | @width_mode << 3 | @divisor_code
when 0x7D then 0xBF | (@length_enable ? 0x40 : 0)
else raise "Reading from invalid Channel4 register: #{hex_str index.to_u16}"
else puts "Reading from invalid Channel4 register: #{hex_str index.to_u16}".colorize.fore(:red); 0_u8 # todo: open bus
end.to_u8
end