Result backupByConfig(u8 *filebuffer, size_t bufsize) { memset(filebuffer, 0, bufsize); FILE *configfile = fopen("config.txt", "r"); if (configfile==NULL) return errno; char source_path[1000], sd_destination[1000]; u32 source_archive; mediatypes_enum mtype; FS_archiveIds atype; int buf2size = 0x10000; u8 *buf2 = malloc(buf2size); if (buf2==NULL) { printf("malloc failed\n"); gfxFlushBuffers(); gfxSwapBuffers(); return -1; } memset(buf2, 0, buf2size); while (fgets((char*) buf2, buf2size, configfile) != NULL) { if (sscanf((const char*) buf2, "DUMP \"%x:%999[^\"]\" \"%999[^\"]\"", (unsigned int*) &source_archive, source_path, sd_destination) == 3) { if (source_archive >= 0x80000000) { mtype = mediatype_NAND; atype = ARCH_SHARED_EXTDATA; } else { mtype = mediatype_SDMC; atype = ARCH_EXTDATA; } u32 extdata_archive_lowpathdata[3] = {mtype, source_archive, 0}; extdata_archive = (FS_archive){atype, (FS_path){PATH_BINARY, 0xC, (u8*)extdata_archive_lowpathdata}}; Result ret = FSUSER_OpenArchive(NULL, &extdata_archive); if(ret!=0) { printf("could not open archive\n"); gfxFlushBuffers(); gfxSwapBuffers(); continue; } printf("Dumping from %s\n", source_path); gfxFlushBuffers(); gfxSwapBuffers(); ret = archive_copyfile(Extdata_Archive, SDArchive, source_path, sd_destination, filebuffer, 0, bufsize, source_path); if (ret) { printf("Copying failed!\n"); } else { printf("Success.\n"); } gfxFlushBuffers(); gfxSwapBuffers(); FSUSER_CloseArchive(NULL, &extdata_archive); } } free(buf2); fclose(configfile); return 0; }
Result restoreFromSd(u8 *buf, size_t bufsize) { memset(buf, 0, bufsize); FILE *configfile = fopen("config.txt", "r"); if (configfile==NULL) return errno; char sd_source[1000], destination_path[1000]; u32 destination_archive; mediatypes_enum mtype; FS_archiveIds atype; u8 *filebuffer2 = malloc(bufsize); memset(filebuffer2, 0, bufsize); while (fgets((char*) buf, bufsize, configfile) != NULL) { if (sscanf((const char*) buf, "RESTORE \"%999[^\"]\" \"%x:%999[^\"]\"", sd_source, (unsigned int*) &destination_archive, destination_path) == 3) { if (destination_archive >= 0x80000000) { mtype = mediatype_NAND; atype = ARCH_SHARED_EXTDATA; } else { mtype = mediatype_SDMC; atype = ARCH_EXTDATA; } u32 extdata_archive_lowpathdata[3] = {mtype, destination_archive, 0}; extdata_archive = (FS_archive) { atype, (FS_path) { PATH_BINARY, 0xC, (u8*)extdata_archive_lowpathdata } }; Result ret = FSUSER_OpenArchive(NULL, &extdata_archive); if(ret!=0) { printf("could not open archive\n"); gfxFlushBuffers(); gfxSwapBuffers(); continue; } printf("Restoring to %s\n", destination_path); gfxFlushBuffers(); gfxSwapBuffers(); ret = archive_copyfile(SDArchive, Extdata_Archive, sd_source, destination_path, filebuffer2, 0, bufsize, destination_path); if (ret) { printf("Copying failed!\n"); } else { printf("Success.\n"); } gfxFlushBuffers(); gfxSwapBuffers(); FSUSER_CloseArchive(NULL, &extdata_archive); } } free(filebuffer2); fclose(configfile); return 0; }
Result archive_copyfile(Archive inarchive, Archive outarchive, char *inpath, char *outpath, u8* buffer, u32 size, u32 maxbufsize, char *display_filepath) { Result ret=0; u32 filesize=0; ret = archive_getfilesize(inarchive, inpath, &filesize); if (ret > 0) { printf("archive_getfilesize() ret=0x%08x, size=0x%08x\n", (unsigned int)ret, (unsigned int)filesize); gfxFlushBuffers(); gfxSwapBuffers(); } if(ret!=0)return ret; if(size==0 || size>filesize) { size = filesize; } if(size>maxbufsize) { printf("-----Size is too large.-----\n"); gfxFlushBuffers(); gfxSwapBuffers(); ret = -1; return ret; } /*printf("Reading %s...\n", display_filepath); gfxFlushBuffers(); gfxSwapBuffers();*/ ret = archive_readfile(inarchive, inpath, buffer, size); if(ret!=0) { printf("-----Failed to read %s (%d): 0x%08x-----\n", display_filepath, (unsigned int) size, (unsigned int)ret); gfxFlushBuffers(); gfxSwapBuffers(); return ret; } /*printf("Writing %s...\n", display_filepath); gfxFlushBuffers(); gfxSwapBuffers();*/ ret = archive_writefile(outarchive, outpath, buffer, size); if(ret!=0) { printf("-----Failed to write %s (%d): 0x%08x-----\n", display_filepath, (unsigned int) size, (unsigned int)ret); gfxFlushBuffers(); gfxSwapBuffers(); return ret; } return ret; }
s32 main (void) { // Initialize services //gfxInitDefault(); //gfxSwapBuffers(); Result res; gfxInitDefault(); gfxSwapBuffers(); consoleInit(GFX_TOP,NULL); //printf("miniPasta2\n\n"); res=suInit(); printf("su init: %08X\n",res); //res=khaxInit(); //printf("khax init: %08X\n",res); res=brahma_init(); printf("brahma init: %08X\n",res); load_arm9_payload_from_mem (arm9payload_bin, arm9payload_bin_size); printf("payload loaded to RAM\n"); res=firm_reboot(); printf("firm reboot: %08X\n",res); 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(); } gfxExit(); // Return to hbmenu return 0; }
int main() { gfxInitDefault(); //gfxSet3D(true); // uncomment if using stereoscopic 3D // Main loop while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); // Your code goes here u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu // Example rendering code that displays a white pixel // Please note that the 3DS screens are sideways (thus 240x400 and 240x320) u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, nullptr, nullptr); memset(fb, 127, 240*400*3); fb[3*(10+10*240)] = 0xFF; fb[3*(10+10*240)+1] = 0xFF; fb[3*(10+10*240)+2] = 0xFF; // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); } gfxExit(); return 0; }
void ui_info_add(const char* info) { consoleSelect(&bottom_screen); printf(info); gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); }
void drawFrame() { u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); int i, j; for(i=1;i<400;i++) { for(j=1;j<240;j++) { u32 v=(j+i*240)*3; bufAdr[v]=(pcCos(i+cnt)+4096)/32; bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64; bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32; } } gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "ftPONY v0.0003 gamma\n", 240-fontDefault.height*1, 10); u32 ip = gethostid(); char bof[256]; sprintf(bof, "IP: %lu.%lu.%lu.%lu\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, bof, 240-fontDefault.height*2, 10); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, quotes[curQuote], 240-fontDefault.height*3, 10); i = countLines(superStr); while(i>240/fontDefault.height-3){cutLine(superStr);i--;} gfxDrawText(GFX_TOP, GFX_LEFT, NULL, superStr, 240-fontDefault.height*4, 20); cnt++; gfxFlushBuffers(); gfxSwapBuffers(); }
STATIC bool fatal_error(bool restart) { bool should_restart = false; if (restart) { printf("\x1b[28;12HPress Select to restart."); } printf("\x1b[29;12H Press Start to exit. "); while (aptMainLoop()) { hidScanInput(); int down = hidKeysDown(); if (down & KEY_START) { break; } else if (restart && (down & KEY_SELECT)) { should_restart = true; break; } gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); } gfxExit(); return should_restart; }
void drawFrames() { drawFrame(GFX_TOP, 0x88, 0x66, 0x00); drawFrame(GFX_BOTTOM, 0x00, 0x00, 0x00); gfxFlushBuffers(); gfxSwapBuffers(); }
/*! draw console to screen */ void console_render(void) { font_t *font; /* clear all screens */ u8 black_color[] = { 0, 0, 0 }; clear_screen(GFX_TOP, GFX_LEFT, black_color); clear_screen(GFX_BOTTOM, GFX_LEFT, black_color); /* look up font for status bar and draw status bar */ font = find_font("sans", 10); if(font != NULL) { draw_text(GFX_BOTTOM, GFX_LEFT, font, status, 20, 4); draw_text(GFX_BOTTOM, GFX_LEFT, font, STATUS_STRING, 20, 220); } else debug("%s: couldn't find 'sans 10pt'\n", __func__); /* look up font for console and draw console */ font = find_font("sans", 8); if(font != NULL) draw_text(GFX_TOP, GFX_LEFT, font, buffer, 20, 5); else debug("%s: couldn't find 'sans 8pt'\n", __func__); /* flush framebuffer */ gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); }
void err_show(char file_name[], int line, char message[]) { quit_for_err = true; // Reset all screens consoleInit(GFX_TOP, &top_screen); consoleInit(GFX_BOTTOM, &debug_screen); consoleInit(GFX_BOTTOM, &instruction_screen); consoleSelect(&top_screen); printf("%s\n\t\tFATAL ERROR\n\n%s", BG_RED, RESET); printf("%s\n", file_name); printf("line %d\n", line); printf(message); printf("\n\nPlease raise an issue at:\ngithub.com/thatguywiththatname/3DES/issues\n"); printf("With details of this error &\nwhat you were doing at the time\n"); printf("\nPress A to close app\n"); while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); u32 exitkDown = hidKeysDown(); if (exitkDown & KEY_A) { return; } gfxFlushBuffers(); gfxSwapBuffers(); } }
int main(int argc, char **argv) { // Initialize services gfxInitDefault(); //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 tu 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[15;19HHello World!"); //Move the cursor to the top left corner of the screen printf("\x1b[0;0H"); //Print a REALLY crappy poeam with colored text //\x1b[cm set a SGR (Select Graphic Rendition) parameter, where c is the parameter that you want to set //Please refer to http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes to see all the possible SGR parameters //As of now ctrulib support only these parameters: //Reset (0), Half bright colors (2), Reverse (7), Text color (30-37) and Background color (40-47) printf("Roses are \x1b[31mred\x1b[0m\n"); printf("Violets are \x1b[34mblue\x1b[0m\n"); printf("Piracy is bad\n"); printf("While homebrews are good\n\n"); //Black text on white background //In this example we set two parameter in a single escape sequence by separating them by a semicolon //\x1b[47;30m means that it will set a white background (47) and it will print white characters (30) //In this we also could have used the printf("\x1b[47;30mBlack text on white background\x1b[0m"); printf("\x1b[29;15HPress 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; }
s32 menu_cb_choose_file (s32 idx, void *param) { s32 curidx = idx; s32 loaded = 0; while (aptMainLoop()) { gspWaitForVBlank(); curidx = print_file_list(curidx, &g_file_list); u32 kDown = wait_key(); if (kDown & KEY_B) { break; } else if (kDown & KEY_A) { consoleClear(); loaded = menu_execute_function(curidx, &g_file_list, &curidx); printf("%s\n", loaded? "[+] Success":"[!] Failure"); wait_any_key(); if (loaded) break; } else if (kDown & KEY_UP) { curidx--; } else if (kDown & KEY_DOWN) { curidx++; } gfxFlushBuffers(); gfxSwapBuffers(); } return 0; }
int main(int argc, char **argv) { //Initialize some sounds for high quality sounding moans and SCREAMS from the ACTION! srvInit(); aptInit(); hidInit(); csndInit(); gfxInitDefault(); consoleInit(GFX_TOP, NULL); printf("\x1b[1;5HGuess who is the freshest squid around?"); wait(10000); printf(" "); printf("\x1b[5;19H\x1b[32m\ Marie Squid\x1b[0m\n"); printf("\x1b[16;3HPress Start to know that such fresh exists."); printf("\x1b[17;3HPress A to get INTO IT!"); // Main loop while (aptMainLoop()) { //Scan all the inputs. This should be done once for each frame mostly for the shoots hidScanInput(); //hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame) hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_START){ //PRESS START TO RETURN TO HBL } if (kDown & KEY_A){ // PRESS A TO PLAY audio_load("squit.bin"); } // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); //Wait for VBlank gspWaitForVBlank(); } // Exit services... I know you want to come back... audio_stop(); audio_stop(); csndExit(); gfxExit(); hidExit(); aptExit(); srvExit(); return 0; }
void dumpFolder(char *path, u32 lowpath_id, char *dumpfolder, u8 *filebuffer, size_t bufsize) { Handle extdata_dir; Result ret = FSUSER_OpenDirectory(NULL, &extdata_dir, extdata_archive, FS_makePath(PATH_CHAR, path)); if (ret!=0) { printf("could not open dir\n"); gfxFlushBuffers(); gfxSwapBuffers(); return; } char dirname[0x120]; sprintf(dirname, "%s/%08x%s", dumpfolder, (unsigned int) lowpath_id, path); mkdir(dirname, 0777); FS_dirent dirStruct; char fileName[0x106] = ""; int cont = 0; while(1) { u32 dataRead = 0; FSDIR_Read(extdata_dir, &dataRead, 1, &dirStruct); if(dataRead == 0) break; unicodeToChar(fileName, dirStruct.name); printf("name: %s%s%s\n", path, fileName, dirStruct.isDirectory ? " (DIRECTORY)" : ""); gfxFlushBuffers(); gfxSwapBuffers(); cont++; if (dirStruct.isDirectory) { char newpath[0x120]; sprintf(newpath, "%s%s/", path, fileName); dumpFolder(newpath, lowpath_id, dumpfolder, filebuffer, bufsize); } else { char file_inpath[0x120]; char file_outpath[0x120]; char file_display_path[0x120]; sprintf(file_inpath, "%s%s", path, fileName); sprintf(file_outpath, "%s/%08x%s%s", dumpfolder, (unsigned int) lowpath_id, path, fileName); sprintf(file_display_path, "%08x%s%s", (unsigned int) lowpath_id, path, fileName); archive_copyfile(Extdata_Archive, SDArchive, file_inpath, file_outpath, filebuffer, 0, bufsize, file_display_path); } } printf("total files in 0x%08x%s: %d\n", (unsigned int) lowpath_id, path, (unsigned int) cont); gfxFlushBuffers(); gfxSwapBuffers(); FSDIR_Close(extdata_dir); }
void sleep(int milliseconds) { // attempts to emulate sleep in ms by assuming 60 fps int i; for (i = 0; i < (int)(milliseconds/16.67); i++) { gspWaitForVBlank(); gfxFlushBuffers(); gfxSwapBuffers(); } }
static int netloader_draw_progress(void) { char info[1024]; sprintf(info, "Transferring: %s\n\n%s",netloadedPath,progress); drawError(GFX_BOTTOM, "NetLoader", info, 0); gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); return 0; }
int main(int argc, char** argv) { gfxInitDefault(); InitOutput(); consoleClear(); Print("Press A to begin...\n"); // unsigned int test_counter = 0; // Moving it here causes this app to refuse to boot at all. while (aptMainLoop()) { gfxFlushBuffers(); gfxSwapBuffers(); hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_START) { break; } else if (kDown & KEY_A) { consoleClear(); unsigned int test_counter = 0; // This configuration works, but obviously only test 0 would run. TestCaller tests[] = { FS::TestAll, CPU::Integer::TestAll, CPU::Memory::TestAll, Kernel::TestAll, GPU::TestAll }; if (test_counter < (sizeof(tests) / sizeof(tests[0]))) { tests[test_counter](); test_counter++; } else { break; } Log("\n"); Print("Press A to continue...\n"); } gspWaitForVBlank(); } consoleClear(); gfxExit(); DeinitOutput(); return 0; }
/*! draw console to screen */ void console_render(void) { /* print tcp table */ print_tcp_table(); /* flush framebuffer */ gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); }
void wait_key(const u32 key) { while (aptMainLoop()) { hidScanInput(); if (hidKeysDown() & key) break; gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); } }
int main(int argc, char** argv) { gfxInitDefault(); consoleInit(GFX_TOP, NULL); svcCreateEvent(&threadRequest,0); u32 *threadStack = memalign(32, STACKSIZE); Result ret = svcCreateThread(&threadHandle, threadMain, 0, &threadStack[STACKSIZE/4], 0x3f, 0); printf("thread create returned %x\n", ret); // Main loop while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); printf("\x1b[5;0H"); printf("thread counter = %d\n",threadcount); u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu if (kDown & KEY_A) svcSignalEvent(threadRequest); // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); } // tell thread to exit threadExit = true; // signal the thread svcSignalEvent(threadRequest); // give it time to exit svcSleepThread(10000000ULL); // close handles and free allocated stack svcCloseHandle(threadRequest); svcCloseHandle(threadHandle); free(threadStack); gfxExit(); return 0; }
void waitForKey() { while (aptMainLoop()) { gfxSwapBuffers(); gfxFlushBuffers(); gspWaitForVBlank(); hidScanInput(); u32 kDown = hidKeysDown(); if (kDown) break; } }
std::string getInput(HB_Keyboard* sHBKB, bool &bCancelled) { sHBKB->HBKB_Clean(); touchPosition touch; u8 KBState = 4; std::string input; while (KBState != 1 || input.length() == 0) { if (!aptMainLoop()) { bCancelled = true; break; } hidScanInput(); hidTouchRead(&touch); KBState = sHBKB->HBKB_CallKeyboard(touch); input = sHBKB->HBKB_CheckKeyboardInput(); // If the user cancelled the input if (KBState == 3) { bCancelled = true; break; } // Otherwise if the user has entered a key else if (KBState != 4) { printf("%c[2K\r", 27); // If input string is > 50 characters, show just the right hand side if (input.length() > 49) { printf("%s", input.substr(input.length() - 49).c_str()); } else { printf("%s", input.c_str()); } } // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); //Wait for VBlank gspWaitForVBlank(); } printf("\n"); return input; }
int deleteEntry(u64 PID, u8 * buffer, u64 size) { u64 *file = (u64 *) buffer; u64 entry = 0; while (true) { if (file[entry * 0x2] == PID) break; entry++; if (entry * ENTRY_SIZE >= size) break; } if (entry * ENTRY_SIZE >= size) { printf("Version record not found.\n"); debug = true; return 2; } else { printf("Version record found at entry %X.\n", (unsigned int) (entry & 0xFFFFFFFF)); gfxFlushBuffers(); gfxSwapBuffers(); if (debug) { printf("Do you want to remove this record?(A/B)\n"); gfxFlushBuffers(); gfxSwapBuffers(); if (confirm() == false) { return 1; } } file[entry * 0x2] = 0x0; } return 0; }
void waitKey(u32 keyWait) { while (aptMainLoop()) { hidScanInput(); u32 kPressed = hidKeysDown(); if (kPressed & keyWait) break; gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); } }
int main() { gfxInitDefault(); consoleInit(GFX_TOP, NULL); Filesystem fs; std::string path = "pk/save/main"; if( fs.isInitialized() ) std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n"; else std::cout << "Failed to initialize filesystem, press START to exit."; while(aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if( fs.isInitialized() ) { if(kDown & KEY_X) { if( fs.exportSaveFile(path) ) std::cout << "Success! Savefile exported in " << path << ".\n"; else std:: cout << "Failed!"; waitA(); consoleClear(); std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n"; } if(kDown & KEY_Y) { if( fs.exportSaveFile(path) ) std::cout << "Success! Savefile imported\n"; else std:: cout << "Failed!"; waitA(); consoleClear(); std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n"; } } if(kDown & KEY_START) break; gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); } gfxExit(); return 0; }
int main() { srvInit(); aptInit(); hidInit(NULL); irrstInit(NULL); gfxInitDefault(); yeti_init( &yeti, (framebuffer_t*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), (framebuffer_t*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), textures, palette, lua ); gfxSet3D(true); game_init(&yeti); while(aptMainLoop()) { int i; for(i=0;i<2;i++) { yeti.viewport.front = yeti.viewport.back; yeti.viewport.back = (framebuffer_t*)gfxGetFramebuffer(GFX_TOP, leftOrRight?GFX_LEFT:GFX_RIGHT, NULL, NULL); game_draw(&yeti); leftOrRight^=1; } yetiUpdateKeyboard(&yeti); game_tick(&yeti); if(hidKeysDown()&KEY_START)break; gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForEvent(GSPEVENT_VBlank0, true); } gfxExit(); irrstExit(); hidExit(); aptExit(); srvExit(); return 0; }
int main(int argc, char **argv) { // Initialize services gfxInitDefault(); //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); // 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 printf("\x1b[0;0H shared page:\n"); volatile u8 *spbase; spbase = (volatile u8 *)0x1FF81000; for(int i = 0; i<16; ++i){ for(int j = 0; j<16; ++j){ printf("%02X ", *spbase); ++spbase; } printf("\n"); } // Flush and swap framebuffers gfxFlushBuffers(); gfxSwapBuffers(); //Wait for VBlank gspWaitForVBlank(); } // Exit services gfxExit(); return 0; }
static void renderFrame(void) { u8 bluish[] = { 0, 0, 127 }; gfxFillColor(GFX_TOP, GFX_LEFT, bluish); gfxFillColor(GFX_BOTTOM, GFX_LEFT, bluish); gfxDrawText(GFX_TOP, GFX_LEFT, top.console, 240-8, 0); gfxDrawText(GFX_BOTTOM, GFX_LEFT, bot.console, 240-8, 0); gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); }
/*! draw console to screen */ void console_render(void) { /* clear all screens */ if (background != NULL){ gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, background, 240, 320, 0, 0); }else{ gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)banner_bin, 240, 320, 0, 0); } /* flush framebuffer */ gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); }