Shortcuts of bookmarks in Hex Editor can be customized. (#129)
This commit is contained in:
parent
49a330532d
commit
96a116e096
|
@ -751,8 +751,7 @@ void loadNameFiles()
|
|||
}
|
||||
|
||||
// bookmarks
|
||||
std::vector<unsigned int> bookmarks_addr;
|
||||
std::vector<std::string> bookmarks_name;
|
||||
std::vector <std::pair<unsigned int, std::string>> bookmarks; // first:address second:name
|
||||
|
||||
/**
|
||||
* Returns the bookmark address of a CPU bookmark identified by its index.
|
||||
|
@ -763,8 +762,8 @@ std::vector<std::string> bookmarks_name;
|
|||
**/
|
||||
unsigned int getBookmarkAddress(unsigned int index)
|
||||
{
|
||||
if (index < bookmarks_addr.size())
|
||||
return bookmarks_addr[index];
|
||||
if (index < bookmarks.size())
|
||||
return bookmarks[index].first;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -777,18 +776,15 @@ unsigned int getBookmarkAddress(unsigned int index)
|
|||
**/
|
||||
void AddDebuggerBookmark2(HWND hwnd, unsigned int addr)
|
||||
{
|
||||
int index = bookmarks_addr.size();
|
||||
bookmarks_addr.push_back(addr);
|
||||
int index = bookmarks.size();
|
||||
// try to find Symbolic name for this address
|
||||
Name* node = findNode(getNamesPointerForAddress(addr), addr);
|
||||
if (node && node->name)
|
||||
bookmarks_name.push_back(node->name);
|
||||
else
|
||||
bookmarks_name.push_back("");
|
||||
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", bookmarks_addr[index], bookmarks_name[index].c_str());
|
||||
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);
|
||||
|
@ -833,13 +829,12 @@ void DeleteDebuggerBookmark(HWND hwnd)
|
|||
} else
|
||||
{
|
||||
// Erase the selected bookmark
|
||||
bookmarks_addr.erase(bookmarks_addr.begin() + selectedItem);
|
||||
bookmarks_name.erase(bookmarks_name.begin() + selectedItem);
|
||||
bookmarks.erase(bookmarks.begin() + selectedItem);
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_DELETESTRING, selectedItem, 0);
|
||||
// Select next item
|
||||
if (selectedItem >= (bookmarks_addr.size() - 1))
|
||||
if (selectedItem >= (bookmarks.size() - 1))
|
||||
// select last item
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, bookmarks_addr.size() - 1, 0);
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, bookmarks.size() - 1, 0);
|
||||
else
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, selectedItem, 0);
|
||||
|
||||
|
@ -850,36 +845,33 @@ void NameDebuggerBookmark(HWND hwnd)
|
|||
{
|
||||
// Get the selected bookmark
|
||||
int selectedItem = SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETCURSEL, 0, 0);
|
||||
if (selectedItem == LB_ERR || selectedItem >= (int)bookmarks_name.size())
|
||||
if (selectedItem == LB_ERR || selectedItem >= (int)bookmarks.size())
|
||||
{
|
||||
MessageBox(hwnd, "Please select a bookmark from the list", "Error", MB_OK | MB_ICONERROR);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
char bookmarkDescription[51] = { 0 };
|
||||
if (bookmarks_name[selectedItem].size())
|
||||
strcpy(bookmarkDescription, bookmarks_name[selectedItem].c_str());
|
||||
else
|
||||
std::pair<unsigned int, std::string> bookmark = bookmarks[selectedItem];
|
||||
if (!bookmark.second.size())
|
||||
{
|
||||
bookmarkDescription[0] = 0;
|
||||
// try to find the same address in bookmarks
|
||||
for (int i = bookmarks_addr.size() - 1; i>= 0; i--)
|
||||
for (int i = bookmarks.size() - 1; i>= 0; i--)
|
||||
{
|
||||
if (i != selectedItem && bookmarks_addr[i] == bookmarks_addr[selectedItem] && bookmarks_name[i].size())
|
||||
if (i != selectedItem && bookmarks[i].first == bookmarks[selectedItem].first && bookmarks[i].second.size())
|
||||
{
|
||||
strcpy(bookmarkDescription, bookmarks_name[i].c_str());
|
||||
bookmark.second = bookmarks[i].second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)bookmarkDescription))
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&bookmark))
|
||||
{
|
||||
// Rename the selected bookmark
|
||||
bookmarks_name[selectedItem] = bookmarkDescription;
|
||||
bookmarks[selectedItem] = bookmark;
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_DELETESTRING, selectedItem, 0);
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%04X %s", bookmarks_addr[selectedItem], bookmarks_name[selectedItem].c_str());
|
||||
sprintf(buffer, "%04X %s", bookmarks[selectedItem].first, bookmarks[selectedItem].second.c_str());
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_INSERTSTRING, selectedItem, (LPARAM)buffer);
|
||||
// Reselect the item (selection disappeared when it was deleted)
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, selectedItem, 0);
|
||||
|
@ -889,17 +881,16 @@ void NameDebuggerBookmark(HWND hwnd)
|
|||
|
||||
void DeleteAllDebuggerBookmarks()
|
||||
{
|
||||
bookmarks_addr.resize(0);
|
||||
bookmarks_name.resize(0);
|
||||
bookmarks.resize(0);
|
||||
}
|
||||
|
||||
void FillDebuggerBookmarkListbox(HWND hwnd)
|
||||
{
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_RESETCONTENT, 0, 0);
|
||||
char buffer[256];
|
||||
for (unsigned int i = 0; i < bookmarks_addr.size(); ++i)
|
||||
for (unsigned int i = 0; i < bookmarks.size(); ++i)
|
||||
{
|
||||
sprintf(buffer, "%04X %s", bookmarks_addr[i], bookmarks_name[i].c_str());
|
||||
sprintf(buffer, "%04X %s", bookmarks[i].first, bookmarks[i].second.c_str());
|
||||
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ struct MemoryMappedRegister
|
|||
|
||||
extern bool symbDebugEnabled;
|
||||
extern bool symbRegNames;
|
||||
extern std::vector<unsigned int> bookmarks_addr;
|
||||
extern std::vector<std::string> bookmarks_name;
|
||||
extern std::vector<std::pair<unsigned int, std::string>> bookmarks;
|
||||
extern int debuggerWasActive;
|
||||
|
||||
int checkCondition(const char* buffer, int num);
|
||||
|
|
|
@ -1409,13 +1409,19 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
if (wParam >= '0' && wParam <= '9')
|
||||
{
|
||||
int bookmark = wParam - '0';
|
||||
int newValue = handleBookmarkMenu(bookmark);
|
||||
|
||||
if (newValue != -1)
|
||||
char buf[3];
|
||||
sprintf(buf, "%c", wParam);
|
||||
int key_num;
|
||||
sscanf(buf, "%d", &key_num);
|
||||
key_num = (key_num + 9) % 10;
|
||||
if (hexBookmarkShortcut[key_num] != -1)
|
||||
{
|
||||
ChangeMemViewFocus(hexBookmarks[bookmark].editmode,newValue,-1);
|
||||
UpdateColorTable();
|
||||
int address = hexBookmarks[hexBookmarkShortcut[key_num]].address;
|
||||
if (address != -1)
|
||||
{
|
||||
ChangeMemViewFocus(hexBookmarks[hexBookmarkShortcut[key_num]].editmode, address, -1);
|
||||
UpdateColorTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "common.h"
|
||||
|
||||
HexBookmark hexBookmarks[64];
|
||||
int hexBookmarkShortcut[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
int numHexBookmarkShortcut = 0;
|
||||
int nextBookmark = 0;
|
||||
|
||||
/// Finds the bookmark for a given address
|
||||
|
@ -48,30 +50,91 @@ int findBookmark(unsigned int address, int editmode)
|
|||
if (hexBookmarks[i].address == address && hexBookmarks[i].editmode == editmode)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL CenterWindow(HWND hwndDlg);
|
||||
|
||||
/// Callback function for the name bookmark dialog
|
||||
/*
|
||||
TODO: The bookmarks of Debugger and Hex Editor uses the same dialog box,
|
||||
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)
|
||||
{
|
||||
static char* description;
|
||||
// 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;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
// Limit bookmark descriptions to 50 characters
|
||||
SendDlgItemMessage(hwndDlg,IDC_BOOKMARK_DESCRIPTION,EM_SETLIMITTEXT,50,0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETLIMITTEXT, 50, 0);
|
||||
|
||||
// Put the current bookmark description into the edit field
|
||||
// and set focus to that edit field.
|
||||
HWND parent = GetParent(hwndDlg);
|
||||
|
||||
description = (char*)lParam;
|
||||
char addr[5];
|
||||
const char* description;
|
||||
// Called from Hex Editor
|
||||
if (parent == hMemView)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Set address and description
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_ADDRESS, addr);
|
||||
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description);
|
||||
|
||||
// and set focus to that edit field.
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION));
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
case WM_QUIT:
|
||||
EndDialog(hwndDlg, 0);
|
||||
|
@ -82,10 +145,47 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
case BN_CLICKED:
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case IDC_CHECK_SHORTCUT:
|
||||
{
|
||||
UINT shortcut_assigned = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHORTCUT);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), shortcut_assigned);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), shortcut_assigned && (hexBookmarkShortcut[i] == -1 || hexBookmarkShortcut[i] == hexBookmarkMsg->bookmark_index));
|
||||
}
|
||||
break;
|
||||
case IDOK:
|
||||
{
|
||||
// Update the bookmark description
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description, 50);
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char description[51];
|
||||
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description, 50);
|
||||
debuggerBookmark->second = description;
|
||||
}
|
||||
EndDialog(hwndDlg, 1);
|
||||
break;
|
||||
}
|
||||
|
@ -107,21 +207,39 @@ int addBookmark(HWND hwnd, unsigned int address, int editmode)
|
|||
// Enforce a maximum of 64 bookmarks
|
||||
if (nextBookmark < 64)
|
||||
{
|
||||
char description[51] = { 0 };
|
||||
sprintf(description, "%s %04X", EditString[editmode], address);
|
||||
|
||||
hexBookmarks[nextBookmark].address = address;
|
||||
hexBookmarks[nextBookmark].editmode = editmode;
|
||||
sprintf(hexBookmarks[nextBookmark].description, "%s %04X", EditString[editmode], address);
|
||||
|
||||
HexBookmarkMsg msg;
|
||||
|
||||
// Pre-define a shortcut if possible
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (hexBookmarkShortcut[i] == -1)
|
||||
{
|
||||
msg.shortcut_index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
msg.bookmark = &hexBookmarks[nextBookmark];
|
||||
msg.bookmark_index = nextBookmark;
|
||||
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)description))
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&msg))
|
||||
{
|
||||
// Add the bookmark
|
||||
hexBookmarks[nextBookmark].address = address;
|
||||
hexBookmarks[nextBookmark].editmode = editmode;
|
||||
strcpy(hexBookmarks[nextBookmark].description, description);
|
||||
nextBookmark++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg.shortcut_index != -1)
|
||||
{
|
||||
if (hexBookmarkShortcut[msg.shortcut_index] != -1)
|
||||
--numHexBookmarkShortcut;
|
||||
hexBookmarkShortcut[msg.shortcut_index] = -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
@ -135,16 +253,21 @@ int editBookmark(HWND hwnd, unsigned int index)
|
|||
{
|
||||
if (index >= 64) return -1;
|
||||
|
||||
char description[51] = { 0 };
|
||||
strcpy(description, hexBookmarks[index].description);
|
||||
HexBookmarkMsg msg;
|
||||
msg.bookmark = &hexBookmarks[index];
|
||||
msg.bookmark_index = index;
|
||||
|
||||
// find its shortcut index
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (index == hexBookmarkShortcut[i])
|
||||
{
|
||||
msg.shortcut_index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
// Show the bookmark name dialog
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)description))
|
||||
{
|
||||
// Update the bookmark information
|
||||
strcpy(hexBookmarks[index].description, description);
|
||||
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)&msg))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
|
@ -158,6 +281,20 @@ int removeBookmark(unsigned int index)
|
|||
{
|
||||
if (index >= 64) return -1;
|
||||
|
||||
// remove its related shortcut
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
// all the indexes after the deleted one sould decrease by 1
|
||||
if (hexBookmarkShortcut[i] != -1 && hexBookmarkShortcut[i] > index)
|
||||
--hexBookmarkShortcut[i];
|
||||
else if (hexBookmarkShortcut[i] == index)
|
||||
{
|
||||
// delete the shortcut index itself
|
||||
hexBookmarkShortcut[i] = -1;
|
||||
--numHexBookmarkShortcut;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point it's necessary to move the content of the bookmark list
|
||||
for (int i=index;i<nextBookmark - 1;i++)
|
||||
{
|
||||
|
@ -206,10 +343,22 @@ void updateBookmarkMenus(HMENU menu)
|
|||
{
|
||||
// Get the text of the menu
|
||||
char buffer[0x100];
|
||||
sprintf(buffer, i < 10 ? "&%d. $%04X - %s\tCtrl+%d" : "%d. $%04X - %s",i, hexBookmarks[i].address, hexBookmarks[i].description, i);
|
||||
|
||||
sprintf(buffer, i < 10 ? "&%d. $%04X - %s" : "%d. $%04X - %s",i, hexBookmarks[i].address, hexBookmarks[i].description);
|
||||
|
||||
AppendMenu(menu, MF_STRING, ID_FIRST_BOOKMARK + i, buffer);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
if (hexBookmarkShortcut[i] != -1)
|
||||
{
|
||||
char buffer[0x100];
|
||||
GetMenuString(menu, ID_FIRST_BOOKMARK + hexBookmarkShortcut[i], buffer, 50, MF_BYCOMMAND);
|
||||
sprintf(&buffer[strlen(buffer)], "\tCtrl+%d\0", (i + 1) % 10);
|
||||
ModifyMenu(menu, ID_FIRST_BOOKMARK + hexBookmarkShortcut[i], MF_BYCOMMAND, ID_FIRST_BOOKMARK + hexBookmarkShortcut[i], buffer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,4 +386,7 @@ void removeAllBookmarks(HMENU menu)
|
|||
RemoveMenu(menu, ID_BOOKMARKLIST_SEP, MF_BYCOMMAND);
|
||||
|
||||
nextBookmark = 0;
|
||||
numHexBookmarkShortcut = 0;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
hexBookmarkShortcut[i] = -1;
|
||||
}
|
|
@ -30,7 +30,16 @@ typedef struct
|
|||
int editmode;
|
||||
} HexBookmark;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HexBookmark* bookmark;
|
||||
int bookmark_index;
|
||||
int shortcut_index = -1;
|
||||
} HexBookmarkMsg;
|
||||
|
||||
extern HexBookmark hexBookmarks[64];
|
||||
extern int hexBookmarkShortcut[10];
|
||||
extern int numHexBookmarkShortcut;
|
||||
extern int nextBookmark;
|
||||
|
||||
int findBookmark(unsigned int address, int editmode);
|
||||
|
|
|
@ -47,16 +47,16 @@ int storeDebuggerPreferences(FILE* f)
|
|||
uint8 tmp;
|
||||
|
||||
// Write the number of CPU bookmarks
|
||||
size = bookmarks_addr.size();
|
||||
bookmarks_name.resize(size);
|
||||
size = bookmarks.size();
|
||||
bookmarks.resize(size);
|
||||
if (fwrite(&size, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
// Write the data of those bookmarks
|
||||
for (i = 0; i < (int)size; ++i)
|
||||
{
|
||||
if (fwrite(&bookmarks_addr[i], sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
len = bookmarks_name[i].size();
|
||||
if (fwrite(&bookmarks[i].first, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
len = bookmarks[i].second.size();
|
||||
if (fwrite(&len, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
if (fwrite(bookmarks_name[i].c_str(), 1, len, f) != len) return 1;
|
||||
if (fwrite(bookmarks[i].second.c_str(), 1, len, f) != len) return 1;
|
||||
}
|
||||
|
||||
// Write all breakpoints
|
||||
|
@ -142,7 +142,19 @@ int storeHexPreferences(FILE* f)
|
|||
// Writes the actual bookmark description
|
||||
if (fwrite(hexBookmarks[i].description, 1, len, f) != len) return 1;
|
||||
}
|
||||
|
||||
|
||||
// optional section: save bookmark shortcut matches
|
||||
if (numHexBookmarkShortcut)
|
||||
{
|
||||
fwrite(&numHexBookmarkShortcut, sizeof(numHexBookmarkShortcut), 1, f);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (hexBookmarkShortcut[i] != -1)
|
||||
{
|
||||
fwrite(&hexBookmarkShortcut[i], sizeof(hexBookmarkShortcut[i]), 1, f);
|
||||
fwrite(&i, sizeof(i), 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -229,18 +241,17 @@ int loadDebuggerPreferences(FILE* f)
|
|||
|
||||
// Read the number of CPU bookmarks
|
||||
if (fread(&size, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
bookmarks_addr.resize(size);
|
||||
bookmarks_name.resize(size);
|
||||
bookmarks.resize(size);
|
||||
// Read the data of those bookmarks
|
||||
char buffer[256];
|
||||
for (i = 0; i < (int)size; ++i)
|
||||
{
|
||||
if (fread(&bookmarks_addr[i], sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
if (fread(&bookmarks[i].first, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
if (fread(&len, sizeof(unsigned int), 1, f) != 1) return 1;
|
||||
if (len >= 256) return 1;
|
||||
if (fread(&buffer, 1, len, f) != len) return 1;
|
||||
buffer[len] = 0;
|
||||
bookmarks_name[i] = buffer;
|
||||
bookmarks[i].second = buffer;
|
||||
}
|
||||
|
||||
myNumWPs = 0;
|
||||
|
@ -358,7 +369,27 @@ int loadHexPreferences(FILE* f)
|
|||
// Read the bookmark description
|
||||
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)
|
||||
{
|
||||
unsigned int bookmark_index, shortcut_index;
|
||||
// read the matching index list of the shortcuts
|
||||
for (unsigned int i = 0; i < numHexBookmarkShortcut; ++i)
|
||||
if (fread(&bookmark_index, sizeof(bookmark_index), 1, f) != EOF && fread(&shortcut_index, sizeof(shortcut_index), 1, f) != EOF)
|
||||
hexBookmarkShortcut[shortcut_index % 10] = bookmark_index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// use the default configruation based on the order of the bookmark list
|
||||
numHexBookmarkShortcut = nextBookmark > 10 ? 10 : nextBookmark;
|
||||
for (int i = 0; i < numHexBookmarkShortcut; ++i)
|
||||
hexBookmarkShortcut[i] = i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1901,14 +1901,28 @@ BEGIN
|
|||
LISTBOX IDC_ASSEMBLER_PATCH_DISASM,7,50,188,59,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
|
||||
NAMEBOOKMARKDLG DIALOGEX 0, 0, 186, 73
|
||||
NAMEBOOKMARKDLG DIALOGEX 0, 0, 269, 79
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Bookmark name"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "Bookmark name",IDC_BOOKMARK_NAME_TEXT,68,14,58,8
|
||||
EDITTEXT IDC_BOOKMARK_DESCRIPTION,7,28,172,14,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "&OK",IDOK,67,52,50,14
|
||||
LTEXT "&Address:",IDC_BOOKMARK_ADDRESS_TEXT,7,10,30,8
|
||||
EDITTEXT IDC_BOOKMARK_ADDRESS,42,7,48,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "&Name:",IDC_BOOKMARK_NAME_TEXT,7,27,23,8
|
||||
EDITTEXT IDC_BOOKMARK_DESCRIPTION,42,25,220,14,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "&OK",IDOK,107,58,50,14
|
||||
CONTROL "&Shortcut:",IDC_CHECK_SHORTCUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,44,46,10
|
||||
LTEXT "Ctrl+",IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT,54,45,17,8
|
||||
CONTROL "&1",IDC_RADIO_SHORTCUT0,"Button",BS_AUTORADIOBUTTON,73,44,18,10
|
||||
CONTROL "&2",IDC_RADIO_SHORTCUT1,"Button",BS_AUTORADIOBUTTON,92,44,18,10
|
||||
CONTROL "&3",IDC_RADIO_SHORTCUT2,"Button",BS_AUTORADIOBUTTON,111,44,18,10
|
||||
CONTROL "&4",IDC_RADIO_SHORTCUT3,"Button",BS_AUTORADIOBUTTON,130,44,18,10
|
||||
CONTROL "&5",IDC_RADIO_SHORTCUT4,"Button",BS_AUTORADIOBUTTON,149,44,18,10
|
||||
CONTROL "&6",IDC_RADIO_SHORTCUT5,"Button",BS_AUTORADIOBUTTON,168,44,18,10
|
||||
CONTROL "&7",IDC_RADIO_SHORTCUT6,"Button",BS_AUTORADIOBUTTON,187,44,18,10
|
||||
CONTROL "&8",IDC_RADIO_SHORTCUT7,"Button",BS_AUTORADIOBUTTON,206,44,18,10
|
||||
CONTROL "&9",IDC_RADIO_SHORTCUT8,"Button",BS_AUTORADIOBUTTON,225,44,18,10
|
||||
CONTROL "&0",IDC_RADIO_SHORTCUT9,"Button",BS_AUTORADIOBUTTON,244,44,18,10
|
||||
END
|
||||
|
||||
CDLOGGER DIALOGEX 0, 0, 307, 254
|
||||
|
@ -2589,9 +2603,9 @@ BEGIN
|
|||
"NAMEBOOKMARKDLG", DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
RIGHTMARGIN, 262
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 66
|
||||
BOTTOMMARGIN, 72
|
||||
END
|
||||
|
||||
"CDLOGGER", DIALOG
|
||||
|
@ -2948,7 +2962,7 @@ IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp"
|
|||
IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp"
|
||||
IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp"
|
||||
IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp"
|
||||
#endif // English(United States) resources
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -472,6 +472,7 @@
|
|||
#define MW_ADDR00 1001
|
||||
#define IDC_MEMVIEWFIND_TYPE_HEX 1001
|
||||
#define IDC_NTVIEW_MIRROR_HORIZONTAL 1001
|
||||
#define IDC_BOOKMARK_ADDRESS 1001
|
||||
#define IDC_CHECK_STOPMOVIE 1002
|
||||
#define IDC_GAME_GENIE_COMP 1002
|
||||
#define IDC_MEMVIEWFIND_TYPE_TEXT 1002
|
||||
|
@ -508,6 +509,7 @@
|
|||
#define MW_ADDR04 1013
|
||||
#define IDC_CHECK1 1013
|
||||
#define IDC_CHEAT_AUTOLOADSAVE 1013
|
||||
#define IDC_CHECK_SHORTCUT 1013
|
||||
#define IDC_RESTORE_BUTTON 1014
|
||||
#define MW_VAL04 1014
|
||||
#define MW_NAME05 1015
|
||||
|
@ -629,6 +631,16 @@
|
|||
#define IDC_GAME_GENIE_LABEL 1097
|
||||
#define IDC_CHEAT_GAME_GENIE_TEXT 1098
|
||||
#define IDC_CHECK2 1099
|
||||
#define IDC_RADIO_SHORTCUT1 1100
|
||||
#define IDC_RADIO_SHORTCUT2 1101
|
||||
#define IDC_RADIO_SHORTCUT3 1102
|
||||
#define IDC_RADIO_SHORTCUT4 1103
|
||||
#define IDC_RADIO_SHORTCUT5 1104
|
||||
#define IDC_RADIO_SHORTCUT6 1105
|
||||
#define IDC_RADIO_SHORTCUT7 1106
|
||||
#define IDC_RADIO_SHORTCUT8 1107
|
||||
#define IDC_RADIO_SHORTCUT9 1108
|
||||
#define IDC_RADIO_SHORTCUT0 1109
|
||||
#define BTN_ALLOW_LRUD 1117
|
||||
#define IDC_PRGROM_EDIT 1118
|
||||
#define IDC_CHRROM_EDIT 1119
|
||||
|
@ -1142,15 +1154,17 @@
|
|||
#define MW_VALUELABEL1 65426
|
||||
#define IDC_STATIC_SLASHTEXT 65442
|
||||
#define IDC_BOOKMARK_NAME_TEXT 65532
|
||||
#define IDC_BOOKMARK_ADDRESS_TEXT 65533
|
||||
#define IDC_NTVIEW_SCANLINE_TEXT 65534
|
||||
#define IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT 65534
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 305
|
||||
#define _APS_NEXT_RESOURCE_VALUE 306
|
||||
#define _APS_NEXT_COMMAND_VALUE 40002
|
||||
#define _APS_NEXT_CONTROL_VALUE 1100
|
||||
#define _APS_NEXT_CONTROL_VALUE 1101
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue