change update_sweep to be in line with other channel mmio functions
This commit is contained in:
parent
26e5cc3431
commit
20f324caa8
|
@ -1,7 +1,4 @@
|
||||||
use self::{
|
use self::types::{Channels, DacSample, Mixer, VinEnable, Volume};
|
||||||
channels::EnvelopeMode,
|
|
||||||
types::{Channels, DacSample, Mixer, VinEnable, Volume},
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
processor::{
|
processor::{
|
||||||
memory::{masked_update, Address},
|
memory::{masked_update, Address},
|
||||||
|
@ -252,16 +249,7 @@ impl Apu {
|
||||||
|
|
||||||
pub fn mmio_write(&mut self, addr: Address, data: u8) {
|
pub fn mmio_write(&mut self, addr: Address, data: u8) {
|
||||||
match addr {
|
match addr {
|
||||||
0xFF10 => {
|
0xFF10 => self.channels.one.update_sweep(data),
|
||||||
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);
|
|
||||||
}
|
|
||||||
0xFF11 => self.channels.one.update_length_timer_and_duty_cycle(data),
|
0xFF11 => self.channels.one.update_length_timer_and_duty_cycle(data),
|
||||||
0xFF12 => self.channels.one.update_volume_and_envelope(data),
|
0xFF12 => self.channels.one.update_volume_and_envelope(data),
|
||||||
0xFF13 => self.channels.one.update_wavelength_low(data),
|
0xFF13 => self.channels.one.update_wavelength_low(data),
|
||||||
|
|
|
@ -205,10 +205,14 @@ impl PwmChannel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn update_sweep(&mut self, pace: u8, mode: EnvelopeMode, slope: u8) {
|
pub(super) fn update_sweep(&mut self, data: u8) {
|
||||||
self.sweep.pace = pace;
|
self.sweep.pace = (data & 0b1110000) >> 4;
|
||||||
self.sweep.mode = mode;
|
self.sweep.mode = if get_bit(data, 3) {
|
||||||
self.sweep.slope = slope;
|
EnvelopeMode::Decrease
|
||||||
|
} else {
|
||||||
|
EnvelopeMode::Increase
|
||||||
|
};
|
||||||
|
self.sweep.slope = data & 0b111;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn get_sweep_register(&self) -> u8 {
|
pub(super) fn get_sweep_register(&self) -> u8 {
|
||||||
|
|
Loading…
Reference in a new issue