From f3e049b7d7fdcb5c0693c17001e27956efa15d50 Mon Sep 17 00:00:00 2001 From: Matthew Berry Date: Tue, 2 Mar 2021 00:01:08 -0800 Subject: [PATCH] don't crash on unmapped apu reads --- src/crab/apu.cr | 2 +- src/crab/apu/channel1.cr | 2 +- src/crab/apu/channel2.cr | 2 +- src/crab/apu/channel3.cr | 2 +- src/crab/apu/channel4.cr | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/crab/apu.cr b/src/crab/apu.cr index e3727e4..59bfb70 100644 --- a/src/crab/apu.cr +++ b/src/crab/apu.cr @@ -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 diff --git a/src/crab/apu/channel1.cr b/src/crab/apu/channel1.cr index 040e118..4405045 100644 --- a/src/crab/apu/channel1.cr +++ b/src/crab/apu/channel1.cr @@ -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 diff --git a/src/crab/apu/channel2.cr b/src/crab/apu/channel2.cr index ca51a14..a2e1a49 100644 --- a/src/crab/apu/channel2.cr +++ b/src/crab/apu/channel2.cr @@ -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 diff --git a/src/crab/apu/channel3.cr b/src/crab/apu/channel3.cr index 33b3252..87c85d9 100644 --- a/src/crab/apu/channel3.cr +++ b/src/crab/apu/channel3.cr @@ -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 diff --git a/src/crab/apu/channel4.cr b/src/crab/apu/channel4.cr index adecd99..65f5a4e 100644 --- a/src/crab/apu/channel4.cr +++ b/src/crab/apu/channel4.cr @@ -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