diff --git a/src/bus.rs b/src/bus.rs index da630bf..c1255e4 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -238,7 +238,7 @@ impl BusIo for Bus { 0x24 => self.snd.ctrl.channel.into(), 0x25 => self.snd.ctrl.output.into(), 0x26 => self.snd.ctrl.status.into(), - 0x30..=0x3F => self.snd.ch3.ram[addr as usize - 0xFF30], + 0x30..=0x3F => self.snd.ch3.wave_ram[addr as usize - 0xFF30], 0x40 => self.ppu.ctrl.into(), 0x41 => self.ppu.stat.into(), 0x42 => self.ppu.pos.scroll_y, @@ -355,7 +355,7 @@ impl BusIo for Bus { 0x24 => self.snd.ctrl.channel = byte.into(), 0x25 => self.snd.ctrl.output = byte.into(), 0x26 => self.snd.ctrl.status = byte.into(), // FIXME: Should we control which bytes are written to here? - 0x30..=0x3F => self.snd.ch3.ram[addr as usize - 0xFF30] = byte, + 0x30..=0x3F => self.snd.ch3.wave_ram[addr as usize - 0xFF30] = byte, 0x40 => self.ppu.ctrl = byte.into(), 0x41 => self.ppu.stat.update(byte), 0x42 => self.ppu.pos.scroll_y = byte, diff --git a/src/sound.rs b/src/sound.rs index f4545f8..f85a143 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -645,7 +645,7 @@ pub(crate) struct Channel3 { pub(crate) freq_lo: u8, /// 0xFF1E | NR34 - Channel 3 Frequency high freq_hi: FrequencyHigh, - pub(crate) ram: [u8; WAVE_PATTERN_RAM_LEN], + pub(crate) wave_ram: [u8; WAVE_PATTERN_RAM_LEN], // Length Functionality length_timer: u16, @@ -713,6 +713,19 @@ enum Channel3Volume { Quarter = 3, } +impl Channel3Volume { + pub fn shift_count(&self) -> u8 { + use Channel3Volume::*; + + match *self { + Mute => 4, + Full => 0, + Half => 1, + Quarter => 2, + } + } +} + impl Default for Channel3Volume { fn default() -> Self { Self::Mute