initial apu
This commit is contained in:
parent
3af4772363
commit
04fcb000a1
7
src/processor/apu.rs
Normal file
7
src/processor/apu.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
pub(super) struct Apu {}
|
||||
|
||||
impl Apu {
|
||||
pub(super) fn init() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
|
@ -101,6 +101,7 @@ pub struct Memory {
|
|||
io: [u8; 76],
|
||||
pub(super) user_mode: bool,
|
||||
joypad: Joypad,
|
||||
pub(super) apu_enabled: bool,
|
||||
}
|
||||
|
||||
impl Memory {
|
||||
|
@ -120,6 +121,7 @@ impl Memory {
|
|||
io: [0xFF; 76],
|
||||
user_mode: false,
|
||||
joypad: Joypad::default(),
|
||||
apu_enabled: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +229,10 @@ impl Memory {
|
|||
0xFF1C => self.masked_io(addr_l, data, 0b1100000),
|
||||
0xFF20 => self.masked_io(addr_l, data, 0b111111),
|
||||
0xFF23 => self.io[addr_l] = (self.io[addr_l] & 0b10111111) | (data & 0b01000000),
|
||||
0xFF26 => self.io[addr_l] = (self.io[addr_l] & 0b1111111) | (data & 0b10000000),
|
||||
0xFF26 => {
|
||||
self.io[addr_l] = (self.io[addr_l] & 0b1111111) | (data & 0b10000000);
|
||||
self.apu_enabled = self.io[addr_l] & 0b10000000 == 0b10000000
|
||||
}
|
||||
0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E => {
|
||||
// sound
|
||||
self.io[addr_l] = data;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use self::{gpu::Gpu, memory::Memory, timer::Timers};
|
||||
use self::{apu::Apu, gpu::Gpu, memory::Memory, timer::Timers};
|
||||
use crate::{
|
||||
util::{clear_bit, get_bit},
|
||||
verbose_println,
|
||||
|
@ -6,6 +6,7 @@ use crate::{
|
|||
use gilrs::Gilrs;
|
||||
use minifb::Window;
|
||||
|
||||
mod apu;
|
||||
pub mod gpu;
|
||||
mod instructions;
|
||||
pub mod memory;
|
||||
|
@ -35,6 +36,7 @@ pub struct Cpu {
|
|||
halted: bool,
|
||||
timers: Timers,
|
||||
gamepad_handler: Gilrs,
|
||||
apu: Apu,
|
||||
}
|
||||
|
||||
// Hz
|
||||
|
@ -62,6 +64,7 @@ impl Cpu {
|
|||
halted: false,
|
||||
timers: Timers::init(),
|
||||
gamepad_handler,
|
||||
apu: Apu::init(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue