diff options
author | Bad Diode <bd@badd10de.dev> | 2021-04-27 14:41:49 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-04-27 14:41:49 +0200 |
commit | 778fe214d136efeda7d072f933a0cf8ff1840f85 (patch) | |
tree | efa86b0ac8cbf713f6d83bb0760b237854dc8387 /src/main.c | |
parent | 3e38d5561d3e2e60f79ec5387f167bb12170c0f9 (diff) | |
download | gba-experiments-778fe214d136efeda7d072f933a0cf8ff1840f85.tar.gz gba-experiments-778fe214d136efeda7d072f933a0cf8ff1840f85.zip |
Testing BIOS calls
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 48 |
1 files changed, 21 insertions, 27 deletions
@@ -13,6 +13,16 @@ | |||
13 | // TODO: Cleanup OBJ/OAM memory copying and access. | 13 | // TODO: Cleanup OBJ/OAM memory copying and access. |
14 | // | 14 | // |
15 | 15 | ||
16 | // | ||
17 | // BIOS calls | ||
18 | // | ||
19 | |||
20 | int bios_div(int num, int denom); | ||
21 | |||
22 | int normal_div(int num, int denom) { | ||
23 | return num / denom; | ||
24 | }; | ||
25 | |||
16 | int main(void) { | 26 | int main(void) { |
17 | // Configure the display in mode 0 to show OBJs, where tile memory is | 27 | // Configure the display in mode 0 to show OBJs, where tile memory is |
18 | // sequential. | 28 | // sequential. |
@@ -22,42 +32,26 @@ int main(void) { | |||
22 | init_sprite_pal(0, COLOR_WHITE); | 32 | init_sprite_pal(0, COLOR_WHITE); |
23 | init_sprites(0); | 33 | init_sprites(0); |
24 | init_button_sprites(); | 34 | init_button_sprites(); |
25 | Color colors[16] = { | ||
26 | COLOR_BLUE, | ||
27 | COLOR_BLUE, | ||
28 | COLOR_BLUE, | ||
29 | COLOR_BLUE, | ||
30 | COLOR_BLUE, | ||
31 | COLOR_BLUE, | ||
32 | COLOR_BLUE, | ||
33 | COLOR_BLUE, | ||
34 | COLOR_BLUE, | ||
35 | COLOR_BLUE, | ||
36 | COLOR_BLUE, | ||
37 | COLOR_BLUE, | ||
38 | COLOR_BLUE, | ||
39 | COLOR_BLUE, | ||
40 | COLOR_BLUE, | ||
41 | COLOR_BLUE, | ||
42 | }; | ||
43 | 35 | ||
44 | size_t n_iter = 10000; | 36 | // Initialize text engine. |
37 | txt_init(0, COLOR_RED, 0); | ||
38 | |||
39 | size_t n_iter = 1000; | ||
45 | profile_start(); | 40 | profile_start(); |
41 | int test = 0; | ||
46 | for (size_t i = 0; i < n_iter; ++i) { | 42 | for (size_t i = 0; i < n_iter; ++i) { |
47 | dma_copy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color), 3); | 43 | txt_printf("Bios div: %d\n", bios_div(5 * i, 5)); |
48 | } | 44 | } |
49 | u32 dma_copy_perf = profile_stop(); | 45 | u32 bios_div_perf = profile_stop(); |
50 | 46 | ||
51 | profile_start(); | 47 | profile_start(); |
52 | for (size_t i = 0; i < n_iter; ++i) { | 48 | for (size_t i = 0; i < n_iter; ++i) { |
53 | memcpy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color)); | 49 | txt_printf("Code div: %d\n", normal_div(5 * i, 5)); |
54 | } | 50 | } |
55 | u32 memcpy_perf = profile_stop(); | 51 | u32 code_perf = profile_stop(); |
56 | 52 | ||
57 | // Initialize text engine. | 53 | txt_printf("C code div perf: %d\n", code_perf); |
58 | txt_init(0, COLOR_RED, 0); | 54 | txt_printf("BIOS div perf: %d\n", bios_div_perf); |
59 | txt_printf("N. cycles memcpy: %d\n", memcpy_perf); | ||
60 | txt_printf("N. cycles dma_copy: %d\n", dma_copy_perf); | ||
61 | 55 | ||
62 | int frame_counter = 0; | 56 | int frame_counter = 0; |
63 | while(true) { | 57 | while(true) { |