1. Fix an ancient bug: .deb file doesn't store edit mode for Hex Editor, when the next time it launches, all the bookmarks are treated as RAM bookmarks.
Since this bug was forgotten by developers for years, saving the missing data along with the other preferences would make the emulator backward incompatible. So I finally decided to append them to the end of the preferences. The older version of FCEUX didn't read/write the .deb file that far, they would stop earlier though the file created by the newer version has more data, because they don't have the appended code. I hope this modification doesn't break anything as I've tried my best to prevent incompatibilities. We're facing a difficult choice here, fortunately, it looks like the preferences of Hex Editor stores at last of .deb, so I can just append information in the function. However what could we do if someday someone found a bug in the middle of the deb file such as debuggers etc? As we can only append data, the functions have to be split into more parts, which is damage to the code maintainability and readability. The problems can't be easily resolved as far as I can think, although currently it is possible to make it work without too much problems. 2. Improved Bookmark Editing Dialog of Hex Editor, now it can edit almost all properties the bookmark has, you can directly change its address and even its view. 3. Changed some logic of debugger bookmark, the address can be directly changed in the dialog. 4. Decoupled Debugger and Hex Editor bookmark editing dialogs and callback functions from sharing one dialog, as they are not in the same system, the differences is worth to make them apart. 5. Disabled input barcode menu in movie recording and no game loading. 6. Detail.
This commit is contained in:
parent
8388d4025f
commit
1f42929f4f
|
@ -2359,7 +2359,7 @@ INT_PTR CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
}
|
||||
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_BOOKMARK_EDIT: EditDebuggerBookmark(hwndDlg); break;
|
||||
case IDC_DEBUGGER_ENABLE_SYMBOLIC:
|
||||
{
|
||||
symbDebugEnabled ^= 1;
|
||||
|
|
|
@ -62,7 +62,9 @@ int debuggerWasActive = 0;
|
|||
char temp_chr[40] = {0};
|
||||
char delimiterChar[2] = "#";
|
||||
|
||||
extern INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
extern WNDPROC DefaultEditCtrlProc;
|
||||
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT uMsg, WPARAM wP, LPARAM lP);
|
||||
|
||||
MemoryMappedRegister RegNames[] = {
|
||||
{"$2000", "PPU_CTRL"},
|
||||
|
@ -768,28 +770,6 @@ unsigned int getBookmarkAddress(unsigned int index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a debugger bookmark to the list on the debugger window.
|
||||
*
|
||||
* @param hwnd HWMD of the debugger window
|
||||
* @param buffer Text of the debugger bookmark
|
||||
**/
|
||||
void AddDebuggerBookmark2(HWND hwnd, unsigned int addr)
|
||||
{
|
||||
int index = bookmarks.size();
|
||||
// try to find Symbolic name for this address
|
||||
Name* node = findNode(getNamesPointerForAddress(addr), addr);
|
||||
std::pair<unsigned int, std::string> bookmark(addr, node && node->name ? node->name : "");
|
||||
bookmarks.push_back(bookmark);
|
||||
|
||||
// add new item to ListBox
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%04X %s", bookmark.first, bookmark.second.c_str());
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer);
|
||||
// select this item
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, index, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the offset from the debugger bookmark edit field and adds a debugger
|
||||
* bookmark with that offset to the bookmark list if the offset is valid.
|
||||
|
@ -798,18 +778,44 @@ void AddDebuggerBookmark2(HWND hwnd, unsigned int addr)
|
|||
**/
|
||||
void AddDebuggerBookmark(HWND hwnd)
|
||||
{
|
||||
int n;
|
||||
char buffer[5] = {0};
|
||||
|
||||
GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5);
|
||||
n = offsetStringToInt(BT_C, buffer);
|
||||
int address = offsetStringToInt(BT_C, buffer);
|
||||
// Make sure the offset is valid
|
||||
if (n == -1 || n > 0xFFFF)
|
||||
if (address == -1 || address > 0xFFFF)
|
||||
{
|
||||
MessageBox(hwnd, "Invalid offset", "Error", MB_OK | MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
AddDebuggerBookmark2(hwnd, n);
|
||||
/*
|
||||
int index = 0;
|
||||
for (std::vector<std::pair<unsigned int, std::string>>::iterator it = bookmarks.begin(); it != bookmarks.end(); ++it)
|
||||
{
|
||||
if (it->first == address)
|
||||
{
|
||||
// select this bookmark to notify it already have a bookmark
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, index, 0);
|
||||
return;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
*/
|
||||
|
||||
int index = bookmarks.size();
|
||||
// try to find Symbolic name for this address
|
||||
Name* node = findNode(getNamesPointerForAddress(address), address);
|
||||
std::pair<unsigned int, std::string> bookmark(address, node && node->name ? node->name : "");
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLGDEBUGGER", hwnd, nameDebuggerBookmarkCallB, (LPARAM)&bookmark))
|
||||
{
|
||||
bookmarks.push_back(bookmark);
|
||||
// add new item to ListBox
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%04X %s", bookmark.first, bookmark.second.c_str());
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer);
|
||||
// select this item
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, index, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -841,7 +847,7 @@ void DeleteDebuggerBookmark(HWND hwnd)
|
|||
}
|
||||
}
|
||||
|
||||
void NameDebuggerBookmark(HWND hwnd)
|
||||
void EditDebuggerBookmark(HWND hwnd)
|
||||
{
|
||||
// Get the selected bookmark
|
||||
int selectedItem = SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETCURSEL, 0, 0);
|
||||
|
@ -865,7 +871,7 @@ void NameDebuggerBookmark(HWND hwnd)
|
|||
}
|
||||
}
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&bookmark))
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLGDEBUGGER", hwnd, nameDebuggerBookmarkCallB, (LPARAM)&bookmark))
|
||||
{
|
||||
// Rename the selected bookmark
|
||||
bookmarks[selectedItem] = bookmark;
|
||||
|
@ -1159,4 +1165,88 @@ void WriteNameFileToDisk(const char* filename, Name* node)
|
|||
}
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static std::pair<unsigned int, std::string>* debuggerBookmark;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
// Limit bookmark descriptions to 50 characters
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETLIMITTEXT, 50, 0);
|
||||
|
||||
// Limit the address text
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_ADDRESS, EM_SETLIMITTEXT, 4, 0);
|
||||
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS), GWLP_WNDPROC, (LONG_PTR)FilterEditCtrlProc);
|
||||
|
||||
debuggerBookmark = (std::pair<unsigned int, std::string>*)lParam;
|
||||
char addr[8];
|
||||
sprintf(addr, "%04X", debuggerBookmark->first);
|
||||
|
||||
// Set address and description
|
||||
sprintf(addr, "%04X", debuggerBookmark->first);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_ADDRESS, addr);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, debuggerBookmark->second.c_str());
|
||||
|
||||
// Set focus to the edit field.
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION));
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETSEL, 0, 52);
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_QUIT:
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwndDlg, 0);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (HIWORD(wParam))
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
char addr_str[8];
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_ADDRESS, addr_str, 8);
|
||||
sscanf(addr_str, "%X", &debuggerBookmark->first);
|
||||
|
||||
if (debuggerBookmark->first > 0xFFFE)
|
||||
{
|
||||
// if the address is out of range
|
||||
char errmsg[64];
|
||||
sprintf(errmsg, "The address must be in range of 0-%X", 0xFFFE);
|
||||
MessageBox(hwndDlg, errmsg, "Address out of range", MB_OK | MB_ICONERROR);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
extern std::vector<std::pair<unsigned int, std::string>> bookmarks;
|
||||
for (std::vector<std::pair<unsigned int, std::string>>::iterator it = bookmarks.begin(); it != bookmarks.end(); ++it)
|
||||
{
|
||||
if (it->first == debuggerBookmark->first && it->second == debuggerBookmark->second)
|
||||
{
|
||||
// if the address already have a bookmark
|
||||
MessageBox(hwndDlg, "This address already have a bookmark", "Bookmark duplicated", MB_OK | MB_ICONASTERISK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Update the description
|
||||
char description[51];
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description, 50);
|
||||
debuggerBookmark->second = description;
|
||||
EndDialog(hwndDlg, 1);
|
||||
break;
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,8 @@ void setNamesPointerForAddress(uint16 address, Name* newNode);
|
|||
void loadNameFiles();
|
||||
void replaceNames(Name* list, char* str, std::vector<uint16>* addressesLog = 0);
|
||||
void AddDebuggerBookmark(HWND hwnd);
|
||||
void AddDebuggerBookmark2(HWND hwnd, unsigned int addr);
|
||||
void DeleteDebuggerBookmark(HWND hwnd);
|
||||
void NameDebuggerBookmark(HWND hwnd);
|
||||
void EditDebuggerBookmark(HWND hwnd);
|
||||
void DeleteAllDebuggerBookmarks();
|
||||
void FillDebuggerBookmarkListbox(HWND hwnd);
|
||||
|
||||
|
|
|
@ -615,7 +615,7 @@ void UpdateMemoryView(int draw_all)
|
|||
return;
|
||||
}
|
||||
|
||||
char EditString[4][20] = {"RAM","PPU","OAM","ROM"};
|
||||
char* EditString[4] = {"RAM","PPU","OAM","ROM"};
|
||||
|
||||
void UpdateCaption()
|
||||
{
|
||||
|
@ -1255,6 +1255,19 @@ void KillMemView()
|
|||
return;
|
||||
}
|
||||
|
||||
int GetMaxSize(int EditingMode)
|
||||
{
|
||||
switch (EditingMode)
|
||||
{
|
||||
case MODE_NES_MEMORY: return 0x10000;
|
||||
case MODE_NES_PPU: return (GameInfo->type == GIT_NSF ? 0x2000 : 0x4000);
|
||||
case MODE_NES_OAM: return 0x100;
|
||||
case MODE_NES_FILE: return 16 + CHRsize[0] + PRGsize[0]; //todo: add trainer size
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
|
@ -2162,17 +2175,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
break;
|
||||
}
|
||||
|
||||
switch (EditingMode)
|
||||
{
|
||||
case MODE_NES_MEMORY:
|
||||
MaxSize = 0x10000; break;
|
||||
case MODE_NES_PPU:
|
||||
MaxSize = (GameInfo->type == GIT_NSF ? 0x2000 : 0x4000); break;
|
||||
case MODE_NES_OAM:
|
||||
MaxSize = 0x100; break;
|
||||
case MODE_NES_FILE: //todo: add trainer size
|
||||
MaxSize = 16 + CHRsize[0] + PRGsize[0]; break;
|
||||
}
|
||||
MaxSize = GetMaxSize(EditingMode);
|
||||
|
||||
if (CurOffset >= MaxSize - DataAmount) CurOffset = MaxSize - DataAmount;
|
||||
if (CurOffset < 0) CurOffset = 0;
|
||||
|
|
|
@ -16,4 +16,4 @@ void SetHexEditorAddress(int gotoaddress);
|
|||
extern HWND hMemView, hMemFind;
|
||||
extern int EditingMode;
|
||||
|
||||
extern char EditString[4][20];
|
||||
extern char* EditString[4];
|
|
@ -62,15 +62,11 @@ BOOL CenterWindow(HWND hwndDlg);
|
|||
but different bookmark systems, either decouple their callback into separate
|
||||
functions or unify them to use the same bookmark system.
|
||||
*/
|
||||
INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// For Hex Editor
|
||||
static HexBookmarkMsg* hexBookmarkMsg;
|
||||
static int dlgShortcutRadioCheck[10] = { IDC_RADIO_SHORTCUT0, IDC_RADIO_SHORTCUT1, IDC_RADIO_SHORTCUT2, IDC_RADIO_SHORTCUT3, IDC_RADIO_SHORTCUT4, IDC_RADIO_SHORTCUT5, IDC_RADIO_SHORTCUT6, IDC_RADIO_SHORTCUT7, IDC_RADIO_SHORTCUT8, IDC_RADIO_SHORTCUT9 };
|
||||
|
||||
// For Debugger
|
||||
extern HWND hDebug;
|
||||
static std::pair<unsigned int, std::string>* debuggerBookmark;
|
||||
int dlgShortcutRadioCheck[10] = { IDC_RADIO_SHORTCUT0, IDC_RADIO_SHORTCUT1, IDC_RADIO_SHORTCUT2, IDC_RADIO_SHORTCUT3, IDC_RADIO_SHORTCUT4, IDC_RADIO_SHORTCUT5, IDC_RADIO_SHORTCUT6, IDC_RADIO_SHORTCUT7, IDC_RADIO_SHORTCUT8, IDC_RADIO_SHORTCUT9 };
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
|
@ -79,60 +75,51 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
// Limit bookmark descriptions to 50 characters
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETLIMITTEXT, 50, 0);
|
||||
|
||||
// Put the current bookmark description into the edit field
|
||||
HWND parent = GetParent(hwndDlg);
|
||||
|
||||
char addr[5];
|
||||
const char* description;
|
||||
// Called from Hex Editor
|
||||
if (parent == hMemView)
|
||||
// Limit the address text
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_ADDRESS, EM_SETLIMITTEXT, 6, 0);
|
||||
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS), GWLP_WNDPROC, (LONG_PTR)FilterEditCtrlProc);
|
||||
|
||||
// Add View list box
|
||||
for (int i = 0; i < 4; ++i)
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_COMBO_VIEW, CB_INSERTSTRING, -1, (LPARAM)EditString[i]);
|
||||
|
||||
hexBookmarkMsg = (HexBookmarkMsg*)lParam;
|
||||
HexBookmark* hexBookmark = hexBookmarkMsg->bookmark;
|
||||
|
||||
bool shortcut_assigned = hexBookmarkMsg->shortcut_index != -1;
|
||||
if (shortcut_assigned)
|
||||
{
|
||||
hexBookmarkMsg = (HexBookmarkMsg*)lParam;
|
||||
HexBookmark* hexBookmark = hexBookmarkMsg->bookmark;
|
||||
sprintf(addr, "%04X", hexBookmark->address);
|
||||
description = hexBookmark->description;
|
||||
|
||||
bool shortcut_assigned = hexBookmarkMsg->shortcut_index != -1;
|
||||
if (shortcut_assigned)
|
||||
{
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_SHORTCUT, BST_CHECKED);
|
||||
CheckDlgButton(hwndDlg, dlgShortcutRadioCheck[hexBookmarkMsg->shortcut_index], BST_CHECKED);
|
||||
}
|
||||
else
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), FALSE);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (!shortcut_assigned || hexBookmarkShortcut[i] != -1 && hexBookmarkShortcut[i] != hexBookmarkMsg->bookmark_index)
|
||||
// the shortcut number is occupied but it doesn't belongs to this bookmark, or the bookmark doesn't have a shortcut
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), FALSE);
|
||||
|
||||
if (!shortcut_assigned && numHexBookmarkShortcut >= 10)
|
||||
{
|
||||
// all the shortcuts are occupied and this one doesn't have a shortcut, it's impossible to assign a new shortcut
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SHORTCUT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), FALSE);
|
||||
}
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_SHORTCUT, BST_CHECKED);
|
||||
CheckDlgButton(hwndDlg, dlgShortcutRadioCheck[hexBookmarkMsg->shortcut_index], BST_CHECKED);
|
||||
}
|
||||
// Called from Debugger
|
||||
else if (parent == hDebug)
|
||||
{
|
||||
debuggerBookmark = (std::pair<unsigned int, std::string>*)lParam;
|
||||
sprintf(addr, "%04X", debuggerBookmark->first);
|
||||
description = debuggerBookmark->second.c_str();
|
||||
else
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), FALSE);
|
||||
|
||||
// Hide the shortcut panel since it doesn't support jump to address shortcut keys.
|
||||
ShowWindow(GetDlgItem(hwndDlg, IDC_CHECK_SHORTCUT), SW_HIDE);
|
||||
ShowWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), SW_HIDE);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
ShowWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), SW_HIDE);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (!shortcut_assigned || hexBookmarkShortcut[i] != -1 && hexBookmarkShortcut[i] != hexBookmarkMsg->bookmark_index)
|
||||
// this bookmark doesn't have a shortcut, or the shortcut number is occupied but it doesn't belongs to this bookmark
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), FALSE);
|
||||
|
||||
if (!shortcut_assigned && numHexBookmarkShortcut >= 10)
|
||||
{
|
||||
// all the shortcuts are occupied and this one doesn't have a shortcut, it's impossible to assign a new shortcut
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SHORTCUT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), FALSE);
|
||||
}
|
||||
|
||||
// Set address and description
|
||||
char addr[8];
|
||||
sprintf(addr, "%04X", hexBookmark->address);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_ADDRESS, addr);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, hexBookmark->description);
|
||||
|
||||
// Set the view of the bookmark
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_COMBO_VIEW, CB_SETCURSEL, hexBookmarkMsg->bookmark->editmode, 0);
|
||||
|
||||
// and set focus to that edit field.
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION));
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETSEL, 0, 52);
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
|
@ -156,42 +143,69 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
break;
|
||||
case IDOK:
|
||||
{
|
||||
HWND parent = GetParent(hwndDlg);
|
||||
// Called from Hex Editor
|
||||
if (parent == hMemView)
|
||||
{
|
||||
// Update the bookmark description
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, hexBookmarkMsg->bookmark->description, 50);
|
||||
|
||||
// Update the shortcut key
|
||||
if (hexBookmarkMsg->shortcut_index != -1 && hexBookmarkShortcut[hexBookmarkMsg->shortcut_index] != -1)
|
||||
{
|
||||
hexBookmarkShortcut[hexBookmarkMsg->shortcut_index] = -1;
|
||||
--numHexBookmarkShortcut;
|
||||
}
|
||||
int address, editmode;
|
||||
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHORTCUT))
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if(IsDlgButtonChecked(hwndDlg, dlgShortcutRadioCheck[i]))
|
||||
{
|
||||
// Update the shortcut index
|
||||
hexBookmarkShortcut[i] = hexBookmarkMsg->bookmark_index;
|
||||
++numHexBookmarkShortcut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (parent == hDebug)
|
||||
// Get the address;
|
||||
char addr_str[8];
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_ADDRESS, addr_str, 8);
|
||||
sscanf(addr_str, "%X", &address);
|
||||
|
||||
// Get the view which the address in
|
||||
editmode = SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_COMBO_VIEW, CB_GETCURSEL, 0, 0);
|
||||
extern int GetMaxSize(int editingMode);
|
||||
int MaxSize = GetMaxSize(editmode);
|
||||
|
||||
// Update the address
|
||||
if (address > MaxSize - 1)
|
||||
{
|
||||
char description[51];
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description, 50);
|
||||
debuggerBookmark->second = description;
|
||||
// if the address is out of range
|
||||
char errmsg[64];
|
||||
sprintf(errmsg, "The address in %s must be in range of 0-%X", EditString[editmode], MaxSize - 1);
|
||||
MessageBox(hwndDlg, errmsg, "Address out of range", MB_OK | MB_ICONERROR);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int found = findBookmark(address, editmode);
|
||||
if (found != -1 && found != hexBookmarkMsg->bookmark_index)
|
||||
{
|
||||
// if the address already have a bookmark and the bookmark is not the one we currently editing
|
||||
MessageBox(hwndDlg, "This address already have a bookmark", "Bookmark duplicated", MB_OK | MB_ICONASTERISK);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hexBookmarkMsg->bookmark->address = address;
|
||||
hexBookmarkMsg->bookmark->editmode = editmode;
|
||||
|
||||
// Update the bookmark description
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, hexBookmarkMsg->bookmark->description, 50);
|
||||
|
||||
// Update the shortcut key
|
||||
if (hexBookmarkMsg->shortcut_index != -1 && hexBookmarkShortcut[hexBookmarkMsg->shortcut_index] == hexBookmarkMsg->bookmark_index)
|
||||
{
|
||||
|
||||
hexBookmarkShortcut[hexBookmarkMsg->shortcut_index] = -1;
|
||||
--numHexBookmarkShortcut;
|
||||
}
|
||||
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHORTCUT))
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (IsDlgButtonChecked(hwndDlg, dlgShortcutRadioCheck[i]))
|
||||
{
|
||||
// Update the shortcut index
|
||||
hexBookmarkShortcut[i] = hexBookmarkMsg->bookmark_index;
|
||||
++numHexBookmarkShortcut;
|
||||
break;
|
||||
}
|
||||
|
||||
EndDialog(hwndDlg, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -225,7 +239,7 @@ int addBookmark(HWND hwnd, unsigned int address, int editmode)
|
|||
msg.bookmark_index = nextBookmark;
|
||||
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&msg))
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLGMEMVIEW", hwnd, nameHexBookmarkCallB, (LPARAM)&msg))
|
||||
{
|
||||
nextBookmark++;
|
||||
return 0;
|
||||
|
@ -266,7 +280,7 @@ int editBookmark(HWND hwnd, unsigned int index)
|
|||
}
|
||||
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&msg))
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLGMEMVIEW", hwnd, nameHexBookmarkCallB, (LPARAM)&msg))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
|
@ -343,7 +357,7 @@ void updateBookmarkMenus(HMENU menu)
|
|||
{
|
||||
// Get the text of the menu
|
||||
char buffer[0x100];
|
||||
sprintf(buffer, i < 10 ? "&%d. $%04X - %s" : "%d. $%04X - %s",i, hexBookmarks[i].address, hexBookmarks[i].description);
|
||||
sprintf(buffer, i < 10 ? "&%d. %s:$%04X - %s" : "%d. $%04X - %s", i, EditString[hexBookmarks[i].editmode], hexBookmarks[i].address, hexBookmarks[i].description);
|
||||
|
||||
AppendMenu(menu, MF_STRING, ID_FIRST_BOOKMARK + i, buffer);
|
||||
}
|
||||
|
|
|
@ -50,3 +50,6 @@ int removeBookmark(unsigned int index);
|
|||
void updateBookmarkMenus(HMENU menu);
|
||||
int handleBookmarkMenu(int bookmark);
|
||||
void removeAllBookmarks(HMENU menu);
|
||||
|
||||
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP);
|
||||
extern WNDPROC DefaultEditCtrlProc;
|
||||
|
|
|
@ -143,7 +143,7 @@ int storeHexPreferences(FILE* f)
|
|||
if (fwrite(hexBookmarks[i].description, 1, len, f) != len) return 1;
|
||||
}
|
||||
|
||||
// optional section: save bookmark shortcut matches
|
||||
// Optional Section 1: Save bookmark shortcut matches
|
||||
if (numHexBookmarkShortcut)
|
||||
{
|
||||
fwrite(&numHexBookmarkShortcut, sizeof(numHexBookmarkShortcut), 1, f);
|
||||
|
@ -155,6 +155,18 @@ int storeHexPreferences(FILE* f)
|
|||
}
|
||||
}
|
||||
|
||||
/* Optional Section 2: Edit mode
|
||||
The Hex Editor used to have a bug, it doesn't store the edit mode to
|
||||
the preferences, which make the bookmarks outside NES memory are all
|
||||
treated as NES memory bookmarks.
|
||||
However, for the consideration of backward compatibility of the older
|
||||
version of FCEUX, we can only add the extra data to the last of the file
|
||||
to fix this problem.
|
||||
*/
|
||||
for (int i = 0; i < nextBookmark; ++i)
|
||||
if (fwrite(&hexBookmarks[i].editmode, sizeof(hexBookmarks[i].editmode), 1, f) != 1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -358,6 +370,10 @@ int loadHexPreferences(FILE* f)
|
|||
if (fread(&nextBookmark, sizeof(nextBookmark), 1, f) != 1) return 1;
|
||||
if (nextBookmark >= 64) return 1;
|
||||
|
||||
// clean the garbage values
|
||||
memset(hexBookmarks, 0, sizeof(HexBookmark) * nextBookmark);
|
||||
|
||||
|
||||
for (i=0;i<nextBookmark;i++)
|
||||
{
|
||||
unsigned int len;
|
||||
|
@ -370,11 +386,14 @@ int loadHexPreferences(FILE* f)
|
|||
if (fread(hexBookmarks[i].description, 1, len, f) != len) return 1;
|
||||
}
|
||||
|
||||
// optional section: read bookmark shortcut matches
|
||||
// read number of shortcuts
|
||||
// older versions of .deb file don't have this section, so the file would reach the end.
|
||||
if (fread(&numHexBookmarkShortcut, sizeof(numHexBookmarkShortcut), 1, f) != EOF)
|
||||
/* Optional Section 1: read bookmark shortcut matches
|
||||
read number of shortcuts
|
||||
older versions of .deb file don't have this section, so the file would reach the end.
|
||||
*/
|
||||
if (!feof(f))
|
||||
{
|
||||
fread(&numHexBookmarkShortcut, sizeof(numHexBookmarkShortcut), 1, f);
|
||||
|
||||
unsigned int bookmark_index, shortcut_index;
|
||||
// read the matching index list of the shortcuts
|
||||
for (unsigned int i = 0; i < numHexBookmarkShortcut; ++i)
|
||||
|
@ -390,6 +409,23 @@ int loadHexPreferences(FILE* f)
|
|||
hexBookmarkShortcut[i] = i;
|
||||
}
|
||||
|
||||
/*
|
||||
Optional Section 2: Edit mode
|
||||
The Hex Editor used to have a bug, it doesn't store the edit mode to
|
||||
the preferences, which make the bookmarks outside NES memory are all
|
||||
treated as NES memory bookmarks.
|
||||
However, for the consideration of backward compatibility of the older
|
||||
version of FCEUX, we can only add the extra data to the last of the file
|
||||
to fix this problem.
|
||||
*/
|
||||
int editmode;
|
||||
if (!feof(f))
|
||||
for (int i = 0; i < nextBookmark; i++)
|
||||
{
|
||||
if (fread(&editmode, sizeof(editmode), 1, f) != EOF)
|
||||
hexBookmarks[i].editmode = editmode;
|
||||
else break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -161,7 +161,7 @@
|
|||
#define IDC_CHECK_CODE_TABBING 117
|
||||
#define CHEAT_CONTEXT_LIST_POKECHEATVALUE 118
|
||||
#define IDC_CHECK_LOG_STATUSES_TO_THE_LEFT 118
|
||||
#define IDC_DEBUGGER_BOOKMARK_NAME 118
|
||||
#define IDC_DEBUGGER_BOOKMARK_EDIT 118
|
||||
#define CHEAT_CONTEXT_LIST_GOTOINHEXEDITOR 119
|
||||
#define IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS 119
|
||||
#define IDC_CHECK_LOG_FRAMES_COUNT 119
|
||||
|
@ -641,6 +641,8 @@
|
|||
#define IDC_RADIO_SHORTCUT8 1107
|
||||
#define IDC_RADIO_SHORTCUT9 1108
|
||||
#define IDC_RADIO_SHORTCUT0 1109
|
||||
#define IDC_BOOKMARK_VIEW_TEXT 1110
|
||||
#define IDC_BOOKMARK_COMBO_VIEW 1112
|
||||
#define BTN_ALLOW_LRUD 1117
|
||||
#define IDC_PRGROM_EDIT 1118
|
||||
#define IDC_CHRROM_EDIT 1119
|
||||
|
@ -1163,9 +1165,9 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 306
|
||||
#define _APS_NEXT_RESOURCE_VALUE 309
|
||||
#define _APS_NEXT_COMMAND_VALUE 40005
|
||||
#define _APS_NEXT_CONTROL_VALUE 1101
|
||||
#define _APS_NEXT_CONTROL_VALUE 1112
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3374,7 +3374,6 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
|
|||
case MW_ADDR16: case MW_ADDR17: case MW_ADDR18: case MW_ADDR19:
|
||||
case MW_ADDR20: case MW_ADDR21: case MW_ADDR22: case MW_ADDR23:
|
||||
case IDC_EDIT_COMPAREADDRESS:
|
||||
|
||||
return IsLetterLegalHex;
|
||||
|
||||
// Specific Address in RAM Search
|
||||
|
|
Loading…
Reference in New Issue