summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-04-28 19:45:09 +0200
committerBad Diode <bd@badd10de.dev>2021-04-28 19:45:09 +0200
commitdbb61a0a339306be380ff4b3bffad64b7e474d24 (patch)
tree47e19be43ccbb774d1bdf7dbb9f3a4539c83bd06
parent3e0bb6c9d1f788b51d26ed55acd32291df721129 (diff)
downloadgba-experiments-dbb61a0a339306be380ff4b3bffad64b7e474d24.tar.gz
gba-experiments-dbb61a0a339306be380ff4b3bffad64b7e474d24.zip
Update main function to use the BIOS VSync
-rw-r--r--src/common.h5
-rw-r--r--src/irs.s6
-rw-r--r--src/main.c6
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() {
516 IRQ_CTRL = 1; 516 IRQ_CTRL = 1;
517} 517}
518 518
519// Stub function pointer needed for when we want to enable interrupts that don't
520// require a custom function, such as for the BIOS VSync.
521void
522irq_stub() {}
523
519#endif // GBAEXP_COMMON_H 524#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:
47 mov r0, #1 47 mov r0, #1
48 lsl r0, r0, r3 48 lsl r0, r0, r3
49 strh r0, [ip, #2] 49 strh r0, [ip, #2]
50 @ TODO: IRQ_ACK_BIOS 50 ldr r1, [ip, #-0x208]
51 orr r1, r1, r0
52 str r1, [ip, #-0x208]
51 53
52 @ Store the SPSR in one of the free registers and save it along with the 54 @ Store the SPSR in one of the free registers and save it along with the
53 @ return pointer. 55 @ return pointer.
@@ -84,5 +86,3 @@ irs_main_exit:
84 86
85mem_irq_base_reg: 87mem_irq_base_reg:
86 .word 0x04000200 @ IRQ_ENABLE 88 .word 0x04000200 @ IRQ_ENABLE
87 .word 0x04000202 @ IRQ_ACK
88 .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) {
44 44
45 // Register interrupts. 45 // Register interrupts.
46 irq_init(); 46 irq_init();
47 irs_set(IRQ_VBLANK, irq_stub);
47 irs_set(IRQ_HBLANK, irs_hblank_func); 48 irs_set(IRQ_HBLANK, irs_hblank_func);
48 49
49 int frame_counter = 0; 50 int frame_counter = 0;
50 while(true) { 51 while(true) {
51 // bios_vblank_wait(); 52 bios_vblank_wait();
52 wait_vsync();
53 poll_keys(); 53 poll_keys();
54 54
55 txt_position(0, 1); 55 txt_position(0, 1);
@@ -59,7 +59,7 @@ int main(void) {
59 txt_printf(" Frame counter: %d", frame_counter); 59 txt_printf(" Frame counter: %d", frame_counter);
60 60
61 frame_counter++; 61 frame_counter++;
62 // update_button_sprites(); 62 update_button_sprites();
63 }; 63 };
64 64
65 return 0; 65 return 0;