From dbb61a0a339306be380ff4b3bffad64b7e474d24 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 28 Apr 2021 19:45:09 +0200 Subject: Update main function to use the BIOS VSync --- src/common.h | 5 +++++ src/irs.s | 6 +++--- src/main.c | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common.h b/src/common.h index dac48ad..7695683 100644 --- a/src/common.h +++ b/src/common.h @@ -516,4 +516,9 @@ irq_init() { IRQ_CTRL = 1; } +// Stub function pointer needed for when we want to enable interrupts that don't +// require a custom function, such as for the BIOS VSync. +void +irq_stub() {} + #endif // GBAEXP_COMMON_H diff --git a/src/irs.s b/src/irs.s index 924441e..66ac0c2 100644 --- a/src/irs.s +++ b/src/irs.s @@ -47,7 +47,9 @@ irs_main_handle_irs: mov r0, #1 lsl r0, r0, r3 strh r0, [ip, #2] - @ TODO: IRQ_ACK_BIOS + ldr r1, [ip, #-0x208] + orr r1, r1, r0 + str r1, [ip, #-0x208] @ Store the SPSR in one of the free registers and save it along with the @ return pointer. @@ -84,5 +86,3 @@ irs_main_exit: mem_irq_base_reg: .word 0x04000200 @ IRQ_ENABLE - .word 0x04000202 @ IRQ_ACK - .word 0x04000208 @ IRQ_CTRL diff --git a/src/main.c b/src/main.c index 6073a6a..2f1c522 100644 --- a/src/main.c +++ b/src/main.c @@ -44,12 +44,12 @@ int main(void) { // Register interrupts. irq_init(); + irs_set(IRQ_VBLANK, irq_stub); irs_set(IRQ_HBLANK, irs_hblank_func); int frame_counter = 0; while(true) { - // bios_vblank_wait(); - wait_vsync(); + bios_vblank_wait(); poll_keys(); txt_position(0, 1); @@ -59,7 +59,7 @@ int main(void) { txt_printf(" Frame counter: %d", frame_counter); frame_counter++; - // update_button_sprites(); + update_button_sprites(); }; return 0; -- cgit v1.2.1