rlm@1
|
1 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
rlm@1
|
2 // Copyright (C) 1999-2003 Forgotten
|
rlm@1
|
3 // Copyright (C) 2004 Forgotten and the VBA development team
|
rlm@1
|
4
|
rlm@1
|
5 // This program is free software; you can redistribute it and/or modify
|
rlm@1
|
6 // it under the terms of the GNU General Public License as published by
|
rlm@1
|
7 // the Free Software Foundation; either version 2, or(at your option)
|
rlm@1
|
8 // any later version.
|
rlm@1
|
9 //
|
rlm@1
|
10 // This program is distributed in the hope that it will be useful,
|
rlm@1
|
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
rlm@1
|
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
rlm@1
|
13 // GNU General Public License for more details.
|
rlm@1
|
14 //
|
rlm@1
|
15 // You should have received a copy of the GNU General Public License
|
rlm@1
|
16 // along with this program; if not, write to the Free Software Foundation,
|
rlm@1
|
17 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
rlm@1
|
18
|
rlm@1
|
19 #include "window.h"
|
rlm@1
|
20
|
rlm@1
|
21 #include <sys/stat.h>
|
rlm@1
|
22
|
rlm@1
|
23 #include <stdio.h>
|
rlm@1
|
24 #include <time.h>
|
rlm@1
|
25
|
rlm@1
|
26 #include <SDL.h>
|
rlm@1
|
27
|
rlm@1
|
28 #include "../gba/GBA.h"
|
rlm@1
|
29 #include "../gba/GBAGlobals.h"
|
rlm@1
|
30 #include "../gba/Flash.h"
|
rlm@1
|
31 #include "../gba/GBASound.h"
|
rlm@1
|
32 #include "../gb/GB.h"
|
rlm@1
|
33 #include "../gb/gbGlobals.h"
|
rlm@1
|
34 #include "../gb/gbPrinter.h"
|
rlm@1
|
35 #include "../common/Util.h"
|
rlm@1
|
36
|
rlm@1
|
37 #include "tools.h"
|
rlm@1
|
38 #include "intl.h"
|
rlm@1
|
39
|
rlm@1
|
40 extern int systemRenderedFrames;
|
rlm@1
|
41 extern int systemFPS;
|
rlm@1
|
42 extern bool debugger;
|
rlm@1
|
43 extern int RGB_LOW_BITS_MASK;
|
rlm@1
|
44 extern void (*dbgMain)();
|
rlm@1
|
45 extern void (*dbgSignal)(int, int);
|
rlm@1
|
46 extern void (*dbgOutput)(char *, u32);
|
rlm@1
|
47 extern void remoteInit();
|
rlm@1
|
48 extern void remoteCleanUp();
|
rlm@1
|
49 extern void remoteStubMain();
|
rlm@1
|
50 extern void remoteStubSignal(int, int);
|
rlm@1
|
51 extern void remoteOutput(char *, u32);
|
rlm@1
|
52 extern void remoteSetProtocol(int);
|
rlm@1
|
53 extern void remoteSetPort(int);
|
rlm@1
|
54
|
rlm@1
|
55 #ifdef MMX
|
rlm@1
|
56 extern "C" bool cpu_mmx;
|
rlm@1
|
57 #endif // MMX
|
rlm@1
|
58
|
rlm@1
|
59 namespace VBA
|
rlm@1
|
60 {
|
rlm@1
|
61
|
rlm@1
|
62 using Gnome::Glade::Xml;
|
rlm@1
|
63
|
rlm@1
|
64 void Window::vOnFileOpen()
|
rlm@1
|
65 {
|
rlm@1
|
66 while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
67 {
|
rlm@1
|
68 if (bLoadROM(m_poFileOpenDialog->get_filename()))
|
rlm@1
|
69 {
|
rlm@1
|
70 break;
|
rlm@1
|
71 }
|
rlm@1
|
72 }
|
rlm@1
|
73 m_poFileOpenDialog->hide();
|
rlm@1
|
74 }
|
rlm@1
|
75
|
rlm@1
|
76 void Window::vOnFileLoad()
|
rlm@1
|
77 {
|
rlm@1
|
78 std::string sSaveDir = m_poDirConfig->sGetKey("saves");
|
rlm@1
|
79
|
rlm@1
|
80 #ifdef GTKMM20
|
rlm@1
|
81
|
rlm@1
|
82 Gtk::FileSelection oDialog(_("Load game"));
|
rlm@1
|
83 oDialog.set_transient_for(*this);
|
rlm@1
|
84
|
rlm@1
|
85 if (sSaveDir == "")
|
rlm@1
|
86 {
|
rlm@1
|
87 oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/");
|
rlm@1
|
88 }
|
rlm@1
|
89 else
|
rlm@1
|
90 {
|
rlm@1
|
91 oDialog.set_filename(sSaveDir + "/");
|
rlm@1
|
92 }
|
rlm@1
|
93
|
rlm@1
|
94 #else // ! GTKMM20
|
rlm@1
|
95
|
rlm@1
|
96 Gtk::FileChooserDialog oDialog(*this, _("Load game"));
|
rlm@1
|
97 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
98 oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
rlm@1
|
99
|
rlm@1
|
100 if (sSaveDir == "")
|
rlm@1
|
101 {
|
rlm@1
|
102 oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
rlm@1
|
103 }
|
rlm@1
|
104 else
|
rlm@1
|
105 {
|
rlm@1
|
106 oDialog.set_current_folder(sSaveDir);
|
rlm@1
|
107 oDialog.add_shortcut_folder(sSaveDir);
|
rlm@1
|
108 }
|
rlm@1
|
109
|
rlm@1
|
110 Gtk::FileFilter oSaveFilter;
|
rlm@1
|
111 oSaveFilter.set_name(_("VisualBoyAdvance save game"));
|
rlm@1
|
112 oSaveFilter.add_pattern("*.[sS][gG][mM]");
|
rlm@1
|
113
|
rlm@1
|
114 oDialog.add_filter(oSaveFilter);
|
rlm@1
|
115
|
rlm@1
|
116 #endif // ! GTKMM20
|
rlm@1
|
117
|
rlm@1
|
118 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
119 {
|
rlm@1
|
120 if (m_stEmulator.emuReadState(oDialog.get_filename().c_str()))
|
rlm@1
|
121 {
|
rlm@1
|
122 break;
|
rlm@1
|
123 }
|
rlm@1
|
124 }
|
rlm@1
|
125 }
|
rlm@1
|
126
|
rlm@1
|
127 void Window::vOnFileSave()
|
rlm@1
|
128 {
|
rlm@1
|
129 Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves");
|
rlm@1
|
130
|
rlm@1
|
131 #ifdef GTKMM20
|
rlm@1
|
132
|
rlm@1
|
133 Gtk::FileSelection oDialog(_("Save game"));
|
rlm@1
|
134 oDialog.set_transient_for(*this);
|
rlm@1
|
135
|
rlm@1
|
136 if (sSaveDir == "")
|
rlm@1
|
137 {
|
rlm@1
|
138 oDialog.set_filename(sCutSuffix(m_sRomFile));
|
rlm@1
|
139 }
|
rlm@1
|
140 else
|
rlm@1
|
141 {
|
rlm@1
|
142 oDialog.set_filename(sSaveDir + "/" +
|
rlm@1
|
143 sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
144 }
|
rlm@1
|
145
|
rlm@1
|
146 #else // ! GTKMM20
|
rlm@1
|
147
|
rlm@1
|
148 Gtk::FileChooserDialog oDialog(*this, _("Save game"),
|
rlm@1
|
149 Gtk::FILE_CHOOSER_ACTION_SAVE);
|
rlm@1
|
150 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
151 oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
rlm@1
|
152
|
rlm@1
|
153 if (sSaveDir == "")
|
rlm@1
|
154 {
|
rlm@1
|
155 oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
rlm@1
|
156 }
|
rlm@1
|
157 else
|
rlm@1
|
158 {
|
rlm@1
|
159 oDialog.set_current_folder(sSaveDir);
|
rlm@1
|
160 oDialog.add_shortcut_folder(sSaveDir);
|
rlm@1
|
161 }
|
rlm@1
|
162 oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
163
|
rlm@1
|
164 Gtk::FileFilter oSaveFilter;
|
rlm@1
|
165 oSaveFilter.set_name(_("VisualBoyAdvance save game"));
|
rlm@1
|
166 oSaveFilter.add_pattern("*.[sS][gG][mM]");
|
rlm@1
|
167
|
rlm@1
|
168 oDialog.add_filter(oSaveFilter);
|
rlm@1
|
169
|
rlm@1
|
170 #endif // ! GTKMM20
|
rlm@1
|
171
|
rlm@1
|
172 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
173 {
|
rlm@1
|
174 Glib::ustring sFile = oDialog.get_filename();
|
rlm@1
|
175 if (! bHasSuffix(sFile, ".sgm", false))
|
rlm@1
|
176 {
|
rlm@1
|
177 sFile += ".sgm";
|
rlm@1
|
178 }
|
rlm@1
|
179
|
rlm@1
|
180 if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
|
rlm@1
|
181 {
|
rlm@1
|
182 Gtk::MessageDialog oConfirmDialog(*this,
|
rlm@1
|
183 _("File already exists. Overwrite it?"),
|
rlm@1
|
184 #ifndef GTKMM20
|
rlm@1
|
185 false,
|
rlm@1
|
186 #endif // ! GTKMM20
|
rlm@1
|
187 Gtk::MESSAGE_QUESTION,
|
rlm@1
|
188 Gtk::BUTTONS_YES_NO);
|
rlm@1
|
189 if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
rlm@1
|
190 {
|
rlm@1
|
191 continue;
|
rlm@1
|
192 }
|
rlm@1
|
193 }
|
rlm@1
|
194
|
rlm@1
|
195 if (m_stEmulator.emuWriteState(sFile.c_str()))
|
rlm@1
|
196 {
|
rlm@1
|
197 break;
|
rlm@1
|
198 }
|
rlm@1
|
199 }
|
rlm@1
|
200 }
|
rlm@1
|
201
|
rlm@1
|
202 void Window::vOnLoadGameMostRecent()
|
rlm@1
|
203 {
|
rlm@1
|
204 int iMostRecent = -1;
|
rlm@1
|
205 time_t uiTimeMax;
|
rlm@1
|
206
|
rlm@1
|
207 for (int i = 0; i < 10; i++)
|
rlm@1
|
208 {
|
rlm@1
|
209 if (! m_astGameSlot[i].m_bEmpty
|
rlm@1
|
210 && (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax))
|
rlm@1
|
211 {
|
rlm@1
|
212 iMostRecent = i;
|
rlm@1
|
213 uiTimeMax = m_astGameSlot[i].m_uiTime;
|
rlm@1
|
214 }
|
rlm@1
|
215 }
|
rlm@1
|
216
|
rlm@1
|
217 if (iMostRecent >= 0)
|
rlm@1
|
218 {
|
rlm@1
|
219 vOnLoadGame(iMostRecent + 1);
|
rlm@1
|
220 }
|
rlm@1
|
221 }
|
rlm@1
|
222
|
rlm@1
|
223 void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
224 {
|
rlm@1
|
225 m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active());
|
rlm@1
|
226 }
|
rlm@1
|
227
|
rlm@1
|
228 void Window::vOnLoadGame(int _iSlot)
|
rlm@1
|
229 {
|
rlm@1
|
230 int i = _iSlot - 1;
|
rlm@1
|
231 if (! m_astGameSlot[i].m_bEmpty)
|
rlm@1
|
232 {
|
rlm@1
|
233 m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
|
rlm@1
|
234 m_poFilePauseItem->set_active(false);
|
rlm@1
|
235 }
|
rlm@1
|
236 }
|
rlm@1
|
237
|
rlm@1
|
238 void Window::vOnSaveGameOldest()
|
rlm@1
|
239 {
|
rlm@1
|
240 int iOldest = -1;
|
rlm@1
|
241 time_t uiTimeMin;
|
rlm@1
|
242
|
rlm@1
|
243 for (int i = 0; i < 10; i++)
|
rlm@1
|
244 {
|
rlm@1
|
245 if (! m_astGameSlot[i].m_bEmpty
|
rlm@1
|
246 && (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin))
|
rlm@1
|
247 {
|
rlm@1
|
248 iOldest = i;
|
rlm@1
|
249 uiTimeMin = m_astGameSlot[i].m_uiTime;
|
rlm@1
|
250 }
|
rlm@1
|
251 }
|
rlm@1
|
252
|
rlm@1
|
253 if (iOldest >= 0)
|
rlm@1
|
254 {
|
rlm@1
|
255 vOnSaveGame(iOldest + 1);
|
rlm@1
|
256 }
|
rlm@1
|
257 else
|
rlm@1
|
258 {
|
rlm@1
|
259 vOnSaveGame(1);
|
rlm@1
|
260 }
|
rlm@1
|
261 }
|
rlm@1
|
262
|
rlm@1
|
263 void Window::vOnSaveGame(int _iSlot)
|
rlm@1
|
264 {
|
rlm@1
|
265 int i = _iSlot - 1;
|
rlm@1
|
266 m_stEmulator.emuWriteState(m_astGameSlot[i].m_sFile.c_str());
|
rlm@1
|
267 vUpdateGameSlots();
|
rlm@1
|
268 }
|
rlm@1
|
269
|
rlm@1
|
270 void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
271 {
|
rlm@1
|
272 m_bPaused = _poCMI->get_active();
|
rlm@1
|
273 if (emulating)
|
rlm@1
|
274 {
|
rlm@1
|
275 if (m_bPaused)
|
rlm@1
|
276 {
|
rlm@1
|
277 vStopEmu();
|
rlm@1
|
278 soundPause();
|
rlm@1
|
279 }
|
rlm@1
|
280 else
|
rlm@1
|
281 {
|
rlm@1
|
282 vStartEmu();
|
rlm@1
|
283 soundResume();
|
rlm@1
|
284 }
|
rlm@1
|
285 }
|
rlm@1
|
286 }
|
rlm@1
|
287
|
rlm@1
|
288 void Window::vOnFileReset()
|
rlm@1
|
289 {
|
rlm@1
|
290 if (emulating)
|
rlm@1
|
291 {
|
rlm@1
|
292 m_stEmulator.emuReset(true);
|
rlm@1
|
293 m_poFilePauseItem->set_active(false);
|
rlm@1
|
294 }
|
rlm@1
|
295 }
|
rlm@1
|
296
|
rlm@1
|
297 void Window::vOnRecentReset()
|
rlm@1
|
298 {
|
rlm@1
|
299 m_listHistory.clear();
|
rlm@1
|
300 vClearHistoryMenu();
|
rlm@1
|
301 }
|
rlm@1
|
302
|
rlm@1
|
303 void Window::vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
304 {
|
rlm@1
|
305 m_poRecentResetItem->set_sensitive(! _poCMI->get_active());
|
rlm@1
|
306 m_poHistoryConfig->vSetKey("freeze", _poCMI->get_active());
|
rlm@1
|
307 }
|
rlm@1
|
308
|
rlm@1
|
309 void Window::vOnRecentFile(std::string _sFile)
|
rlm@1
|
310 {
|
rlm@1
|
311 bLoadROM(_sFile);
|
rlm@1
|
312 }
|
rlm@1
|
313
|
rlm@1
|
314 void Window::vOnImportBatteryFile()
|
rlm@1
|
315 {
|
rlm@1
|
316 std::string BatteryDir = m_poDirConfig->sGetKey("batteries");
|
rlm@1
|
317
|
rlm@1
|
318 #ifdef GTKMM20
|
rlm@1
|
319
|
rlm@1
|
320 Gtk::FileSelection oDialog(_("Import battery file"));
|
rlm@1
|
321 oDialog.set_transient_for(*this);
|
rlm@1
|
322
|
rlm@1
|
323 if (BatteryDir == "")
|
rlm@1
|
324 {
|
rlm@1
|
325 oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/");
|
rlm@1
|
326 }
|
rlm@1
|
327 else
|
rlm@1
|
328 {
|
rlm@1
|
329 oDialog.set_filename(BatteryDir + "/");
|
rlm@1
|
330 }
|
rlm@1
|
331
|
rlm@1
|
332 #else // ! GTKMM20
|
rlm@1
|
333
|
rlm@1
|
334 Gtk::FileChooserDialog oDialog(*this, _("Import battery file"));
|
rlm@1
|
335 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
336 oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
rlm@1
|
337
|
rlm@1
|
338 if (BatteryDir == "")
|
rlm@1
|
339 {
|
rlm@1
|
340 oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
rlm@1
|
341 }
|
rlm@1
|
342 else
|
rlm@1
|
343 {
|
rlm@1
|
344 oDialog.set_current_folder(BatteryDir);
|
rlm@1
|
345 oDialog.add_shortcut_folder(BatteryDir);
|
rlm@1
|
346 }
|
rlm@1
|
347
|
rlm@1
|
348 Gtk::FileFilter oBatteryFilter;
|
rlm@1
|
349 oBatteryFilter.set_name(_("Battery file"));
|
rlm@1
|
350 oBatteryFilter.add_pattern("*.[sS][aA][vV]");
|
rlm@1
|
351
|
rlm@1
|
352 Gtk::FileFilter oFlashFilter;
|
rlm@1
|
353 oFlashFilter.set_name(_("Flash save"));
|
rlm@1
|
354 oFlashFilter.add_pattern("*.[dD][aA][tT]");
|
rlm@1
|
355
|
rlm@1
|
356 oDialog.add_filter(oBatteryFilter);
|
rlm@1
|
357 oDialog.add_filter(oFlashFilter);
|
rlm@1
|
358
|
rlm@1
|
359 #endif // ! GTKMM20
|
rlm@1
|
360
|
rlm@1
|
361 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
362 {
|
rlm@1
|
363 Gtk::MessageDialog oConfirmDialog(*this,
|
rlm@1
|
364 _("Importing a battery file will erase any saved games and reset the emulator. Do you want to continue?"),
|
rlm@1
|
365 #ifndef GTKMM20
|
rlm@1
|
366 false,
|
rlm@1
|
367 #endif // ! GTKMM20
|
rlm@1
|
368 Gtk::MESSAGE_QUESTION,
|
rlm@1
|
369 Gtk::BUTTONS_YES_NO);
|
rlm@1
|
370 if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
rlm@1
|
371 {
|
rlm@1
|
372 continue;
|
rlm@1
|
373 }
|
rlm@1
|
374
|
rlm@1
|
375 if (m_stEmulator.emuReadBattery(oDialog.get_filename().c_str()))
|
rlm@1
|
376 {
|
rlm@1
|
377 m_stEmulator.emuReset(false);
|
rlm@1
|
378 break;
|
rlm@1
|
379 }
|
rlm@1
|
380 else
|
rlm@1
|
381 {
|
rlm@1
|
382 vPopupError(_("Failed to import battery file %s."),
|
rlm@1
|
383 oDialog.get_filename().c_str());
|
rlm@1
|
384 }
|
rlm@1
|
385 }
|
rlm@1
|
386 }
|
rlm@1
|
387
|
rlm@1
|
388 void Window::vOnExportBatteryFile()
|
rlm@1
|
389 {
|
rlm@1
|
390 std::string sBatteryDir = m_poDirConfig->sGetKey("batteries");
|
rlm@1
|
391
|
rlm@1
|
392 #ifdef GTKMM20
|
rlm@1
|
393
|
rlm@1
|
394 Gtk::FileSelection oDialog(_("Export battery file"));
|
rlm@1
|
395 oDialog.set_transient_for(*this);
|
rlm@1
|
396
|
rlm@1
|
397 if (sBatteryDir == "")
|
rlm@1
|
398 {
|
rlm@1
|
399 oDialog.set_filename(sCutSuffix(m_sRomFile));
|
rlm@1
|
400 }
|
rlm@1
|
401 else
|
rlm@1
|
402 {
|
rlm@1
|
403 oDialog.set_filename(sBatteryDir + "/" +
|
rlm@1
|
404 sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
405 }
|
rlm@1
|
406
|
rlm@1
|
407 #else // ! GTKMM20
|
rlm@1
|
408
|
rlm@1
|
409 Gtk::FileChooserDialog oDialog(*this, _("Export battery file"),
|
rlm@1
|
410 Gtk::FILE_CHOOSER_ACTION_SAVE);
|
rlm@1
|
411 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
412 oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
rlm@1
|
413
|
rlm@1
|
414 if (sBatteryDir == "")
|
rlm@1
|
415 {
|
rlm@1
|
416 oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
rlm@1
|
417 }
|
rlm@1
|
418 else
|
rlm@1
|
419 {
|
rlm@1
|
420 oDialog.set_current_folder(sBatteryDir);
|
rlm@1
|
421 oDialog.add_shortcut_folder(sBatteryDir);
|
rlm@1
|
422 }
|
rlm@1
|
423 oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
424
|
rlm@1
|
425 Gtk::FileFilter oBatteryFilter;
|
rlm@1
|
426 oBatteryFilter.set_name(_("Battery file"));
|
rlm@1
|
427 oBatteryFilter.add_pattern("*.[sS][aA][vV]");
|
rlm@1
|
428
|
rlm@1
|
429 Gtk::FileFilter oFlashFilter;
|
rlm@1
|
430 oFlashFilter.set_name(_("Flash save"));
|
rlm@1
|
431 oFlashFilter.add_pattern("*.[dD][aA][tT]");
|
rlm@1
|
432
|
rlm@1
|
433 oDialog.add_filter(oBatteryFilter);
|
rlm@1
|
434 oDialog.add_filter(oFlashFilter);
|
rlm@1
|
435
|
rlm@1
|
436 #endif // ! GTKMM20
|
rlm@1
|
437
|
rlm@1
|
438 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
439 {
|
rlm@1
|
440 Glib::ustring sFile = oDialog.get_filename();
|
rlm@1
|
441 Glib::ustring sExt;
|
rlm@1
|
442
|
rlm@1
|
443 #ifdef GTKMM20
|
rlm@1
|
444
|
rlm@1
|
445 sExt = ".sav";
|
rlm@1
|
446
|
rlm@1
|
447 #else // ! GTKMM20
|
rlm@1
|
448
|
rlm@1
|
449 if (oDialog.get_filter() == &oBatteryFilter)
|
rlm@1
|
450 {
|
rlm@1
|
451 sExt = ".sav";
|
rlm@1
|
452 }
|
rlm@1
|
453 else
|
rlm@1
|
454 {
|
rlm@1
|
455 sExt = ".dat";
|
rlm@1
|
456 }
|
rlm@1
|
457
|
rlm@1
|
458 #endif // ! GTKMM20
|
rlm@1
|
459
|
rlm@1
|
460 if (! bHasSuffix(sFile, sExt, false))
|
rlm@1
|
461 {
|
rlm@1
|
462 sFile += sExt;
|
rlm@1
|
463 }
|
rlm@1
|
464
|
rlm@1
|
465 if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
|
rlm@1
|
466 {
|
rlm@1
|
467 Gtk::MessageDialog oConfirmDialog(*this,
|
rlm@1
|
468 _("File already exists. Overwrite it?"),
|
rlm@1
|
469 #ifndef GTKMM20
|
rlm@1
|
470 false,
|
rlm@1
|
471 #endif // ! GTKMM20
|
rlm@1
|
472 Gtk::MESSAGE_QUESTION,
|
rlm@1
|
473 Gtk::BUTTONS_YES_NO);
|
rlm@1
|
474 if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
rlm@1
|
475 {
|
rlm@1
|
476 continue;
|
rlm@1
|
477 }
|
rlm@1
|
478 }
|
rlm@1
|
479
|
rlm@1
|
480 bool bResult;
|
rlm@1
|
481 if (m_eCartridge == CartridgeGB)
|
rlm@1
|
482 {
|
rlm@1
|
483 bResult = gbWriteBatteryFile(sFile.c_str(), false);
|
rlm@1
|
484 }
|
rlm@1
|
485 else
|
rlm@1
|
486 {
|
rlm@1
|
487 bResult = m_stEmulator.emuWriteBattery(sFile.c_str());
|
rlm@1
|
488 }
|
rlm@1
|
489
|
rlm@1
|
490 if (bResult)
|
rlm@1
|
491 {
|
rlm@1
|
492 break;
|
rlm@1
|
493 }
|
rlm@1
|
494 else
|
rlm@1
|
495 {
|
rlm@1
|
496 vPopupError(_("Failed to export battery file %s."),
|
rlm@1
|
497 sFile.c_str());
|
rlm@1
|
498 }
|
rlm@1
|
499 }
|
rlm@1
|
500 }
|
rlm@1
|
501
|
rlm@1
|
502 void Window::vOnFileScreenCapture()
|
rlm@1
|
503 {
|
rlm@1
|
504 std::string sCaptureDir = m_poDirConfig->sGetKey("captures");
|
rlm@1
|
505
|
rlm@1
|
506 #ifdef GTKMM20
|
rlm@1
|
507
|
rlm@1
|
508 Gtk::FileSelection oDialog(_("Save screenshot"));
|
rlm@1
|
509 oDialog.set_transient_for(*this);
|
rlm@1
|
510
|
rlm@1
|
511 if (sCaptureDir == "")
|
rlm@1
|
512 {
|
rlm@1
|
513 oDialog.set_filename(sCutSuffix(m_sRomFile));
|
rlm@1
|
514 }
|
rlm@1
|
515 else
|
rlm@1
|
516 {
|
rlm@1
|
517 oDialog.set_filename(sCaptureDir + "/" +
|
rlm@1
|
518 sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
519 }
|
rlm@1
|
520
|
rlm@1
|
521 #else // ! GTKMM20
|
rlm@1
|
522
|
rlm@1
|
523 Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"),
|
rlm@1
|
524 Gtk::FILE_CHOOSER_ACTION_SAVE);
|
rlm@1
|
525 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
526 oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
rlm@1
|
527
|
rlm@1
|
528 if (sCaptureDir == "")
|
rlm@1
|
529 {
|
rlm@1
|
530 oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
rlm@1
|
531 }
|
rlm@1
|
532 else
|
rlm@1
|
533 {
|
rlm@1
|
534 oDialog.set_current_folder(sCaptureDir);
|
rlm@1
|
535 oDialog.add_shortcut_folder(sCaptureDir);
|
rlm@1
|
536 }
|
rlm@1
|
537 oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
|
rlm@1
|
538
|
rlm@1
|
539 Gtk::FileFilter oPngFilter;
|
rlm@1
|
540 oPngFilter.set_name(_("PNG image"));
|
rlm@1
|
541 oPngFilter.add_pattern("*.[pP][nN][gG]");
|
rlm@1
|
542
|
rlm@1
|
543 Gtk::FileFilter oBmpFilter;
|
rlm@1
|
544 oBmpFilter.set_name(_("BMP image"));
|
rlm@1
|
545 oBmpFilter.add_pattern("*.[bB][mM][pP]");
|
rlm@1
|
546
|
rlm@1
|
547 oDialog.add_filter(oPngFilter);
|
rlm@1
|
548 oDialog.add_filter(oBmpFilter);
|
rlm@1
|
549
|
rlm@1
|
550 if (m_poCoreConfig->sGetKey("screenshot_format") == "bmp")
|
rlm@1
|
551 {
|
rlm@1
|
552 oDialog.set_filter(oBmpFilter);
|
rlm@1
|
553 }
|
rlm@1
|
554
|
rlm@1
|
555 #endif // ! GTKMM20
|
rlm@1
|
556
|
rlm@1
|
557 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
558 {
|
rlm@1
|
559 Glib::ustring sFile = oDialog.get_filename();
|
rlm@1
|
560 Glib::ustring sExt;
|
rlm@1
|
561
|
rlm@1
|
562 #ifdef GTKMM20
|
rlm@1
|
563
|
rlm@1
|
564 sExt = "." + m_poCoreConfig->sGetKey("screenshot_format");
|
rlm@1
|
565
|
rlm@1
|
566 #else // ! GTKMM20
|
rlm@1
|
567
|
rlm@1
|
568 if (oDialog.get_filter() == &oPngFilter)
|
rlm@1
|
569 {
|
rlm@1
|
570 sExt = ".png";
|
rlm@1
|
571 }
|
rlm@1
|
572 else
|
rlm@1
|
573 {
|
rlm@1
|
574 sExt = ".bmp";
|
rlm@1
|
575 }
|
rlm@1
|
576
|
rlm@1
|
577 #endif // ! GTKMM20
|
rlm@1
|
578
|
rlm@1
|
579 if (! bHasSuffix(sFile, sExt, false))
|
rlm@1
|
580 {
|
rlm@1
|
581 sFile += sExt;
|
rlm@1
|
582 }
|
rlm@1
|
583
|
rlm@1
|
584 if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
|
rlm@1
|
585 {
|
rlm@1
|
586 Gtk::MessageDialog oConfirmDialog(*this,
|
rlm@1
|
587 _("File already exists. Overwrite it?"),
|
rlm@1
|
588 #ifndef GTKMM20
|
rlm@1
|
589 false,
|
rlm@1
|
590 #endif // ! GTKMM20
|
rlm@1
|
591 Gtk::MESSAGE_QUESTION,
|
rlm@1
|
592 Gtk::BUTTONS_YES_NO);
|
rlm@1
|
593 if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
rlm@1
|
594 {
|
rlm@1
|
595 continue;
|
rlm@1
|
596 }
|
rlm@1
|
597 }
|
rlm@1
|
598
|
rlm@1
|
599 bool bResult;
|
rlm@1
|
600 if (sExt == ".png")
|
rlm@1
|
601 {
|
rlm@1
|
602 bResult = m_stEmulator.emuWritePNG(sFile.c_str());
|
rlm@1
|
603 }
|
rlm@1
|
604 else
|
rlm@1
|
605 {
|
rlm@1
|
606 bResult = m_stEmulator.emuWriteBMP(sFile.c_str());
|
rlm@1
|
607 }
|
rlm@1
|
608
|
rlm@1
|
609 if (bResult)
|
rlm@1
|
610 {
|
rlm@1
|
611 break;
|
rlm@1
|
612 }
|
rlm@1
|
613 }
|
rlm@1
|
614 }
|
rlm@1
|
615
|
rlm@1
|
616 void Window::vOnFileClose()
|
rlm@1
|
617 {
|
rlm@1
|
618 if (m_eCartridge != CartridgeNone)
|
rlm@1
|
619 {
|
rlm@1
|
620 soundPause();
|
rlm@1
|
621 vStopEmu();
|
rlm@1
|
622 vSetDefaultTitle();
|
rlm@1
|
623 vDrawDefaultScreen();
|
rlm@1
|
624 vSaveBattery();
|
rlm@1
|
625 m_stEmulator.emuCleanUp();
|
rlm@1
|
626 m_eCartridge = CartridgeNone;
|
rlm@1
|
627 emulating = 0;
|
rlm@1
|
628
|
rlm@1
|
629 vUpdateGameSlots();
|
rlm@1
|
630
|
rlm@1
|
631 for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
|
rlm@1
|
632 it != m_listSensitiveWhenPlaying.end();
|
rlm@1
|
633 it++)
|
rlm@1
|
634 {
|
rlm@1
|
635 (*it)->set_sensitive(false);
|
rlm@1
|
636 }
|
rlm@1
|
637
|
rlm@1
|
638 m_poFilePauseItem->set_active(false);
|
rlm@1
|
639 }
|
rlm@1
|
640 }
|
rlm@1
|
641
|
rlm@1
|
642 void Window::vOnFileExit()
|
rlm@1
|
643 {
|
rlm@1
|
644 hide();
|
rlm@1
|
645 }
|
rlm@1
|
646
|
rlm@1
|
647 void Window::vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue)
|
rlm@1
|
648 {
|
rlm@1
|
649 if (! _poCMI->get_active())
|
rlm@1
|
650 {
|
rlm@1
|
651 return;
|
rlm@1
|
652 }
|
rlm@1
|
653
|
rlm@1
|
654 if (_iValue >= 0 && _iValue <= 9)
|
rlm@1
|
655 {
|
rlm@1
|
656 m_poCoreConfig->vSetKey("frameskip", _iValue);
|
rlm@1
|
657 gbFrameSkip = _iValue;
|
rlm@1
|
658 systemFrameSkip = _iValue;
|
rlm@1
|
659 m_bAutoFrameskip = false;
|
rlm@1
|
660 }
|
rlm@1
|
661 else
|
rlm@1
|
662 {
|
rlm@1
|
663 m_poCoreConfig->vSetKey("frameskip", "auto");
|
rlm@1
|
664 gbFrameSkip = 0;
|
rlm@1
|
665 systemFrameSkip = 0;
|
rlm@1
|
666 m_bAutoFrameskip = true;
|
rlm@1
|
667 }
|
rlm@1
|
668 }
|
rlm@1
|
669
|
rlm@1
|
670 void Window::vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent)
|
rlm@1
|
671 {
|
rlm@1
|
672 if (! _poCMI->get_active())
|
rlm@1
|
673 {
|
rlm@1
|
674 return;
|
rlm@1
|
675 }
|
rlm@1
|
676
|
rlm@1
|
677 vSetThrottle(_iPercent);
|
rlm@1
|
678
|
rlm@1
|
679 // Initialize the frameskip adjustment each time throttle is changed
|
rlm@1
|
680 if (m_bAutoFrameskip)
|
rlm@1
|
681 {
|
rlm@1
|
682 systemFrameSkip = 0;
|
rlm@1
|
683 }
|
rlm@1
|
684 }
|
rlm@1
|
685
|
rlm@1
|
686 void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
687 {
|
rlm@1
|
688 if (! _poCMI->get_active())
|
rlm@1
|
689 {
|
rlm@1
|
690 return;
|
rlm@1
|
691 }
|
rlm@1
|
692
|
rlm@1
|
693 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
694 poXml = Xml::create(PKGDATADIR "/vba.glade", "ThrottleDialog");
|
rlm@1
|
695
|
rlm@1
|
696 Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("ThrottleDialog"));
|
rlm@1
|
697 Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("ThrottleSpin"));
|
rlm@1
|
698
|
rlm@1
|
699 poDialog->set_transient_for(*this);
|
rlm@1
|
700
|
rlm@1
|
701 if (m_iThrottle != 0)
|
rlm@1
|
702 {
|
rlm@1
|
703 poSpin->set_value(m_iThrottle);
|
rlm@1
|
704 }
|
rlm@1
|
705 else
|
rlm@1
|
706 {
|
rlm@1
|
707 poSpin->set_value(100);
|
rlm@1
|
708 }
|
rlm@1
|
709
|
rlm@1
|
710 if (poDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
711 {
|
rlm@1
|
712 vSetThrottle(poSpin->get_value_as_int());
|
rlm@1
|
713 }
|
rlm@1
|
714
|
rlm@1
|
715 delete poDialog;
|
rlm@1
|
716 vSelectBestThrottleItem();
|
rlm@1
|
717 }
|
rlm@1
|
718
|
rlm@1
|
719 void Window::vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale)
|
rlm@1
|
720 {
|
rlm@1
|
721 if (! _poCMI->get_active())
|
rlm@1
|
722 {
|
rlm@1
|
723 return;
|
rlm@1
|
724 }
|
rlm@1
|
725
|
rlm@1
|
726 m_poDisplayConfig->vSetKey("scale", _iScale);
|
rlm@1
|
727 vUpdateScreen();
|
rlm@1
|
728 }
|
rlm@1
|
729
|
rlm@1
|
730 void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer)
|
rlm@1
|
731 {
|
rlm@1
|
732 int iMask = (0x0100 << _iLayer);
|
rlm@1
|
733 if (_poCMI->get_active())
|
rlm@1
|
734 {
|
rlm@1
|
735 layerSettings |= iMask;
|
rlm@1
|
736 }
|
rlm@1
|
737 else
|
rlm@1
|
738 {
|
rlm@1
|
739 layerSettings &= ~iMask;
|
rlm@1
|
740 }
|
rlm@1
|
741 layerEnable = DISPCNT & layerSettings;
|
rlm@1
|
742
|
rlm@1
|
743 const char * acsLayers[] =
|
rlm@1
|
744 {
|
rlm@1
|
745 "layer_bg0",
|
rlm@1
|
746 "layer_bg1",
|
rlm@1
|
747 "layer_bg2",
|
rlm@1
|
748 "layer_bg3",
|
rlm@1
|
749 "layer_obj",
|
rlm@1
|
750 "layer_win0",
|
rlm@1
|
751 "layer_win1",
|
rlm@1
|
752 "layer_objwin"
|
rlm@1
|
753 };
|
rlm@1
|
754 m_poCoreConfig->vSetKey(acsLayers[_iLayer], _poCMI->get_active());
|
rlm@1
|
755 }
|
rlm@1
|
756
|
rlm@1
|
757 void Window::vOnDirectories()
|
rlm@1
|
758 {
|
rlm@1
|
759 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
760 poXml = Xml::create(PKGDATADIR "/vba.glade", "DirectoriesDialog");
|
rlm@1
|
761
|
rlm@1
|
762 struct
|
rlm@1
|
763 {
|
rlm@1
|
764 const char * m_csKey;
|
rlm@1
|
765 const char * m_csEntry;
|
rlm@1
|
766 const char * m_csResetButton;
|
rlm@1
|
767 const char * m_csSelectButton;
|
rlm@1
|
768 }
|
rlm@1
|
769 astRow[] =
|
rlm@1
|
770 {
|
rlm@1
|
771 { "gba_roms", "GBARomsDirEntry", "GBARomsDirResetButton", "GBARomsDirSelectButton" },
|
rlm@1
|
772 { "gb_roms", "GBRomsDirEntry", "GBRomsDirResetButton", "GBRomsDirSelectButton" },
|
rlm@1
|
773 { "batteries", "BatteriesDirEntry", "BatteriesDirResetButton", "BatteriesDirSelectButton" },
|
rlm@1
|
774 { "saves", "SavesDirEntry", "SavesDirResetButton", "SavesDirSelectButton" },
|
rlm@1
|
775 { "captures", "CapturesDirEntry", "CapturesDirResetButton", "CapturesDirSelectButton" }
|
rlm@1
|
776 };
|
rlm@1
|
777
|
rlm@1
|
778 for (guint i = 0; i < G_N_ELEMENTS(astRow); i++)
|
rlm@1
|
779 {
|
rlm@1
|
780 Gtk::Entry * poEntry = dynamic_cast<Gtk::Entry *>(poXml->get_widget(astRow[i].m_csEntry));
|
rlm@1
|
781 Gtk::Button * poReset = dynamic_cast<Gtk::Button *>(poXml->get_widget(astRow[i].m_csResetButton));
|
rlm@1
|
782 Gtk::Button * poSelect = dynamic_cast<Gtk::Button *>(poXml->get_widget(astRow[i].m_csSelectButton));
|
rlm@1
|
783
|
rlm@1
|
784 poEntry->set_text(m_poDirConfig->sGetKey(astRow[i].m_csKey));
|
rlm@1
|
785
|
rlm@1
|
786 poReset->signal_clicked().connect(SigC::bind<Gtk::Entry *>(
|
rlm@1
|
787 SigC::slot(*this, &Window::vOnDirectoryReset),
|
rlm@1
|
788 poEntry));
|
rlm@1
|
789 poSelect->signal_clicked().connect(SigC::bind<Gtk::Entry *>(
|
rlm@1
|
790 SigC::slot(*this, &Window::vOnDirectorySelect),
|
rlm@1
|
791 poEntry));
|
rlm@1
|
792 }
|
rlm@1
|
793
|
rlm@1
|
794 Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("DirectoriesDialog"));
|
rlm@1
|
795 poDialog->set_transient_for(*this);
|
rlm@1
|
796
|
rlm@1
|
797 if (poDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
798 {
|
rlm@1
|
799 for (guint i = 0; i < G_N_ELEMENTS(astRow); i++)
|
rlm@1
|
800 {
|
rlm@1
|
801 Gtk::Entry * poEntry = dynamic_cast<Gtk::Entry *>(poXml->get_widget(astRow[i].m_csEntry));
|
rlm@1
|
802 Glib::ustring sDir = poEntry->get_text();
|
rlm@1
|
803 if (! Glib::file_test(sDir, Glib::FILE_TEST_IS_DIR))
|
rlm@1
|
804 {
|
rlm@1
|
805 sDir = "";
|
rlm@1
|
806 }
|
rlm@1
|
807 m_poDirConfig->vSetKey(astRow[i].m_csKey, sDir);
|
rlm@1
|
808 }
|
rlm@1
|
809
|
rlm@1
|
810 // Needed if saves dir changed
|
rlm@1
|
811 vUpdateGameSlots();
|
rlm@1
|
812 }
|
rlm@1
|
813
|
rlm@1
|
814 delete poDialog;
|
rlm@1
|
815 }
|
rlm@1
|
816
|
rlm@1
|
817 void Window::vOnDirectoryReset(Gtk::Entry * _poEntry)
|
rlm@1
|
818 {
|
rlm@1
|
819 _poEntry->set_text("");
|
rlm@1
|
820 }
|
rlm@1
|
821
|
rlm@1
|
822 void Window::vOnDirectorySelect(Gtk::Entry * _poEntry)
|
rlm@1
|
823 {
|
rlm@1
|
824 #ifdef GTKMM20
|
rlm@1
|
825
|
rlm@1
|
826 Gtk::FileSelection oDialog(_("Select directory"));
|
rlm@1
|
827 oDialog.set_transient_for(*this);
|
rlm@1
|
828
|
rlm@1
|
829 if (_poEntry->get_text() != "")
|
rlm@1
|
830 {
|
rlm@1
|
831 oDialog.set_filename(_poEntry->get_text() + "/");
|
rlm@1
|
832 }
|
rlm@1
|
833
|
rlm@1
|
834 if (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
835 {
|
rlm@1
|
836 std::string sFile = oDialog.get_filename();
|
rlm@1
|
837 if (! Glib::file_test(sFile, Glib::FILE_TEST_IS_DIR))
|
rlm@1
|
838 {
|
rlm@1
|
839 sFile = Glib::path_get_dirname(sFile);
|
rlm@1
|
840 }
|
rlm@1
|
841 _poEntry->set_text(sFile);
|
rlm@1
|
842 }
|
rlm@1
|
843
|
rlm@1
|
844 #else // ! GTKMM20
|
rlm@1
|
845
|
rlm@1
|
846 Gtk::FileChooserDialog oDialog(*this, _("Select directory"),
|
rlm@1
|
847 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
rlm@1
|
848 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
849 oDialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
rlm@1
|
850
|
rlm@1
|
851 if (_poEntry->get_text() != "")
|
rlm@1
|
852 {
|
rlm@1
|
853 oDialog.add_shortcut_folder(_poEntry->get_text());
|
rlm@1
|
854 oDialog.set_current_folder(_poEntry->get_text());
|
rlm@1
|
855 }
|
rlm@1
|
856
|
rlm@1
|
857 if (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
858 {
|
rlm@1
|
859 _poEntry->set_text(oDialog.get_filename());
|
rlm@1
|
860 }
|
rlm@1
|
861
|
rlm@1
|
862 #endif // ! GTKMM20
|
rlm@1
|
863 }
|
rlm@1
|
864
|
rlm@1
|
865 void Window::vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
866 {
|
rlm@1
|
867 m_poDisplayConfig->vSetKey("pause_when_inactive", _poCMI->get_active());
|
rlm@1
|
868 }
|
rlm@1
|
869
|
rlm@1
|
870 void Window::vOnSelectBios()
|
rlm@1
|
871 {
|
rlm@1
|
872 #ifdef GTKMM20
|
rlm@1
|
873
|
rlm@1
|
874 Gtk::FileSelection oDialog(_("Select BIOS file"));
|
rlm@1
|
875 oDialog.set_transient_for(*this);
|
rlm@1
|
876
|
rlm@1
|
877 if (m_poCoreConfig->sGetKey("bios_file") != "")
|
rlm@1
|
878 {
|
rlm@1
|
879 oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file"));
|
rlm@1
|
880 }
|
rlm@1
|
881
|
rlm@1
|
882 #else // ! GTKMM20
|
rlm@1
|
883
|
rlm@1
|
884 Gtk::FileChooserDialog oDialog(*this, _("Select BIOS file"));
|
rlm@1
|
885 oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
rlm@1
|
886 oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
rlm@1
|
887
|
rlm@1
|
888 if (m_poCoreConfig->sGetKey("bios_file") != "")
|
rlm@1
|
889 {
|
rlm@1
|
890 oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file"));
|
rlm@1
|
891 }
|
rlm@1
|
892
|
rlm@1
|
893 const char * acsPattern[] =
|
rlm@1
|
894 {
|
rlm@1
|
895 "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
|
rlm@1
|
896 "*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
|
rlm@1
|
897 };
|
rlm@1
|
898
|
rlm@1
|
899 Gtk::FileFilter oAllFilter;
|
rlm@1
|
900 oAllFilter.set_name(_("All files"));
|
rlm@1
|
901 oAllFilter.add_pattern("*");
|
rlm@1
|
902
|
rlm@1
|
903 Gtk::FileFilter oBiosFilter;
|
rlm@1
|
904 oBiosFilter.set_name(_("Gameboy Advance BIOS"));
|
rlm@1
|
905 for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
|
rlm@1
|
906 {
|
rlm@1
|
907 oBiosFilter.add_pattern(acsPattern[i]);
|
rlm@1
|
908 }
|
rlm@1
|
909
|
rlm@1
|
910 oDialog.add_filter(oAllFilter);
|
rlm@1
|
911 oDialog.add_filter(oBiosFilter);
|
rlm@1
|
912
|
rlm@1
|
913 oDialog.set_filter(oBiosFilter);
|
rlm@1
|
914
|
rlm@1
|
915 #endif // ! GTKMM20
|
rlm@1
|
916
|
rlm@1
|
917 while (oDialog.run() == Gtk::RESPONSE_OK)
|
rlm@1
|
918 {
|
rlm@1
|
919 if (Glib::file_test(oDialog.get_filename(), Glib::FILE_TEST_IS_REGULAR))
|
rlm@1
|
920 {
|
rlm@1
|
921 m_poCoreConfig->vSetKey("bios_file", oDialog.get_filename());
|
rlm@1
|
922 m_poUseBiosItem->set_sensitive();
|
rlm@1
|
923 break;
|
rlm@1
|
924 }
|
rlm@1
|
925 }
|
rlm@1
|
926 }
|
rlm@1
|
927
|
rlm@1
|
928 void Window::vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
929 {
|
rlm@1
|
930 m_poCoreConfig->vSetKey("use_bios_file", _poCMI->get_active());
|
rlm@1
|
931 }
|
rlm@1
|
932
|
rlm@1
|
933 void Window::vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed)
|
rlm@1
|
934 {
|
rlm@1
|
935 if (! _poCMI->get_active())
|
rlm@1
|
936 {
|
rlm@1
|
937 return;
|
rlm@1
|
938 }
|
rlm@1
|
939
|
rlm@1
|
940 m_eShowSpeed = (EShowSpeed)_iShowSpeed;
|
rlm@1
|
941 if (m_eShowSpeed == ShowNone)
|
rlm@1
|
942 {
|
rlm@1
|
943 vSetDefaultTitle();
|
rlm@1
|
944 }
|
rlm@1
|
945 m_poDisplayConfig->vSetKey("show_speed", _iShowSpeed);
|
rlm@1
|
946 }
|
rlm@1
|
947
|
rlm@1
|
948 void Window::vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType)
|
rlm@1
|
949 {
|
rlm@1
|
950 if (! _poCMI->get_active())
|
rlm@1
|
951 {
|
rlm@1
|
952 return;
|
rlm@1
|
953 }
|
rlm@1
|
954
|
rlm@1
|
955 cpuSaveType = _iSaveType;
|
rlm@1
|
956 m_poCoreConfig->vSetKey("save_type", _iSaveType);
|
rlm@1
|
957 }
|
rlm@1
|
958
|
rlm@1
|
959 void Window::vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize)
|
rlm@1
|
960 {
|
rlm@1
|
961 if (! _poCMI->get_active())
|
rlm@1
|
962 {
|
rlm@1
|
963 return;
|
rlm@1
|
964 }
|
rlm@1
|
965
|
rlm@1
|
966 if (_iFlashSize == 64)
|
rlm@1
|
967 {
|
rlm@1
|
968 flashSetSize(0x10000);
|
rlm@1
|
969 }
|
rlm@1
|
970 else
|
rlm@1
|
971 {
|
rlm@1
|
972 flashSetSize(0x20000);
|
rlm@1
|
973 }
|
rlm@1
|
974 m_poCoreConfig->vSetKey("flash_size", _iFlashSize);
|
rlm@1
|
975 }
|
rlm@1
|
976
|
rlm@1
|
977 void Window::vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat)
|
rlm@1
|
978 {
|
rlm@1
|
979 if (! _poCMI->get_active())
|
rlm@1
|
980 {
|
rlm@1
|
981 return;
|
rlm@1
|
982 }
|
rlm@1
|
983
|
rlm@1
|
984 m_poCoreConfig->vSetKey("screenshot_format", _sFormat);
|
rlm@1
|
985 }
|
rlm@1
|
986
|
rlm@1
|
987 void Window::vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus)
|
rlm@1
|
988 {
|
rlm@1
|
989 if (! _poCMI->get_active())
|
rlm@1
|
990 {
|
rlm@1
|
991 return;
|
rlm@1
|
992 }
|
rlm@1
|
993
|
rlm@1
|
994 std::string sSoundStatus;
|
rlm@1
|
995 switch (_iSoundStatus)
|
rlm@1
|
996 {
|
rlm@1
|
997 case SoundOff:
|
rlm@1
|
998 soundOffFlag = true;
|
rlm@1
|
999 if (systemSoundOn)
|
rlm@1
|
1000 {
|
rlm@1
|
1001 soundShutdown();
|
rlm@1
|
1002 }
|
rlm@1
|
1003 sSoundStatus = "off";
|
rlm@1
|
1004 break;
|
rlm@1
|
1005 case SoundMute:
|
rlm@1
|
1006 soundDisableChannels(0x30f);
|
rlm@1
|
1007 sSoundStatus = "mute";
|
rlm@1
|
1008 break;
|
rlm@1
|
1009 case SoundOn:
|
rlm@1
|
1010 if (soundOffFlag)
|
rlm@1
|
1011 {
|
rlm@1
|
1012 soundOffFlag = false;
|
rlm@1
|
1013 if (! soundInit())
|
rlm@1
|
1014 {
|
rlm@1
|
1015 m_poSoundOffItem->set_active();
|
rlm@1
|
1016 return;
|
rlm@1
|
1017 }
|
rlm@1
|
1018 }
|
rlm@1
|
1019 soundEnableChannels(0x30f);
|
rlm@1
|
1020 sSoundStatus = "on";
|
rlm@1
|
1021 break;
|
rlm@1
|
1022 }
|
rlm@1
|
1023 m_poSoundConfig->vSetKey("status", sSoundStatus);
|
rlm@1
|
1024 }
|
rlm@1
|
1025
|
rlm@1
|
1026 void Window::vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1027 {
|
rlm@1
|
1028 soundEcho = _poCMI->get_active();
|
rlm@1
|
1029 m_poSoundConfig->vSetKey("echo", soundEcho);
|
rlm@1
|
1030 }
|
rlm@1
|
1031
|
rlm@1
|
1032 void Window::vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1033 {
|
rlm@1
|
1034 soundLowPass = _poCMI->get_active();
|
rlm@1
|
1035 m_poSoundConfig->vSetKey("low_pass", soundLowPass);
|
rlm@1
|
1036 }
|
rlm@1
|
1037
|
rlm@1
|
1038 void Window::vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1039 {
|
rlm@1
|
1040 soundReverse = _poCMI->get_active();
|
rlm@1
|
1041 m_poSoundConfig->vSetKey("reverse_stereo", soundReverse);
|
rlm@1
|
1042 }
|
rlm@1
|
1043
|
rlm@1
|
1044 void Window::vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel)
|
rlm@1
|
1045 {
|
rlm@1
|
1046 int iShift = _iSoundChannel;
|
rlm@1
|
1047 if (_iSoundChannel > 3)
|
rlm@1
|
1048 {
|
rlm@1
|
1049 iShift += 4;
|
rlm@1
|
1050 }
|
rlm@1
|
1051 int iFlag = 1 << iShift;
|
rlm@1
|
1052 int iActive = soundGetEnabledChannels() & 0x30f;
|
rlm@1
|
1053 if (_poCMI->get_active())
|
rlm@1
|
1054 {
|
rlm@1
|
1055 iActive |= iFlag;
|
rlm@1
|
1056 }
|
rlm@1
|
1057 else
|
rlm@1
|
1058 {
|
rlm@1
|
1059 iActive &= ~iFlag;
|
rlm@1
|
1060 }
|
rlm@1
|
1061 soundEnableChannels(iActive);
|
rlm@1
|
1062 soundDisableChannels(~iActive & 0x30f);
|
rlm@1
|
1063
|
rlm@1
|
1064 const char * acsChannels[] =
|
rlm@1
|
1065 {
|
rlm@1
|
1066 "channel_1",
|
rlm@1
|
1067 "channel_2",
|
rlm@1
|
1068 "channel_3",
|
rlm@1
|
1069 "channel_4",
|
rlm@1
|
1070 "channel_A",
|
rlm@1
|
1071 "channel_B"
|
rlm@1
|
1072 };
|
rlm@1
|
1073 m_poSoundConfig->vSetKey(acsChannels[_iSoundChannel], _poCMI->get_active());
|
rlm@1
|
1074 }
|
rlm@1
|
1075
|
rlm@1
|
1076 void Window::vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality)
|
rlm@1
|
1077 {
|
rlm@1
|
1078 if (! _poCMI->get_active())
|
rlm@1
|
1079 {
|
rlm@1
|
1080 return;
|
rlm@1
|
1081 }
|
rlm@1
|
1082
|
rlm@1
|
1083 m_eSoundQuality = (ESoundQuality)_iSoundQuality;
|
rlm@1
|
1084 if (m_eCartridge == CartridgeGBA)
|
rlm@1
|
1085 {
|
rlm@1
|
1086 soundSetQuality(_iSoundQuality);
|
rlm@1
|
1087 }
|
rlm@1
|
1088 else if (m_eCartridge == CartridgeGB)
|
rlm@1
|
1089 {
|
rlm@1
|
1090 gbSoundSetQuality(_iSoundQuality);
|
rlm@1
|
1091 }
|
rlm@1
|
1092 m_poSoundConfig->vSetKey("quality", _iSoundQuality);
|
rlm@1
|
1093 }
|
rlm@1
|
1094
|
rlm@1
|
1095 void Window::vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume)
|
rlm@1
|
1096 {
|
rlm@1
|
1097 if (! _poCMI->get_active())
|
rlm@1
|
1098 {
|
rlm@1
|
1099 return;
|
rlm@1
|
1100 }
|
rlm@1
|
1101
|
rlm@1
|
1102 soundVolume = _iSoundVolume;
|
rlm@1
|
1103 m_poSoundConfig->vSetKey("volume", _iSoundVolume);
|
rlm@1
|
1104 }
|
rlm@1
|
1105
|
rlm@1
|
1106 void Window::vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1107 {
|
rlm@1
|
1108 gbBorderOn = _poCMI->get_active();
|
rlm@1
|
1109 if (emulating && m_eCartridge == CartridgeGB && _poCMI->get_active())
|
rlm@1
|
1110 {
|
rlm@1
|
1111 gbSgbRenderBorder();
|
rlm@1
|
1112 }
|
rlm@1
|
1113 vUpdateScreen();
|
rlm@1
|
1114 m_poCoreConfig->vSetKey("gb_border", _poCMI->get_active());
|
rlm@1
|
1115 }
|
rlm@1
|
1116
|
rlm@1
|
1117 void Window::vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1118 {
|
rlm@1
|
1119 if (_poCMI->get_active())
|
rlm@1
|
1120 {
|
rlm@1
|
1121 gbSerialFunction = gbPrinterSend;
|
rlm@1
|
1122 }
|
rlm@1
|
1123 else
|
rlm@1
|
1124 {
|
rlm@1
|
1125 gbSerialFunction = NULL;
|
rlm@1
|
1126 }
|
rlm@1
|
1127 m_poCoreConfig->vSetKey("gb_printer", _poCMI->get_active());
|
rlm@1
|
1128 }
|
rlm@1
|
1129
|
rlm@1
|
1130 void Window::vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType)
|
rlm@1
|
1131 {
|
rlm@1
|
1132 gbEmulatorType = _iEmulatorType;
|
rlm@1
|
1133 m_poCoreConfig->vSetKey("emulator_type", _iEmulatorType);
|
rlm@1
|
1134 }
|
rlm@1
|
1135
|
rlm@1
|
1136 void Window::vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x)
|
rlm@1
|
1137 {
|
rlm@1
|
1138 if (! _poCMI->get_active())
|
rlm@1
|
1139 {
|
rlm@1
|
1140 return;
|
rlm@1
|
1141 }
|
rlm@1
|
1142
|
rlm@1
|
1143 m_poScreenArea->vSetFilter2x((EFilter2x)_iFilter2x);
|
rlm@1
|
1144 if (emulating)
|
rlm@1
|
1145 {
|
rlm@1
|
1146 vDrawScreen();
|
rlm@1
|
1147 }
|
rlm@1
|
1148 m_poDisplayConfig->vSetKey("filter2x", _iFilter2x);
|
rlm@1
|
1149 }
|
rlm@1
|
1150
|
rlm@1
|
1151 void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB)
|
rlm@1
|
1152 {
|
rlm@1
|
1153 if (! _poCMI->get_active())
|
rlm@1
|
1154 {
|
rlm@1
|
1155 return;
|
rlm@1
|
1156 }
|
rlm@1
|
1157
|
rlm@1
|
1158 m_poScreenArea->vSetFilterIB((EFilterIB)_iFilterIB);
|
rlm@1
|
1159 if (emulating)
|
rlm@1
|
1160 {
|
rlm@1
|
1161 vDrawScreen();
|
rlm@1
|
1162 }
|
rlm@1
|
1163 m_poDisplayConfig->vSetKey("filterIB", _iFilterIB);
|
rlm@1
|
1164 }
|
rlm@1
|
1165
|
rlm@1
|
1166 #ifdef MMX
|
rlm@1
|
1167 void Window::vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI)
|
rlm@1
|
1168 {
|
rlm@1
|
1169 cpu_mmx = ! _poCMI->get_active();
|
rlm@1
|
1170 m_poDisplayConfig->vSetKey("filter_disable_mmx", _poCMI->get_active());
|
rlm@1
|
1171 }
|
rlm@1
|
1172 #endif // MMX
|
rlm@1
|
1173
|
rlm@1
|
1174 void Window::vOnJoypadConfigure(int _iJoypad)
|
rlm@1
|
1175 {
|
rlm@1
|
1176 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
1177 poXml = Xml::create(PKGDATADIR "/vba.glade", "JoypadConfigDialog");
|
rlm@1
|
1178
|
rlm@1
|
1179 JoypadConfigDialog * poDialog = NULL;
|
rlm@1
|
1180 poXml->get_widget_derived<JoypadConfigDialog>("JoypadConfigDialog", poDialog);
|
rlm@1
|
1181 poDialog->set_transient_for(*this);
|
rlm@1
|
1182 poDialog->vSetConfig(m_oJoypads[_iJoypad - 1]);
|
rlm@1
|
1183
|
rlm@1
|
1184 if (poDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
1185 {
|
rlm@1
|
1186 m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig();
|
rlm@1
|
1187 if (_iJoypad == m_poInputConfig->oGetKey<int>("active_joypad"))
|
rlm@1
|
1188 {
|
rlm@1
|
1189 if (m_poKeymap != NULL)
|
rlm@1
|
1190 {
|
rlm@1
|
1191 delete m_poKeymap;
|
rlm@1
|
1192 }
|
rlm@1
|
1193 m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
|
rlm@1
|
1194 }
|
rlm@1
|
1195 }
|
rlm@1
|
1196
|
rlm@1
|
1197 delete poDialog;
|
rlm@1
|
1198 }
|
rlm@1
|
1199
|
rlm@1
|
1200 void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad)
|
rlm@1
|
1201 {
|
rlm@1
|
1202 if (! _poCMI->get_active())
|
rlm@1
|
1203 {
|
rlm@1
|
1204 return;
|
rlm@1
|
1205 }
|
rlm@1
|
1206
|
rlm@1
|
1207 if (m_poKeymap != NULL)
|
rlm@1
|
1208 {
|
rlm@1
|
1209 delete m_poKeymap;
|
rlm@1
|
1210 }
|
rlm@1
|
1211 m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap();
|
rlm@1
|
1212
|
rlm@1
|
1213 m_poInputConfig->vSetKey("active_joypad", _iJoypad);
|
rlm@1
|
1214 }
|
rlm@1
|
1215
|
rlm@1
|
1216 void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag)
|
rlm@1
|
1217 {
|
rlm@1
|
1218 if (_poCMI->get_active())
|
rlm@1
|
1219 {
|
rlm@1
|
1220 m_uiAutofireState |= _uiKeyFlag;
|
rlm@1
|
1221 }
|
rlm@1
|
1222 else
|
rlm@1
|
1223 {
|
rlm@1
|
1224 m_uiAutofireState &= ~_uiKeyFlag;
|
rlm@1
|
1225 }
|
rlm@1
|
1226
|
rlm@1
|
1227 std::string sKey;
|
rlm@1
|
1228 if (_uiKeyFlag == KeyFlagA)
|
rlm@1
|
1229 {
|
rlm@1
|
1230 sKey = "autofire_A";
|
rlm@1
|
1231 }
|
rlm@1
|
1232 else if (_uiKeyFlag == KeyFlagB)
|
rlm@1
|
1233 {
|
rlm@1
|
1234 sKey = "autofire_B";
|
rlm@1
|
1235 }
|
rlm@1
|
1236 else if (_uiKeyFlag == KeyFlagL)
|
rlm@1
|
1237 {
|
rlm@1
|
1238 sKey = "autofire_L";
|
rlm@1
|
1239 }
|
rlm@1
|
1240 else if (_uiKeyFlag == KeyFlagR)
|
rlm@1
|
1241 {
|
rlm@1
|
1242 sKey = "autofire_R";
|
rlm@1
|
1243 }
|
rlm@1
|
1244 m_poInputConfig->vSetKey(sKey, _poCMI->get_active());
|
rlm@1
|
1245 }
|
rlm@1
|
1246
|
rlm@1
|
1247 void Window::vOnGDBWait()
|
rlm@1
|
1248 {
|
rlm@1
|
1249 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
1250 poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog");
|
rlm@1
|
1251
|
rlm@1
|
1252 Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("TcpPortDialog"));
|
rlm@1
|
1253 Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("TcpPortSpin"));
|
rlm@1
|
1254
|
rlm@1
|
1255 poDialog->set_transient_for(*this);
|
rlm@1
|
1256
|
rlm@1
|
1257 int iPort = 55555;
|
rlm@1
|
1258 poSpin->set_value(iPort);
|
rlm@1
|
1259
|
rlm@1
|
1260 bool bOk = false;
|
rlm@1
|
1261 if (poDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
1262 {
|
rlm@1
|
1263 bOk = true;
|
rlm@1
|
1264 iPort = poSpin->get_value_as_int();
|
rlm@1
|
1265 }
|
rlm@1
|
1266 delete poDialog;
|
rlm@1
|
1267
|
rlm@1
|
1268 if (! bOk)
|
rlm@1
|
1269 {
|
rlm@1
|
1270 return;
|
rlm@1
|
1271 }
|
rlm@1
|
1272
|
rlm@1
|
1273 m_eCartridge = CartridgeGBA;
|
rlm@1
|
1274 m_sRomFile = "gnu_stub";
|
rlm@1
|
1275 m_stEmulator = GBASystem;
|
rlm@1
|
1276
|
rlm@1
|
1277 rom = (u8 *) malloc(0x2000000);
|
rlm@1
|
1278 workRAM = (u8 *) calloc(1, 0x40000);
|
rlm@1
|
1279 bios = (u8 *) calloc(1, 0x4000);
|
rlm@1
|
1280 internalRAM = (u8 *) calloc(1, 0x8000);
|
rlm@1
|
1281 paletteRAM = (u8 *) calloc(1, 0x400);
|
rlm@1
|
1282 vram = (u8 *) calloc(1, 0x20000);
|
rlm@1
|
1283 oam = (u8 *) calloc(1, 0x400);
|
rlm@1
|
1284 pix = (u8 *) calloc(1, 4 * m_iGBAScreenWidth * m_iGBAScreenHeight);
|
rlm@1
|
1285 ioMem = (u8 *) calloc(1, 0x400);
|
rlm@1
|
1286
|
rlm@1
|
1287 useBios = m_poCoreConfig->oGetKey<bool>("use_bios_file");
|
rlm@1
|
1288 //CPUInit(m_poCoreConfig->sGetKey("bios_file").c_str(), useBios);
|
rlm@1
|
1289 CPUInit();
|
rlm@1
|
1290 CPUReset();
|
rlm@1
|
1291
|
rlm@1
|
1292 for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
|
rlm@1
|
1293 it != m_listSensitiveWhenPlaying.end();
|
rlm@1
|
1294 it++)
|
rlm@1
|
1295 {
|
rlm@1
|
1296 (*it)->set_sensitive();
|
rlm@1
|
1297 }
|
rlm@1
|
1298
|
rlm@1
|
1299 if (m_poCoreConfig->oGetKey<bool>("load_game_auto"))
|
rlm@1
|
1300 {
|
rlm@1
|
1301 vOnLoadGameMostRecent();
|
rlm@1
|
1302 }
|
rlm@1
|
1303
|
rlm@1
|
1304 vStartEmu();
|
rlm@1
|
1305
|
rlm@1
|
1306 emulating = 1;
|
rlm@1
|
1307
|
rlm@1
|
1308 dbgMain = remoteStubMain;
|
rlm@1
|
1309 dbgSignal = remoteStubSignal;
|
rlm@1
|
1310 dbgOutput = remoteOutput;
|
rlm@1
|
1311 debugger = true;
|
rlm@1
|
1312
|
rlm@1
|
1313 remoteSetProtocol(0);
|
rlm@1
|
1314 remoteSetPort(iPort);
|
rlm@1
|
1315 remoteInit();
|
rlm@1
|
1316 }
|
rlm@1
|
1317
|
rlm@1
|
1318 void Window::vOnGDBLoadAndWait()
|
rlm@1
|
1319 {
|
rlm@1
|
1320 bool bLoaded = false;
|
rlm@1
|
1321
|
rlm@1
|
1322 while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
1323 {
|
rlm@1
|
1324 if (bLoadROM(m_poFileOpenDialog->get_filename()))
|
rlm@1
|
1325 {
|
rlm@1
|
1326 bLoaded = true;
|
rlm@1
|
1327 break;
|
rlm@1
|
1328 }
|
rlm@1
|
1329 }
|
rlm@1
|
1330 m_poFileOpenDialog->hide();
|
rlm@1
|
1331
|
rlm@1
|
1332 if (! bLoaded)
|
rlm@1
|
1333 {
|
rlm@1
|
1334 return;
|
rlm@1
|
1335 }
|
rlm@1
|
1336
|
rlm@1
|
1337 if (m_eCartridge != CartridgeGBA)
|
rlm@1
|
1338 {
|
rlm@1
|
1339 vPopupError(_("Only GBA images are supported."));
|
rlm@1
|
1340 vOnFileClose();
|
rlm@1
|
1341 return;
|
rlm@1
|
1342 }
|
rlm@1
|
1343
|
rlm@1
|
1344 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
1345 poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog");
|
rlm@1
|
1346
|
rlm@1
|
1347 Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("TcpPortDialog"));
|
rlm@1
|
1348 Gtk::SpinButton * poSpin = dynamic_cast<Gtk::SpinButton *>(poXml->get_widget("TcpPortSpin"));
|
rlm@1
|
1349
|
rlm@1
|
1350 poDialog->set_transient_for(*this);
|
rlm@1
|
1351
|
rlm@1
|
1352 int iPort = 55555;
|
rlm@1
|
1353 poSpin->set_value(iPort);
|
rlm@1
|
1354
|
rlm@1
|
1355 bool bOk = false;
|
rlm@1
|
1356 if (poDialog->run() == Gtk::RESPONSE_OK)
|
rlm@1
|
1357 {
|
rlm@1
|
1358 bOk = true;
|
rlm@1
|
1359 iPort = poSpin->get_value_as_int();
|
rlm@1
|
1360 }
|
rlm@1
|
1361 delete poDialog;
|
rlm@1
|
1362
|
rlm@1
|
1363 if (! bOk)
|
rlm@1
|
1364 {
|
rlm@1
|
1365 return;
|
rlm@1
|
1366 }
|
rlm@1
|
1367
|
rlm@1
|
1368 dbgMain = remoteStubMain;
|
rlm@1
|
1369 dbgSignal = remoteStubSignal;
|
rlm@1
|
1370 dbgOutput = remoteOutput;
|
rlm@1
|
1371 debugger = true;
|
rlm@1
|
1372
|
rlm@1
|
1373 remoteSetProtocol(0);
|
rlm@1
|
1374 remoteSetPort(iPort);
|
rlm@1
|
1375 remoteInit();
|
rlm@1
|
1376 }
|
rlm@1
|
1377
|
rlm@1
|
1378 void Window::vOnGDBBreak()
|
rlm@1
|
1379 {
|
rlm@1
|
1380 if (armState)
|
rlm@1
|
1381 {
|
rlm@1
|
1382 armNextPC -= 4;
|
rlm@1
|
1383 reg[15].I -= 4;
|
rlm@1
|
1384 }
|
rlm@1
|
1385 else
|
rlm@1
|
1386 {
|
rlm@1
|
1387 armNextPC -= 2;
|
rlm@1
|
1388 reg[15].I -= 2;
|
rlm@1
|
1389 }
|
rlm@1
|
1390
|
rlm@1
|
1391 debugger = true;
|
rlm@1
|
1392 }
|
rlm@1
|
1393
|
rlm@1
|
1394 void Window::vOnGDBDisconnect()
|
rlm@1
|
1395 {
|
rlm@1
|
1396 remoteCleanUp();
|
rlm@1
|
1397 debugger = false;
|
rlm@1
|
1398 }
|
rlm@1
|
1399
|
rlm@1
|
1400 void Window::vOnHelpAbout()
|
rlm@1
|
1401 {
|
rlm@1
|
1402 Glib::RefPtr<Xml> poXml;
|
rlm@1
|
1403 poXml = Xml::create(PKGDATADIR "/vba.glade", "AboutDialog");
|
rlm@1
|
1404
|
rlm@1
|
1405 Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("AboutDialog"));
|
rlm@1
|
1406 poDialog->set_transient_for(*this);
|
rlm@1
|
1407
|
rlm@1
|
1408 Gtk::Image oIcon(PKGDATADIR "/vba-64.png");
|
rlm@1
|
1409 oIcon.show();
|
rlm@1
|
1410 Gtk::Container * poIconContainer = dynamic_cast<Gtk::Container *>(poXml->get_widget("AboutIconContainer"));
|
rlm@1
|
1411 poIconContainer->add(oIcon);
|
rlm@1
|
1412
|
rlm@1
|
1413 Gtk::Label * poLabel = dynamic_cast<Gtk::Label *>(poXml->get_widget("VersionLabel"));
|
rlm@1
|
1414 poLabel->set_markup("<b><big>" PACKAGE " " VERSION "</big></b>");
|
rlm@1
|
1415
|
rlm@1
|
1416 poDialog->run();
|
rlm@1
|
1417 delete poDialog;
|
rlm@1
|
1418 }
|
rlm@1
|
1419
|
rlm@1
|
1420 bool Window::bOnEmuIdle()
|
rlm@1
|
1421 {
|
rlm@1
|
1422 if (debugger && m_stEmulator.emuHasDebugger)
|
rlm@1
|
1423 {
|
rlm@1
|
1424 dbgMain();
|
rlm@1
|
1425 return true;
|
rlm@1
|
1426 }
|
rlm@1
|
1427
|
rlm@1
|
1428 if (m_uiThrottleDelay != 0)
|
rlm@1
|
1429 {
|
rlm@1
|
1430 u32 uiTime = SDL_GetTicks();
|
rlm@1
|
1431 if (uiTime - m_uiThrottleLastTime >= m_uiThrottleDelay)
|
rlm@1
|
1432 {
|
rlm@1
|
1433 m_uiThrottleDelay = 0;
|
rlm@1
|
1434 m_uiThrottleLastTime = uiTime;
|
rlm@1
|
1435 }
|
rlm@1
|
1436 else
|
rlm@1
|
1437 {
|
rlm@1
|
1438 return true;
|
rlm@1
|
1439 }
|
rlm@1
|
1440 }
|
rlm@1
|
1441
|
rlm@1
|
1442 m_stEmulator.emuMain(m_stEmulator.emuCount);
|
rlm@1
|
1443 return true;
|
rlm@1
|
1444 }
|
rlm@1
|
1445
|
rlm@1
|
1446 bool Window::on_focus_in_event(GdkEventFocus * _pstEvent)
|
rlm@1
|
1447 {
|
rlm@1
|
1448 if (emulating
|
rlm@1
|
1449 && ! m_bPaused
|
rlm@1
|
1450 && m_poDisplayConfig->oGetKey<bool>("pause_when_inactive"))
|
rlm@1
|
1451 {
|
rlm@1
|
1452 vStartEmu();
|
rlm@1
|
1453 soundResume();
|
rlm@1
|
1454 }
|
rlm@1
|
1455 return false;
|
rlm@1
|
1456 }
|
rlm@1
|
1457
|
rlm@1
|
1458 bool Window::on_focus_out_event(GdkEventFocus * _pstEvent)
|
rlm@1
|
1459 {
|
rlm@1
|
1460 if (emulating
|
rlm@1
|
1461 && ! m_bPaused
|
rlm@1
|
1462 && m_poDisplayConfig->oGetKey<bool>("pause_when_inactive"))
|
rlm@1
|
1463 {
|
rlm@1
|
1464 vStopEmu();
|
rlm@1
|
1465 soundPause();
|
rlm@1
|
1466 }
|
rlm@1
|
1467 return false;
|
rlm@1
|
1468 }
|
rlm@1
|
1469
|
rlm@1
|
1470 bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
rlm@1
|
1471 {
|
rlm@1
|
1472 EKey eKey;
|
rlm@1
|
1473
|
rlm@1
|
1474 if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
rlm@1
|
1475 || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
|
rlm@1
|
1476 {
|
rlm@1
|
1477 return Gtk::Window::on_key_press_event(_pstEvent);
|
rlm@1
|
1478 }
|
rlm@1
|
1479
|
rlm@1
|
1480 switch (eKey)
|
rlm@1
|
1481 {
|
rlm@1
|
1482 case KeyA:
|
rlm@1
|
1483 m_uiJoypadState |= KeyFlagA;
|
rlm@1
|
1484 break;
|
rlm@1
|
1485 case KeyB:
|
rlm@1
|
1486 m_uiJoypadState |= KeyFlagB;
|
rlm@1
|
1487 break;
|
rlm@1
|
1488 case KeySelect:
|
rlm@1
|
1489 m_uiJoypadState |= KeyFlagSelect;
|
rlm@1
|
1490 break;
|
rlm@1
|
1491 case KeyStart:
|
rlm@1
|
1492 m_uiJoypadState |= KeyFlagStart;
|
rlm@1
|
1493 break;
|
rlm@1
|
1494 case KeyRight:
|
rlm@1
|
1495 m_uiJoypadState |= KeyFlagRight;
|
rlm@1
|
1496 m_uiJoypadState &= ~KeyFlagLeft;
|
rlm@1
|
1497 break;
|
rlm@1
|
1498 case KeyLeft:
|
rlm@1
|
1499 m_uiJoypadState |= KeyFlagLeft;
|
rlm@1
|
1500 m_uiJoypadState &= ~KeyFlagRight;
|
rlm@1
|
1501 break;
|
rlm@1
|
1502 case KeyUp:
|
rlm@1
|
1503 m_uiJoypadState |= KeyFlagUp;
|
rlm@1
|
1504 m_uiJoypadState &= ~KeyFlagDown;
|
rlm@1
|
1505 break;
|
rlm@1
|
1506 case KeyDown:
|
rlm@1
|
1507 m_uiJoypadState |= KeyFlagDown;
|
rlm@1
|
1508 m_uiJoypadState &= ~KeyFlagUp;
|
rlm@1
|
1509 break;
|
rlm@1
|
1510 case KeyR:
|
rlm@1
|
1511 m_uiJoypadState |= KeyFlagR;
|
rlm@1
|
1512 break;
|
rlm@1
|
1513 case KeyL:
|
rlm@1
|
1514 m_uiJoypadState |= KeyFlagL;
|
rlm@1
|
1515 break;
|
rlm@1
|
1516 case KeySpeed:
|
rlm@1
|
1517 m_uiJoypadState |= KeyFlagSpeed;
|
rlm@1
|
1518 break;
|
rlm@1
|
1519 case KeyCapture:
|
rlm@1
|
1520 m_uiJoypadState |= KeyFlagCapture;
|
rlm@1
|
1521 break;
|
rlm@1
|
1522 case KeyNone:
|
rlm@1
|
1523 break;
|
rlm@1
|
1524 }
|
rlm@1
|
1525 return true;
|
rlm@1
|
1526 }
|
rlm@1
|
1527
|
rlm@1
|
1528 bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
rlm@1
|
1529 {
|
rlm@1
|
1530 EKey eKey;
|
rlm@1
|
1531
|
rlm@1
|
1532 if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
rlm@1
|
1533 || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone)
|
rlm@1
|
1534 {
|
rlm@1
|
1535 return Gtk::Window::on_key_release_event(_pstEvent);
|
rlm@1
|
1536 }
|
rlm@1
|
1537
|
rlm@1
|
1538 switch (eKey)
|
rlm@1
|
1539 {
|
rlm@1
|
1540 case KeyA:
|
rlm@1
|
1541 m_uiJoypadState &= ~KeyFlagA;
|
rlm@1
|
1542 break;
|
rlm@1
|
1543 case KeyB:
|
rlm@1
|
1544 m_uiJoypadState &= ~KeyFlagB;
|
rlm@1
|
1545 break;
|
rlm@1
|
1546 case KeySelect:
|
rlm@1
|
1547 m_uiJoypadState &= ~KeyFlagSelect;
|
rlm@1
|
1548 break;
|
rlm@1
|
1549 case KeyStart:
|
rlm@1
|
1550 m_uiJoypadState &= ~KeyFlagStart;
|
rlm@1
|
1551 break;
|
rlm@1
|
1552 case KeyRight:
|
rlm@1
|
1553 m_uiJoypadState &= ~KeyFlagRight;
|
rlm@1
|
1554 break;
|
rlm@1
|
1555 case KeyLeft:
|
rlm@1
|
1556 m_uiJoypadState &= ~KeyFlagLeft;
|
rlm@1
|
1557 break;
|
rlm@1
|
1558 case KeyUp:
|
rlm@1
|
1559 m_uiJoypadState &= ~KeyFlagUp;
|
rlm@1
|
1560 break;
|
rlm@1
|
1561 case KeyDown:
|
rlm@1
|
1562 m_uiJoypadState &= ~KeyFlagDown;
|
rlm@1
|
1563 break;
|
rlm@1
|
1564 case KeyR:
|
rlm@1
|
1565 m_uiJoypadState &= ~KeyFlagR;
|
rlm@1
|
1566 break;
|
rlm@1
|
1567 case KeyL:
|
rlm@1
|
1568 m_uiJoypadState &= ~KeyFlagL;
|
rlm@1
|
1569 break;
|
rlm@1
|
1570 case KeySpeed:
|
rlm@1
|
1571 m_uiJoypadState &= ~KeyFlagSpeed;
|
rlm@1
|
1572 break;
|
rlm@1
|
1573 case KeyCapture:
|
rlm@1
|
1574 m_uiJoypadState &= ~KeyFlagCapture;
|
rlm@1
|
1575 break;
|
rlm@1
|
1576 case KeyNone:
|
rlm@1
|
1577 break;
|
rlm@1
|
1578 }
|
rlm@1
|
1579 return true;
|
rlm@1
|
1580 }
|
rlm@1
|
1581
|
rlm@1
|
1582 } // namespace VBA
|