This commit is contained in:
Alex Janka 2023-03-01 08:40:37 +11:00
parent 80d58ba497
commit 3471148dd5
2 changed files with 11 additions and 12 deletions

View file

@ -195,16 +195,15 @@ impl Apu {
} }
pub fn get_register(&self, addr: Address) -> u8 { pub fn get_register(&self, addr: Address) -> u8 {
if addr == 0xFF26 if self.apu_enable {
|| addr == 0xFF11
|| addr == 0xFF16
|| addr == 0xFF1B
|| addr == 0xFF20
|| self.apu_enable
{
self.make_register(addr) self.make_register(addr)
} else { } else {
0xFF match addr {
0xFF26 | 0xFF11 | 0xFF16 | 0xFF1B | 0xFF20 | 0xFF30..0xFF40 => {
self.make_register(addr)
}
_ => 0xFF,
}
} }
} }
@ -262,7 +261,7 @@ impl Apu {
// not registers // not registers
0xFF15 | 0xFF1F | 0xFF27..0xFF30 => 0xFF, 0xFF15 | 0xFF1F | 0xFF27..0xFF30 => 0xFF,
// wave ram // 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"), 0x0..0xFF10 | 0xFF40..=0xFFFF => panic!("non-apu addr in apu"),
} }
} }

View file

@ -311,8 +311,8 @@ impl ShiftVolumePercent {
} }
} }
struct WaveRam { pub(super) struct WaveRam {
data: [u8; 16], pub(super) data: [u8; 16],
} }
impl WaveRam { impl WaveRam {
@ -333,7 +333,7 @@ pub(super) struct WaveChannel {
wavelength: u16, wavelength: u16,
wave_timer: u16, wave_timer: u16,
wave_position: usize, wave_position: usize,
wave_ram: WaveRam, pub(super) wave_ram: WaveRam,
} }
impl WaveChannel { impl WaveChannel {