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

feat: better APU cycles

parent 6395f11d
No related branches found
No related tags found
1 merge request!19Initial tentative audio support 🔉
Pipeline #2258 failed
...@@ -49,6 +49,11 @@ impl Apu { ...@@ -49,6 +49,11 @@ impl Apu {
} }
} }
pub fn clock(&mut self, cycles: u8) {
// @todo implement the clock and allow for the proper
// writing of the output buffer at a fixed frequency
}
pub fn read(&mut self, addr: u16) -> u8 { pub fn read(&mut self, addr: u16) -> u8 {
match addr { match addr {
0xff26 => 1 as u8, // todo implement this 0xff26 => 1 as u8, // todo implement this
......
use core::panic; use core::panic;
use crate::{ use crate::{
apu::Apu,
debugln, debugln,
inst::{EXTENDED, INSTRUCTIONS}, inst::{EXTENDED, INSTRUCTIONS},
mmu::Mmu, mmu::Mmu,
...@@ -271,6 +272,11 @@ impl Cpu { ...@@ -271,6 +272,11 @@ impl Cpu {
self.mmu().ppu() self.mmu().ppu()
} }
#[inline(always)]
pub fn apu(&mut self) -> &mut Apu {
self.mmu().apu()
}
#[inline(always)] #[inline(always)]
pub fn pad(&mut self) -> &mut Pad { pub fn pad(&mut self) -> &mut Pad {
self.mmu().pad() self.mmu().pad()
......
...@@ -75,6 +75,7 @@ impl GameBoy { ...@@ -75,6 +75,7 @@ impl GameBoy {
pub fn clock(&mut self) -> u8 { pub fn clock(&mut self) -> u8 {
let cycles = self.cpu_clock(); let cycles = self.cpu_clock();
self.ppu_clock(cycles); self.ppu_clock(cycles);
self.apu_clock(cycles);
self.timer_clock(cycles); self.timer_clock(cycles);
cycles cycles
} }
...@@ -95,6 +96,10 @@ impl GameBoy { ...@@ -95,6 +96,10 @@ impl GameBoy {
self.ppu().clock(cycles) self.ppu().clock(cycles)
} }
pub fn apu_clock(&mut self, cycles: u8) {
self.apu().clock(cycles)
}
pub fn timer_clock(&mut self, cycles: u8) { pub fn timer_clock(&mut self, cycles: u8) {
self.timer().clock(cycles) self.timer().clock(cycles)
} }
...@@ -248,6 +253,10 @@ impl GameBoy { ...@@ -248,6 +253,10 @@ impl GameBoy {
self.cpu.ppu() self.cpu.ppu()
} }
pub fn apu(&mut self) -> &mut Apu {
self.cpu.apu()
}
pub fn pad(&mut self) -> &mut Pad { pub fn pad(&mut self) -> &mut Pad {
self.cpu.pad() self.cpu.pad()
} }
......
...@@ -75,6 +75,10 @@ impl Mmu { ...@@ -75,6 +75,10 @@ impl Mmu {
&mut self.ppu &mut self.ppu
} }
pub fn apu(&mut self) -> &mut Apu {
&mut self.apu
}
pub fn pad(&mut self) -> &mut Pad { pub fn pad(&mut self) -> &mut Pad {
&mut self.pad &mut self.pad
} }
......
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