diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 96 |
1 files changed, 28 insertions, 68 deletions
@@ -22,83 +22,43 @@ int main(void) { | |||
22 | init_sprite_pal(0, COLOR_WHITE); | 22 | init_sprite_pal(0, COLOR_WHITE); |
23 | init_sprites(0); | 23 | init_sprites(0); |
24 | init_button_sprites(); | 24 | 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 | // These should be equivalent here, but remember that the dma_copy and | ||
44 | // dma_fill functions will always work on U32 chunks. | ||
45 | // | ||
46 | // memcpy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color)); | ||
47 | // dma_copy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color), 3); | ||
48 | |||
49 | u32 color = COLOR_RED | COLOR_RED << 16; | ||
50 | dma_fill(&PAL_BUFFER_SPRITES[0], color, 16 * sizeof(Color), 3); | ||
25 | 51 | ||
26 | // Initialize text engine. | 52 | // Initialize text engine. |
27 | txt_init(0, COLOR_RED, 0); | 53 | // txt_init(0, COLOR_RED, 0); |
28 | txt_position(0, 6); | 54 | // txt_printf("TEST"); |
29 | txt_printf("Strings: %s\n", "Hello World"); | ||
30 | txt_printf("Signed ints: %d\n", -100000); | ||
31 | txt_printf("Unsigned ints: %u\n", 1234567); | ||
32 | txt_printf("Hex values: 0x%x\n", 1024); | ||
33 | 55 | ||
34 | int frame_counter = 0; | 56 | int frame_counter = 0; |
35 | int x = 0; | ||
36 | int y = 0; | ||
37 | while(true) { | 57 | while(true) { |
38 | wait_vsync(); | 58 | wait_vsync(); |
39 | poll_keys(); | 59 | poll_keys(); |
40 | 60 | ||
41 | txt_position(0, 0); | ||
42 | txt_printf("Frame counter: %d\n", frame_counter); | ||
43 | |||
44 | if (key_hold(KEY_DOWN)) { | ||
45 | y += 3; | ||
46 | } | ||
47 | if (key_hold(KEY_UP)) { | ||
48 | y -= 3; | ||
49 | } | ||
50 | if (key_hold(KEY_LEFT)) { | ||
51 | x -= 3; | ||
52 | } | ||
53 | if (key_hold(KEY_RIGHT)) { | ||
54 | x += 3; | ||
55 | } | ||
56 | |||
57 | if (key_pressed(KEY_A)) { | ||
58 | txt_clear_line(); | ||
59 | txt_printf("Pressed key: A"); | ||
60 | } | ||
61 | if (key_pressed(KEY_B)) { | ||
62 | txt_clear_line(); | ||
63 | txt_printf("Pressed key: B"); | ||
64 | } | ||
65 | if (key_pressed(KEY_L)) { | ||
66 | txt_clear_line(); | ||
67 | txt_printf("Pressed key: L"); | ||
68 | } | ||
69 | if (key_pressed(KEY_R)) { | ||
70 | txt_clear_line(); | ||
71 | txt_printf("Pressed key: R"); | ||
72 | } | ||
73 | if (key_pressed(KEY_START)) { | ||
74 | txt_clear_line(); | ||
75 | txt_printf("Pressed key: Start"); | ||
76 | } | ||
77 | if (key_pressed(KEY_SELECT)) { | ||
78 | txt_clear_line(); | ||
79 | txt_printf("Pressed key: Select"); | ||
80 | } | ||
81 | if (key_pressed(KEY_UP)) { | ||
82 | txt_clear_line(); | ||
83 | txt_printf("Pressed key: Up"); | ||
84 | } | ||
85 | if (key_pressed(KEY_DOWN)) { | ||
86 | txt_clear_line(); | ||
87 | txt_printf("Pressed key: Down"); | ||
88 | } | ||
89 | if (key_pressed(KEY_LEFT)) { | ||
90 | txt_clear_line(); | ||
91 | txt_printf("Pressed key: Left"); | ||
92 | } | ||
93 | if (key_pressed(KEY_RIGHT)) { | ||
94 | txt_clear_line(); | ||
95 | txt_printf("Pressed key: Right"); | ||
96 | } | ||
97 | |||
98 | frame_counter++; | 61 | frame_counter++; |
99 | // BG_H_SCROLL_0 = x; | ||
100 | // BG_V_SCROLL_0 = y; | ||
101 | |||
102 | update_button_sprites(); | 62 | update_button_sprites(); |
103 | }; | 63 | }; |
104 | 64 | ||