OSDN Git Service

[General][VM][FM7][CMake] Build at least eFM77AV40EX.
[csp-qt/common_source_project-fm7.git] / source / src / qt / machines / fm7 / MainWindow.cpp
1 /*
2  * Common Source code Project:
3  * Ui->Qt->MainWindow for X1TurboZ .
4  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  *   License : GPLv2
6  *   History :
7  * Jan 14, 2015 : Initial, many of constructors were moved to qt/gui/menu_main.cpp.
8  */
9
10 #include <QtCore/QVariant>
11 #include <QtGui>
12 #include "commonclasses.h"
13 #include "menuclasses.h"
14 #include "emu.h"
15 #include "qt_main.h"
16 #include "sound_dialog.h"
17
18 #include "../../vm/fm7/fm7_common.h"
19
20 //QT_BEGIN_NAMESPACE
21
22
23 Object_Menu_Control_7::Object_Menu_Control_7(QObject *parent) : Object_Menu_Control(parent)
24 {
25 }
26
27 Object_Menu_Control_7::~Object_Menu_Control_7()
28 {
29 }
30
31 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
32 void Object_Menu_Control_7::do_set_kanji_rom(bool flag)
33 {
34         if(flag) {
35                 config.dipswitch = config.dipswitch | FM7_DIPSW_CONNECT_KANJIROM;
36         } else {
37                 config.dipswitch = config.dipswitch & ~FM7_DIPSW_CONNECT_KANJIROM;
38         }
39 }
40 #endif
41
42 #if defined(_FM8)
43 void Object_Menu_Control_7::do_set_protect_ram(bool flag)
44 {
45         if(flag) {
46                 config.dipswitch = config.dipswitch | FM7_DIPSW_FM8_PROTECT_FD0F;
47         } else {
48                 config.dipswitch = config.dipswitch & ~FM7_DIPSW_FM8_PROTECT_FD0F;
49         }
50         emit sig_emu_update_config();
51 }
52 #else
53 void Object_Menu_Control_7::do_set_cyclesteal(bool flag)
54 {
55         if(flag) {
56                 config.dipswitch = config.dipswitch | FM7_DIPSW_CYCLESTEAL;
57         } else {
58                 config.dipswitch = config.dipswitch & ~FM7_DIPSW_CYCLESTEAL;
59         }
60         emit sig_emu_update_config();
61 }
62 #endif
63
64 #if defined(_FM77AV_VARIANTS)
65 void Object_Menu_Control_7::do_set_hsync(bool flag)
66 {
67         if(flag) {
68                 config.dipswitch = config.dipswitch | FM7_DIPSW_SYNC_TO_HSYNC;
69         } else {
70                 config.dipswitch = config.dipswitch & ~FM7_DIPSW_SYNC_TO_HSYNC;
71         }
72 }
73 #endif
74
75 void Action_Control_7::do_set_frameskip()
76 {
77         config.dipswitch &= 0xcfffffff;
78         config.dipswitch |= ((fm7_binds->getValue1() & 3) << 28);
79 }
80
81 Action_Control_7::Action_Control_7(QObject *parent) : Action_Control(parent)
82 {
83         fm7_binds = new Object_Menu_Control_7(parent);
84         fm7_binds->setValue1(0);
85 }
86
87 Action_Control_7::~Action_Control_7()
88 {
89         delete fm7_binds;
90 }
91
92
93
94 void META_MainWindow::do_set_extram(bool flag)
95 {
96 # if defined(_FM77AV40) || defined(_FM77AV40SX) || defined(_FM77AV40EX) || defined(_FM77AV20) || defined(_FM77_VARIANTS)
97         if(flag) {      
98                 config.dipswitch |= FM7_DIPSW_EXTRAM;
99         } else {
100                 config.dipswitch &= ~FM7_DIPSW_EXTRAM;
101         }
102 #else
103 # if defined(_FM77AV_VARIANTS)
104         if(flag) {      
105                 config.dipswitch |= FM7_DIPSW_EXTRAM_AV;
106         } else {
107                 config.dipswitch &= ~FM7_DIPSW_EXTRAM_AV;
108         }
109 # endif
110 #endif
111 }
112
113 void META_MainWindow::retranslateVolumeLabels(Ui_SoundDialog *p)
114 {
115 }
116
117 void META_MainWindow::retranslateUi(void)
118 {
119         
120         retranslateControlMenu("HOT START", true);
121         retranslateFloppyMenu(0, 0);
122         retranslateFloppyMenu(1, 1);
123         retranslateCMTMenu();
124         retranslateSoundMenu();
125         retranslateScreenMenu();
126         retranslateMachineMenu();
127         retranslateEmulatorMenu();
128         retranslateUI_Help();
129         
130         this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
131         
132         actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
133 #if defined(USE_PRINTER_TYPE)
134         actionPrintDevice[1]->setText(QApplication::translate("MainWindow", "Dempa Joystick with #1", 0));
135         actionPrintDevice[2]->setText(QApplication::translate("MainWindow", "Dempa Joystick with #2", 0));
136 #endif
137 #ifdef USE_DEBUGGER
138         actionDebugger_1->setText(QApplication::translate("MainWindow", "Debug Main CPU", 0));
139         actionDebugger_2->setText(QApplication::translate("MainWindow", "Debug Sub  CPU", 0));
140         actionDebugger_3->setVisible(false);
141 #endif  
142         //      actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Record Movie", 0));
143         //      actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Record Movie", 0));
144         // 
145         menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0));
146         // FM-7 Specified
147
148         menuFrameSkip->setTitle(QApplication::translate("MainWindow", "Frame skip", 0));
149         actionFrameSkip[0]->setText(QApplication::translate("MainWindow", "None", 0));
150         actionFrameSkip[1]->setText(QApplication::translate("MainWindow", "1 Frame", 0));
151         actionFrameSkip[2]->setText(QApplication::translate("MainWindow", "2 Frames", 0));
152         actionFrameSkip[3]->setText(QApplication::translate("MainWindow", "3 Frames", 0));
153 #if defined(_FM77AV_VARIANTS)
154         actionSyncToHsync->setText(QApplication::translate("MainWindow", "Sync to HSYNC", 0));
155 #endif  
156         menuCpuType->setTitle(QApplication::translate("MainWindow", "CPU Frequency", 0));
157         actionCpuType[0]->setText(QString::fromUtf8("2MHz"));
158         actionCpuType[1]->setText(QString::fromUtf8("1.2MHz"));
159         
160         menuBootMode->setTitle("BOOT Mode");
161         actionBootMode[0]->setText(QString::fromUtf8("BASIC"));
162         actionBootMode[1]->setText(QString::fromUtf8("DOS"));   
163 #if defined(_FM77_VARIANTS)
164         actionBootMode[2]->setVisible(true);
165         actionBootMode[2]->setText(QString::fromUtf8("MMR"));
166 #elif defined(_FM8)
167         actionBootMode[2]->setText(QApplication::translate("MainWindow", "Bubble Casette", 0));
168         actionBootMode[3]->setText(QApplication::translate("MainWindow", "8Inch FD", 0));
169         
170         actionBootMode[2]->setVisible(true);
171         actionBootMode[3]->setVisible(true);
172 #elif defined(_FM7) || defined(_FMNEW7) 
173         actionBootMode[2]->setVisible(false);
174 #endif
175
176 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
177         actionKanjiRom->setText(QApplication::translate("MainWindow", "Kanji ROM(Need restart)", 0));
178 #endif  
179 #if defined(_FM8)
180         actionRamProtect->setText(QString::fromUtf8("BANK PROTECT($FD0F/hack)"));
181 #elif defined(_FM7) || defined(_FMNEW7) 
182         actionCycleSteal->setText(QString::fromUtf8("Cycle Steal(hack)"));
183 #else                                                     
184         actionCycleSteal->setText(QString::fromUtf8("Cycle Steal"));
185 #endif                                                    
186         menuSoundDevice->setTitle(QApplication::translate("MainWindow", "Sound Boards", 0));
187 #if defined(USE_SOUND_DEVICE_TYPE)
188 # if defined(_FM8)
189         actionSoundDevice[0]->setVisible(true);
190         actionSoundDevice[1]->setVisible(true);
191         actionSoundDevice[0]->setText(QString::fromUtf8("Beep Only"));
192         actionSoundDevice[1]->setText(QString::fromUtf8("PSG (hack)"));
193 # elif defined(_FM77AV_VARIANTS)
194         actionSoundDevice[0]->setVisible(false);
195         actionSoundDevice[2]->setVisible(false);
196         actionSoundDevice[4]->setVisible(false);
197         actionSoundDevice[6]->setVisible(false);
198         actionSoundDevice[1]->setText(QString::fromUtf8("OPN"));
199         actionSoundDevice[3]->setText(QString::fromUtf8("OPN+WHG"));
200         actionSoundDevice[5]->setText(QString::fromUtf8("OPN+THG"));
201         actionSoundDevice[7]->setText(QString::fromUtf8("OPN+WHG+THG"));
202 # else
203         actionSoundDevice[0]->setText(QString::fromUtf8("PSG"));
204         actionSoundDevice[1]->setText(QString::fromUtf8("PSG+OPN"));
205         actionSoundDevice[2]->setText(QString::fromUtf8("PSG+WHG"));
206         actionSoundDevice[3]->setText(QString::fromUtf8("PSG+OPN+WHG"));
207         actionSoundDevice[4]->setText(QString::fromUtf8("PSG+THG"));
208         actionSoundDevice[5]->setText(QString::fromUtf8("PSG+OPN+THG"));
209         actionSoundDevice[6]->setText(QString::fromUtf8("PSG+WHG+THG"));
210         actionSoundDevice[7]->setText(QString::fromUtf8("PSG+OPN+WHG+THG"));
211 # endif
212 #endif
213 #if !defined(_FM8)
214 # if defined(USE_DEVICE_TYPE)
215         menuDeviceType->setTitle(QApplication::translate("MainWindow", "Mouse", 0));
216         actionDeviceType[0]->setText(QApplication::translate("MainWindow", "none", 0));
217         actionDeviceType[1]->setText(QApplication::translate("MainWindow", "JS port1", 0));
218         actionDeviceType[2]->setText(QApplication::translate("MainWindow", "JS port2", 0));
219 # endif 
220 # if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
221         actionExtRam->setText(QString::fromUtf8("Use Extra RAM (Need reboot)"));
222 # endif
223 #endif                                                    
224         menuEmulator->setTitle(QApplication::translate("MainWindow", "Emulator", 0));
225         menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0));
226         
227         // Set Labels
228   
229 } // retranslateUi
230
231 void META_MainWindow::setupUI_Emu(void)
232 {
233         int i;
234         uint32_t skip;
235         menuFrameSkip = new QMenu(menuMachine);
236         menuFrameSkip->setObjectName(QString::fromUtf8("menuControl_FrameSkip"));
237         actionGroup_FrameSkip = new QActionGroup(this);
238         actionGroup_FrameSkip->setExclusive(true);
239         skip = (config.dipswitch >> 28) & 3;
240         for(i = 0; i < 4; i++) {
241                 actionFrameSkip[i] = new Action_Control_7(this);
242                 actionFrameSkip[i]->setCheckable(true);
243                 actionFrameSkip[i]->setVisible(true);
244                 actionFrameSkip[i]->fm7_binds->setValue1(i);
245                 actionGroup_FrameSkip->addAction(actionFrameSkip[i]);
246                 menuFrameSkip->addAction(actionFrameSkip[i]);
247                 if(i == skip) actionFrameSkip[i]->setChecked(true);
248                 connect(actionFrameSkip[i], SIGNAL(triggered()), actionFrameSkip[i], SLOT(do_set_frameskip()));
249         }
250         menuMachine->addAction(menuFrameSkip->menuAction());
251         
252         menuCpuType = new QMenu(menuMachine);
253         menuCpuType->setObjectName(QString::fromUtf8("menuControl_CpuType"));
254         menuMachine->addAction(menuCpuType->menuAction());
255         ConfigCPUTypes(2);
256         menuBootMode = new QMenu(menuMachine);
257         menuBootMode->setObjectName(QString::fromUtf8("menuControl_BootMode"));
258         menuMachine->addAction(menuBootMode->menuAction());
259
260 #if defined(_FM8)
261         ConfigCPUBootMode(4);
262 #elif defined(_FM77AV_VARIANTS)
263         ConfigCPUBootMode(2);
264 #else
265         ConfigCPUBootMode(3);
266 #endif
267 #if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
268         actionKanjiRom = new Action_Control_7(this);
269         menuMachine->addAction(actionKanjiRom);
270         actionKanjiRom->setCheckable(true);
271         actionKanjiRom->setVisible(true);
272         if((config.dipswitch & FM7_DIPSW_CONNECT_KANJIROM) != 0) actionKanjiRom->setChecked(true);
273         connect(actionKanjiRom, SIGNAL(toggled(bool)),
274                  actionKanjiRom->fm7_binds, SLOT(do_set_kanji_rom(bool)));
275 #endif
276
277 #if defined(_FM8)
278         actionRamProtect = new Action_Control_7(this);
279         menuMachine->addAction(actionRamProtect);
280         actionRamProtect->setCheckable(true);
281         actionRamProtect->setVisible(true);
282         if((config.dipswitch & FM7_DIPSW_FM8_PROTECT_FD0F) != 0) actionRamProtect->setChecked(true);
283         connect(actionRamProtect, SIGNAL(toggled(bool)),
284                         actionRamProtect->fm7_binds, SLOT(do_set_protect_ram(bool)));
285         connect(actionRamProtect->fm7_binds, SIGNAL(sig_emu_update_config()),
286                         this, SLOT(do_emu_update_config()));
287 #else   
288         actionCycleSteal = new Action_Control_7(this);
289         menuMachine->addAction(actionCycleSteal);
290         actionCycleSteal->setCheckable(true);
291         actionCycleSteal->setVisible(true);
292         if((config.dipswitch & FM7_DIPSW_CYCLESTEAL) != 0) actionCycleSteal->setChecked(true);
293         connect(actionCycleSteal, SIGNAL(toggled(bool)),
294                  actionCycleSteal->fm7_binds, SLOT(do_set_cyclesteal(bool)));
295         connect(actionCycleSteal->fm7_binds, SIGNAL(sig_emu_update_config()),
296                         this, SLOT(do_emu_update_config()));
297 #endif  
298 #if defined(_FM77AV_VARIANTS)   
299         actionSyncToHsync = new Action_Control_7(this); 
300         menuMachine->addAction(actionSyncToHsync);
301         actionSyncToHsync->setCheckable(true);
302         actionSyncToHsync->setVisible(true);
303         if((config.dipswitch & FM7_DIPSW_SYNC_TO_HSYNC) != 0) actionSyncToHsync->setChecked(true);
304         connect(actionSyncToHsync, SIGNAL(toggled(bool)),
305                         actionSyncToHsync->fm7_binds, SLOT(do_set_hsync(bool)));
306 #endif
307 #if defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
308         actionExtRam = new Action_Control_7(this);
309         menuMachine->addAction(actionExtRam);
310         actionExtRam->setCheckable(true);
311         actionExtRam->setVisible(true);
312 # if defined(_FM77AV40) || defined(_FM77AV40SX) || defined(_FM77AV40EX) || defined(_FM77_VARIANTS)
313         if((config.dipswitch & FM7_DIPSW_EXTRAM) != 0) actionExtRam->setChecked(true);
314 # elif defined(_FM77AV_VARIANTS)
315         if((config.dipswitch & FM7_DIPSW_EXTRAM_AV) != 0) actionExtRam->setChecked(true);
316 # endif   
317         connect(actionExtRam, SIGNAL(toggled(bool)),
318                         this, SLOT(do_set_extram(bool)));
319 #endif
320 }
321
322
323 META_MainWindow::META_MainWindow(QWidget *parent) : Ui_MainWindow(parent)
324 {
325         setupUI_Emu();
326         retranslateUi();
327 }
328
329
330 META_MainWindow::~META_MainWindow()
331 {
332 }
333
334 //QT_END_NAMESPACE
335
336
337