remove more unportable ASM, obsoleting C_CORE define
[rofl0r-VisualBoyAdvance.git] / src / win32 / MainWndCheats.cpp
blob90df14bf71794e2b7e082d15cb0e229b38ef814d
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)
8 // any later version.
9 //
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 #include "stdafx.h"
20 #include "MainWnd.h"
22 #include "FileDlg.h"
23 #include "GBACheats.h"
24 #include "GBCheatsDlg.h"
25 #include "Reg.h"
26 #include "WinResUtil.h"
28 #include "../GBA.h"
29 #include "../Globals.h"
30 #include "../gb/gbCheats.h"
32 extern int emulating;
34 void MainWnd::OnCheatsSearchforcheats()
36 theApp.winCheckFullscreen();
37 if(theApp.cartridgeType == 0) {
38 GBACheatSearch dlg;
39 dlg.DoModal();
40 } else {
41 GBCheatSearch dlg;
42 dlg.DoModal();
46 void MainWnd::OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI)
48 pCmdUI->Enable(emulating);
51 void MainWnd::OnCheatsCheatlist()
53 theApp.winCheckFullscreen();
54 if(theApp.cartridgeType == 0) {
55 GBACheatList dlg;
56 dlg.DoModal();
57 } else {
58 GBCheatList dlg;
59 dlg.DoModal();
63 void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI)
65 pCmdUI->Enable(emulating);
68 void MainWnd::OnCheatsAutomaticsaveloadcheats()
70 theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
73 void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI)
75 pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
78 void MainWnd::OnCheatsLoadcheatlist()
80 theApp.winCheckFullscreen();
81 CString buffer;
82 CString filename;
84 int index = theApp.filename.ReverseFind('\\');
86 if(index != -1)
87 buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
88 else
89 buffer = theApp.filename;
91 CString saveDir = regQueryStringValue("saveDir", NULL);
93 if(saveDir.IsEmpty())
94 saveDir = getDirFromFile(theApp.filename);
96 if(isDriveRoot(saveDir))
97 filename.Format("%s%s.clt", saveDir, buffer);
98 else
99 filename.Format("%s\\%s.clt", saveDir, buffer);
101 LPCTSTR exts[] = { ".clt" };
102 CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
103 CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
105 FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, false);
107 if(dlg.DoModal() == IDOK) {
108 winLoadCheatList(dlg.GetPathName());
112 void MainWnd::OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI)
114 pCmdUI->Enable(emulating);
117 void MainWnd::OnCheatsSavecheatlist()
119 theApp.winCheckFullscreen();
120 CString buffer;
121 CString filename;
123 int index = theApp.filename.ReverseFind('\\');
125 if(index != -1)
126 buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
127 else
128 buffer = theApp.filename;
130 CString saveDir = regQueryStringValue("saveDir", NULL);
132 if(saveDir.IsEmpty())
133 saveDir = getDirFromFile(theApp.filename);
135 if(isDriveRoot(saveDir))
136 filename.Format("%s%s.clt", saveDir, buffer);
137 else
138 filename.Format("%s\\%s.clt", saveDir, buffer);
140 LPCTSTR exts[] = { ".clt" };
141 CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
142 CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
144 FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, true);
146 if(dlg.DoModal() == IDOK) {
147 winSaveCheatList(dlg.GetPathName());
151 void MainWnd::OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI)
153 pCmdUI->Enable(emulating);
156 void MainWnd::OnCheatsDisablecheats()
158 cheatsEnabled = !cheatsEnabled;
161 void MainWnd::OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI)
163 pCmdUI->SetCheck(!cheatsEnabled);