diff --git a/src/bus.rs b/src/bus.rs index 607abe5..a2420d0 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -20,7 +20,7 @@ pub struct Bus { var_ram: VariableWorkRam, timer: Timer, int: Interrupt, - sound: Sound, + snd: Sound, high_ram: HighRam, serial: Serial, pub joypad: Joypad, @@ -36,7 +36,7 @@ impl Default for Bus { var_ram: Default::default(), timer: Default::default(), int: Default::default(), - sound: Default::default(), + snd: Default::default(), high_ram: Default::default(), serial: Default::default(), joypad: Default::default(), @@ -69,7 +69,7 @@ impl Bus { pub(crate) fn clock(&mut self) { self.ppu.clock(); self.timer.clock(); - self.sound.clock(); + self.snd.clock(); self.clock_dma(); } @@ -220,21 +220,21 @@ impl BusIo for Bus { 0x06 => self.timer.modulo, 0x07 => self.timer.ctrl.into(), 0x0F => self.interrupt_flag().into(), - 0x10 => self.sound.ch1.sweep.into(), - 0x11 => self.sound.ch1.duty.into(), - 0x12 => self.sound.ch1.envelope.into(), - 0x14 => self.sound.ch1.freq_hi.into(), - 0x16 => self.sound.ch2.duty.into(), - 0x17 => self.sound.ch2.envelope.into(), - 0x19 => self.sound.ch2.freq_hi.into(), - 0x1A => self.sound.ch3.enabled(), - 0x1B => self.sound.ch3.len, - 0x1C => self.sound.ch3.volume(), - 0x1E => self.sound.ch3.freq_hi.into(), - 0x24 => self.sound.ctrl.channel.into(), - 0x25 => self.sound.ctrl.output.into(), - 0x26 => self.sound.ctrl.status.into(), - 0x30..=0x3F => self.sound.ch3.ram[addr as usize - 0xFF30], + 0x10 => self.snd.ch1.sweep.into(), + 0x11 => self.snd.ch1.duty.into(), + 0x12 => self.snd.ch1.envelope.into(), + 0x14 => self.snd.ch1.freq_hi.into(), + 0x16 => self.snd.ch2.duty.into(), + 0x17 => self.snd.ch2.envelope.into(), + 0x19 => self.snd.ch2.freq_hi.into(), + 0x1A => self.snd.ch3.enabled(), + 0x1B => self.snd.ch3.len, + 0x1C => self.snd.ch3.volume(), + 0x1E => self.snd.ch3.freq_hi.into(), + 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], 0x40 => self.ppu.ctrl.into(), 0x41 => self.ppu.stat.into(), 0x42 => self.ppu.pos.scroll_y, @@ -330,24 +330,24 @@ impl BusIo for Bus { 0x06 => self.timer.modulo = byte, 0x07 => self.timer.ctrl = byte.into(), 0x0F => self.set_interrupt_flag(byte), - 0x10 => self.sound.ch1.sweep = byte.into(), - 0x11 => self.sound.ch1.duty = byte.into(), - 0x12 => self.sound.ch1.envelope = byte.into(), - 0x13 => self.sound.ch1.freq_lo = byte, - 0x14 => self.sound.ch1.freq_hi = byte.into(), - 0x16 => self.sound.ch2.duty = byte.into(), - 0x17 => self.sound.ch2.envelope = byte.into(), - 0x18 => self.sound.ch2.freq_lo = byte, - 0x19 => self.sound.ch2.freq_hi = byte.into(), - 0x1A => self.sound.ch3.set_enabled(byte), - 0x1B => self.sound.ch3.len = byte, - 0x1C => self.sound.ch3.set_volume(byte), - 0x1D => self.sound.ch3.freq_lo = byte, - 0x1E => self.sound.ch3.freq_hi = byte.into(), - 0x24 => self.sound.ctrl.channel = byte.into(), - 0x25 => self.sound.ctrl.output = byte.into(), - 0x26 => self.sound.ctrl.status = byte.into(), // FIXME: Should we control which bytes are written to here? - 0x30..=0x3F => self.sound.ch3.ram[addr as usize - 0xFF30] = byte, + 0x10 => self.snd.ch1.sweep = byte.into(), + 0x11 => self.snd.ch1.duty = byte.into(), + 0x12 => self.snd.ch1.envelope = byte.into(), + 0x13 => self.snd.ch1.freq_lo = byte, + 0x14 => self.snd.ch1.freq_hi = byte.into(), + 0x16 => self.snd.ch2.duty = byte.into(), + 0x17 => self.snd.ch2.envelope = byte.into(), + 0x18 => self.snd.ch2.freq_lo = byte, + 0x19 => self.snd.ch2.freq_hi = byte.into(), + 0x1A => self.snd.ch3.set_enabled(byte), + 0x1B => self.snd.ch3.len = byte, + 0x1C => self.snd.ch3.set_volume(byte), + 0x1D => self.snd.ch3.freq_lo = byte, + 0x1E => self.snd.ch3.freq_hi = byte.into(), + 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, 0x40 => self.ppu.ctrl = byte.into(), 0x41 => self.ppu.stat.update(byte), 0x42 => self.ppu.pos.scroll_y = byte,