Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerge Bot <bot@example.com>2022-08-22 03:32:11 +0300
committerAutomerge Bot <bot@example.com>2022-08-22 03:32:11 +0300
commit00653157d189de4921b7ef0f2ebf354c1dbb73c2 (patch)
treefb70c8bb54115de6e3eb9d2d48544555c3974e31
parentbd654cf2b2521560e8ca1bcd76e6572b1167e3ca (diff)
parent7806b24388291a15b5cda04531c23ed417339ab7 (diff)
Merge branch 'master' of https://github.com/TASVideos/fceux into coolgirl
-rw-r--r--src/drivers/Qt/CheatsConf.cpp29
-rw-r--r--src/drivers/Qt/CheatsConf.h1
-rw-r--r--src/drivers/Qt/ConsoleWindow.cpp15
-rw-r--r--src/drivers/Qt/ConsoleWindow.h1
-rw-r--r--src/drivers/Qt/config.cpp3
-rw-r--r--src/drivers/Qt/config.h2
-rw-r--r--src/drivers/Qt/fceuWrapper.cpp3
-rw-r--r--src/drivers/win/debuggersp.cpp20
-rw-r--r--src/drivers/win/debuggersp.h1
-rw-r--r--src/drivers/win/monitor.cpp3
-rw-r--r--src/drivers/win/res.rc48
-rw-r--r--src/drivers/win/window.cpp366
-rw-r--r--src/drivers/win/window.h16
-rw-r--r--src/input.cpp1
14 files changed, 286 insertions, 223 deletions
diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp
index d995700d..79cc3c60 100644
--- a/src/drivers/Qt/CheatsConf.cpp
+++ b/src/drivers/Qt/CheatsConf.cpp
@@ -52,6 +52,9 @@ void openCheatDialog(QWidget *parent)
{
if (win != NULL)
{
+ win->activateWindow();
+ win->raise();
+ win->setFocus();
return;
}
win = new GuiCheatsDialog_t(parent);
@@ -199,6 +202,18 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
vbox1->addLayout(hbox);
hbox = new QHBoxLayout();
+ lbl = new QLabel(tr("Type:"));
+ typeEntry = new QComboBox();
+ typeEntry->addItem(tr("0: Periodic Set (Every Frame)"), 0 );
+ typeEntry->addItem(tr("1: Substitute/Freeze"), 1 );
+ typeEntry->setCurrentIndex(1);
+
+ hbox->addWidget(lbl,1);
+ hbox->addWidget(typeEntry,10);
+
+ vbox1->addLayout(hbox);
+
+ hbox = new QHBoxLayout();
addCheatBtn = new QPushButton(tr("Add"));
delCheatBtn = new QPushButton(tr("Delete"));
@@ -435,6 +450,8 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
setLayout(mainLayout);
+ modCheatBtn->setDefault(true);
+
connect(srchResetBtn, SIGNAL(clicked(void)), this, SLOT(resetSearchCallback(void)));
connect(knownValBtn, SIGNAL(clicked(void)), this, SLOT(knownValueCallback(void)));
connect(eqValBtn, SIGNAL(clicked(void)), this, SLOT(equalValueCallback(void)));
@@ -719,6 +736,8 @@ void GuiCheatsDialog_t::showActiveCheatList(bool redraw)
{
win = this;
+ enaCheats->setChecked(!globalCheatDisabled);
+
actvCheatRedraw = redraw;
if (redraw)
@@ -871,6 +890,7 @@ void GuiCheatsDialog_t::addActvCheat(void)
uint32 a = 0;
uint8 v = 0;
int c = -1;
+ int t = 1;
std::string name, cmpStr;
a = strtoul(cheatAddrEntry->displayText().toStdString().c_str(), NULL, 16);
@@ -890,8 +910,10 @@ void GuiCheatsDialog_t::addActvCheat(void)
name = cheatNameEntry->text().toStdString();
+ t = typeEntry->currentData().toInt();
+
FCEU_WRAPPER_LOCK();
- FCEUI_AddCheat(name.c_str(), a, v, c, 1);
+ FCEUI_AddCheat(name.c_str(), a, v, c, t);
FCEU_WRAPPER_UNLOCK();
showActiveCheatList(true);
@@ -921,6 +943,7 @@ void GuiCheatsDialog_t::deleteActvCheat(void)
cheatAddrEntry->setText(tr(""));
cheatValEntry->setText(tr(""));
cheatCmpEntry->setText(tr(""));
+ typeEntry->setCurrentIndex(0);
}
//----------------------------------------------------------------------------
void GuiCheatsDialog_t::updateCheatParameters(void)
@@ -969,6 +992,8 @@ void GuiCheatsDialog_t::updateCheatParameters(void)
//printf("Name: %s \n", name.c_str() );
+ type = typeEntry->currentData().toInt();
+
FCEU_WRAPPER_LOCK();
FCEUI_SetCheat(row, &name, a, v, c, s, type);
@@ -1022,6 +1047,8 @@ void GuiCheatsDialog_t::actvCheatItemClicked(QTreeWidgetItem *item, int column)
}
cheatNameEntry->setText(tr(name.c_str()));
+
+ typeEntry->setCurrentIndex(type);
}
//----------------------------------------------------------------------------
void GuiCheatsDialog_t::globalEnableCheats(int state)
diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h
index c06e9f75..4eab63a9 100644
--- a/src/drivers/Qt/CheatsConf.h
+++ b/src/drivers/Qt/CheatsConf.h
@@ -67,6 +67,7 @@ protected:
QLineEdit *neValEntry;
QLineEdit *grValEntry;
QLineEdit *ltValEntry;
+ QComboBox *typeEntry;
QFont font;
int fontCharWidth;
diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp
index 9332dac4..23e4bf40 100644
--- a/src/drivers/Qt/ConsoleWindow.cpp
+++ b/src/drivers/Qt/ConsoleWindow.cpp
@@ -862,6 +862,7 @@ void consoleWin_t::initHotKeys(void)
connect( Hotkeys[ HK_TOGGLE_BG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleBackground(void)) );
connect( Hotkeys[ HK_TOGGLE_FG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleForeground(void)) );
connect( Hotkeys[ HK_FKB_ENABLE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleFamKeyBrdEnable(void)) );
+ connect( Hotkeys[ HK_TOGGLE_ALL_CHEATS ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleGlobalCheatEnable(void)) );
connect( Hotkeys[ HK_SAVE_STATE_0 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState0(void)) );
connect( Hotkeys[ HK_SAVE_STATE_1 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState1(void)) );
@@ -3173,6 +3174,20 @@ void consoleWin_t::toggleFamKeyBrdEnable(void)
toggleFamilyKeyboardFunc();
}
+extern int globalCheatDisabled;
+
+void consoleWin_t::toggleGlobalCheatEnable(void)
+{
+ FCEU_WRAPPER_LOCK();
+ FCEUI_GlobalToggleCheat(globalCheatDisabled);
+ FCEU_WRAPPER_UNLOCK();
+
+ g_config->setOption("SDL.CheatsDisabled", globalCheatDisabled);
+ g_config->save();
+
+ updateCheatDialog();
+}
+
void consoleWin_t::warnAmbiguousShortcut( QShortcut *shortcut)
{
char stmp[256];
diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h
index 4586e06b..d4451965 100644
--- a/src/drivers/Qt/ConsoleWindow.h
+++ b/src/drivers/Qt/ConsoleWindow.h
@@ -415,6 +415,7 @@ class consoleWin_t : public QMainWindow
void toggleBackground(void);
void toggleForeground(void);
void toggleFamKeyBrdEnable(void);
+ void toggleGlobalCheatEnable(void);
void saveState0(void);
void saveState1(void);
void saveState2(void);
diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp
index 386571ee..25442b96 100644
--- a/src/drivers/Qt/config.cpp
+++ b/src/drivers/Qt/config.cpp
@@ -83,6 +83,9 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut, const
case HK_CHEAT_MENU:
name = "CheatMenu"; keySeq = ""; title = "Open Cheat Window"; group = "Tools";
break;
+ case HK_TOGGLE_ALL_CHEATS:
+ name = "ToggleCheats"; keySeq = ""; title = "Toggle Global Cheat Enable"; group = "Tools";
+ break;
case HK_BIND_STATE:
name = "BindState"; keySeq = ""; title = "Bind Save State to Movie"; group = "Movie";
break;
diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h
index 0bb68e78..d719f12d 100644
--- a/src/drivers/Qt/config.h
+++ b/src/drivers/Qt/config.h
@@ -53,7 +53,7 @@ enum HOTKEY {
// Display
HK_TOGGLE_FG, HK_TOGGLE_BG, HK_TOGGLE_INPUT_DISPLAY, HK_LAG_COUNTER_DISPLAY,
- HK_CHEAT_MENU, HK_LOAD_LUA,
+ HK_CHEAT_MENU, HK_TOGGLE_ALL_CHEATS, HK_LOAD_LUA,
HK_MUTE_CAPTURE,
HK_FA_LAG_SKIP,
HK_VOLUME_DOWN, HK_VOLUME_UP,
diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp
index 8c5ef9e7..12790b69 100644
--- a/src/drivers/Qt/fceuWrapper.cpp
+++ b/src/drivers/Qt/fceuWrapper.cpp
@@ -39,6 +39,7 @@
#include "Qt/unix-netplay.h"
#include "Qt/AviRecord.h"
#include "Qt/HexEditor.h"
+#include "Qt/CheatsConf.h"
#include "Qt/SymbolicDebug.h"
#include "Qt/CodeDataLogger.h"
#include "Qt/ConsoleDebugger.h"
@@ -352,6 +353,8 @@ int LoadGame(const char *path, bool silent)
debugSymbolTable.loadGameSymbols();
+ updateCheatDialog();
+
CDLoggerROMChanged();
int state_to_load;
diff --git a/src/drivers/win/debuggersp.cpp b/src/drivers/win/debuggersp.cpp
index 1f78660f..8cf8c093 100644
--- a/src/drivers/win/debuggersp.cpp
+++ b/src/drivers/win/debuggersp.cpp
@@ -21,6 +21,7 @@
#include "common.h"
#include "utils/xstring.h"
#include "debuggersp.h"
+#include "window.h"
#include "../../fceu.h"
#include "../../debug.h"
#include "../../conddebug.h"
@@ -60,6 +61,7 @@ bool symbRegNames = true;
int debuggerWasActive = 0;
char temp_chr[40] = {0};
char delimiterChar[2] = "#";
+
INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern WNDPROC DefaultEditCtrlProc;
@@ -153,10 +155,10 @@ int parseLine(char* line, Name* n)
if (llen == 5) // Offset size of normal lines of the form $XXXX
{
if (line[0] != '$'
- || !IsLetterLegalHex(line[1])
- || !IsLetterLegalHex(line[2])
- || !IsLetterLegalHex(line[3])
- || !IsLetterLegalHex(line[4])
+ || !IsLetterLegalHex(0,line[1])
+ || !IsLetterLegalHex(1,line[2])
+ || !IsLetterLegalHex(2,line[3])
+ || !IsLetterLegalHex(3,line[4])
)
{
return 4;
@@ -166,10 +168,10 @@ int parseLine(char* line, Name* n)
{
int i;
if (line[0] != '$'
- || !IsLetterLegalHex(line[1])
- || !IsLetterLegalHex(line[2])
- || !IsLetterLegalHex(line[3])
- || !IsLetterLegalHex(line[4])
+ || !IsLetterLegalHex(0,line[1])
+ || !IsLetterLegalHex(1,line[2])
+ || !IsLetterLegalHex(2,line[3])
+ || !IsLetterLegalHex(3,line[4])
|| line[5] != '/'
)
{
@@ -178,7 +180,7 @@ int parseLine(char* line, Name* n)
for (i=6;line[i];i++)
{
- if (!IsLetterLegalHex(line[i]))
+ if (!IsLetterLegalHex(i,line[i]))
{
return 6;
}
diff --git a/src/drivers/win/debuggersp.h b/src/drivers/win/debuggersp.h
index 01b7d907..3bd04d65 100644
--- a/src/drivers/win/debuggersp.h
+++ b/src/drivers/win/debuggersp.h
@@ -61,7 +61,6 @@ void DeleteAllDebuggerBookmarks();
void FillDebuggerBookmarkListbox(HWND hwnd);
void GoToDebuggerBookmark(HWND hwnd);
-extern bool IsLetterLegalHex(char c);
bool DoSymbolicDebugNaming(int offset, HWND parentHWND);
bool DoSymbolicDebugNaming(int offset, int size, HWND parentHWND);
diff --git a/src/drivers/win/monitor.cpp b/src/drivers/win/monitor.cpp
index 376e96e5..037f5b73 100644
--- a/src/drivers/win/monitor.cpp
+++ b/src/drivers/win/monitor.cpp
@@ -3,6 +3,7 @@
#include "debugger.h"
#include "debuggersp.h"
#include "memwatch.h"
+#include "window.h"
#include "../../fceu.h"
#include "../../debug.h"
#include "../../conddebug.h"
@@ -120,7 +121,7 @@ BOOL updateResults(HWND hwndDlg, int rule)
for (unsigned int j=0;j<len;j++)
{
- if (IsLetterLegalHex(input_buff[j]) == FALSE)
+ if (IsLetterLegalHex(j,input_buff[j]) == FALSE)
{
return FALSE;
}
diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc
index 2b467b92..88d77f03 100644
--- a/src/drivers/win/res.rc
+++ b/src/drivers/win/res.rc
@@ -684,53 +684,53 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
GROUPBOX "",IDC_STATIC,3,0,126,200
GROUPBOX "",IDC_STATIC,131,0,128,200
- EDITTEXT MW_ADDR00,6,17,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR00,6,17,30,14,0
EDITTEXT MW_NAME00,41,17,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR01,6,32,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR01,6,32,30,14,0
EDITTEXT MW_NAME01,41,32,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR02,6,47,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR02,6,47,30,14,0
EDITTEXT MW_NAME02,41,47,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR03,6,62,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR03,6,62,30,14,0
EDITTEXT MW_NAME03,41,62,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR04,6,77,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR04,6,77,30,14,0
EDITTEXT MW_NAME04,41,77,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR05,6,92,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR05,6,92,30,14,0
EDITTEXT MW_NAME05,41,92,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR06,6,107,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR06,6,107,30,14,0
EDITTEXT MW_NAME06,41,107,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR07,6,122,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR07,6,122,30,14,0
EDITTEXT MW_NAME07,41,122,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR08,6,137,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR08,6,137,30,14,0
EDITTEXT MW_NAME08,41,137,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR09,6,152,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR09,6,152,30,14,0
EDITTEXT MW_NAME09,41,152,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR10,6,167,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR10,6,167,30,14,0
EDITTEXT MW_NAME10,41,167,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR11,6,182,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR11,6,182,30,14,0
EDITTEXT MW_NAME11,41,182,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR12,135,17,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR12,135,17,30,14,0
EDITTEXT MW_NAME12,171,17,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR13,135,32,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR13,135,32,30,14,0
EDITTEXT MW_NAME13,171,32,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR14,135,47,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR14,135,47,30,14,0
EDITTEXT MW_NAME14,171,47,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR15,135,62,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR15,135,62,30,14,0
EDITTEXT MW_NAME15,171,62,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR16,135,77,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR16,135,77,30,14,0
EDITTEXT MW_NAME16,171,77,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR17,135,92,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR17,135,92,30,14,0
EDITTEXT MW_NAME17,171,92,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR18,135,107,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR18,135,107,30,14,0
EDITTEXT MW_NAME18,171,107,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR19,135,122,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR19,135,122,30,14,0
EDITTEXT MW_NAME19,171,122,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR20,135,137,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR20,135,137,30,14,0
EDITTEXT MW_NAME20,171,137,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR21,135,152,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR21,135,152,30,14,0
EDITTEXT MW_NAME21,171,152,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR22,135,167,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR22,135,167,30,14,0
EDITTEXT MW_NAME22,171,167,55,14,ES_AUTOHSCROLL
- EDITTEXT MW_ADDR23,135,182,30,14,ES_UPPERCASE
+ EDITTEXT MW_ADDR23,135,182,30,14,0
EDITTEXT MW_NAME23,171,182,55,14,ES_AUTOHSCROLL
LTEXT "Name",IDC_STATIC,41,7,20,8
LTEXT "Address",IDC_STATIC,6,7,26,8
diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp
index d2ba531e..3effd90d 100644
--- a/src/drivers/win/window.cpp
+++ b/src/drivers/win/window.cpp
@@ -3283,72 +3283,132 @@ POINT CalcSubWindowPos(HWND hDlg, POINT* conf)
return pt;
}
-LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
+static bool IsInputLegal(IsLetterLegalProc proc, int index, char letter)
{
- bool through = true;
- INT_PTR result = 0;
+ return !proc || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || proc(index,letter);
+}
- switch (msg)
+bool IsLetterLegalGG(int index, char letter)
+{
+ char ch = toupper(letter);
+ for (int i = 0; GameGenieLetters[i]; ++i)
+ if (GameGenieLetters[i] == ch)
+ return true;
+ return false;
+}
+
+bool IsLetterLegalHex(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f';
+}
+
+bool IsLetterLegalMemwatchAddress(int index, char letter)
+{
+ //accept normal hex stuff
+ if(letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f')
+ return true;
+
+ //accept prefixes
+ if(index == 0)
{
- case WM_PASTE:
- {
+ if(letter == 'x' || letter == 'X' || letter == '!')
+ return true;
+ }
- bool (*IsLetterLegal)(char) = GetIsLetterLegal(GetDlgCtrlID(hwnd));
+ return false;
+}
- if (IsLetterLegal)
- {
- if (OpenClipboard(hwnd))
- {
- HANDLE handle = GetClipboardData(CF_TEXT);
- if (handle)
- {
+bool IsLetterLegalHexList(int index, char letter)
+{
+ return IsLetterLegalHex(index,letter) || letter == ',' || letter == ' ';
+}
- // get the original clipboard string
- char* clipStr = (char*)GlobalLock(handle);
+bool IsLetterLegalCheat(int index, char letter)
+{
+ return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?';
+}
- // check if the text in clipboard has illegal characters
- int len = strlen(clipStr);
- for (int i = 0; i < len; ++i)
- {
- if (!IsLetterLegal(clipStr[i]))
- {
- through = false;
- // Show Edit control tip, just like the control with ES_NUMBER do
- ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal);
- break;
- }
- }
- GlobalUnlock(handle);
- CloseClipboard();
- }
- }
- }
- }
- break;
- case WM_CHAR:
- {
- bool(*IsLetterLegal)(char) = GetIsLetterLegal(GetDlgCtrlID(hwnd));
- through = IsInputLegal(IsLetterLegal, wP);
- if (!through)
- ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal);
- }
- }
+bool IsLetterLegalSize(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B';
+}
- return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result;
+bool IsLetterLegalDec(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter == '-' || letter == '+';
+}
+
+bool IsLetterLegalFloat(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+';
+}
+
+bool IsLetterLegalDecHexMixed(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+';
+}
+
+bool IsLetterLegalUnsignedDecHexMixed(int index, char letter)
+{
+ return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
+}
+
+wchar_t* GetLetterIllegalErrMsg(IsLetterLegalProc proc)
+{
+ 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";
+ if (proc == &IsLetterLegalHex)
+ return L"You can only type characters for hexadecimal number (0-9,A-F).";
+ if (proc == &IsLetterLegalHexList)
+ return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)";
+ if (proc == &IsLetterLegalCheat)
+ return
+ L"The cheat code comes into the following 2 formats:\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"
+ "All the characters are hexadecimal number (0-9,A-F).\n";
+ if (proc == &IsLetterLegalFloat)
+ return L"You can only type decimal number (decimal point is acceptable).";
+ if (proc == &IsLetterLegalSize)
+ return L"You can only type decimal number followed with B, KB or MB.";
+ if (proc == &IsLetterLegalDec)
+ return L"You can only type decimal number (sign character is acceptable).";
+ if (proc == &IsLetterLegalDecHexMixed)
+ return
+ L"You can only type decimal or hexademical number\n"
+ "(sign character is acceptable).\n\n"
+ "When your number contains letter A-F,\n"
+ "it is regarded as hexademical number,\n"
+ "however, if you want to express a heademical number\n"
+ "but all the digits are in 0-9,\n"
+ "you must add a $ prefix to prevent ambiguous.\n"
+ "eg. 10 is a decimal number,\n"
+ "$10 means a hexademical number that is 16 in decimal.";
+ if (proc == &IsLetterLegalUnsignedDecHexMixed)
+ return
+ L"You can only type decimal or hexademical number.\n\n"
+ "When your number contains letter A-F,\n"
+ "it is regarded as hexademical number,\n"
+ "however, if you want to express a heademical number\n"
+ "but all the digits are in 0-9,\n"
+ "you must add a $ prefix to prevent ambiguous.\n"
+ "eg. 10 is a decimal number,\n"
+ "$10 means a hexademical number that is 16 in decimal.";
+
+ return L"Your input contains invalid characters.";
}
// return a letter legal checking function for the specified control with the given id
-bool inline (*GetIsLetterLegal(UINT id))(char letter)
+IsLetterLegalProc GetIsLetterLegalProc(UINT id)
{
switch (id)
{
-
// Game genie text in Cheat and Game Genie Encoder/Decoder
case IDC_CHEAT_GAME_GENIE_TEXT:
case IDC_GAME_GENIE_CODE:
- return IsLetterLegalGG;
-
- // Addresses in Debugger
+ return &IsLetterLegalGG;
+
+ // Addresses in Debugger
case IDC_DEBUGGER_VAL_PCSEEK:
case IDC_DEBUGGER_VAL_PC:
case IDC_DEBUGGER_VAL_A:
@@ -3356,177 +3416,137 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter)
case IDC_DEBUGGER_VAL_Y:
case IDC_DEBUGGER_BOOKMARK:
- // Debugger -> Add breakpoint
+ // Debugger -> Add breakpoint
case IDC_ADDBP_ADDR_START: case IDC_ADDBP_ADDR_END:
- // Array Size, Init value in Symbolic Name in Debugger
+ // Array Size, Init value in Symbolic Name in Debugger
case IDC_EDIT_SYMBOLIC_ARRAY: case IDC_EDIT_SYMBOLIC_INIT:
- // Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat
+ // Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat
case IDC_CHEAT_ADDR: case IDC_CHEAT_VAL: case IDC_CHEAT_COM:
case IDC_CHEAT_VAL_KNOWN: case IDC_CHEAT_VAL_NE_BY:
case IDC_CHEAT_VAL_GT_BY: case IDC_CHEAT_VAL_LT_BY:
- // Address, Value and Compare in Game Genie Encoder/Decoder
+ // Address, Value and Compare in Game Genie Encoder/Decoder
case IDC_GAME_GENIE_ADDR: case IDC_GAME_GENIE_VAL: case IDC_GAME_GENIE_COMP:
- // Address controls in Memory watch
+ // Address controls in Memory watch
case MW_ADDR00: case MW_ADDR01: case MW_ADDR02: case MW_ADDR03:
case MW_ADDR04: case MW_ADDR05: case MW_ADDR06: case MW_ADDR07:
case MW_ADDR08: case MW_ADDR09: case MW_ADDR10: case MW_ADDR11:
case MW_ADDR12: case MW_ADDR13: case MW_ADDR14: case MW_ADDR15:
case MW_ADDR16: case MW_ADDR17: case MW_ADDR18: case MW_ADDR19:
case MW_ADDR20: case MW_ADDR21: case MW_ADDR22: case MW_ADDR23:
+ return &IsLetterLegalMemwatchAddress;
+
case IDC_EDIT_COMPAREADDRESS:
- return IsLetterLegalHex;
+ return &IsLetterLegalHex;
- // Specific Address in RAM Search
- // RAM Watch / RAM Search / Cheat -> Add watch (current only in adding watch operation)
+ // Specific Address in RAM Search
+ // RAM Watch / RAM Search / Cheat -> Add watch (current only in adding watch operation)
case IDC_EDIT_COMPAREADDRESSES:
- return IsLetterLegalHexList;
+ return &IsLetterLegalHexList;
- // Size multiplier and TV Aspect in Video Config
+ // Size multiplier and TV Aspect in Video Config
case IDC_WINSIZE_MUL_X: case IDC_WINSIZE_MUL_Y:
case IDC_TVASPECT_X: case IDC_TVASPECT_Y:
- return IsLetterLegalFloat;
+ return &IsLetterLegalFloat;
- // Cheat code in Cheat
+ // Cheat code in Cheat
case IDC_CHEAT_TEXT:
- return IsLetterLegalCheat;
+ return &IsLetterLegalCheat;
- // PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM and CHR NVRAM in NES Header Editor
+ // PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM and CHR NVRAM in NES Header Editor
case IDC_PRGROM_EDIT: case IDC_PRGRAM_EDIT: case IDC_PRGNVRAM_EDIT:
case IDC_CHRROM_EDIT: case IDC_CHRRAM_EDIT: case IDC_CHRNVRAM_EDIT:
- return IsLetterLegalSize;
+ return &IsLetterLegalSize;
- // Specific value, Different by and Modulo in RAM search
+ // Specific value, Different by and Modulo in RAM search
case IDC_EDIT_COMPAREVALUE:
case IDC_EDIT_DIFFBY:
case IDC_EDIT_MODBY:
- {
- extern char rs_t;
- switch (rs_t)
- {
- case 's': return IsLetterLegalDecHexMixed;
- case 'u': return IsLetterLegalUnsignedDecHexMixed;
- case 'h': return IsLetterLegalHex;
+ {
+ extern char rs_t;
+ switch (rs_t)
+ {
+ case 's': return &IsLetterLegalDecHexMixed;
+ case 'u': return &IsLetterLegalUnsignedDecHexMixed;
+ case 'h': return &IsLetterLegalHex;
+ }
}
- }
}
return NULL;
}
-void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter))
-{
- wchar_t* title = L"Unacceptable Character";
- wchar_t* msg = GetLetterIllegalErrMsg(IsLetterLegal);
-
- EDITBALLOONTIP tip;
- tip.cbStruct = sizeof(EDITBALLOONTIP);
- tip.pszText = msg;
- tip.pszTitle = title;
- tip.ttiIcon = TTI_ERROR;
- SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&tip);
-
- // make a sound
- MessageBeep(0xFFFFFFFF);
-}
-
-inline wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter))
+LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP)
{
- if (IsLetterLegal == 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";
- if (IsLetterLegal == IsLetterLegalHex)
- return L"You can only type characters for hexadecimal number (0-9,A-F).";
- if (IsLetterLegal == IsLetterLegalHexList)
- return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)";
- if (IsLetterLegal == IsLetterLegalCheat)
- return
- L"The cheat code comes into the following 2 formats:\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"
- "All the characters are hexadecimal number (0-9,A-F).\n";
- if (IsLetterLegal == IsLetterLegalFloat)
- return L"You can only type decimal number (decimal point is acceptable).";
- if (IsLetterLegal == IsLetterLegalSize)
- return L"You can only type decimal number followed with B, KB or MB.";
- if (IsLetterLegal == IsLetterLegalDec)
- return L"You can only type decimal number (sign character is acceptable).";
- if (IsLetterLegal == IsLetterLegalDecHexMixed)
- return
- L"You can only type decimal or hexademical number\n"
- "(sign character is acceptable).\n\n"
- "When your number contains letter A-F,\n"
- "it is regarded as hexademical number,\n"
- "however, if you want to express a heademical number\n"
- "but all the digits are in 0-9,\n"
- "you must add a $ prefix to prevent ambiguous.\n"
- "eg. 10 is a decimal number,\n"
- "$10 means a hexademical number that is 16 in decimal.";
- if (IsLetterLegal == IsLetterLegalUnsignedDecHexMixed)
- return
- L"You can only type decimal or hexademical number.\n\n"
- "When your number contains letter A-F,\n"
- "it is regarded as hexademical number,\n"
- "however, if you want to express a heademical number\n"
- "but all the digits are in 0-9,\n"
- "you must add a $ prefix to prevent ambiguous.\n"
- "eg. 10 is a decimal number,\n"
- "$10 means a hexademical number that is 16 in decimal.";
-
- return L"Your input contains invalid characters.";
-}
+ bool through = true;
+ INT_PTR result = 0;
-inline bool IsInputLegal(bool (*IsLetterLegal)(char letter), char letter)
-{
- return !IsLetterLegal || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || IsLetterLegal(letter);
-}
+ switch (msg)
+ {
+ case WM_PASTE:
+ {
-inline bool IsLetterLegalGG(char letter)
-{
- char ch = toupper(letter);
- for (int i = 0; GameGenieLetters[i]; ++i)
- if (GameGenieLetters[i] == ch)
- return true;
- return false;
-}
+ IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
-inline bool IsLetterLegalHex(char letter)
-{
- return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f';
-}
+ if (isLetterLegal)
+ {
+ if (OpenClipboard(hwnd))
+ {
+ HANDLE handle = GetClipboardData(CF_TEXT);
+ if (handle)
+ {
-inline bool IsLetterLegalHexList(char letter)
-{
- return IsLetterLegalHex(letter) || letter == ',' || letter == ' ';
-}
+ // get the original clipboard string
+ char* clipStr = (char*)GlobalLock(handle);
-inline bool IsLetterLegalCheat(char letter)
-{
- return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?';
-}
+ // check if the text in clipboard has illegal characters
+ int len = strlen(clipStr);
+ for (int i = 0; i < len; ++i)
+ {
+ if (!isLetterLegal(i,clipStr[i]))
+ {
+ through = false;
+ // Show Edit control tip, just like the control with ES_NUMBER do
+ ShowLetterIllegalBalloonTip(hwnd, isLetterLegal);
+ break;
+ }
+ }
+ GlobalUnlock(handle);
+ CloseClipboard();
+ }
+ }
+ }
+ }
+ break;
-inline bool IsLetterLegalSize(char letter)
-{
- return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B';
-}
+ case WM_CHAR:
+ {
+ DWORD cpBegin, cpEnd;
+ SendMessage(hwnd, EM_GETSEL, (LPARAM)&cpBegin, (LPARAM)&cpEnd);
+ IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd));
+ through = IsInputLegal(isLetterLegal, (int)cpBegin, wP);
+ if (!through)
+ ShowLetterIllegalBalloonTip(hwnd, isLetterLegal);
+ }
+ }
-inline bool IsLetterLegalDec(char letter)
-{
- return letter >= '0' && letter <= '9' || letter == '-' || letter == '+';
+ return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result;
}
-inline bool IsLetterLegalFloat(char letter)
+void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc proc)
{
- return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+';
-}
+ wchar_t* title = L"Unacceptable Character";
+ wchar_t* msg = GetLetterIllegalErrMsg(proc);
-inline bool IsLetterLegalDecHexMixed(char letter)
-{
- return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+';
-}
+ EDITBALLOONTIP tip;
+ tip.cbStruct = sizeof(EDITBALLOONTIP);
+ tip.pszText = msg;
+ tip.pszTitle = title;
+ tip.ttiIcon = TTI_ERROR;
+ SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&tip);
-inline bool IsLetterLegalUnsignedDecHexMixed(char letter)
-{
- return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$';
+ // make a sound
+ MessageBeep(0xFFFFFFFF);
}
diff --git a/src/drivers/win/window.h b/src/drivers/win/window.h
index 0127ad97..da716a69 100644
--- a/src/drivers/win/window.h
+++ b/src/drivers/win/window.h
@@ -128,19 +128,9 @@ struct HOTKEYMENUINDEX {
void UpdateMenuHotkeys(FCEUMENU_INDEX index);
int GetCurrentContextIndex();
-inline bool (*GetIsLetterLegal(UINT id))(char letter);
-inline wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter));
-void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter));
-inline bool IsInputLegal(bool(*IsLetterLegal)(char letter), char letter);
-inline bool IsLetterLegalGG(char letter);
-inline bool IsLetterLegalHex(char letter);
-inline bool IsLetterLegalHexList(char letter);
-inline bool IsLetterLegalCheat(char letter);
-inline bool IsLetterLegalDec(char letter);
-inline bool IsLetterLegalSize(char letter);
-inline bool IsLetterLegalFloat(char letter);
-inline bool IsLetterLegalDecHexMixed(char letter);
-inline bool IsLetterLegalUnsignedDecHexMixed(char letter);
+typedef bool (*IsLetterLegalProc)(int index, char ch);
+bool IsLetterLegalHex(int index, char letter);
+void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc);
extern WNDPROC DefaultEditCtrlProc;
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP);
diff --git a/src/input.cpp b/src/input.cpp
index c1dcd536..592d5e50 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -1271,6 +1271,7 @@ static void RamSearchOpNE(void) {
}
extern int globalCheatDisabled;
+extern unsigned int FrozenAddressCount;
static void ToggleCheats()
{
FCEUI_GlobalToggleCheat(globalCheatDisabled);