faster memwatch?
This commit is contained in:
parent
491af5b372
commit
9e1f1d82e9
|
@ -1320,3 +1320,22 @@ void DoDebug(uint8 halt) {
|
||||||
if (GameInfo) UpdateDebugger();
|
if (GameInfo) UpdateDebugger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------
|
||||||
|
DebugSystem* debugSystem;
|
||||||
|
|
||||||
|
DebugSystem::DebugSystem()
|
||||||
|
{
|
||||||
|
hFixedFont = CreateFont(13,8, /*Height,Width*/
|
||||||
|
0,0, /*escapement,orientation*/
|
||||||
|
400,FALSE,FALSE,FALSE, /*weight, italic,, underline, strikeout*/
|
||||||
|
ANSI_CHARSET,OUT_DEVICE_PRECIS,CLIP_MASK, /*charset, precision, clipping*/
|
||||||
|
DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/
|
||||||
|
"Courier"); /*font name*/
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugSystem::~DebugSystem()
|
||||||
|
{
|
||||||
|
DeleteObject(hFixedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,15 @@ void DoDebug(uint8 halt);
|
||||||
|
|
||||||
extern bool inDebugger;
|
extern bool inDebugger;
|
||||||
|
|
||||||
|
extern class DebugSystem {
|
||||||
|
public:
|
||||||
|
DebugSystem();
|
||||||
|
~DebugSystem();
|
||||||
|
|
||||||
|
HFONT hFixedFont;
|
||||||
|
static const int fixedFontWidth = 8;
|
||||||
|
static const int fixedFontHeight = 13;
|
||||||
|
} *debugSystem;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -547,6 +547,7 @@ int main(int argc,char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
debugSystem = new DebugSystem();
|
||||||
|
|
||||||
if(!FCEUI_Initialize())
|
if(!FCEUI_Initialize())
|
||||||
{
|
{
|
||||||
|
@ -673,6 +674,9 @@ doloopy:
|
||||||
DriverKill();
|
DriverKill();
|
||||||
timeEndPeriod(1);
|
timeEndPeriod(1);
|
||||||
FCEUI_Kill();
|
FCEUI_Kill();
|
||||||
|
|
||||||
|
delete debugSystem;
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,10 +91,7 @@ HWND hMemView, hMemFind;
|
||||||
HDC mDC;
|
HDC mDC;
|
||||||
//int tempdummy;
|
//int tempdummy;
|
||||||
//char dummystr[100];
|
//char dummystr[100];
|
||||||
HFONT hMemFont;
|
|
||||||
int CurOffset;
|
int CurOffset;
|
||||||
int MemFontHeight;
|
|
||||||
int MemFontWidth;
|
|
||||||
int ClientHeight;
|
int ClientHeight;
|
||||||
int NoColors;
|
int NoColors;
|
||||||
int EditingMode;
|
int EditingMode;
|
||||||
|
@ -299,7 +296,11 @@ void UnloadTableFile(){
|
||||||
TableFileLoaded = 0;
|
TableFileLoaded = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void UpdateMemoryView(int draw_all){
|
void UpdateMemoryView(int draw_all)
|
||||||
|
{
|
||||||
|
int MemFontWidth = debugSystem->fixedFontWidth;
|
||||||
|
int MemFontHeight = debugSystem->fixedFontHeight;
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
//LPVOID lpMsgBuf;
|
//LPVOID lpMsgBuf;
|
||||||
//int curlength;
|
//int curlength;
|
||||||
|
@ -728,18 +729,22 @@ void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset){
|
||||||
|
|
||||||
|
|
||||||
int GetHexScreenCoordx(int offset){
|
int GetHexScreenCoordx(int offset){
|
||||||
return (8*MemFontWidth)+((offset%16)*3*MemFontWidth); //todo: add Curoffset to this and to below function
|
return (8*debugSystem->fixedFontWidth)+((offset%16)*3*debugSystem->fixedFontWidth); //todo: add Curoffset to this and to below function
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetHexScreenCoordy(int offset){
|
int GetHexScreenCoordy(int offset){
|
||||||
return (offset/16)*MemFontHeight;
|
return (offset/16)*debugSystem->fixedFontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
|
//0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
|
||||||
|
|
||||||
//if the mouse is in the text field, this function will set AddyWasText to 1 otherwise it is 0
|
//if the mouse is in the text field, this function will set AddyWasText to 1 otherwise it is 0
|
||||||
//if the mouse wasn't in any range, this function returns -1
|
//if the mouse wasn't in any range, this function returns -1
|
||||||
int GetAddyFromCoord(int x,int y){
|
int GetAddyFromCoord(int x,int y)
|
||||||
|
{
|
||||||
|
int MemFontWidth = debugSystem->fixedFontWidth;
|
||||||
|
int MemFontHeight = debugSystem->fixedFontHeight;
|
||||||
|
|
||||||
if(y < 0)y = 0;
|
if(y < 0)y = 0;
|
||||||
if(x < 8*MemFontWidth)x = 8*MemFontWidth+1;
|
if(x < 8*MemFontWidth)x = 8*MemFontWidth+1;
|
||||||
|
|
||||||
|
@ -758,7 +763,8 @@ int GetAddyFromCoord(int x,int y){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoScrollFromCoord(int x,int y){
|
void AutoScrollFromCoord(int x,int y)
|
||||||
|
{
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
if(y < 0){
|
if(y < 0){
|
||||||
ZeroMemory(&si, sizeof(SCROLLINFO));
|
ZeroMemory(&si, sizeof(SCROLLINFO));
|
||||||
|
@ -787,8 +793,8 @@ void AutoScrollFromCoord(int x,int y){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KillMemView(){
|
void KillMemView()
|
||||||
DeleteObject(hMemFont);
|
{
|
||||||
ReleaseDC(hMemView,mDC);
|
ReleaseDC(hMemView,mDC);
|
||||||
DestroyWindow(hMemView);
|
DestroyWindow(hMemView);
|
||||||
UnregisterClass("MEMVIEW",fceu_hInstance);
|
UnregisterClass("MEMVIEW",fceu_hInstance);
|
||||||
|
@ -796,7 +802,8 @@ void KillMemView(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
|
LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HGLOBAL hGlobal ;
|
HGLOBAL hGlobal ;
|
||||||
PTSTR pGlobal ;
|
PTSTR pGlobal ;
|
||||||
|
@ -808,6 +815,9 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
int x, y, i, j;
|
int x, y, i, j;
|
||||||
|
|
||||||
|
const int MemFontWidth = debugSystem->fixedFontWidth;
|
||||||
|
const int MemFontHeight = debugSystem->fixedFontHeight;
|
||||||
|
|
||||||
char c[2];
|
char c[2];
|
||||||
char str[100];
|
char str[100];
|
||||||
// ################################## Start of SP CODE ###########################
|
// ################################## Start of SP CODE ###########################
|
||||||
|
@ -831,18 +841,10 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
// ################################## End of SP CODE ###########################
|
// ################################## End of SP CODE ###########################
|
||||||
mDC = GetDC(hwnd);
|
mDC = GetDC(hwnd);
|
||||||
HDataDC = mDC;//deleteme
|
HDataDC = mDC;//deleteme
|
||||||
hMemFont = CreateFont(13,8, /*Height,Width*/
|
SelectObject (HDataDC, debugSystem->hFixedFont);
|
||||||
0,0, /*escapement,orientation*/
|
|
||||||
400,FALSE,FALSE,FALSE, /*weight, italic,, underline, strikeout*/
|
|
||||||
ANSI_CHARSET,OUT_DEVICE_PRECIS,CLIP_MASK, /*charset, precision, clipping*/
|
|
||||||
DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/
|
|
||||||
"Courier"); /*font name*/
|
|
||||||
SelectObject (HDataDC, hMemFont);
|
|
||||||
SetTextAlign(HDataDC,TA_UPDATECP | TA_TOP | TA_LEFT);
|
SetTextAlign(HDataDC,TA_UPDATECP | TA_TOP | TA_LEFT);
|
||||||
|
|
||||||
GetTextMetrics (HDataDC, &tm) ;
|
GetTextMetrics (HDataDC, &tm);
|
||||||
MemFontWidth = 8;
|
|
||||||
MemFontHeight = 13;
|
|
||||||
|
|
||||||
MaxSize = 0x10000;
|
MaxSize = 0x10000;
|
||||||
//Allocate Memory for color lists
|
//Allocate Memory for color lists
|
||||||
|
@ -1264,7 +1266,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
ClientHeight = HIWORD (lParam) ;
|
ClientHeight = HIWORD (lParam);
|
||||||
if(DataAmount != ((ClientHeight/MemFontHeight)*16)){
|
if(DataAmount != ((ClientHeight/MemFontHeight)*16)){
|
||||||
DataAmount = ((ClientHeight/MemFontHeight)*16);
|
DataAmount = ((ClientHeight/MemFontHeight)*16);
|
||||||
if(DataAmount+CurOffset > MaxSize)CurOffset = MaxSize-DataAmount;
|
if(DataAmount+CurOffset > MaxSize)CurOffset = MaxSize-DataAmount;
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
#include "..\..\fceu.h"
|
#include "..\..\fceu.h"
|
||||||
#include "memwatch.h"
|
#include "memwatch.h"
|
||||||
#include "..\..\debug.h"
|
#include "..\..\debug.h"
|
||||||
|
#include "debugger.h"
|
||||||
|
|
||||||
|
static HDC hdc;
|
||||||
static HWND hwndMemWatch=0;
|
static HWND hwndMemWatch=0;
|
||||||
static char addresses[24][16];
|
static char addresses[24][16];
|
||||||
static char labels[24][24];
|
static char labels[24][24];
|
||||||
|
@ -120,6 +122,9 @@ static const int MW_ADDR_Lookup[] = {
|
||||||
|
|
||||||
static const int MWNUM = ARRAY_SIZE(MW_ADDR_Lookup);
|
static const int MWNUM = ARRAY_SIZE(MW_ADDR_Lookup);
|
||||||
|
|
||||||
|
static int yPositions[MWNUM];
|
||||||
|
static int xPositions[MWNUM];
|
||||||
|
|
||||||
static struct MWRec
|
static struct MWRec
|
||||||
{
|
{
|
||||||
static int findIndex(WORD ctl)
|
static int findIndex(WORD ctl)
|
||||||
|
@ -170,43 +175,46 @@ void UpdateMemWatch()
|
||||||
{
|
{
|
||||||
if(hwndMemWatch)
|
if(hwndMemWatch)
|
||||||
{
|
{
|
||||||
|
SetTextColor(hdc,RGB(0,0,0));
|
||||||
|
SetBkColor(hdc,GetSysColor(COLOR_3DFACE));
|
||||||
|
|
||||||
for(int i = 0; i < MWNUM; i++)
|
for(int i = 0; i < MWNUM; i++)
|
||||||
{
|
{
|
||||||
MWRec& mwrec = mwrecs[i];
|
MWRec& mwrec = mwrecs[i];
|
||||||
uint16& a = mwrec.addr;
|
|
||||||
bool& hex = mwrec.hex;
|
|
||||||
bool& twobytes = mwrec.twobytes;
|
|
||||||
bool& valid = mwrec.valid;
|
|
||||||
|
|
||||||
if(mwrec.valid)
|
char* text;
|
||||||
|
if(mwrec.valid && GameInfo)
|
||||||
{
|
{
|
||||||
if(mwrec.hex)
|
if(mwrec.hex)
|
||||||
{
|
{
|
||||||
if(mwrec.twobytes)
|
if(mwrec.twobytes)
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U8ToStr(GetMem(mwrec.addr)));
|
text = U16ToHexStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U16ToDecStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8)));
|
text = U8ToHexStr(GetMem(mwrec.addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(mwrec.twobytes)
|
if(mwrec.twobytes)
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U8ToHexStr(GetMem(mwrec.addr)));
|
text = U16ToDecStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U16ToHexStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8)));
|
text = U8ToStr(GetMem(mwrec.addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)"---");
|
text = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoveToEx(hdc,xPositions[i],yPositions[i],NULL);
|
||||||
|
TextOut(hdc,0,0,text,strlen(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,18 +395,45 @@ static void LoadMemWatch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
//mbg 5/7/08 - wtf?
|
const int kLabelControls[] = {MW_ValueLabel1,MW_ValueLabel2};
|
||||||
//DSMFix(uMsg);
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
hdc = GetDC(hwndDlg);
|
||||||
|
SelectObject (hdc, debugSystem->hFixedFont);
|
||||||
|
SetTextAlign(hdc,TA_UPDATECP | TA_TOP | TA_LEFT);
|
||||||
|
|
||||||
|
//find the positions where we should draw string values
|
||||||
|
for(int i=0;i<MWNUM;i++) {
|
||||||
|
int col=0;
|
||||||
|
if(i>=MWNUM/2)
|
||||||
|
col=1;
|
||||||
|
RECT r;
|
||||||
|
GetWindowRect(GetDlgItem(hwndDlg,MW_ADDR_Lookup[i]),&r);
|
||||||
|
ScreenToClient(hwndDlg,(LPPOINT)&r);
|
||||||
|
ScreenToClient(hwndDlg,(LPPOINT)&r.right);
|
||||||
|
yPositions[i] = r.top;
|
||||||
|
yPositions[i] += ((r.bottom-r.top)-debugSystem->fixedFontHeight)/2; //vertically center
|
||||||
|
GetWindowRect(GetDlgItem(hwndDlg,kLabelControls[col]),&r);
|
||||||
|
ScreenToClient(hwndDlg,(LPPOINT)&r);
|
||||||
|
xPositions[i] = r.left;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_PAINT: {
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
BeginPaint(hwndDlg, &ps);
|
||||||
|
EndPaint(hwndDlg, &ps);
|
||||||
|
UpdateMemWatch();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
SaveStrings();
|
SaveStrings();
|
||||||
|
DeleteObject(hdc);
|
||||||
DestroyWindow(hwndMemWatch);
|
DestroyWindow(hwndMemWatch);
|
||||||
hwndMemWatch=0;
|
hwndMemWatch=0;
|
||||||
break;
|
break;
|
||||||
|
@ -490,6 +525,7 @@ void CreateMemWatch(HWND parent)
|
||||||
//Create
|
//Create
|
||||||
//hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",parent,MemWatchCallB);
|
//hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",parent,MemWatchCallB);
|
||||||
hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",NULL,MemWatchCallB);
|
hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",NULL,MemWatchCallB);
|
||||||
|
UpdateMemWatch();
|
||||||
|
|
||||||
//Initialize values to previous entered addresses/labels
|
//Initialize values to previous entered addresses/labels
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
|
@ -270,6 +270,8 @@
|
||||||
#define MENU_MEMORY_WATCH 40081
|
#define MENU_MEMORY_WATCH 40081
|
||||||
#define MENU_RAMFILTER 40082
|
#define MENU_RAMFILTER 40082
|
||||||
#define MENU_LOG_SOUND 40120
|
#define MENU_LOG_SOUND 40120
|
||||||
|
#define MW_ValueLabel2 65423
|
||||||
|
#define MW_ValueLabel1 65426
|
||||||
#define GUI_BOT_DEBUG 65436
|
#define GUI_BOT_DEBUG 65436
|
||||||
#define GUI_BOT_ERROR 65438
|
#define GUI_BOT_ERROR 65438
|
||||||
#define LBL_INPUT_HELP 65488
|
#define LBL_INPUT_HELP 65488
|
||||||
|
|
|
@ -1158,7 +1158,9 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
||||||
goto proco;
|
goto proco;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
case WM_QUIT:DoFCEUExit();break;
|
case WM_QUIT:
|
||||||
|
DoFCEUExit();
|
||||||
|
break;
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
if((BOOL)wParam)
|
if((BOOL)wParam)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue