winport - change input filter functions to take an index so they can search for a prefix (at index 0 perhaps) and use it on the memwatch. it's better to do these things based on strings and not chars but that's just how we have it setup for now
This commit is contained in:
parent
26c3919358
commit
f6f13d6843
|
@ -21,6 +21,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "utils/xstring.h"
|
#include "utils/xstring.h"
|
||||||
#include "debuggersp.h"
|
#include "debuggersp.h"
|
||||||
|
#include "window.h"
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../conddebug.h"
|
#include "../../conddebug.h"
|
||||||
|
@ -61,6 +62,7 @@ int debuggerWasActive = 0;
|
||||||
char temp_chr[40] = {0};
|
char temp_chr[40] = {0};
|
||||||
char delimiterChar[2] = "#";
|
char delimiterChar[2] = "#";
|
||||||
|
|
||||||
|
|
||||||
INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
extern WNDPROC DefaultEditCtrlProc;
|
extern WNDPROC DefaultEditCtrlProc;
|
||||||
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT uMsg, WPARAM wP, LPARAM lP);
|
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT uMsg, WPARAM wP, LPARAM lP);
|
||||||
|
@ -153,10 +155,10 @@ int parseLine(char* line, Name* n)
|
||||||
if (llen == 5) // Offset size of normal lines of the form $XXXX
|
if (llen == 5) // Offset size of normal lines of the form $XXXX
|
||||||
{
|
{
|
||||||
if (line[0] != '$'
|
if (line[0] != '$'
|
||||||
|| !IsLetterLegalHex(line[1])
|
|| !IsLetterLegalHex(0,line[1])
|
||||||
|| !IsLetterLegalHex(line[2])
|
|| !IsLetterLegalHex(1,line[2])
|
||||||
|| !IsLetterLegalHex(line[3])
|
|| !IsLetterLegalHex(2,line[3])
|
||||||
|| !IsLetterLegalHex(line[4])
|
|| !IsLetterLegalHex(3,line[4])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
|
@ -166,10 +168,10 @@ int parseLine(char* line, Name* n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (line[0] != '$'
|
if (line[0] != '$'
|
||||||
|| !IsLetterLegalHex(line[1])
|
|| !IsLetterLegalHex(0,line[1])
|
||||||
|| !IsLetterLegalHex(line[2])
|
|| !IsLetterLegalHex(1,line[2])
|
||||||
|| !IsLetterLegalHex(line[3])
|
|| !IsLetterLegalHex(2,line[3])
|
||||||
|| !IsLetterLegalHex(line[4])
|
|| !IsLetterLegalHex(3,line[4])
|
||||||
|| line[5] != '/'
|
|| line[5] != '/'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +180,7 @@ int parseLine(char* line, Name* n)
|
||||||
|
|
||||||
for (i=6;line[i];i++)
|
for (i=6;line[i];i++)
|
||||||
{
|
{
|
||||||
if (!IsLetterLegalHex(line[i]))
|
if (!IsLetterLegalHex(i,line[i]))
|
||||||
{
|
{
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ void DeleteAllDebuggerBookmarks();
|
||||||
void FillDebuggerBookmarkListbox(HWND hwnd);
|
void FillDebuggerBookmarkListbox(HWND hwnd);
|
||||||
|
|
||||||
void GoToDebuggerBookmark(HWND hwnd);
|
void GoToDebuggerBookmark(HWND hwnd);
|
||||||
extern bool IsLetterLegalHex(char c);
|
|
||||||
|
|
||||||
bool DoSymbolicDebugNaming(int offset, HWND parentHWND);
|
bool DoSymbolicDebugNaming(int offset, HWND parentHWND);
|
||||||
bool DoSymbolicDebugNaming(int offset, int size, HWND parentHWND);
|
bool DoSymbolicDebugNaming(int offset, int size, HWND parentHWND);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "debuggersp.h"
|
#include "debuggersp.h"
|
||||||
#include "memwatch.h"
|
#include "memwatch.h"
|
||||||
|
#include "window.h"
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../conddebug.h"
|
#include "../../conddebug.h"
|
||||||
|
@ -120,7 +121,7 @@ BOOL updateResults(HWND hwndDlg, int rule)
|
||||||
|
|
||||||
for (unsigned int j=0;j<len;j++)
|
for (unsigned int j=0;j<len;j++)
|
||||||
{
|
{
|
||||||
if (IsLetterLegalHex(input_buff[j]) == FALSE)
|
if (IsLetterLegalHex(j,input_buff[j]) == FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3283,12 +3283,12 @@ POINT CalcSubWindowPos(HWND hDlg, POINT* conf)
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInputLegal(bool (*IsLetterLegal)(char letter), char letter)
|
static bool IsInputLegal(IsLetterLegalProc proc, int index, char letter)
|
||||||
{
|
{
|
||||||
return !IsLetterLegal || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || IsLetterLegal(letter);
|
return !proc || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || proc(index,letter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalGG(char letter)
|
bool IsLetterLegalGG(int index, char letter)
|
||||||
{
|
{
|
||||||
char ch = toupper(letter);
|
char ch = toupper(letter);
|
||||||
for (int i = 0; GameGenieLetters[i]; ++i)
|
for (int i = 0; GameGenieLetters[i]; ++i)
|
||||||
|
@ -3297,80 +3297,83 @@ bool IsLetterLegalGG(char letter)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalHex(char letter)
|
bool IsLetterLegalHex(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f';
|
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalMemwatchAddress(char letter)
|
bool IsLetterLegalMemwatchAddress(int index, char letter)
|
||||||
{
|
{
|
||||||
//accept normal hex stuff
|
//accept normal hex stuff
|
||||||
if(letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f')
|
if(letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//accept prefixes
|
//accept prefixes
|
||||||
if(letter == 'x' || letter == 'X' || letter == '!')
|
if(index == 0)
|
||||||
return true;
|
{
|
||||||
|
if(letter == 'x' || letter == 'X' || letter == '!')
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalHexList(char letter)
|
bool IsLetterLegalHexList(int index, char letter)
|
||||||
{
|
{
|
||||||
return IsLetterLegalHex(letter) || letter == ',' || letter == ' ';
|
return IsLetterLegalHex(index,letter) || letter == ',' || letter == ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalCheat(char letter)
|
bool IsLetterLegalCheat(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?';
|
return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalSize(char letter)
|
bool IsLetterLegalSize(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B';
|
return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalDec(char letter)
|
bool IsLetterLegalDec(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter == '-' || letter == '+';
|
return letter >= '0' && letter <= '9' || letter == '-' || letter == '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalFloat(char letter)
|
bool IsLetterLegalFloat(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+';
|
return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalDecHexMixed(char letter)
|
bool IsLetterLegalDecHexMixed(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+';
|
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLetterLegalUnsignedDecHexMixed(char letter)
|
bool IsLetterLegalUnsignedDecHexMixed(int index, char letter)
|
||||||
{
|
{
|
||||||
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
|
return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter))
|
wchar_t* GetLetterIllegalErrMsg(IsLetterLegalProc proc)
|
||||||
{
|
{
|
||||||
if (IsLetterLegal == &IsLetterLegalGG)
|
if (proc == &IsLetterLegalGG)
|
||||||
return L"You can only type Game Genie characters:\nA P Z L G I T Y E O X U K S V N";
|
return L"You can only type Game Genie characters:\nA P Z L G I T Y E O X U K S V N";
|
||||||
if (IsLetterLegal == &IsLetterLegalHex)
|
if (proc == &IsLetterLegalHex)
|
||||||
return L"You can only type characters for hexadecimal number (0-9,A-F).";
|
return L"You can only type characters for hexadecimal number (0-9,A-F).";
|
||||||
if (IsLetterLegal == &IsLetterLegalHexList)
|
if (proc == &IsLetterLegalHexList)
|
||||||
return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)";
|
return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)";
|
||||||
if (IsLetterLegal == &IsLetterLegalCheat)
|
if (proc == &IsLetterLegalCheat)
|
||||||
return
|
return
|
||||||
L"The cheat code comes into the following 2 formats:\n"
|
L"The cheat code comes into the following 2 formats:\n"
|
||||||
"AAAA:VV freezes the value in Address $AAAA to $VV.\n"
|
"AAAA:VV freezes the value in Address $AAAA to $VV.\n"
|
||||||
"AAAA?CC:VV changes the value in Address $AAAA to $VV only when it's $CC.\n"
|
"AAAA?CC:VV changes the value in Address $AAAA to $VV only when it's $CC.\n"
|
||||||
"All the characters are hexadecimal number (0-9,A-F).\n";
|
"All the characters are hexadecimal number (0-9,A-F).\n";
|
||||||
if (IsLetterLegal == &IsLetterLegalFloat)
|
if (proc == &IsLetterLegalFloat)
|
||||||
return L"You can only type decimal number (decimal point is acceptable).";
|
return L"You can only type decimal number (decimal point is acceptable).";
|
||||||
if (IsLetterLegal == &IsLetterLegalSize)
|
if (proc == &IsLetterLegalSize)
|
||||||
return L"You can only type decimal number followed with B, KB or MB.";
|
return L"You can only type decimal number followed with B, KB or MB.";
|
||||||
if (IsLetterLegal == &IsLetterLegalDec)
|
if (proc == &IsLetterLegalDec)
|
||||||
return L"You can only type decimal number (sign character is acceptable).";
|
return L"You can only type decimal number (sign character is acceptable).";
|
||||||
if (IsLetterLegal == &IsLetterLegalDecHexMixed)
|
if (proc == &IsLetterLegalDecHexMixed)
|
||||||
return
|
return
|
||||||
L"You can only type decimal or hexademical number\n"
|
L"You can only type decimal or hexademical number\n"
|
||||||
"(sign character is acceptable).\n\n"
|
"(sign character is acceptable).\n\n"
|
||||||
|
@ -3381,7 +3384,7 @@ wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter))
|
||||||
"you must add a $ prefix to prevent ambiguous.\n"
|
"you must add a $ prefix to prevent ambiguous.\n"
|
||||||
"eg. 10 is a decimal number,\n"
|
"eg. 10 is a decimal number,\n"
|
||||||
"$10 means a hexademical number that is 16 in decimal.";
|
"$10 means a hexademical number that is 16 in decimal.";
|
||||||
if (IsLetterLegal == &IsLetterLegalUnsignedDecHexMixed)
|
if (proc == &IsLetterLegalUnsignedDecHexMixed)
|
||||||
return
|
return
|
||||||
L"You can only type decimal or hexademical number.\n\n"
|
L"You can only type decimal or hexademical number.\n\n"
|
||||||
"When your number contains letter A-F,\n"
|
"When your number contains letter A-F,\n"
|
||||||
|
@ -3485,9 +3488,9 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
|
||||||
case WM_PASTE:
|
case WM_PASTE:
|
||||||
{
|
{
|
||||||
|
|
||||||
bool (*IsLetterLegal)(char) = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
|
IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
|
||||||
|
|
||||||
if (IsLetterLegal)
|
if (isLetterLegal)
|
||||||
{
|
{
|
||||||
if (OpenClipboard(hwnd))
|
if (OpenClipboard(hwnd))
|
||||||
{
|
{
|
||||||
|
@ -3502,11 +3505,11 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
|
||||||
int len = strlen(clipStr);
|
int len = strlen(clipStr);
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (!IsLetterLegal(clipStr[i]))
|
if (!isLetterLegal(i,clipStr[i]))
|
||||||
{
|
{
|
||||||
through = false;
|
through = false;
|
||||||
// Show Edit control tip, just like the control with ES_NUMBER do
|
// Show Edit control tip, just like the control with ES_NUMBER do
|
||||||
ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal);
|
ShowLetterIllegalBalloonTip(hwnd, isLetterLegal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3520,8 +3523,9 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
|
||||||
|
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
{
|
{
|
||||||
|
int len = GetWindowTextLength(hwnd);
|
||||||
IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
|
IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
|
||||||
through = IsInputLegal(isLetterLegal, wP);
|
through = IsInputLegal(isLetterLegal, len, wP);
|
||||||
if (!through)
|
if (!through)
|
||||||
ShowLetterIllegalBalloonTip(hwnd, isLetterLegal);
|
ShowLetterIllegalBalloonTip(hwnd, isLetterLegal);
|
||||||
}
|
}
|
||||||
|
@ -3530,10 +3534,10 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
|
||||||
return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result;
|
return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter))
|
void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc proc)
|
||||||
{
|
{
|
||||||
wchar_t* title = L"Unacceptable Character";
|
wchar_t* title = L"Unacceptable Character";
|
||||||
wchar_t* msg = GetLetterIllegalErrMsg(IsLetterLegal);
|
wchar_t* msg = GetLetterIllegalErrMsg(proc);
|
||||||
|
|
||||||
EDITBALLOONTIP tip;
|
EDITBALLOONTIP tip;
|
||||||
tip.cbStruct = sizeof(EDITBALLOONTIP);
|
tip.cbStruct = sizeof(EDITBALLOONTIP);
|
||||||
|
|
|
@ -128,8 +128,8 @@ struct HOTKEYMENUINDEX {
|
||||||
void UpdateMenuHotkeys(FCEUMENU_INDEX index);
|
void UpdateMenuHotkeys(FCEUMENU_INDEX index);
|
||||||
int GetCurrentContextIndex();
|
int GetCurrentContextIndex();
|
||||||
|
|
||||||
typedef bool (*IsLetterLegalProc)(char);
|
typedef bool (*IsLetterLegalProc)(int index, char ch);
|
||||||
bool IsLetterLegalHex(char letter);
|
bool IsLetterLegalHex(int index, char letter);
|
||||||
void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc);
|
void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc);
|
||||||
|
|
||||||
extern WNDPROC DefaultEditCtrlProc;
|
extern WNDPROC DefaultEditCtrlProc;
|
||||||
|
|
Loading…
Reference in New Issue