Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <3ds.h>
- #define GFX_TOP_WIDTH 400
- #define GFX_TOP_HEIGHT 240
- #define GFX_BOTTOM_WIDTH 320
- #define GFX_BOTTOM_HEIGHT 240
- u32 kDown; // keys down
- u32 kHeld; // keys pressed
- u32 kUp; // keys up
- u8* fbTopLeft; // top left screen's framebuffer
- u8* fbTopRight; // top right screen's framebuffer
- u8* fbBottom; // bottom screen's framebuffer
- u8* sprites;
- void resetBuffers()
- {
- fbTopLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
- fbTopRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL);
- fbBottom = gfxGetFramebuffer(GFX_BOTTOM, 0, NULL, NULL);
- memset(fbTopLeft, 0, 240 * 400 * 3);
- memset(fbTopRight, 0, 240 * 400 * 3);
- memset(fbBottom, 0, 240 * 320 * 3);
- }
- void init()
- {
- srvInit(); // services
- aptInit(); // applets
- hidInit(NULL); // input
- gfxInitDefault(); // graphics
- gfxSet3D(false); // stereoscopy (true == on / false == off)
- resetBuffers();
- }
- void quit()
- {
- gfxExit();
- hidExit();
- aptExit();
- srvExit();
- }
- void setPixelRGB(u8* buffer, int w, int h, int x, int y, int r, int g, int b)
- {
- if((x < w) && (y < h))
- {
- buffer[((h * x) + (h - y)) * 3] = b;
- buffer[(((h * x) + (h - y)) * 3) + 1] = g;
- buffer[(((h * x) + (h - y)) * 3) + 2] = r;
- }
- }
- void setPixelBGR(u8* buffer, int w, int h, int x, int y, int b, int g, int r)
- {
- if((x < w) && (y < h))
- {
- buffer[((h * x) + (h - y)) * 3] = b;
- buffer[(((h * x) + (h - y)) * 3) + 1] = g;
- buffer[(((h * x) + (h - y)) * 3) + 2] = r;
- }
- }
- int main()
- {
- init();
- // Main loop
- while (aptMainLoop())
- {
- // Wait for next frame
- gspWaitForVBlank();
- // Read which buttons are currently pressed or not
- hidScanInput();
- kDown = hidKeysDown();
- kHeld = hidKeysHeld();
- kUp = hidKeysUp();
- // If START button is pressed, break loop and quit
- if (kDown & KEY_START)
- {
- break;
- }
- //resetBuffers();
- setPixelRGB(fbTopLeft, GFX_TOP_WIDTH, GFX_TOP_HEIGHT, 0, 0, 255, 0, 0);
- // Flush and swap framebuffers
- gfxFlushBuffers();
- gfxSwapBuffers();
- }
- quit();
- // Return to hbmenu
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement