* Tracer: the dialog window can be resized

* Tracer: disassembly text field width is now 45 symbols instead of 35
This commit is contained in:
ansstuff 2013-09-22 14:18:57 +00:00
parent b72648aced
commit 8b8a9d5191
7 changed files with 274 additions and 60 deletions

View File

@ -27,6 +27,27 @@ void WindowBoundsCheckNoResize(int &windowPosX, int &windowPosY, long windowRigh
}
}
int recalculateResizedItemCoordinate(int initialValue, int initialBase, int newBase, unsigned int resizingType)
{
switch (resizingType)
{
default:
case WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED:
{
return initialValue;
}
case WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED:
{
return newBase - (initialBase - initialValue);
}
case WINDOW_ITEM_RESIZE_TYPE_MULTIPLY:
{
return (newBase * initialValue) / initialBase;
break;
}
}
}
// Check if a filename/path has the given extension. The extension is expected to be at the very end of the filename
void AddExtensionIfMissing(char * name, unsigned int maxsize, const char * extension)
{

View File

@ -52,9 +52,19 @@ extern int eoptions;
#define EO_TVASPECT 524288
#define EO_SQUAREPIXELS 1048576
enum WINDOW_ITEM_RESIZE_TYPES
{
WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED,
WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
WINDOW_ITEM_RESIZE_TYPE_MULTIPLY,
// ---
WINDOW_ITEM_RESIZE_TYPES_TOTAL
};
bool directoryExists(const char* dirname);
void WindowBoundsCheckResize(int &windowPosX, int &windowPosY, int windowSizeX, long windowRight);
void WindowBoundsCheckNoResize(int &windowPosX, int &windowPosY, long windowRight);
int recalculateResizedItemCoordinate(int initialValue, int initialBase, int newBase, unsigned int resizingType);
void AddExtensionIfMissing(char * name,unsigned int maxsize,const char * extension);
void AddExtensionIfMissing(std::string &name,const char * extension);
std::string GetPath(std::string filename);

View File

@ -101,6 +101,7 @@ extern int Monitor_wndx, Monitor_wndy;
extern int logging_options;
extern int log_lines_option;
extern int Tracer_wndx, Tracer_wndy;
extern int Tracer_wndWidth, Tracer_wndHeight;
extern int CDLogger_wndx, CDLogger_wndy;
extern bool autoresumeCDLogging;
extern bool autosaveCDL;
@ -315,6 +316,8 @@ static CFGSTRUCT fceuconfig[] =
AC(log_lines_option),
AC(Tracer_wndx),
AC(Tracer_wndy),
AC(Tracer_wndWidth),
AC(Tracer_wndHeight),
AC(CDLogger_wndx),
AC(CDLogger_wndy),
AC(autosaveCDL),

View File

@ -1170,42 +1170,41 @@ BEGIN
EDITTEXT IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL,4,5,14,301,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED
END
TRACER DIALOGEX 65527, 65513, 382, 317
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
TRACER DIALOGEX 0, 0, 317, 181
STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Trace Logger"
FONT 8, "MS Sans Serif", 400, 0, 0x0
BEGIN
SCROLLBAR IDC_SCRL_TRACER_LOG,367,4,11,169,SBS_VERT
EDITTEXT IDC_TRACER_LOG,4,4,363,169,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL
CONTROL "Log last",IDC_RADIO_LOG_LAST,"Button",BS_AUTORADIOBUTTON | BS_LEFT,11,181,38,10
CONTROL "Log to File",IDC_RADIO_LOG_TO_FILE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,11,198,47,10
LTEXT "lines to this window",106,101,181,63,10
PUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,165,178,67,14,BS_CENTER | BS_VCENTER
COMBOBOX IDC_TRACER_LOG_SIZE,51,179,48,127,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Log Options",109,4,212,374,68
CONTROL "Log state of A, X, Y and S registers",IDC_CHECK_LOG_REGISTERS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,11,224,126,10
CONTROL "Log Processor Status flags",IDC_CHECK_LOG_PROCESSOR_STATUS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,224,104,10
PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,59,196,46,14,BS_CENTER | BS_VCENTER
CONTROL "Only log newly mapped code",IDC_CHECK_LOG_NEW_INSTRUCTIONS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,11,295,111,10
GROUPBOX "Extra Log Options that work with the Code/Data Logger",113,4,282,374,29
CONTROL "Only log code that accesses newly mapped data",IDC_CHECK_LOG_NEW_DATA,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,295,171,10
CONTROL "Automatically update Window while logging",IDC_CHECK_LOG_UPDATE_WINDOW,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,198,160,10
CONTROL "Use Stack Pointer for code tabbing (nesting visualization)",IDC_CHECK_CODE_TABBING,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,264,197,10
CONTROL "To the left from disassembly text",IDC_CHECK_LOG_STATUSES_TO_THE_LEFT,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,254,224,117,10
CONTROL "Log Frames count",IDC_CHECK_LOG_FRAMES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,11,237,102,10
CONTROL "Symbolic trace",IDC_CHECK_SYMBOLIC_TRACING,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,11,264,72,10
CONTROL "Log emulator messages",IDC_CHECK_LOG_MESSAGES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,11,250,94,10
CONTROL "Log breakpoint hits",IDC_CHECK_LOG_BREAKPOINTS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,250,82,10
CONTROL "Log Cycles count",IDC_CHECK_LOG_CYCLES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,141,237,102,10
EDITTEXT IDC_TRACER_LOG,3,3,300,44,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL
SCROLLBAR IDC_SCRL_TRACER_LOG,303,3,11,44,SBS_VERT
CONTROL "Log last",IDC_RADIO_LOG_LAST,"Button",BS_AUTORADIOBUTTON | BS_LEFT,9,54,38,10
COMBOBOX IDC_TRACER_LOG_SIZE,50,53,47,13,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "lines to this window",IDC_TEXT_LINES_TO_THIS_WINDOW,100,55,62,10
DEFPUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,243,51,71,15,BS_CENTER | BS_VCENTER
CONTROL "Log to File",IDC_RADIO_LOG_TO_FILE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,9,71,46,10
PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,57,69,40,14,BS_CENTER | BS_VCENTER
CONTROL "Automatically update this window while logging",IDC_CHECK_LOG_UPDATE_WINDOW,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,71,156,10
GROUPBOX "Log Options",IDC_GROUP_LOG_OPTIONS,3,85,311,65
CONTROL "Log state of registers",IDC_CHECK_LOG_REGISTERS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,96,99,10
CONTROL "Log Processor status flags",IDC_CHECK_LOG_PROCESSOR_STATUS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,96,96,10
CONTROL "To the left from disassembly",IDC_CHECK_LOG_STATUSES_TO_THE_LEFT,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,211,96,100,10
CONTROL "Log Frames count",IDC_CHECK_LOG_FRAMES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,109,98,10
CONTROL "Log Cycles count",IDC_CHECK_LOG_CYCLES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,109,94,10
CONTROL "Log Instructions count",IDC_CHECK_LOG_INSTRUCTIONS_COUNT,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,254,237,102,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,211,109,98,10
CONTROL "Log emulator messages",IDC_CHECK_LOG_MESSAGES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,122,97,10
CONTROL "Log breakpoint hits",IDC_CHECK_LOG_BREAKPOINTS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,122,91,10
CONTROL "Symbolic trace",IDC_CHECK_SYMBOLIC_TRACING,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,135,96,10
CONTROL "Use Stack Pointer for code tabbing (nesting visualization)",IDC_CHECK_CODE_TABBING,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,135,196,10
GROUPBOX "Extra Log Options that work with the Code/Data Logger",IDC_EXTRA_LOG_OPTIONS,3,151,311,26
CONTROL "Only log newly mapped code",IDC_CHECK_LOG_NEW_INSTRUCTIONS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,162,102,10
CONTROL "Only log code that accesses newly mapped data",IDC_CHECK_LOG_NEW_DATA,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,112,162,171,10
END
ADDBP DIALOGEX 66, 83, 196, 130

View File

@ -92,6 +92,7 @@
#define IDC_DEBUGGER_STEP_OUT 106
#define IDC_ADDBP_MEM_PPU 106
#define IDC_NTVIEW_PROPERTIES_LINE_4 106
#define IDC_TEXT_LINES_TO_THIS_WINDOW 106
#define BTN_PORT2 107
#define BTN_CDLOGGER_SAVE 107
#define IDC_CHEAT_SCRL_POSSIBILITIES 107
@ -113,6 +114,7 @@
#define BTN_CDLOGGER_SAVE_UNUSED 109
#define IDC_VIDEOCONFIG_43 109
#define IDC_VIDEOCONFIG_TVASPECT 109
#define IDC_GROUP_LOG_OPTIONS 109
#define IDC_CHEAT_VAL_LT_BY 110
#define MENU_SAVE_STATE 110
#define CB_ASK_EXIT 110
@ -137,6 +139,7 @@
#define IDC_DEBUGGER_BOOKMARK_ADD 112
#define IDC_VIDEOCONFIG_DIRECTDRAW_WIN 112
#define IDC_DEBUGGER_BOOKMARK_DEL 113
#define IDC_EXTRA_LOG_OPTIONS 113
#define BTN_CLEAR_AH 114
#define IDC_CHECK_LOG_NEW_INSTRUCTIONS 114
#define IDD_DIALOG1 114
@ -637,7 +640,6 @@
#define IDC_COPY_MARKERS 1204
#define IDC_AUTORESUMECDLOGGING2 1204
#define IDC_AUTOSAVECDL 1204
#define IDC_USE_CDLOGGER_DATA2 1204
#define IDC_INVERT_THE_MASK 1204
#define IDC_RAMLIST 1205
#define IDC_CHECK4 1205

View File

@ -59,7 +59,52 @@ int logging_options = LOG_REGISTERS | LOG_PROCESSOR_STATUS | LOG_TO_THE_LEFT | L
int log_update_window = 0;
//int tracer_open=0;
volatile int logtofile = 0, logging = 0;
HWND hTracer;
bool tracerIsReadyForResizing = false;
int tracerMinWidth = 0;
int tracerMinHeight = 0;
int Tracer_wndx = 0, Tracer_wndy = 0;
int Tracer_wndWidth = 640, Tracer_wndHeight = 500;
int tracerInitialClientWidth = 0, tracerInitialClientHeight = 0;
int tracerCurrentClientWidth = 0, tracerCurrentClientHeight = 0;
// this structure stores the data of an existing window pos and how it should be resized. The data is calculated at runtime
struct WindowItemPosData
{
HWND itemHWND;
int initialLeft;
int initialTop;
int initialRight;
int initialBottom;
unsigned int leftResizeType;
unsigned int topResizeType;
unsigned int rightResizeType;
unsigned int bottomResizeType;
};
std::vector<WindowItemPosData> arrayOfWindowItemPosData; // the data is filled in WM_INITDIALOG
// this structure holds the data how a known item should be resized. The data is prepared
struct KnownWindowItemPosData
{
int id;
unsigned int leftResizeType;
unsigned int topResizeType;
unsigned int rightResizeType;
unsigned int bottomResizeType;
};
// not all window items have to be mentioned here, others will be resized by default method (WINDOW_ITEM_RESIZE_TYPE_MULTIPLY, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_MULTIPLY, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED)
KnownWindowItemPosData tracerKnownWindowItems[] = {
IDC_TRACER_LOG, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_SCRL_TRACER_LOG, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_RADIO_LOG_LAST, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_TRACER_LOG_SIZE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_TEXT_LINES_TO_THIS_WINDOW, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_BTN_START_STOP_LOGGING, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_RADIO_LOG_TO_FILE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
IDC_BTN_LOG_BROWSE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED,
};
int log_optn_intlst[LOG_OPTION_SIZE] = {3000000, 1000000, 300000, 100000, 30000, 10000, 3000, 1000, 300, 100};
char *log_optn_strlst[LOG_OPTION_SIZE] = {"3 000 000", "1 000 000", "300 000", "100 000", "30 000", "10 000", "3000", "1000", "300", "100"};
int log_lines_option = 5; // 10000 lines by default
@ -89,8 +134,6 @@ extern int currFrameCounter;
FILE *LOG_FP;
int Tracer_wndx=0, Tracer_wndy=0;
char trace_str[35000] = {0};
WNDPROC IDC_TRACER_LOG_oldWndProc = 0;
@ -105,6 +148,9 @@ int PromptForCDLogger(void);
// returns the address, or EOF if selection cursor points to something else
int Tracer_CheckClickingOnAnAddressOrSymbolicName(unsigned int lineNumber, bool onlyCheckWhenNothingSelected)
{
if (!tracelogbufsize)
return EOF;
// trace_str contains the text in the log window
int sel_start, sel_end;
SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
@ -258,43 +304,112 @@ BOOL CALLBACK IDC_TRACER_LOG_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
return CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, uMsg, wParam, lParam);
}
BOOL CALLBACK TracerInitialEnumWindowsProc(HWND hwnd, LPARAM lParam)
{
RECT rect;
POINT p;
// create new WindowItemPosData with default settings of resizing the item
WindowItemPosData windowItemPosData;
windowItemPosData.itemHWND = hwnd;
GetWindowRect(hwnd, &rect);
p.x = rect.left;
p.y = rect.top;
ScreenToClient(hTracer, &p);
windowItemPosData.initialLeft = p.x;
windowItemPosData.initialTop = p.y;
p.x = rect.right;
p.y = rect.bottom;
ScreenToClient(hTracer, &p);
windowItemPosData.initialRight = p.x;
windowItemPosData.initialBottom = p.y;
windowItemPosData.leftResizeType = WINDOW_ITEM_RESIZE_TYPE_MULTIPLY;
windowItemPosData.topResizeType = WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED;
windowItemPosData.rightResizeType = WINDOW_ITEM_RESIZE_TYPE_MULTIPLY;
windowItemPosData.bottomResizeType = WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED;
// try to find the info in tracerKnownWindowItems
int controlID = GetDlgCtrlID(hwnd);
int sizeofKnownWindowItemPosData = sizeof(KnownWindowItemPosData);
int tracerKnownWindowItemsTotal = sizeof(tracerKnownWindowItems) / sizeofKnownWindowItemPosData;
int i;
for (i = 0; i < tracerKnownWindowItemsTotal; ++i)
{
if (tracerKnownWindowItems[i].id == controlID)
break;
}
if (i < tracerKnownWindowItemsTotal)
{
// this item is known, so its resizing method may differ from defaults
windowItemPosData.leftResizeType = tracerKnownWindowItems[i].leftResizeType;
windowItemPosData.topResizeType = tracerKnownWindowItems[i].topResizeType;
windowItemPosData.rightResizeType = tracerKnownWindowItems[i].rightResizeType;
windowItemPosData.bottomResizeType = tracerKnownWindowItems[i].bottomResizeType;
}
arrayOfWindowItemPosData.push_back(windowItemPosData);
return TRUE;
}
BOOL CALLBACK TracerResizingEnumWindowsProc(HWND hwnd, LPARAM lParam)
{
// find the data about resizing type
for (int i = arrayOfWindowItemPosData.size() - 1; i >= 0; i--)
{
if (arrayOfWindowItemPosData[i].itemHWND == hwnd)
{
// recalculate the coordinates according to the resizing type of the item
int left = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialLeft, tracerInitialClientWidth, tracerCurrentClientWidth, arrayOfWindowItemPosData[i].leftResizeType);
int top = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialTop, tracerInitialClientHeight, tracerCurrentClientHeight, arrayOfWindowItemPosData[i].topResizeType);
int right = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialRight, tracerInitialClientWidth, tracerCurrentClientWidth, arrayOfWindowItemPosData[i].rightResizeType);
int bottom = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialBottom, tracerInitialClientHeight, tracerCurrentClientHeight, arrayOfWindowItemPosData[i].bottomResizeType);
SetWindowPos(hwnd, 0, left, top, right - left, bottom - top, SWP_NOZORDER | SWP_NOOWNERZORDER);
return TRUE;
}
}
return TRUE;
}
BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int i;
switch(uMsg)
{
case WM_MOVE:
{
if (!IsIconic(hwndDlg))
{
RECT wrect;
GetWindowRect(hwndDlg,&wrect);
Tracer_wndx = wrect.left;
Tracer_wndy = wrect.top;
WindowBoundsCheckNoResize(Tracer_wndx,Tracer_wndy,wrect.right);
}
break;
}
case WM_INITDIALOG:
{
hTracer = hwndDlg;
// calculate initial size/positions of items
RECT mainRect;
GetClientRect(hTracer, &mainRect);
tracerInitialClientWidth = mainRect.right;
tracerInitialClientHeight = mainRect.bottom;
// set min size of the window to current size
GetWindowRect(hTracer, &mainRect);
tracerMinWidth = mainRect.right - mainRect.left;
tracerMinHeight = mainRect.bottom - mainRect.top;
if (Tracer_wndWidth < tracerMinWidth)
Tracer_wndWidth = tracerMinWidth;
if (Tracer_wndHeight < tracerMinHeight)
Tracer_wndHeight = tracerMinHeight;
// remember initial positions of all items
EnumChildWindows(hTracer, TracerInitialEnumWindowsProc, 0);
// restore position and size from config, also bring the window on top
if (Tracer_wndx==-32000) Tracer_wndx=0; //Just in case
if (Tracer_wndy==-32000) Tracer_wndy=0;
SetWindowPos(hwndDlg,0,Tracer_wndx,Tracer_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
hTracer = hwndDlg;
// setup font
SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG, WM_SETFONT, (WPARAM)debugSystem->hFixedFont, FALSE);
SetWindowPos(hTracer, HWND_TOP, Tracer_wndx, Tracer_wndy, Tracer_wndWidth, Tracer_wndHeight, SWP_NOOWNERZORDER);
// calculate tracesi.nPage
RECT wrect;
GetClientRect(GetDlgItem(hwndDlg, IDC_TRACER_LOG), &wrect);
tracesi.nPage = wrect.bottom / debugSystem->fixedFontHeight;
// setup font
SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG, WM_SETFONT, (WPARAM)debugSystem->hFixedFont, FALSE);
//check the disabled radio button
CheckRadioButton(hwndDlg,IDC_RADIO_LOG_LAST,IDC_RADIO_LOG_TO_FILE,IDC_RADIO_LOG_LAST);
//EnableWindow(GetDlgItem(hwndDlg,IDC_SCRL_TRACER_LOG),FALSE);
//fill in the options for the log size
// fill in the options for the log size
for(i = 0;i < LOG_OPTION_SIZE;i++)
{
SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG_SIZE, CB_INSERTSTRING, -1, (LPARAM)(LPSTR)log_optn_strlst[i]);
@ -326,6 +441,69 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
IDC_TRACER_LOG_oldWndProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_TRACER_LOG), GWL_WNDPROC, (LONG)IDC_TRACER_LOG_WndProc);
break;
}
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS* windowpos = (WINDOWPOS*)lParam;
if (!(windowpos->flags & SWP_NOSIZE))
{
// window was resized
if (!IsIconic(hwndDlg))
{
if (arrayOfWindowItemPosData.size())
{
RECT mainRect;
GetWindowRect(hTracer, &mainRect);
Tracer_wndWidth = mainRect.right - mainRect.left;
Tracer_wndHeight = mainRect.bottom - mainRect.top;
// resize all items
GetClientRect(hTracer, &mainRect);
tracerCurrentClientWidth = mainRect.right;
tracerCurrentClientHeight = mainRect.bottom;
EnumChildWindows(hTracer, TracerResizingEnumWindowsProc, 0);
InvalidateRect(hTracer, 0, TRUE);
}
// recalculate tracesi.nPage
RECT wrect;
GetClientRect(GetDlgItem(hwndDlg, IDC_TRACER_LOG), &wrect);
int newPageSize = wrect.bottom / debugSystem->fixedFontHeight;
if (tracesi.nPage != newPageSize)
{
tracesi.nPage = newPageSize;
if ((tracesi.nPos + (int)tracesi.nPage) > tracesi.nMax)
tracesi.nPos = tracesi.nMax - (int)tracesi.nPage;
if (tracesi.nPos < tracesi.nMin)
tracesi.nPos = tracesi.nMin;
SetScrollInfo(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), SB_CTL, &tracesi, TRUE);
if (logging && !logtofile)
UpdateLogText();
}
}
}
if (!(windowpos->flags & SWP_NOMOVE))
{
// window was moved
if (!IsIconic(hwndDlg) && arrayOfWindowItemPosData.size())
{
RECT mainRect;
GetWindowRect(hTracer, &mainRect);
Tracer_wndWidth = mainRect.right - mainRect.left;
Tracer_wndHeight = mainRect.bottom - mainRect.top;
Tracer_wndx = mainRect.left;
Tracer_wndy = mainRect.top;
WindowBoundsCheckNoResize(Tracer_wndx, Tracer_wndy, mainRect.right);
}
}
break;
}
case WM_GETMINMAXINFO:
{
if (tracerMinWidth)
{
((MINMAXINFO*)lParam)->ptMinTrackSize.x = tracerMinWidth;
((MINMAXINFO*)lParam)->ptMinTrackSize.y = tracerMinHeight;
}
break;
}
case WM_CLOSE:
case WM_QUIT:
if(logging)
@ -475,7 +653,6 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (tracesi.nPos < tracesi.nMin)
tracesi.nPos = tracesi.nMin;
SetScrollInfo(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), SB_CTL, &tracesi, TRUE);
UpdateLogText();
break;
}
@ -968,7 +1145,8 @@ void ShowLogDirDialog(void){
void DoTracer()
{
if (!GameInfo) {
if (!GameInfo)
{
FCEUD_PrintError("You must have a game loaded before you can use the Trace Logger.");
return;
}
@ -977,8 +1155,9 @@ void DoTracer()
// return;
//}
if(!hTracer)
if (!hTracer)
{
arrayOfWindowItemPosData.resize(0);
CreateDialog(fceu_hInstance,"TRACER",NULL,TracerCallB);
//hTracer gets set in WM_INITDIALOG
} else

View File

@ -13,7 +13,7 @@
#define LOG_CYCLES_COUNT 1024
#define LOG_INSTRUCTIONS_COUNT 2048
#define LOG_LINE_MAX_LEN 150
#define LOG_LINE_MAX_LEN 160
// Frames count - 1+6+1 symbols
// Cycles count - 1+11+1 symbols
// Instructions count - 1+11+1 symbols
@ -22,7 +22,7 @@
// Tabs - 31
// Address - 6
// Data - 10
// Disassembly - 35
// Disassembly - 45
// EOL (/0) - 1
// ------------------------
// 148 symbols total
@ -31,7 +31,7 @@
#define LOG_TABS_MASK 31
#define LOG_ADDRESS_MAX_LEN 7
#define LOG_DATA_MAX_LEN 11
#define LOG_DISASSEMBLY_MAX_LEN 36
#define LOG_DISASSEMBLY_MAX_LEN 46
extern HWND hTracer;
extern int log_update_window;