faster memwatch?

This commit is contained in:
zeromus 2008-05-13 00:17:49 +00:00
parent 491af5b372
commit 9e1f1d82e9
8 changed files with 110 additions and 36 deletions

View File

@ -1320,3 +1320,22 @@ void DoDebug(uint8 halt) {
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);
}

View File

@ -31,6 +31,15 @@ void DoDebug(uint8 halt);
extern bool inDebugger;
extern class DebugSystem {
public:
DebugSystem();
~DebugSystem();
HFONT hFixedFont;
static const int fixedFontWidth = 8;
static const int fixedFontHeight = 13;
} *debugSystem;
#endif

View File

@ -547,6 +547,7 @@ int main(int argc,char *argv[])
}
InitCommonControls();
debugSystem = new DebugSystem();
if(!FCEUI_Initialize())
{
@ -673,6 +674,9 @@ doloopy:
DriverKill();
timeEndPeriod(1);
FCEUI_Kill();
delete debugSystem;
return(0);
}

View File

@ -91,10 +91,7 @@ HWND hMemView, hMemFind;
HDC mDC;
//int tempdummy;
//char dummystr[100];
HFONT hMemFont;
int CurOffset;
int MemFontHeight;
int MemFontWidth;
int ClientHeight;
int NoColors;
int EditingMode;
@ -299,7 +296,11 @@ void UnloadTableFile(){
TableFileLoaded = 0;
return;
}
void UpdateMemoryView(int draw_all){
void UpdateMemoryView(int draw_all)
{
int MemFontWidth = debugSystem->fixedFontWidth;
int MemFontHeight = debugSystem->fixedFontHeight;
int i, j;
//LPVOID lpMsgBuf;
//int curlength;
@ -728,18 +729,22 @@ void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset){
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){
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 : ................
//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
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(x < 8*MemFontWidth)x = 8*MemFontWidth+1;
@ -758,7 +763,8 @@ int GetAddyFromCoord(int x,int y){
return -1;
}
void AutoScrollFromCoord(int x,int y){
void AutoScrollFromCoord(int x,int y)
{
SCROLLINFO si;
if(y < 0){
ZeroMemory(&si, sizeof(SCROLLINFO));
@ -787,8 +793,8 @@ void AutoScrollFromCoord(int x,int y){
}
}
void KillMemView(){
DeleteObject(hMemFont);
void KillMemView()
{
ReleaseDC(hMemView,mDC);
DestroyWindow(hMemView);
UnregisterClass("MEMVIEW",fceu_hInstance);
@ -796,7 +802,8 @@ void KillMemView(){
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;
HGLOBAL hGlobal ;
PTSTR pGlobal ;
@ -808,6 +815,9 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
SCROLLINFO si;
int x, y, i, j;
const int MemFontWidth = debugSystem->fixedFontWidth;
const int MemFontHeight = debugSystem->fixedFontHeight;
char c[2];
char str[100];
// ################################## Start of SP CODE ###########################
@ -831,18 +841,10 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// ################################## End of SP CODE ###########################
mDC = GetDC(hwnd);
HDataDC = mDC;//deleteme
hMemFont = 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*/
SelectObject (HDataDC, hMemFont);
SelectObject (HDataDC, debugSystem->hFixedFont);
SetTextAlign(HDataDC,TA_UPDATECP | TA_TOP | TA_LEFT);
GetTextMetrics (HDataDC, &tm) ;
MemFontWidth = 8;
MemFontHeight = 13;
GetTextMetrics (HDataDC, &tm);
MaxSize = 0x10000;
//Allocate Memory for color lists
@ -1264,7 +1266,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return 0;
case WM_SIZE:
ClientHeight = HIWORD (lParam) ;
ClientHeight = HIWORD (lParam);
if(DataAmount != ((ClientHeight/MemFontHeight)*16)){
DataAmount = ((ClientHeight/MemFontHeight)*16);
if(DataAmount+CurOffset > MaxSize)CurOffset = MaxSize-DataAmount;

View File

@ -22,7 +22,9 @@
#include "..\..\fceu.h"
#include "memwatch.h"
#include "..\..\debug.h"
#include "debugger.h"
static HDC hdc;
static HWND hwndMemWatch=0;
static char addresses[24][16];
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 int yPositions[MWNUM];
static int xPositions[MWNUM];
static struct MWRec
{
static int findIndex(WORD ctl)
@ -170,43 +175,46 @@ void UpdateMemWatch()
{
if(hwndMemWatch)
{
SetTextColor(hdc,RGB(0,0,0));
SetBkColor(hdc,GetSysColor(COLOR_3DFACE));
for(int i = 0; i < MWNUM; 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.twobytes)
{
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U8ToStr(GetMem(mwrec.addr)));
text = U16ToHexStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8));
}
else
{
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U16ToDecStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8)));
text = U8ToHexStr(GetMem(mwrec.addr));
}
}
else
{
if(mwrec.twobytes)
{
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U8ToHexStr(GetMem(mwrec.addr)));
text = U16ToDecStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8));
}
else
{
SetDlgItemText(hwndMemWatch,1002+i*3,(LPTSTR)U16ToHexStr(GetMem(mwrec.addr)+(GetMem(mwrec.addr+1)<<8)));
text = U8ToStr(GetMem(mwrec.addr));
}
}
}
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)
{
//mbg 5/7/08 - wtf?
//DSMFix(uMsg);
const int kLabelControls[] = {MW_ValueLabel1,MW_ValueLabel2};
switch(uMsg)
{
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;
case WM_PAINT: {
PAINTSTRUCT ps;
BeginPaint(hwndDlg, &ps);
EndPaint(hwndDlg, &ps);
UpdateMemWatch();
break;
}
case WM_CLOSE:
case WM_QUIT:
SaveStrings();
DeleteObject(hdc);
DestroyWindow(hwndMemWatch);
hwndMemWatch=0;
break;
@ -490,6 +525,7 @@ void CreateMemWatch(HWND parent)
//Create
//hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",parent,MemWatchCallB);
hwndMemWatch=CreateDialog(fceu_hInstance,"MEMWATCH",NULL,MemWatchCallB);
UpdateMemWatch();
//Initialize values to previous entered addresses/labels
{

Binary file not shown.

View File

@ -270,6 +270,8 @@
#define MENU_MEMORY_WATCH 40081
#define MENU_RAMFILTER 40082
#define MENU_LOG_SOUND 40120
#define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426
#define GUI_BOT_DEBUG 65436
#define GUI_BOT_ERROR 65438
#define LBL_INPUT_HELP 65488

View File

@ -1158,7 +1158,9 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
goto proco;
case WM_CLOSE:
case WM_DESTROY:
case WM_QUIT:DoFCEUExit();break;
case WM_QUIT:
DoFCEUExit();
break;
case WM_ACTIVATEAPP:
if((BOOL)wParam)
{