mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
move profiler to be a function
This commit is contained in:
parent
4bec0d073f
commit
ac9826c4d7
|
@ -101,18 +101,9 @@ fn all_tags(gfx: &ObjectController) {
|
||||||
fn main(mut gba: agb::Gba) -> ! {
|
fn main(mut gba: agb::Gba) -> ! {
|
||||||
let gfx = gba.display.object.get();
|
let gfx = gba.display.object.get();
|
||||||
|
|
||||||
let timers = gba.timers.timers();
|
let mut timers = gba.timers.timers();
|
||||||
let mut my_timer = timers.timer0;
|
|
||||||
my_timer.set_interrupt(true);
|
|
||||||
my_timer.set_overflow_amount(10000);
|
|
||||||
my_timer.set_enabled(true);
|
|
||||||
|
|
||||||
agb::add_interrupt_handler!(
|
let _a = agb::interrupt::profiler(&mut timers.timer0, 5000);
|
||||||
agb::interrupt::Interrupt::Timer0,
|
|
||||||
|_key: &CriticalSection| {
|
|
||||||
agb::println!("{:#010x}", agb::get_program_counter_before_interrupt());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
all_tags(&gfx);
|
all_tags(&gfx);
|
||||||
|
|
|
@ -360,3 +360,14 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn profiler(timer: &mut crate::timer::Timer, period: u16) -> InterruptHandler {
|
||||||
|
timer.set_interrupt(true);
|
||||||
|
timer.set_overflow_amount(period);
|
||||||
|
timer.set_enabled(true);
|
||||||
|
|
||||||
|
add_interrupt_handler(timer.get_interrupt(), |_key: &CriticalSection| {
|
||||||
|
crate::println!("{:#010x}", crate::get_program_counter_before_interrupt());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -106,6 +106,17 @@ impl Timer {
|
||||||
fn get_timer_number(&self) -> usize {
|
fn get_timer_number(&self) -> usize {
|
||||||
self.timer_number as usize
|
self.timer_number as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_interrupt(&self) -> crate::interrupt::Interrupt {
|
||||||
|
use crate::interrupt::Interrupt;
|
||||||
|
match self.timer_number {
|
||||||
|
0 => Interrupt::Timer0,
|
||||||
|
1 => Interrupt::Timer1,
|
||||||
|
2 => Interrupt::Timer2,
|
||||||
|
3 => Interrupt::Timer3,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
|
Loading…
Reference in a new issue