mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
The poor profiler
This commit is contained in:
parent
3c09a86f88
commit
4bec0d073f
|
@ -5,6 +5,7 @@ extern crate alloc;
|
||||||
|
|
||||||
use agb::display::object::{Graphics, ObjectController, Sprite, TagMap};
|
use agb::display::object::{Graphics, ObjectController, Sprite, TagMap};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
use bare_metal::CriticalSection;
|
||||||
|
|
||||||
const GRAPHICS: &Graphics = agb::include_aseprite!(
|
const GRAPHICS: &Graphics = agb::include_aseprite!(
|
||||||
"../examples/the-purple-night/gfx/objects.aseprite",
|
"../examples/the-purple-night/gfx/objects.aseprite",
|
||||||
|
@ -100,6 +101,19 @@ 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 my_timer = timers.timer0;
|
||||||
|
my_timer.set_interrupt(true);
|
||||||
|
my_timer.set_overflow_amount(10000);
|
||||||
|
my_timer.set_enabled(true);
|
||||||
|
|
||||||
|
agb::add_interrupt_handler!(
|
||||||
|
agb::interrupt::Interrupt::Timer0,
|
||||||
|
|_key: &CriticalSection| {
|
||||||
|
agb::println!("{:#010x}", agb::get_program_counter_before_interrupt());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
all_tags(&gfx);
|
all_tags(&gfx);
|
||||||
all_sprites(&gfx);
|
all_sprites(&gfx);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
@ An interrupt handler that simply acknowledges all interrupts
|
@ An interrupt handler that simply acknowledges all interrupts
|
||||||
.arm
|
.arm
|
||||||
.global InterruptHandler
|
.global InterruptHandler
|
||||||
|
@ -14,6 +15,10 @@ InterruptHandler:
|
||||||
ldrh r3, [r2, #2] @ load 16 bit interrupt request to r3
|
ldrh r3, [r2, #2] @ load 16 bit interrupt request to r3
|
||||||
and r0, r1, r3 @ interrupts both enabled and requested
|
and r0, r1, r3 @ interrupts both enabled and requested
|
||||||
|
|
||||||
|
ldr r1, [sp, #20]
|
||||||
|
ldr r3, =agb_rs__program_counter
|
||||||
|
str r1, [r3]
|
||||||
|
|
||||||
@ change to system mode
|
@ change to system mode
|
||||||
mrs r1, cpsr
|
mrs r1, cpsr
|
||||||
orr r1, r1, #0xD
|
orr r1, r1, #0xD
|
||||||
|
@ -43,3 +48,10 @@ InterruptHandler:
|
||||||
|
|
||||||
bx lr @ return to bios
|
bx lr @ return to bios
|
||||||
.pool
|
.pool
|
||||||
|
|
||||||
|
|
||||||
|
.section .iwram
|
||||||
|
.global agb_rs__program_counter
|
||||||
|
.balign 4
|
||||||
|
agb_rs__program_counter:
|
||||||
|
.word 0
|
||||||
|
|
|
@ -407,3 +407,11 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
pub fn get_program_counter_before_interrupt() -> u32 {
|
||||||
|
extern "C" {
|
||||||
|
static mut agb_rs__program_counter: u32;
|
||||||
|
}
|
||||||
|
unsafe { agb_rs__program_counter }
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,11 @@ impl Timer {
|
||||||
self.control_register().set_bits(bit, 1, 2);
|
self.control_register().set_bits(bit, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_interrupt(&mut self, interrupt: bool) {
|
||||||
|
let bit = interrupt as u16;
|
||||||
|
self.control_register().set_bits(bit, 1, 6);
|
||||||
|
}
|
||||||
|
|
||||||
fn data_register(&self) -> MemoryMapped<u16> {
|
fn data_register(&self) -> MemoryMapped<u16> {
|
||||||
timer_data(self.get_timer_number())
|
timer_data(self.get_timer_number())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue