diff --git a/src/drivers/win/debuggersp.h b/src/drivers/win/debuggersp.h index f656bdbb..f9668860 100644 --- a/src/drivers/win/debuggersp.h +++ b/src/drivers/win/debuggersp.h @@ -44,3 +44,4 @@ void DeleteDebuggerBookmark(HWND hwnd); void GoToDebuggerBookmark(HWND hwnd); int getBank(int offs); void dumpBookmarks(HWND hwmd); +int isHex(char c); \ No newline at end of file diff --git a/src/drivers/win/monitor.cpp b/src/drivers/win/monitor.cpp new file mode 100644 index 00000000..5995571b --- /dev/null +++ b/src/drivers/win/monitor.cpp @@ -0,0 +1,269 @@ +#include "common.h" +#include "monitor.h" +#include "debugger.h" +#include "debuggersp.h" +#include "..\..\fceu.h" +#include "..\..\debug.h" +#include "..\..\conddebug.h" +#include + +HWND hMonitor = 0; +int monitor_open = 0; + +#define NUMBER_OF_RULES 10 + +#define SIZE_OF_RAM 0x800 + +#define RULE_BOX_1 3000 +#define RULE_INPUT_1 3010 +#define RULE_BUTTON_1 3020 +#define RESULTS_BOX 3100 +#define RESULTS_LABEL 3101 + +#define RULE_UNKNOWN 0 +#define RULE_EXACT 1 +#define RULE_EXACT_NOT 2 +#define RULE_LESS 3 +#define RULE_LESS_EQUAL 4 +#define RULE_EQUAL 5 +#define RULE_NOT_EQUAL 6 +#define RULE_GREATER_EQUAL 7 +#define RULE_GREATER 8 + +const char* rule_strings[] = { "Any", "Exact value", "All but value", "Less than last value", "Less than or equal to last value", "Equal to last value", "Not equal to last value", "Greater than or equal to last value", "Greater than last value" }; + +unsigned char snapshots[NUMBER_OF_RULES][SIZE_OF_RAM];// = { first_snapshot, second_snapshot, third_snapshot, fourth_snapshot, fifth_snapshot }; + +unsigned int last_button = 0; + +BOOL verify_rule(unsigned int rule_number, unsigned int chosen_rule, unsigned int offset, unsigned int value) +{ + if ( chosen_rule == RULE_UNKNOWN ) + { + return TRUE; + } + else if ( chosen_rule == RULE_EXACT && snapshots[rule_number][offset] == value ) + { + return TRUE; + } + else if ( chosen_rule == RULE_EXACT_NOT && snapshots[rule_number][offset] != value ) + { + return TRUE; + } + else if ( chosen_rule == RULE_LESS && snapshots[rule_number][offset] < snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + else if ( chosen_rule == RULE_LESS_EQUAL && snapshots[rule_number][offset] <= snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + else if ( chosen_rule == RULE_GREATER && snapshots[rule_number][offset] > snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + else if ( chosen_rule == RULE_GREATER_EQUAL && snapshots[rule_number][offset] >= snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + else if ( chosen_rule == RULE_EQUAL && snapshots[rule_number][offset] == snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + else if ( chosen_rule == RULE_NOT_EQUAL && snapshots[rule_number][offset] != snapshots[rule_number - 1][offset] ) + { + return TRUE; + } + + return FALSE; +} + +void UpdateControls(HWND hwndDlg, unsigned int rule) +{ + unsigned int i; + + for (i=RULE_BUTTON_1;i %02X", snapshots[j][i]); + strcat(buff, buff2); + } + + SendDlgItemMessage(hwndDlg, RESULTS_BOX, LB_ADDSTRING, 0, (LPARAM) buff); + } + } + + UpdateControls(hwndDlg, rule); + + return TRUE; +} + +HFONT hNewFont; + +void InitControls(HWND hwndDlg) +{ + int i, j; + + for (i=RULE_BOX_1;i 2) + break; + + SendDlgItemMessage( hwndDlg, i, (UINT) CB_ADDSTRING, 0,(LPARAM) rule_strings[j] ); + } + + SendDlgItemMessage(hwndDlg, i, CB_SETCURSEL, 0, 0); + + SendMessage(GetDlgItem(hwndDlg, i - RULE_BOX_1 + RULE_INPUT_1), EM_LIMITTEXT, 2, 0); + + EnableWindow( GetDlgItem( hwndDlg, i - RULE_BOX_1 + RULE_INPUT_1), FALSE ); + + if ( i != RULE_BOX_1 ) + { + EnableWindow( GetDlgItem( hwndDlg, i ), FALSE ); + EnableWindow( GetDlgItem( hwndDlg, i - RULE_BOX_1 + RULE_BUTTON_1), FALSE ); + } + } + + LOGFONT lf; + HFONT hFont = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0); + GetObject(hFont, sizeof(LOGFONT), &lf); + strcpy(lf.lfFaceName,"Courier"); + hNewFont = CreateFontIndirect(&lf); + +// HFONT hFont = CreateFont(0, 0, 0, 0, FW_THIN, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 0, PROOF_QUALITY, DEFAULT_PITCH | FF_MODERN, "Courier New" ); + SendDlgItemMessage(hwndDlg, RESULTS_BOX, WM_SETFONT, (WPARAM)hNewFont, TRUE); +} + +BOOL handleButtonClick(HWND hwndDlg, unsigned int button_id) +{ + unsigned int rule = button_id - RULE_BUTTON_1; + + return updateResults(hwndDlg, rule); +} + +unsigned int ruleBox_to_ruleInput(unsigned int ruleBox) +{ + return ruleBox - RULE_BOX_1 + RULE_INPUT_1; +} + +BOOL CALLBACK MonitorCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) { + case WM_INITDIALOG: + monitor_open = 1; +// CenterWindow(hwndDlg); + + InitControls(hwndDlg); + break; + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + if ( GameInfo ) + { + if ( !handleButtonClick(hwndDlg, LOWORD(wParam)) ) + { + MessageBox(hwndDlg, "Invalid byte value", "Error", MB_OK | MB_ICONERROR); + } + } + break; + case CBN_SELCHANGE: + { + unsigned int sl = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0); + + EnableWindow(GetDlgItem(hwndDlg, ruleBox_to_ruleInput(LOWORD(wParam))), sl == RULE_EXACT || sl == RULE_EXACT_NOT); + + break; + } + } + break; + case WM_CLOSE: + case WM_QUIT: + DeleteObject(hNewFont); + monitor_open = 0; + DestroyWindow(hwndDlg); + break; + } + return FALSE; +} + +void DoByteMonitor() +{ + if (!monitor_open) + { + hMonitor = CreateDialog(fceu_hInstance,"MONITOR",NULL,MonitorCallB); + ShowWindow(hMonitor, SW_SHOW); +// SetWindowPos(hMonitor, HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); + } +} diff --git a/src/drivers/win/monitor.h b/src/drivers/win/monitor.h new file mode 100644 index 00000000..b6704722 --- /dev/null +++ b/src/drivers/win/monitor.h @@ -0,0 +1 @@ +void DoByteMonitor(); diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 2ea9d9af..33b66ed4 100644 Binary files a/src/drivers/win/res.rc and b/src/drivers/win/res.rc differ diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 60d32cfd..b72955b9 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -244,6 +244,7 @@ #define MENU_GAMEGENIEDECODER 40079 #define MENU_DEBUGGER 40080 #define MENU_MEMORY_WATCH 40081 +#define MENU_RAMFILTER 40082 #define MENU_LOG_SOUND 40120 #define GUI_BOT_DEBUG 65436 #define GUI_BOT_ERROR 65438 @@ -253,8 +254,8 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 -#define _APS_NEXT_COMMAND_VALUE 40081 +#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_COMMAND_VALUE 40083 #define _APS_NEXT_CONTROL_VALUE 1128 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 57d7c76d..4298b6e1 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -44,6 +44,7 @@ #include "cdlogger.h" #include "basicbot.h" #include "throttle.h" +#include "monitor.h" #include "guiconfig.h" #include "timing.h" @@ -716,6 +717,10 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) DoPPUView(); break; + case MENU_RAMFILTER: + DoByteMonitor(); + break; + case MENU_NAMETABLEVIEWER: DoNTView(); break; diff --git a/vc8/fceux.vcproj b/vc8/fceux.vcproj index 1c195ace..aa44e537 100644 --- a/vc8/fceux.vcproj +++ b/vc8/fceux.vcproj @@ -970,6 +970,14 @@ RelativePath="..\src\drivers\win\memwatch.h" > + + + +