diff --git a/VBA.vcproj b/VBA.vcproj
index b6b4ee4a..181cc348 100644
--- a/VBA.vcproj
+++ b/VBA.vcproj
@@ -601,10 +601,6 @@
RelativePath=".\src\armdis.cpp"
>
-
-
@@ -697,6 +693,10 @@
RelativePath=".\src\bios.cpp"
>
+
+
@@ -1097,6 +1097,10 @@
RelativePath=".\src\win32\stdafx.cpp"
>
+
+
diff --git a/src/gb/gbCheats.cpp b/src/gb/gbCheats.cpp
index 4642339a..7b93658a 100644
--- a/src/gb/gbCheats.cpp
+++ b/src/gb/gbCheats.cpp
@@ -185,18 +185,18 @@ bool gbVerifyGsCode(const char *code)
return true;
}
-void gbAddGsCheat(const char *code, const char *desc)
+bool gbAddGsCheat(const char *code, const char *desc)
{
if(gbCheatNumber > 999) {
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
N_("Maximum number of cheats reached."));
- return;
+ return false;
}
if(!gbVerifyGsCode(code)) {
systemMessage(MSG_INVALID_GAMESHARK_CODE,
N_("Invalid GameShark code: %s"), code);
- return;
+ return false;
}
int i = gbCheatNumber;
@@ -230,6 +230,8 @@ void gbAddGsCheat(const char *code, const char *desc)
N_("Unsupported GameShark code type : %s"), code);
gbCheatNumber++;
+
+ return true;
}
bool gbVerifyGgCode(const char *code)
@@ -303,18 +305,18 @@ bool gbVerifyGgCode(const char *code)
return true;
}
-void gbAddGgCheat(const char *code, const char *desc)
+bool gbAddGgCheat(const char *code, const char *desc)
{
if(gbCheatNumber > 999) {
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
N_("Maximum number of cheats reached."));
- return;
+ return false;
}
if(!gbVerifyGgCode(code)) {
systemMessage(MSG_INVALID_GAMEGENIE_CODE,
N_("Invalid GameGenie code: %s"), code);
- return;
+ return false;
}
int i = gbCheatNumber;
@@ -355,6 +357,8 @@ void gbAddGgCheat(const char *code, const char *desc)
gbCheatMap[gbCheatList[i].address] = true;
gbCheatNumber++;
+
+ return true;
}
void gbCheatRemove(int i)
diff --git a/src/gb/gbCheats.h b/src/gb/gbCheats.h
index 3aff0a8c..a9c4517b 100644
--- a/src/gb/gbCheats.h
+++ b/src/gb/gbCheats.h
@@ -37,20 +37,23 @@ struct gbCheat {
bool enabled;
};
-extern void gbCheatsSaveGame(gzFile);
-extern void gbCheatsReadGame(gzFile, int);
-extern void gbCheatsSaveCheatList(const char *);
-extern bool gbCheatsLoadCheatList(const char *);
-extern bool gbCheatReadGSCodeFile(const char *);
+void gbCheatsSaveGame(gzFile);
+void gbCheatsReadGame(gzFile, int);
+void gbCheatsSaveCheatList(const char *);
+bool gbCheatsLoadCheatList(const char *);
+bool gbCheatReadGSCodeFile(const char *);
+
+bool gbAddGsCheat(const char *, const char*);
+bool gbAddGgCheat(const char *, const char*);
+void gbCheatRemove(int);
+void gbCheatRemoveAll();
+void gbCheatEnable(int);
+void gbCheatDisable(int);
+u8 gbCheatRead(u16);
+void gbCheatWrite(bool);
+bool gbVerifyGsCode(const char *code);
+bool gbVerifyGgCode(const char *code);
-extern void gbAddGsCheat(const char *, const char*);
-extern void gbAddGgCheat(const char *, const char*);
-extern void gbCheatRemove(int);
-extern void gbCheatRemoveAll();
-extern void gbCheatEnable(int);
-extern void gbCheatDisable(int);
-extern u8 gbCheatRead(u16);
-extern void gbCheatWrite(bool);
extern int gbCheatNumber;
extern gbCheat gbCheatList[1000];
diff --git a/src/win32/GBCheatsDlg.cpp b/src/win32/GBCheatsDlg.cpp
index 621594cd..e6b56701 100644
--- a/src/win32/GBCheatsDlg.cpp
+++ b/src/win32/GBCheatsDlg.cpp
@@ -39,14 +39,12 @@ static char THIS_FILE[] = __FILE__;
static bool winGbCheatAddVerifyGs(const char *code, const char *desc)
{
- gbAddGsCheat(code, desc);
- return true;
+ return gbAddGsCheat(code, desc);
}
static bool winGbCheatAddVerifyGg(const char *code, const char *desc)
{
- gbAddGgCheat(code, desc);
- return true;
+ return gbAddGgCheat(code, desc);
}
/////////////////////////////////////////////////////////////////////////////
@@ -786,7 +784,8 @@ BEGIN_MESSAGE_MAP(GBCheatList, CDialog)
ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
//}}AFX_MSG_MAP
- END_MESSAGE_MAP()
+ ON_NOTIFY(NM_DBLCLK, IDC_CHEAT_LIST, &GBCheatList::OnNMDblclkCheatList)
+END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// GBCheatList message handlers
@@ -949,16 +948,17 @@ AddGBCode::AddGBCode(bool (*verify)(const char *,const char*), int len, const ch
addVerify = verify;
addLength = len;
addTitle = title;
+ m_onlyOneLine = false;
}
void AddGBCode::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(AddGBCode)
DDX_Control(pDX, IDC_DESC, m_desc);
DDX_Control(pDX, IDC_CODE, m_code);
- //}}AFX_DATA_MAP
+ DDX_Text(pDX, IDC_DESC, m_descVal);
+ DDX_Text(pDX, IDC_CODE, m_codeVal);
}
@@ -982,15 +982,19 @@ void AddGBCode::OnOk()
StringTokenizer st(buffer, " \t\n\r");
const char *t = st.next();
while(t) {
- addVerify(t, desc);
- t = st.next();
+ if( !addVerify(t, desc) ) {
+ EndDialog( IDABORT );
+ return;
+ }
+ if( m_onlyOneLine ) break;
+ t = st.next();
}
- EndDialog(TRUE);
+ EndDialog( IDOK );
}
void AddGBCode::OnCancel()
{
- EndDialog(FALSE);
+ EndDialog( IDCANCEL );
}
BOOL AddGBCode::OnInitDialog()
@@ -1005,3 +1009,41 @@ BOOL AddGBCode::OnInitDialog()
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
+
+void GBCheatList::OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult)
+{
+ int selection = m_list.GetSelectionMark();
+ // get index value of corresponding code in cheatlist
+ if( selection == -1 ) return;
+
+ LVITEM item;
+ ZeroMemory( &item, sizeof(item) );
+ item.mask = LVIF_PARAM;
+ item.iItem = selection;
+ if( FALSE == m_list.GetItem( &item ) ) return;
+
+ // modify code
+ INT_PTR res;
+ if( gbVerifyGsCode( gbCheatList[ item.lParam ].cheatCode ) ) {
+ CString temp = winResLoadString(IDS_ADD_GS_CODE);
+ AddGBCode dlg( winGbCheatAddVerifyGs, 8, temp );
+ dlg.m_codeVal = gbCheatList[ item.lParam ].cheatCode;
+ dlg.m_descVal = gbCheatList[ item.lParam ].cheatDesc;
+ dlg.m_onlyOneLine = true;
+ res = dlg.DoModal();
+ } else if( gbVerifyGgCode( gbCheatList[ item.lParam ].cheatCode ) ) {
+ CString temp = winResLoadString(IDS_ADD_GG_CODE);
+ AddGBCode dlg( winGbCheatAddVerifyGg, 11, temp );
+ dlg.m_codeVal = gbCheatList[ item.lParam ].cheatCode;
+ dlg.m_descVal = gbCheatList[ item.lParam ].cheatDesc;
+ dlg.m_onlyOneLine = true;
+ res = dlg.DoModal();
+ }
+
+ if( res == IDOK ) {
+ gbCheatRemove( item.lParam ); // remove old cheat
+ refresh();
+ }
+
+ *pResult = 0;
+}
diff --git a/src/win32/GBCheatsDlg.h b/src/win32/GBCheatsDlg.h
index 6e754d40..12106f47 100644
--- a/src/win32/GBCheatsDlg.h
+++ b/src/win32/GBCheatsDlg.h
@@ -171,7 +171,9 @@ class GBCheatList : public CDialog
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
- };
+public:
+ afx_msg void OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult);
+};
/////////////////////////////////////////////////////////////////////////////
// AddGBCode dialog
@@ -187,6 +189,9 @@ class AddGBCode : public CDialog
enum { IDD = IDD_ADD_CHEAT_DLG };
CEdit m_desc;
CEdit m_code;
+ CString m_descVal;
+ CString m_codeVal;
+ bool m_onlyOneLine;
//}}AFX_DATA
int addLength;
diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc
index 6e097a70..48f7dc43 100644
--- a/src/win32/VBA.rc
+++ b/src/win32/VBA.rc
@@ -1,3 +1,5 @@
+// Microsoft Visual C++ generated resource script.
+//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
@@ -2233,5 +2235,7 @@ END
// Generated from the TEXTINCLUDE 3 resource.
//
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+