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(); } }
void app() { gfxInitDefault(); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); // Initialize the render target C3D_RenderTarget *target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS); init_gpu_stuff(); //consoleInit(GFX_BOTTOM, NULL); // Main loop while (aptMainLoop()) { hidScanInput(); // Refresh Inputs // Process one frame menu.update(); // Draw C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_RenderTargetClear(target, C3D_CLEAR_ALL, 0x000000FF, 0); C3D_FrameDrawOn(target); menu.draw(); C3D_FrameEnd(0); } end_gpu_stuff(); // Deinitialize graphics C3D_Fini(); gfxExit(); }
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; }
bool OSystem_3DS::pollEvent(Common::Event &event) { if (showMessageOSD) { showMessageOSD = false; StatusMessageDialog dialog(messageOSD, 800); dialog.runModal(); } aptMainLoop(); // Call apt hook when necessary if (optionMenuOpening) { optionMenuOpening = false; OptionsDialog dialog; if (g_engine) g_engine->pauseEngine(true); dialog.runModal(); if (g_engine) g_engine->pauseEngine(false); } Common::StackLock lock(*eventMutex); if (_eventQueue.empty()) return false; event = _eventQueue.pop(); return true; }
void ProcessGameQueue() { // Create the tickets folder if we're in ticket mode char empty_titleVersion[2] = {0x00, 0x00}; std::vector<game_item>::iterator game = game_queue.begin(); while(aptMainLoop() && game != game_queue.end()) { std::string selected_titleid = (*game).titleid; std::string selected_enckey = (*game).titlekey; std::string selected_name = (*game).name; std::string selected_region = (*game).region; if (config.GetMode() == CConfig::Mode::INSTALL_TICKET) { CreateTicket(selected_titleid, selected_enckey, empty_titleVersion, "/CIAngel/tmp/ticket"); InstallTicket("/CIAngel/tmp/ticket", selected_titleid); } else { Result res = DownloadTitle(selected_titleid, selected_enckey, selected_name, selected_region); if (R_FAILED(res)) { printf("Error processing queue. Returning to menu\n"); break; } } game = game_queue.erase(game); } wait_key_specific("Press A to continue.\n", KEY_A); }
void wait_for_input(void) { printf("\n\nPress Start.\n\n"); fflush(stdout); while(aptMainLoop()) { u32 kDown; hidScanInput(); kDown = hidKeysDown(); if (kDown & KEY_START) break; if (kDown & KEY_SELECT) exit(0); #if 0 select_pressed = true; #endif svcSleepThread(1000000); } }
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() { suInit(); gfxInitDefault(); consoleInit(GFX_TOP, &topConsole); consoleSelect(&topConsole); cfguInit(); fsInit(); amInit(); fbTopLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); fbTopRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL); fbBottom = gfxGetFramebuffer(GFX_BOTTOM, 0, NULL, NULL); u8 next = mainMenu(); while (aptMainLoop()) { switch (next) { case 0: break; case 1: next = mainMenu(); break; //case 2: next = legitInstallMenu(); break; case 3: next = downgradeMenu(); break; //case 4: next = downgradeMSETMenu(); break; //case 5: next = downgradeBrowserMenu(); break; default: next = mainMenu(); } if (next == 0) break; } gfxExit(); 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); //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; }
int main() { gfxInitDefault(); consoleInit(GFX_TOP, NULL); Result rc = romfsInit(); if (rc) printf("romfsInit: %08lX\n", rc); else { printf("romfs Init Successful!\n"); printfile("romfs:/folder/file.txt"); // Test reading a file with non-ASCII characters in the name printfile("romfs:/フォルダ/ファイル.txt"); } // Main loop while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu } romfsExit(); gfxExit(); return 0; }
int main() { sf2d_init(); sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); consoleInit(GFX_BOTTOM, NULL); printf("sftd sample\n"); // Font loading sftd_init(); sftd_font *font = sftd_load_font_mem(airstrike_ttf, airstrike_ttf_size); while (aptMainLoop()) { hidScanInput(); if (hidKeysDown() & KEY_START) break; sf2d_start_frame(GFX_TOP, GFX_LEFT); sftd_draw_text(font, 10, 10, RGBA8(255, 0, 0, 255), 20, "Font drawing on the top screen!"); sftd_draw_textf(font, 10, 40, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps()); sf2d_end_frame(); sf2d_swapbuffers(); } sftd_free_font(font); sftd_fini(); sf2d_fini(); return 0; }
int main(int argc, const char* argv[]) { gfxInitDefault(); Result setCpuTimeRes = APT_SetAppCpuTimeLimit(30); if(R_FAILED(setCpuTimeRes)) { util_panic("Failed to set syscore CPU time limit: %08lX", setCpuTimeRes); return 1; } romfsInit(); cfguInit(); acInit(); ptmuInit(); httpcInit(0); amInit(); AM_InitializeExternalTitleDatabase(false); soc_buffer = memalign(0x1000, 0x100000); if(soc_buffer != NULL) { socInit(soc_buffer, 0x100000); } screen_init(); ui_init(); mainmenu_open(); while(aptMainLoop() && ui_update()); cleanup(); return 0; }
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; }
// -------------------------------------------------- ViewState Viewer::startMainLoop(Viewer* viewer) // -------------------------------------------------- { viewer->initialize(); u32 kDown, kHeld, kUp; touchPosition touch; while(viewer->isRunning() && aptMainLoop()) { hidScanInput(); kDown = hidKeysDown(); kHeld = hidKeysHeld(); kUp = hidKeysUp(); hidTouchRead(&touch); sf2d_start_frame(GFX_TOP, GFX_LEFT); viewer->drawTopScreen(); sf2d_end_frame(); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); viewer->drawBotScreen(); sf2d_end_frame(); sf2d_swapbuffers(); viewer->updateControls(kDown, kHeld, kUp, &touch); } return viewer->state(); }
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; }
int main(int argc, char **argv) { // without one iteration of the APT main loop. aptMainLoop(); PTM_RebootAsync(); return 0; }
int autoBootFix(int index) { int delay = config->autobootfix; while (aptMainLoop() && delay > 0) { gfxSwap(); delay--; } return load(config->entries[index].path, config->entries[index].offset); }
void waitForStart() { while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_START)break; } }
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; }
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; }
int confirm() { while (aptMainLoop()) { hidScanInput(); gspWaitForVBlank(); u32 kDown = hidKeysDown(); if (!(kDown & (KEY_A | KEY_B))) break; } while (aptMainLoop()) { hidScanInput(); gspWaitForVBlank(); u32 kDown = hidKeysDown(); if (kDown & KEY_A) return true; if (kDown & KEY_B) return false; } return false; }
int main(int argc, char **argv) { // Start sf2dlib sf2d_init(); sf2d_set_clear_color(RGBA8(0xF5, 0xF2, 0xEF, 0xFF)); // Initialize console on top screen // consoleInit(GFX_TOP, NULL); printf("Sizeof report:\n"); printf(" > elementNode: %i\n", sizeof(elementNode_s)); printf(" > elementList: %i\n", sizeof(elementList_s)); printf(" %2i | %2i |", strcmp("ab", "aa"), strcmp("ab", "ac")); printf(" %2i | %2i \n", strcmp("a ", "aA"), strcmp("a ", "aa")); AlchemyScene scene; scene.initialize(); // consoleClear(); keystate_s ks; while(aptMainLoop()) { hidKeys(&ks); // Draw the top screen sf2d_start_frame(GFX_TOP, GFX_LEFT); scene.drawTopScreen(); sf2d_end_frame(); // Draw the bottom screen sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); scene.drawBottomScreen(); sf2d_end_frame(); // Swap the buffers sf2d_swapbuffers(); scene.updateInput(ks); // Exit the loop if (ks.down & KEY_START) break; } scene.destroy(); // Stop sf2dlib sf2d_fini(); return 0; }
void waitForKey() { while (aptMainLoop()) { gfxSwapBuffers(); gfxFlushBuffers(); gspWaitForVBlank(); hidScanInput(); u32 kDown = hidKeysDown(); if (kDown) break; } }
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; }
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; }
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() { gfxInitDefault(); hidInit(NULL); void* device = gfxCreateDevice(240, 400); gfxMakeCurrent(device); glViewport(0, 0, 240, 400); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float near = 0.1f; float far = 100.0f; float fov = 90.0f; float aspect = 240.0f / 400.0f; float t = tan(fov * 3.14159 / 360.0) * near; float b = -t; float l = aspect * b; float r = aspect * t; glFrustumf(l, r, b, t, near, far); //3DS' framebuffers are sideways glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); while (aptMainLoop()) { hidScanInput(); if (keysDown() & KEY_START) break; DrawGLScene(); gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL)); gfxFlushBuffers(); gfxSwapBuffersGpu(); gspWaitForVBlank(); } // Exit services gfxExit(); hidExit(); return 0; }