New Symbolic Debug Naming dialog:

1. Multiline comments can be directly edited in the dialog.
2. You can add an array of comments to the addresses.
3. More convinient features of symbolic debug naming.
This commit is contained in:
owomomo 2020-12-20 18:48:35 +08:00
parent 022909e9ac
commit 67e64410a8
5 changed files with 3346 additions and 3189 deletions

View File

@ -412,6 +412,7 @@ Name* parse(char* lines, const char* filename)
{
first = prev = nn;
}
printf("nnoffset: %s, %d\n", nn->offset, nn->offsetNumeric);
}
// Free the allocated node
@ -936,11 +937,20 @@ INT_PTR CALLBACK SymbolicNamingCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
if (node->comment && node->comment[0])
SetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, node->comment);
}
SetDlgItemText(hwndDlg, IDC_EDIT_SYMBOLIC_ARRAY, "10");
SetDlgItemText(hwndDlg, IDC_EDIT_SYMBOLIC_INIT, "0");
// set focus to IDC_SYMBOLIC_NAME
SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwndDlg, IDC_SYMBOLIC_NAME), true);
//always set the limits
SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_NAME, EM_SETLIMITTEXT, NL_MAX_NAME_LEN, 0);
SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_COMMENT, EM_SETLIMITTEXT, NL_MAX_MULTILINE_COMMENT_LEN, 0);
SendDlgItemMessage(hwndDlg, IDC_EDIT_SYMBOLIC_ARRAY, EM_SETLIMITTEXT, 2, 0);
SendDlgItemMessage(hwndDlg, IDC_EDIT_SYMBOLIC_INIT, EM_SETLIMITTEXT, 2, 0);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_ARRAY), GWLP_WNDPROC, (LONG_PTR)FilterEditCtrlProc);
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_INIT), GWLP_WNDPROC, (LONG_PTR)FilterEditCtrlProc);
CheckDlgButton(hwndDlg, IDC_CHECK_SYMBOLIC_NAME_OVERWRITE, BST_CHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD, BST_CHECKED);
break;
}
case WM_CLOSE:
@ -954,19 +964,86 @@ INT_PTR CALLBACK SymbolicNamingCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
{
switch(LOWORD(wParam))
{
case IDC_CHECK_SYMBOLIC_DELETE:
{
bool delete_mode = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_DELETE) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_NAME), !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_COMMENT), !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_SYMBOLIC_NAME), !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_SYMBOLIC_COMMENT), !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_NAME_OVERWRITE), !delete_mode);
if (delete_mode)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_INIT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_INIT), FALSE);
} else
{
bool array_chk = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_ARRAY) == BST_CHECKED;
bool comment_head_only = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD), array_chk);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_NAME_OVERWRITE), array_chk);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE), array_chk && !comment_head_only);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_INIT), array_chk);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_INIT), array_chk);
}
break;
}
case IDC_CHECK_SYMBOLIC_ARRAY:
{
bool array_chk = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_ARRAY) == BST_CHECKED;
bool delete_mode = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_DELETE) == BST_CHECKED;
bool comment_head_only = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_NAME_OVERWRITE), array_chk && !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD), array_chk && !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE), array_chk && !comment_head_only && !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_ARRAY), array_chk);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_BYTE), array_chk);
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_SYMBOLIC_INIT), array_chk && !delete_mode);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_SYMBOLIC_INIT), array_chk && !delete_mode);
break;
}
case IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD:
{
bool comment_head_only = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE), !comment_head_only);
break;
}
case IDOK:
{
unsigned int newAddress = 0;
char newOffset[6] = {0};
char newOffset[6] = { 0 };
GetDlgItemText(hwndDlg, IDC_SYMBOLIC_ADDRESS, newOffset, 6);
if (sscanf(newOffset, "%*[$]%4X", &newAddress) != EOF)
{
char newName[NL_MAX_NAME_LEN + 1] = {0};
GetDlgItemText(hwndDlg, IDC_SYMBOLIC_NAME, newName, NL_MAX_NAME_LEN + 1);
char newComment[NL_MAX_MULTILINE_COMMENT_LEN + 1] = {0};
GetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, newComment, NL_MAX_MULTILINE_COMMENT_LEN + 1);
AddNewSymbolicName(newAddress, newOffset, newName, newComment);
unsigned int arraySize = 0;
unsigned int arrayInit = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_ARRAY) == BST_CHECKED)
{
char strArraySize[6] = { 0 };
GetDlgItemText(hwndDlg, IDC_EDIT_SYMBOLIC_ARRAY, strArraySize, 6);
if (*strArraySize)
sscanf(strArraySize, "%4X", &arraySize);
}
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_DELETE) == BST_UNCHECKED)
{
char newName[NL_MAX_NAME_LEN + 1] = { 0 };
GetDlgItemText(hwndDlg, IDC_SYMBOLIC_NAME, newName, NL_MAX_NAME_LEN + 1);
char newComment[NL_MAX_MULTILINE_COMMENT_LEN + 1] = { 0 };
GetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, newComment, NL_MAX_MULTILINE_COMMENT_LEN + 1);
char strArrayInit[6] = { 0 };
GetDlgItemText(hwndDlg, IDC_EDIT_SYMBOLIC_INIT, strArrayInit, 6);
if (*strArrayInit)
sscanf(strArrayInit, "%4X", &arrayInit);
AddNewSymbolicName(newAddress, newOffset, newName, newComment, arraySize, arrayInit, IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_NAME_OVERWRITE) == BST_CHECKED, IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD) == BST_CHECKED, IsDlgButtonChecked(hwndDlg, IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE) == BST_CHECKED);
} else
DeleteSymbolicName(newAddress, arraySize);
WriteNameFileToDisk(generateNLFilenameForAddress(newAddress), getNamesPointerForAddress(newAddress));
}
EndDialog(hwndDlg, 1);
@ -998,11 +1075,8 @@ bool DoSymbolicDebugNaming(int offset, HWND parentHWND)
return false;
}
void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment)
void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment, int size, int init, bool nameOverwrite, bool commentHeadOnly, bool commentOverwrite)
{
Name* initialNode = getNamesPointerForAddress(newAddress);
Name* node = initialNode;
// remove all delimiterChars from name and comment
char* pos = newName;
while (pos < newName + strlen(newName))
@ -1025,122 +1099,172 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
if (*newName || *newComment)
{
if (!initialNode)
{
// no previous data, create new list
node = (Name*)malloc(sizeof(Name));
node->offset = (char*)malloc(strlen(newOffset) + 1);
strcpy(node->offset, newOffset);
node->offsetNumeric = newAddress;
if (strlen(newName))
int i = 0;
char* tmpNewOffset = (char*)malloc(strlen(newOffset) + 1);
strcpy(tmpNewOffset, newOffset);
uint16 tmpNewAddress = newAddress;
int tmpInit = init;
do {
Name* node = getNamesPointerForAddress(tmpNewAddress);
if (!node)
{
node->name = (char*)malloc(strlen(newName) + 1);
strcpy(node->name, newName);
}
else
{
node->name = 0;
}
if (strlen(newComment))
{
node->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(node->comment, newComment);
} else
{
node->comment = 0;
}
node->next = 0;
setNamesPointerForAddress(newAddress, node);
} else
{
// search the list
while (node)
{
if (node->offsetNumeric == newAddress)
node = (Name*)malloc(sizeof(Name));
node->offset = (char*)malloc(strlen(tmpNewOffset) + 1);
strcpy(node->offset, tmpNewOffset);
node->offsetNumeric = tmpNewAddress;
// Node name
if (strlen(newName))
{
// found matching address - replace its name and comment
if (node->name)
free(node->name);
if (strlen(newName))
if (size)
{
char arr_index[16];
sprintf(arr_index, "[%X]", tmpInit);
node->name = (char*)malloc(strlen(newName) + strlen(arr_index) + 1);
strcpy(node->name, newName);
strcat(node->name, arr_index);
}
else
{
node->name = (char*)malloc(strlen(newName) + 1);
strcpy(node->name, newName);
} else
{
node->name = 0;
}
if (node->comment)
{
free(node->comment);
}
if (strlen(newComment))
{
node->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(node->comment, newComment);
} else
{
node->comment = 0;
}
break;
}
if (node->next)
else
node->name = 0;
if ((i == 0 || !commentHeadOnly) && strlen(newComment))
{
node = node->next;
} else
node->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(node->comment, newComment);
}
else
node->comment = 0;
node->next = 0;
setNamesPointerForAddress(tmpNewAddress, node);
}
else
{
while (node)
{
// this is the last node in the list - so just append the address
Name* newNode = (Name*)malloc(sizeof(Name));
node->next = newNode;
newNode->offset = (char*)malloc(strlen(newOffset) + 1);
strcpy(newNode->offset, newOffset);
newNode->offsetNumeric = newAddress;
if (strlen(newName))
if (node->offsetNumeric == tmpNewAddress)
{
newNode->name = (char*)malloc(strlen(newName) + 1);
strcpy(newNode->name, newName);
// found matching address, proccessing its name and comment based on the configuration
if ((i == 0 || nameOverwrite) && node->name)
{
free(node->name);
node->name = 0;
}
if (!node->name && strlen(newName))
{
if (size)
{
char arr_index[16];
sprintf(arr_index, "[%X]", tmpInit);
node->name = (char*)malloc(strlen(newName) + strlen(arr_index) + 1);
strcpy(node->name, newName);
strcat(node->name, arr_index);
}
else
{
node->name = (char*)malloc(strlen(newName) + 1);
strcpy(node->name, newName);
}
}
if ((i == 0 || !commentHeadOnly && commentOverwrite) && node->comment)
{
free(node->comment);
node->comment = 0;
}
if (!node->comment && strlen(newComment))
{
node->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(node->comment, newComment);
}
break;
}
if (node->next)
node = node->next;
else {
newNode->name = 0;
// this is the last node in the list - so just append the address
Name* newNode = (Name*)malloc(sizeof(Name));
newNode->offset = (char*)malloc(strlen(tmpNewOffset) + 1);
strcpy(newNode->offset, tmpNewOffset);
newNode->offsetNumeric = tmpNewAddress;
// Node name
if (strlen(newName))
{
if (size)
{
char arr_index[16];
sprintf(arr_index, "[%X]", tmpInit);
newNode->name = (char*)malloc(strlen(newName) + strlen(arr_index) + 1);
strcpy(newNode->name, newName);
strcat(newNode->name, arr_index);
}
else
{
newNode->name = (char*)malloc(strlen(newName) + 1);
strcpy(newNode->name, newName);
}
}
else
newNode->name = 0;
if ((i == 0 || !commentHeadOnly) && strlen(newComment))
{
newNode->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(newNode->comment, newComment);
}
else
newNode->comment = 0;
newNode->next = 0;
node->next = newNode;
break;
}
if (strlen(newComment))
{
newNode->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(newNode->comment, newComment);
} else {
newNode->comment = 0;
}
newNode->next = 0;
break;
}
}
}
} else
{
// name and comment field are all empty - remove the address from the list
Name* previousNode = 0;
++tmpNewAddress;
++tmpInit;
sprintf(tmpNewOffset, "$%04X", tmpNewAddress);
} while (++i < size);
}
}
void DeleteSymbolicName(uint16 address, int size)
{
int i = 0;
uint16 tmpAddress = address;
do {
Name* prev = 0;
Name* initialNode = getNamesPointerForAddress(tmpAddress);
Name* node = initialNode;
while (node)
{
if (node->offsetNumeric == newAddress)
if (node->offsetNumeric == tmpAddress)
{
// found matching address - delete it
if (node->offset)
free(node->offset);
if (node->name)
free(node->name);
if (node->comment)
free(node->comment);
if (previousNode)
previousNode->next = node->next;
if (prev)
prev->next = node->next;
if (node == initialNode)
setNamesPointerForAddress(newAddress, node->next);
setNamesPointerForAddress(tmpAddress, node->next);
free(node);
break;
}
previousNode = node;
prev = node;
node = node->next;
}
}
++tmpAddress;
} while (++i < size);
}
void WriteNameFileToDisk(const char* filename, Name* node)

View File

@ -64,5 +64,6 @@ void GoToDebuggerBookmark(HWND hwnd);
int isHex(char c);
bool DoSymbolicDebugNaming(int offset, HWND parentHWND);
void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment);
void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment, int size, int init, bool nameOverwrite, bool commentHeadOnly, bool commentOverwrite);
void DeleteSymbolicName(uint16 address, int size);
void WriteNameFileToDisk(const char* filename, Name* node);

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 res.rc 使用
// Microsoft Visual C++ generated include file.
// Used by res.rc
//
#define CLOSE_BUTTON 1
#define BUTTON_CLOSE 1
@ -510,6 +510,7 @@
#define IDC_CHECK1 1013
#define IDC_CHEAT_AUTOLOADSAVE 1013
#define IDC_CHECK_SHORTCUT 1013
#define IDC_CHECK_SYMBOLIC_ARRAY 1013
#define IDC_RESTORE_BUTTON 1014
#define MW_VAL04 1014
#define MW_NAME05 1015
@ -517,38 +518,50 @@
#define IDC_EDIT_SHORTCUT0 1016
#define MW_VAL05 1017
#define IDC_EDIT_SHORTCUT1 1017
#define IDC_CHECK_SYMBOLIC_DELETE 1017
#define IDC_PRGROM_COMBO 1018
#define MW_NAME06 1018
#define IDC_EDIT_SHORTCUT2 1018
#define IDC_EDIT_SYMBOLIC_ARRAY 1018
#define MW_ADDR06 1019
#define IDC_CHRROM_COMBO 1019
#define IDC_EDIT_SHORTCUT7 1019
#define IDC_RADIO_MIRR_HORIZONTAL 1020
#define MW_VAL06 1020
#define IDC_EDIT_SHORTCUT6 1020
#define IDC_STATIC_SYMBOLIC_NAME 1020
#define IDC_RADIO_MIRR_VERTICAL 1021
#define MW_NAME07 1021
#define IDC_EDIT6 1021
#define IDC_EDIT_SHORTCUT9 1021
#define IDC_STATIC_SYMBOLIC_COMMENT 1021
#define MW_ADDR07 1022
#define IDC_RADIO_MIRR_4SCREEN 1022
#define IDC_EDIT_SHORTCUT5 1022
#define IDC_STATIC_SYMBOLIC_ADDRESS 1022
#define MW_VAL07 1023
#define IDC_EDIT_SHORTCUT4 1023
#define IDC_CHECK_SYMBOLIC_COMMENT_ARRAY_HEAD 1023
#define IDC_CHECK_TRAINER 1024
#define MW_NAME08 1024
#define IDC_EDIT_SHORTCUT8 1024
#define IDC_CHECK_SYMBOLIC_COMMENT_OVERWRITE 1024
#define MW_ADDR08 1025
#define IDC_PRGRAM_COMBO 1025
#define IDC_EDIT_SHORTCUT3 1025
#define IDC_CHECK4 1025
#define IDC_MAPPER_COMBO 1026
#define MW_VAL08 1026
#define IDC_CHECK_SYMBOLIC_OVERWRITE_NAME 1026
#define IDC_CHECK_SYMBOLIC_NAME_OVERWRITE 1026
#define IDC_SUBMAPPER_EDIT 1027
#define MW_NAME09 1027
#define IDC_STATIC_SYMBOLIC_BYTE 1027
#define MW_ADDR09 1028
#define IDC_CHRRAM_COMBO 1028
#define IDC_PRGNVRAM_COMBO 1029
#define MW_VAL09 1029
#define IDC_STATIC_SYMBOLIC_INIT 1029
#define IDC_CHRNVRAM_COMBO 1030
#define MW_NAME10 1030
#define MW_ADDR10 1031
@ -890,6 +903,7 @@
#define IDC_CHEAT_LABEL_KNOWN 1316
#define IDC_BINARY 1317
#define IDC_GAME_GENIE_ADDR 1501
#define IDC_EDIT_SYMBOLIC_INIT 1502
#define MENU_INESHEADEREDITOR 40001
#define MENU_INPUT_BARCODE 40004
#define ID_BOOKMARKS_IMPORT 40005
@ -1191,9 +1205,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 311
#define _APS_NEXT_RESOURCE_VALUE 312
#define _APS_NEXT_COMMAND_VALUE 40009
#define _APS_NEXT_CONTROL_VALUE 1017
#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -3358,6 +3358,9 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
// Debugger -> Add breakpoint
case IDC_ADDBP_ADDR_START: case IDC_ADDBP_ADDR_END:
// Array Size, Init value in Symbolic Name in Debugger
case IDC_EDIT_SYMBOLIC_ARRAY: case IDC_EDIT_SYMBOLIC_INIT:
// Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat
case IDC_CHEAT_ADDR: case IDC_CHEAT_VAL: case IDC_CHEAT_COM:
case IDC_CHEAT_VAL_KNOWN: case IDC_CHEAT_VAL_NE_BY: