chore(apu): change access modifiers of some methods

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-07-18 20:55:26 -05:00
parent 8e2ef58b81
commit c1430594cf
4 changed files with 11 additions and 16 deletions

View File

@ -17,7 +17,7 @@ const CHANNEL_COUNT: usize = 2;
const SAMPLE_INCREMENT: u64 = SAMPLE_RATE as u64; const SAMPLE_INCREMENT: u64 = SAMPLE_RATE as u64;
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub(crate) struct Apu { pub struct Apu {
pub(crate) ctrl: SoundControl, pub(crate) ctrl: SoundControl,
/// Tone & Sweep /// Tone & Sweep
pub(crate) ch1: Channel1, pub(crate) ch1: Channel1,
@ -102,7 +102,7 @@ impl Apu {
} }
} }
pub(crate) fn set_audio_src(&mut self, sender: AudioSender<f32>) { pub fn set_audio_sender(&mut self, sender: AudioSender<f32>) {
self.sender = Some(sender); self.sender = Some(sender);
} }

View File

@ -1,4 +1,3 @@
use crate::apu::gen::AudioSender;
use crate::apu::Apu; use crate::apu::Apu;
use crate::cartridge::Cartridge; use crate::cartridge::Cartridge;
use crate::high_ram::HighRam; use crate::high_ram::HighRam;
@ -16,12 +15,12 @@ const BOOT_ROM_SIZE: usize = 0x100;
pub struct Bus { pub struct Bus {
boot: Option<[u8; BOOT_ROM_SIZE]>, // Boot ROM is 256b long boot: Option<[u8; BOOT_ROM_SIZE]>, // Boot ROM is 256b long
cartridge: Option<Cartridge>, cartridge: Option<Cartridge>,
pub ppu: Ppu, pub(crate) ppu: Ppu,
work_ram: WorkRam, work_ram: WorkRam,
var_ram: VariableWorkRam, var_ram: VariableWorkRam,
pub(crate) timer: Timer, pub(crate) timer: Timer,
int: Interrupt, int: Interrupt,
apu: Apu, pub(crate) apu: Apu,
high_ram: HighRam, high_ram: HighRam,
serial: Serial, serial: Serial,
pub(crate) joypad: Joypad, pub(crate) joypad: Joypad,
@ -75,10 +74,6 @@ impl Bus {
&mut self.apu &mut self.apu
} }
pub(crate) fn pass_audio_src(&mut self, sender: AudioSender<f32>) {
self.apu.set_audio_src(sender)
}
pub(crate) fn clock(&mut self) { pub(crate) fn clock(&mut self) {
self.ppu.clock(); self.ppu.clock();
self.timer.clock(); self.timer.clock();

View File

@ -1,4 +1,4 @@
use crate::apu::gen::AudioSender; use crate::apu::Apu;
use crate::bus::{Bus, BusIo}; use crate::bus::{Bus, BusIo};
use crate::instruction::{Cycle, Instruction}; use crate::instruction::{Cycle, Instruction};
use crate::interrupt::{InterruptEnable, InterruptFlag}; use crate::interrupt::{InterruptEnable, InterruptFlag};
@ -45,10 +45,6 @@ impl Cpu {
}) })
} }
pub fn set_audio_src(&mut self, sender: AudioSender<f32>) {
self.bus.pass_audio_src(sender)
}
pub(crate) fn ime(&self) -> ImeState { pub(crate) fn ime(&self) -> ImeState {
self.ime self.ime
} }
@ -174,6 +170,10 @@ impl Cpu {
&self.bus.ppu &self.bus.ppu
} }
pub fn apu_mut(&mut self) -> &mut Apu {
&mut self.bus.apu
}
pub(crate) fn joypad_mut(&mut self) -> &mut Joypad { pub(crate) fn joypad_mut(&mut self) -> &mut Joypad {
&mut self.bus.joypad &mut self.bus.joypad
} }

View File

@ -3,7 +3,7 @@ use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg
use gb::{AudioMPSC, Cycle, Egui, GB_HEIGHT, GB_WIDTH}; use gb::{AudioMPSC, Cycle, Egui, GB_HEIGHT, GB_WIDTH};
use gilrs::Gilrs; use gilrs::Gilrs;
use pixels::{Pixels, SurfaceTexture}; use pixels::{Pixels, SurfaceTexture};
use rodio::{OutputStream, Sink}; use rodio::OutputStream;
use std::time::Instant; use std::time::Instant;
use winit::dpi::LogicalSize; use winit::dpi::LogicalSize;
use winit::event::{Event, VirtualKeyCode}; use winit::event::{Event, VirtualKeyCode};
@ -67,7 +67,7 @@ fn main() -> Result<()> {
}; };
let (send, recv) = AudioMPSC::init(); let (send, recv) = AudioMPSC::init();
game_boy.set_audio_src(send); game_boy.apu_mut().set_audio_sender(send);
// Initialize Audio // Initialize Audio
let (_stream, stream_handle) = OutputStream::try_default().expect("Initialized Audio"); let (_stream, stream_handle) = OutputStream::try_default().expect("Initialized Audio");