diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index ab39af05..f0a2f63a 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -88,6 +88,7 @@ extern int TASEdit_greenzone_capacity; extern int TasEdit_undo_levels; extern int TASEdit_autosave_period; extern bool TASEdit_jump_to_undo; +extern int TASEdit_last_export_type; //window positions and sizes: extern int ChtPosX,ChtPosY; @@ -325,6 +326,7 @@ static CFGSTRUCT fceuconfig[] = { AC(TasEdit_undo_levels), AC(TASEdit_autosave_period), AC(TASEdit_jump_to_undo), + AC(TASEdit_last_export_type), AC(lagCounterDisplay), AC(oldInputDisplay), AC(movieSubtitles), diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 386c4ada..07db0794 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -225,7 +225,7 @@ BEGIN MENUITEM "Save &Compact", ID_FILE_SAVECOMPACT, INACTIVE MENUITEM "&Recent", ID_TASEDIT_FILE_RECENT MENUITEM SEPARATOR - MENUITEM "&Import FM2", ID_FILE_IMPORTFM2, INACTIVE + MENUITEM "&Import", ID_FILE_IMPORTFM2 MENUITEM "&Export to FM2", ID_FILE_EXPORTFM2 MENUITEM SEPARATOR MENUITEM "&Close\tAlt+F4", ID_TASEDIT_FILE_CLOSE @@ -1414,6 +1414,18 @@ BEGIN LTEXT "Clipboard: 0 rows, 16 columns",IDC_TEXT_CLIPBOARD,316,134,114,10 END +IDD_TASEDIT_EXPORT DIALOGEX 0, 0, 122, 73 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Export to FM2" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Export",IDOK,7,52,50,14 + PUSHBUTTON "Cancel",IDCANCEL,65,52,50,14 + CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON,36,8,49,10 + CONTROL " 2 players",IDC_RADIO_2PLAYERS,"Button",BS_AUTORADIOBUTTON,36,21,49,10 + CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,37,35,47,10 +END + ASSEMBLER DIALOGEX 0, 0, 202, 135 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Inline Assembler" @@ -1854,6 +1866,10 @@ BEGIN BOTTOMMARGIN, 121 END + "GGCONV", DIALOG + BEGIN + END + "MONITOR", DIALOG BEGIN LEFTMARGIN, 7 @@ -1905,6 +1921,10 @@ BEGIN BOTTOMMARGIN, 213 END + "PPUVIEW", DIALOG + BEGIN + END + "ARCHIVECHOOSERDIALOG", DIALOG BEGIN LEFTMARGIN, 7 @@ -1936,6 +1956,10 @@ BEGIN TOPMARGIN, 8 BOTTOMMARGIN, 268 END + + IDD_PROMPT, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED @@ -1943,6 +1967,41 @@ END ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// Русский (Россия) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_TASEDIT_EXPORT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 115 + TOPMARGIN, 7 + BOTTOMMARGIN, 66 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Русский (Россия) resources +///////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////// // Английский (США) resources diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 09aad912..02b60d9f 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -180,6 +180,8 @@ #define IDB_BITMAP18 181 #define IDB_BITMAP19 182 #define IDB_BRANCH_SPRITESHEET 184 +#define IDD_DIALOG4 185 +#define IDD_TASEDIT_EXPORT 185 #define MENU_RESET 200 #define BUTTON_ROMS 200 #define TXT_PAD1 200 @@ -535,6 +537,9 @@ #define CHECK_TURBO_SEEK 1266 #define IDC_TEXT_SELECTION 1267 #define IDC_TEXT_CLIPBOARD 1268 +#define IDC_RADIO_1PLAYER 1269 +#define IDC_RADIO_2PLAYERS 1270 +#define IDC_RADIO_FOURSCORE 1271 #define MENU_NETWORK 40040 #define MENU_PALETTE 40041 #define MENU_SOUND 40042 @@ -924,9 +929,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 185 +#define _APS_NEXT_RESOURCE_VALUE 186 #define _APS_NEXT_COMMAND_VALUE 40501 -#define _APS_NEXT_CONTROL_VALUE 1269 +#define _APS_NEXT_CONTROL_VALUE 1270 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 6748b4bf..a0c0fa57 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -61,6 +61,7 @@ int TASEdit_autosave_period = AUTOSAVE_PERIOD_DEFAULT; extern bool muteTurbo; bool TASEdit_enable_hot_changes = true; bool TASEdit_jump_to_undo = true; +int TASEdit_last_export_type = EXPORT_TYPE_1P; // resources string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page @@ -766,7 +767,7 @@ void OpenProject() { if (!AskSaveProject()) return; - const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0"; + const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0\0"; OPENFILENAME ofn; memset(&ofn,0,sizeof(ofn)); @@ -780,10 +781,10 @@ void OpenProject() strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames ofn.lpstrFile=nameo; - ofn.nMaxFile=256; + ofn.nMaxFile = 2048; ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - ofn.lpstrInitialDir=initdir.c_str(); + string initdir = FCEU_GetPath(FCEUMKF_MOVIE); + ofn.lpstrInitialDir = initdir.c_str(); if(GetOpenFileName(&ofn)) //If it is a valid filename { @@ -815,24 +816,23 @@ void OpenProject() // Saves current project bool SaveProjectAs() { - const char TPfilter[]="TASEdit Project (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0"; //Filetype filter - + const char filter[]="TASEdit Project (*.tas)\0*.tas\0All Files (*.*)\0*.*\0\0"; OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndTasEdit; - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save TASEdit Project As..."; - ofn.lpstrFilter=TPfilter; + ofn.hInstance = fceu_hInstance; + ofn.lpstrTitle = "Save TASEdit Project As..."; + ofn.lpstrFilter = filter; char nameo[2048]; strcpy(nameo, mass_replace(GetRomName(),"|",".").c_str()); //convert | to . for archive filenames ofn.lpstrFile = nameo; - ofn.lpstrDefExt="tas"; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory - ofn.lpstrInitialDir=initdir.c_str(); + ofn.lpstrDefExt = "tas"; + ofn.nMaxFile = 2048; + ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; + string initdir = FCEU_GetPath(FCEUMKF_MOVIE); //Initial directory + ofn.lpstrInitialDir = initdir.c_str(); if(GetSaveFileName(&ofn)) //If it is a valid filename { @@ -877,36 +877,142 @@ bool AskSaveProject() return true; } +extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader); void Import() { + const char filter[] = "FCEUX Movie Files, TASEdit Projects\0*.fm2;*.tas\0All Files (*.*)\0*.*\0\0"; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwndTasEdit; + ofn.hInstance = fceu_hInstance; + ofn.lpstrTitle = "Import"; + ofn.lpstrFilter = filter; + char nameo[2048] = {0}; + ofn.lpstrFile = nameo; + ofn.nMaxFile = 2048; + ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; + string initdir = FCEU_GetPath(FCEUMKF_MOVIE); + ofn.lpstrInitialDir = initdir.c_str(); - + if(GetOpenFileName(&ofn)) + { + EMUFILE_FILE ifs(nameo, "rb"); + // Load input to temporary moviedata + MovieData md; + if (LoadFM2(md, &ifs, ifs.size(), false)) + { + // loaded successfully, now register changes + char drv[512], dir[512], name[1024], ext[512]; + splitpath(nameo, drv, dir, name, ext); + strcat(name, ext); + history.RegisterImport(md, name); + } else + { + FCEUD_PrintError("Error loading movie data!"); + } + } } + +BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + SetWindowPos(hwndDlg, 0, TasEdit_wndx + 100, TasEdit_wndy + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); + switch (TASEdit_last_export_type) + { + case EXPORT_TYPE_1P: + { + Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_1PLAYER), BST_CHECKED); + break; + } + case EXPORT_TYPE_2P: + { + Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_2PLAYERS), BST_CHECKED); + break; + } + case EXPORT_TYPE_FOURSCORE: + { + Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_FOURSCORE), BST_CHECKED); + break; + } + } + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_RADIO_1PLAYER: + TASEdit_last_export_type = EXPORT_TYPE_1P; + break; + case IDC_RADIO_2PLAYERS: + TASEdit_last_export_type = EXPORT_TYPE_2P; + break; + case IDC_RADIO_FOURSCORE: + TASEdit_last_export_type = EXPORT_TYPE_FOURSCORE; + break; + case IDOK: + EndDialog(hwndDlg, 1); + return TRUE; + case IDCANCEL: + EndDialog(hwndDlg, 0); + return TRUE; + } + } + return FALSE; +} + void Export() { - //TODO: redesign this - //Dump project header info into file, then comments & subtitles, then input log - //This will require special prunctions, ::DumpHeader ::DumpComments etc - const char filter[]="FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0"; - char fname[2048] = {0}; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner = hwndTasEdit; - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Export TAS as..."; - ofn.lpstrFilter=filter; - ofn.lpstrFile=fname; - ofn.lpstrDefExt="fm2"; - ofn.nMaxFile=256; - std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - ofn.lpstrInitialDir=initdir.c_str(); - if(GetSaveFileName(&ofn)) + if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDIT_EXPORT), hwndTasEdit, ExportProc) > 0) { - EMUFILE* osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); - currMovieData.dump(osRecordingMovie,false); - delete osRecordingMovie; - osRecordingMovie = 0; + const char filter[] = "FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0"; + char fname[2048] = {0}; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwndTasEdit; + ofn.hInstance = fceu_hInstance; + ofn.lpstrTitle = "Export to FM2"; + ofn.lpstrFilter = filter; + ofn.lpstrFile = fname; + ofn.lpstrDefExt = "fm2"; + ofn.nMaxFile = 2048; + ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; + std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE); + ofn.lpstrInitialDir = initdir.c_str(); + if(GetSaveFileName(&ofn)) + { + EMUFILE* osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); + // create copy of current movie data + MovieData temp_md = currMovieData; + // modify the copy according to selected type of export + switch (TASEdit_last_export_type) + { + case EXPORT_TYPE_1P: + { + temp_md.fourscore = false; + temp_md.ports[0] = SI_GAMEPAD; + temp_md.ports[1] = SI_NONE; + break; + } + case EXPORT_TYPE_2P: + { + temp_md.fourscore = false; + temp_md.ports[0] = SI_GAMEPAD; + temp_md.ports[1] = SI_GAMEPAD; + break; + } + case EXPORT_TYPE_FOURSCORE: + { + temp_md.fourscore = true; + break; + } + } + temp_md.dump(osRecordingMovie, false); + delete osRecordingMovie; + osRecordingMovie = 0; + } } } @@ -926,10 +1032,10 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (!IsIconic(hwndDlg)) { RECT wrect; - GetWindowRect(hwndDlg,&wrect); + GetWindowRect(hwndDlg, &wrect); TasEdit_wndx = wrect.left; TasEdit_wndy = wrect.top; - WindowBoundsCheckNoResize(TasEdit_wndx,TasEdit_wndy,wrect.right); + WindowBoundsCheckNoResize(TasEdit_wndx, TasEdit_wndy, wrect.right); // also move screenshot display if it's open screenshot_display.ParentWindowMoved(); } @@ -1422,8 +1528,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar void EnterTasEdit() { if(!FCEU_IsValidUI(FCEUI_TASEDIT)) return; - // window stuff - if(!hwndTasEdit) hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT",hAppWnd,WndprocTasEdit); + if(!hwndTasEdit) hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT", hAppWnd, WndprocTasEdit); if(hwndTasEdit) { // save "eoptions" diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index 10734426..5bf411f4 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -10,6 +10,10 @@ #define AUTOSAVE_PERIOD_MAX 60 // 1 hour #define AUTOSAVE_PERIOD_DEFAULT 10 // in minutes +#define EXPORT_TYPE_1P 0 +#define EXPORT_TYPE_2P 1 +#define EXPORT_TYPE_FOURSCORE 2 + enum ECONTEXTMENU { CONTEXTMENU_STRAY = 0, diff --git a/src/drivers/win/taseditlib/bookmark.h b/src/drivers/win/taseditlib/bookmark.h index 126122da..fc4fa7e6 100644 --- a/src/drivers/win/taseditlib/bookmark.h +++ b/src/drivers/win/taseditlib/bookmark.h @@ -9,11 +9,6 @@ #define SCREENSHOT_HEIGHT 240 #define SCREENSHOT_SIZE SCREENSHOT_WIDTH * SCREENSHOT_HEIGHT -#define PARENT_RELATION_SAME 0 // Yellow-blue: this child has absolutely the same input as its parent, although maybe different jump_frame. Input sizes must be equal too. -#define PARENT_RELATION_DIRECT 1 // Green-blue: the child has the same input at least until parent's jump_frame. Child's jump_frame can be higher or lower than parent's jump_frame (doesn't matter), but if child's input is shorter than parent's input, it is considered different if parent has non-null input after child's input ends. -#define PARENT_RELATION_ORPHAN 2 // Red-blue: child has different input before parent's jump_frame, so their inheritance may be illogical. -#define PARENT_RELATION_ATTACHED 3 // Blue: normal parent was lost due to different input before its jump_frame, so new parent was found. Essentially this is the same as PARENT_RELATION_DIRECT, but this also adds small notification that parent was inherited by autofinding system rather that by normal chain of user-made events (this notification may be useful for something). - class BOOKMARK { public: @@ -34,7 +29,6 @@ public: std::vector savestate; std::vector saved_screenshot; int parent_branch; - int parent_relation; private: diff --git a/src/drivers/win/taseditlib/bookmarks.cpp b/src/drivers/win/taseditlib/bookmarks.cpp index 6ea5a6f9..53917469 100644 --- a/src/drivers/win/taseditlib/bookmarks.cpp +++ b/src/drivers/win/taseditlib/bookmarks.cpp @@ -434,7 +434,6 @@ void BOOKMARKS::unleash(int slot) if (first_change >= 0) { // restore entire movie - currMovieData.records.resize(bookmarks_array[slot].snapshot.size); bookmarks_array[slot].snapshot.toMovie(currMovieData, first_change); tasedit_list.update(); history.RegisterBranching(MODTYPE_BRANCH_0 + slot, first_change, slot); diff --git a/src/drivers/win/taseditlib/inputhistory.cpp b/src/drivers/win/taseditlib/inputhistory.cpp index 951fdb32..80c7f4dd 100644 --- a/src/drivers/win/taseditlib/inputhistory.cpp +++ b/src/drivers/win/taseditlib/inputhistory.cpp @@ -70,7 +70,7 @@ void INPUT_HISTORY::init(int new_size) hwndHistoryList_oldWndProc = (WNDPROC)SetWindowLong(hwndHistoryList, GWL_WNDPROC, (LONG)HistoryListWndProc); LVCOLUMN lvc; lvc.mask = LVCF_WIDTH | LVCF_FMT; - lvc.cx = 200; + lvc.cx = 500; lvc.fmt = LVCFMT_LEFT; ListView_InsertColumn(hwndHistoryList, 0, &lvc); // init vars @@ -158,7 +158,6 @@ int INPUT_HISTORY::jump(int new_pos) int first_change = input_snapshots[real_pos].findFirstChange(currMovieData); if (first_change >= 0) { - currMovieData.records.resize(input_snapshots[real_pos].size); input_snapshots[real_pos].toMovie(currMovieData, first_change); bookmarks.ChangesMadeSinceBranch(); // list will be redrawn by greenzone invalidation @@ -259,7 +258,7 @@ int INPUT_HISTORY::RegisterChanges(int mod_type, int start, int end) return -1; } else { - // all other types of modification: + // other types of modification: // check if there are input differences from latest snapshot int real_pos = (history_start_pos + history_cursor_pos) % history_size; int first_changes = inp.findFirstChange(input_snapshots[real_pos], start, end); @@ -276,7 +275,6 @@ int INPUT_HISTORY::RegisterChanges(int mod_type, int start, int end) case MODTYPE_TRUNCATE: case MODTYPE_CLEAR: case MODTYPE_CUT: - case MODTYPE_IMPORT: { inp.jump_frame = first_changes; break; @@ -332,10 +330,6 @@ int INPUT_HISTORY::RegisterChanges(int mod_type, int start, int end) inp.copyHotChanges(&input_snapshots[real_pos]); // do not add new hotchanges and do not fade old hotchanges, because there was nothing added break; - case MODTYPE_IMPORT: - // do not inherit old hotchanges, because imported input (most likely) doesn't have direct connection with recent edits, so old hotchanges are irrelevant and should not be copied - inp.fillHotChanges(input_snapshots[real_pos], first_changes, end); - break; } } AddInputSnapshotToHistory(inp); @@ -445,6 +439,40 @@ void INPUT_HISTORY::RegisterRecording(int frame_of_change) } bookmarks.ChangesMadeSinceBranch(); } +void INPUT_HISTORY::RegisterImport(MovieData& md, char* filename) +{ + // create new input snapshot + INPUT_SNAPSHOT inp; + inp.init(md, TASEdit_enable_hot_changes, (currMovieData.fourscore)?FOURSCORE:NORMAL_2JOYPADS); + // check if there are input differences from latest snapshot + int real_pos = (history_start_pos + history_cursor_pos) % history_size; + int first_changes = inp.findFirstChange(input_snapshots[real_pos]); + if (first_changes >= 0) + { + // differences found + inp.mod_type = MODTYPE_IMPORT; + inp.jump_frame = first_changes; + // fill description: + strcat(inp.description, modCaptions[inp.mod_type]); + // add filename to description + strcat(inp.description, " "); + strncat(inp.description, filename, SNAPSHOT_DESC_MAX_LENGTH - strlen(inp.description) - 1); + if (TASEdit_enable_hot_changes) + { + // do not inherit old hotchanges, because imported input (most likely) doesn't have direct connection with recent edits, so old hotchanges are irrelevant and should not be copied + inp.fillHotChanges(input_snapshots[real_pos], first_changes); + } + AddInputSnapshotToHistory(inp); + inp.toMovie(currMovieData); + tasedit_list.update(); + bookmarks.ChangesMadeSinceBranch(); + project.SetProjectChanged(); + greenzone.InvalidateAndCheck(first_changes); + } else + { + MessageBox(hwndTasEdit, "Imported movie has the same input.\nNo changes were made.", "TAS Editor", MB_OK); + } +} void INPUT_HISTORY::save(EMUFILE *os) { diff --git a/src/drivers/win/taseditlib/inputhistory.h b/src/drivers/win/taseditlib/inputhistory.h index 5b212053..ebba8e5d 100644 --- a/src/drivers/win/taseditlib/inputhistory.h +++ b/src/drivers/win/taseditlib/inputhistory.h @@ -65,6 +65,7 @@ public: int RegisterChanges(int mod_type, int start = 0, int end =-1); void RegisterBranching(int mod_type, int first_change, int slot); void RegisterRecording(int frame_of_change); + void RegisterImport(MovieData& md, char* filename); INPUT_SNAPSHOT& GetCurrentSnapshot(); INPUT_SNAPSHOT& GetNextToCurrentSnapshot(); diff --git a/src/drivers/win/taseditlib/inputsnapshot.cpp b/src/drivers/win/taseditlib/inputsnapshot.cpp index 345bd1c9..449a6096 100644 --- a/src/drivers/win/taseditlib/inputsnapshot.cpp +++ b/src/drivers/win/taseditlib/inputsnapshot.cpp @@ -14,17 +14,20 @@ INPUT_SNAPSHOT::INPUT_SNAPSHOT() { } -void INPUT_SNAPSHOT::init(MovieData& md, bool hotchanges) +void INPUT_SNAPSHOT::init(MovieData& md, bool hotchanges, int force_input_type) { has_hot_changes = hotchanges; - already_compressed = false; + if (force_input_type < 0) + input_type = (md.fourscore)?FOURSCORE:NORMAL_2JOYPADS; + else + input_type = force_input_type; // retrieve input data from movie data size = md.getNumRecords(); - input_type = (md.fourscore)?1:0; joysticks.resize(bytes_per_frame[input_type] * size); // it's much faster to have this format than have [frame][joy] or other structures commands.resize(size); if (has_hot_changes) hot_changes.resize(bytes_per_frame[input_type] * size * HOTCHANGE_BYTES_PER_JOY); + // fill input vector int pos = 0; switch(input_type) @@ -52,9 +55,14 @@ void INPUT_SNAPSHOT::init(MovieData& md, bool hotchanges) break; } } + // make a copy of markers.markers_array markers.MakeCopy(markers_array); + if ((int)markers_array.size() < size) + markers_array.resize(size); + coherent = true; + already_compressed = false; // save time to description time_t raw_time; time(&raw_time); @@ -71,6 +79,7 @@ void INPUT_SNAPSHOT::toMovie(MovieData& md, int start, int end) { if (end < 0) end = size-1; // write input data to movie data + md.records.resize(size); switch(input_type) { case FOURSCORE: diff --git a/src/drivers/win/taseditlib/inputsnapshot.h b/src/drivers/win/taseditlib/inputsnapshot.h index 3fdcdccc..df6768c2 100644 --- a/src/drivers/win/taseditlib/inputsnapshot.h +++ b/src/drivers/win/taseditlib/inputsnapshot.h @@ -1,7 +1,7 @@ //Specification file for Input Snapshot class #define HOTCHANGE_BYTES_PER_JOY 4 -#define SNAPSHOT_DESC_MAX_LENGTH 50 +#define SNAPSHOT_DESC_MAX_LENGTH 100 #define NUM_SUPPORTED_INPUT_TYPES 2 #define NORMAL_2JOYPADS 0 @@ -11,7 +11,7 @@ class INPUT_SNAPSHOT { public: INPUT_SNAPSHOT(); - void init(MovieData& md, bool hotchanges); + void init(MovieData& md, bool hotchanges, int force_input_type = -1); void toMovie(MovieData& md, int start = 0, int end = -1); void toMarkers(); diff --git a/src/drivers/win/taseditlib/markers.cpp b/src/drivers/win/taseditlib/markers.cpp index f43ec35c..6121d7db 100644 --- a/src/drivers/win/taseditlib/markers.cpp +++ b/src/drivers/win/taseditlib/markers.cpp @@ -72,7 +72,6 @@ void MARKERS::MakeCopy(std::vector &destination_array) destination_array = markers_array; // copy notes - } void MARKERS::RestoreFromCopy(std::vector &source_array, int until_frame) { @@ -82,7 +81,7 @@ void MARKERS::RestoreFromCopy(std::vector &source_array, int until_frame) if ((int)markers_array.size() <= until_frame) markers_array.resize(until_frame+1); for (int i = until_frame; i >= 0; i--) markers_array[i] = source_array[i]; - // restore notes + // restore some notes } else { diff --git a/src/drivers/win/taseditlib/screenshot_display.cpp b/src/drivers/win/taseditlib/screenshot_display.cpp index 2480df5d..2fdae366 100644 --- a/src/drivers/win/taseditlib/screenshot_display.cpp +++ b/src/drivers/win/taseditlib/screenshot_display.cpp @@ -62,7 +62,7 @@ void SCREENSHOT_DISPLAY::init() } HDC win_hdc = GetWindowDC(tasedit_list.hwndList); scr_bmp = CreateDIBSection(win_hdc, scr_bmi, DIB_RGB_COLORS, (void**)&scr_ptr, 0, 0); - // calculate coordinates (relative to IDC_BOOKMARKS_BOX top-left corner) + // calculate coordinates (relative to IDC_BOOKMARKS_BOX) RECT temp_rect, parent_rect; GetWindowRect(hwndTasEdit, &parent_rect); GetWindowRect(GetDlgItem(hwndTasEdit, IDC_BOOKMARKS_BOX), &temp_rect); diff --git a/src/drivers/win/taseditlib/taseditproj.cpp b/src/drivers/win/taseditlib/taseditproj.cpp index 08bc52a5..0723370e 100644 --- a/src/drivers/win/taseditlib/taseditproj.cpp +++ b/src/drivers/win/taseditlib/taseditproj.cpp @@ -70,8 +70,6 @@ bool TASEDIT_PROJECT::saveProject() } extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader); - - bool TASEDIT_PROJECT::LoadProject(std::string PFN) { const char* filename = PFN.c_str(); @@ -81,8 +79,14 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN) FCEU_printf("\nLoading TASEdit project %s\n", filename); bool error; - LoadFM2(currMovieData, &ifs, ifs.size(), false); - LoadSubtitles(currMovieData); + if (LoadFM2(currMovieData, &ifs, ifs.size(), false)) + { + LoadSubtitles(currMovieData); + } else + { + FCEU_printf("Error loading movie data\n"); + error = true; + } // try to load markers error = markers.load(&ifs); if (error) diff --git a/src/input.cpp b/src/input.cpp index 7abf6b5b..20d7354b 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -776,7 +776,7 @@ struct EMUCMDTABLE FCEUI_CommandTable[]= { EMUCMD_TOOL_RAMSEARCHGTE, EMUCMDTYPE_TOOL, RamSearchOpGTE, 0, 0, "Ram Search - Greater Than or Equal", 0}, { EMUCMD_TOOL_RAMSEARCHEQ, EMUCMDTYPE_TOOL, RamSearchOpEQ, 0, 0, "Ram Search - Equal", 0}, { EMUCMD_TOOL_RAMSEARCHNE, EMUCMDTYPE_TOOL, RamSearchOpNE, 0, 0, "Ram Search - Not Equal", 0}, - { EMUCMD_TASEDIT_REWIND, EMUCMDTYPE_TOOL, TaseditRewindOn, TaseditRewindOff, 0, "Rewind Frame (TASEditor-only)", EMUCMDFLAG_TASEDIT}, + { EMUCMD_TASEDIT_REWIND, EMUCMDTYPE_MISC, TaseditRewindOn, TaseditRewindOff, 0, "Rewind Frame (TASEditor-only)", EMUCMDFLAG_TASEDIT}, { EMUCMD_RERECORD_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_MovieToggleRerecordDisplay, 0, 0, "Toggle Rerecord Display", EMUCMDFLAG_TASEDIT }, }; diff --git a/src/movie.cpp b/src/movie.cpp index ed9c9aa2..891ab659 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -349,11 +349,6 @@ void MovieRecord::dumpBinary(MovieData* md, EMUFILE* os, int index) void MovieRecord::dump(MovieData* md, EMUFILE* os, int index) { - if (false/*currMovieData.binaryFlag*/) - { - dumpBinary(md, os, index); - return; - } //dump the misc commands //*os << '|' << setw(1) << (int)commands; os->fputc('|'); @@ -491,7 +486,7 @@ int MovieData::dump(EMUFILE *os, bool binary) if(binary) os->fprintf("binary 1\n" ); - if(savestate.size() != 0) + if(savestate.size()) os->fprintf("savestate %s\n" , BytesToString(&savestate[0],savestate.size()).c_str() ); if(FCEUMOV_Mode(MOVIEMODE_TASEDIT)) @@ -502,11 +497,12 @@ int MovieData::dump(EMUFILE *os, bool binary) //put one | to start the binary dump os->fputc('|'); for(int i=0;i<(int)records.size();i++) - records[i].dumpBinary(this,os,i); - } - else + records[i].dumpBinary(this, os, i); + } else + { for(int i=0;i<(int)records.size();i++) - records[i].dump(this,os,i); + records[i].dump(this, os, i); + } int end = os->ftell(); return end-start; @@ -994,7 +990,7 @@ void FCEUMOV_AddInputState() MovieRecord* mr = &currMovieData.records[currFrameCounter]; if(movie_readonly || turbo || playback.pause_frame > currFrameCounter) { - // do not record buttons + // replay buttons if(mr->command_reset()) ResetNES(); if(mr->command_fds_insert()) @@ -1360,7 +1356,7 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size) if (currFrameCounter > (int)tempMovieData.records.size()) { //This is a post movie savestate, handle it differently - //Recplae movie contents but then switch to movie finished mode + //Replace movie contents but then switch to movie finished mode currMovieData = tempMovieData; openRecordingMovie(curMovieFilename); currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/);