graphics/printing/both-screen-text/source/main.c
/*
Both Screen Text example made by Aurelio Mannara for libctru
This code was modified for the last time on: 12/12/2014 23:20 UTC+1
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
// Initialize services
gfxInitDefault();
//In this example we need one PrintConsole for each screen
PrintConsole topScreen, bottomScreen;
//Initialize console for both screen using the two different PrintConsole we have defined
consoleInit(GFX_TOP, &topScreen);
consoleInit(GFX_BOTTOM, &bottomScreen);
//Before doing any text printing we should select the PrintConsole in which we are willing to write, otherwise the library will print on the last selected/initialized one
//Let's start by printing something on the top screen
consoleSelect(&topScreen);
printf("This is the top screen. We have lot of space here!\n");
//Now write something else on the bottom screen
consoleSelect(&bottomScreen);
printf("This is the bottom screen. We don't have much space...\nStill better than DS screens :D");
consoleSelect(&topScreen);
printf("\x1b[30;16HPress Start to exit.");
// 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
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
//Wait for VBlank
gspWaitForVBlank();
}
// Exit services
gfxExit();
return 0;
}
3ds.h
Central 3DS header.
aptMainLoop
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
consoleInit
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
consoleSelect
PrintConsole * consoleSelect(PrintConsole *console)
Make the specified console the render target.
gfxSwapBuffers
void gfxSwapBuffers(void)
Updates the configuration of both screens.
gfxInitDefault
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
GFX_BOTTOM
@ GFX_BOTTOM
Bottom screen.
Definition: gfx.h:27
GFX_TOP
@ GFX_TOP
Top screen.
Definition: gfx.h:26
gfxExit
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
gfxFlushBuffers
void gfxFlushBuffers(void)
Flushes the data cache for the current framebuffers.
gspWaitForVBlank
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
KEY_START
@ KEY_START
Start.
Definition: hid.h:15
hidKeysDown
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
hidScanInput
void hidScanInput(void)
Scans HID for input data.
PrintConsole
Console structure used to store the state of a console render context.
Definition: console.h:77
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23