diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -17,11 +17,17 @@ | |||
17 | // BIOS calls | 17 | // BIOS calls |
18 | // | 18 | // |
19 | 19 | ||
20 | int bios_vblank_wait(); | ||
20 | int bios_div(int num, int denom); | 21 | int bios_div(int num, int denom); |
21 | 22 | ||
22 | int normal_div(int num, int denom) { | 23 | int hblank_counter = 0; |
23 | return num / denom; | 24 | |
24 | }; | 25 | void |
26 | irs_hblank_func() { | ||
27 | u16 clr = (DISP_VCOUNT / 8); | ||
28 | PAL_BUFFER_BG[0] = rgb15(clr, 0, 31 - clr); | ||
29 | hblank_counter++; | ||
30 | } | ||
25 | 31 | ||
26 | int main(void) { | 32 | int main(void) { |
27 | // Configure the display in mode 0 to show OBJs, where tile memory is | 33 | // Configure the display in mode 0 to show OBJs, where tile memory is |
@@ -36,28 +42,22 @@ int main(void) { | |||
36 | // Initialize text engine. | 42 | // Initialize text engine. |
37 | txt_init(0, COLOR_RED, 0); | 43 | txt_init(0, COLOR_RED, 0); |
38 | 44 | ||
39 | size_t n_iter = 1000; | 45 | // Register interrupts. |
40 | profile_start(); | 46 | irq_init(); |
41 | int test = 0; | 47 | irs_set(IRQ_HBLANK, irs_hblank_func); |
42 | for (size_t i = 0; i < n_iter; ++i) { | ||
43 | txt_printf("Bios div: %d\n", bios_div(5 * i, 5)); | ||
44 | } | ||
45 | u32 bios_div_perf = profile_stop(); | ||
46 | |||
47 | profile_start(); | ||
48 | for (size_t i = 0; i < n_iter; ++i) { | ||
49 | txt_printf("Code div: %d\n", normal_div(5 * i, 5)); | ||
50 | } | ||
51 | u32 code_perf = profile_stop(); | ||
52 | |||
53 | txt_printf("C code div perf: %d\n", code_perf); | ||
54 | txt_printf("BIOS div perf: %d\n", bios_div_perf); | ||
55 | 48 | ||
56 | int frame_counter = 0; | 49 | int frame_counter = 0; |
57 | while(true) { | 50 | while(true) { |
51 | // bios_vblank_wait(); | ||
58 | wait_vsync(); | 52 | wait_vsync(); |
59 | poll_keys(); | 53 | poll_keys(); |
60 | 54 | ||
55 | txt_position(0, 1); | ||
56 | txt_clear_line(); | ||
57 | txt_printf(" HBlank counter: %d\n", hblank_counter); | ||
58 | txt_clear_line(); | ||
59 | txt_printf(" Frame counter: %d", frame_counter); | ||
60 | |||
61 | frame_counter++; | 61 | frame_counter++; |
62 | // update_button_sprites(); | 62 | // update_button_sprites(); |
63 | }; | 63 | }; |