Game::~Game() { CloseGame(); //Remove ourself as a Window listener Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this); windowClosed(mWindow); delete mRoot; }
/** * Loads a game, given a full path/filename. The driver code must be * initialized after the game is loaded, because the emulator code * provides data necessary for the driver code(number of scanlines to * render, what virtual input devices to use, etc.). */ int LoadGame(const char *path) { if (isloaded){ CloseGame(); } if(!FCEUI_LoadGame(path, 1)) { return 0; } int state_to_load; g_config->getOption("SDL.AutoLoadState", &state_to_load); if (state_to_load >= 0 && state_to_load < 10){ FCEUI_SelectState(state_to_load, 0); FCEUI_LoadState(NULL, false); } ParseGIInput(GameInfo); RefreshThrottleFPS(); if(!DriverInitialize(GameInfo)) { return(0); } // set pal/ntsc int id; g_config->getOption("SDL.PAL", &id); switch(id) { case 0: FCEUI_SetVidSystem(0); pal_emulation = 0; dendy = 0; break; case 1: FCEUI_SetVidSystem(1); pal_emulation = 1; dendy = 0; break; case 2: FCEUI_SetVidSystem(0); pal_emulation = 0; dendy = 1; } std::string filename; g_config->getOption("SDL.Sound.RecordFile", &filename); if(filename.size()) { if(!FCEUI_BeginWaveRecord(filename.c_str())) { g_config->setOption("SDL.Sound.RecordFile", ""); } } isloaded = 1; FCEUD_NetworkConnect(); return 1; }
int LoadGame(const char *path) { MDFNGI *tmp; CloseGame(); pending_save_state = 0; pending_save_movie = 0; pending_snapshot = 0; #ifdef NEED_CDEMU if(loadcd) { if(!(tmp = MDFNI_LoadCD(loadcd, path))) return(0); } else #endif { if(!(tmp=MDFNI_LoadGame(path))) return 0; } CurGame = tmp; InitGameInput(tmp); RefreshThrottleFPS(1); SDL_mutexP(VTMutex); NeedVideoChange = -1; SDL_mutexV(VTMutex); if(SDL_ThreadID() != MainThreadID) while(NeedVideoChange) { SDL_Delay(1); } sound_active = 0; if(MDFN_GetSettingB("sound")) sound_active = InitSound(tmp); if(MDFN_GetSettingB("autosave")) MDFNI_LoadState(NULL, "ncq"); if(netconnect) MDFND_NetworkConnect(); GameThreadRun = 1; GameThread = SDL_CreateThread(GameLoop, NULL); ffnosound = MDFN_GetSettingB("ffnosound"); return 1; }
void ResetGameLoaded(void) { if (FCEUGameInfo) CloseGame(); GameStateRestore = 0; PPU_hook = 0; GameHBIRQHook = 0; if (GameExpSound.Kill) GameExpSound.Kill(); memset(&GameExpSound, 0, sizeof(GameExpSound)); MapIRQHook = 0; MMC5Hack = 0; PAL &= 1; pale = 0; }
// Custom palette static void custom_update(unsigned long key) { const char *types[] = {".pal", NULL}; char palname[128] = ""; if (!RunFileBrowser("/usr/local/home/.fceux", palname, types, "Choose nes palette (.pal)")) { CloseGame(); dingoo_deinit(); exit(-1); } std::string cpalette = std::string(palname); g_config->setOption("SDL.Palette", cpalette); }
// Main menu commands static int load_rom() { const char *types[] = { ".nes", ".fds", ".zip", ".fcm", ".fm2", ".nsf", NULL }; char filename[128], romname[128]; int error; #ifdef DINGUX_ON_WIN32 if (!RunFileBrowser("d:\\", filename, types)) { #else if (!RunFileBrowser(NULL, filename, types)) { #endif CloseGame(); SDL_Quit(); exit(-1); } // TODO - Must close game here? CloseGame(); // Is this a movie? if (!(error = FCEUD_LoadMovie(filename, romname))) error = LoadGame(filename); if (error != 1) { CloseGame(); SDL_Quit(); exit(-1); } return 1; } static int reset_nes() { FCEUI_ResetNES(); return 1; }
void UpdatePhysicalInput(void) { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { //case SDL_SYSWMEVENT: puts("Nifty keen");break; //case SDL_VIDEORESIZE: puts("Okie dokie");break; case SDL_QUIT: CloseGame();puts("Quit");break; } //printf("Event: %d\n",event.type); //fflush(stdout); } //SDL_PumpEvents(); }
void FCEUI_CloseGame(void) { CloseGame(); }
static void KeyboardCommands(void) { int is_shift, is_alt; keys=GetKeyboard(); if(InputType[2]==SIFC_FKB) // Family Keyboard (FKB) { if(keyonly(SCROLLLOCK)) { cidisabled^=1; FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis"); } #ifdef SDL SDL_WM_GrabInput( cidisabled? SDL_GRAB_ON: SDL_GRAB_OFF ); #endif if(cidisabled) return; } is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT); is_alt = KEY(LEFTALT) | KEY(RIGHTALT); #ifdef SDL if(keyonly(F4)) { if(is_shift) FCEUI_SetRenderDisable(-1, 2); else FCEUI_SetRenderDisable(2, -1); } #endif #if defined(SDL) && !defined(FLASH) if(keyonly(ENTER) && is_alt) ToggleFS(); #endif // Disable most keyboard shortcuts in Flash #ifndef FLASH NoWaiting &=~ 1; if(KEY(GRAVE)) { NoWaiting|=1; } if(gametype==GIT_FDS) { if(keyonly(F6)) FCEUI_FDSSelect(); if(keyonly(F8)) FCEUI_FDSInsert(0); } if(keyonly(F9)) { FCEUI_SaveSnapshot(); } if(gametype!=GIT_NSF) { #ifndef EXTGUI if(keyonly(F2)) { DoCheatSeq(); } #endif if(keyonly(F5)) { if(is_shift) FCEUI_SaveMovie(NULL); else FCEUI_SaveState(NULL); } if(keyonly(F7)) { if(is_shift) FCEUI_LoadMovie(NULL); else FCEUI_LoadState(NULL); } } if(keyonly(F1)) FCEUI_ToggleTileView(); if(keyonly(F10)) FCEUI_ResetNES(); if(keyonly(F11)) FCEUI_PowerNES(); #ifdef EXTGUI if(keyonly(F3)) GUI_Hide(-1); if(KEY(F12)) GUI_RequestExit(); if(KEY(ESCAPE)) CloseGame(); #else if(KEY(F12) || KEY(ESCAPE)) CloseGame(); #endif if(gametype==GIT_VSUNI) { if(keyonly(F8)) FCEUI_VSUniCoin(); if(keyonly(F6)) { DIPS^=1; FCEUI_VSUniToggleDIPView(); } if(!(DIPS&1)) goto DIPSless; if(keyonly(1)) FCEUI_VSUniToggleDIP(0); if(keyonly(2)) FCEUI_VSUniToggleDIP(1); if(keyonly(3)) FCEUI_VSUniToggleDIP(2); if(keyonly(4)) FCEUI_VSUniToggleDIP(3); if(keyonly(5)) FCEUI_VSUniToggleDIP(4); if(keyonly(6)) FCEUI_VSUniToggleDIP(5); if(keyonly(7)) FCEUI_VSUniToggleDIP(6); if(keyonly(8)) FCEUI_VSUniToggleDIP(7); } else { static uint8 bbuf[32]; static int bbuft; static int barcoder = 0; if(keyonly(H)) FCEUI_NTSCSELHUE(); if(keyonly(T)) FCEUI_NTSCSELTINT(); if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC(); if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC(); if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) { if(keyonly(F8)) { barcoder ^= 1; if(!barcoder) { if(InputType[2] == SIFC_BWORLD) { strcpy(&BWorldData[1],bbuf); BWorldData[0]=1; } else FCEUI_DatachSet(bbuf); FCEUI_DispMessage("Barcode Entered"); } else { bbuft = 0; FCEUI_DispMessage("Enter Barcode");} } } else barcoder = 0; #define SSM(x) \ { if(barcoder) { if(bbuft < 13) {bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0;} FCEUI_DispMessage("Barcode: %s",bbuf);} \ else { \ if(is_shift) FCEUI_SelectMovie(x); \ else FCEUI_SelectState(x); \ } } DIPSless: if(keyonly(0)) SSM(0); if(keyonly(1)) SSM(1); if(keyonly(2)) SSM(2); if(keyonly(3)) SSM(3); if(keyonly(4)) SSM(4); if(keyonly(5)) SSM(5); if(keyonly(6)) SSM(6); if(keyonly(7)) SSM(7); if(keyonly(8)) SSM(8); if(keyonly(9)) SSM(9); #undef SSM } #endif }
int GCMemROM(int size) { bool biosError = false; ResetGameLoaded(); CloseGame(); GameInfo = new FCEUGI(); memset(GameInfo, 0, sizeof(FCEUGI)); GameInfo->filename = strdup(romFilename); GameInfo->archiveCount = 0; /*** Set some default values ***/ GameInfo->name=0; GameInfo->type=GIT_CART; GameInfo->vidsys=(EGIV)GCSettings.timing; GameInfo->input[0]=GameInfo->input[1]=SI_UNSET; GameInfo->inputfc=SIFC_UNSET; GameInfo->cspecial=SIS_NONE; /*** Set internal sound information ***/ SetSampleRate(); FCEUI_SetSoundVolume(100); // 0-100 FCEUI_SetLowPass(0); FCEUFILE * fceufp = new FCEUFILE(); fceufp->size = size; fceufp->filename = romFilename; fceufp->mode = FCEUFILE::READ; // read only EMUFILE_MEMFILE *fceumem = new EMUFILE_MEMFILE(nesrom, size); fceufp->stream = fceumem; romLoaded = iNESLoad(romFilename, fceufp, 1); if(!romLoaded) { romLoaded = UNIFLoad(romFilename, fceufp); } if(!romLoaded) { romLoaded = NSFLoad(romFilename, fceufp); } if(!romLoaded) { // read FDS BIOS into FDSBIOS - should be 8192 bytes if (FDSBIOS[1] == 0) { size_t biosSize = 0; char * tmpbuffer = (char *) memalign(32, 64 * 1024); char filepath[1024]; sprintf (filepath, "%s%s/disksys.rom", pathPrefix[GCSettings.LoadMethod], APPFOLDER); biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT); if(biosSize == 0 && strlen(appPath) > 0) { sprintf (filepath, "%s/disksys.rom", appPath); biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT); } if (biosSize == 8192) { memcpy(FDSBIOS, tmpbuffer, 8192); } else { biosError = true; if (biosSize > 0) ErrorPrompt("FDS BIOS file is invalid!"); else ErrorPrompt("FDS BIOS file not found!"); } free(tmpbuffer); } if (FDSBIOS[1] != 0) { romLoaded = FDSLoad(romFilename, fceufp); } } delete fceufp; if (romLoaded) { FCEU_ResetVidSys(); if(GameInfo->type!=GIT_NSF) if(FSettings.GameGenie) OpenGameGenie(); PowerNES(); //if(GameInfo->type!=GIT_NSF) // FCEU_LoadGamePalette(); FCEU_ResetPalette(); FCEU_ResetMessages(); // Save state, status messages, etc. SetupCheats(); ResetAudio(); return 1; } else { delete GameInfo; GameInfo = 0; if(!biosError) ErrorPrompt("Invalid game file!"); romLoaded = false; return 0; } }
void HUDInterface::MainMenuClick ( Button *button ) { CloseGame (); }
bool FrameFunc() { if (menu == 1) { int id = UpdateGUI1(); switch(id) { case 1: //menu = 2; //InitiateGUI2(); level_name = "demo.lev"; //if (StartNewGame()) { menu = 0; CreateNewGame(); } break; case 2: { //menu = 2; //InitiateGUI2(); //HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX1); //if (!mutex) // mutex = CreateMutex(NULL, FALSE, NAME_MUTEX1); //hgeGUIObject *lb = gui->GetCtrl(1); //find_srv = CreateThread(NULL, 0, &FindServer, lb, 0, NULL); } break; case 3: menu = 2; InitiateGUIOptions(); break; case 4: menu = 4; InitiateGUI4(); break; case 5: return true; break; } } else if (menu == 2) { int id = UpdateGUI2(); switch(id) { case 2: /*if (StartNewGame()) { CreateNewGame(); menu = 0; }*/ { hgeGUIListbox *lb = (hgeGUIListbox *)gui->GetCtrl(1); int item = lb->GetSelectedItem(); char *buffer = lb->GetItemText(item); lb = (hgeGUIListbox *)gui->GetCtrl(4); item = lb->GetSelectedItem(); char *temp = lb->GetItemText(item); bool screen_mode = false; if (strcmp("FULL SCREEN", temp) == 0) { screen_mode = false; } else if (strcmp("WINDOWED", temp) == 0) { screen_mode = true; } std::string str(buffer); int index = str.find("x", 0); std::string sub_str1 = str.substr(0, index); std::string sub_str2 = str.substr(index+1); int w = atoi(sub_str1.c_str()); int h = atoi(sub_str2.c_str()); std::ofstream f("options.cfg", std::ios::binary); f.write((const char *)&w, sizeof(int)); f.write((const char *)&h, sizeof(int)); f.write((const char *)&screen_mode, sizeof(bool)); f.close(); menu = 1; InitiateGUI1(); } break; case 3: menu = 1; InitiateGUI1(); break; } } else if (menu == 3) { HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX1); if (mutex) { WaitForSingleObject(mutex, INFINITE); int id = UpdateGUI3(); switch(id) { case 2: /*TerminateThread(find_srv, 0); if (ConnectToGame()) { menu = 0; }*/ break; case 3: break; case 4: menu = 1; //TerminateThread(find_srv, 0); //find_srv = NULL; InitiateGUI1(); break; } ReleaseMutex(mutex); } } else if (menu == 4) { int id = UpdateGUI4(); switch(id) { case 2: menu = 1; InitiateGUI1(); break; } } else { static float time = 0; hge->Input_GetMousePos(&mouse_pos.x, &mouse_pos.y); float dt = hge->Timer_GetDelta(); time += dt; hard->Update(dt); if (time > 0.025000)//40 fps { if (hge->Input_GetKeyState(HGEK_ESCAPE)) { menu = 1; CloseGame(); InitiateGUI1(); return false; } world->Reset(); if (ENTITY_DEATH != player->GetState()) { HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2); if (mutex) { WaitForSingleObject(mutex, INFINITE); if (hge->Input_GetKeyState(HGEK_SPACE) || hge->Input_GetKeyState(HGEK_UP)) { player->Jump(); } if (hge->Input_GetKeyState(HGEK_A) || hge->Input_GetKeyState(HGEK_LEFT)) { player->Move(MOVE_LEFT); } if (hge->Input_GetKeyState(HGEK_D) || hge->Input_GetKeyState(HGEK_RIGHT)) { player->Move(MOVE_RIGHT); } if (hge->Input_GetKeyState(HGEK_K)) { player->Kill(); } player->FaceToTarget(mouse_pos); if (world->GetWorldEntitys()->size() == 0) { if (!next_level_name.empty()) { level_end = 1; } else { level_end = 2; } static float tmp = 0; tmp += hge->Timer_GetDelta(); if (tmp > 0.40) { if (hge->Input_GetKeyState(HGEK_LBUTTON)) { level_end = 0; level_name = next_level_name; if (!level_name.empty()) { CreateNewGame(); } else { menu = 1; CloseGame(); InitiateGUI1(); return false; } tmp = 0; } } } if (hge->Input_GetKeyState(HGEK_LBUTTON)) { player->Attack(mouse_pos); } else { player->RotateWeapon(mouse_pos); } world->GetMap()->ScrollTo(player->GetPos()); ReleaseMutex(mutex); } } else { if (hge->Input_GetKeyState(HGEK_SPACE)) { UpdatePlayerPos(); HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2); if (mutex) { WaitForSingleObject(mutex, INFINITE); world->GetMap()->ScrollTo(player->GetPos()); ReleaseMutex(mutex); } } } world->UpdatePositionObjects(); world->UpdateObjects(); time = 0; } if (world->GetWorldEntitys()->size() == 0) { if (!next_level_name.empty()) { level_end = 1; } else { level_end = 2; } } world->UpdateGraphic(); } return false; }
/** * The main loop for the SDL. */ int main(int argc, char *argv[]) { // this is a hackish check for the --help arguemnts // these are normally processed by the config parser, but SDL_Init // must be run before the config parser: so if even SDL_Init fails, // these six lines will still print the help output if(argc > 1) { if(!strcmp(argv[1], "--help") || !strcmp(argv[1],"-h")) { ShowUsage(argv[0]); return 0; } } int error, frameskip; FCEUD_Message("Starting " FCEU_NAME_AND_VERSION "...\n"); #ifdef WIN32 /* Taken from win32 sdl_main.c */ SDL_SetModuleHandle(GetModuleHandle(NULL)); #endif /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */ if(SDL_Init(SDL_INIT_VIDEO)) { printf("Could not initialize SDL: %s.\n", SDL_GetError()); return(-1); } #ifdef OPENGL SDL_GL_LoadLibrary(0); #endif // Initialize the configuration system g_config = InitConfig(); if(!g_config) { SDL_Quit(); return -1; } // initialize the infrastructure error = FCEUI_Initialize(); if(error != 1) { ShowUsage(argv[0]); SDL_Quit(); return -1; } // check for --help or -h and display usage; also check for --nogui for(int i=0; i<argc;i++) { if(strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { ShowUsage(argv[0]); SDL_Quit(); return 0; } #ifdef _GTK else if(strcmp(argv[i], "--nogui") == 0) { noGui = 1; argv[i] = ""; } #endif } int romIndex = g_config->parse(argc, argv); // This is here so that a default fceux.cfg will be created on first // run, even without a valid ROM to play. // Unless, of course, there's actually --no-config given // mbg 8/23/2008 - this is also here so that the inputcfg routines can have // a chance to dump the new inputcfg to the fceux.cfg in case you didnt // specify a rom filename g_config->getOption("SDL.NoConfig", &noconfig); if (!noconfig) g_config->save(); std::string s; g_config->getOption("SDL.InputCfg", &s); if(s.size() != 0) { InitVideo(GameInfo); InputCfg(s); } // set the FAMICOM PAD 2 Mic thing { int t; g_config->getOption("SDL.Input.FamicomPad2.EnableMic", &t); if(t) replaceP2StartWithMicrophone = t; } // update the input devices UpdateInput(g_config); // check for a .fcm file to convert to .fm2 g_config->getOption ("SDL.FCMConvert", &s); g_config->setOption ("SDL.FCMConvert", ""); if (!s.empty()) { int okcount = 0; std::string infname = s.c_str(); // produce output filename std::string outname; size_t dot = infname.find_last_of ("."); if (dot == std::string::npos) outname = infname + ".fm2"; else outname = infname.substr(0,dot) + ".fm2"; MovieData md; EFCM_CONVERTRESULT result = convert_fcm (md, infname); if (result == FCM_CONVERTRESULT_SUCCESS) { okcount++; // *outf = new EMUFILE; EMUFILE_FILE* outf = FCEUD_UTF8_fstream (outname, "wb"); md.dump (outf,false); delete outf; FCEUD_Message ("Your file has been converted to FM2.\n"); } else { FCEUD_Message ("Something went wrong while converting your file...\n"); } DriverKill(); SDL_Quit(); return 0; } // If x/y res set to 0, store current display res in SDL.LastX/YRes int yres, xres; g_config->getOption("SDL.XResolution", &xres); g_config->getOption("SDL.YResolution", &yres); #if SDL_VERSION_ATLEAST(2, 0, 0) // TODO _ SDL 2.0 #else const SDL_VideoInfo* vid_info = SDL_GetVideoInfo(); if(xres == 0) { if(vid_info != NULL) { g_config->setOption("SDL.LastXRes", vid_info->current_w); } else { g_config->setOption("SDL.LastXRes", 512); } } else { g_config->setOption("SDL.LastXRes", xres); } if(yres == 0) { if(vid_info != NULL) { g_config->setOption("SDL.LastYRes", vid_info->current_h); } else { g_config->setOption("SDL.LastYRes", 448); } } else { g_config->setOption("SDL.LastYRes", yres); } #endif int autoResume; g_config->getOption("SDL.AutoResume", &autoResume); if(autoResume) { AutoResumePlay = true; } else { AutoResumePlay = false; } // check to see if recording HUD to AVI is enabled int rh; g_config->getOption("SDL.RecordHUD", &rh); if( rh == 0) FCEUI_SetAviEnableHUDrecording(true); else FCEUI_SetAviEnableHUDrecording(false); // check to see if movie messages are disabled int mm; g_config->getOption("SDL.MovieMsg", &mm); if( mm == 0) FCEUI_SetAviDisableMovieMessages(true); else FCEUI_SetAviDisableMovieMessages(false); // check for a .fm2 file to rip the subtitles g_config->getOption("SDL.RipSubs", &s); g_config->setOption("SDL.RipSubs", ""); if (!s.empty()) { MovieData md; std::string infname; infname = s.c_str(); FCEUFILE *fp = FCEU_fopen(s.c_str(), 0, "rb", 0); // load the movie and and subtitles extern bool LoadFM2(MovieData&, EMUFILE*, int, bool); LoadFM2(md, fp->stream, INT_MAX, false); LoadSubtitles(md); // fill subtitleFrames and subtitleMessages delete fp; // produce .srt file's name and open it for writing std::string outname; size_t dot = infname.find_last_of ("."); if (dot == std::string::npos) outname = infname + ".srt"; else outname = infname.substr(0,dot) + ".srt"; FILE *srtfile; srtfile = fopen(outname.c_str(), "w"); if (srtfile != NULL) { extern std::vector<int> subtitleFrames; extern std::vector<std::string> subtitleMessages; float fps = (md.palFlag == 0 ? 60.0988 : 50.0069); // NTSC vs PAL float subduration = 3; // seconds for the subtitles to be displayed for (int i = 0; i < subtitleFrames.size(); i++) { fprintf(srtfile, "%i\n", i+1); // starts with 1, not 0 double seconds, ms, endseconds, endms; seconds = subtitleFrames[i]/fps; if (i+1 < subtitleFrames.size()) // there's another subtitle coming after this one { if (subtitleFrames[i+1]-subtitleFrames[i] < subduration*fps) // avoid two subtitles at the same time { endseconds = (subtitleFrames[i+1]-1)/fps; // frame x: subtitle1; frame x+1 subtitle2 } else { endseconds = seconds+subduration; } } else { endseconds = seconds+subduration; } ms = modf(seconds, &seconds); endms = modf(endseconds, &endseconds); // this is just beyond ugly, don't show it to your kids fprintf(srtfile, "%02.0f:%02d:%02d,%03d --> %02.0f:%02d:%02d,%03d\n", // hh:mm:ss,ms --> hh:mm:ss,ms floor(seconds/3600), (int)floor(seconds/60 ) % 60, (int)floor(seconds) % 60, (int)(ms*1000), floor(endseconds/3600), (int)floor(endseconds/60) % 60, (int)floor(endseconds) % 60, (int)(endms*1000)); fprintf(srtfile, "%s\n\n", subtitleMessages[i].c_str()); // new line for every subtitle } fclose(srtfile); printf("%d subtitles have been ripped.\n", (int)subtitleFrames.size()); } else { FCEUD_Message("Couldn't create output srt file...\n"); } DriverKill(); SDL_Quit(); return 0; } // if we're not compiling w/ the gui, exit if a rom isn't specified #ifndef _GTK if(romIndex <= 0) { ShowUsage(argv[0]); FCEUD_Message("\nError parsing command line arguments\n"); SDL_Quit(); return -1; } #endif // update the emu core UpdateEMUCore(g_config); #ifdef CREATE_AVI g_config->getOption("SDL.VideoLog", &s); g_config->setOption("SDL.VideoLog", ""); if(!s.empty()) { NESVideoSetVideoCmd(s.c_str()); LoggingEnabled = 1; g_config->getOption("SDL.MuteCapture", &mutecapture); } else { mutecapture = 0; } #endif { int id; g_config->getOption("SDL.InputDisplay", &id); extern int input_display; input_display = id; // not exactly an id as an true/false switch; still better than creating another int for that g_config->getOption("SDL.SubtitleDisplay", &id); extern int movieSubtitles; movieSubtitles = id; } // load the hotkeys from the config life setHotKeys(); #ifdef _GTK if(noGui == 0) { gtk_init(&argc, &argv); InitGTKSubsystem(argc, argv); while(gtk_events_pending()) gtk_main_iteration_do(FALSE); } #endif if(romIndex >= 0) { // load the specified game error = LoadGame(argv[romIndex]); if(error != 1) { DriverKill(); SDL_Quit(); return -1; } g_config->setOption("SDL.LastOpenFile", argv[romIndex]); g_config->save(); } // movie playback g_config->getOption("SDL.Movie", &s); g_config->setOption("SDL.Movie", ""); if (s != "") { if(s.find(".fm2") != std::string::npos || s.find(".fm3") != std::string::npos) { static int pauseframe; g_config->getOption("SDL.PauseFrame", &pauseframe); g_config->setOption("SDL.PauseFrame", 0); FCEUI_printf("Playing back movie located at %s\n", s.c_str()); FCEUI_LoadMovie(s.c_str(), false, pauseframe ? pauseframe : false); } else { FCEUI_printf("Sorry, I don't know how to play back %s\n", s.c_str()); } } int periodic_saves; int save_state; g_config->getOption("SDL.PeriodicSaves", &periodic_saves); g_config->getOption("SDL.AutoSaveState", &save_state); if(periodic_saves && save_state < 10 && save_state >= 0){ FCEUI_SelectState(save_state, 0); } else { periodic_saves = 0; } #ifdef _S9XLUA_H // load lua script if option passed g_config->getOption("SDL.LuaScript", &s); g_config->setOption("SDL.LuaScript", ""); if (s != "") { FCEU_LoadLuaCode(s.c_str()); } #endif { int id; g_config->getOption("SDL.NewPPU", &id); if (id) newppu = 1; } g_config->getOption("SDL.Frameskip", &frameskip); // loop playing the game #ifdef _GTK if(noGui == 0) { while(1) { if(GameInfo) DoFun(frameskip, periodic_saves); else SDL_Delay(1); while(gtk_events_pending()) gtk_main_iteration_do(FALSE); } } else { while(GameInfo) DoFun(frameskip, periodic_saves); } #else while(GameInfo) { DoFun(frameskip, periodic_saves); } #endif CloseGame(); // exit the infrastructure FCEUI_Kill(); SDL_Quit(); return 0; }