diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | src/bios_calls.s | 9 | ||||
-rw-r--r-- | src/main.c | 48 |
3 files changed, 33 insertions, 28 deletions
@@ -14,8 +14,10 @@ LIBGBA += $(LIBGBA_DIR)/lib/libmm.a | |||
14 | # Source code location and files to watch for changes. | 14 | # Source code location and files to watch for changes. |
15 | SRC_DIR := src | 15 | SRC_DIR := src |
16 | SRC_MAIN := $(SRC_DIR)/main.c | 16 | SRC_MAIN := $(SRC_DIR)/main.c |
17 | ASM_FILES := $(wildcard $(SRC_DIR)/*.s) | ||
17 | WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) | 18 | WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) |
18 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) | 19 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) |
20 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.s) | ||
19 | 21 | ||
20 | # Output library names and executables. | 22 | # Output library names and executables. |
21 | TARGET := experiments | 23 | TARGET := experiments |
@@ -57,7 +59,7 @@ $(BIN): $(ELF) | |||
57 | 59 | ||
58 | # Link files. | 60 | # Link files. |
59 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) | 61 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) |
60 | $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) $(SRC_MAIN) $(LDLIBS) | 62 | $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) $(SRC_MAIN) $(ASM_FILES) $(LDLIBS) |
61 | 63 | ||
62 | # Create build directory if needed. | 64 | # Create build directory if needed. |
63 | $(BUILD_DIR): | 65 | $(BUILD_DIR): |
diff --git a/src/bios_calls.s b/src/bios_calls.s new file mode 100644 index 0000000..2268b4d --- /dev/null +++ b/src/bios_calls.s | |||
@@ -0,0 +1,9 @@ | |||
1 | @ Bios division call. | ||
2 | .text @ aka .section .text | ||
3 | .code 16 @ aka .thumb | ||
4 | .align 2 @ aka .balign 4 | ||
5 | .global bios_div | ||
6 | .thumb_func | ||
7 | bios_div: | ||
8 | swi 0x06 | ||
9 | bx lr | ||
@@ -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) { |