void CMD(void){ char CMD[256]; //int NUMBINPUT; consoleClear(); iprintf("Weclome to debug screen\n"); while(1){ scanf("%s", CMD); if(!strcmp(CMD, "/server")){ debug = true; break; } else if((!strcmp(CMD, "/version")) || (!strcmp(CMD, "/ver"))){ iprintf("Version: %d\n", VERSION); } else if((!strcmp(CMD, "/help")) || (!strcmp(CMD, "/?"))){ iprintf("%s", HELP); } else if(!strcmp(CMD, "/back")){ consoleClear(); break; } else if(!strcmp(CMD, "/clear")){ consoleClear(); } else if(!strcmp(CMD, "/exit")){ exit(0); } else{ iprintf("Unknown Command\n"); } } }
bool FrameProc(){ bluVent bluMe = tblu->Input_PumpQueue(); if(bluMe.msg == KEYPRESS){ if(bluMe.keys == KEY_A){ for(int i = 0; i < 150; i++){ tblu->GFX_PlayAnimation(&bsp, &tban); tblu->GFX_BltSpr(&bsp); swiWaitForVBlank(); consoleClear(); iprintf("\x1b[10;0H Sprite= 1\n"); } } if(bluMe.keys == KEY_B){ for(int i = 0; i < 150; i++){ tblu->GFX_PlayAnimation(&bsp, &tban2); tblu->GFX_BltSpr(&bsp); swiWaitForVBlank(); consoleClear(); iprintf("\x1b[10;0H Sprite= 2\n"); } } if(bluMe.keys == KEY_DOWN){ bluVent b = {QUIT}; tblu->Input_PushEvent(b); } } if(bluMe.msg == QUIT){ return true; } //this is just a test hope it works, if program, idles wait for input tblu->Input_KeysPressed(); return false; }
void Display::clearGfx(){ consoleSelect(&subConsole); consoleClear(); consoleSelect(&mainConsole); consoleClear(); oamClear(&oamSub, 0, 0); oamClear(&oamMain, 17, 110); }
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; }
// Clears the screen and rewrites the "Made by" sentence void reset_screens() { consoleSelect(&top_screen); consoleClear(); set_font_color(cyan); iprintf("Made by Lennart Kroes, s1062295"); consoleSelect(&bottom_screen); consoleClear(); set_font_color(cyan); iprintf("Made by Lennart Kroes, s1062295"); }
// Clears the screen and rewrites the "Made by" sentence on screen void reset_screens() { Color default_color = yellow; consoleSelect(&top_screen); consoleClear(); set_font_color(default_color); puts("Made by Lennart Kroes, s1062295\n"); consoleSelect(&bottom_screen); consoleClear(); set_font_color(default_color); puts("Made by Lennart Kroes, s1062295\n"); }
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; }
void action_download_json() { consoleClear(); download_JSON(); load_JSON_data(); }
static void updateConsole() { consoleClear(); iprintf("\n \x1b[36mLots of models\n Draw mode: %s\n Model: %s\n\n", drawMode ? "LINES" : "TRIANGLES", getModelName()); }
void ui_pause(const char* message) { consoleSelect(&top_screen); consoleClear(); printf("%s\n\n\n\n\nA = Continue", message); gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); while (aptMainLoop()) { hidScanInput(); if (hidKeysDown() & KEY_A) { consoleClear(); svcSleepThread(100000000); break; } } }
void consoleInitProgress(const char* header, const char* text, const float progress) { consoleClear(); // Print progress bar borders int progressBarY = consoleCurrent->consoleHeight / 2 - 1; consoleCurrent->cursorY = progressBarY; int startX = ProgressBarPadding; int endX = consoleCurrent->consoleWidth - ProgressBarPadding + 1; int startY = progressBarY; for (int i = startX; i < endX; i++) { // Draw left and right border for (int j = 0; j < 12; j++) { consoleCurrent->frameBuffer[((startX * 8 - 3) * 240) + (230 - (startY * 8)) + j] = 0xffff; consoleCurrent->frameBuffer[((endX * 8 - 6) * 240) + (230 - (startY * 8)) + j] = 0xffff; } // Draw top and bottom borders for (int j = 0; j < (i < endX - 1 ? 8 : 6); j++) { consoleCurrent->frameBuffer[((i * 8 + j - 3) * 240) + (239 - (startY * 8 - 3))] = 0xffff; consoleCurrent->frameBuffer[((i * 8 + j - 3) * 240) + (239 - ((startY + 1) * 8 + 2))] = 0xffff; } } // Print header consoleCurrent->cursorY = progressBarY - 2; consoleCurrent->cursorX = ProgressBarPadding; std::printf("%s%s%s", CONSOLE_YELLOW, header, CONSOLE_RESET); // Set data consoleSetProgressData(text, progress); }
void action_toggle_install() { consoleClear(); CConfig::Mode nextMode = CConfig::Mode::INSTALL_CIA; switch (config.GetMode()) { case CConfig::Mode::DOWNLOAD_CIA: nextMode = CConfig::Mode::INSTALL_CIA; break; case CConfig::Mode::INSTALL_CIA: nextMode = CConfig::Mode::INSTALL_TICKET; break; case CConfig::Mode::INSTALL_TICKET: nextMode = CConfig::Mode::DOWNLOAD_CIA; break; } if (nextMode == CConfig::Mode::INSTALL_TICKET || nextMode == CConfig::Mode::INSTALL_CIA) { if (!bSvcHaxAvailable) { nextMode = CConfig::Mode::DOWNLOAD_CIA; printf(CONSOLE_RED "Kernel access not available.\nCan't enable Install modes.\nYou can only make a CIA.\n" CONSOLE_RESET); wait_key_specific("\nPress A to continue.", KEY_A); } } config.SetMode(nextMode); }
void Display::padsUpdate(){ u8 noteStatus; char* noteName; if (Cfg::pads.updated){ if (Cfg::pads.oct_updated){ consoleSelect(&subConsole); consoleClear(); } for (u8 i = 0; i < 12; ++i){ noteStatus = Cfg::notesStatus[Cfg::pads.channel][i + Cfg::pads.baseNote]; if (Cfg::pads.oct_updated){ noteName = midi->getNoteName(i + Cfg::pads.baseNote); echo(0, 40, 22 - (i/4)*8, (i%4)*8+3, noteName); } setPadSpriteFrame(i,noteStatus); } Cfg::pads.updated = false; Cfg::pads.oct_updated = false; } octaveSelectSprite->display(25, 231, 144 - Cfg::pads.baseNote, OBJPRIORITY_0, 0); consoleSelect(&mainConsole); iprintf("\x1b[1;10H%2d", Cfg::pads.channel + 1); padsButtonsStatus(); }
int main(void) { consoleDemoInit(); Keyboard *kbd = keyboardDemoInit(); kbd->OnKeyPressed = OnKeyPressed; while(1) { char myName[256]; iprintf("What is your name?\n"); scanf("%s", myName); iprintf("\nHello %s", myName); scanKeys(); while(!keysDown())scanKeys(); swiWaitForVBlank(); consoleClear(); } 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; }
void Menu::Main() { consoleClear(); printf("\n netxmms-nds\n ___________\n\n" " A - CONNECT\n" " B - CONFIGURE\n\n" " START - INFORMATION"); while(1) { swiWaitForVBlank(); scanKeys(); u32 entry = keysDown(); if(entry & KEY_A) { Menu::ConnectWifi(); return; } else if(entry & KEY_B) { Menu::Configuration(); return; } else if(entry & KEY_START) { Menu::Information(); return; } } }
void DSGM_InitText(DSGM_Layer *layer) { DSGM_Debug("Init text: screen %d, layerNumber %d, vramId %d\n", layer->screen, layer->layerNumber, DSGM_text[layer->screen][layer->layerNumber].bgId); ConsoleFont font; if(layer->background != DSGM_DEFAULT_FONT) { font.gfx = bgGetGfxPtr(layer->vramId); DSGM_UnlockBackgroundPalette(layer->screen); font.pal = (u16 *)&(layer->screen == DSGM_TOP ? VRAM_E_EXT_PALETTE : VRAM_H_EXT_PALETTE)[layer->layerNumber][0]; font.numColors = 2; font.numChars = 127; font.bpp = 4; font.asciiOffset = 0; font.convertSingleColor = false; } consoleInit(&DSGM_text[layer->screen][layer->layerNumber], layer->layerNumber, BgType_Text4bpp, BgSize_T_256x256, layer->mapBase, layer->tileBase, layer->screen, layer->background == DSGM_DEFAULT_FONT); layer->vramId = DSGM_text[layer->screen][layer->layerNumber].bgId; if(layer->background != DSGM_DEFAULT_FONT) { consoleSetFont(&DSGM_text[layer->screen][layer->layerNumber], &font); DSGM_LockBackgroundPalette(layer->screen); } DSGM_textLayer[layer->screen] = layer->layerNumber; consoleSelect(&DSGM_text[layer->screen][layer->layerNumber]); consoleClear(); }
int main() { consoleDemoInit(); uint ticks = 0; TimerStates state = timerState_Stop; int down = keysDown(); while(!(down & KEY_START)) { swiWaitForVBlank(); consoleClear(); scanKeys(); down = keysDown(); if(state == timerState_Running) { ticks += timerElapsed(0); } if(down & KEY_A) { if(state == timerState_Stop) { timerStart(0, ClockDivider_1024, 0, NULL); state = timerState_Running; } else if(state == timerState_Pause) { timerUnpause(0); state = timerState_Running; } else if(state == timerState_Running) { ticks += timerPause(0); state = timerState_Pause; } } else if(down & KEY_B) { timerStop(0); ticks = 0; state = timerState_Stop; } iprintf("Press A to start and pause the \ntimer, B to clear the timer \nand start to quit the program.\n\n"); iprintf("ticks: %u\n", ticks); iprintf("second: %u:%u\n", ticks/TIMER_SPEED, ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED); } if(state != timerState_Stop) { timerStop(0); } return 0; }
void consoleOff(void) { #if PLATFORM == WINDOWS consoleClear( ); #elif PLATFORM == UNIX || PLATFORM == OSX refresh( ); endwin( ); #endif }
void drawHelp(void) { consoleSelect(&logConsole); consoleClear(); printf(" Welcome in tvds, a tdvs clone.\n"); printf("\n"); switch (state) { case STATE_BROWSE: { printf("> [Up/Down] Select file/folder\n"); printf("> [L/R] Swap between Save/Sdmc folder\n"); printf("> [A] Navigate inside a folder\n"); printf("> [B] Return to the parent folder\n"); printf("> [X] Delete the current file/folder\n"); printf("> [Y] Copy the current file/folder\n"); break; } case STATE_BACKUP: { printf("> [Up/Down] Select backup\n"); printf("> [A] Inject the selected backup back\n"); printf("> [X] Delete the selected backup\n"); printf("> [Y] Create a new backup\n"); break; } default: break; } printf("> [Select] Print these instructions\n"); printf("> [Start] Exit tvds\n"); printf("\n"); consoleSelectDefault(); consoleSelect(&titleConsole); consoleClear(); printf("Title id: 0x%016llx", titleid); consoleSelectDefault(); }
void filePrintFileList(const char *dir, int first, int select, int count, bool cancel = false) { if (select < first) select = first; consoleSelect(&lowerScreen); consoleSetWindow(&lowerScreen, 0, 0, 32, 19); consoleClear(); char *buf = (char*)data; for (int i = 0; i < first; i++) { buf = strchr(buf, '\n') + 1; } for (int i = first; (i < first + 18) && (i < count); i++) { char *newline = strchr(buf, '\n'); int linelen = newline - buf; *newline = 0; if (*buf == 'd') { if (i != select) iprintf("[%.29s]\n", buf+1); else iprintf("-->[%.26s]\n", buf+1); } else { if (i != select) iprintf("%.31s\n", buf+1); else iprintf("-->%.28s\n", buf+1); } *newline = '\n'; buf += linelen+1; } consoleSelect(&lowerScreen); consoleSetWindow(&lowerScreen, 0, 18, 32, 6); consoleClear(); iprintf("================================"); if (cancel) iprintf(stringsGetMessageString(STR_FS_WRITE)); else iprintf(stringsGetMessageString(STR_FS_READ)); }
// -------------------------------------------------- Result SavexitViewer::initialize() // -------------------------------------------------- { if (hasChild()) { if (child->initialize() == PARENT_STEP) ; else return CHILD_STEP; } // Viewer::initialize(); // Not useful here! consoleClear(); return SUCCESS_STEP; }
void Menu::NX(int sock) { int volume = 77; while(1) { consoleClear(); iprintf("\n netxmms-nds\n ___________\n\n" " A - PLAY\n" " B - PAUSE\n" " Y - STOP\n" " R - NEXT\n" " L - PREVIOUS\n" " < - VOLUME-\n" " > - VOLUME+\n\n" " VOLUME: %d%%", volume); while(1) { swiWaitForVBlank(); scanKeys(); int pressed = keysDown(); int held = keysHeld(); if(pressed & KEY_A) NX::Play(sock); if(pressed & KEY_B) NX::Pause(sock); if(pressed & KEY_Y) NX::Stop(sock); if(pressed & KEY_R) NX::Next(sock); if(pressed & KEY_L) NX::Previous(sock); if(pressed & KEY_LID) { int s = REG_POWERCNT; REG_POWERCNT = 0; while(1) { scanKeys(); if(keysUp() & KEY_LID) { REG_POWERCNT = s; break; } } } if(held & KEY_LEFT && volume > 0) { volume--; NX::Volume(sock, volume); break; } else if(held & KEY_RIGHT && volume < 100) { volume++; NX::Volume(sock, volume); break; } } } }
void init_backgrounds() { int main_bg2 = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgSetPriority(main_bg2, BG_PRIORITY(1)); int main_bg3 = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 6, 0); bgSetPriority(main_bg3, BG_PRIORITY(0)); consoleInit(&top_screen, 0, BgType_Text4bpp, BgSize_T_256x256, 31, 0, 0, 1); consoleSelect(&top_screen); consoleClear(); puts("Made by Lennart Kroes, s1062295"); }
void action_manual_entry() { HB_Keyboard sHBKB; bool bKBCancelled = false; consoleClear(); // Keep looping so the user can retry if they enter a bad id/key while(true) { printf("Please enter a titleID:\n"); std::string titleId = getInput(&sHBKB, bKBCancelled); std::string key; if (bKBCancelled) { break; } for (unsigned int i = 0; i < sourceData.size(); i++){ std::string tempId = sourceData[i]["titleid"].asString(); std::string tempKey = sourceData[i]["enckey"].asString(); if(tempId.compare(titleId) == 0 && tempKey.length() == 32) { printf("Found encTitleKey, proceeding automatically\n"); key = tempKey; break; } } if(key.length() != 32) { printf("Please enter the corresponding encTitleKey:\n"); key = getInput(&sHBKB, bKBCancelled); if (bKBCancelled) { break; } } if (titleId.length() == 16 && key.length() == 32) { DownloadTitle(titleId, key, "", ""); wait_key_specific("\nPress A to continue.\n", KEY_A); break; } else { printf("There was an error in you input:\n"); if(titleId.length() != 16) { printf("titleIDs are 16 chars long, not %i\n", titleId.length()); } if(key.length() != 32) { printf("encTitleKeys are 32 chars long, not %i\n", key.length()); } } } }
void advMultipleLayers(void) { videoSetMode(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG); //initialize the backgrounds int bg1 = bgInit(0, BgType_Text8bpp, BgSize_ER_256x256, 0,1); int bg2 = bgInit(1, BgType_Text8bpp, BgSize_ER_256x256, 1,1); int bg3 = bgInit(2, BgType_ExRotation, BgSize_ER_256x256, 2,1); //make sure the floor is on the bottom (by default hardware layer 0 will be rendered last) bgSetPriority(bg1, 3); bgSetPriority(bg2, 2); bgSetPriority(bg3, 1); //they all share tiles and a palette dmaCopy(MultilayerTiles, bgGetGfxPtr(bg1), sizeof(MultilayerTiles)); dmaCopy(MultilayerPal, BG_PALETTE, sizeof(MultilayerPal)); //all we need to do is copy in the maps dmaCopy(Layer_1Map, bgGetMapPtr(bg1), Layer_1MapLen); dmaCopy(Layer_2Map, bgGetMapPtr(bg2), Layer_2MapLen); dmaCopy(Layer_3Map, bgGetMapPtr(bg3), Layer_3MapLen); int keys = 0; bool bg1_hidden = false; bool bg2_hidden = false; bool bg3_hidden = false; while(!(keys & KEY_B)) { scanKeys(); keys = keysDown(); if(keys & KEY_UP) bg1_hidden = !bg1_hidden; if(keys & KEY_DOWN) bg2_hidden = !bg2_hidden; if(keys & KEY_LEFT) bg3_hidden = !bg3_hidden; swiWaitForVBlank(); bg1_hidden ? bgHide(bg1) : bgShow(bg1); bg2_hidden ? bgHide(bg2) : bgShow(bg2); bg3_hidden ? bgHide(bg3) : bgShow(bg3); consoleClear(); iprintf("Press UP DOWN LEFT to toggle the layers\n\n"); iprintf("Floor (UP): %s\n", bg1_hidden ? "hidden" : "displayed"); iprintf("Walls (DOWN): %s\n", bg2_hidden ? "hidden" : "displayed"); iprintf("Decorations (LEFT): %s\n", bg3_hidden ? "hidden" : "displayed"); } }
int pchexexit(struct s_pchex *pch) { consoleSelect(&pch->bot); consoleClear(); printf("\x1B[15;2H"); printf("Program ended, press A to finish\n"); waitKey(KEY_A); free(pch->save); gfxExit(); filesysExit(&pch->sd.handle, &pch->sav.handle, &pch->sd.arch, &pch->sav.arch); return (0); }
void menu_print_page (const page_t *page) { int i, cur; u32 keys, keys_; cur = 0; while (1) { consoleClear(); iprintf("-- %s\n\n", page->title); const entry_t *sel_entry = &page->entries[cur]; for (i = 0; i < page->entries_no; i++) { const entry_t *entry = &page->entries[i]; iprintf("%c %s %s\n", (i == cur) ? '>' : ' ', entry->label, (entry->opts_no) ? entry->opts[*entry->opt_ptr] : ""); } scanKeys(); keys = keysDown(); keys_ = keysDownRepeat(); if (keys_&KEY_UP) { cur--; if (cur < 0) cur = page->entries_no - 1; } if (keys_&KEY_DOWN) { cur++; if (cur == page->entries_no) cur = 0; } if (sel_entry->opts_no && (keys_&(KEY_LEFT|KEY_RIGHT))) { if (keys_&KEY_LEFT && *sel_entry->opt_ptr > 0) (*sel_entry->opt_ptr)--; if (keys_&KEY_RIGHT && *sel_entry->opt_ptr < sel_entry->opts_no - 1) (*sel_entry->opt_ptr)++; if (!sel_entry->confirm && sel_entry->cb) sel_entry->cb(*sel_entry->opt_ptr); } if (keys&KEY_A && sel_entry->cb) { sel_entry->cb(*sel_entry->opt_ptr); return; } if (keys&(KEY_B|KEY_START)) return; swiWaitForVBlank(); } }
void conn_main() { APP_STATUS status; u32 it = 0; int ret = 0; int first = 1; int exiting = 0; while((status = aptGetStatus()) != APP_EXITING) { hidScanInput(); consoleClear(&bot); print(&bot, "frame: %08x\n", it); print(&bot, "ret: %08x\n", ret); print(&bot, "last_cmd: %02x\n", last_cmd & 0xFF); if(!first) { u32 bytes_read = 0; while(1) { ret = recv(sock, &cmd, sizeof(cmd), 0); if(ret < 0) { if(ret == -EWOULDBLOCK) continue; break; } bytes_read += ret; if(bytes_read == sizeof(cmd)) { svcSignalEvent(new_cmd_event); svcWaitSynchronization(cmd_done_event, U64_MAX); svcClearEvent(cmd_done_event); send(sock, &resp, sizeof(resp), 0); if(last_cmd_result == 0xDEAD) exiting = 1; break; } } } first = 0; it++; if(enable_draw) renderFrame(); u32 keys = hidKeysUp(); if(keys & KEY_A || exiting) break; } }
void advRotating(void) { videoSetMode(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG); int bg = bgInit(3, BgType_ExRotation, BgSize_ER_256x256, 0,1); dmaCopy(TextBackgroundsTiles, bgGetGfxPtr(bg), sizeof(TextBackgroundsTiles)); dmaCopy(TextBackgroundsPal, BG_PALETTE, sizeof(TextBackgroundsPal)); dmaCopy(Layer256x256Map, bgGetMapPtr(bg), Layer256x256MapLen); bgMosaicEnable(bg); int keys = 0; int angle = 0; int center_x = 0; int center_y = 0; while(!(keys & KEY_B)) { scanKeys(); keys = keysHeld(); if(keys & KEY_UP) center_y--; if(keys & KEY_DOWN) center_y++; if(keys & KEY_LEFT) center_x--; if(keys & KEY_RIGHT) center_x++; if(keys & KEY_L) angle-=40; if(keys & KEY_R) angle+=40; if(center_x > 256) center_x = 256; if(center_x < 0) center_x = 0; if(center_y > 192) center_y = 192; if(center_y < 0) center_y = 0; swiWaitForVBlank(); bgSetRotate(bg, angle); bgSetScroll(bg, center_x, center_y); bgSetCenter(bg, center_x, center_y); bgUpdate(); consoleClear(); iprintf("Press B to exit.n"); iprintf("Angle: %d \ncenter X: %d center Y: %d", angleToDegrees(angle), center_x, center_y); } }