change update_sweep to be in line with other channel mmio functions

This commit is contained in:
Alex Janka 2023-02-19 21:49:58 +11:00
parent 26e5cc3431
commit 20f324caa8
2 changed files with 10 additions and 18 deletions

View file

@ -1,7 +1,4 @@
use self::{
channels::EnvelopeMode,
types::{Channels, DacSample, Mixer, VinEnable, Volume},
};
use self::types::{Channels, DacSample, Mixer, VinEnable, Volume};
use crate::{
processor::{
memory::{masked_update, Address},
@ -252,16 +249,7 @@ impl Apu {
pub fn mmio_write(&mut self, addr: Address, data: u8) {
match addr {
0xFF10 => {
let pace = (data & 0b1110000) >> 4;
let mode = if get_bit(data, 3) {
EnvelopeMode::Decrease
} else {
EnvelopeMode::Increase
};
let slope = data & 0b111;
self.channels.one.update_sweep(pace, mode, slope);
}
0xFF10 => self.channels.one.update_sweep(data),
0xFF11 => self.channels.one.update_length_timer_and_duty_cycle(data),
0xFF12 => self.channels.one.update_volume_and_envelope(data),
0xFF13 => self.channels.one.update_wavelength_low(data),

View file

@ -205,10 +205,14 @@ impl PwmChannel {
}
}
pub(super) fn update_sweep(&mut self, pace: u8, mode: EnvelopeMode, slope: u8) {
self.sweep.pace = pace;
self.sweep.mode = mode;
self.sweep.slope = slope;
pub(super) fn update_sweep(&mut self, data: u8) {
self.sweep.pace = (data & 0b1110000) >> 4;
self.sweep.mode = if get_bit(data, 3) {
EnvelopeMode::Decrease
} else {
EnvelopeMode::Increase
};
self.sweep.slope = data & 0b111;
}
pub(super) fn get_sweep_register(&self) -> u8 {