From af05a2979f97d00eab36261374af1eaf2ac3c833 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 27 Apr 2021 12:36:28 +0200 Subject: Add DMA control macros and small memory copy test --- src/main.c | 96 ++++++++++++++++++-------------------------------------------- 1 file changed, 28 insertions(+), 68 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3bd5865..efd460f 100644 --- a/src/main.c +++ b/src/main.c @@ -22,83 +22,43 @@ int main(void) { init_sprite_pal(0, COLOR_WHITE); init_sprites(0); init_button_sprites(); + Color colors[16] = { + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + COLOR_BLUE, + }; + // These should be equivalent here, but remember that the dma_copy and + // dma_fill functions will always work on U32 chunks. + // + // memcpy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color)); + // dma_copy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color), 3); + + u32 color = COLOR_RED | COLOR_RED << 16; + dma_fill(&PAL_BUFFER_SPRITES[0], color, 16 * sizeof(Color), 3); // Initialize text engine. - txt_init(0, COLOR_RED, 0); - txt_position(0, 6); - txt_printf("Strings: %s\n", "Hello World"); - txt_printf("Signed ints: %d\n", -100000); - txt_printf("Unsigned ints: %u\n", 1234567); - txt_printf("Hex values: 0x%x\n", 1024); + // txt_init(0, COLOR_RED, 0); + // txt_printf("TEST"); int frame_counter = 0; - int x = 0; - int y = 0; while(true) { wait_vsync(); poll_keys(); - txt_position(0, 0); - txt_printf("Frame counter: %d\n", frame_counter); - - if (key_hold(KEY_DOWN)) { - y += 3; - } - if (key_hold(KEY_UP)) { - y -= 3; - } - if (key_hold(KEY_LEFT)) { - x -= 3; - } - if (key_hold(KEY_RIGHT)) { - x += 3; - } - - if (key_pressed(KEY_A)) { - txt_clear_line(); - txt_printf("Pressed key: A"); - } - if (key_pressed(KEY_B)) { - txt_clear_line(); - txt_printf("Pressed key: B"); - } - if (key_pressed(KEY_L)) { - txt_clear_line(); - txt_printf("Pressed key: L"); - } - if (key_pressed(KEY_R)) { - txt_clear_line(); - txt_printf("Pressed key: R"); - } - if (key_pressed(KEY_START)) { - txt_clear_line(); - txt_printf("Pressed key: Start"); - } - if (key_pressed(KEY_SELECT)) { - txt_clear_line(); - txt_printf("Pressed key: Select"); - } - if (key_pressed(KEY_UP)) { - txt_clear_line(); - txt_printf("Pressed key: Up"); - } - if (key_pressed(KEY_DOWN)) { - txt_clear_line(); - txt_printf("Pressed key: Down"); - } - if (key_pressed(KEY_LEFT)) { - txt_clear_line(); - txt_printf("Pressed key: Left"); - } - if (key_pressed(KEY_RIGHT)) { - txt_clear_line(); - txt_printf("Pressed key: Right"); - } - frame_counter++; - // BG_H_SCROLL_0 = x; - // BG_V_SCROLL_0 = y; - update_button_sprites(); }; -- cgit v1.2.1