static int NDS_RenderClear(SDL_Renderer *renderer) { NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; /* wait for capture unit to be ready */ while(REG_DISPCAPCNT & DCAP_ENABLE); /* 3D engine can only work on one screen at a time. */ data->is_sub = !data->is_sub; if (data->is_sub) { lcdMainOnBottom(); vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_SUB_SPRITE); REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3); } else { lcdMainOnTop(); vramSetBankD(VRAM_D_LCD); vramSetBankC(VRAM_C_SUB_BG); REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3); } glBegin2D(); glClearColor(renderer->r >> 3, renderer->g >> 3, renderer->b >> 3, renderer->a >> 3); return 0; }
void initMenu(void) { lcdMainOnTop(); videoSetMode(MODE_5_3D); videoSetModeSub(MODE_5_2D); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_SUB_BG,VRAM_D_TEXTURE); initD3D(); glInit(); glEnable(GL_TEXTURE_2D); glEnable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); initVramBanks(2); initTextures(); initMenuScene(); initMenuButtons(); //TEMP glLight(0, RGB15(31,31,31), cosLerp(4096), 0, sinLerp(4096)); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(24,24,24)); glMaterialf(GL_SPECULAR, RGB15(0,0,0)); glMaterialf(GL_EMISSION, RGB15(0,0,0)); glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? applyCameraState(&menuCamera,&cameraStates[4]); tempState=cameraStates[4]; testTransition=startCameraTransition(&cameraStates[1],&cameraStates[4],64); setupMenuPage(startMenuPage, startMenuPageLength); logoMain=createTexture("logo.pcx", "menu"); logoRotate=createTexture("rotate_logo.pcx", "menu"); logoAlpha=31; glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(0,0,0)); //TEMP? NOGBA("END mem free : %dko (%do)",getMemFree()/1024,getMemFree()); fadeIn(); }
// 2 frames delay void setupScaledScreens2() { REG_DISPCNT &= ~(3<<16); // Disable main display REG_DISPCNT_SUB |= 1<<16; // Enable sub display if (consoleScreen == 0) lcdMainOnTop(); else lcdMainOnBottom(); powerOn(backlights[!consoleScreen]); refreshScaleMode(); }
/* DS_SysInit Initializes DS specific system hardware and interrupts. */ LOCALPROC DS_SysInit(void) { defaultExceptionHandler(); powerOn(POWER_ALL_2D); lcdMainOnTop(); irqSet(IRQ_VBLANK, DS_VBlank_IRQ); irqSet(IRQ_HBLANK, DS_HBlank_IRQ); irqSet(IRQ_TIMER1, DS_Timer1_IRQ); irqEnable(IRQ_VBLANK); irqEnable(IRQ_HBLANK); irqEnable(IRQ_TIMER1); /* This sets up 2 timers as a milisecond counter. TIMER0_DATA Will overflow roughly every 1 msec into TIMER1_DATA. When TIMER1_DATA overflows an interrupt will be generated and DS_Timer1_IRQ will be called. */ TIMER0_DATA = 32768; TIMER0_CR = TIMER_DIV_1 | TIMER_ENABLE; TIMER1_DATA = 0; TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_IRQ_REQ; /* Testing. */ consoleDemoInit(); consoleDebugInit(DebugDevice_NOCASH); /* Use the default keyboard until I design a (good) UI... */ DSKeyboard = keyboardDemoInit(); keyboardShow(); /* Drop back to a read only filesystem embedded in the Mini vMac binary if we cannot open a media device. */ if (! fatInitDefault()) { nitroFSInit(); } }
static void setup() { consoleDemoInit(); //put 3D on top lcdMainOnTop(); //set mode 0, enable BG0 and set it to 3D videoSetMode(MODE_0_3D); // initialize gl glInit(); // enable antialiasing glEnable(GL_ANTIALIAS); // setup the rear plane glClearColor(0,0,0,31); // BG must be opaque for AA to work glClearPolyID(63); // BG must have a unique polygon ID for AA to work glClearDepth(0x7FFF); // Set our viewport to be the same size as the screen glViewport(0,0,255,191); glColor3b(255,255,0); glLight(0, RGB15(0,31,0) , 0, floattov10(-1.0), 0); //need to set up some material properties since DS does not have them set by default glMaterialf(GL_AMBIENT, RGB15(5,5,5)); glMaterialf(GL_DIFFUSE, RGB15(15,15,15)); glMaterialf(GL_SPECULAR, RGB15(8,8,8)); glMaterialf(GL_EMISSION, RGB15(5,5,5)); //ds uses a table for shinyness..this generates a half-assed one glMaterialShinyness(); //ds specific, several attributes can be set here glPolyFmt( POLY_ALPHA(31) | POLY_CULL_NONE | POLY_FORMAT_LIGHT0 ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, (float)W / H, Znear, Zfar); lookAtSelectedModel(); }
void splashScreen::initiate() { lcdMainOnTop(); videoSetMode(MODE_5_2D); videoSetModeSub(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG_0x06000000); vramSetBankC(VRAM_C_SUB_BG_0x06200000); //sets up our backgrounds bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256,0,0); dmaCopy(splashBitmap, bgGetGfxPtr(bg3), splashBitmapLen); dmaCopy(splashPal, BG_PALETTE, splashPalLen); bg2 = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, 0,0); dmaCopy(splashBitmap, bgGetGfxPtr(bg2), splashBitmapLen); dmaCopy(splashPal, BG_PALETTE_SUB, splashPalLen); initiated = true; }
void setupUnscaledScreens() { int screensToSet[2]; REG_DISPCNT &= ~(3<<16); REG_DISPCNT |= 1<<16; // Enable main display if (!consoleInitialized) { consoleDemoInit(); // Or, consoleInit(menuConsole, ...) setPrintConsole(menuConsole); BG_PALETTE_SUB[8*16 - 1] = RGB15(17,17,17); // Grey (replaces a color established in consoleDemoInit) consoleInitialized = true; } if (consoleScreen == 0) lcdMainOnBottom(); else lcdMainOnTop(); screensToSet[!consoleScreen] = true; if (!(fpsOutput || timeOutput || consoleDebugOutput || isMenuOn() || isFileChooserOn())) { screensToSet[consoleScreen] = false; REG_DISPCNT_SUB &= ~(3<<16); // Disable sub display } else { screensToSet[consoleScreen] = true; REG_DISPCNT_SUB &= ~(3<<16); REG_DISPCNT_SUB |= 1<<16; // Enable sub display } for (int i=0; i<2; i++) { if (screensToSet[i]) { if (i == consoleScreen) doAtVBlank(enableConsoleBacklight); else powerOn(backlights[i]); } else powerOff(backlights[i]); } }
// Adapted in part from the devkitPro examples. INT32 I_StartupSystem(void) { lcdMainOnTop(); videoSetModeSub(MODE_0_2D); vramSetBankC(VRAM_C_MAIN_BG); // Get this mapped *out* of the sub BG vramSetBankI(VRAM_I_SUB_BG_0x06208000); // The background VRAM that's mapped starts at 0x06208000. // The map base is specified in an offset of multiples of 2 KB // from 0x06200000, and the tile base in multiples of 16 KB. // We put the tiles at the start and the map 2 KB from the end // (i.e. 14 KB from the start). // The map base is then at 0x0620B800 = 0x06200000 + 16 * 0x800 + 7 * 0x800, // and the tile base is at 0x06208000 = 0x06200000 + 2 * 0x4000. consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 16+7, 2, false, true); // start FAT filesystem code, required for reading SD card if(!fatInitDefault()) I_Error("Couldn't init FAT."); return 0; }
static int opt_screen (const int sel) { emu_screen = sel; (sel) ? lcdMainOnBottom() : lcdMainOnTop(); return 1; }
void uiOpenNotebook(AppState & state) { lcdMainOnTop(); DIR_ITER* dir = diropen (MAINPATH); if (dir == NULL) { printf("Marginalia data not found\n"); return; } printf("\x1b[2J"); printf("Select notebook to open\n(Press Select to create NEW)"); struct stat st; char filename[MAXPATHLEN]; int i=0; std::vector<std::string> notebooks; while (dirnext(dir, filename, &st) == 0) { // st.st_mode & S_IFDIR indicates a directory // if (!(st.st_mode & S_IFDIR)) // continue; // if (strcmp(filename, "..") == 0) // continue; // if (strcmp(filename, ".") == 0) // continue; printf ("\x1b[%d;3H%d) %s\n", i+3, i, filename); notebooks.push_back(filename); i++; } dirclose (dir); int selected = 0; printf ("\x1b[%d;6H*", selected+3); while (1) { scanKeys(); if(keysHeld() & KEY_TOUCH) { } if (keysDown() & KEY_X) { } if (keysDown() & KEY_Y) { } if (keysDown() & KEY_SELECT) { printf ("\x1b[10;1H Insert new Directory Name"); char newName[256]; Keyboard *kbd = keyboardDemoInit(); scanf("%s", newName); printf ("\x1b[11;1H Creating directory %s", newName); state.notebookName = newName; if (mkdir(state.notebookName.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) { printf ("\x1b[12;1H directory creation failed"); continue; } state.lastPage = -1; state.scroll_x = 0; state.scroll_y = 0; state.center_x = MY_BG_W/2; state.center_y = MY_BG_H/2; fillDisplay(RGB15(0,0,0) | BIT(15), 0, state); std::string fileName = state.notebookName + "/notes.txt"; state.notebook = loadFile(fileName.c_str()); state.currentPage = &(state.notebook.pages[0]); drawPage(state.currentPage, RGB15(31,31,31) | BIT(15), state); lcdMainOnBottom(); return; } if (keysDown() & KEY_A) { printf ("\x1b[20;6H opening %s\n", notebooks[selected].c_str()); state.lastPage = -1; state.scroll_x = 0; state.scroll_y = 0; state.center_x = MY_BG_W/2; state.center_y = MY_BG_H/2; state.notebookName = notebooks[selected]; fillDisplay(RGB15(0,0,0) | BIT(15), 0, state); std::string fileName = state.notebookName + "/notes.txt"; state.notebook = loadFile(fileName.c_str()); state.currentPage = &(state.notebook.pages[0]); drawPage(state.currentPage, RGB15(31,31,31) | BIT(15), state); lcdMainOnBottom(); return; } if (keysDown() & KEY_B) { } if (keysDown() & KEY_LEFT) { } if (keysDown() & KEY_RIGHT) { } if (keysDown() & KEY_UP) { printf ("\x1b[%d;6H ", selected+3); selected -= 1; printf ("\x1b[%d;6H*", selected+3); } if (keysDown() & KEY_DOWN) { printf ("\x1b[%d;6H ", selected+3); selected += 1; printf ("\x1b[%d;6H*", selected+3); } swiWaitForVBlank(); } }
void initProgram() { //------------------------ // start initializing crap //------------------------ defaultExceptionHandler(); // set up the exception handler powerON(POWER_ALL_2D); // turn on everything #ifndef DEBUG_MODE fb_init(); // initialize top screen video #else debugInit(); #endif bg_init(); // initialize bottom screen video setNewOrientation(ORIENTATION_0); // set up extra vram banks to be scratch memory vramSetBankE(VRAM_E_LCD); vramSetBankF(VRAM_F_LCD); vramSetBankG(VRAM_G_LCD); vramSetBankH(VRAM_H_LCD); vramSetBankI(VRAM_I_LCD); fb_setBGColor(30653); bg_setBGColor(0); drawStartSplash(); lcdMainOnTop(); // set fb to top screen fb_swapBuffers(); bg_swapBuffers(); // out of order for competition irqInit(); // initialize irqs irqSet(IRQ_VBLANK, startvBlank); irqEnable(IRQ_VBLANK); setMode(INITFAT); setSoundInterrupt(); // initialize fifo irq setGenericSound(11025, 127, 64, 1); waitForInit(); // wait until arm7 has loaded and gone to sleep initComplexSound(); // initialize sound variables initWifi(); fixGautami(); setCursorProperties(0, 2, 0, 0); initCapture(); initClipboard(); // set defaults to english in case we can't load the langauge file for // some reason also takes care of partial translations. initLanguage(); initRandomList(); fixAndTags(); resetKeyboard(); setDate(); if(!DRAGON_InitFiles()) { // oops, no cf card! setMode(DISPLAYCOW); setFont(font_arial_11); setColor(0xFFFF); bg_dispSprite(96, 5, errmsg, 0); bg_setClipping(5,25,250,181); bg_dispString(0,0,l_nofat); bg_swapBuffers(); while(1) { // wee, la la la! // More or less, we aren't going to do nothing here } } //-------------------------------------------------------------------- //finished init, now check to make sure the DSOrganize dir is there... //-------------------------------------------------------------------- findDataDirectory(); makeDirectories(); if(DRAGON_FileExists("DSOrganize") != FE_DIR) { setMode(DISPLAYCOW); // oops, not there, we must create! DRAGON_mkdir("DSOrganize"); DRAGON_chdir("DSOrganize"); DRAGON_mkdir("DAY"); DRAGON_mkdir("HELP"); DRAGON_mkdir("LANG"); DRAGON_mkdir("RESOURCES"); DRAGON_mkdir("REMINDER"); DRAGON_mkdir("SCRIBBLE"); DRAGON_mkdir("TODO"); DRAGON_mkdir("VCARD"); DRAGON_mkdir("ICONS"); DRAGON_mkdir("CACHE"); DRAGON_mkdir("COOKIES"); DRAGON_mkdir("HOME"); DRAGON_chdir("/"); makeDefaultSettings(); setFont(font_arial_11); setColor(0xFFFF); bg_dispSprite(96, 5, errmsg, 0); bg_setClipping(5,25,250,181); bg_dispString(0,0, l_createdir); bg_swapBuffers(); while(!keysDown()) { scanKeys(); } } setMode(INITPLUGIN); //------------------------------------------------------------------- //finished creating dirs, now check to make sure if they extracted it //did their extracting program actually get all the dirs? //------------------------------------------------------------------- DRAGON_chdir(d_base); if(DRAGON_FileExists("Day") != FE_DIR) { DRAGON_mkdir("DAY"); } if(DRAGON_FileExists("Help") != FE_DIR) { DRAGON_mkdir("HELP"); } if(DRAGON_FileExists("Lang") != FE_DIR) { DRAGON_mkdir("LANG"); } if(DRAGON_FileExists("Reminder") != FE_DIR) { DRAGON_mkdir("REMINDER"); } if(DRAGON_FileExists("Scribble") != FE_DIR) { DRAGON_mkdir("SCRIBBLE"); } if(DRAGON_FileExists("Todo") != FE_DIR) { DRAGON_mkdir("TODO"); } if(DRAGON_FileExists("VCard") != FE_DIR) { DRAGON_mkdir("VCARD"); } if(DRAGON_FileExists("Icons") != FE_DIR) { DRAGON_mkdir("ICONS"); } if(DRAGON_FileExists("Cache") != FE_DIR) { DRAGON_mkdir("CACHE"); } if(DRAGON_FileExists("Cookies") != FE_DIR) { DRAGON_mkdir("COOKIES"); } if(DRAGON_FileExists("Home") != FE_DIR) { DRAGON_mkdir("HOME"); } DRAGON_chdir("/"); //------------------------------------------- //how about we load the settings for them eh? //------------------------------------------- loadSettings(); DRAGON_chdir(d_base); if(DRAGON_FileExists("startup.wav") == FE_FILE) { char tStr[256]; sprintf(tStr, "%sstartup.wav", d_base); loadWavToMemory(); loadSound(tStr); } DRAGON_chdir("/"); initStartScreen(); irqSet(IRQ_VBLANK, vBlank); fb_setBGColor(genericFillColor); bg_setBGColor(genericFillColor); }
void initGame(void) { lcdMainOnTop(); int oldv=getMemFree(); NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("initializing..."); videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); glInit(); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000); vramSetBankH(VRAM_H_SUB_BG); vramSetBankI(VRAM_I_SUB_BG_0x06208000); glEnable(GL_TEXTURE_2D); // glEnable(GL_ANTIALIAS); glDisable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(31,0,0)); //TEMP? glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? glClearColor(31,31,0,31); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); // initVramBanks(1); initVramBanks(2); initTextures(); initSound(); initCamera(NULL); initPlayer(NULL); initLights(); initParticles(); initMaterials(); loadMaterialSlices("slices.ini"); loadMaterials("materials.ini"); loadControlConfiguration("config.ini"); initElevators(); initWallDoors(); initTurrets(); initBigButtons(); initTimedButtons(); initEnergyBalls(); initPlatforms(); initCubes(); initEmancipation(); initDoors(); initSludge(); initPause(); initText(); NOGBA("lalala"); getPlayer()->currentRoom=&gameRoom; currentBuffer=false; getVramStatus(); fadeIn(); mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgSetPriority(mainBG, 0); REG_BG0CNT=BG_PRIORITY(3); #ifdef DEBUG_GAME consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true); consoleSelect(&bottomScreen); #endif // glSetToonTableRange(0, 14, RGB15(16,16,16)); // glSetToonTableRange(15, 31, RGB15(26,26,26)); initPortals(); //PHYSICS initPI9(); strcpy(&mapFilePath[strlen(mapFilePath)-3], "map"); newReadMap(mapFilePath, NULL, 255); transferRectangles(&gameRoom); makeGrid(); generateRoomGrid(&gameRoom); gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false); getVramStatus(); startPI(); NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv); levelInfoCounter=60; }
static void CB_Start(void) { lcdMainOnTop(); DrawOnlineHelp(); }
//------------------------------------------------------- int main() { //------------------------------------------------------- videoSetMode(MODE_0_3D); videoSetModeSub(MODE_5_2D); glInit(); // sub sprites hold the bottom image when 3D directed to top initSubSprites(); // sub background holds the top image when 3D directed to bottom bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); //------------------------------------------------------- // Setup gl //------------------------------------------------------- glEnable(GL_ANTIALIAS); glClearColor(0,0,0,31); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70, 256.0 / 192.0, 0.1, 100); glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); //------------------------------------------------------- // main loop //------------------------------------------------------- bool top = true; while (true) { // wait for capture unit to be ready while(REG_DISPCAPCNT & DCAP_ENABLE); scanKeys(); int keys = keysDown(); if (keys & KEY_START) break; //------------------------------------------------------- // Switch render targets //------------------------------------------------------- top = !top; if(top) { lcdMainOnBottom(); vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_SUB_SPRITE); REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3); } else { lcdMainOnTop(); vramSetBankD(VRAM_D_LCD); vramSetBankC(VRAM_C_SUB_BG); REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3); } //------------------------------------------------------- // Render the scene //------------------------------------------------------- glMatrixMode(GL_MODELVIEW); renderScene(top); glFlush(0); } return 0; }