ADDED possibility to edit GB cheats
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@320 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
46ea60b680
commit
c73edf150f
12
VBA.vcproj
12
VBA.vcproj
|
@ -601,10 +601,6 @@
|
||||||
RelativePath=".\src\armdis.cpp"
|
RelativePath=".\src\armdis.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\Cheats.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\CheatSearch.cpp"
|
RelativePath=".\src\CheatSearch.cpp"
|
||||||
>
|
>
|
||||||
|
@ -697,6 +693,10 @@
|
||||||
RelativePath=".\src\bios.cpp"
|
RelativePath=".\src\bios.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Cheats.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\EEprom.cpp"
|
RelativePath=".\src\EEprom.cpp"
|
||||||
>
|
>
|
||||||
|
@ -1097,6 +1097,10 @@
|
||||||
RelativePath=".\src\win32\stdafx.cpp"
|
RelativePath=".\src\win32\stdafx.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\win32\VBA-M.ico"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\win32\VBA.cpp"
|
RelativePath=".\src\win32\VBA.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -185,18 +185,18 @@ bool gbVerifyGsCode(const char *code)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbAddGsCheat(const char *code, const char *desc)
|
bool gbAddGsCheat(const char *code, const char *desc)
|
||||||
{
|
{
|
||||||
if(gbCheatNumber > 999) {
|
if(gbCheatNumber > 999) {
|
||||||
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
|
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
|
||||||
N_("Maximum number of cheats reached."));
|
N_("Maximum number of cheats reached."));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!gbVerifyGsCode(code)) {
|
if(!gbVerifyGsCode(code)) {
|
||||||
systemMessage(MSG_INVALID_GAMESHARK_CODE,
|
systemMessage(MSG_INVALID_GAMESHARK_CODE,
|
||||||
N_("Invalid GameShark code: %s"), code);
|
N_("Invalid GameShark code: %s"), code);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = gbCheatNumber;
|
int i = gbCheatNumber;
|
||||||
|
@ -230,6 +230,8 @@ void gbAddGsCheat(const char *code, const char *desc)
|
||||||
N_("Unsupported GameShark code type : %s"), code);
|
N_("Unsupported GameShark code type : %s"), code);
|
||||||
|
|
||||||
gbCheatNumber++;
|
gbCheatNumber++;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gbVerifyGgCode(const char *code)
|
bool gbVerifyGgCode(const char *code)
|
||||||
|
@ -303,18 +305,18 @@ bool gbVerifyGgCode(const char *code)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbAddGgCheat(const char *code, const char *desc)
|
bool gbAddGgCheat(const char *code, const char *desc)
|
||||||
{
|
{
|
||||||
if(gbCheatNumber > 999) {
|
if(gbCheatNumber > 999) {
|
||||||
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
|
systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS,
|
||||||
N_("Maximum number of cheats reached."));
|
N_("Maximum number of cheats reached."));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!gbVerifyGgCode(code)) {
|
if(!gbVerifyGgCode(code)) {
|
||||||
systemMessage(MSG_INVALID_GAMEGENIE_CODE,
|
systemMessage(MSG_INVALID_GAMEGENIE_CODE,
|
||||||
N_("Invalid GameGenie code: %s"), code);
|
N_("Invalid GameGenie code: %s"), code);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = gbCheatNumber;
|
int i = gbCheatNumber;
|
||||||
|
@ -355,6 +357,8 @@ void gbAddGgCheat(const char *code, const char *desc)
|
||||||
gbCheatMap[gbCheatList[i].address] = true;
|
gbCheatMap[gbCheatList[i].address] = true;
|
||||||
|
|
||||||
gbCheatNumber++;
|
gbCheatNumber++;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbCheatRemove(int i)
|
void gbCheatRemove(int i)
|
||||||
|
|
|
@ -37,20 +37,23 @@ struct gbCheat {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void gbCheatsSaveGame(gzFile);
|
void gbCheatsSaveGame(gzFile);
|
||||||
extern void gbCheatsReadGame(gzFile, int);
|
void gbCheatsReadGame(gzFile, int);
|
||||||
extern void gbCheatsSaveCheatList(const char *);
|
void gbCheatsSaveCheatList(const char *);
|
||||||
extern bool gbCheatsLoadCheatList(const char *);
|
bool gbCheatsLoadCheatList(const char *);
|
||||||
extern bool gbCheatReadGSCodeFile(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 int gbCheatNumber;
|
||||||
extern gbCheat gbCheatList[1000];
|
extern gbCheat gbCheatList[1000];
|
||||||
|
|
|
@ -39,14 +39,12 @@ static char THIS_FILE[] = __FILE__;
|
||||||
|
|
||||||
static bool winGbCheatAddVerifyGs(const char *code, const char *desc)
|
static bool winGbCheatAddVerifyGs(const char *code, const char *desc)
|
||||||
{
|
{
|
||||||
gbAddGsCheat(code, desc);
|
return gbAddGsCheat(code, desc);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool winGbCheatAddVerifyGg(const char *code, const char *desc)
|
static bool winGbCheatAddVerifyGg(const char *code, const char *desc)
|
||||||
{
|
{
|
||||||
gbAddGgCheat(code, desc);
|
return gbAddGgCheat(code, desc);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -786,7 +784,8 @@ BEGIN_MESSAGE_MAP(GBCheatList, CDialog)
|
||||||
ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
|
ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll)
|
||||||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
|
ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
ON_NOTIFY(NM_DBLCLK, IDC_CHEAT_LIST, &GBCheatList::OnNMDblclkCheatList)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// GBCheatList message handlers
|
// GBCheatList message handlers
|
||||||
|
@ -949,16 +948,17 @@ AddGBCode::AddGBCode(bool (*verify)(const char *,const char*), int len, const ch
|
||||||
addVerify = verify;
|
addVerify = verify;
|
||||||
addLength = len;
|
addLength = len;
|
||||||
addTitle = title;
|
addTitle = title;
|
||||||
|
m_onlyOneLine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddGBCode::DoDataExchange(CDataExchange* pDX)
|
void AddGBCode::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
//{{AFX_DATA_MAP(AddGBCode)
|
|
||||||
DDX_Control(pDX, IDC_DESC, m_desc);
|
DDX_Control(pDX, IDC_DESC, m_desc);
|
||||||
DDX_Control(pDX, IDC_CODE, m_code);
|
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");
|
StringTokenizer st(buffer, " \t\n\r");
|
||||||
const char *t = st.next();
|
const char *t = st.next();
|
||||||
while(t) {
|
while(t) {
|
||||||
addVerify(t, desc);
|
if( !addVerify(t, desc) ) {
|
||||||
t = st.next();
|
EndDialog( IDABORT );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( m_onlyOneLine ) break;
|
||||||
|
t = st.next();
|
||||||
}
|
}
|
||||||
EndDialog(TRUE);
|
EndDialog( IDOK );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddGBCode::OnCancel()
|
void AddGBCode::OnCancel()
|
||||||
{
|
{
|
||||||
EndDialog(FALSE);
|
EndDialog( IDCANCEL );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL AddGBCode::OnInitDialog()
|
BOOL AddGBCode::OnInitDialog()
|
||||||
|
@ -1005,3 +1009,41 @@ BOOL AddGBCode::OnInitDialog()
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// 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;
|
||||||
|
}
|
||||||
|
|
|
@ -171,7 +171,9 @@ class GBCheatList : public CDialog
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
public:
|
||||||
|
afx_msg void OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AddGBCode dialog
|
// AddGBCode dialog
|
||||||
|
@ -187,6 +189,9 @@ class AddGBCode : public CDialog
|
||||||
enum { IDD = IDD_ADD_CHEAT_DLG };
|
enum { IDD = IDD_ADD_CHEAT_DLG };
|
||||||
CEdit m_desc;
|
CEdit m_desc;
|
||||||
CEdit m_code;
|
CEdit m_code;
|
||||||
|
CString m_descVal;
|
||||||
|
CString m_codeVal;
|
||||||
|
bool m_onlyOneLine;
|
||||||
//}}AFX_DATA
|
//}}AFX_DATA
|
||||||
|
|
||||||
int addLength;
|
int addLength;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define APSTUDIO_READONLY_SYMBOLS
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
@ -2233,5 +2235,7 @@ END
|
||||||
// Generated from the TEXTINCLUDE 3 resource.
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
#endif // not APSTUDIO_INVOKED
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue