chore: reduce size of public interface

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-10-30 10:28:20 +09:00
parent 2bb8bd6d8f
commit 01278ca83f
6 changed files with 19 additions and 14 deletions

View File

@ -437,7 +437,7 @@ impl Channel1 {
} }
/// 0xFF12 | NR12 - Channel 1 Volume Envelope /// 0xFF12 | NR12 - Channel 1 Volume Envelope
pub fn envelope(&self) -> u8 { pub(crate) fn envelope(&self) -> u8 {
u8::from(self.envelope) u8::from(self.envelope)
} }

View File

@ -19,12 +19,12 @@ pub struct Bus {
ppu: Ppu, ppu: Ppu,
work_ram: WorkRam, work_ram: WorkRam,
var_ram: VariableWorkRam, var_ram: VariableWorkRam,
pub(crate) timer: Timer, timer: Timer,
int: Interrupt, int: Interrupt,
pub(crate) apu: Apu, apu: Apu,
high_ram: HighRam, high_ram: HighRam,
serial: Serial, serial: Serial,
pub(crate) joypad: Joypad, joypad: Joypad,
} }
impl Default for Bus { impl Default for Bus {
@ -103,6 +103,11 @@ impl Bus {
self.cart.as_mut() self.cart.as_mut()
} }
#[inline]
pub(crate) fn apu_mut(&mut self) -> &mut Apu {
&mut self.apu
}
#[inline] #[inline]
pub fn ppu(&self) -> &Ppu { pub fn ppu(&self) -> &Ppu {
&self.ppu &self.ppu
@ -110,7 +115,7 @@ impl Bus {
} }
impl Bus { impl Bus {
pub fn oam_read_byte(&self, addr: u16) -> u8 { pub(crate) fn oam_read_byte(&self, addr: u16) -> u8 {
match addr { match addr {
0x0000..=0x7FFF => { 0x0000..=0x7FFF => {
// 16KB ROM bank 00 (ends at 0x3FFF) // 16KB ROM bank 00 (ends at 0x3FFF)
@ -157,7 +162,7 @@ impl Bus {
} }
} }
pub fn oam_write_byte(&mut self, addr: u16, byte: u8) { pub(crate) fn oam_write_byte(&mut self, addr: u16, byte: u8) {
self.ppu.oam.write_byte(addr, byte); self.ppu.oam.write_byte(addr, byte);
} }
} }

View File

@ -103,7 +103,7 @@ impl Cpu {
/// routine. /// routine.
/// ///
/// Handle HALT and interrupts. /// Handle HALT and interrupts.
pub fn step(&mut self) -> Cycle { pub(crate) fn step(&mut self) -> Cycle {
// Log instructions // Log instructions
// if self.reg.pc > 0xFF { // if self.reg.pc > 0xFF {
// let out = std::io::stdout(); // let out = std::io::stdout();

View File

@ -90,7 +90,7 @@ impl Emulator {
} }
pub fn set_prod(&mut self, prod: SampleProducer<f32>) { pub fn set_prod(&mut self, prod: SampleProducer<f32>) {
self.cpu.bus_mut().apu.attach_producer(prod) self.cpu.bus_mut().apu_mut().attach_producer(prod)
} }
pub fn title(&self) -> &str { pub fn title(&self) -> &str {

View File

@ -1893,7 +1893,7 @@ mod table {
} }
impl Group1RegisterPair { impl Group1RegisterPair {
pub fn as_register_pair(&self) -> RegisterPair { pub(crate) fn as_register_pair(&self) -> RegisterPair {
use Group1RegisterPair::*; use Group1RegisterPair::*;
match self { match self {
@ -1927,7 +1927,7 @@ mod table {
} }
impl Group2RegisterPair { impl Group2RegisterPair {
pub fn as_register_pair(&self) -> RegisterPair { pub(crate) fn as_register_pair(&self) -> RegisterPair {
use Group2RegisterPair::*; use Group2RegisterPair::*;
match self { match self {
@ -1961,7 +1961,7 @@ mod table {
} }
impl Group3RegisterPair { impl Group3RegisterPair {
pub fn as_register_pair(&self) -> RegisterPair { pub(crate) fn as_register_pair(&self) -> RegisterPair {
use Group3RegisterPair::*; use Group3RegisterPair::*;
match self { match self {
@ -2003,7 +2003,7 @@ mod table {
} }
impl Register { impl Register {
pub fn cpu_register(&self) -> CpuRegister { pub(crate) fn cpu_register(&self) -> CpuRegister {
use Register::*; use Register::*;
match self { match self {

View File

@ -111,7 +111,7 @@ impl ButtonEvent {
} }
#[inline] #[inline]
pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) { pub(crate) fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
use winit::event::VirtualKeyCode; use winit::event::VirtualKeyCode;
// TODO: What do I have to do to get a match statement here? // TODO: What do I have to do to get a match statement here?
@ -177,7 +177,7 @@ pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
} }
#[inline] #[inline]
pub fn handle_gamepad_input(pad: &mut Joypad, event: GamepadEvent) { pub(crate) fn handle_gamepad_input(pad: &mut Joypad, event: GamepadEvent) {
use Button::*; use Button::*;
use GamepadEventType::*; use GamepadEventType::*;