Skip to content
Snippets Groups Projects
Verified Commit ab06bbe8 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: major issue with APU address range selection

This issue was prevent CH4 from working properly.
Also added TODO operations to the master volume.
parent 9ad5064e
No related branches found
No related tags found
1 merge request!21Initial working version of Audio CH4
Pipeline #2449 passed
...@@ -413,12 +413,25 @@ impl Apu { ...@@ -413,12 +413,25 @@ impl Apu {
self.ch4_length_stop |= value & 0x40 == 0x40; self.ch4_length_stop |= value & 0x40 == 0x40;
self.ch4_enabled |= value & 0x80 == 0x80; self.ch4_enabled |= value & 0x80 == 0x80;
if value & 0x80 == 0x80 { if value & 0x80 == 0x80 {
self.ch4_timer = self.ch4_timer = ((CH4_DIVISORS[self.ch4_divisor as usize] as u16)
(CH4_DIVISORS[self.ch4_divisor as usize] << self.ch4_clock_shift) as i16; << self.ch4_clock_shift) as i16;
self.ch4_lfsr = 0x7ff1; self.ch4_lfsr = 0x7ff1;
} }
} }
// 0xFF24 — NR50: Master volume & VIN panning
0xff24 => {
//@TODO: Implement master volume & VIN panning
}
// 0xFF25 — NR51: Sound panning
0xff25 => {
//@TODO: Implement sound panning
}
// 0xFF26 — NR52: Sound on/off
0xff26 => {
//@TODO: Implement sound on/off
}
// 0xFF30-0xFF3F — Wave pattern RAM // 0xFF30-0xFF3F — Wave pattern RAM
0xff30..=0xff3f => { 0xff30..=0xff3f => {
self.wave_ram[addr as usize & 0x000f] = value; self.wave_ram[addr as usize & 0x000f] = value;
...@@ -700,7 +713,8 @@ impl Apu { ...@@ -700,7 +713,8 @@ impl Apu {
self.ch4_output = 0; self.ch4_output = 0;
} }
self.ch4_timer += (CH4_DIVISORS[self.ch4_divisor as usize] << self.ch4_clock_shift) as i16; self.ch4_timer +=
((CH4_DIVISORS[self.ch4_divisor as usize] as u16) << self.ch4_clock_shift) as i16;
} }
} }
......
...@@ -170,7 +170,7 @@ impl Mmu { ...@@ -170,7 +170,7 @@ impl Mmu {
0x00 0x00
} }
}, },
0x10..=26 | 0x30..=0x37 => self.apu.read(addr), 0x10..=0x26 | 0x30..=0x37 => self.apu.read(addr),
0x40 | 0x50 | 0x60 | 0x70 => self.ppu.read(addr), 0x40 | 0x50 | 0x60 | 0x70 => self.ppu.read(addr),
_ => { _ => {
debugln!("Reading from unknown IO control 0x{:04x}", addr); debugln!("Reading from unknown IO control 0x{:04x}", addr);
...@@ -241,7 +241,7 @@ impl Mmu { ...@@ -241,7 +241,7 @@ impl Mmu {
0x04..=0x07 => self.timer.write(addr, value), 0x04..=0x07 => self.timer.write(addr, value),
_ => debugln!("Writing to unknown IO control 0x{:04x}", addr), _ => debugln!("Writing to unknown IO control 0x{:04x}", addr),
}, },
0x10..=26 | 0x30..=0x37 => self.apu.write(addr, value), 0x10..=0x26 | 0x30..=0x37 => self.apu.write(addr, value),
0x40 | 0x60 | 0x70 => { 0x40 | 0x60 | 0x70 => {
match addr & 0x00ff { match addr & 0x00ff {
// 0xFF46 — DMA: OAM DMA source address & start // 0xFF46 — DMA: OAM DMA source address & start
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment