Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

merge fifo pump 1<<16 cycles

Layle004eecf52a14
diff --git a/crates/gecko/src/flipper/cp.rs b/crates/gecko/src/flipper/cp.rs
index 92bcc6b..c39f3f1 100644
--- a/crates/gecko/src/flipper/cp.rs
+++ b/crates/gecko/src/flipper/cp.rs
@@ -4,6 +4,7 @@ use crate::flipper::pi::InterruptFlag;
use crate::system::{System, SystemId};
pub const GP_BURST: u32 = 32;
+pub const PUMP_INTERVAL_CYCLES: u64 = 1 << 16;
const GP_PIPE_CAPACITY: usize = 64;
@@ -176,7 +177,6 @@ pub fn refresh_interrupts<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
pub fn ack_breakpoint<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
sys.cp.status = sys.cp.status.with_bp_interrupt(false);
self::refresh_interrupts(sys);
- self::pump_fifo(sys);
}
#[inline(always)]
@@ -255,8 +255,12 @@ pub fn gather_pipe_bursted<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
sys.cp.refresh_status();
refresh_interrupts(sys);
}
+}
- pump_fifo(sys);
+pub fn pump_handler<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
+ self::pump_fifo(sys);
+ sys.scheduler
+ .schedule_in(PUMP_INTERVAL_CYCLES, self::pump_handler::<SYSTEM>);
}
pub fn pump_fifo<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
diff --git a/crates/gecko/src/flipper/cp/regs.rs b/crates/gecko/src/flipper/cp/regs.rs
index f5c6c36..43e893b 100644
--- a/crates/gecko/src/flipper/cp/regs.rs
+++ b/crates/gecko/src/flipper/cp/regs.rs
@@ -66,7 +66,6 @@ impl<const SYSTEM: SystemId> MmioAccess<System<SYSTEM>> for CpControl {
fn write(self, sys: &mut System<SYSTEM>, _: WriteMask) {
sys.cp.control = self;
cp::refresh_interrupts(sys);
- cp::pump_fifo(sys);
}
}
diff --git a/crates/gecko/src/scheduler.rs b/crates/gecko/src/scheduler.rs
index 3c54e5e..a13da97 100644
--- a/crates/gecko/src/scheduler.rs
+++ b/crates/gecko/src/scheduler.rs
@@ -144,6 +144,10 @@ impl<const SYSTEM: SystemId> Scheduler<SYSTEM> {
crate::gekko::dec::cycles_until_underflow(u32::MAX),
crate::gekko::dec::underflow_handler::<SYSTEM>,
);
+ s.schedule_at(
+ crate::flipper::cp::PUMP_INTERVAL_CYCLES,
+ crate::flipper::cp::pump_handler::<SYSTEM>,
+ );
s
}
}