* Hexeditor: show symbolic names in the window caption

This commit is contained in:
ansstuff 2013-02-22 21:17:34 +00:00
parent 71f2d5bc9c
commit 71f4affe5c
2 changed files with 51 additions and 8 deletions

View File

@ -67,7 +67,8 @@ int isHex(char c)
**/ **/
void replaceString(char* src, const char* r, const char* w) void replaceString(char* src, const char* r, const char* w)
{ {
char buff[1001] = {0}; static char buff[1001];
buff[0] = 0;
char* pos = src; char* pos = src;
char* beg = src; char* beg = src;

View File

@ -31,6 +31,7 @@
#include "debugger.h" #include "debugger.h"
#include "cdlogger.h" #include "cdlogger.h"
#include "memviewsp.h" #include "memviewsp.h"
#include "debuggersp.h"
#include "cheat.h" #include "cheat.h"
#include <assert.h> #include <assert.h>
#include "main.h" #include "main.h"
@ -38,6 +39,10 @@
#include "help.h" #include "help.h"
#include "Win32InputBox.h" #include "Win32InputBox.h"
extern Name* lastBankNames;
extern Name* loadedBankNames;
extern Name* ramBankNames;
using namespace std; using namespace std;
#define MODE_NES_MEMORY 0 #define MODE_NES_MEMORY 0
@ -540,16 +545,53 @@ void UpdateMemoryView(int draw_all)
return; return;
} }
char EditString[3][20] = {"RAM","PPU","ROM"};
void UpdateCaption() void UpdateCaption()
{ {
char str[100]; static char str[1000];
char EditString[3][20] = {"RAM","PPU","ROM"}; static char addrName[1000];
static char addrNameCopy[1000];
if(CursorEndAddy == -1){ if (CursorEndAddy == -1)
sprintf(str,"Hex Editor - %s Offset 0x%06x",EditString[EditingMode],CursorStartAddy); {
} else { sprintf(str, "Hex Editor - %s Offset 0x%06x",
sprintf(str,"Hex Editor - %s Offset 0x%06x - 0x%06x, 0x%x bytes selected ", EditString[EditingMode], CursorStartAddy);
EditString[EditingMode],CursorStartAddy,CursorEndAddy,CursorEndAddy-CursorStartAddy+1); if (EditingMode == 0 && symbDebugEnabled)
{
// when watching RAM we may as well see symbolic names
sprintf(addrName, "$%04X", CursorStartAddy);
strcpy(addrNameCopy, addrName);
// try to find the name for this address in loadedBankNames
replaceNames(ramBankNames, addrName);
if (strcmp(addrName, addrNameCopy))
{
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
{
sprintf(str, "Hex Editor - %s Offset 0x%06x - 0x%06x, 0x%x bytes selected ",
EditString[EditingMode], CursorStartAddy, CursorEndAddy, CursorEndAddy - CursorStartAddy + 1);
} }
SetWindowText(hMemView,str); SetWindowText(hMemView,str);
return; return;