diff --git a/trunk/src/drivers/win/debugger.cpp b/trunk/src/drivers/win/debugger.cpp index 5aaea319..1a03730a 100644 --- a/trunk/src/drivers/win/debugger.cpp +++ b/trunk/src/drivers/win/debugger.cpp @@ -79,7 +79,7 @@ char debug_str[35000] = {0}; char debug_cdl_str[500] = {0}; char* debug_decoration_name; char* debug_decoration_comment; -char debug_str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0}; +char debug_str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; // this is used to keep track of addresses that lines of Disassembly window correspond to std::vector disassembly_addresses; @@ -385,15 +385,6 @@ BOOL CALLBACK AddbpCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) { -// ################################## Start of SP CODE ########################### - -// Changed size of str (TODO: Better calculation of max size) -// Changed the buffer size of str to 35000 - - symbDebugEnabled = IsDlgButtonChecked(hWnd, IDC_DEBUGGER_ENABLE_SYMBOLIC); - -// ################################## End of SP CODE ########################### - char chr[40] = {0}; int size; uint8 opcode[3]; @@ -450,19 +441,20 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) strcat(debug_str_decoration_comment, "\r\n"); debug_decoration_comment = debug_str_decoration_comment; // divide the debug_str_decoration_comment into strings (Comment1, Comment2, ...) - char* end_pos = strstr(debug_decoration_comment, "\r"); + char* end_pos = strstr(debug_decoration_comment, "\r\n"); while (end_pos) { end_pos[0] = 0; // set \0 instead of \r strcat(debug_str, "; "); strcat(debug_str, debug_decoration_comment); strcat(debug_str, "\r\n"); - end_pos += 2; - debug_decoration_comment = end_pos; - end_pos = strstr(debug_decoration_comment, "\r"); // we added one line to the disassembly window disassembly_addresses.push_back(addr); i++; + + end_pos += 2; + debug_decoration_comment = end_pos; + end_pos = strstr(end_pos, "\r\n"); } } } @@ -1373,81 +1365,90 @@ void LoadGameDebuggerData(HWND hwndDlg = hDebug) FillBreakList(hwndDlg); } +// returns the address, or EOF if selection cursor points to something else +int CheckClickingOnAnAddress() +{ + // debug_str contains the text in the disassembly window + int sel_start, sel_end; + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + // find the ":" or "$" before sel_start + int i = sel_start - 1; + for (; i > sel_start - 6; i--) + if (i >= 0 && debug_str[i] == ':' || debug_str[i] == '$') + break; + if (i > sel_start - 6) + { + char offsetBuffer[5]; + strncpy(offsetBuffer, debug_str + i + 1, 4); + offsetBuffer[4] = 0; + // invalidate the string if a space or \r is found + char* firstspace = strstr(offsetBuffer, " "); + if (!firstspace) + firstspace = strstr(offsetBuffer, "\r"); + if (!firstspace) + { + unsigned int offset; + if (sscanf(offsetBuffer, "%4X", &offset) != EOF) + { + // select the text + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 5)); + // send the address to "Seek To" field + SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PCSEEK, offsetBuffer); + // send the address to "Bookmark Add" field + SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, offsetBuffer); + return (int)offset; + } + } + } + return EOF; +} + BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_LBUTTONDBLCLK: { - // debug_str contains the text in the disassembly window - int sel_start, sel_end; - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - // find the ":" or "$" before sel_start - int i = sel_start - 1; - for (; i > sel_start - 6; i--) - if (i >= 0 && debug_str[i] == ':' || debug_str[i] == '$') - break; - if (i > sel_start - 6) + int offset = CheckClickingOnAnAddress(); + if (offset != EOF) { - char offsetBuffer[5]; - strncpy(offsetBuffer, debug_str + i + 1, 4); - offsetBuffer[4] = 0; - // invalidate the string if a space or \r is found - char* firstspace = strstr(offsetBuffer, " "); - if (!firstspace) - firstspace = strstr(offsetBuffer, "\r"); - if (!firstspace) - { - unsigned int offset; - if (sscanf(offsetBuffer, "%4X", &offset) != EOF) - { - // select the text - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 5)); - childwnd = 1; - if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, offset)) - AddBreakList(); - childwnd = 0; - UpdateDebugger(false); - } - } + // bring "Add Breakpoint" dialog + childwnd = 1; + if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, offset)) + AddBreakList(); + childwnd = 0; + UpdateDebugger(false); } return 0; } case WM_LBUTTONUP: { - // debug_str contains the text in the disassembly window + CheckClickingOnAnAddress(); + break; + } + case WM_RBUTTONDOWN: + { + // if nothing is selected, simulate Left-click int sel_start, sel_end; SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - // only continue if there's no selection in the Disassembly window if (sel_start == sel_end) { - // find the ":" or "$" before sel_start - int i = sel_start - 1; - for (; i > sel_start - 6; i--) - if (i >= 0 && debug_str[i] == ':' || debug_str[i] == '$') - break; - if (i > sel_start - 6) - { - char offsetBuffer[5] = {0}; - strncpy(offsetBuffer, debug_str + i + 1, 4); - offsetBuffer[4] = 0; - // truncate the string if a space or \r is found - char* firstspace = strstr(offsetBuffer, " "); - if (!firstspace) - firstspace = strstr(offsetBuffer, "\r"); - if (firstspace) - firstspace[0] = 0; - unsigned int offset; - if (sscanf(offsetBuffer, "%4X", &offset) != EOF) - { - // select the text - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 1 + strlen(offsetBuffer))); - // send the address to "Seek To" field - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PCSEEK, offsetBuffer); - // send the address to "Bookmark Add" field - SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, offsetBuffer); - } - } + CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); + CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); + return 0; + } + break; + } + case WM_RBUTTONUP: + { + // if nothing is selected, try bringing Symbolic Debug Naming dialog + int sel_start, sel_end; + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + if (sel_start == sel_end) + { + int offset = CheckClickingOnAnAddress(); + if (offset != EOF) + DoSymbolicDebugNaming(offset); } break; } @@ -2068,7 +2069,12 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case IDC_DEBUGGER_BOOKMARK_ADD: AddDebuggerBookmark(hwndDlg); break; case IDC_DEBUGGER_BOOKMARK_DEL: DeleteDebuggerBookmark(hwndDlg); break; case IDC_DEBUGGER_BOOKMARK_NAME: NameDebuggerBookmark(hwndDlg); break; - case IDC_DEBUGGER_ENABLE_SYMBOLIC: UpdateDebugger(false); break; + case IDC_DEBUGGER_ENABLE_SYMBOLIC: + { + symbDebugEnabled = IsDlgButtonChecked(hwndDlg, IDC_DEBUGGER_ENABLE_SYMBOLIC); + UpdateDebugger(false); + break; + } // ################################## End of SP CODE ########################### @@ -2132,11 +2138,13 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara extern void iNESGI(GI h); -void DoPatcher(int address,HWND hParent) +void DoPatcher(int address, HWND hParent) { - iapoffset=address; - if(GameInterface==iNESGI)DialogBox(fceu_hInstance,"ROMPATCHER",hParent,PatcherCallB); - else MessageBox(hDebug, "Sorry, The Patcher only works on INES rom images", "Error", MB_OK); + iapoffset = address; + if (GameInterface == iNESGI) + DialogBox(fceu_hInstance, "ROMPATCHER", hParent, PatcherCallB); + else + MessageBox(hDebug, "Sorry, The Patcher only works on INES rom images", "Error", MB_OK); UpdateDebugger(false); } diff --git a/trunk/src/drivers/win/debuggersp.cpp b/trunk/src/drivers/win/debuggersp.cpp index ded3f982..cdf73455 100644 --- a/trunk/src/drivers/win/debuggersp.cpp +++ b/trunk/src/drivers/win/debuggersp.cpp @@ -43,6 +43,7 @@ char NLfilename[2048]; char symbDebugEnabled = 0; int debuggerWasActive = 0; char temp_chr[40] = {0}; +char delimiterChar[2] = "#"; extern BOOL CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); extern char bookmarkDescription[]; @@ -131,7 +132,7 @@ int parseLine(char* line, Name* n) // Attempt to tokenize the given line - pos = strstr(line, "#"); + pos = strstr(line, delimiterChar); if (!pos) { @@ -194,7 +195,7 @@ int parseLine(char* line, Name* n) // Attempt to tokenize the string again to find the name of the address - pos = strstr(line, "#"); + pos = strstr(line, delimiterChar); if (!pos) { @@ -207,7 +208,7 @@ int parseLine(char* line, Name* n) if (*line) { if (strlen(line) > NL_MAX_NAME_LEN) - line[NL_MAX_NAME_LEN] = 0; + line[NL_MAX_NAME_LEN + 1] = 0; n->name = (char*)malloc(strlen(line) + 1); strcpy(n->name, line); } @@ -225,7 +226,15 @@ int parseLine(char* line, Name* n) if (*line > 0x0D) { if (strlen(line) > NL_MAX_MULTILINE_COMMENT_LEN) - line[NL_MAX_MULTILINE_COMMENT_LEN] = 0; + line[NL_MAX_MULTILINE_COMMENT_LEN + 1] = 0; + // remove all backslashes after \r\n + char* crlf_pos = strstr(line, "\r\n\\"); + while (crlf_pos) + { + strcpy(crlf_pos + 2, crlf_pos + 3); + crlf_pos = strstr(crlf_pos + 2, "\r\n\\"); + } + n->comment = (char*)malloc(strlen(line) + 1); strcpy(n->comment, line); } @@ -302,14 +311,8 @@ Name* parse(char* lines, const char* filename) { pos[0] = '\r'; pos[1] = '\n'; - pos += 2; - } - else - { - // Remove backslash - pos[1] = ' '; - pos += 1; } + pos += 2; } if (!pos) @@ -318,7 +321,10 @@ Name* parse(char* lines, const char* filename) break; } - *pos = 0; + if (pos[-1] == '\r') + pos[-1] = 0; + else + *pos = 0; // Attempt to parse the current line fail = parseLine(lines, cur); @@ -540,6 +546,46 @@ Name* searchNode(Name* node, const char* offs) return 0; } +char* generateNLFilenameForAddress(unsigned int address) +{ + if (address < 0x8000) + { + // The NL file for the RAM addresses has the name nesrom.nes.ram.nl + strcpy(NLfilename, mass_replace(LoadedRomFName, "|", ".").c_str()); + strcat(NLfilename, ".ram.nl"); + } else + { + sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), getBank(address)); + } + return NLfilename; +} +Name* getNamesPointerForAddress(unsigned int address) +{ + if (address < 0x8000) + { + return ramBankNames; + } else if (address < 0xC000) + { + return loadedBankNames; + } else + { + return lastBankNames; + } +} +void setNamesPointerForAddress(unsigned int address, Name* newNode) +{ + if (address < 0x8000) + { + ramBankNames = newNode; + } else if (address < 0xC000) + { + loadedBankNames = newNode; + } else + { + lastBankNames = newNode; + } +} + /** * Loads the necessary NL files **/ @@ -554,12 +600,8 @@ void loadNameFiles() if (ramBankNames) free(ramBankNames); - // The NL file for the RAM addresses has the name nesrom.nes.ram.nl - strcpy(NLfilename, mass_replace(LoadedRomFName, "|", ".").c_str()); - strcat(NLfilename, ".ram.nl"); - // Load the address descriptions for the RAM addresses - ramBankNames = parseNameFile(NLfilename); + ramBankNames = parseNameFile(generateNLFilenameForAddress(0x0000)); } // Find out which bank is loaded at 0xC000 @@ -574,14 +616,11 @@ void loadNameFiles() // to load the address descriptions of the new bank. lastBank = cb; - // Get the name of the NL file - sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), lastBank); - if (lastBankNames) freeList(lastBankNames); // Load new address definitions - lastBankNames = parseNameFile(NLfilename); + lastBankNames = parseNameFile(generateNLFilenameForAddress(0xC000)); } // Find out which bank is loaded at 0x8000 @@ -597,14 +636,11 @@ void loadNameFiles() loadedBank = cb; - // Get the name of the NL file - sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), loadedBank); - if (loadedBankNames) freeList(loadedBankNames); // Load new address definitions - loadedBankNames = parseNameFile(NLfilename); + loadedBankNames = parseNameFile(generateNLFilenameForAddress(0x8000)); } } @@ -624,7 +660,7 @@ void decorateAddress(unsigned int addr, char** str_name, char** str_comment) } else { // Search address definition node for a ROM address - n = addr >= 0xC000 ? searchNode(lastBankNames, temp_chr) : searchNode(loadedBankNames, temp_chr); + n = (addr >= 0xC000) ? searchNode(lastBankNames, temp_chr) : searchNode(loadedBankNames, temp_chr); } if (n) @@ -801,3 +837,233 @@ void GoToDebuggerBookmark(HWND hwnd) unsigned int n = getBookmarkAddress(selectedItem); Disassemble(hwnd, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, n); } + +BOOL CALLBACK SymbolicNamingCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + CenterWindow(hwndDlg); + unsigned int newAddress = lParam; + // filename + generateNLFilenameForAddress(newAddress); + SetDlgItemText(hwndDlg, IDC_SYMBOLIC_FILENAME, NLfilename); + // offset + sprintf(temp_chr, "$%04X", newAddress); + SetDlgItemText(hwndDlg, IDC_SYMBOLIC_ADDRESS, temp_chr); + char* oldName = 0; + char* oldComment = 0; + decorateAddress(newAddress, &oldName, &oldComment); + // name + SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_NAME, EM_SETLIMITTEXT, NL_MAX_NAME_LEN, 0); + if (oldName && oldName[0]) + SetDlgItemText(hwndDlg, IDC_SYMBOLIC_NAME, oldName); + // comment + SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_COMMENT, EM_SETLIMITTEXT, NL_MAX_MULTILINE_COMMENT_LEN, 0); + if (oldComment && oldComment[0]) + SetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, oldComment); + // set focus to IDC_SYMBOLIC_NAME + SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwndDlg, IDC_SYMBOLIC_NAME), true); + break; + } + case WM_CLOSE: + case WM_QUIT: + break; + case WM_COMMAND: + { + switch(HIWORD(wParam)) + { + case BN_CLICKED: + { + switch(LOWORD(wParam)) + { + case IDOK: + { + unsigned int newAddress = 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); + WriteNameFileToDisk(generateNLFilenameForAddress(newAddress), getNamesPointerForAddress(newAddress)); + } + EndDialog(hwndDlg, 1); + break; + } + case IDCANCEL: + { + EndDialog(hwndDlg, 0); + break; + } + } + break; + } + } + break; + } + } + return FALSE; +} + +void DoSymbolicDebugNaming(int offset) +{ + loadNameFiles(); + childwnd = 1; + if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_SYMBOLIC_DEBUG_NAMING), hDebug, SymbolicNamingCallB, offset)) + { + + symbDebugEnabled = true; + CheckDlgButton(hDebug, IDC_DEBUGGER_ENABLE_SYMBOLIC, BST_CHECKED); + UpdateDebugger(false); + } + childwnd = 0; +} + +void AddNewSymbolicName(unsigned int newAddress, char* newOffset, char* newName, char* newComment) +{ + Name* initialNode = getNamesPointerForAddress(newAddress); + Name* node = initialNode; + + // remove all delimiterChars from name and comment + char* pos = newName; + while (pos < newName + strlen(newName)) + { + pos = strstr(pos, delimiterChar); + if (pos) + strcpy(pos, pos + 1); + else + break; + } + pos = newComment; + while (pos < newComment + strlen(newComment)) + { + pos = strstr(pos, delimiterChar); + if (pos) + strcpy(pos, pos + 1); + else + break; + } + + if (newName[0]) + { + 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->name = (char*)malloc(strlen(newName) + 1); + strcpy(node->name, newName); + node->comment = (char*)malloc(strlen(newComment) + 1); + strcpy(node->comment, newComment); + node->next = 0; + setNamesPointerForAddress(newAddress, node); + } else + { + // search the list + while (node) + { + if (!strcmp(node->offset, newOffset)) + { + // found matching address - replace its name and comment + free(node->name); + node->name = (char*)malloc(strlen(newName) + 1); + strcpy(node->name, newName); + free(node->comment); + node->comment = (char*)malloc(strlen(newComment) + 1); + strcpy(node->comment, newComment); + break; + } + if (node->next) + { + node = node->next; + } else + { + // 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->name = (char*)malloc(strlen(newName) + 1); + strcpy(newNode->name, newName); + newNode->comment = (char*)malloc(strlen(newComment) + 1); + strcpy(newNode->comment, newComment); + newNode->next = 0; + break; + } + } + } + } else + { + // name field is empty - remove the address from the list + Name* previousNode = 0; + while (node) + { + if (!strcmp(node->offset, newOffset)) + { + // found matching address - delete it + free(node->offset); + free(node->name); + free(node->comment); + if (previousNode) + previousNode->next = node->next; + if (node == initialNode) + setNamesPointerForAddress(newAddress, node->next); + free(node); + break; + } + previousNode = node; + node = node->next; + } + } +} + +void WriteNameFileToDisk(const char* filename, Name* node) +{ + FILE* f = fopen(filename, "wb"); + char tempComment[NL_MAX_MULTILINE_COMMENT_LEN + 10]; + if (f) + { + char tempString[10 + 1 + NL_MAX_NAME_LEN + 1 + NL_MAX_MULTILINE_COMMENT_LEN + 1]; + while (node) + { + strcpy(tempString, node->offset); + strcat(tempString, delimiterChar); + if (node->name) + strcat(tempString, node->name); + strcat(tempString, delimiterChar); + if (node->comment) + { + // dump multiline comment + strcpy(tempComment, node->comment); + char* remainder_pos = tempComment; + char* crlf_pos = strstr(tempComment, "\r\n"); + while (crlf_pos) + { + *crlf_pos = 0; + strcat(tempString, remainder_pos); + strcat(tempString, "\r\n\\"); + crlf_pos = remainder_pos = crlf_pos + 2; + crlf_pos = strstr(crlf_pos, "\r\n"); + } + strcat(tempString, remainder_pos); + strcat(tempString, "\r\n"); + } else + { + strcat(tempString, "\r\n"); + } + // write to the file + fwrite(tempString, 1, strlen(tempString), f); + node = node->next; + } + fclose(f); + } +} + + diff --git a/trunk/src/drivers/win/debuggersp.h b/trunk/src/drivers/win/debuggersp.h index 81ad2639..4f8e7b7c 100644 --- a/trunk/src/drivers/win/debuggersp.h +++ b/trunk/src/drivers/win/debuggersp.h @@ -38,6 +38,9 @@ extern std::vector bookmarks_name; extern int debuggerWasActive; int checkCondition(const char* buffer, int num); +char* generateNLFilenameForAddress(unsigned int address); +Name* getNamesPointerForAddress(unsigned int address); +void setNamesPointerForAddress(unsigned int address, Name* newNode); void loadNameFiles(); void decorateAddress(unsigned int addr, char** str_name, char** str_comment); void replaceNames(Name* list, char* str); @@ -50,3 +53,7 @@ void FillDebuggerBookmarkListbox(HWND hwnd); void GoToDebuggerBookmark(HWND hwnd); int isHex(char c); + +void DoSymbolicDebugNaming(int offset); +void AddNewSymbolicName(unsigned int newAddress, char* newOffset, char* newName, char* newComment); +void WriteNameFileToDisk(const char* filename, Name* node); diff --git a/trunk/src/drivers/win/memview.cpp b/trunk/src/drivers/win/memview.cpp index 1d471a93..f00eb822 100644 --- a/trunk/src/drivers/win/memview.cpp +++ b/trunk/src/drivers/win/memview.cpp @@ -638,29 +638,13 @@ void UpdateCaption() sprintf(addrName, "$%04X", CursorStartAddy); strcpy(addrNameCopy, addrName); // try to find the name for this address in loadedBankNames - replaceNames(ramBankNames, addrName); + replaceNames(getNamesPointerForAddress(CursorStartAddy), addrName); + // check if anything chenged in this string if (strcmp(addrName, addrNameCopy)) { + // changes found, so the string was decorated by symbolic name - then output it strcat(str, " - "); strcat(str, addrName); - } else - { - // name was not found in ramBankNames, try loadedBankNames - replaceNames(loadedBankNames, addrName); - if (strcmp(addrName, addrNameCopy)) - { - strcat(str, " - "); - strcat(str, addrName); - } else - { - // name was not found in ramBankNames, try loadedBankNames - replaceNames(lastBankNames, addrName); - if (strcmp(addrName, addrNameCopy)) - { - strcat(str, " - "); - strcat(str, addrName); - } - } } } } else diff --git a/trunk/src/drivers/win/res.rc b/trunk/src/drivers/win/res.rc index ecf8821a..04355d4d 100644 --- a/trunk/src/drivers/win/res.rc +++ b/trunk/src/drivers/win/res.rc @@ -2193,6 +2193,23 @@ BEGIN GROUPBOX "Settings",IDC_STATIC,6,4,91,177 END +IDD_SYMBOLIC_DEBUG_NAMING DIALOGEX 0, 0, 245, 83 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Symbolic Debug Naming" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,132,62,50,14 + PUSHBUTTON "Cancel",IDCANCEL,189,62,50,14 + LTEXT "File",IDC_STATIC,7,7,15,9 + EDITTEXT IDC_SYMBOLIC_ADDRESS,38,24,33,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP + LTEXT "Address",IDC_STATIC,6,26,30,10 + EDITTEXT IDC_SYMBOLIC_NAME,107,24,132,13,ES_AUTOHSCROLL + LTEXT "Name",IDC_STATIC,83,26,22,10 + LTEXT "Comment",IDC_STATIC,6,45,37,10 + EDITTEXT IDC_SYMBOLIC_COMMENT,45,43,194,13,ES_AUTOHSCROLL + EDITTEXT IDC_SYMBOLIC_FILENAME,24,6,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP +END + ///////////////////////////////////////////////////////////////////////////// // @@ -2205,6 +2222,11 @@ BEGIN IDD_TASEDITOR_SAVINGOPTIONS, DIALOG BEGIN END + + IDD_SYMBOLIC_DEBUG_NAMING, DIALOG + BEGIN + BOTTOMMARGIN, 82 + END END #endif // APSTUDIO_INVOKED diff --git a/trunk/src/drivers/win/resource.h b/trunk/src/drivers/win/resource.h index b8cfe5b7..11a9be86 100644 --- a/trunk/src/drivers/win/resource.h +++ b/trunk/src/drivers/win/resource.h @@ -361,6 +361,7 @@ #define IDB_BITMAP_SELECTED18 287 #define IDB_BITMAP_SELECTED19 288 #define IDD_TASEDITOR_SAVINGOPTIONS 289 +#define IDD_SYMBOLIC_DEBUG_NAMING 290 #define MENU_HIDE_MENU 300 #define COMBO_FILTER 300 #define IDC_EDIT_AUTHORINFO 300 @@ -573,9 +574,14 @@ #define IDC_AUTOSAVE_PERIOD 1147 #define IDC_BUTTON9 1148 #define TASEDITOR_FIND_NEXT_SIMILAR_MARKER 1148 +#define IDC_SYMBOLIC_ADDRESS 1148 #define IDC_HISTORYLIST 1149 +#define IDC_SYMBOLIC_NAME 1149 #define IDC_BOOKMARKSLIST 1150 +#define IDC_SYMBOLIC_ADDRESS2 1150 +#define IDC_SYMBOLIC_FILENAME 1150 #define TASEDITOR_NEXT_MARKER 1151 +#define IDC_SYMBOLIC_COMMENT 1151 #define IDC_BRANCHES_BUTTON 1152 #define IDC_JUMP_PLAYBACK_BUTTON 1153 #define IDC_EDIT2 1154 @@ -1202,9 +1208,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 290 +#define _APS_NEXT_RESOURCE_VALUE 291 #define _APS_NEXT_COMMAND_VALUE 40589 -#define _APS_NEXT_CONTROL_VALUE 1289 +#define _APS_NEXT_CONTROL_VALUE 1290 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/trunk/src/drivers/win/tracer.cpp b/trunk/src/drivers/win/tracer.cpp index 096c65a8..7a7cc13e 100644 --- a/trunk/src/drivers/win/tracer.cpp +++ b/trunk/src/drivers/win/tracer.cpp @@ -77,8 +77,8 @@ char str_result[LOG_LINE_MAX_LEN] = {0}; char str_temp[LOG_LINE_MAX_LEN] = {0}; char* tracer_decoration_name; char* tracer_decoration_comment; -char str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0}; -char str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0}; +char str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; +char str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; bool log_old_emu_paused = true; // thanks to this flag the window only updates once after the game is paused extern bool JustFrameAdvanced; @@ -452,7 +452,7 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size) strcat(str_decoration_comment, "\r\n"); tracer_decoration_comment = str_decoration_comment; // divide the str_decoration_comment into strings (Comment1, Comment2, ...) - char* end_pos = strstr(tracer_decoration_comment, "\r"); + char* end_pos = strstr(tracer_decoration_comment, "\r\n"); while (end_pos) { end_pos[0] = 0; // set \0 instead of \r @@ -461,7 +461,7 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size) OutputLogLine(str_decoration, true); end_pos += 2; tracer_decoration_comment = end_pos; - end_pos = strstr(tracer_decoration_comment, "\r"); + end_pos = strstr(end_pos, "\r\n"); } } replaceNames(ramBankNames, a);