void bsp_start (void) { /* initialize irq management */ BSP_rtems_irq_mngt_init (); /* setup console mode for lower screen */ irqEnable (IRQ_VBLANK); videoSetMode (0); videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankC (VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE (31); BG_PALETTE_SUB[255] = RGB15 (31, 31, 31); consoleInitDefault ((u16 *) SCREEN_BASE_BLOCK_SUB (31), (u16 *) CHAR_BASE_BLOCK_SUB (0), 16); /* print status message */ printk ("[+] kernel console started\n"); /* set the cpu mode to system user */ arm_cpu_mode = 0x1f; /* configure clock period */ Configuration.microseconds_per_tick = 10000; /* us */ defaultExceptionHandler (); }
//--------------------------------------------------------------------------------- // Places the console in a default mode using bg0 of the sub display, and vram c for // font and map..this is provided for rapid prototyping and nothing more void consoleDemoInit(void) { //--------------------------------------------------------------------------------- videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 //consoleInit() is a lot more flexible but this gets you up and running quick consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); }
void arm9_consoleInit() { powerON(/*POWER_ALL*/POWER_LCD); // Use the main screen for output videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG); BG0_CR = BG_MAP_BASE(31); // Set the colour of the font to White. BG_PALETTE[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- struct stat st; // Enable VBlank for Vblank Interrupt Wait irqInit(); irqEnable(IRQ_VBLANK); videoSetMode(0); //not using the main screen // Subscreen as a console videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankH(VRAM_H_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(15); BG_PALETTE_SUB[0]=0; BG_PALETTE_SUB[255]=0xffff; consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); iprintf ("Init'ing FAT..."); if (fatInitDefault()) { iprintf ("okay\n"); } else { iprintf ("fail!\n"); stop(); } if (stat (DEFAULT_FILE, &st) >= 0) { iprintf ("Running %s\n", DEFAULT_FILE); runNdsFile (DEFAULT_FILE); } else { std::string filename = browseForFile (".nds"); iprintf ("Running %s\n", filename.c_str()); runNdsFile (filename.c_str()); } iprintf ("Start failed\n"); stop(); return 0; }
int main() { irqInit(); irqEnable(IRQ_VBLANK); videoSetMode(0); videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31, 31, 31); consoleInitDefault((u16 *) SCREEN_BASE_BLOCK_SUB(31), (u16 *) CHAR_BASE_BLOCK_SUB(0), 16); printf("Starting FAT\n"); fatInitDefault(); printf("Starting WiFi\n"); wifiInit(); while(1) Menu::Main(); return 0; }
int NDS_VideoInit(_THIS, SDL_PixelFormat *vformat) { //printf("WARNING: You are using the SDL NDS video driver!\n"); /* Determine the screen depth (use default 8-bit depth) */ /* we change this during the SDL_SetVideoMode implementation... */ vformat->BitsPerPixel = 16; // mode 3 vformat->BytesPerPixel = 2; vformat->Rmask = 0x0000f800; vformat->Gmask = 0x000007e0; vformat->Bmask = 0x0000001f; powerON(POWER_ALL); irqInit(); irqSet(IRQ_VBLANK, on_irq_vblank); irqEnable(IRQ_VBLANK); //set the mode for 2 text layers and two extended background layers //videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetMode(MODE_6_2D | DISPLAY_BG2_ACTIVE); //set the sub background up for text display (we could just print to one //of the main display text backgrounds just as easily videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text //set the first two banks as background memory and the third as sub background memory //D is not used..if you need a bigger background then you will need to map //more vram banks consecutivly (VRAM A-D are all 0x20000 bytes in size) //vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000,VRAM_C_SUB_BG , VRAM_D_LCD); vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG); //vramSetBankA(VRAM_A_MAIN_BG); //vramSetBankB(VRAM_B_MAIN_BG); //vramSetBankC(VRAM_C_MAIN_BG); //vramSetBankD(VRAM_D_MAIN_BG); //vramSetBankE(VRAM_E_MAIN_BG); //vramSetBankF(VRAM_F_MAIN_BG); //vramSetBankG(VRAM_G_MAIN_BG); vramSetBankH(VRAM_H_SUB_BG); vramSetBankI(VRAM_I_LCD); ////////////////set up text background for text///////////////////// SUB_BG0_CR = BG_MAP_BASE(8); BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255 ///////////////set up our bitmap background/////////////////////// //BG3_CR = BG_BMP16_512x512; //these are rotation backgrounds so you must set the rotation attributes: //these are fixed point numbers with the low 8 bits the fractional part //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap /* BG3_XDX = 1<<8; BG3_XDY = 0; BG3_YDX = 0; BG3_YDY = 1<<8; //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2 BG3_CX = 0; BG3_CY = 0; */ //consoleInit() is a lot more flexible but this gets you up and running quick consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); frontBuffer =(u16*)(0x06000000); //backBuffer =(u16*)(0x06000000 + 1024 * 512*2); //lcdSwap(); /* We're done! */ return 0; }
int main(void) { gfxInitDefault(); consoleInitDefault(); Result ret; state = STATE_START; ret = FS_Init(); if (R_FAILED(ret)) { consoleLog("\nCouldn't initialize the FS module!\n"); consoleLog("Have you selected a title?\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } ret = saveInit(); if (R_FAILED(ret)) { consoleLog("\nCouldn't initialize the Save module!\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } ret = saveGetTitleId(&titleid); if (R_FAILED(ret)) { consoleLog("\nCouldn't get the title id of the game!\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } fsDirInit(); fsBackInit(titleid); switchState(&state); consoleSelectNew(&consoleLog); drawHelp(); u64 heldUp = 0; u64 heldDown = 0; u32 kDown, kHeld; while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); kDown = hidKeysDown(); kHeld = hidKeysHeld(); switch (state) { case STATE_BROWSE: { if (kDown & (KEY_LEFT | KEY_RIGHT)) { fsDirSwitch(NULL); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_ZL) { fsDirSwitch(&saveDir); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_ZR) { fsDirSwitch(&sdmcDir); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_UP) { fsDirMove(-1); fsDirPrintCurrent(); heldUp = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_UP) { if (heldUp + HELD_TICK < svcGetSystemTick()) { fsDirMove(-1); fsDirPrintCurrent(); heldUp = svcGetSystemTick(); } } #endif if (kDown & KEY_DOWN) { fsDirMove(+1); fsDirPrintCurrent(); heldDown = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_DOWN) { if (heldDown + HELD_TICK < svcGetSystemTick()) { fsDirMove(+1); fsDirPrintCurrent(); heldDown = svcGetSystemTick(); } } #endif if (kDown & KEY_A) { ret = fsDirGotoSubDir(); consoleLog(" > fsDirGotoSubDir: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_B) { ret = fsDirGotoParentDir(); consoleLog(" > fsDirGotoParentDir: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_X) { ret = fsDirDeleteCurrentEntry(); consoleLog(" > fsDirDeleteCurrentEntry: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_Y) { ret = fsDirCopyCurrentEntry(false); consoleLog(" > fsDirCopyCurrentEntry: %lx\n", ret); fsDirPrintDick(); } break; } case STATE_BACKUP: { if (kDown & KEY_A) { ret = fsBackImport(); consoleLog(" > fsBackImport: %lx\n", ret); fsBackPrintSave(); } if (kDown & KEY_B) { state = STATE_BACKUP_KEY; // TODO: setKeyboardString consoleSelectNew(&logConsole); } if (kDown & KEY_X) { ret = fsBackDelete(); consoleLog(" > fsBackDelete: %lx\n", ret); fsBackPrintBackup(); } if (kDown & KEY_Y) { ret = fsBackExport(); consoleLog(" > fsBackExport: %lx\n", ret); fsBackPrintBackup(); } if (kDown & KEY_UP) { fsBackMove(-1); fsBackPrintBackup(); heldUp = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_UP) { if (heldUp + HELD_TICK < svcGetSystemTick()) { fsBackMove(-1); fsBackPrintBackup(); heldUp = svcGetSystemTick(); } } #endif if (kDown & KEY_DOWN) { fsBackMove(+1); fsBackPrintBackup(); heldDown = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_DOWN) { if (heldDown + HELD_TICK < svcGetSystemTick()) { fsBackMove(+1); fsBackPrintBackup(); heldDown = svcGetSystemTick(); } } #endif break; } case STATE_BACKUP_KEY: { // TODO: updateKeyboard if (kDown & KEY_A) { state = STATE_BACKUP; // TODO: getKeyboardString drawBackup(); } if (kDown & KEY_B) { state = STATE_BACKUP; drawBackup(); } break; } case STATE_ERROR: { consoleLog("\nAn error has occured...\n"); consoleLog("Please check previous logs!\n"); consoleLog("\nPress start to exit.\n"); state = STATE_EOF; break; } default: break; } { if (kDown & KEY_L) { // TODO: Prev switchState(&state); } if (kDown & KEY_R) { // TODO: Next switchState(&state); } if (kDown & KEY_SELECT) { drawHelp(); } } if (kDown & KEY_START) break; gfxFlushBuffers(); gfxSwapBuffers(); } fsDirExit(); fsBackExit(); FS_Exit(); { hidScanInput(); if (!(hidKeysHeld() & KEY_L) && !(hidKeysHeld() & KEY_R)) { u8 out = 0; FS_MediaType mediaType = 3; FSUSER_GetMediaType(&mediaType); Result ret = saveRemoveSecureValue(titleid, mediaType, &out); if (R_FAILED(ret)) { consoleSelect(&logConsole); printf("\nSecure value not removed.\n"); printf("It might already be unitialized.\n"); printf("Error code: 0x%lx (%i)\n", ret, out); printf("\n\nPress any key to exit.\n"); waitKey(KEY_ANY); } } } gfxExit(); return 0; }
int main() { struct timeval tv; powerON(POWER_ALL); //set mode 0, enable BG0 and set it to 3D videoSetMode(MODE_0_3D); //Use console videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); //iprintf("Starting up...\n"); // install the default exception handler defaultExceptionHandler(); //irqs are nice irqInit(); irqEnable(IRQ_VBLANK); // set the generic sound parameters setGenericSound( 11025, /* sample rate */ 127, /* volume */ 64, /* panning */ 1 ); /* sound format*/ glInit(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); //this should work the same as the normal gl call glViewPort(0,0,255,191); glClearColor(0,0,0,0); glClearDepth(0x7FFF); vramSetBankA(VRAM_A_TEXTURE); vramSetBankB(VRAM_B_TEXTURE); logo(); glGenTextures(1, &textureID); glBindTexture(0, textureID); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD , (u8*)die_bmp_bin); glGenTextures(1, &textureID2); glBindTexture(0, textureID2); glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)mario_bmp_bin); gettimeofday(&tv, NULL); //iprintf("Seeding with %d\n", tv.tv_usec); srand(tv.tv_usec); while(1){ gameLoop(); } return 0; }//end main
bool Console::AllocateConsole() { CoreAssert(this != NULL); #ifdef TARGET_OS_WINDOWS m_consoleAllocated = (AllocConsole() == TRUE); #elif defined (TARGET_OS_MACOSX) && 0 /* BSD-style pty code. */ char buf[64]; const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char *ptyminors = "0123456789abcdef"; int num_minors = strlen(ptyminors); int num_ptys = strlen(ptymajors) * num_minors; for (int i = 0; i < num_ptys; i++) { sprintf(buf, "/dev/pty%c%c", ptymajors[i / num_minors], ptyminors[i % num_minors]); m_ptyfd = open(buf, O_RDWR | O_NOCTTY); if (m_ptyfd < 0) continue; sprintf(m_slaveName, "/dev/tty%c%c", ptymajors[i / num_minors], ptyminors[i % num_minors]); /* Open the slave side. */ m_ttyfd = open(m_slaveName, O_RDWR | O_NOCTTY); if (m_ttyfd < 0) { close(m_ptyfd); break; } m_consoleAllocated = true; break; } if (m_consoleAllocated) { m_childPID = fork(); if (m_childPID == -1) { m_consoleAllocated = false; close(m_ttyfd); close(m_ptyfd); return m_consoleAllocated; } if (m_childPID == 0) { /* child */ close(m_ttyfd); char call[128]; char *pt = &m_slaveName[strlen(m_slaveName) - 1]; const char *xterm = "/usr/X11/bin/xterm"; sprintf(call, "-S%s/%d", pt, m_ptyfd); execl(xterm, xterm, "-bg", "black", "-fg", "white", "-geometry", "132x50", call, NULL); exit(0); } else { /* master */ close(m_ptyfd); } } #elif defined (TARGET_OS_NDSFIRMWARE) irqInit(); irqEnable(IRQ_VBLANK); videoSetMode(MODE_0_2D); videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31, 31, 31); consoleInitDefault((u16 *)SCREEN_BASE_BLOCK_SUB(31), (u16 *)CHAR_BASE_BLOCK_SUB(0), 16); m_consoleAllocated = true; #endif return m_consoleAllocated; }
int main(void) { touchPosition touch; videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 //consoleInit() is a lot more fluxible but this gets you up and running quick consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); ///////////// powerON(POWER_ALL); // set mode 0, enable BG0 and set it to 3D videoSetMode(MODE_0_3D); vramSetBankA(VRAM_A_TEXTURE); // irqs are nice irqInit(); irqEnable(IRQ_VBLANK); // initialize gl glInit(); // setup the rear plane glClearColor(2, 4, 3, 16); glClearDepth(GL_MAX_DEPTH); // this should work the same as the normal gl call glViewPort(0,0, 255,191); glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //~ glOrtho(0, 1, 192.0/256.0, 0, -10, 10); glOrthof32(0, 1<<12, (192<<12)/256, 0, -10<<12, 10<<12); REG_POWERCNT^= POWER_SWAP_LCDS; ///////////// flux_init(); create_frame_groups(); create_button_groups(); create_titleframe(); dmaCopy(fluxcolors, syscol_table, sizeof(fluxcolors)); dword rc1= create_rect(NOPARENT, 20,20, 128,96, 0x808080); dword rc= create_rect(NOPARENT, 10,10, 128,96, 0x404040|TRANSL_3); dword frm= clone_frame("titleframe", rc); clone_frame("titleframe", rc1); //~ clone_group("button", rc, 10,30, 30,14, ALIGN_LEFT|ALIGN_TOP); create_rect(rc, 10,10, 10,10, 0xFFFFFF|TRANSL_1); create_rect(rc, 20,10, 10,10, 0xFFFFFF|TRANSL_2); create_rect(rc, 30,10, 10,10, 0xFFFFFF|TRANSL_3); create_rect(rc, 10,15, 30,10, 0xFFFFFF|TRANSL_1); create_text(rc, 10,30, 40,40, "Text! Space!\nNewline!", 0xFFFFFF, FONT_DEFAULT); bool redraw_all= true; bool touch_wasdown= false; int lasttouch_x, lasttouch_y; while(1) { scanKeys(); u32 keysheld= keysHeld(); u32 keysdown= keysDown(); touch= touchReadXY(); if(keysdown&KEY_A) { redraw_all^= 1; iprintf("redraw each frame: %s\n", redraw_all? "on": "off"); } if(keysdown&KEY_B) { do_texalpha^= 1; iprintf("texture alpha: %s\n", do_texalpha? "on": "off"); } if(touch.x || touch.y) { flux_mouse_event(touch.px, touch.py, 1); lasttouch_x= touch.px, lasttouch_y= touch.py; touch_wasdown= true; } else { if(touch_wasdown) flux_mouse_event(lasttouch_x, lasttouch_y, 0); touch_wasdown= false; } flux_tick(); if(redraw_all) { redraw_rect(&viewport); update_rect(&viewport); } swiWaitForVBlank(); } return 0; }