FCEUGI *FCEUI_LoadGame(const char *name) { FCEUFILE *fp; ResetGameLoaded(); FCEUGameInfo = malloc(sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI)); FCEUGameInfo->soundchan = 0; FCEUGameInfo->soundrate = 0; FCEUGameInfo->name=0; FCEUGameInfo->type=GIT_CART; FCEUGameInfo->vidsys=GIV_USER; FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1; FCEUGameInfo->inputfc=-1; FCEUGameInfo->cspecial=0; GetFileBase(name); fp=FCEU_fopen(name,"rb",0); if(!fp) return 0; /*Error opening ROM*/ if(iNESLoad(name,fp)) goto endlseq; if(UNIFLoad(name,fp)) goto endlseq; if(FDSLoad(name,fp)) goto endlseq; FCEU_fclose(fp); /*An error occcurred while loading the file*/ return 0; endlseq: FCEU_fclose(fp); FCEU_ResetVidSys(); if(FSettings.GameGenie) OpenGenie(); PowerNES(); FCEU_LoadGamePalette(); /*FCEU_LoadGameCheats(0);*/ FCEU_ResetPalette(); return(FCEUGameInfo); }
void UpdateReplayCommentsSubs(const char * fname) { MOVIE_INFO info; FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0); fp->stream = fp->stream->memwrap(); bool scanok = FCEUI_MovieGetInfo(fp, info, true); delete fp; if(!scanok) return; currComments = info.comments; currSubtitles = info.subtitles; }
FCEUGI *FCEUI_LoadGame(const char *name) { FCEUFILE *fp; char *ipsfn; ResetGameLoaded(); FCEUGameInfo = malloc(sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI)); FCEUGameInfo->soundchan = 0; FCEUGameInfo->soundrate = 0; FCEUGameInfo->name=0; FCEUGameInfo->type=GIT_CART; FCEUGameInfo->vidsys=GIV_USER; FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1; FCEUGameInfo->inputfc=-1; FCEUGameInfo->cspecial=0; FCEU_printf("Loading %s...\n\n",name); GetFileBase(name); ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0); fp=FCEU_fopen(name,ipsfn,"rb",0); free(ipsfn); if(!fp) { FCEU_PrintError("Error opening \"%s\"!",name); return 0; } if(iNESLoad(name,fp)) goto endlseq; if(NSFLoad(fp)) goto endlseq; if(UNIFLoad(name,fp)) goto endlseq; if(FDSLoad(name,fp)) goto endlseq; FCEU_PrintError("An error occurred while loading the file."); FCEU_fclose(fp); return 0; endlseq: FCEU_fclose(fp); FCEU_ResetVidSys(); if(FCEUGameInfo->type!=GIT_NSF) if(FSettings.GameGenie) OpenGenie(); PowerNES(); FCEUSS_CheckStates(); FCEUMOV_CheckMovies(); if(FCEUGameInfo->type!=GIT_NSF) { FCEU_LoadGamePalette(); FCEU_LoadGameCheats(0); } FCEU_ResetPalette(); FCEU_ResetMessages(); // Save state, status messages, etc. return(FCEUGameInfo); }
/** * 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; }
BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayReadOnlySetting?BST_CHECKED:BST_UNCHECKED, 0); SendDlgItemMessage(hwndDlg, IDC_CHECK_STOPMOVIE,BM_SETCHECK, BST_UNCHECKED, 0); #define NUM_OF_MOVIEGLOB_PATHS 1 char* findGlob[NUM_OF_MOVIEGLOB_PATHS] = {strdup(FCEU_MakeFName(FCEUMKF_MOVIEGLOB, 0, 0).c_str())}; int items=0; for(int j = 0;j < NUM_OF_MOVIEGLOB_PATHS; j++) { char* temp=0; do { temp=strchr(findGlob[j],'/'); if(temp) *temp = '\\'; } while(temp); // disabled because... apparently something is case sensitive?? // for(i=1;i<strlen(findGlob[j]);i++) // findGlob[j][i] = tolower(findGlob[j][i]); } for(int j = 0;j < NUM_OF_MOVIEGLOB_PATHS; j++) { // if the two directories are the same, only look through one of them to avoid adding everything twice if(j==1 && !strnicmp(findGlob[0],findGlob[1],MAX(strlen(findGlob[0]),strlen(findGlob[1]))-6)) continue; char globBase[512]; strcpy(globBase,findGlob[j]); globBase[strlen(globBase)-5]='\0'; //char szFindPath[512]; //mbg merge 7/17/06 removed WIN32_FIND_DATA wfd; HANDLE hFind; memset(&wfd, 0, sizeof(wfd)); hFind = FindFirstFile(findGlob[j], &wfd); if(hFind != INVALID_HANDLE_VALUE) { do { if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //TODO - a big copy/pasted block below. factor out extension extractor or use another one // filter out everything that's not an extension we like (*.fm2 and *.fm3) // (because FindFirstFile is too dumb to do that) { std::string ext = getExtension(wfd.cFileName); if(ext != "fm2") if(ext != "fm3") if(ext != "zip") if(ext != "rar") if(ext != "7z") continue; } char filename [512]; sprintf(filename, "%s%s", globBase, wfd.cFileName); //replay system requires this to stay put. SetCurrentDirectory(BaseDirectory.c_str()); ArchiveScanRecord asr = FCEUD_ScanArchive(filename); if(!asr.isArchive()) { FCEUFILE* fp = FCEU_fopen(filename,0,"rb",0); if(fp) { //fp->stream = fp->stream->memwrap(); - no need to load whole movie to memory! We only need to read movie header! HandleScan(hwndDlg, fp, items); delete fp; } } else { asr.files.FilterByExtension(fm2ext); for(uint32 i=0;i<asr.files.size();i++) { FCEUFILE* fp = FCEU_fopen(filename,0,"rb",0,asr.files[i].index); if(fp) { HandleScan(hwndDlg,fp, items); delete fp; } } } } while(FindNextFile(hFind, &wfd)); FindClose(hFind); } } for(int j = 0; j < NUM_OF_MOVIEGLOB_PATHS; j++) free(findGlob[j]); if(items>0) SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_SETCURSEL, items-1, 0); SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_INSERTSTRING, items++, (LPARAM)"Browse..."); UpdateReplayDialog(hwndDlg); } SetFocus(GetDlgItem(hwndDlg, IDC_COMBO_FILENAME)); return FALSE; case WM_COMMAND: if (HIWORD(wParam) == EN_CHANGE) { if (LOWORD(wParam) == IDC_EDIT_STOPFRAME) // Check if Stop movie at value has changed { if (stopframeWasEditedByUser) { HWND hwnd1 = GetDlgItem(hwndDlg,IDC_CHECK_STOPMOVIE); Button_SetCheck(hwnd1,BST_CHECKED); stopframeWasEditedByUser = true; } else stopframeWasEditedByUser = true; } } if (HIWORD(wParam) == CBN_SELCHANGE) { UpdateReplayDialog(hwndDlg); } else if(HIWORD(wParam) == CBN_CLOSEUP) { LONG lCount = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCOUNT, 0, 0); LONG lIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCURSEL, 0, 0); if (lIndex != CB_ERR && lIndex == lCount-1) SendMessage(hwndDlg, WM_COMMAND, (WPARAM)IDOK, 0); // send an OK notification to open the file browser } else { int wID = LOWORD(wParam); switch(wID) { case IDC_BUTTON_METADATA: DialogBoxParam(fceu_hInstance, "IDD_REPLAY_METADATA", hwndDlg, ReplayMetadataDialogProc, (LPARAM)0); break; case IDOK: { LONG lCount = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCOUNT, 0, 0); LONG lIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_GETCURSEL, 0, 0); if(lIndex != CB_ERR) { if(lIndex == lCount-1) { // pop open a file browser... char *pn=strdup(FCEU_GetPath(FCEUMKF_MOVIE).c_str()); char szFile[MAX_PATH]={0}; OPENFILENAME ofn; //int nRet; //mbg merge 7/17/06 removed memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "FCEUX Movie Files (*.fm2), TAS Editor Projects (*.fm3)\0*.fm2;*.fm3\0FCEUX Movie Files (*.fm2)\0*.fm2\0Archive Files (*.zip,*.rar,*.7z)\0*.zip;*.rar;*.7z\0All Files (*.*)\0*.*\0\0"; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrInitialDir = pn; ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY; ofn.lpstrDefExt = "fm2"; ofn.lpstrTitle = "Play Movie from File"; if(GetOpenFileName(&ofn)) { char relative[MAX_PATH*2]; AbsoluteToRelative(relative, szFile, BaseDirectory.c_str()); //replay system requires this to stay put. SetCurrentDirectory(BaseDirectory.c_str()); ArchiveScanRecord asr = FCEUD_ScanArchive(relative); FCEUFILE* fp = FCEU_fopen(relative,0,"rb",0,-1,fm2ext); if(!fp) goto abort; strcpy(relative,fp->fullFilename.c_str()); delete fp; LONG lOtherIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)relative); if(lOtherIndex != CB_ERR) { // select already existing string SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_SETCURSEL, lOtherIndex, 0); UpdateReplayDialog(hwndDlg); } else { SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_INSERTSTRING, lIndex, (LPARAM)relative); SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_SETCURSEL, lIndex, 0); //UpdateReplayDialog(hwndDlg); - this call would be redundant, because the update is always triggered by CBN_SELCHANGE message anyway } // restore focus to the dialog SetFocus(GetDlgItem(hwndDlg, IDC_COMBO_FILENAME)); } abort: free(pn); } else { // user had made their choice // TODO: warn the user when they open a movie made with a different ROM char* fn=GetReplayPath(hwndDlg); //char TempArray[16]; //mbg merge 7/17/06 removed replayReadOnlySetting = (SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_GETCHECK, 0, 0) == BST_CHECKED); char offset1Str[32]={0}; SendDlgItemMessage(hwndDlg, IDC_EDIT_STOPFRAME, WM_GETTEXT, (WPARAM)32, (LPARAM)offset1Str); replayStopFrameSetting = (SendDlgItemMessage(hwndDlg, IDC_CHECK_STOPMOVIE, BM_GETCHECK,0,0) == BST_CHECKED)? strtol(offset1Str,0,10):0; EndDialog(hwndDlg, (INT_PTR)fn); } } } return TRUE; case IDCANCEL: EndDialog(hwndDlg, 0); return TRUE; } } return FALSE; case WM_CTLCOLORSTATIC: if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LABEL_CURRCHECKSUM)) { // draw the md5 sum in red if it's different from the md5 of the rom used in the replay HDC hdcStatic = (HDC)wParam; char szMd5Text[35]; GetDlgItemText(hwndDlg, IDC_LABEL_ROMCHECKSUM, szMd5Text, 35); if (!strlen(szMd5Text) || !strcmp(szMd5Text, "unknown") || !strcmp(szMd5Text, "00000000000000000000000000000000") || !strcmp(szMd5Text, md5_asciistr(GameInfo->MD5))) SetTextColor(hdcStatic, RGB(0,0,0)); // use black color for a match (or no comparison) else SetTextColor(hdcStatic, RGB(255,0,0)); // use red for a mismatch SetBkMode((HDC)wParam,TRANSPARENT); return (BOOL)GetSysColorBrush(COLOR_BTNFACE); } else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LABEL_NEWPPUUSED)) { HDC hdcStatic = (HDC)wParam; char szMd5Text[35]; GetDlgItemText(hwndDlg, IDC_LABEL_NEWPPUUSED, szMd5Text, 35); bool want_newppu = (strcmp(szMd5Text, "Off") != 0); extern int newppu; if ((want_newppu && newppu) || (!want_newppu && !newppu)) SetTextColor(hdcStatic, RGB(0,0,0)); // use black color for a match else SetTextColor(hdcStatic, RGB(255,0,0)); // use red for a mismatch SetBkMode((HDC)wParam,TRANSPARENT); return (BOOL)GetSysColorBrush(COLOR_BTNFACE); } else { return FALSE; } } return FALSE; };
void UpdateReplayDialog(HWND hwndDlg) { int doClear=1; char *fn=GetReplayPath(hwndDlg); // remember the previous setting for the read-only checkbox replayReadOnlySetting = (SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_GETCHECK, 0, 0) == BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_METADATA),FALSE); if(fn) { MOVIE_INFO info; FCEUFILE* fp = FCEU_fopen(fn,0,"rb",0); fp->stream = fp->stream->memwrap(); bool isarchive = FCEU_isFileInArchive(fn); bool ismovie = FCEUI_MovieGetInfo(fp, info, false); delete fp; if(ismovie) { char tmp[256]; double div; sprintf(tmp, "%u", (unsigned)info.num_frames); SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES), tmp); // frames SetDlgItemText(hwndDlg,IDC_EDIT_STOPFRAME,tmp); stopframeWasEditedByUser = false; EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),TRUE); div = (FCEUI_GetCurrentVidSystem(0,0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding int num_seconds = (int)tempCount; int fraction = (int)((tempCount - num_seconds) * 100); int seconds = num_seconds % 60; int minutes = (num_seconds / 60) % 60; int hours = (num_seconds / 60 / 60) % 60; sprintf(tmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction); SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH), tmp); // length sprintf(tmp, "%u", (unsigned)info.rerecord_count); SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT), tmp); // rerecord SendDlgItemMessage(hwndDlg,IDC_CHECK_READONLY,BM_SETCHECK,(replayReadOnlySetting ? BST_CHECKED : BST_UNCHECKED), 0); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate")); if(isarchive) { EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),FALSE); Button_SetCheck(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),BST_CHECKED); } else EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),TRUE); //----------- //mbg 5/26/08 - getting rid of old movie formats //if(info.movie_version > 1) //{ char emuStr[128]; SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),info.name_of_rom_used.c_str()); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),md5_asciistr(info.md5_of_rom_used)); char boolstring[4] = "On "; if (!info.pal) strcpy(boolstring, "Off"); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_PALUSED),boolstring); if (info.ppuflag) strcpy(boolstring, "On "); else strcpy(boolstring, "Off"); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_NEWPPUUSED),boolstring); if(info.emu_version_used < 20000 ) sprintf(emuStr, "FCEU %d.%02d.%02d%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : ""); else sprintf(emuStr, "FCEUX %d.%02d.%02d", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100); //else //{ // if(info.emu_version_used == 1) // strcpy(emuStr, "Famtasia"); // else if(info.emu_version_used == 2) // strcpy(emuStr, "Nintendulator"); // else if(info.emu_version_used == 3) // strcpy(emuStr, "VirtuaNES"); // else // { // strcpy(emuStr, "(unknown)"); // char* dot = strrchr(fn,'.'); // if(dot) // { // if(!stricmp(dot,".fmv")) // strcpy(emuStr, "Famtasia? (unknown version)"); // else if(!stricmp(dot,".nmv")) // strcpy(emuStr, "Nintendulator? (unknown version)"); // else if(!stricmp(dot,".vmv")) // strcpy(emuStr, "VirtuaNES? (unknown version)"); // else if(!stricmp(dot,".fcm")) // strcpy(emuStr, "FCEU? (unknown version)"); // } // } //} SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),emuStr); //} //else //{ // SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"unknown"); // SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"unknown"); // SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),"FCEU 0.98.10 (blip)"); //} //-------------------- SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_CURRCHECKSUM),md5_asciistr(GameInfo->MD5)); // enable OK and metadata EnableWindow(GetDlgItem(hwndDlg,IDOK),TRUE); EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_METADATA),TRUE); currComments = info.comments; currSubtitles = info.subtitles; doClear = 0; } free(fn); } else { EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_OFFSET),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_FROM),FALSE); } if(doClear) { SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_CURRCHECKSUM),md5_asciistr(GameInfo->MD5)); SetDlgItemText(hwndDlg,IDC_EDIT_STOPFRAME,""); stopframeWasEditedByUser=false; EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDOK),FALSE); } }