int main (int argc, char **argv) { VIDEO_Init(); WPAD_Init(); PAD_Init(); sys_rmode = VIDEO_GetPreferredMode(NULL); sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_frame_count = 0; CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIDEO_Configure(sys_rmode); VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(sys_rmode->viTVMode & VI_NON_INTERLACE) { VIDEO_WaitVSync(); }; sys_frame_count++; GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight); if(!fatInitDefault()) { Sys_Error("Filesystem not enabled"); }; sys_previous_time = Sys_Milliseconds(); do { sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true); } while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000)); if(sys_netinit_error < 0) { printf("Network not enabled\n"); }; if (KEYBOARD_Init(Sys_KeyPress) != 0) { printf("Keyboard not found\n"); }; OSK_LoadKeys(Keys_dat, Keys_dat_size); int len, i; char *cmdline; // merge the command line, this is kinda silly for (len = 1, i = 1; i < argc; i++) len += strlen(argv[i]) + 1; cmdline = malloc(len); *cmdline = 0; for (i = 1; i < argc; i++) { if (i > 1) strcat(cmdline, " "); strcat(cmdline, argv[i]); } Com_Init(cmdline); WPAD_SetPowerButtonCallback(Sys_PowerOff); while (1) { sys_previous_time = Sys_Milliseconds(); if(MOUSE_IsConnected()) { sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event); if(sys_mouse_valid) MOUSE_FlushEvents(); } else { sys_mouse_valid = 0; sys_mouse_event.button = 0; }; Com_Frame( ); if(in_osk->value) { OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]); }; sys_frame_count++; GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]); KEYBOARD_FlushEvents(); VIDEO_Flush(); VIDEO_WaitVSync(); } return 0; }
int main(int argc, char* argv[]) { u8 *tex_ptrone=GRRLIB_LoadTexture(handpointerred_png); u8 *tex_ptrtwo=GRRLIB_LoadTexture(handpointergreen_png); u8 *tex_back=GRRLIB_LoadJPG(bigmenuback_jpg, bigmenuback_jpg_size); u8 *tex_fore=GRRLIB_LoadTexture(credits_png); fatInitDefault(); GRRLIB_InitVideo(); WPAD_Init(); SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); rmode = VIDEO_GetPreferredMode(NULL); SND_Init(INIT_RATE_48000); // Initialize the Sound Lib MODPlay_Init(&mod_track); SND_Pause(0); // the sound loop is running now if (MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod) < 0 ) // set the MOD song { MODPlay_Unload (&mod_track); } else { // set the music volume to the minimum so we don't hear the music before saved volume is known MODPlay_SetVolume( &mod_track, 0,0); MODPlay_Start (&mod_track); // Play the MOD } WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight); initMain(); MODPlay_SetVolume( &mod_track, opt_music, opt_music); while( HWButton == 0) { WPAD_ScanPads(); u32 wpad_one_down = WPAD_ButtonsDown(0); u32 wpad_two_down = WPAD_ButtonsDown(1); u32 type; WPADData *wd_one, *wd_two; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); WPAD_Probe(WPAD_CHAN_ALL, &type); wd_one = WPAD_Data(0); wd_two = WPAD_Data(1); switch(main_mode) { case STARTUP : GRRLIB_FillScreen(0xFF000000); GRRLIB_DrawImg(0, 0, 640, 480, tex_back, 0, 1, 1, alpha>255?255:alpha); GRRLIB_DrawImg(68,308, 256, 80, tex_fore, 0, 1, 1, alpha>255?255:alpha); if(alpha++>394 || wpad_one_down > 0) { main_mode=MENU; if(tex_back) free(tex_back); if(tex_fore) free(tex_fore); initMenu(); } break; case MENU : GRRLIB_FillScreen(0xFF000000); int menuopt = menuWiimote(wd_one,wpad_one_down); if(menuopt==EXIT) { if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); } if(menuopt>NOTHING) { processMenuOption(menuopt); if(main_mode==GAME) { MODPlay_Unload (&mod_track); if(opt_tileset==SPOOKY) MODPlay_SetMOD (&mod_track, graveyard_mod); else if(opt_tileset==EGYPTIAN) MODPlay_SetMOD (&mod_track, egypt_crap_mod); else if(opt_tileset==SIMPLE) MODPlay_SetMOD (&mod_track, childhood_mod); else if(opt_tileset==SPACE) MODPlay_SetMOD (&mod_track, nebulos_mod); else MODPlay_SetMOD (&mod_track, sushi_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); } else drawMenu(wd_one); } else drawMenu(wd_one); break; case GAME : if(gameWiimote(wd_one,wpad_one_down,wd_two,wpad_two_down)) { // we are exiting the game back to the menu main_mode=MENU; MODPlay_Unload (&mod_track); MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); killGame(); initMenu(); } else { drawGame(); } break; } // alternate which pointer is on top every frame to not give the advantage to player one in two player mode static int ticktock=0; ticktock++; if(wd_two->ir.valid && ticktock%2==0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->ir.valid) { GRRLIB_DrawColImg(wd_one->ir.x - 9,wd_one->ir.y - 7,68,80,tex_ptrone,0,1,1,0xEEFFFFFF); } if(wd_two->ir.valid && ticktock%2!=0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->btns_h & WPAD_BUTTON_1) { GRRLIB_ScrShot("MahjonggWii_Screen_%y%m%d_%H%M%S.png",time(NULL)); } GRRLIB_Render(); } // we are exiting, free the mallocs switch( main_mode) { case GAME: killGame(); } if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); killMenuLanguages(); MODPlay_Unload (&mod_track); WPAD_Shutdown(); SND_End(); GRRLIB_Stop(); saveConfig(FILE_CFG); SYS_ResetSystem(HWButton, 0, 0); return 0; }
int main(int argc, char *argv[]) #endif { #ifdef PSP SetupCallbacks(); scePowerSetClockFrequency(333, 333, 166); #endif for (int i=0; i<FLAG_COUNT; i++) { GAME_FLAGS[i] = false; } UNUSED(argc); string argvString = ""; #ifndef WII argvString = string(argv[0]); #else if (!fatInitDefault()) { printf("fatInitDefault ERROR #1"); std::fflush(stdout); timer.delay(500); exit(-1); } #endif get_filepath(); // fallback in case getcwd returns null if (FILEPATH.size() == 0) { std::cout << "Could not read path, fallback to using argv" << std::endl; FILEPATH = argvString.substr(0, argvString.size()-EXEC_NAME.size()); } std::cout << "main - argvString: '" << argvString << "', FILEPATH: '" << FILEPATH << "'" << std::endl; std::fflush(stdout); #ifdef PLAYSTATION2 std::cout << "PS2.DEBUG #1" << std::endl; std::fflush(stdout); #ifndef PS2LINK SifIopReset(NULL, 0); // clean previous loading of irx by apps like ulaunchElf. Comment this line to get cout on ps2link #endif printf("DEBUG.PS2 #1.1\n"); /* SP193: Being creative (Do something while waiting for the slow IOP to be reset). =D */ int main_id = GetThreadId(); ChangeThreadPriority(main_id, 72); std::cout << "PS2.DEBUG #1.1" << std::endl; std::fflush(stdout); printf("DEBUG.PS2 #1.2\n"); #ifndef PS2LINK while(SifIopSync()) { std::cout << "PS2.SifIopSync()" << std::endl; } #endif /* Initialize and connect to all SIF services on the IOP. */ SifInitRpc(0); SifInitIopHeap(); SifLoadFileInit(); fioInit(); printf("DEBUG.PS2 #1.3\n"); /* Apply the SBV LMB patch to allow modules to be loaded from a buffer in EE RAM. */ sbv_patch_enable_lmb(); // --- DEBUG --- // //FILEPATH = "cdfs:/"; // --- DEBUG --- // std::cout << "PS2.DEBUG #2" << std::endl; std::fflush(stdout); if (FILEPATH.find("mass:") != std::string::npos) { printf("DEBUG.PS2 #1.4\n"); std::cout << "PS2.DEBUG Load USB" << std::endl; std::fflush(stdout); PS2_load_USB(); } if (FILEPATH.find("cdfs") != std::string::npos || FILEPATH.find("cdrom") != std::string::npos) { printf("DEBUG.PS2 #1.5\n"); std::cout << "PS2.DEBUG Load CDROM" << std::endl; std::fflush(stdout); FILEPATH = "cdfs:"; PS2_load_CDROM(); } printf("DEBUG.PS2 #2\n"); std::cout << "PS2.DEBUG #3" << std::endl; std::fflush(stdout); #endif // check command-line paramethers if (argc > 1) { for (int i=1; i<argc; i++) { std::string temp_argv(argv[i]); if (temp_argv == "--fullscreen") { } else if (temp_argv == "--quickload") { GAME_FLAGS[FLAG_QUICKLOAD] = true; } else if (temp_argv == "--invencible") { // player have infinite HP GAME_FLAGS[FLAG_INVENCIBLE] = true; } else if (temp_argv == "--allweapons") { // player have all weapons available even if GAME_FLAGS[FLAG_ALLWEAPONS] = true; } else if (temp_argv == "--infinitejump") { // player can jump again and again GAME_FLAGS[FLAG_INFINITE_JUMP] = true; } } } std::cout << "PS2.DEBUG #7" << std::endl; std::fflush(stdout); //fio.check_conversion(); fio.read_game(game_data); //GAME_FLAGS[FLAG_INFINITE_HP] = true; // DEBUG gameControl.get_drop_item_ids(); soundManager.init_audio_system(); // PS2 version have to load config AFTER SDL_Init due to SDK issues #ifdef LINUX SAVEPATH = std::string(getenv("HOME")) + "/.rockbot/"; mkdir(SAVEPATH.c_str(), 0777); //std::cout << "SAVEPATH: " << SAVEPATH << ", mkdir-res: " << res << ", errno: " << errno << std::endl; #elif WIN32 SAVEPATH = std::string(getenv("APPDATA")) + "/rockbot"; std::cout << "SAVEPATH: " << SAVEPATH << std::endl; _mkdir(SAVEPATH.c_str()); #else SAVEPATH = FILEPATH; #endif #ifndef PLAYSTATION2 fio.load_config(game_config); #endif // INIT GRAPHICS if (graphLib.initGraphics() != true) { printf("ERROR intializing graphic\n"); return -1; } // define SAVEPATH #ifdef PLAYSTATION2 PS2_load_MC(); SAVEPATH = "mc0:Rockbot/"; if (fioMkdir(SAVEPATH.c_str()) < 0) { std::cout << "main - warning: could not create '" << SAVEPATH << "' folder" << std::endl; std::fflush(stdout); /// @TODO - check if directory exists } else { std::cout << "Folder '" << SAVEPATH << "' created" << std::endl; std::fflush(stdout); } #endif have_save = fio.save_exists(); #ifndef DEBUG_OUTPUT // redirect output to null std::string cout_file = "/dev/null"; std::ofstream out(cout_file.c_str()); std::cout.rdbuf(out.rdbuf()); #else // --- REDIRECT STDOUT TO A FILE --- // #if defined(PSP) || defined(WII) || defined(ANDROID) || defined(DINGUX) || defined(PLAYSTATION2) //std::string cout_file = SAVEPATH + "/stdout.txt"; std::string cout_file = FILEPATH + "/stdout.txt"; std::streambuf *coutbuf = std::cout.rdbuf(); std::ofstream out(cout_file.c_str()); std::cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt! #endif #endif graphLib.preload(); #ifdef PLAYSTATION2 fio.load_config(game_config); PS2_create_save_icons(); #endif draw_lib.preload(); gameControl.currentStage = APEBOT; // INIT GAME if (GAME_FLAGS[FLAG_QUICKLOAD] == false) { if (gameControl.showIntro() == false) { std::cout << "ERROR SHOWING INTRO" << std::endl; return 0; } } else { gameControl.quick_load_game(); //ending end_obj; //end_obj.start(); //return 1; } input.clean(); input.p1_input[BTN_START] = 0; input.waitTime(200); input.clean(); bool run_game = true; while (run_game) { #if !defined(PSP) && !defined(DINGUX) timer.start_ticker(); #endif #ifdef PLAYSTATION2 RotateThreadReadyQueue(_MIXER_THREAD_PRIORITY); #endif gameControl.showGame(); #ifdef DEBUG_SHOW_FPS gameControl.fps_count(); #endif draw_lib.update_screen(); if (input.p1_input[BTN_QUIT] == 1) { //std::cout << "LEAVE #3" << std::endl; std::fflush(stdout); gameControl.leave_game(); } unsigned int now_ticks = timer.get_ticks(); if (now_ticks < (1000 / FRAMES_PER_SECOND)) { timer.delay((1000 / FRAMES_PER_SECOND) - now_ticks); } } /// @TODO: sdl quit sub-systems #ifdef PSP sceKernelExitGame(); return 0; #else SDL_Quit(); #endif return 1; }
int main (int argc, char *argv[]) { #ifdef HW_RVL /* initialize DVD device */ DI_Init(); #endif u16 usBetweenFrames; long long now, prev; /* Initialize OGC subsystems */ ogc_video__init(); ogc_input__init(); ogc_audio__init(); #ifdef HW_DOL /* Initialize GC DVD interface */ DVD_Init (); dvd_drive_detect(); #endif #ifdef HW_RVL /* Power Button callback */ SYS_SetPowerCallback(Power_Off); #endif /* Initialize FAT Interface */ if (fatInitDefault() == true) { fat_enabled = 1; } /* Default Config */ legal(); set_option_defaults (); config_load(); #ifdef HW_RVL /* Load SMB Settings */ loadSettings(); #endif /* Restore Recent Files list */ set_history_defaults(); history_load(); /* Initialize Virtual Machine */ init_machine (); /* Show Menu */ MainMenu(); ConfigRequested = 0; /* Initialize Frame timings */ frameticker = 0; usBetweenFrames = sms.display ? 20000 : 16666; prev = gettime(); /* Emulation Loop */ while (1) { /* update inputs */ ogc_input__update(); /* Frame synchronization */ if (gc_pal != sms.display) { /* use timers */ now = gettime(); if (diff_usec(prev, now) > usBetweenFrames) { /* Frame skipping */ prev = now; system_frame(1); } else { /* Delay */ while (diff_usec(prev, now) < usBetweenFrames) now = gettime(); /* Render Frame */ prev = now; system_frame(0); } } else { /* use VSync */ if (frameticker > 1) { /* Frame skipping */ frameticker--; system_frame (1); } else { /* Delay */ while (!frameticker) usleep(10); system_frame (0); } frameticker--; } /* update video & audio */ ogc_video__update(); ogc_audio__update(); /* Check for Menu request */ if (ConfigRequested) { /* reset AUDIO */ ogc_audio__reset(); /* go to menu */ MainMenu (); ConfigRequested = 0; ogc_video__reset(); /* reset frame timings */ frameticker = 0; usBetweenFrames = sms.display ? 20000 : 16666; prev = gettime(); } } return 0; }
int main (int argc, char **argv) { #ifdef GEKKO printf("\x1b[2;0H"); //initialize libfat library if (fatInitDefault()) printf("FAT subsytem initialized\n\n"); else { printf("Couldn't initialize FAT subsytem\n\n"); sleep(3); exit(0); } DIR *dp; dp = opendir ("sd:/"); if (dp) sdismount = 1; else sdismount = 0; if (sdismount) printf("SD FAT subsytem initialized\n\n"); else printf("Couldn't initialize SD fat subsytem\n\n"); if (sdismount) closedir (dp); usbismount = InitUSB(); default_prefs (&currprefs, 0); cfgfile_load (&currprefs, SMBFILENAME, 0); printf("\n"); if (currprefs.smb_enable) networkisinit = InitNetwork(); if (networkisinit && currprefs.smb_enable) ConnectShare(); sleep(2); if (!(log_quiet = !currprefs.write_logfile)) set_logfile("/uae/uae.log"); #endif write_log("main started\n"); init_sdl (); write_log("sdl inited\n"); gui_init (argc, argv); write_log("Starting real main\n"); real_main (argc, argv); #ifdef GEKKO if (smbismount) CloseShare (); DeInitUSB(); fatUnmount(0); #endif return 0; }
int main(int argc, char ** argv) { PA_Init(); PA_InitVBL(); PA_InitText(0, 0); PA_OutputSimpleText(0, 6, 1, "Create GFX from FAT"); fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAT access. PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system PA_FatSetBasePath("/DemoFiles/data"); // Set a base path from the card root to load your asset files from // Within this base asset folder: // all background binaries should be in /bg/ // sprite and sprite palette binaries in /sprites/ // and RAW format sound files in /sfx/ u16 gfx[2]; // Load a sprite image from FAT to VRAM. It works just like PA_CreateGfx! gfx[0] = PA_FatEasyCreateGfx(0, // Screen "pokekun", // Name of a sprite binary created with PAGfx (without the "_Sprite.bin") OBJ_SIZE_32X64, // Sprite size macro 1); // 256 color sprite // Let's make another one for the top screen gfx[1] = PA_FatEasyCreateGfx(1, "pokekun", OBJ_SIZE_32X64, 1); // Create some palettes for sprites that will be created later. It works just like PA_LoadSpritePal! PA_FatEasyLoadSpritePal(0, // Screen 0, // Sprite palette number "pokekun"); // Name of a palette binary in EFS created by PAGfx (without the "_Pal.bin") // for the top screen, too PA_FatEasyLoadSpritePal(1, 0, "pokekun"); PA_OutputSimpleText(0, 0, 20, "Press A to create a sprite on\nthe bottom screen, B for one on\nthe top screen"); u8 nsprites0 = 0; // Number of sprites on the bottom screen u8 nsprites1 = 0; // Top screen while(1) { if (Pad.Newpress.A && nsprites0 < 128) { // Since the sprite is already in VRAM you can just the normal PA_CreateSpriteFromGfx PA_CreateSpriteFromGfx(0, // screen nsprites0, // Next sprite to load... gfx[0], // image to use in memory, no image copying ! OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128)); // The rest is like normal sprites ++nsprites0; // Next time, load the next sprite number } if (Pad.Newpress.B && nsprites1 < 128) { PA_CreateSpriteFromGfx(1, nsprites1, gfx[1], OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128)); ++nsprites1; } PA_WaitForVBL(); } return 0; }
// initialize the file system int EFS_Init(int options, char *path) { bool found = false; // reset current path memset(currPath, 0, EFS_MAXPATHLEN); //iprintf("efs1\n"); // first try to init NitroFS from GBA mem sysSetBusOwners(BUS_OWNER_ARM9, BUS_OWNER_ARM9); // take gba slot ownership //iprintf("efs2\n"); if(strncmp(((const char*)GBAROM)+EFS_LOADERSTROFFSET, EFS_GBALOADERSTR, strlen(EFS_GBALOADERSTR)) == 0) { // there's a GBA loader here memcpy(&fnt_offset, EFS_FNTOFFSET+EFS_LOADEROFFSET + (void*)GBAROM, sizeof(fnt_offset)); memcpy(&fat_offset, EFS_FATOFFSET+EFS_LOADEROFFSET + (void*)GBAROM, sizeof(fat_offset)); fnt_offset += EFS_LOADEROFFSET; fat_offset += EFS_LOADEROFFSET; hasLoader = true; useDLDI = false; AddDevice(&EFSdevoptab); found = true; strcpy(efs_path, "GBA ROM"); //iprintf("GBA2\n"); } else if(strncmp(((const char*)GBAROM)+EFS_LOADERSTROFFSET, EFS_STDLOADERSTR, strlen(EFS_STDLOADERSTR)) == 0) { // there's a standard nds loader here memcpy(&fnt_offset, EFS_FNTOFFSET + (void*)GBAROM, sizeof(fnt_offset)); memcpy(&fat_offset, EFS_FATOFFSET + (void*)GBAROM, sizeof(fat_offset)); hasLoader = false; useDLDI = false; AddDevice(&EFSdevoptab); found = true; strcpy(efs_path, "GBA ROM"); //iprintf("GBA2\n"); } else { // if init from GBA mem failed go for DLDI I/O useDLDI = true; //iprintf("DLDI\n"); // init libfat if requested if(options & EFS_AND_FAT) { if(!fatInitDefault()) return false; } //iprintf("FatInited\n"); // check if the provided path is valid if(path && CheckFile(path, true)) { found = true; //iprintf("Path1-1\n"); } else { // check if there's already a path stored if(efs_path[0]) { if(CheckFile(efs_path, false)) { found = true; } else { efs_path[0] = '\0'; } } //iprintf("Path2-1\n"); // if no path is defined, search the whole FAT space if(!efs_path[0]) { chdir("/"); if(SearchDirectory()) found = true; } //iprintf("Path2-2\n"); } // if nds file is found, open it and read the header if(found) { //iprintf("Path2-3\n"); char buffer[8]; nds_file = open(efs_path, O_RDWR); // check for if a loader is present lseek(nds_file, EFS_LOADERSTROFFSET, SEEK_SET); read(nds_file, buffer, 6); buffer[7] = '\0'; if(strcmp(buffer, EFS_GBALOADERSTR) == 0) { // loader present lseek(nds_file, EFS_LOADEROFFSET+EFS_FNTOFFSET, SEEK_SET); read(nds_file, &fnt_offset, sizeof(u32)); lseek(nds_file, 4, SEEK_CUR); read(nds_file, &fat_offset, sizeof(u32)); fnt_offset += EFS_LOADEROFFSET; fat_offset += EFS_LOADEROFFSET; hasLoader = true; } else { lseek(nds_file, EFS_FNTOFFSET, SEEK_SET); read(nds_file, &fnt_offset, sizeof(u32)); lseek(nds_file, 4, SEEK_CUR); read(nds_file, &fat_offset, sizeof(u32)); hasLoader = false; } AddDevice(&EFSdevoptab); } } // set as default device if requested if(found && (options & EFS_DEFAULT_DEVICE)) chdir(EFS_DEVICE); // works better than setDefaultDevice(); return (found && (!useDLDI || (nds_file != -1))); }
s32 main(s32 argc, const char* argv[]) { atexit(unload_modules); InitVideo(); // Initialize video SetupPads(); // Initialize input #ifdef TOPORT InitAudio(); // Initialize audio fatInitDefault(); // Initialize file system #endif #ifdef TOPORT InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system InitGUIThreads(); // Initialize GUI DefaultSettings(); MainMenu(MENU_SETTINGS); #endif #ifdef PSL1GHT if(SysLoadModule(SYSMODULE_FS)!=0) return 0; else module_flag |=1; if(SysLoadModule(SYSMODULE_PNGDEC)!=0) return 0; else module_flag |=2; #endif VideoModule * video = VideoModule::getVideoModule(); InputPadModule * inpad = InputPadModule::getInputPadModule(); #ifdef PSL1GHT PngDatas png1; LoadPNG(&png1, (char *)"/dev_usb/PS3_GAME/ICON0.PNG"); #endif long frame = 0; // To keep track of how many frames we have rendered. int x = DEBUG_X, y = DEBUG_Y; // Ok, everything is setup. Now for the main loop. while(1) { char str [300]; sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame); inpad->refreshPadConnections(); // Check the pads. for( size_t i = 0; i < inpad->getPadNumber(); i++) { if( inpad->getPad(i)->isPressed( eAbsButUp) && y > 0) y--; if( inpad->getPad(i)->isPressed( eAbsButDown) && y < 1080) y++; if( inpad->getPad(i)->isPressed( eAbsButLeft) && x > 0) x--; if( inpad->getPad(i)->isPressed( eAbsButRight) && x > 0) x++; else if( inpad->getPad(i)->isPressed( eAbsButExecute)) return 0; } sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame); video->waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer #ifdef PSL1GHT drawFrame(video->getCurrentBuffer(), frame++); // Draw into the unused buffer if(png1.bmp_out) { video->displayBitmap( (u32 *)png1.bmp_out, png1.height, png1.width, png1.wpitch); } #endif video->printf(x, y, str); video->flip(); // Flip buffer onto screen } return 0; }
static void frontend_gx_init(void *data) { (void)data; #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); #ifndef IS_SALAMANDER gx_init_mem2(); #endif #endif #ifdef USBGECKO DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif #if defined(DEBUG) && defined(IS_SALAMANDER) VIInit(); GXRModeObj *rmode = VIDEO_GetPreferredMode(NULL); void *xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIConfigure(rmode); VISetNextFramebuffer(xfb); VISetBlack(FALSE); VIFlush(); VIWaitForRetrace(); VIWaitForRetrace(); #endif #ifndef DEBUG __exception_setreload(8); #endif fatInitDefault(); #ifdef HAVE_LOGGER devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) && !defined(IS_SALAMANDER) devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple( gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple( gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); gx_device_cond_mutex = slock_new(); gx_device_cond = scond_new(); gx_device_mutex = slock_new(); gx_device_thread = sthread_create(gx_devthread, NULL); #endif }
int main (int argc, char *argv[]) { #ifdef HW_RVL /* initialize DVDX */ DI_Init(); #endif /* initialize hardware */ gx_video_Init(); gx_input_Init(); #ifdef HW_DOL DVD_Init (); dvd_drive_detect(); #endif /* initialize FAT devices */ if (fatInitDefault()) { /* check for default directories */ DIR_ITER *dir = NULL; /* base directory */ char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* SRAM & Savestate files directory */ sprintf (pathname, "%s/saves",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* Snapshot files directory */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* Cheat files directory */ sprintf (pathname, "%s/cheats",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); } /* initialize sound engine */ gx_audio_Init(); /* initialize core engine */ legal(); config_default(); history_default(); init_machine(); /* run any injected rom */ if (cart.romsize) { ARAMFetch((char *)cart.rom, (void *)0x8000, cart.romsize); reloadrom (cart.romsize,"INJECT.bin"); gx_video_Start(); gx_audio_Start(); frameticker = 1; } else { /* Main Menu */ ConfigRequested = 1; } /* initialize GUI engine */ GUI_Initialize(); #ifdef HW_RVL /* Power button callback */ SYS_SetPowerCallback(Power_Off); #endif /* main emulation loop */ while (1) { /* Main Menu request */ if (ConfigRequested) { /* stop video & audio */ gx_audio_Stop(); gx_video_Stop(); /* show menu */ MainMenu (); ConfigRequested = 0; /* start video & audio */ gx_audio_Start(); gx_video_Start(); frameticker = 1; } if (frameticker > 1) { /* skip frame */ system_frame(1); --frameticker; } else { while (frameticker < 1) usleep(10); /* render frame */ system_frame(0); --frameticker; /* update video */ gx_video_Update(); } /* update audio */ gx_audio_Update(); } return 0; }
// Main function int main() { // Init and load stuff init(); bool plotPressed=false; bool killPressed=false; bool exitPressed=false; bool doParticle=false; bool doneMusicPlay=false; float endCount=0; short explosion=0; // Put first cirra sprite putCirra(gdl::ScreenCenterX, gdl::ScreenCenterY, 100); // Main loop while(1) { // Get player input doPlayerInput(); if (ending == false) { // Drop a Cirra into the field if (playerInput.mouseLB) { if (plotPressed==false) { putCirra(playerInput.pointerX, playerInput.pointerY, 100); //plotPressed=true; } } else { plotPressed=false; } // Kill a Cirra if (playerInput.mouseRB) { if (killPressed==false) { // Simple bounding box search, too lazy to add sorting but it works for (int s=0; s<numCirras; s++) { if (onSprite(playerInput.pointerX, playerInput.pointerY, cirra[s].x, cirra[s].y, sprites.SpriteInfo(CIRRA_DOWN))) { sound[1].Play2D(1.f + ((0.6f*((float)rand()/RAND_MAX))-0.2f), 100.f, cirra[s].x-gdl::ScreenCenterX, cirra[s].y-gdl::ScreenCenterY); killCirra(s); break; } } //killPressed=true; } } else { killPressed=false; } } // Initiate end sequence (blowing up all Cirras :) ) #ifdef PLATFORM_PC if ((playerInput.exitGame) || gdl::pc::WindowShouldClose()) { #else if (playerInput.exitGame) { #endif if (exitPressed == false) { if (ending == false) { sound[2].Play(1.f, 100.f); tnt.active = true; tnt.x = gdl::ScreenCenterX; tnt.y = gdl::ScreenCenterY; tnt.a = 100; tnt.aMove = 0; tnt.duration = 0; ending = true; #ifdef PLATFORM_PC glfwSetWindowShouldClose(gdl::pc::WindowContext, false); #endif } else { #ifdef PLATFORM_PC break; #else gdl::wii::Exit(); #endif } } exitPressed = true; } else { exitPressed = false; } // Prepare to draw stuff gdl::PrepDisplay(); // Reset sprite entry count and clear ordering table numSpriteEntries=0; memset(spriteOT, 0x00, sizeof(void*)*OT_LENGTH); // Do TNT animation if (tnt.active) { if (tnt.a > 0) { tnt.aMove += - (0.2f*gdl::Delta); tnt.a += (tnt.aMove*gdl::Delta); if (tnt.a <= 0) tnt.a = 0; } else { tnt.a = 0; } addSprite(tnt.x, tnt.y-1, 0, SHADOW); addSprite(tnt.x, tnt.y, tnt.a, TNT); doParticle ^= 1; if (doParticle) { putFireParticle(tnt.x, tnt.y, tnt.a+13); putFireParticle(tnt.x+1, tnt.y, tnt.a+13); } tnt.duration += (1.f*gdl::Delta); // Detonate! if (tnt.duration > 240) { // Kill all cirras when the TNT explodes while(numCirras) killCirra(0); sound[3].Play(1.f, 100.f); explosion = 2; endCount = 1; tnt.active = false; } } // Do Cirra entities doCirras(); doEffects(); // Draw sprites inside ordering table drawSpriteOT(); // Draw pointer (only on Wii platform) #ifdef PLATFORM_WII if ((ending == false) && (playerInput.pointerOnScreen)) { pointer.Put(playerInput.pointerX, playerInput.pointerY, gdl::Color::White, 4, 0, 1, Wiimote[0].data.ir.angle); } #endif // Draw instruction text if (ending == false) { #ifdef GDL_PLATFORM_WII font.Printf(9, 17, 1.f, gdl::Color::Black, "Press A to plot, B to kill."); font.Printf(8, 16, 1.f, gdl::Color::White, "Press A to plot, B to kill."); font.Printf(9, 33, 1.f, gdl::Color::Black, "Press Home or Reset to exit..."); font.Printf(8, 32, 1.f, gdl::Color::White, "Press Home or Reset to exit..."); #else font.Printf(9, 7, 1.f, gdl::Color::Black, "Press LMB to plot, RMB to kill."); font.Printf(8, 6, 1.f, gdl::Color::White, "Press LMB to plot, RMB to kill."); font.Printf(9, 23, 1.f, gdl::Color::Black, "Press Escape or Close to exit..."); font.Printf(8, 22, 1.f, gdl::Color::White, "Press Escape or Close to exit..."); #endif // GDL_PLATFORM_WII } // Do TNT sequence if (endCount) { if ((endCount > 10) && (doneMusicPlay == false)) { // Play 'gameover' music gdl::PlayMusic("testdata/gameover.ogg", false); doneMusicPlay = true; } if (endCount > 60) { //sprites.PutX(gdl::ScreenCenterX, gdl::ScreenCenterY, GAMEOVER, gdl::Pivot, gdl::Pivot, 0, 4, gdl::Color::White); sprites.Put(gdl::ScreenCenterX, gdl::ScreenCenterY, GAMEOVER, gdl::Color::White, gdl::Pivot, gdl::Pivot, 4.f); #ifdef GDL_PLATFORM_WII font.Printf(gdl::Centered, gdl::ScreenYres-69, 1.f, gdl::Color::Black, "Press Home or Reset again to exit"); font.Printf(gdl::Centered, gdl::ScreenYres-70, 1.f, gdl::Color::White, "Press Home or Reset again to exit"); #else font.Printf(gdl::Centered, gdl::ScreenYres-69, 1.f, gdl::Color::Black, "Press Escape or Close again to exit"); font.Printf(gdl::Centered, gdl::ScreenYres-70, 1.f, gdl::Color::White, "Press Escape or Close again to exit"); #endif } if (endCount <= 60) endCount += 1.f*gdl::Delta; } // Simple flash effect for the TNT explosion if (explosion) { gdl::DrawBoxF(0, 0, gdl::ScreenXres-1, gdl::ScreenYres-1, gdl::Color::White); explosion--; } // Display stuff gdl::Display(); } } // Init function void init() { #ifdef GDL_PLATFORM_WII // Init code for Wii fatInitDefault(); gdl::InitSystem(gdl::ModeAuto, gdl::AspectAuto, gdl::LowRes); WPAD_Init(); InitWiimotes(1); #else // Init code for PC gdl::Init("Whack-a-Cirra", 427, 240, 32, 0, 0, 2); #endif // Set clear color gdl::SetClearColor(0, 63, 127, 255); #ifdef GDL_PLATFORM_WII // Set console mode and load pointer image gdl::ConsoleMode(); if (!pointer.LoadImage("testdata/pointer.png", gdl::Nearest, gdl::RGB5A3)) exit(0); #else // Step back a directory on PC chdir("../.."); #endif // Load font if (!fontImage.LoadImage("testdata/font8x16.png", gdl::Nearest, gdl::RGB5A3)) exit(0); font.BindSheet(fontImage, 8, 16); // Load sprites if (!sprites.LoadSprites("testdata/test_sprites.tsm", "testdata/", gdl::Nearest, gdl::RGB5A3)) exit(0); // Load sound effects if (!sound[0].LoadSound("testdata/hitfloor.wav")) exit(0); if (!sound[1].LoadSound("testdata/smack.wav")) exit(0); if (!sound[2].LoadSound("testdata/fuse.wav")) exit(0); if (!sound[3].LoadSound("testdata/explode.wav")) exit(0); }
int main(void) { int i; defaultExceptionHandler(); irqEnable(IRQ_VBLANK); irqEnable(IRQ_HBLANK); irqSet(IRQ_VBLANK, vblank_idle); fifoSetValue32Handler(FIFO_USER_02, arm7print, NULL); fifoSetValue32Handler(FIFO_USER_03, sleepMode, NULL); //vramSetBankA(VRAM_A_LCD); videoSetMode(MODE_0_2D); // map some VRAM // bank C to ARM7, bank H for subscreen graphics *(vu8*)0x04000242 = 0x82; *(vu8*)0x04000248 = 0x81; videoSetModeSub(MODE_0_2D); consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 2, 0, false, true); *(vu16*)0x0400100A = 0x0300; setBackdropColorSub(0x7C00); // configure BLDCNT so that backdrop becomes black *(vu16*)0x04001050 = 0x00E0; *(vu8*)0x04001054 = 16; // enable window 0 and disable color effects inside it *(vu16*)0x04001000 |= 0x2000; *(vu16*)0x04001048 = 0x001F; *(vu16*)0x0400104A = 0x003F; toggleConsole(false); #ifdef NITROFS_ROM if (!nitroFSInit()) #else if (!fatInitDefault()) #endif { toggleConsole(true); iprintf("FAT init failed\n"); return -1; } makeROMList(); makeMenu(); iprintf("lolSnes " VERSION " -- by Mega-Mario\n"); for (;;) { if (keypress != 0x03FF) { if (!(keypress & 0x0040)) // up { menusel--; if (menusel < 0) menusel = 0; if (menusel < menuscroll) menuscroll = menusel; makeMenu(); } else if (!(keypress & 0x0080)) // down { menusel++; if (menusel > nfiles-1) menusel = nfiles-1; if (menusel-21 > menuscroll) menuscroll = menusel-21; makeMenu(); } else if ((keypress & 0x0003) != 0x0003) // A/B { strncpy(fullpath, "snes/", 5); strncpy(fullpath + 5, &filelist[menusel << 8], 256); if (!Mem_LoadROM(fullpath)) { iprintf("ROM loading failed\n"); continue; } *(vu16*)0x04001000 &= 0xDFFF; toggleConsole(true); iprintf("ROM loaded, running\n"); CPU_Reset(); fifoSendValue32(FIFO_USER_01, 1); swiWaitForVBlank(); fifoSendValue32(FIFO_USER_01, 2); irqSet(IRQ_VBLANK, vblank); irqSet(IRQ_HBLANK, PPU_HBlank); swiWaitForVBlank(); CPU_Run(); } keypress = 0x03FF; } swiWaitForVBlank(); } return 0; }
// Main function int main() { // Init code for PC version #ifdef PLATFORM_PC // Initialize and create GDL window gdl::Init("Simple 2D Stuff", 854, 480, 32, 0, 0); #endif // Init code for Wii version #ifdef PLATFORM_WII // Initialize the file system fatInitDefault(); // Initialize MTek-GDL with default settings gdl::InitSystem(gdl::ModeAuto, gdl::AspectAuto, gdl::HiRes, gdl::AntiAliasing); //gdl::InitSystem(0); // Initialize Wiimote library (WPAD) WPAD_Init(); // Enter console mode to display error messages (on console platforms only) gdl::ConsoleMode(); #endif // Create 3 image objects for our test images gdl::Image image[3]; // Font sheet image for the fixed-font handling class gdl::Image fontImage; // Fixed-font handling class gdl::FFont font; // Some variables float angle=0,scaleCount=0; // Step a directory back since the test files are located there when compiled for PC #ifdef PLATFORM_PC chdir(".."); #endif // Load my uber-cute Barb fan-art (unless you're not a fan of my style) #ifdef PLATFORM_WII if (!image[0].LoadImageMipmapped("testdata/barb.png", gdl::LN_MM_LN, gdl::Linear, gdl::RGBA8, 9)) exit(0); #else if (!image[0].LoadImage("testdata/barb.png", gdl::Linear)) exit(0); #endif // Load the Trollface :) if (!image[1].LoadImage("testdata/trollface.png", gdl::Linear, gdl::IA4)) exit(0); // Create a 128x128 image for the procedurally generated plasma image[2].Create(128, 128, gdl::Linear, gdl::RGBA8); // Load generic 8x16 system font sheet if (!fontImage.LoadImage("testdata/font8x16.png", gdl::Nearest, gdl::I4)) exit(0); // Bind font sheet to our font object so we can print characters with it font.BindSheet(fontImage, 8, 16); // Generate color table for the plasma effect #define J 255.f/360*3 #define K 255.f/360*2 #define L 255.f/360*1 u_int colTable[256]; for (short c=0; c<256; c++) { int r = 255*fabs(sin((J*c)*ROTPI)); int g = 255*fabs(sin((K*c)*ROTPI)); int b = 255*fabs(sin((L*c)*ROTPI)); colTable[c] = RGBA(r, g, b, 255); } // Main loop while(1) { #ifdef PLATFORM_WII WPAD_ScanPads(); // Quit if home button is pressed if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)) gdl::wii::Exit(); #else if ((gdl::pc::WindowShouldClose()) || (gdl::Keyboard::KeyDown(gdl::Keyboard::KEY_ESCAPE))) break; #endif // Prepare display for rendering (this must be called prior to intensive code) gdl::PrepDisplay(); // Generate plasma image #ifdef PLATFORM_WII for(short py=0; py<128; py++) { for(short px=0; px<128; px++) { short col = (sin(px*PI/270)*255)+(sin(py*PI/45)*31)+(sin(((py+px)+(4*angle))*PI/90)*63); image[2].Texture.PokePixel(px, py, colTable[abs(col)%256]); } } // Flush texture so that updated pixels will be drawn properly image[2].Texture.Flush(); #else // Because PokePixel() is very slow on OpenGL, it is best to allocate a texture buffer and then upload its // pixels to the video card all at once using glTexSubImage2D(). u_int imageBuff[128][128]; for(short py=0; py<128; py++) { for(short px=0; px<128; px++) { short col = (sin(px*PI/270)*255)+(sin(py*PI/45)*31)+(sin(((py+px)+(4*angle))*PI/90)*63); imageBuff[py][px] = colTable[abs(col)%256]; } } glBindTexture(GL_TEXTURE_2D, image[2].Texture.TexID()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, imageBuff); #endif // Stretch the procedurally generated plasma graphic to fill the entire screen image[2].PutS(0, 0, gdl::ScreenXres, gdl::ScreenYres, gdl::Color::White); // Draw Barb picture and make it roto-zoom image[0].Put( gdl::ScreenCenterX, gdl::ScreenCenterY, RGBA(255, 255, 255, 127), gdl::Centered, gdl::Centered, 1.f+(0.8f*(sin(scaleCount*ROTPI))), angle ); // Draw trollface and make it bob up & down (for trolliness) image[1].Put(16, (gdl::ScreenYres-120)+(16*(sin((scaleCount*32)*ROTPI))) , gdl::Color::White); // Draw text and make it scale in and out font.DrawText("The power of MTek-GDL!", gdl::Centered, 32, 2.f+(1.f*(sin((scaleCount*4)*ROTPI))), gdl::Color::White); // Display gdl::Display(); // Update counters (with gdl::Delta so that it'll adapt according to your console's current TV system) angle += 0.1f*gdl::Delta; scaleCount += 0.5f*gdl::Delta; } }
/** \brief The main function \param argc number of arg \param *argv string table \return int */ FUNCNORETURN #if defined (_XBOX) && defined (__GNUC__) void XBoxStartup() { const char *logdir = NULL; myargc = -1; myargv = NULL; #else #ifdef FORCESDLMAIN int SDL_main(int argc, char **argv) #else int main(int argc, char **argv) #endif { const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string #endif #ifdef HAVE_TTF #ifdef _PS3 // apparently there is a bug in SDL_PSL1GHT which needs this to be set to work around SDL_setenv("SDL_VIDEODRIVER", "psl1ght", 1); I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE|SDL_DOUBLEBUF); #elif defined(_WIN32) I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE); #else I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE); #endif #endif #ifdef _PS3 // initialise controllers. //ioPadInit(7); #endif // init Wii-specific stuff #ifdef _WII // Start network if_config(localip, netmask, gateway, TRUE); #ifdef REMOTE_DEBUGGING #if REMOTE_DEBUGGING == 0 DEBUG_Init(GDBSTUB_DEVICE_TCP, GDBSTUB_DEF_TCPPORT); // Port 2828 #elif REMOTE_DEBUGGING > 2 DEBUG_Init(GDBSTUB_DEVICE_TCP, REMOTE_DEBUGGING); // Custom Port #elif REMOTE_DEBUGGING < 0 DEBUG_Init(GDBSTUB_DEVICE_USB, GDBSTUB_DEF_CHANNEL); // Slot 1 #else DEBUG_Init(GDBSTUB_DEVICE_USB, REMOTE_DEBUGGING-1); // Custom Slot #endif #endif // Start FAT filesystem fatInitDefault(); if (getcwd(wiicwd, PATH_MAX)) I_PutEnv(va("HOME=%ssrb2wii", wiicwd)); #endif logdir = D_Home(); #ifdef LOGMESSAGES #if defined(_WIN32_WCE) || defined(GP2X) logstream = fopen(va("%s.log",argv[0]), "a"); #elif defined (_WII) logstream = fopen(va("%s/srb2log.txt",logdir), "a"); #elif defined (DEFAULTDIR) if (logdir) logstream = fopen(va("%s/"DEFAULTDIR"/srb2log.txt",logdir), "a"); else #endif logstream = fopen("./srb2log.txt", "a"); #endif //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); #if defined (_WIN32) && !defined (_XBOX) #ifndef _WIN32_WCE { p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) #ifdef BUGTRAP && !InitBugTrap() #endif ) { LoadLibraryA("exchndl.dll"); } } #endif prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo); #ifndef _WIN32_WCE MakeCodeWritable(); #endif #endif // startup SRB2 CONS_Printf("%s", M_GetText("Setting up SRB2...\n")); D_SRB2Main(); CONS_Printf("%s", M_GetText("Entering main game loop...\n")); // never return D_SRB2Loop(); #ifdef BUGTRAP // This is safe even if BT didn't start. ShutdownBugTrap(); #endif // return to OS #ifndef __GNUC__ return 0; #endif }
void REV_init() { //Local variables f32 yscale; u32 xfbHeight; //Load the right IOS, so keyboard works fin u32 iosVersion = IOS_GetVersion(); if(iosVersion != 36) { IOS_ReloadIOS(36); } //// VIDEO_Init();//Video Library Init PAD_Init();//Gamecube Pad Library Init WPAD_Init();//Wiimote Library Init rMode = VIDEO_GetPreferredMode(NULL);//Set render mode // allocate 2 framebuffers for double buffering frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); //Configure Video System VIDEO_Configure(rMode); VIDEO_SetNextFramebuffer(frameBuffer[fb]);//Initial Framebuffer VIDEO_Flush(); VIDEO_WaitVSync(); if(rMode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); fb ^= 1;//Set next index //Set up the FIFO void *gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);//Allocate memset(gp_fifo,0,DEFAULT_FIFO_SIZE);//and Clear //Init GX hardware GX_Init(gp_fifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(DEF_BG_COLOR , 0x00ffffff); //More initialization w = rMode->viWidth; h = rMode->viHeight; yscale = GX_GetYScaleFactor(rMode->efbHeight,rMode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetDispCopySrc(0,0,rMode->fbWidth,rMode->efbHeight); GX_SetDispCopyDst(rMode->fbWidth,xfbHeight); GX_SetFieldMode(rMode->field_rendering,((h==2*rMode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (rMode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); for(u8 i = 0; i < 4; i++) WPAD_SetVRes(i,w,h); //Hardware Initialized, now engine initialization //Init filesystem fatInitDefault(); //First create a Root mainRoot = new ROOT; mainRoot->init((f32)w,(f32)h); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetColorUpdate(GX_ENABLE); GX_SetAlphaUpdate(GX_ENABLE); GX_SetZCompLoc(GX_TRUE); GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE); init3dConfig(); init2dConfig(); init2D(w, h); transQueue = NULL; solidQueue = NULL; zQueue = NULL; REV_fontsInit(); KEYBOARD_Init(NULL); keyboardInit(); }
int main(int _argc, char **_argv) { int framecount=0; int sramcount=0; argc=_argc, argv=_argv; defaultExceptionHandler(); fifoSendValue32(FIFO_USER_06, (u32)ipc_region); DS_init(); //DS init. #ifndef ROM_EMBEDED active_interface = fatInitDefault(); //init file operations to your external card. initNiFi(); #endif EMU_Init(); //emulation init. irqSet(IRQ_VBLANK, vblankinterrupt); irqEnable(IRQ_HBLANK); //fifoSetValue32Handler(FIFO_USER_06, aliveinterrupt, 0); //fifoSetValue32Handler(FIFO_USER_05, reg4015interrupt, 0); IPC_ALIVE = 0; IPC_APUIRQ = 0; IPC_REG4015 = 0; consoleinit(); //init subscreen to show chars. crcinit(); //init the crc table. //pre-alocate memory.... //IPC_FILES = malloc(MAXFILES * 256 + MAXFILES * 4); //IPC_ROM = malloc(ROM_MAX_SIZE); #ifndef ROM_EMBEDED if(!bootext()) { //chdir("/"); do_rommenu(); //show a menu selecting rom files. } #else do_romebd(); #endif //__emuflags |= PALSYNC; while(1) { // main loop to do the emulation framecount++; if(__emuflags & PALTIMING && global_playcount == 0) { framecount--; } if(debuginfo[VBLS]>59) { debuginfo[VBLS]-=60; debuginfo[1] = debuginfo[0]; debuginfo[0] = 0; debuginfo[FPS]=framecount; framecount=0; } scanKeys(); IPC_KEYS = keysCurrent(); //change nsf states if(__emuflags & NSFFILE) { static int oldkey = 0; int keydown = IPC_KEYS & (~oldkey); oldkey = IPC_KEYS; if(keydown & KEY_LEFT) { if(__nsfsongno == 0) { __nsfsongno = nsfheader.TotalSong-1; } else { __nsfsongno--; } } if(keydown & KEY_RIGHT) { if(++__nsfsongno > nsfheader.TotalSong-1) { __nsfsongno = 0; } } if(keydown & KEY_UP) { __nsfplay = 1; __nsfinit = 1; } if(keydown & KEY_DOWN) { __nsfplay = 0; Sound_reset(); } } do_shortcuts(); if((__emuflags & AUTOSRAM)) { if(__emuflags & NEEDSRAM) { sramcount = 1; __emuflags&=~NEEDSRAM; } if(sramcount > 0) sramcount++; if(sramcount > 120) { //need auto save for sram. sramcount = 0; save_sram(); } } touch_update(); // do menu functions. do_menu(); //do control menu. do_multi(); if(nifi_stat == 0 || nifi_stat >= 5) play(); //emulate a frame of the NES game. else swiWaitForVBlank(); } }
/** * Taken from the devkitPPC template... */ void WiiEnvironment::setup() { // Mtx view; Mtx model, modelview; GXColor background = {0, 0, 0, 0xff}; // init the vi. VIDEO_Init(); WPAD_Init(); WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC ); rmode = VIDEO_GetPreferredMode(NULL); // Attempt to initiate the fat filesystem... if ( !fatInitDefault() ) { // TODO: Logging somehow? exit( 1 ); } // allocate 2 framebuffers for double buffering frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(frameBuffer[fb]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // setup the fifo and then init the flipper void *gp_fifo = NULL; gp_fifo = memalign(32,DEFAULT_FIFO_SIZE); memset(gp_fifo,0,DEFAULT_FIFO_SIZE); GX_Init(gp_fifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(background, 0x00ffffff); // other gx setup GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1); yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopyDst(rmode->fbWidth,xfbHeight); GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter); GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); GX_SetCullMode(GX_CULL_NONE); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); // setup the vertex descriptor // tells the flipper to expect direct data GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); // setup the vertex attribute table // describes the data // args: vat location 0-7, type of data, data format, size, scale // so for ex. in the first call we are sending position data with // 3 values X,Y,Z of size F32. scale sets the number of fractional // bits for non float data. GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0); GX_SetNumChans(1); GX_SetNumTexGens(0); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0); GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); // setup our camera at the origin // looking down the -z axis with y up guVector cam = {0.0F, 0.0F, -100.0F}, up = {0.0F, 1.0F, 0.0F}, look = {0.0F, 0.0F, 0.0F}; guLookAt(view, &cam, &up, &look); // setup our projection matrix // this creates a perspective matrix with a view angle of 90, // and aspect ratio based on the display resolution f32 w = rmode->viWidth; f32 h = rmode->viHeight; guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F); GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE); }
int load_feeds() { if (!fatInitDefault()) { return -1; } mxml_node_t *tree; mxml_node_t *rss; mxml_node_t *node; //printf("DEBUG: load_feeds()\n"); FILE *fp = fopen("/feeds.xml", "rb"); if (fp == NULL) { fclose(fp); //printf("DEBUG: File-Pointer is NULL!!!\n"); return -2; } else { fseek (fp , 0, SEEK_END); long settings_size = ftell (fp); rewind (fp); if (settings_size > 0) { tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK); fclose(fp); rss = mxmlFindElement(tree, tree, "rss", NULL, NULL, MXML_DESCEND); if (rss == NULL) return -103; for (node = mxmlFindElement(rss, rss, "feed", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, rss, "feed", NULL, NULL, MXML_DESCEND)) { const char * feedurl = node->child->value.opaque; if (feedurl) { const char * sender = mxmlElementGetAttr(node, "name"); if (sender) { //printf("DEBUG: Valid node found!!!\n"); int old_length = ijobs; RSS_Job * tmp = new RSS_Job[old_length]; for (int i = 0; i < old_length; i++) { //printf("DEBUG: Copying an element to the temp-Array...\n"); tmp[i] = jobs[i]; } jobs = new RSS_Job[ old_length + 1 ]; for (int j = 0; j < old_length ; j++) { //printf("DEBUG: Copying an element back to the jobs-Array...\n"); jobs[j] = tmp[j]; } memset(newone.url, 0, 256); memset(newone.name, 0, 256); snprintf(newone.url, 255, feedurl); snprintf(newone.name, 255, sender); jobs[old_length] = newone; ijobs++; //printf("DEBUG: ijobs: %i\n", ijobs); } else { //printf("DEBUG: return -102\n"); return -102; } } else { //printf("DEBUG: return -101\n"); return -101; } } mxmlDelete(tree); //printf("File loaded.\n\n"); } else { fclose(fp); //printf("DEBUG: return -1\n"); return -3; } } return 0; }
int main(int argc, char **argv) { // Exit after 10 seconds if there is an error __exception_setreload(10); // u64 timeout = 0; CheckForGecko(); DCInvalidateRange(loader_stub, 0x1800); memcpy(loader_stub, (void*)0x80001800, 0x1800); RAMInit(); //Meh, doesnt do anything anymore anyways //STM_RegisterEventHandler(HandleSTMEvent); Initialise(); // Checking for storage devices... ShowMessageScreen("Checking storage devices..."); u32 u; //Disables MEMPROT for patches write16(MEM_PROT, 0); //Patches FS access for( u = 0x93A00000; u < 0x94000000; u+=2 ) { if( memcmp( (void*)(u), FSAccessPattern, sizeof(FSAccessPattern) ) == 0 ) { // gprintf("FSAccessPatch:%08X\r\n", u ); memcpy( (void*)u, FSAccessPatch, sizeof(FSAccessPatch) ); DCFlushRange((void*)u, sizeof(FSAccessPatch)); break; } } //for BT.c CONF_GetPadDevices((conf_pads*)0x932C0000); DCFlushRange((void*)0x932C0000, sizeof(conf_pads)); *(vu32*)0x932C0490 = CONF_GetIRSensitivity(); *(vu32*)0x932C0494 = CONF_GetSensorBarPosition(); DCFlushRange((void*)0x932C0490, 8); if(LoadKernel() < 0) { ClearScreen(); gprintf("Failed to load kernel from NAND!\r\n"); ShowMessageScreenAndExit("Failed to load kernel from NAND!", 1); } InsertModule((char*)kernel_bin, kernel_bin_size); memset( (void*)0x92f00000, 0, 0x100000 ); DCFlushRange( (void*)0x92f00000, 0x100000 ); DCInvalidateRange( (void*)0x939F02F0, 0x20 ); memcpy( (void*)0x939F02F0, Boot2Patch, sizeof(Boot2Patch) ); DCFlushRange( (void*)0x939F02F0, 0x20 ); //libogc still has that, lets close it __ES_Close(); s32 fd = IOS_Open( "/dev/es", 0 ); memset( STATUS, 0xFFFFFFFF, 0x20 ); DCFlushRange( STATUS, 0x20 ); memset( (void*)0x91000000, 0xFFFFFFFF, 0x20 ); DCFlushRange( (void*)0x91000000, 0x20 ); *(vu32*)0xD3003420 = 0; //make sure kernel doesnt reload raw_irq_handler_t irq_handler = BeforeIOSReload(); IOS_IoctlvAsync( fd, 0x1F, 0, 0, &IOCTL_Buf, NULL, NULL ); AfterIOSReload( irq_handler, FoundVersion ); while(1) { DCInvalidateRange( STATUS, 0x20 ); if((STATUS_LOADING > 0 || abs(STATUS_LOADING) > 1) && STATUS_LOADING < 20) { gprintf("Kernel sent signal\n"); break; } } /* For slow USB HDDs */ time_t timeout = time(NULL); while(time(NULL) - timeout < 10) { if(__io_custom_usbstorage.startup() && __io_custom_usbstorage.isInserted()) break; usleep(50000); } fatInitDefault(); gprintf("Nintendont at your service!\r\n%s\r\n", NIN_BUILD_STRING); KernelLoaded = 1; char* first_slash = strrchr(argv[0], '/'); if (first_slash != NULL) strncpy(launch_dir, argv[0], first_slash-argv[0]+1); gprintf("launch_dir = %s\r\n", launch_dir); FPAD_Init(); FPAD_Update(); /* Read IPL Font before doing any patches */ void *fontbuffer = memalign(32, 0x50000); __SYS_ReadROM((void*)fontbuffer,0x50000,0x1AFF00); memcpy((void*)0xD3100000, fontbuffer, 0x50000); DCInvalidateRange( (void*)0x93100000, 0x50000 ); free(fontbuffer); //gprintf("Font: 0x1AFF00 starts with %.4s, 0x1FCF00 with %.4s\n", (char*)0x93100000, (char*)0x93100000 + 0x4D000); // Simple code to autoupdate the meta.xml in Nintendont's folder FILE *meta = fopen("meta.xml", "w"); if(meta != NULL) { fprintf(meta, "%s\r\n<app version=\"1\">\r\n\t<name>%s</name>\r\n", META_XML, META_NAME); fprintf(meta, "\t<coder>%s</coder>\r\n\t<version>%d.%d</version>\r\n", META_AUTHOR, NIN_VERSION>>16, NIN_VERSION&0xFFFF); fprintf(meta, "\t<release_date>20150531000000</release_date>\r\n"); fprintf(meta, "\t<short_description>%s</short_description>\r\n", META_SHORT); fprintf(meta, "\t<long_description>%s\r\n\r\n%s</long_description>\r\n", META_LONG1, META_LONG2); fprintf(meta, "\t<ahb_access/>\r\n</app>"); fclose(meta); }
extern "C" int main(int argc, char **argv) { timeval tv; gettimeofday(&tv, NULL); srand(tv.tv_usec); #if defined(GEKKO) DIR *dir_tmp; #endif // Init SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError()); return 1; } if (TTF_Init() < 0) { fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() ); return 1; } fflush(stdout); #ifdef GEKKO printf("\x1b[2;0H"); //initialize libfat library if (fatInitDefault()) printf("FAT subsytem initialized\n\n"); else { printf("Couldn't initialize FAT subsytem\n\n"); sleep(3); exit(0); } DIR *dp; dp = opendir ("sd:/"); if (dp) sdismount = 1; else sdismount = 0; if (sdismount) printf("SD FAT subsytem initialized\n\n"); else printf("Couldn't initialize SD fat subsytem\n\n"); if (sdismount) closedir (dp); usbismount = InitUSB(); if (usbismount) printf("USB FAT subsytem initialized\n\n"); else printf("Impossible to initialize USB FAT subsytem\n\n"); networkisinit = InitNetwork(); sleep(2); //create tmp directory if it does not exist dir_tmp = opendir("/frodo/tmp"); if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(2);} else closedir(dir_tmp); //Cancel the old files unlink ("/frodo/tmp/a"); unlink ("/frodo/tmp/dummy"); #endif Frodo *the_app = new Frodo(); the_app->ArgvReceived(argc, argv); the_app->ReadyToRun(); delete the_app; if (smbismount) CloseShare (true); #ifdef GEKKO DeInitUSB(); fatUnmount(0); #endif return 0; }
bool PA_InitFat() { return fatInitDefault(); }
/*************************************************************************** * M A I N * ***************************************************************************/ int main (int argc, char *argv[]) { #ifdef HW_RVL /* enable 64-byte fetch mode for L2 cache */ L2Enhance(); /* initialize DI interface */ DI_UseCache(0); DI_Init(); sprintf(osd_version, "%s (IOS %d)", VERSION, IOS_GetVersion()); #else sprintf(osd_version, "%s (GCN)", VERSION); #endif /* initialize video engine */ gx_video_Init(); #ifndef HW_RVL /* initialize DVD interface */ DVD_Init(); #endif /* initialize input engine */ gx_input_Init(); /* initialize FAT devices */ int retry = 0; int fatMounted = 0; /* try to mount FAT devices during 3 seconds */ while (!fatMounted && (retry < 12)) { fatMounted = fatInitDefault(); usleep(250000); retry++; } if (fatMounted) { /* base directory */ char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); DIR *dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default SRAM & Savestate files directories */ sprintf (pathname, "%s/saves",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default Snapshot files directories */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default Cheat files directories */ sprintf (pathname, "%s/cheats",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default BIOS ROM files directories */ sprintf (pathname, "%s/bios",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default LOCK-ON ROM files directories */ sprintf (pathname, "%s/lock-on",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); } /* initialize sound engine */ gx_audio_Init(); /* initialize genesis plus core */ history_default(); config_default(); init_machine(); /* auto-load last ROM file */ if (config.autoload) { SILENT = 1; if (OpenDirectory(TYPE_RECENT, -1)) { if (LoadFile(0)) { reloadrom(); gx_video_Start(); gx_audio_Start(); ConfigRequested = 0; } } SILENT = 0; } /* show disclaimer */ if (ConfigRequested) { legal(); } #ifdef HW_RVL /* power button callback */ SYS_SetPowerCallback(PowerOff_cb); #endif /* reset button callback */ SYS_SetResetCallback(Reset_cb); /* main emulation loop */ run_emulation(); /* we should never return anyway */ return 0; }
int main(int argc, char *argv[]) { s32 res; #ifdef USE_WII_DI DI_Init(); #endif VIDEO_Init(); PAD_Init(); AUDIO_Init(NULL); #ifdef DEBUG_WII_USBGECKO CON_EnableGecko(1, false); #endif #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif #ifdef USE_WII_DI // initial async mount for the browser, see wii-fs.cpp DI_Mount(); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); fatUnmountDefault(); #ifdef USE_WII_DI DI_Close(); #endif if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); return res; }
int main( int argc, char **argv) { // defaultExceptionHandler(); if (fatInitDefault()) { fifoWaitValue32(FIFO_USER_02); if (fifoGetValue32(FIFO_USER_01) == 0) { int size = 32; FILE* ResetData = fopen("sd:/hiya/ResetData.bin","rb"); fread((void*)0x02000300,1,size,ResetData); fclose(ResetData); fifoSendValue32(FIFO_USER_08, 1); for (int i = 0; i < 5; i++) { swiWaitForVBlank(); } } LoadSettings(); bool gotoSettings = false; if (access("sd:/hiya/settings.ini", F_OK)) { gotoSettings = true; } scanKeys(); if(keysHeld() & KEY_SELECT) gotoSettings = true; if(gotoSettings) { // Subscreen as a console videoSetMode(MODE_0_2D); vramSetBankG(VRAM_G_MAIN_BG); videoSetModeSub(MODE_0_2D); vramSetBankH(VRAM_H_SUB_BG); int pressed = 0; bool menuprinted = true; while(1) { if(menuprinted) { consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 15, 0, true, true); consoleClear(); printf("HiyaCFW v1.0 configuration\n"); printf("Press A to select, START to save"); printf("\n"); if(cursorPosition == 0) printf(">"); else printf(" "); printf("Splash: "); if(splash) printf("Off( ), On(x)"); else printf("Off(x), On( )"); printf("\n\n"); if(cursorPosition == 1) printf(">"); else printf(" "); if(dsiSplash) printf("(x)"); else printf("( )"); printf(" DSi Splash/H&S screen"); consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); consoleClear(); if(cursorPosition == 0) { printf("Enable splash screen."); } else if(cursorPosition == 1) { printf("Enable showing the DSi Splash/\n"); printf("Health & Safety screen."); } menuprinted = false; } do { scanKeys(); pressed = keysDownRepeat(); swiWaitForVBlank(); } while (!pressed); if (pressed & KEY_A) { switch(cursorPosition){ case 0: default: splash = !splash; break; case 1: dsiSplash = !dsiSplash; break; } menuprinted = true; } if (pressed & KEY_UP) { cursorPosition -= 1; menuprinted = true; } else if (pressed & KEY_DOWN) { cursorPosition += 1; menuprinted = true; } if (cursorPosition < 0) cursorPosition = 1; if (cursorPosition > 1) cursorPosition = 0; if (pressed & KEY_START) { SaveSettings(); break; } } } if(dsiSplash) fifoSendValue32(FIFO_USER_03, 1); if(splash) { BootSplashInit(); LoadScreen(); for (int i = 0; i < 60*3; i++) { swiWaitForVBlank(); } } runNdsFile("/BOOTLOADER.NDS", 0, NULL); } else { BootSplashInit(); // Display Error Screen swiDecompressLZSSVram ((void*)topErrorTiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); swiDecompressLZSSVram ((void*)subErrorTiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); vramcpy_ui (&BG_PALETTE[0], topErrorPal, topErrorPalLen); vramcpy_ui (&BG_PALETTE_SUB[0], subErrorPal, subErrorPalLen); } while(1) { swiWaitForVBlank(); } }