* saving and loading tweakCount in .tas and fm2

* Added string "Tweak Count" to Replay loading dialog
* Tasedit: View - "Show Tweak count"
* Tasedit: rewrote project save/load functions
* Tasedit: fixed old bug caused by not initializing input ports
* Tasedit: checking movie fourscore flag when creating/opening project; only show columns for pads 3 and 4 if fourscore is attached
This commit is contained in:
ansstuff 2011-09-12 12:23:48 +00:00
parent 5a2d97662f
commit e0e0f72d2f
12 changed files with 324 additions and 207 deletions

View File

@ -420,7 +420,7 @@ void DrawTextTransWH(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor, i
wid = JoedCharWidth(*textmsg);
int newx = x+wid;
if(newx >= width) { x=beginx; y+=8; }
if(newx >= (int)width) { x=beginx; y+=8; }
for(int ny=0; ny<7; ++ny)
{

View File

@ -69,6 +69,7 @@ extern bool fullSaveStateLoads;
extern int frameSkipAmt;
extern bool TASEdit_follow_playback;
extern bool TASEdit_show_lag_frames;
extern bool TASEdit_show_tweak_count;
//window positions and sizes:
extern int ChtPosX,ChtPosY;
@ -286,6 +287,7 @@ static CFGSTRUCT fceuconfig[] = {
AC(DesynchAutoFire),
AC(TASEdit_follow_playback),
AC(TASEdit_show_lag_frames),
AC(TASEdit_show_tweak_count),
AC(lagCounterDisplay),
AC(oldInputDisplay),
AC(movieSubtitles),

View File

@ -463,10 +463,12 @@ void InitInputPorts(bool fourscore)
int attrib;
if(fourscore) {
if(fourscore)
{
FCEUI_SetInput(0,SI_GAMEPAD,&JSreturn,0);
FCEUI_SetInput(1,SI_GAMEPAD,&JSreturn,0);
} else {
} else
{
for(int i=0;i<2;i++)
{
attrib=0;

View File

@ -177,6 +177,8 @@ void UpdateReplayDialog(HWND hwndDlg)
sprintf(tmp, "%u", (unsigned)info.rerecord_count);
SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT), tmp); // rerecord
sprintf(tmp, "%u", (unsigned)info.tweak_count);
SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_TWEAKCOUNT), tmp);
SendDlgItemMessage(hwndDlg,IDC_CHECK_READONLY,BM_SETCHECK,(replayReadOnlySetting ? BST_CHECKED : BST_UNCHECKED), 0);
@ -271,6 +273,7 @@ void UpdateReplayDialog(HWND hwndDlg)
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_TWEAKCOUNT),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),"");

View File

@ -12,13 +12,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
// Íåéòðàëüíûé resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
#endif //_WIN32
#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
//
@ -246,7 +244,8 @@ BEGIN
END
POPUP "&View"
BEGIN
MENUITEM "Show &lag frames", ID_VIEW_SHOW_LAG_FRAMES
MENUITEM "Highlight &lag frames", ID_VIEW_SHOW_LAG_FRAMES
MENUITEM "Show T&weak count", ID_VIEW_SHOW_TWEAK_COUNT
MENUITEM SEPARATOR
MENUITEM "&Follow playback", ID_VIEW_FOLLOW_PLAYBACK
END
@ -1296,41 +1295,43 @@ BEGIN
RTEXT "Author:",65502,18,43,34,10,SS_CENTERIMAGE | NOT WS_GROUP,WS_EX_RIGHT
END
IDD_REPLAYINP DIALOGEX 0, 0, 300, 218
IDD_REPLAYINP DIALOGEX 0, 0, 300, 215
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Play Movie"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",1,193,192,50,14
GROUPBOX "",65497,3,0,293,183
DEFPUSHBUTTON "OK",1,187,197,50,14
GROUPBOX "",65497,3,0,293,192
RTEXT "File:",65498,8,11,24,10,SS_CENTERIMAGE | NOT WS_GROUP
COMBOBOX IDC_COMBO_FILENAME,35,10,257,128,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Cancel",2,247,192,50,14
PUSHBUTTON "Cancel",2,241,197,50,14
RTEXT "Length:",64397,10,67,59,8
RTEXT "Frames:",65496,10,78,59,8
RTEXT "Record Count:",65495,10,89,59,8
RTEXT "ROM Used:",65493,10,111,59,8
RTEXT "ROM Checksum:",65492,10,121,59,8
RTEXT "Recorded From:",65491,10,100,59,8
RTEXT "Emulator Used:",65490,10,143,59,8
RTEXT "Current ROM Sum:",65489,8,132,61,8
RTEXT "ROM Used:",65493,10,122,59,8
RTEXT "ROM Checksum:",65492,10,133,59,8
RTEXT "Recorded From:",65491,10,111,59,8
RTEXT "Emulator Used:",65490,10,155,59,8
RTEXT "Current ROM Sum:",65489,8,144,61,8
CONTROL "Pause movie at frame",IDC_CHECK_STOPMOVIE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,49,83,10
EDITTEXT IDC_EDIT_STOPFRAME,103,47,35,12,ES_AUTOHSCROLL | ES_NUMBER
GROUPBOX "Parameters",IDC_STATIC,13,25,278,40
PUSHBUTTON "Metadata...",IDC_BUTTON_METADATA,239,71,50,14
EDITTEXT IDC_LABEL_EMULATORUSED,76,143,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_CURRCHECKSUM,76,132,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_ROMCHECKSUM,76,122,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_ROMUSED,76,111,187,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_RECORDEDFROM,76,100,123,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_EMULATORUSED,76,155,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_CURRCHECKSUM,76,144,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_ROMCHECKSUM,76,133,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_ROMUSED,76,122,187,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_RECORDEDFROM,76,111,123,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
CONTROL "Open &Read-Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,36,69,10
EDITTEXT IDC_LABEL_UNDOCOUNT,76,89,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_FRAMES,76,78,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
EDITTEXT IDC_LABEL_LENGTH,76,67,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "Pal:",65494,10,153,59,8
EDITTEXT IDC_LABEL_PALUSED,76,153,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "New PPU:",65499,10,164,59,8
EDITTEXT IDC_LABEL_NEWPPUUSED,76,164,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "Pal:",65494,10,166,59,8
EDITTEXT IDC_LABEL_PALUSED,76,166,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "New PPU:",65499,10,177,59,8
EDITTEXT IDC_LABEL_NEWPPUUSED,76,177,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
RTEXT "Tweak Count:",65500,10,100,59,8
EDITTEXT IDC_LABEL_TWEAKCOUNT,76,100,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END
TASEDIT DIALOGEX 0, 0, 474, 383
@ -1712,6 +1713,18 @@ BEGIN
TOPMARGIN, 8
END
"DWBDIALOG", DIALOG
BEGIN
END
"FKBDIALOG", DIALOG
BEGIN
END
"GAMEPADDIALOG", DIALOG
BEGIN
END
"GUICONFIG", DIALOG
BEGIN
LEFTMARGIN, 10
@ -1728,6 +1741,14 @@ BEGIN
BOTTOMMARGIN, 191
END
"MAHJONGDIALOG", DIALOG
BEGIN
END
"MAPINPUT", DIALOG
BEGIN
END
"MESSAGELOG", DIALOG
BEGIN
BOTTOMMARGIN, 184
@ -1773,6 +1794,10 @@ BEGIN
BOTTOMMARGIN, 208
END
"DWBDIALOGSIMPLE", DIALOG
BEGIN
END
"MEMWATCH", DIALOG
BEGIN
RIGHTMARGIN, 260
@ -1791,6 +1816,10 @@ BEGIN
BOTTOMMARGIN, 121
END
"GGCONV", DIALOG
BEGIN
END
"MONITOR", DIALOG
BEGIN
LEFTMARGIN, 7
@ -1814,7 +1843,7 @@ BEGIN
"IDD_REPLAYINP", DIALOG
BEGIN
BOTTOMMARGIN, 214
BOTTOMMARGIN, 211
END
"TASEDIT", DIALOG
@ -1841,6 +1870,10 @@ BEGIN
BOTTOMMARGIN, 66
END
"CDLOGGER", DIALOG
BEGIN
END
"ARCHIVECHOOSERDIALOG", DIALOG
BEGIN
LEFTMARGIN, 7
@ -1875,18 +1908,16 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // Neutral resources
#endif // Íåéòðàëüíûé resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
// Àíãëèéñêèé (ÑØÀ) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
@ -1986,7 +2017,7 @@ END
//
IDB_TE_ARROW BITMAP "res/te_arrow.bmp"
#endif // English (U.S.) resources
#endif // Àíãëèéñêèé (ÑØÀ) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -261,6 +261,7 @@
#define IDC_LABEL_NEWPPUUSED 310
#define MENU_PAL 311
#define IDC_DEBUGGER_VAL_SPR 311
#define IDC_LABEL_TWEAKCOUNT 311
#define IDC_DEBUGGER_BOOKMARK 312
#define MENU_DIRECTORIES 320
#define MENU_INPUT 321
@ -809,6 +810,7 @@
#define FCEUX_CONTEXT_GUICONFIG 40418
#define ID_VIEW_FOLLOW_PLAYBACK 40419
#define ID_VIEW_SHOW_LAG_FRAMES 40420
#define ID_VIEW_SHOW_TWEAK_COUNT 40421
#define IDC_DEBUGGER_ICONTRAY 55535
#define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426
@ -818,7 +820,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 160
#define _APS_NEXT_COMMAND_VALUE 40421
#define _APS_NEXT_COMMAND_VALUE 40422
#define _APS_NEXT_CONTROL_VALUE 1261
#define _APS_NEXT_SYMED_VALUE 101
#endif

View File

@ -24,14 +24,16 @@ using namespace std;
int TasEdit_wndx, TasEdit_wndy;
bool TASEdit_follow_playback = true;
bool TASEdit_show_lag_frames = true;
bool TASEdit_show_tweak_count = false;
string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page
char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"};
HWND hwndTasEdit = 0;
static HMENU hmenu, hrmenu;
static int lastCursor;
static HWND hwndList, hwndHeader;
static HWND hwndList, hwndHeader, hwndTweakCount;
static WNDPROC hwndHeader_oldWndproc, hwndList_oldWndProc;
typedef std::set<int> TSelectionFrames;
@ -169,8 +171,32 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg)
}
}
void CreateProject(MovieData data)
void EnterTasEdit()
{
if (movieMode == MOVIEMODE_INACTIVE)
{
FCEUI_StopMovie();
CreateCleanMovie();
//reset the rom
poweron(true);
currFrameCounter = 0;
}
else
{
//use current movie to create a new project
FCEUI_StopMovie();
}
// pause the emulator and enter tasedit mode
FCEUI_SetEmulationPaused(1);
movieMode = MOVIEMODE_TASEDIT;
currMovieData.TryDumpIncremental();
FCEU_DispMessage("Tasedit engaged",0);
}
void ExitTasEdit()
{
movieMode = MOVIEMODE_INACTIVE;
FCEU_DispMessage("Tasedit disengaged",0);
CreateCleanMovie();
}
// called from the rest of the emulator when things happen and the tasedit should change to reflect it
@ -224,6 +250,10 @@ void RedrawList()
{
InvalidateRect(hwndList,0,FALSE);
}
void RedrawTasedit()
{
InvalidateRect(hwndTasEdit,0,FALSE);
}
enum ECONTEXTMENU
{
@ -273,14 +303,6 @@ void RightClick(LPNMITEMACTIVATE info)
RightClickMenu(info);
}
void LockGreenZone(int newstart)
{
for (int i=1; i<newstart; ++i)
{
currMovieData.savestates[i].clear();
}
}
void InvalidateGreenZone(int after)
{
if (currMovieData.greenZoneCount > after+1)
@ -288,7 +310,7 @@ void InvalidateGreenZone(int after)
currMovieData.greenZoneCount = after+1;
// increase tweakCount
currMovieData.tweakCount++;
InvalidateRect(hwndTasEdit,0,FALSE);
RedrawTasedit();
if (currFrameCounter >= currMovieData.greenZoneCount)
JumpToFrame(currMovieData.greenZoneCount-1);
}
@ -354,7 +376,11 @@ void DoubleClick(LPNMITEMACTIVATE info)
return;
//if the icon or frame columns were double clicked:
if(info->iSubItem == COLUMN_ARROW || info->iSubItem == COLUMN_FRAMENUM || info->iSubItem == COLUMN_FRAMENUM2)
if(info->iSubItem == COLUMN_ARROW)
{
// set bookmark (of current bookmark slot) here
} else if(info->iSubItem == COLUMN_FRAMENUM || info->iSubItem == COLUMN_FRAMENUM2)
{
JumpToFrame(index);
}
@ -794,8 +820,28 @@ static void InitDialog()
ListView_InsertColumn(hwndList, colidx++, &lvc);
// pads columns
lvc.cx = 20;
char buttonNames[NUM_JOYPAD_BUTTONS][2] = {"A", "B", "S", "T", "U", "D", "L", "R"};
for (int joy = 0; joy < NUM_JOYPADS; ++joy)
// add pads 1 and 2
for (int joy = 0; joy < 2; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
lvc.pszText = buttonNames[btn];
ListView_InsertColumn(hwndList, colidx++, &lvc);
}
}
// add pads 3 and 4 and frame_number2
if (currMovieData.fourscore) AddFourscoreColumns();
//the initial update
UpdateTasEdit();
}
void AddFourscoreColumns()
{
LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH | LVCF_TEXT;
lvc.cx = 20;
int colidx = COLUMN_JOYPAD3_A;
for (int joy = 0; joy < 2; ++joy)
{
for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn)
{
@ -807,10 +853,13 @@ static void InitDialog()
lvc.cx = 92;
lvc.pszText = "Frame#";
ListView_InsertColumn(hwndList, colidx++, &lvc);
//-----------------------------
//the initial update
UpdateTasEdit();
}
void RemoveFourscoreColumns()
{
for (int i = COLUMN_FRAMENUM2; i >= COLUMN_JOYPAD3_A; --i)
{
ListView_DeleteColumn (hwndList, i);
}
}
bool CheckSaveChanges()
@ -821,23 +870,20 @@ bool CheckSaveChanges()
void KillTasEdit()
{
if (!CheckSaveChanges())
return;
if (!CheckSaveChanges()) return;
DestroyWindow(hwndTasEdit);
hwndTasEdit = 0;
turbo=false;
FCEUMOV_ExitTasEdit();
turbo = false;
ExitTasEdit();
}
//Creates a new TASEdit Project
static void NewProject()
{
//determine if current project changed
//if so, ask to save changes
//close current project
if (!CheckSaveChanges())
return;
//determine if current project changed
//if so, ask to save changes
//close current project
if (!CheckSaveChanges()) return;
//TODO: close current project instance, create a new one with a non-parameterized constructor
}
@ -871,7 +917,8 @@ static void OpenProject()
string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
ofn.lpstrInitialDir=initdir.c_str();
if(GetOpenFileName(&ofn)){ //If it is a valid filename
if(GetOpenFileName(&ofn)) //If it is a valid filename
{
std::string tempstr = nameo; //Make a temporary string for filename
char drv[512], dir[512], name[512], ext[512]; //For getting the filename!
if(tempstr.rfind(".tas") == std::string::npos) //If they haven't put ".tas" after it
@ -887,13 +934,21 @@ static void OpenProject()
filename.append(ext); //Stick extension back on...
project.SetProjectFile(filename); //And update the project's filename.
}
project.SetProjectName(GetRomName()); //Set the project's name to the ROM name
//Set the project's name to the ROM name
project.SetProjectName(GetRomName());
//Set the fm2 name
std::string thisfm2name = project.GetProjectName();
thisfm2name.append(".fm2"); //Setup the fm2 name
project.SetFM2Name(thisfm2name); //Set the project's fm2 name
thisfm2name.append(".fm2");
project.SetFM2Name(thisfm2name);
// load project and change number of listview columns if needed
bool last_fourscore = currMovieData.fourscore;
project.LoadProject(project.GetProjectFile());
if (last_fourscore && !currMovieData.fourscore)
RemoveFourscoreColumns();
else if (!last_fourscore && currMovieData.fourscore)
AddFourscoreColumns();
FollowPlayback();
}
}
// Saves current project
@ -997,7 +1052,7 @@ static void Truncate()
currMovieData.truncateAt(frame+1);
InvalidateGreenZone(frame);
currMovieData.TryDumpIncremental();
//currMovieData.TryDumpIncremental();
UpdateTasEdit();
}
@ -1051,8 +1106,12 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_PAINT:
{
char temp[128];
sprintf(temp,"TweakCount: %d\n",currMovieData.tweakCount);
SetWindowText(GetDlgItem(hwndDlg,IDC_TWEAKCOUNT),temp);
if (TASEdit_show_tweak_count)
sprintf(temp,"Tweak count: %d\n",currMovieData.tweakCount);
else
sprintf(temp,"");
SetWindowText(hwndTweakCount,temp);
RedrawTasedit();
}
break;
case WM_INITDIALOG:
@ -1061,6 +1120,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
SetWindowPos(hwndDlg,0,TasEdit_wndx,TasEdit_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
hwndList = GetDlgItem(hwndDlg,IDC_LIST1);
hwndTweakCount = GetDlgItem(hwndDlg,IDC_TWEAKCOUNT);
InitDialog();
break;
@ -1272,11 +1332,18 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
FollowPlayback();
break;
case ID_VIEW_SHOW_LAG_FRAMES:
//switch "Show lag frames" flag
//switch "Highlight lag frames" flag
TASEdit_show_lag_frames ^= 1;
CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED);
RedrawList();
break;
case ID_VIEW_SHOW_TWEAK_COUNT:
//switch "Show Tweak count" flag
TASEdit_show_tweak_count ^= 1;
CheckMenuItem(hmenu, ID_VIEW_SHOW_TWEAK_COUNT, TASEdit_show_tweak_count?MF_CHECKED : MF_UNCHECKED);
//RedrawList();
break;
}
break;
@ -1300,23 +1367,23 @@ void FollowPlayback()
void DoTasEdit()
{
if(!FCEU_IsValidUI(FCEUI_TASEDIT))
return;
if(!FCEU_IsValidUI(FCEUI_TASEDIT)) return;
lastCursor = -1;
if(!hwndTasEdit)
hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT",hAppWnd,WndprocTasEdit);
EnterTasEdit();
if(!hwndTasEdit) hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT",hAppWnd,WndprocTasEdit);
if(hwndTasEdit)
{
KeyboardSetBackgroundAccessBit(KEYBACKACCESS_TASEDIT);
JoystickSetBackgroundAccessBit(JOYBACKACCESS_TASEDIT);
hmenu = GetMenu(hwndTasEdit);
hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS");
// check option ticks
CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hmenu, ID_VIEW_SHOW_TWEAK_COUNT, TASEdit_show_tweak_count?MF_CHECKED : MF_UNCHECKED);
if(hwndTasEdit)
{
KeyboardSetBackgroundAccessBit(KEYBACKACCESS_TASEDIT);
JoystickSetBackgroundAccessBit(JOYBACKACCESS_TASEDIT);
FCEUMOV_EnterTasEdit();
SetWindowPos(hwndTasEdit,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
}
}

View File

@ -39,6 +39,7 @@
#define COLUMN_JOYPAD4_L 32
#define COLUMN_JOYPAD4_R 33
#define COLUMN_FRAMENUM2 34
// listview colors
#define NORMAL_FRAMENUM_COLOR 0xFFFFFF
#define CUR_FRAMENUM_COLOR 0xFCF1CE
@ -56,8 +57,11 @@
// -----------------------------
void DoTasEdit();
void UpdateTasEdit();
void CreateProject(MovieData data);
void InvalidateGreenZone(int after);
bool JumpToFrame(int index);
int FindBeginningOfGreenZone(int starting_index);
void FollowPlayback();
void AddFourscoreColumns();
void RemoveFourscoreColumns();
void EnterTasEdit();
void ExitTasEdit();

View File

@ -86,12 +86,13 @@ bool TASEDIT_PROJECT::LoadProject(std::string PFN)
char branchname;
branchname = ifs.fgetc(); // TODO: Add main branch name.
currMovieData.loadGreenzone(&ifs, true);
currMovieData.clearGreenzone();
if (!currMovieData.loadGreenzone(&ifs, true))
{
// there was some error while loading greenzone - reset playback to frame 0
poweron(true);
currFrameCounter = currMovieData.greenZoneCount;
currMovieData.TryDumpIncremental();
currFrameCounter = 0;
}
changed=false;
return true;
}

View File

@ -652,7 +652,7 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_PAUSE, EMUCMDTYPE_MISC, FCEUI_ToggleEmulationPause, 0, 0, "Pause", EMUCMDFLAG_TASEDIT },
{ EMUCMD_FRAME_ADVANCE, EMUCMDTYPE_MISC, FCEUI_FrameAdvance, FCEUI_FrameAdvanceEnd, 0, "Frame Advance", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SCREENSHOT, EMUCMDTYPE_MISC, FCEUI_SaveSnapshot, 0, 0, "Screenshot", EMUCMDFLAG_TASEDIT },
{ EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", 0 },
{ EMUCMD_EXIT, EMUCMDTYPE_MISC, FCEUI_DoExit, 0, 0, "Exit", 0},
{ EMUCMD_SPEED_SLOWEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Slowest Speed", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_SLOWER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Down", EMUCMDFLAG_TASEDIT },

View File

@ -390,10 +390,10 @@ MovieData::MovieData()
, palFlag(false)
, PPUflag(false)
, rerecordCount(0)
, tweakCount(0)
, binaryFlag(false)
, greenZoneCount(0)
, microphone(false)
, tweakCount(0)
{
memset(&romChecksum,0,sizeof(MD5DATA));
}
@ -416,6 +416,8 @@ void MovieData::installValue(std::string& key, std::string& val)
installInt(val,emuVersion);
else if(key == "rerecordCount")
installInt(val,rerecordCount);
else if(key == "tweakCount")
installInt(val,tweakCount);
else if(key == "palFlag")
installBool(val,palFlag);
else if(key == "romFilename")
@ -462,6 +464,7 @@ int MovieData::dump(EMUFILE *os, bool binary)
os->fprintf("version %d\n", version);
os->fprintf("emuVersion %d\n", emuVersion);
os->fprintf("rerecordCount %d\n", rerecordCount);
os->fprintf("tweakCount %d\n", tweakCount);
os->fprintf("palFlag %d\n" , (palFlag?1:0) );
os->fprintf("romFilename %s\n" , romFilename.c_str() );
os->fprintf("romChecksum %s\n" , BytesToString(romChecksum.data,MD5DATA::size).c_str() );
@ -471,8 +474,8 @@ int MovieData::dump(EMUFILE *os, bool binary)
os->fprintf("port0 %d\n" , ports[0] );
os->fprintf("port1 %d\n" , ports[1] );
os->fprintf("port2 %d\n" , ports[2] );
os->fprintf("FDS %d\n" , isFDS?1:0 );
os->fprintf("NewPPU %d\n" , newppu?1:0 );
os->fprintf("FDS %d\n" , fds?1:0 );
os->fprintf("NewPPU %d\n" , PPUflag?1:0 );
for(uint32 i=0;i<comments.size();i++)
os->fprintf("comment %s\n" , wcstombs(comments[i]).c_str() );
@ -504,47 +507,89 @@ int MovieData::dump(EMUFILE *os, bool binary)
return end-start;
}
void MovieData::clearGreenzone()
{
int size = currMovieData.savestates.size();
for (int i = 1; i < size; ++i)
{
currMovieData.savestates[i].clear();
}
greenZoneCount = 1;
currMovieData.frames_flags.resize(1);
// reset lua_colorings
// reset monitorings
}
int MovieData::dumpGreenzone(EMUFILE *os, bool binary)
{
// save savestates
int start = os->ftell();
int frame, size;
for (int i=0; i<(int)savestates.size(); ++i)
write32le(greenZoneCount, os);
for (frame = 0; frame < greenZoneCount; ++frame)
{
if (savestates[i].empty())
continue;
frame=i;
size=savestates[i].size();
if (savestates[frame].empty()) continue;
write32le(frame, os);
size = savestates[frame].size();
write32le(size, os);
// write savestate
os->fwrite(&savestates[frame][0], size);
// write frames_flags
os->fwrite(&frames_flags[frame], 1);
// write lua_colorings
// write monitorings
os->fwrite(&savestates[i][0], size);
}
frame=-1;
size=currMovieData.greenZoneCount;
write32le(frame, os);
write32le(size, os);
int end= os->ftell();
// write -1 as eof for greenzone
write32le(-1, os);
// finally write playback cursor position
write32le(currFrameCounter, os);
int end = os->ftell();
return end-start;
}
int MovieData::loadGreenzone(EMUFILE *is, bool binary)
bool MovieData::loadGreenzone(EMUFILE *is, bool binary)
{
int frame, size;
clearGreenzone();
int frame = 0, prev_frame = 0, size = 0;
if (read32le((uint32 *)&size, is))
{
greenZoneCount = size;
frames_flags.resize(size);
savestates.resize(size);
while(1)
{
if (!read32le((uint32 *)&frame, is)) {size=0; break;}
if (!read32le((uint32 *)&size, is)) {size=0; break;}
if (frame==-1) break;
int pos = is->ftell();
FCEUSS_LoadFP(is, SSLOADPARAM_NOBACKUP);
storeTasSavestate(frame, Z_DEFAULT_COMPRESSION);
is->fseek(pos+size,SEEK_SET);
}
greenZoneCount=size;
if (!read32le((uint32 *)&frame, is)) break;
if (frame == -1) break;
if (!read32le((uint32 *)&size, is)) break;
return 1;
if ((int)savestates.size() <= frame) savestates.resize(frame+1);
// load savestate
savestates[frame].resize(size);
if ((int)is->fread((char*)&savestates[frame][0],size) < size) break;
// load frames_flags
if ((int)is->fread(&frames_flags[frame],1) != 1) break;
// load lua_colorings
// load monitorings
prev_frame = frame;
}
greenZoneCount = prev_frame+1; // cut greenZoneCount to last good frame
if (frame == -1)
{
// everything went fine - load savestate at cursor position
if (read32le((uint32 *)&currFrameCounter, is) && currMovieData.loadTasSavestate(currFrameCounter))
{
return true;
}
} else
{
// there was some error while reading greenzone
}
}
return false;
}
@ -636,6 +681,8 @@ bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
std::string a("length"), b("-1");
// Non-TAS projects consume until EOF
movieData.installValue(a, b);
std::string a1("tweakCount"), b1("0");
movieData.installValue(a1, b1);
//first, look for an fcm signature
char fcmbuf[3];
@ -824,59 +871,23 @@ void poweron(bool shouldDisableBatteryLoading)
disableBatteryLoading = 0;
}
void FCEUMOV_EnterTasEdit()
void CreateCleanMovie()
{
//If no movie, start a new project, currMovieData will serve as the "main branch" file, so give it a filename and save that into the project
//Dump all header info int ot the project file
//Else use the currentmovie to create a new project
//BIG TODO: Why is this tasedit stuff in movie.cpp? Let's movie it out, it is win32 only anyway
if (movieMode == MOVIEMODE_INACTIVE)
{
//stop any current movie activity
FCEUI_StopMovie();
//clear the current movie
currFrameCounter = 0;
currMovieData = MovieData();
currMovieData.guid.newGuid();
currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0;
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.romFilename = FileBase;
//reset the rom
poweron(false);
}
else
{
FCEUI_StopMovie();
currMovieData.greenZoneCount=currFrameCounter;
}
//todo - think about this
//ResetInputTypes();
//todo - maybe this instead
//FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]);
#ifdef WIN32
CreateProject(currMovieData);
#endif
FCEUI_SetEmulationPaused(1); //pause the emulator
//and enter tasedit mode
movieMode = MOVIEMODE_TASEDIT;
currMovieData.TryDumpIncremental();
FCEU_DispMessage("Tasedit engaged",0);
}
void FCEUMOV_ExitTasEdit()
{
movieMode = MOVIEMODE_INACTIVE;
FCEU_DispMessage("Tasedit disengaged",0);
currMovieData = MovieData();
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.guid.newGuid();
currMovieData.fourscore = FCEUI_GetInputFourscore();
currMovieData.microphone = FCEUI_GetInputMicrophone();
//currMovieData.ports[0] = InputType[0];
//currMovieData.ports[1] = InputType[1];
//currMovieData.ports[2] = InputType[2];
currMovieData.ports[0] = joyports[0].type;
currMovieData.ports[1] = joyports[1].type;
currMovieData.ports[2] = portFC.type;
currMovieData.fds = isFDS;
currMovieData.PPUflag = (newppu != 0);
}
bool FCEUMOV_FromPoweron()
@ -985,8 +996,7 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
{
currFrameCounter = 0;
pauseframe = _pauseframe;
currMovieData.TryDumpIncremental();
//currMovieData.TryDumpIncremental();
}
else
{
@ -1045,19 +1055,9 @@ void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author)
currFrameCounter = 0;
LagCounterReset();
currMovieData = MovieData();
currMovieData.guid.newGuid();
CreateCleanMovie();
if(author != L"") currMovieData.comments.push_back(L"author " + author);
currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0;
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.romFilename = FileBase;
currMovieData.fourscore = FCEUI_GetInputFourscore();
currMovieData.microphone = FCEUI_GetInputMicrophone();
currMovieData.ports[0] = joyports[0].type;
currMovieData.ports[1] = joyports[1].type;
currMovieData.ports[2] = portFC.type;
if(flags & MOVIE_FLAG_FROM_POWERON)
{
@ -1635,6 +1635,7 @@ bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount)
info.emu_version_used = md.emuVersion;
info.name_of_rom_used = md.romFilename;
info.rerecord_count = md.rerecordCount;
info.tweak_count = md.tweakCount;
info.comments = md.comments;
info.subtitles = md.subtitles;

View File

@ -13,6 +13,8 @@
#include "utils/guid.h"
#include "utils/md5.h"
extern int InputType[3];
struct FCEUFILE;
enum EMOVIE_FLAG
@ -39,6 +41,7 @@ typedef struct
int movie_version; // version of the movie format in the file
uint32 num_frames;
uint32 rerecord_count;
uint32 tweak_count;
bool poweron, pal, nosynchack, ppuflag;
bool reset; //mbg 6/21/08 - this flag isnt used anymore.. but maybe one day we can scan it out of the first record in the movie file
uint32 emu_version_used; // 9813 = 0.98.13
@ -90,10 +93,10 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size);
void FCEUMOV_PreLoad();
bool FCEUMOV_PostLoad();
void FCEUMOV_EnterTasEdit();
void FCEUMOV_ExitTasEdit();
bool FCEUMOV_FromPoweron();
void CreateCleanMovie();
class MovieData;
class MovieRecord
{
@ -231,8 +234,9 @@ public:
void truncateAt(int frame);
void installValue(std::string& key, std::string& val);
int dump(EMUFILE* os, bool binary);
void clearGreenzone();
int dumpGreenzone(EMUFILE *os, bool binary);
int loadGreenzone(EMUFILE *is, bool binary);
bool loadGreenzone(EMUFILE *is, bool binary);
void clearRecordRange(int start, int len);
void insertEmpty(int at, int frames);