From 3471148dd5b2e467134512602ded0f7f7716bb8b Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 1 Mar 2023 08:40:37 +1100 Subject: [PATCH] cleaner --- src/processor/memory/mmio/apu.rs | 17 ++++++++--------- src/processor/memory/mmio/apu/channels.rs | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/processor/memory/mmio/apu.rs b/src/processor/memory/mmio/apu.rs index 0001038..61e83e2 100644 --- a/src/processor/memory/mmio/apu.rs +++ b/src/processor/memory/mmio/apu.rs @@ -195,16 +195,15 @@ impl Apu { } pub fn get_register(&self, addr: Address) -> u8 { - if addr == 0xFF26 - || addr == 0xFF11 - || addr == 0xFF16 - || addr == 0xFF1B - || addr == 0xFF20 - || self.apu_enable - { + if self.apu_enable { self.make_register(addr) } else { - 0xFF + match addr { + 0xFF26 | 0xFF11 | 0xFF16 | 0xFF1B | 0xFF20 | 0xFF30..0xFF40 => { + self.make_register(addr) + } + _ => 0xFF, + } } } @@ -262,7 +261,7 @@ impl Apu { // not registers 0xFF15 | 0xFF1F | 0xFF27..0xFF30 => 0xFF, // wave ram - 0xFF30..0xFF40 => 0xFF, + 0xFF30..0xFF40 => self.channels.three.wave_ram.data[(addr - 0xFF30) as usize], 0x0..0xFF10 | 0xFF40..=0xFFFF => panic!("non-apu addr in apu"), } } diff --git a/src/processor/memory/mmio/apu/channels.rs b/src/processor/memory/mmio/apu/channels.rs index 301ce0d..39b0ef5 100644 --- a/src/processor/memory/mmio/apu/channels.rs +++ b/src/processor/memory/mmio/apu/channels.rs @@ -311,8 +311,8 @@ impl ShiftVolumePercent { } } -struct WaveRam { - data: [u8; 16], +pub(super) struct WaveRam { + pub(super) data: [u8; 16], } impl WaveRam { @@ -333,7 +333,7 @@ pub(super) struct WaveChannel { wavelength: u16, wave_timer: u16, wave_position: usize, - wave_ram: WaveRam, + pub(super) wave_ram: WaveRam, } impl WaveChannel {