Win32 - Memw - ram monitor implementation, now uses 4 addresses

This commit is contained in:
adelikat 2008-11-16 22:37:57 +00:00
parent b18cd2afdb
commit 113fb5f339
4 changed files with 131 additions and 72 deletions

View File

@ -52,15 +52,16 @@ const unsigned int MEMW_MAX_NUMBER_OF_RECENT_FILES = sizeof(memw_recent_files)/s
static HMENU memwrecentmenu;
//Ram change globals------------------------
unsigned int ramChange = 0;
char editbox00address[5];
char editbox00last[5];
int edit00last = 0;
int edit00now = 0;
unsigned int edit00count = 0;
char edit00changem[5];
//------------------------------------------
//Ram change monitor globals------------------------
bool RamChangeInitialize = false; //Set true during memw WM_INIT
const int MAX_RAMMONITOR = 4; //Maximum number of Ram values that can be monitored
char editboxnow[MAX_RAMMONITOR][5]; //current address put into editbox 00
char editboxlast[MAX_RAMMONITOR][5]; //last address put into editbox (1 frame ago)
int editlast[MAX_RAMMONITOR]; //last address value (1 frame ago)
int editnow[MAX_RAMMONITOR]; //current address value
unsigned int editcount[MAX_RAMMONITOR]; //Current counter value
char editchangem[MAX_RAMMONITOR][5]; //counter converted to string
//-------------------------------------------------
void UpdateMemw_RMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid)
{
@ -695,12 +696,23 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
}
//Populate Formula pulldown menus
for (int x = 0; x < FMAX; x++)
for (int x = 0; x < MAX_RAMMONITOR; x++)
{
SendDlgItemMessage(hwndDlg, MEMW_EDIT00FORMULA,(UINT) CB_ADDSTRING, 0,(LPARAM) formula[x].c_str() );
for (int y = 0; y < FMAX; y++)
{
SendDlgItemMessage(hwndDlg, MEMW_EDIT00FORMULA+x,(UINT) CB_ADDSTRING, 0,(LPARAM) formula[y].c_str() );
}
SendDlgItemMessage(hwndDlg, MEMW_EDIT00FORMULA+x, CB_SETCURSEL, 0, 0);
}
SendDlgItemMessage(hwndDlg, MEMW_EDIT00FORMULA, CB_SETCURSEL, 0, 0);
//Initialize RAM Change monitor globals
for (int x; x < MAX_RAMMONITOR; x++)
{
editnow[x] = 0;
editlast[x]= 0;
}
RamChangeInitialize = true;
break;
case WM_PAINT:
@ -769,10 +781,25 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
OpenHelpWindow(memwhelp);
break;
case MEMW_EDIT00RESET:
edit00last = 0;
edit00now = 0;
edit00count = 0;
editlast[0] = 0;
editnow[0] = 0;
editcount[0] = 0;
break;
case MEMW_EDIT01RESET:
editlast[1] = 0;
editnow[1] = 0;
editcount[1] = 0;
break;
case MEMW_EDIT02RESET:
editlast[2] = 0;
editnow[2] = 0;
editcount[2] = 0;
break;
case MEMW_EDIT03RESET:
editlast[3] = 0;
editnow[3] = 0;
editcount[3] = 0;
break;
default:
if (LOWORD(wParam) >= MEMW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < MEMW_MENU_FIRST_RECENT_FILE+MEMW_MAX_NUMBER_OF_RECENT_FILES)
OpenMemwatchRecentFile(LOWORD(wParam) - MEMW_MENU_FIRST_RECENT_FILE);
@ -898,49 +925,54 @@ void AddMemWatch(char memaddress[32])
void RamChange()
{
MWRec& mwrec = mwrecs[0];
if(mwrec.valid && GameInfo)
if (!RamChangeInitialize) return;
for (int x = 0; x < MAX_RAMMONITOR; x++)
{
GetDlgItemText(hwndMemWatch, MW_ADDR00, editbox00address, 6); //Get Address value of edit00
SetDlgItemText(hwndMemWatch, MEMW_EDIT00RMADDRESS, editbox00address);
edit00last = edit00now; //Update last value
edit00now = GetMem(mwrec.addr); //Update now value
//Calculate Ram Change
int x = SendDlgItemMessage(hwndMemWatch, MEMW_EDIT00FORMULA,(UINT) CB_GETTOPINDEX, 0,0);
switch (x)
MWRec& mwrec = mwrecs[x];
if(mwrec.valid && GameInfo)
{
//Greater than------------------------------------
case 0:
if (edit00now > edit00last) edit00count++;
break;
//Greater by 1------------------------------------
case 1:
if (edit00now-edit00last == 1) edit00count++;
break;
//Less than---------------------------------------
case 2:
if (edit00now<edit00last) edit00count++;
break;
//Less by 1---------------------------------------
case 3:
if (edit00last-edit00now == 1) edit00count++;
break;
//Equal-------------------------------------------
case 4:
if (edit00now == edit00last) edit00count++;
break;
//Not Equal---------------------------------------
case 5:
if (edit00now != edit00last) edit00count++;
break;
default:
break;
GetDlgItemText(hwndMemWatch, MW_ADDR00+(x*3), editboxnow[x], 6); //Get Address value of edit00
SetDlgItemText(hwndMemWatch, MEMW_EDIT00RMADDRESS+x, editboxnow[x]); //Put Address value
editlast[x] = editnow[x]; //Update last value
editnow[x] = GetMem(mwrec.addr); //Update now value
//Calculate Ram Change
int z = SendDlgItemMessage(hwndMemWatch, MEMW_EDIT00FORMULA+x,(UINT) CB_GETTOPINDEX, 0,0);
switch (z)
{
//Greater than------------------------------------
case 0:
if (editnow[x] > editlast[x]) editcount[x]++;
break;
//Greater by 1------------------------------------
case 1:
if (editnow[x]-editlast[x] == 1) editcount[x]++;
else if ((editnow[x] == 0 && editlast[x]==255) || (editnow[x] == 0 && editlast[x]==65535)) editcount[x]++;
break;
//Less than---------------------------------------
case 2:
if (editnow[x]<editlast[x]) editcount[x]++;
break;
//Less by 1---------------------------------------
case 3:
if (editlast[x]-editnow[x] == 1) editcount[x]++;
else if ((editlast[x] == 0 && editnow[x]==255) || (editlast[x] == 0 && editnow[x]==65535)) editcount[x]++;
break;
//Equal-------------------------------------------
case 4:
if (editnow[x] == editlast[x]) editcount[x]++;
break;
//Not Equal---------------------------------------
case 5:
if (editnow[x] != editlast[x]) editcount[x]++;
break;
default:
break;
}
sprintf(editchangem[x], "%d", editcount[x]); //Convert counter to text
SetDlgItemText(hwndMemWatch, EDIT00_RESULTS+x, editchangem[x]); //Display text in results box
}
sprintf(edit00changem, "%d", edit00count); //Convert counter to text
SetDlgItemText(hwndMemWatch, MEMW_RESULTS, edit00changem); //Display text in results box
}
} //End of for loop
}

View File

@ -8,3 +8,4 @@ extern bool MemWatchLoadOnStart;
extern bool MemWatchLoadFileOnStart;
extern char *memw_recent_files[];
extern HWND memw_pwindow;
extern bool RamChangeInitialize;

View File

@ -779,7 +779,7 @@ BEGIN
END
MEMWATCH DIALOGEX 0, 0, 260, 269
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_VSCROLL | WS_SYSMENU
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Memory Watch"
MENU MEMWATCHMENU
FONT 8, "MS Sans Serif", 0, 0, 0x0
@ -840,16 +840,31 @@ BEGIN
LTEXT "Name",65425,171,7,20,8
LTEXT "Address",65424,135,7,26,8
LTEXT "Value",MW_ValueLabel2,231,7,19,8
LTEXT "Frames",MEMW_STATIC,209,249,44,8
LTEXT "results",MEMW_RESULTS,100,228,36,8
GROUPBOX "Memory Change Monitoring",IDC_STATIC,0,202,256,65
LTEXT " ",EDIT00_RESULTS,89,225,26,8
GROUPBOX "Memory Change Monitoring",IDC_STATIC,0,202,129,65
LTEXT "Address",IDC_STATIC,6,213,26,8
LTEXT "Value",IDC_STATIC,101,213,19,8
LTEXT "Change formula",IDC_STATIC,44,213,50,8
LTEXT " ",MEMW_EDIT00RMADDRESS,7,228,24,8
PUSHBUTTON " ",MEMW_EDIT00RESET,137,230,11,7
LTEXT "Reset",IDC_STATIC,133,213,20,8
COMBOBOX MEMW_EDIT00FORMULA,45,226,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "Count",IDC_STATIC,90,213,20,8
LTEXT "Change formula",IDC_STATIC,36,213,50,8
LTEXT " ",MEMW_EDIT00RMADDRESS,7,225,24,8
PUSHBUTTON " ",MEMW_EDIT00RESET,115,226,11,7
LTEXT "reset",IDC_STATIC,112,213,16,8
COMBOBOX MEMW_EDIT00FORMULA,37,223,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT " ",MEMW_EDIT01RMADDRESS,7,241,24,8
COMBOBOX MEMW_EDIT01FORMULA,37,241,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT " ",EDIT01_RESULTS,89,244,25,8
PUSHBUTTON " ",MEMW_EDIT01RESET,115,243,11,7
LTEXT " ",EDIT02_RESULTS,217,225,26,8
LTEXT "Address",IDC_STATIC,133,213,26,8
LTEXT "Change formula",IDC_STATIC,163,213,50,8
LTEXT " ",MEMW_EDIT02RMADDRESS,135,225,24,8
PUSHBUTTON " ",MEMW_EDIT02RESET,243,226,11,7
LTEXT "reset",IDC_STATIC,239,213,16,8
COMBOBOX MEMW_EDIT02FORMULA,165,223,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT " ",MEMW_EDIT03RMADDRESS,135,242,24,8
COMBOBOX MEMW_EDIT03FORMULA,165,241,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT " ",EDIT03_RESULTS,217,244,28,8
PUSHBUTTON " ",MEMW_EDIT03RESET,243,243,11,7
GROUPBOX "Memory Change Monitoring",IDC_STATIC,131,202,125,65
END
DEBUGGER DIALOGEX 54, 74, 548, 305

View File

@ -351,12 +351,12 @@
#define IDC_RADIO1 1138
#define IDC_RADIO2 1139
#define IDC_RADIO3 1140
//#define IDC_COMBO1 1142
//#define EDIT00FORMULA 1142
#define MEMW_EDIT00FORMULA 1142
#define IDC_BUTTON6 1143
#define MEMW_EDIT01FORMULA 1143
#define IDC_BUTTON5 1144
#define MEMW_EDIT02FORMULA 1144
#define IDC_BUTTON7 1145
#define MEMW_EDIT03FORMULA 1145
#define IDC_BUTTON8 1146
#define IDC_EDIT1 1147
#define IDC_BUTTON9 1148
@ -365,8 +365,19 @@
#define IDC_EDIT_AUTHOR 1180
#define MEMW_STATIC 1181
#define MEMW_RESULTS 1184
#define MEMW_EDIT00RESET 1185
#define MEMW_EDIT00RMADDRESS 1186
#define MEMW_EDIT00RESET 1184
#define MEMW_EDIT01RESET 1185
#define MEMW_EDIT02RESET 1186
#define MEMW_EDIT03RESET 1187
#define MEMW_EDIT00RMADDRESS 1188
#define MEMW_EDIT01RMADDRESS 1189
#define MEMW_EDIT02RMADDRESS 1190
#define MEMW_EDIT03RMADDRESS 1191
#define MEMW_EDIT04RMADDRESS 1192
#define EDIT00_RESULTS 1193
#define EDIT01_RESULTS 1194
#define EDIT02_RESULTS 1195
#define EDIT03_RESULTS 1196
#define MENU_NETWORK 40040
#define MENU_PALETTE 40041
#define MENU_SOUND 40042