diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-11-16 12:38:37 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-11-16 12:38:37 -0600 |
commit | 57331ba9756df043b5c665aa4952a0a7b38799e5 (patch) | |
tree | 0feb2ca5cbe38744088845b8bb105673016c1fac /src/main.c |
Initial commit
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..c8a1115 --- /dev/null +++ b/src/main.c @@ -0,0 +1,65 @@ +#include "gc.h" +#include "util.h" +#include <3ds.h> +#include <inttypes.h> +#include <stdio.h> + +int main(int argc, char **argv) { + gfxInit(GSP_BGR8_OES, GSP_BGR8_OES, false); + + // Initialize console on top screen. Using NULL as the second argument tells + // the console library to use the internal console structure as current one + consoleInit(GFX_TOP, NULL); + + // Move the cursor to row 15 and column 19 and then prints "Hello World!" + // To move the cursor you have to print "\x1b[r;cH", where r and c are + // respectively the row and column where you want your cursor to move The top + // screen has 30 rows and 50 columns The bottom screen has 30 rows and 40 + // columns + printf("\x1b[16;20HHello World!"); + + printf("\x1b[29;16HPress Start to exit.\n"); + + gc_init(); + + // Main loop + while (aptMainLoop()) { + // Scan all the inputs. This should be done once for each frame + hidScanInput(); + + // hidKeysDown returns information about which buttons have been just + // pressed (and they weren't in the previous frame) + u32 kDown = hidKeysDown(); + + if (kDown & KEY_START) + break; // break in order to return to hbmenu + if (kDown & KEY_A) + todo("GM"); + + circlePosition pos; + hidCircleRead(&pos); + printf("\x1b[0;0H\x1b[K(%" PRId16 ", %" PRId16 ")\n", pos.dx, pos.dy); + + // Get the bottom screen's frame buffer + u16 w, h; + u8 *fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &w, &h); + + for (u16 j = 0; j < h; j++) { + for (u16 i = 0; i < w; i++) { + *fb++ = (u8)(((float)i / (float)w) * 255.0); + *fb++ = (u8)(((float)j / (float)h) * 255.0); + *fb++ = 0x00; + } + } + + // Flush and swap framebuffers + gfxFlushBuffers(); + gfxSwapBuffers(); + + // Wait for VBlank + gspWaitForVBlank(); + } + + gfxExit(); + return 0; +} |