From 72e04788fe28b01e27b6c728e7d397c3e8d92572 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Thu, 22 Sep 2011 16:02:09 +0000 Subject: [PATCH] * deleted "Lag Counter Reset" hotkey, as it was obsolete since FCEUX 2.0.2; added "Open TAS Edit" hotkey * Tasedit: auto clear "Disable speed throttling" and "Run in background", auto set "Set high-priority thread" when entering TASEdit; FCEUX runs in bg when TASEdit has focus * Tasedit: Config->"Mute Turbo" check (same as in Config->Sound) * fixed long "savestate" messages containing path --- src/drivers/win/res.rc | 12 +++--- src/drivers/win/resource.h | 4 +- src/drivers/win/tasedit.cpp | 76 ++++++++++++++++++++++++------------- src/drivers/win/tasedit.h | 2 +- src/drivers/win/window.cpp | 11 ++---- src/input.cpp | 14 ++++++- src/input.h | 2 +- src/state.cpp | 12 ++++-- 8 files changed, 86 insertions(+), 47 deletions(-) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 3c6c3881..78035986 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -250,6 +250,7 @@ BEGIN POPUP "Config" BEGIN MENUITEM "Set greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY + MENUITEM "Mute Turbo", ID_CONFIG_MUTETURBO END POPUP "&Help" BEGIN @@ -1988,14 +1989,15 @@ END IDR_ACCELERATOR1 ACCELERATORS BEGIN - VK_DELETE, ACCEL_CTRL_DELETE, VIRTKEY, CONTROL, NOINVERT - "S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT - "T", ACCEL_CTRL_T, VIRTKEY, CONTROL, NOINVERT "C", ACCEL_CTRL_C, VIRTKEY, CONTROL, NOINVERT - "V", ACCEL_CTRL_V, VIRTKEY, CONTROL, NOINVERT - "X", ACCEL_CTRL_X, VIRTKEY, CONTROL, NOINVERT + VK_DELETE, ACCEL_CTRL_DELETE, VIRTKEY, CONTROL, NOINVERT "F", ACCEL_CTRL_F, VIRTKEY, CONTROL, NOINVERT "P", ACCEL_CTRL_P, VIRTKEY, CONTROL, NOINVERT + "S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT + "T", ACCEL_CTRL_T, VIRTKEY, CONTROL, NOINVERT + "V", ACCEL_CTRL_V, VIRTKEY, CONTROL, NOINVERT + "X", ACCEL_CTRL_X, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ACCEL_CTRL_INSERT, VIRTKEY, CONTROL, NOINVERT END IDR_RWACCELERATOR ACCELERATORS diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index d0e94b1b..633133b4 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -820,6 +820,8 @@ #define ACCEL_CTRL_F 40429 #define ACCEL_CTRL_P 40430 #define ID_CONFIG_SETGREENZONECAPACITY 40432 +#define ACCEL_CTRL_INSERT 40433 +#define ID_CONFIG_MUTETURBO 40435 #define IDC_DEBUGGER_ICONTRAY 55535 #define MW_ValueLabel2 65423 #define MW_ValueLabel1 65426 @@ -829,7 +831,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_COMMAND_VALUE 40433 +#define _APS_NEXT_COMMAND_VALUE 40436 #define _APS_NEXT_CONTROL_VALUE 1262 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 0fad0f9f..30ea828b 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -12,6 +12,7 @@ #include "movie.h" #include "utils/xstring.h" #include "Win32InputBox.h" +#include "window.h" #include "keyboard.h" #include "joystick.h" #include "help.h" @@ -27,6 +28,8 @@ int lastCursor; int old_pauseframe; bool old_show_pauseframe; bool show_pauseframe; +bool TASEdit_focus = false; +int saved_eoptions = 0; // vars saved in cfg file int TasEdit_wndx, TasEdit_wndy; @@ -35,12 +38,12 @@ bool TASEdit_show_lag_frames = true; bool TASEdit_show_tweak_count = false; bool TASEdit_restore_position = false; int TASEdit_greenzone_capacity = GREENZONE_DEFAULT_CAPACITY; +extern bool muteTurbo; 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 HWND hwndList, hwndHeader, hwndTweakCount; static RECT rectTweakCount; @@ -398,6 +401,7 @@ void DoubleClick(LPNMITEMACTIVATE info) { JumpToFrame(index); ClearSelection(); + RedrawList(); } else if(info->iSubItem >= COLUMN_JOYPAD1_A && info->iSubItem <= COLUMN_JOYPAD4_R) { @@ -699,12 +703,6 @@ static bool Paste() return result; } -//removes the current selection (does not put in clipboard) -static void Delete() -{ - DeleteFrames(); -} - void AddMarker() { } @@ -847,15 +845,6 @@ bool CheckSaveChanges() return true; } -void KillTasEdit() -{ - if (!CheckSaveChanges()) return; - DestroyWindow(hwndTasEdit); - hwndTasEdit = 0; - turbo = false; - ExitTasEdit(); -} - //Creates a new TASEdit Project static void NewProject() { @@ -1150,9 +1139,15 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_CLOSE: case WM_QUIT: - KillTasEdit(); + ExitTasEdit(); break; + case WM_ACTIVATEAPP: + if((BOOL)wParam) + TASEdit_focus = true; + else + TASEdit_focus = false; + return DefWindowProc(hwndDlg,uMsg,wParam,lParam); case WM_COMMAND: switch(LOWORD(wParam)) { @@ -1183,7 +1178,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case ID_TASEDIT_FILE_CLOSE: - KillTasEdit(); + ExitTasEdit(); break; case ID_EDIT_SELECTALL: @@ -1207,7 +1202,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case ACCEL_CTRL_DELETE: case ID_TASEDIT_DELETE: - Delete(); + case ID_CONTEXT_SELECTED_DELETEFRAMES: + if (selectionFrames.size()) DeleteFrames(); break; case ID_EDIT_ADDMARKER: @@ -1257,14 +1253,11 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } break; + case ACCEL_CTRL_INSERT: case ID_CONTEXT_SELECTED_INSERTFRAMES: - InsertFrames(); + if (selectionFrames.size()) InsertFrames(); break; - case ID_CONTEXT_SELECTED_DELETEFRAMES: - DeleteFrames(); - break; - case TASEDIT_FOWARD: //advance 1 frame JumpToFrame(currFrameCounter+1); @@ -1325,6 +1318,7 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED); break; case ID_CONFIG_SETGREENZONECAPACITY: + { //open input dialog int new_capacity = TASEdit_greenzone_capacity; if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?", new_capacity, hwndDlg) == IDOK) @@ -1341,11 +1335,17 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } else TASEdit_greenzone_capacity = new_capacity; } break; + } + + case ID_CONFIG_MUTETURBO: + muteTurbo ^= 1; + CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED); + break; } + default: break; } - return FALSE; } @@ -1393,8 +1393,20 @@ void EnterTasEdit() if(!hwndTasEdit) hwndTasEdit = CreateDialog(fceu_hInstance,"TASEDIT",hAppWnd,WndprocTasEdit); if(hwndTasEdit) { + // save "eoptions" + saved_eoptions = eoptions; + // clear "Run in background" + eoptions &= ~EO_BGRUN; + // set "Background TASEdit input" KeyboardSetBackgroundAccessBit(KEYBACKACCESS_TASEDIT); JoystickSetBackgroundAccessBit(JOYBACKACCESS_TASEDIT); + // "Set high-priority thread" + eoptions |= EO_HIGHPRIO; + DoPriority(); + // clear "Disable speed throttling" + eoptions &= ~EO_NOTHROTTLE; + UpdateCheckedMenuItems(); + hmenu = GetMenu(hwndTasEdit); hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS"); // check option ticks @@ -1402,14 +1414,26 @@ void EnterTasEdit() 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); CheckDlgButton(hwndTasEdit,CHECK_AUTORESTORE_PLAYBACK,TASEdit_restore_position?BST_CHECKED:BST_UNCHECKED); + CheckMenuItem(hmenu, ID_CONFIG_MUTETURBO, muteTurbo?MF_CHECKED : MF_UNCHECKED); SetWindowPos(hwndTasEdit,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); } } void ExitTasEdit() { + if (!CheckSaveChanges()) return; + DestroyWindow(hwndTasEdit); + hwndTasEdit = 0; + turbo = false; + pauseframe = -1; + TASEdit_focus = false; + // restore "eoptions" + eoptions = saved_eoptions; + DoPriority(); + UpdateCheckedMenuItems(); + // release memory + currMovieData.clearGreenzone(); movieMode = MOVIEMODE_INACTIVE; FCEU_DispMessage("Tasedit disengaged",0); - currMovieData.clearGreenzone(); CreateCleanMovie(); } diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index 96c75b21..1d49e22a 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -3,7 +3,7 @@ #define FRAMES_TOO_FAR 60 #define NUM_JOYPADS 4 #define NUM_JOYPAD_BUTTONS 8 -#define GREENZONE_DEFAULT_CAPACITY 50000 +#define GREENZONE_DEFAULT_CAPACITY 100000 #define GREENZONE_MIN_CAPACITY 1 #define GREENZONE_MAX_CAPACITY 200000 // maybe even more #define PAUSEFRAME_BLINKING_PERIOD 100 diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index dfeb88ab..fc41cdf1 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -126,6 +126,7 @@ bool AVIdisableMovieMessages = false; char *md5_asciistr(uint8 digest[16]); static int winwidth, winheight; static volatile int nofocus = 0; +extern bool TASEdit_focus; static int tog = 0; //Toggle for Hide Menu static bool loggingSound = false; static LONG WindowXC=1<<30,WindowYC; @@ -2223,13 +2224,9 @@ adelikat: Outsourced this to a remappable hotkey break; case WM_ACTIVATEAPP: if((BOOL)wParam) - { - nofocus=0; - } + nofocus = 0; else - { - nofocus=1; - } + nofocus = 1; goto proco; case WM_ENTERMENULOOP: UpdateCheckedMenuItems(); @@ -2360,7 +2357,7 @@ void UpdateFCEUWindow(void) if(!(eoptions & EO_BGRUN)) { - while(nofocus) + while(nofocus && !TASEdit_focus) { Sleep(75); diff --git a/src/input.cpp b/src/input.cpp index f15da8f2..3b0a175d 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -620,6 +620,7 @@ static void BackgroundDisplayToggle(void); static void ObjectDisplayToggle(void); static void LagCounterToggle(void); static void ViewSlots(void); +static void LaunchTasEdit(void); static void LaunchMemoryWatch(void); static void LaunchCheats(void); static void LaunchDebugger(void); @@ -743,13 +744,13 @@ struct EMUCMDTABLE FCEUI_CommandTable[]= { EMUCMD_MISC_DISPLAY_BG_TOGGLE, EMUCMDTYPE_MISC, BackgroundDisplayToggle, 0, 0, "Toggle Background Display", 0 }, { EMUCMD_MISC_DISPLAY_OBJ_TOGGLE, EMUCMDTYPE_MISC, ObjectDisplayToggle, 0, 0, "Toggle Object Display", 0 }, { EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE,EMUCMDTYPE_MISC, LagCounterToggle, 0, 0, "Lag Counter Toggle", EMUCMDFLAG_TASEDIT }, - { EMUCMD_MISC_LAGCOUNTER_RESET, EMUCMDTYPE_MISC, LagCounterReset, 0, 0, "Lag Counter Reset", 0}, + { EMUCMD_MISC_OPENTASEDIT, EMUCMDTYPE_TOOL, LaunchTasEdit, 0, 0, "Open TAS Edit", 0}, { EMUCMD_TOOL_OPENMEMORYWATCH, EMUCMDTYPE_TOOL, LaunchMemoryWatch,0, 0, "Open Memory Watch", EMUCMDFLAG_TASEDIT }, { EMUCMD_TOOL_OPENCHEATS, EMUCMDTYPE_TOOL, LaunchCheats, 0, 0, "Open Cheats", 0}, { EMUCMD_TOOL_OPENDEBUGGER, EMUCMDTYPE_TOOL, LaunchDebugger, 0, 0, "Open Debugger", 0}, { EMUCMD_TOOL_OPENHEX, EMUCMDTYPE_TOOL, LaunchHex, 0, 0, "Open Hex Editor", 0}, { EMUCMD_TOOL_OPENPPU, EMUCMDTYPE_TOOL, LaunchPPU, 0, 0, "Open PPU Viewer", 0}, - { EMUCMD_TOOL_OPENNTVIEW, EMUCMDTYPE_TOOL, LaunchNTView, 0, 0, "Open Name Table Viewer", 0}, + { EMUCMD_TOOL_OPENNTVIEW, EMUCMDTYPE_TOOL, LaunchNTView, 0, 0, "Open Name Table Viewer", 0}, { EMUCMD_TOOL_OPENTRACELOGGER, EMUCMDTYPE_TOOL, LaunchTraceLogger, 0, 0, "Open Trace Logger", 0}, { EMUCMD_TOOL_OPENCDLOGGER, EMUCMDTYPE_TOOL, LaunchCodeDataLogger, 0, 0, "Open Code/Data Logger", 0}, { EMUCMD_FRAMEADV_SKIPLAG, EMUCMDTYPE_MISC, FA_SkipLag, 0, 0, "Frame Adv.-Skip Lag", 0}, @@ -901,6 +902,14 @@ static void LagCounterToggle(void) lagCounterDisplay ^= 1; } +static void LaunchTasEdit(void) +{ +#ifdef WIN32 + extern void EnterTasEdit(); + EnterTasEdit(); +#endif +} + static void LaunchMemoryWatch(void) { #ifdef WIN32 @@ -974,6 +983,7 @@ static void LaunchRamSearch(void) #endif } + static void RamSearchOpLT(void) { #ifdef WIN32 extern void SetSearchType(int SearchType); diff --git a/src/input.h b/src/input.h index 90a31af5..fba788c3 100644 --- a/src/input.h +++ b/src/input.h @@ -201,8 +201,8 @@ enum EMUCMD EMUCMD_MISC_DISPLAY_OBJ_TOGGLE, EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE, - EMUCMD_MISC_LAGCOUNTER_RESET, //Currently Windows only------ + EMUCMD_MISC_OPENTASEDIT, EMUCMD_TOOL_OPENMEMORYWATCH, EMUCMD_TOOL_OPENCHEATS, EMUCMD_TOOL_OPENDEBUGGER, diff --git a/src/state.cpp b/src/state.cpp index 31e2b982..d9b77591 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -725,7 +725,8 @@ bool FCEUSS_Load(const char *fname) if(st == NULL || (st->get_fp() == NULL)) { - FCEU_DispMessage("State %d load error. Filename: %s",0,CurrentState, fn); + FCEU_DispMessage("State %d load error.",0,CurrentState); + //FCEU_DispMessage("State %d load error. Filename: %s",0,CurrentState, fn); SaveStateStatus[CurrentState]=0; return false; } @@ -739,11 +740,13 @@ bool FCEUSS_Load(const char *fname) { char szFilename[260]={0}; splitpath(fname, 0, 0, szFilename, 0); - FCEU_DispMessage("State %s loaded. Filename: %s",0,szFilename, fn); + FCEU_DispMessage("State %s loaded.",0,szFilename); + //FCEU_DispMessage("State %s loaded. Filename: %s",0,szFilename, fn); } else { - FCEU_DispMessage("State %d loaded. Filename: %s",0,CurrentState, fn); + FCEU_DispMessage("State %d loaded.",0,CurrentState); + //FCEU_DispMessage("State %d loaded. Filename: %s",0,CurrentState, fn); SaveStateStatus[CurrentState]=1; } delete st; @@ -786,7 +789,8 @@ bool FCEUSS_Load(const char *fname) { SaveStateStatus[CurrentState]=1; } - FCEU_DispMessage("Error(s) reading state %d! Filename: %s",0,CurrentState, fn); + FCEU_DispMessage("Error(s) reading state %d!",0,CurrentState); + //FCEU_DispMessage("Error(s) reading state %d! Filename: %s",0,CurrentState, fn); delete st; return 0; }