1 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
2 // Copyright (C) 1999-2003 Forgotten
3 // Copyright (C) 2004 Forgotten and the VBA development team
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2, or(at your option)
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 // GBACheats.cpp : implementation file
24 #include "GBACheats.h"
26 #include "../System.h"
27 #include "../Cheats.h"
28 #include "../CheatSearch.h"
30 #include "../Globals.h"
33 #include "StringTokenizer.h"
34 #include "WinResUtil.h"
39 static char THIS_FILE
[] = __FILE__
;
42 /////////////////////////////////////////////////////////////////////////////
43 // GBACheatSearch dialog
45 GBACheatSearch::GBACheatSearch(CWnd
* pParent
/*=NULL*/)
46 : CDialog(GBACheatSearch::IDD
, pParent
)
48 //{{AFX_DATA_INIT(GBACheatSearch)
58 GBACheatSearch::~GBACheatSearch()
64 void GBACheatSearch::DoDataExchange(CDataExchange
* pDX
)
66 CDialog::DoDataExchange(pDX
);
67 //{{AFX_DATA_MAP(GBACheatSearch)
68 DDX_Control(pDX
, IDC_VALUE
, m_value
);
69 DDX_Control(pDX
, IDC_CHEAT_LIST
, m_list
);
70 DDX_Radio(pDX
, IDC_OLD_VALUE
, valueType
);
71 DDX_Radio(pDX
, IDC_SIZE_8
, sizeType
);
72 DDX_Radio(pDX
, IDC_EQ
, searchType
);
73 DDX_Radio(pDX
, IDC_SIGNED
, numberType
);
74 DDX_Check(pDX
, IDC_UPDATE
, updateValues
);
79 BEGIN_MESSAGE_MAP(GBACheatSearch
, CDialog
)
80 //{{AFX_MSG_MAP(GBACheatSearch)
81 ON_BN_CLICKED(ID_OK
, OnOk
)
82 ON_BN_CLICKED(IDC_START
, OnStart
)
83 ON_BN_CLICKED(IDC_SEARCH
, OnSearch
)
84 ON_BN_CLICKED(IDC_ADD_CHEAT
, OnAddCheat
)
85 ON_BN_CLICKED(IDC_UPDATE
, OnUpdate
)
86 ON_NOTIFY(LVN_GETDISPINFO
, IDC_CHEAT_LIST
, OnGetdispinfoCheatList
)
87 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_CHEAT_LIST
, OnItemchangedCheatList
)
88 ON_CONTROL_RANGE(BN_CLICKED
, IDC_OLD_VALUE
, IDC_SPECIFIC_VALUE
, OnValueType
)
89 ON_CONTROL_RANGE(BN_CLICKED
, IDC_EQ
, IDC_GE
, OnSearchType
)
90 ON_CONTROL_RANGE(BN_CLICKED
, IDC_SIGNED
, IDC_HEXADECIMAL
, OnNumberType
)
91 ON_CONTROL_RANGE(BN_CLICKED
, IDC_SIZE_8
, IDC_SIZE_32
, OnSizeType
)
95 /////////////////////////////////////////////////////////////////////////////
96 // GBACheatSearch message handlers
98 void GBACheatSearch::OnOk()
103 void GBACheatSearch::OnStart()
105 if(cheatSearchData
.count
== 0) {
106 CheatSearchBlock
*block
= &cheatSearchData
.blocks
[0];
107 block
->size
= 0x40000;
108 block
->offset
= 0x2000000;
109 block
->bits
= (u8
*)malloc(0x40000>>3);
110 block
->data
= workRAM
;
111 block
->saved
= (u8
*)malloc(0x40000);
113 block
= &cheatSearchData
.blocks
[1];
114 block
->size
= 0x8000;
115 block
->offset
= 0x3000000;
116 block
->bits
= (u8
*)malloc(0x8000>>3);
117 block
->data
= internalRAM
;
118 block
->saved
= (u8
*)malloc(0x8000);
120 cheatSearchData
.count
= 2;
123 cheatSearchStart(&cheatSearchData
);
124 GetDlgItem(IDC_SEARCH
)->EnableWindow(TRUE
);
127 void GBACheatSearch::OnSearch()
132 cheatSearch(&cheatSearchData
,
137 m_value
.GetWindowText(buffer
);
138 if(buffer
.IsEmpty()) {
139 systemMessage(IDS_NUMBER_CANNOT_BE_EMPTY
, "Number cannot be empty");
145 sscanf(buffer
, "%d", &value
);
148 sscanf(buffer
, "%u", &value
);
151 sscanf(buffer
, "%x", &value
);
153 cheatSearchValue(&cheatSearchData
,
163 cheatSearchUpdateValues(&cheatSearchData
);
166 void GBACheatSearch::OnAddCheat()
168 int mark
= m_list
.GetSelectionMark();
172 memset(&item
,0, sizeof(item
));
173 item
.mask
= LVIF_PARAM
;
175 if(m_list
.GetItem(&item
)) {
176 AddCheat
dlg((u32
)item
.lParam
);
182 void GBACheatSearch::OnUpdate()
184 if(GetDlgItem(IDC_UPDATE
)->SendMessage(BM_GETCHECK
,
189 updateValues
= false;
190 regSetDwordValue("cheatsUpdate", updateValues
);
193 void GBACheatSearch::OnGetdispinfoCheatList(NMHDR
* pNMHDR
, LRESULT
* pResult
)
195 LV_DISPINFO
* info
= (LV_DISPINFO
*)pNMHDR
;
196 if(info
->item
.mask
& LVIF_TEXT
) {
197 int index
= info
->item
.iItem
;
198 int col
= info
->item
.iSubItem
;
202 strcpy(info
->item
.pszText
, data
[index
].address
);
205 strcpy(info
->item
.pszText
, data
[index
].oldValue
);
208 strcpy(info
->item
.pszText
, data
[index
].newValue
);
216 void GBACheatSearch::OnItemchangedCheatList(NMHDR
* pNMHDR
, LRESULT
* pResult
)
218 GetDlgItem(IDC_ADD_CHEAT
)->EnableWindow(m_list
.GetSelectionMark() != -1);
222 BOOL
GBACheatSearch::OnInitDialog()
224 CDialog::OnInitDialog();
226 CString temp
= winResLoadString(IDS_ADDRESS
);
228 m_list
.InsertColumn(0, temp
, LVCFMT_CENTER
, 125, 0);
230 temp
= winResLoadString(IDS_OLD_VALUE
);
231 m_list
.InsertColumn(1, temp
, LVCFMT_CENTER
, 125, 1);
233 temp
= winResLoadString(IDS_NEW_VALUE
);
234 m_list
.InsertColumn(2, temp
, LVCFMT_CENTER
, 125, 2);
236 m_list
.SetFont(CFont::FromHandle((HFONT
)GetStockObject(SYSTEM_FIXED_FONT
)),
239 m_list
.SetExtendedStyle(LVS_EX_FULLROWSELECT
);
241 if(!cheatSearchData
.count
) {
242 GetDlgItem(IDC_SEARCH
)->EnableWindow(FALSE
);
243 GetDlgItem(IDC_ADD_CHEAT
)->EnableWindow(FALSE
);
246 valueType
= regQueryDwordValue("cheatsValueType", 0);
247 if(valueType
< 0 || valueType
> 1)
250 searchType
= regQueryDwordValue("cheatsSearchType", SEARCH_EQ
);
251 if(searchType
> 5 || searchType
< 0)
254 numberType
= regQueryDwordValue("cheatsNumberType", 2);
255 if(numberType
< 0 || numberType
> 2)
258 sizeType
= regQueryDwordValue("cheatsSizeType", 0);
259 if(sizeType
< 0 || sizeType
> 2)
262 updateValues
= regQueryDwordValue("cheatsUpdate", 0) ?
268 m_value
.EnableWindow(FALSE
);
271 if(cheatSearchData
.count
) {
275 return TRUE
; // return TRUE unless you set the focus to a control
276 // EXCEPTION: OCX Property Pages should return FALSE
279 void GBACheatSearch::addChanges(bool showMsgs
)
281 int count
= cheatSearchGetCount(&cheatSearchData
, sizeType
);
283 m_list
.DeleteAllItems();
287 systemMessage(IDS_SEARCH_PRODUCED_TOO_MANY
,
288 "Search produced %d results. Please refine better",
295 systemMessage(IDS_SEARCH_PRODUCED_NO_RESULTS
,
296 "Search produced no results.");
300 m_list
.SetItemCount(count
);
304 data
= (WinCheatsData
*)calloc(count
,sizeof(WinCheatsData
));
317 if(numberType
== 0) {
318 for(int i
= 0; i
< cheatSearchData
.count
; i
++) {
319 CheatSearchBlock
*block
= &cheatSearchData
.blocks
[i
];
321 for(int j
= 0; j
< block
->size
; j
+= inc
) {
322 if(IS_BIT_SET(block
->bits
, j
)) {
325 cheatSearchSignedRead(block
->saved
,
328 cheatSearchSignedRead(block
->data
,
335 for(int i
= 0; i
< cheatSearchData
.count
; i
++) {
336 CheatSearchBlock
*block
= &cheatSearchData
.blocks
[i
];
338 for(int j
= 0; j
< block
->size
; j
+= inc
) {
339 if(IS_BIT_SET(block
->bits
, j
)) {
342 cheatSearchRead(block
->saved
,
345 cheatSearchRead(block
->data
,
353 for(int i
= 0; i
< count
; i
++) {
356 item
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_STATE
;
359 item
.lParam
= data
[i
].addr
;
362 item
.pszText
= LPSTR_TEXTCALLBACK
;
363 m_list
.InsertItem(&item
);
365 m_list
.SetItemText(i
, 1, LPSTR_TEXTCALLBACK
);
366 m_list
.SetItemText(i
, 2, LPSTR_TEXTCALLBACK
);
370 void GBACheatSearch::addChange(int index
, u32 address
, u32 oldValue
, u32 newValue
)
372 data
[index
].addr
= address
;
373 sprintf(data
[index
].address
, "%08x",address
);
376 sprintf(data
[index
].oldValue
, "%d", oldValue
);
377 sprintf(data
[index
].newValue
, "%d", newValue
);
380 sprintf(data
[index
].oldValue
, "%u", oldValue
);
381 sprintf(data
[index
].newValue
, "%u", newValue
);
386 sprintf(data
[index
].oldValue
, "%02x", oldValue
);
387 sprintf(data
[index
].newValue
, "%02x", newValue
);
390 sprintf(data
[index
].oldValue
, "%04x", oldValue
);
391 sprintf(data
[index
].newValue
, "%04x", newValue
);
394 sprintf(data
[index
].oldValue
, "%08x", oldValue
);
395 sprintf(data
[index
].newValue
, "%08x", newValue
);
401 void GBACheatSearch::OnValueType(UINT id
)
406 m_value
.EnableWindow(FALSE
);
407 regSetDwordValue("cheatsValueType", 0);
409 case IDC_SPECIFIC_VALUE
:
411 m_value
.EnableWindow(TRUE
);
412 regSetDwordValue("cheatsValueType", 1);
417 void GBACheatSearch::OnSearchType(UINT id
)
421 searchType
= SEARCH_EQ
;
422 regSetDwordValue("cheatsSearchType", 0);
425 searchType
= SEARCH_NE
;
426 regSetDwordValue("cheatsSearchType", 1);
429 searchType
= SEARCH_LT
;
430 regSetDwordValue("cheatsSearchType", 2);
433 searchType
= SEARCH_LE
;
434 regSetDwordValue("cheatsSearchType", 3);
437 searchType
= SEARCH_GT
;
438 regSetDwordValue("cheatsSearchType", 4);
441 searchType
= SEARCH_GE
;
442 regSetDwordValue("cheatsSearchType", 5);
447 void GBACheatSearch::OnNumberType(UINT id
)
452 regSetDwordValue("cheatsNumberType", 0);
453 if(m_list
.GetItemCount()) {
459 regSetDwordValue("cheatsNumberType", 1);
460 if(m_list
.GetItemCount()) {
464 case IDC_HEXADECIMAL
:
466 regSetDwordValue("cheatsNumberType", 2);
467 if(m_list
.GetItemCount()) {
474 void GBACheatSearch::OnSizeType(UINT id
)
479 regSetDwordValue("cheatsSizeType", 0);
480 if(m_list
.GetItemCount()) {
486 regSetDwordValue("cheatsSizeType", 1);
487 if(m_list
.GetItemCount()) {
493 regSetDwordValue("cheatsSizeType", 2);
494 if(m_list
.GetItemCount()) {
500 /////////////////////////////////////////////////////////////////////////////
504 AddCheat::AddCheat(u32 address
, CWnd
* pParent
/*=NULL*/)
505 : CDialog(AddCheat::IDD
, pParent
)
507 //{{AFX_DATA_INIT(AddCheat)
511 this->address
= address
;
515 void AddCheat::DoDataExchange(CDataExchange
* pDX
)
517 CDialog::DoDataExchange(pDX
);
518 //{{AFX_DATA_MAP(AddCheat)
519 DDX_Control(pDX
, IDC_VALUE
, m_value
);
520 DDX_Control(pDX
, IDC_DESC
, m_desc
);
521 DDX_Control(pDX
, IDC_ADDRESS
, m_address
);
522 DDX_Radio(pDX
, IDC_SIZE_8
, sizeType
);
523 DDX_Radio(pDX
, IDC_SIGNED
, numberType
);
528 BEGIN_MESSAGE_MAP(AddCheat
, CDialog
)
529 //{{AFX_MSG_MAP(AddCheat)
530 ON_BN_CLICKED(ID_OK
, OnOk
)
531 ON_BN_CLICKED(ID_CANCEL
, OnCancel
)
532 ON_CONTROL_RANGE(BN_CLICKED
, IDC_SIGNED
, IDC_HEXADECIMAL
, OnNumberType
)
533 ON_CONTROL_RANGE(BN_CLICKED
, IDC_SIZE_8
, IDC_SIZE_32
, OnSizeType
)
537 /////////////////////////////////////////////////////////////////////////////
538 // AddCheat message handlers
540 void AddCheat::OnOk()
548 void AddCheat::OnCancel()
553 BOOL
AddCheat::OnInitDialog()
555 CDialog::OnInitDialog();
559 buffer
.Format("%08x", address
);
560 m_address
.SetWindowText(buffer
);
561 m_address
.EnableWindow(FALSE
);
564 numberType
= regQueryDwordValue("cheatsNumberType", 2);
565 if(numberType
< 0 || numberType
> 2)
568 sizeType
= regQueryDwordValue("cheatsSizeType", 0);
569 if(sizeType
< 0 || sizeType
> 2)
574 GetDlgItem(IDC_DESC
)->SendMessage(EM_LIMITTEXT
,
578 GetDlgItem(IDC_SIZE_8
)->EnableWindow(FALSE
);
579 GetDlgItem(IDC_SIZE_16
)->EnableWindow(FALSE
);
580 GetDlgItem(IDC_SIZE_32
)->EnableWindow(FALSE
);
581 GetDlgItem(IDC_HEXADECIMAL
)->EnableWindow(FALSE
);
582 GetDlgItem(IDC_UNSIGNED
)->EnableWindow(FALSE
);
583 GetDlgItem(IDC_SIGNED
)->EnableWindow(FALSE
);
588 return TRUE
; // return TRUE unless you set the focus to a control
589 // EXCEPTION: OCX Property Pages should return FALSE
592 void AddCheat::OnNumberType(UINT id
)
597 regSetDwordValue("cheatsNumberType", 0);
601 regSetDwordValue("cheatsNumberType", 1);
603 case IDC_HEXADECIMAL
:
605 regSetDwordValue("cheatsNumberType", 2);
610 void AddCheat::OnSizeType(UINT id
)
615 regSetDwordValue("cheatsSizeType", 0);
619 regSetDwordValue("cheatsSizeType", 1);
623 regSetDwordValue("cheatsSizeType", 2);
628 bool AddCheat::addCheat()
633 m_address
.GetWindowText(buffer
);
635 sscanf(buffer
, "%x", &address
);
636 if((address
>= 0x02000000 && address
< 0x02040000) ||
637 (address
>= 0x03000000 && address
< 0x03008000)) {
639 systemMessage(IDS_INVALID_ADDRESS
, "Invalid address: %08x", address
);
643 if(sizeType
== 1 && address
& 1) {
644 systemMessage(IDS_MISALIGNED_HALFWORD
,
645 "Misaligned half-word address: %08x", address
);
648 if(sizeType
== 2 && address
& 3) {
649 systemMessage(IDS_MISALIGNED_WORD
,
650 "Misaligned word address: %08x", address
);
655 m_value
.GetWindowText(buffer
);
657 if(buffer
.IsEmpty()) {
658 systemMessage(IDS_VALUE_CANNOT_BE_EMPTY
, "Value cannot be empty");
664 sscanf(buffer
, "%d", &value
);
667 sscanf(buffer
, "%u", &value
);
670 sscanf(buffer
, "%x", &value
);
673 m_desc
.GetWindowText(buffer
);
677 code
.Format("%08x:%02x", address
, value
);
680 code
.Format("%08x:%04x", address
, value
);
683 code
.Format("%08x:%08x", address
, value
);
687 cheatsAdd(code
, buffer
, address
,address
, value
,-1, sizeType
);
690 /////////////////////////////////////////////////////////////////////////////
691 // GBACheatList dialog
694 GBACheatList::GBACheatList(CWnd
* pParent
/*=NULL*/)
695 : CDialog(GBACheatList::IDD
, pParent
)
697 //{{AFX_DATA_INIT(GBACheatList)
698 // NOTE: the ClassWizard will add member initialization here
700 duringRefresh
= false;
704 void GBACheatList::DoDataExchange(CDataExchange
* pDX
)
706 CDialog::DoDataExchange(pDX
);
707 //{{AFX_DATA_MAP(GBACheatList)
708 DDX_Control(pDX
, IDC_RESTORE
, m_restore
);
709 DDX_Control(pDX
, IDC_CHEAT_LIST
, m_list
);
714 BEGIN_MESSAGE_MAP(GBACheatList
, CDialog
)
715 //{{AFX_MSG_MAP(GBACheatList)
716 ON_BN_CLICKED(IDC_ADD_CHEAT
, OnAddCheat
)
717 ON_BN_CLICKED(IDC_ADD_CODE
, OnAddCode
)
718 ON_BN_CLICKED(IDC_ADD_CODEBREAKER
, OnAddCodebreaker
)
719 ON_BN_CLICKED(IDC_ADD_GAMESHARK
, OnAddGameshark
)
720 ON_BN_CLICKED(IDC_ENABLE
, OnEnable
)
721 ON_BN_CLICKED(IDC_REMOVE
, OnRemove
)
722 ON_BN_CLICKED(IDC_REMOVE_ALL
, OnRemoveAll
)
723 ON_BN_CLICKED(IDC_RESTORE
, OnRestore
)
724 ON_BN_CLICKED(ID_OK
, OnOk
)
725 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_CHEAT_LIST
, OnItemchangedCheatList
)
729 /////////////////////////////////////////////////////////////////////////////
730 // GBACheatList message handlers
732 void GBACheatList::OnAddCheat()
739 void GBACheatList::OnAddCode()
746 void GBACheatList::OnAddCodebreaker()
753 void GBACheatList::OnAddGameshark()
760 void GBACheatList::OnEnable()
762 int mark
= m_list
.GetSelectionMark();
763 int count
= m_list
.GetItemCount();
767 for(int i
= 0; i
< count
; i
++) {
768 memset(&item
, 0, sizeof(item
));
769 item
.mask
= LVIF_PARAM
|LVIF_STATE
;
770 item
.stateMask
= LVIS_SELECTED
;
772 if(m_list
.GetItem(&item
)) {
773 if(item
.state
& LVIS_SELECTED
) {
774 if(cheatsList
[item
.lParam
].enabled
)
775 cheatsDisable((int)(item
.lParam
& 0xFFFFFFFF));
777 cheatsEnable((int)(item
.lParam
& 0xFFFFFFFF));
785 void GBACheatList::OnRemove()
787 int mark
= m_list
.GetSelectionMark();
788 int count
= m_list
.GetItemCount();
791 for(int i
= count
- 1; i
>= 0; i
--) {
793 memset(&item
,0, sizeof(item
));
794 item
.mask
= LVIF_PARAM
|LVIF_STATE
;
796 item
.stateMask
= LVIS_SELECTED
;
797 if(m_list
.GetItem(&item
)) {
798 if(item
.state
& LVIS_SELECTED
) {
799 cheatsDelete((int)(item
.lParam
& 0xFFFFFFFF), restoreValues
);
807 void GBACheatList::OnRemoveAll()
809 cheatsDeleteAll(restoreValues
);
814 void GBACheatList::OnRestore()
816 restoreValues
= !restoreValues
;
817 regSetDwordValue("cheatsRestore", restoreValues
);
820 void GBACheatList::OnOk()
825 void GBACheatList::OnItemchangedCheatList(NMHDR
* pNMHDR
, LRESULT
* pResult
)
827 if(m_list
.GetSelectionMark() != -1) {
828 GetDlgItem(IDC_REMOVE
)->EnableWindow(TRUE
);
829 GetDlgItem(IDC_ENABLE
)->EnableWindow(TRUE
);
831 GetDlgItem(IDC_REMOVE
)->EnableWindow(FALSE
);
832 GetDlgItem(IDC_ENABLE
)->EnableWindow(FALSE
);
836 LPNMLISTVIEW l
= (LPNMLISTVIEW
)pNMHDR
;
837 if(l
->uChanged
& LVIF_STATE
) {
838 if(((l
->uOldState
& LVIS_STATEIMAGEMASK
)>>12) !=
839 (((l
->uNewState
& LVIS_STATEIMAGEMASK
)>>12))) {
840 if(m_list
.GetCheck(l
->iItem
))
841 cheatsEnable((int)(l
->lParam
& 0xFFFFFFFF));
843 cheatsDisable((int)(l
->lParam
& 0xFFFFFFFF));
852 BOOL
GBACheatList::OnInitDialog()
854 CDialog::OnInitDialog();
856 CString temp
= winResLoadString(IDS_CODE
);
857 m_list
.InsertColumn(0, temp
, LVCFMT_LEFT
, 170, 0);
858 temp
= winResLoadString(IDS_DESCRIPTION
);
859 m_list
.InsertColumn(1, temp
, LVCFMT_LEFT
, 150, 1);
860 temp
= winResLoadString(IDS_STATUS
);
861 m_list
.InsertColumn(2, temp
, LVCFMT_LEFT
, 80, 1);
863 m_list
.SetFont(CFont::FromHandle((HFONT
)GetStockObject(SYSTEM_FIXED_FONT
)),
866 m_list
.SetExtendedStyle(LVS_EX_CHECKBOXES
| LVS_EX_FULLROWSELECT
);
868 restoreValues
= regQueryDwordValue("cheatsRestore", 0) ?
871 m_restore
.SetCheck(restoreValues
);
874 GetDlgItem(IDC_REMOVE
)->EnableWindow(FALSE
);
875 GetDlgItem(IDC_ENABLE
)->EnableWindow(FALSE
);
878 return TRUE
; // return TRUE unless you set the focus to a control
879 // EXCEPTION: OCX Property Pages should return FALSE
882 void GBACheatList::refresh()
884 duringRefresh
= true;
885 m_list
.DeleteAllItems();
889 for(int i
= 0; i
< cheatsNumber
; i
++) {
892 item
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_STATE
;
898 item
.pszText
= cheatsList
[i
].codestring
;
899 m_list
.InsertItem(&item
);
901 m_list
.SetCheck(i
, (cheatsList
[i
].enabled
) ? TRUE
: FALSE
);
903 m_list
.SetItemText(i
, 1, cheatsList
[i
].desc
);
905 buffer
= (cheatsList
[i
].enabled
) ? 'E' : 'D';
906 m_list
.SetItemText(i
, 2, buffer
);
908 duringRefresh
= false;
910 /////////////////////////////////////////////////////////////////////////////
914 AddGSACode::AddGSACode(CWnd
* pParent
/*=NULL*/)
915 : CDialog(AddGSACode::IDD
, pParent
)
917 //{{AFX_DATA_INIT(AddGSACode)
918 // NOTE: the ClassWizard will add member initialization here
923 void AddGSACode::DoDataExchange(CDataExchange
* pDX
)
925 CDialog::DoDataExchange(pDX
);
926 //{{AFX_DATA_MAP(AddGSACode)
927 DDX_Control(pDX
, IDC_DESC
, m_desc
);
928 DDX_Control(pDX
, IDC_CODE
, m_code
);
933 BEGIN_MESSAGE_MAP(AddGSACode
, CDialog
)
934 //{{AFX_MSG_MAP(AddGSACode)
935 ON_BN_CLICKED(ID_OK
, OnOk
)
936 ON_BN_CLICKED(ID_CANCEL
, OnCancel
)
940 /////////////////////////////////////////////////////////////////////////////
941 // AddGSACode message handlers
943 void AddGSACode::OnOk()
951 m_code
.GetWindowText(buffer
);
952 m_desc
.GetWindowText(desc
);
954 StringTokenizer
st(buffer
, " \t\n\r");
956 const char *t
= st
.next();
960 if(token
.GetLength() == 16)
961 cheatsAddGSACode(token
, desc
, false);
962 else if(token
.GetLength() == 12) {
963 code
= token
.Left(8);
965 code
+= token
.Right(4);
966 cheatsAddCBACode(code
, desc
);
967 } else if(part1
.IsEmpty())
970 if(token
.GetLength() == 4) {
974 cheatsAddCBACode(code
, desc
);
976 code
= part1
+ token
;
977 cheatsAddGSACode(code
, desc
, true);
987 void AddGSACode::OnCancel()
992 BOOL
AddGSACode::OnInitDialog()
994 CDialog::OnInitDialog();
996 m_code
.LimitText(1024);
997 m_desc
.LimitText(32);
998 CString title
= winResLoadString(IDS_ADD_GSA_CODE
);
999 SetWindowText(title
);
1002 return TRUE
; // return TRUE unless you set the focus to a control
1003 // EXCEPTION: OCX Property Pages should return FALSE
1006 /////////////////////////////////////////////////////////////////////////////
1007 // AddCBACode dialog
1010 AddCBACode::AddCBACode(CWnd
* pParent
/*=NULL*/)
1011 : CDialog(AddCBACode::IDD
, pParent
)
1013 //{{AFX_DATA_INIT(AddCBACode)
1014 // NOTE: the ClassWizard will add member initialization here
1019 void AddCBACode::DoDataExchange(CDataExchange
* pDX
)
1021 CDialog::DoDataExchange(pDX
);
1022 //{{AFX_DATA_MAP(AddCBACode)
1023 DDX_Control(pDX
, IDC_DESC
, m_desc
);
1024 DDX_Control(pDX
, IDC_CODE
, m_code
);
1029 BEGIN_MESSAGE_MAP(AddCBACode
, CDialog
)
1030 //{{AFX_MSG_MAP(AddCBACode)
1031 ON_BN_CLICKED(ID_OK
, OnOk
)
1032 ON_BN_CLICKED(ID_CANCEL
, OnCancel
)
1036 /////////////////////////////////////////////////////////////////////////////
1037 // AddCBACode message handlers
1039 void AddCBACode::OnOk()
1047 m_code
.GetWindowText(buffer
);
1048 m_desc
.GetWindowText(desc
);
1050 StringTokenizer
st(buffer
, " \t\n\r");
1052 const char *t
= st
.next();
1056 if(token
.GetLength() == 16)
1057 cheatsAddGSACode(token
, desc
, false);
1058 else if(token
.GetLength() == 12) {
1059 code
= token
.Left(8);
1061 code
+= token
.Right(4);
1062 cheatsAddCBACode(code
, desc
);
1063 } else if(part1
.IsEmpty())
1066 if(token
.GetLength() == 4) {
1070 cheatsAddCBACode(code
, desc
);
1072 code
= part1
+ token
;
1073 cheatsAddGSACode(code
, desc
, true);
1083 void AddCBACode::OnCancel()
1088 BOOL
AddCBACode::OnInitDialog()
1090 CDialog::OnInitDialog();
1092 m_code
.LimitText(1024);
1093 m_desc
.LimitText(32);
1094 CString title
= winResLoadString(IDS_ADD_CBA_CODE
);
1095 SetWindowText(title
);
1098 return TRUE
; // return TRUE unless you set the focus to a control
1099 // EXCEPTION: OCX Property Pages should return FALSE
1102 /////////////////////////////////////////////////////////////////////////////
1103 // AddCheatCode dialog
1106 AddCheatCode::AddCheatCode(CWnd
* pParent
/*=NULL*/)
1107 : CDialog(AddCheatCode::IDD
, pParent
)
1109 //{{AFX_DATA_INIT(AddCheatCode)
1110 // NOTE: the ClassWizard will add member initialization here
1115 void AddCheatCode::DoDataExchange(CDataExchange
* pDX
)
1117 CDialog::DoDataExchange(pDX
);
1118 //{{AFX_DATA_MAP(AddCheatCode)
1119 DDX_Control(pDX
, IDC_DESC
, m_desc
);
1120 DDX_Control(pDX
, IDC_CODE
, m_code
);
1125 BEGIN_MESSAGE_MAP(AddCheatCode
, CDialog
)
1126 //{{AFX_MSG_MAP(AddCheatCode)
1127 ON_BN_CLICKED(ID_OK
, OnOk
)
1128 ON_BN_CLICKED(ID_CANCEL
, OnCancel
)
1132 /////////////////////////////////////////////////////////////////////////////
1133 // AddCheatCode message handlers
1135 void AddCheatCode::OnOk()
1141 m_code
.GetWindowText(buffer
);
1142 m_desc
.GetWindowText(desc
);
1144 StringTokenizer
st(buffer
, " \t\n\r");
1145 const char *t
= st
.next();
1149 cheatsAddCheatCode(token
, desc
);
1155 void AddCheatCode::OnCancel()
1160 BOOL
AddCheatCode::OnInitDialog()
1162 CDialog::OnInitDialog();
1164 m_code
.LimitText(1024);
1165 m_desc
.LimitText(32);
1166 CString title
= winResLoadString(IDS_ADD_CHEAT_CODE
);
1167 SetWindowText(title
);
1170 return TRUE
; // return TRUE unless you set the focus to a control
1171 // EXCEPTION: OCX Property Pages should return FALSE