OSDN Git Service

db1bd638e48d6ec50d6dc2a350ecfea6c3c66790
[csp-qt/common_source_project-fm7.git] / source / src / qt / machines / pc8801 / 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 <QVariant>
11 #include <QtGui>
12 #include <QApplication>
13 #include <QMenu>
14
15 #include "../../../src/vm/vm.h"
16 #include "commonclasses.h"
17 #include "menuclasses.h"
18 #include "emu.h"
19 #include "qt_main.h"
20 #include "sound_dialog.h"
21
22 //QT_BEGIN_NAMESPACE
23
24 extern config_t config;
25
26 Object_Menu_Control_88::Object_Menu_Control_88(QObject *parent, USING_FLAGS *p) : Object_Menu_Control(parent, p)
27 {
28 }
29
30 Object_Menu_Control_88::~Object_Menu_Control_88()
31 {
32 }
33
34
35 void Object_Menu_Control_88::do_set_memory_wait(bool flag)
36 {
37         emit sig_set_dipsw(0, flag);
38 }
39
40
41 Action_Control_88::Action_Control_88(QObject *parent, USING_FLAGS *p) : Action_Control(parent, p)
42 {
43         pc88_binds = new Object_Menu_Control_88(parent, p);
44         pc88_binds->setValue1(0);
45 }
46
47 Action_Control_88::~Action_Control_88()
48 {
49         delete pc88_binds;
50 }
51
52 void META_MainWindow::retranslateVolumeLabels(Ui_SoundDialog *p)
53 {
54         if(p != NULL) {
55                 p->setDeviceLabel(1, QApplication::translate("MenuPC88", "CMT", 0));
56                 switch(config_sound_device_type) {
57                 case 0:
58                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
59                         p->setSliderVisible(2, true);
60                         p->setSliderVisible(3, false);
61                         break;
62                 case 1:
63                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
64                         p->setSliderVisible(2, true);
65                         p->setSliderVisible(3, false);
66                         break;
67 #ifdef SUPPORT_PC88_SB2
68                 case 2:
69                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
70                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA", 0));
71                         p->setSliderVisible(2, true);
72                         p->setSliderVisible(3, true);
73                         break;
74                 case 3:
75                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN-1", 0));
76                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN-2", 0));
77                         p->setSliderVisible(2, true);
78                         p->setSliderVisible(3, true);
79                         break;
80                 case 4:
81                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA-1", 0));
82                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA-2", 0));
83                         p->setSliderVisible(2, true);
84                         p->setSliderVisible(3, true);
85                         break;
86                 case 5:
87                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
88                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN", 0));
89                         p->setSliderVisible(2, true);
90                         p->setSliderVisible(3, true);
91                         break;
92 #endif
93                 }
94                 
95         }
96 }
97
98 void META_MainWindow::retranslateUi(void)
99 {
100         const char *title="";
101         Ui_MainWindowBase::retranslateUi();
102         retranslateControlMenu(title, false);
103         config_sound_device_type = config.sound_type;
104         
105         this->setWindowTitle(QApplication::translate("MenuPC88", "MainWindow", 0));
106         
107         // PC88 Specified
108         menuCpuType->setTitle(QApplication::translate("MenuPC88", "CPU Frequency", 0));
109 #ifdef SUPPORT_PC88_HIGH_CLOCK
110         actionCpuType[0]->setText(QString::fromUtf8("8MHz"));
111         actionCpuType[1]->setText(QString::fromUtf8("4MHz"));
112         actionCpuType[2]->setText(QString::fromUtf8("8MHz (FE2/MC)"));
113 #else // _PC8001SR
114         actionCpuType[0]->setText(QString::fromUtf8("4MHz"));
115 #if defined(USE_CPU_TYPE)
116         for(int i = 1; i < USE_CPU_TYPE; i++) {
117                 actionCpuType[i]->setVisible(false);
118         }
119 #endif
120 //      menuCpuType->setVisible(false);
121 //      actionCpuType[0]->setVisible(false);
122 #endif
123
124         menuBootMode->setTitle(QApplication::translate("MenuPC88", "Machine Mode", 0));
125         menuBootMode->setToolTipsVisible(true);
126 #if defined(_PC8801)
127         actionBootMode[0]->setText(QString::fromUtf8("N88 Mode"));
128         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
129         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N88 Mode.\nYou can run softwares of PC-8801/mk2.", 0));
130         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
131         actionBootMode[1]->setVisible(false);
132         actionBootMode[2]->setVisible(false);
133 #elif defined(_PC8801MK2)
134         actionBootMode[0]->setText(QString::fromUtf8("N88 Mode"));
135         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
136         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N88 Mode.\nYou can run softwares of PC-8801/mk2.", 0));
137         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
138         actionBootMode[1]->setVisible(false);
139         actionBootMode[2]->setVisible(false);
140         
141 #elif defined(_PC8801MA)
142         actionBootMode[0]->setText(QString::fromUtf8("N88-V1(S) Mode"));
143         actionBootMode[1]->setText(QString::fromUtf8("N88-V1(H) Mode"));        
144         actionBootMode[2]->setText(QString::fromUtf8("N88-V2 Mode"));
145         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
146         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "V1(Standard) Mode.\nYou can run softwares of PC-8801/mk2.", 0));
147         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "V1(High Speed) Mode.\nYou can run softwares of PC-8801/mk2 faster.", 0));    
148         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "V2 Mode.\nYou can run only softwares for PC-8801SR or later.", 0));
149         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
150 #elif defined(_PC8001)
151         menuBootMode->setVisible(false);
152         menuBootMode->setToolTipsVisible(false);
153         actionBootMode[0]->setVisible(false);
154         actionBootMode[1]->setVisible(false);
155         actionBootMode[2]->setVisible(false);
156 #elif defined(_PC8001MK2)
157         actionBootMode[0]->setText(QString::fromUtf8("N80     Mode"));
158         actionBootMode[2]->setText(QString::fromUtf8("N Mode"));
159         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N80 Mode.\nYou can run softwares of PC-8001/mk2.", 0));
160         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "N  Mode.\nYou can run only softwares for PC-8001.", 0));
161         actionBootMode[1]->setVisible(false);
162 #elif defined(_PC8001SR)
163         actionBootMode[0]->setText(QString::fromUtf8("N80     Mode"));
164         actionBootMode[1]->setText(QString::fromUtf8("N80-V2(SR) Mode"));       
165         actionBootMode[2]->setText(QString::fromUtf8("N Mode"));
166         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N80 Mode.\nYou can run softwares of PC-8001/mk2.", 0));
167         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "N80 V2 Mode.\nYou can run only softwares for PC-8001mk2SR or later.", 0));
168         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "N  Mode.\nYou can run only softwares for PC-8001.", 0));
169 #endif
170
171 #if defined(SUPPORT_PC88_OPN1) && defined(SUPPORT_PC88_OPN2)
172         #if defined(_PC8001SR)
173                 menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
174                 actionSoundDevice[0]->setText(QString::fromUtf8("OPN"));
175                 actionSoundDevice[1]->setText(QString::fromUtf8("OPNA"));   
176                 actionSoundDevice[2]->setText(QString::fromUtf8("OPN + OPNA"));   
177                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "Using YM2203(OPN) as FM sounder.", 0));
178                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "Using YM2608(OPNA) as FM sounder.", 0));
179                 actionSoundDevice[2]->setToolTip(QApplication::translate("MenuPC88", "Using YM2203(OPN) and YM2608(OPNA) as FM sounder.", 0));
180         #else
181                 menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
182                 actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
183                 actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));   
184                 actionSoundDevice[2]->setText(QString::fromUtf8("Sound Board 2 (OPN + OPNA)"));   
185                 actionSoundDevice[3]->setText(QString::fromUtf8("Sound Board 2(OPN + OPN)"));   
186                 actionSoundDevice[4]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPNA)"));   
187                 actionSoundDevice[5]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPN)"));
188                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
189                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));   
190                 actionSoundDevice[2]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPNA).", 0));   
191                 actionSoundDevice[3]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPN).", 0));   
192                 actionSoundDevice[4]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPNA).", 0));   
193                 actionSoundDevice[5]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPN).", 0));
194         #endif
195 #elif defined(SUPPORT_PC88_OPN1) || defined(SUPPORT_PC88_OPN2)
196         menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
197         #if defined(SUPPORT_OPNA)
198                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));
199                 actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));
200                 actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
201                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
202         #else
203                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));
204                 actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));
205         #endif
206 #endif
207 #ifdef USE_DEBUGGER
208         actionDebugger[0]->setText(QApplication::translate("MenuPC88", "Main CPU", 0));
209 #if defined(_PC8001SR)  
210         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "PC-80S31K CPU", 0));
211 #else
212         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "Sub CPU", 0));
213 #endif  
214         actionDebugger[0]->setVisible(true);
215         actionDebugger[1]->setVisible(true);
216         
217         actionDebugger[2]->setVisible(false);
218         actionDebugger[3]->setVisible(false);
219 #endif  
220 #if defined(USE_JOYSTICK_TYPE)
221         actionJoystickType[0]->setText(QApplication::translate("MenuPC88", "Joystick", 0));
222         actionJoystickType[1]->setText(QApplication::translate("MenuPC88", "Bus Mouse", 0));
223         actionJoystickType[0]->setToolTip(QApplication::translate("MenuPC88", "Connect joystick to JOY PORT.", 0));
224         actionJoystickType[1]->setToolTip(QApplication::translate("MenuPC88", "Connect bus-mouse to JOY PORT.", 0));
225         menuJoystickType->setTitle(QApplication::translate("MenuPC88", "Joy Port", 0));
226 #endif
227 #if defined(USE_PRINTER)
228         actionPrintDevice[1]->setText(QString::fromUtf8("PC-PR201"));
229         actionPrintDevice[1]->setToolTip(QApplication::translate("MenuPC88", "NEC PC-PR201 kanji serial printer.", 0));
230         actionPrintDevice[1]->setEnabled(false);
231 #endif
232         
233         actionMemoryWait->setText(QApplication::translate("MenuPC88", "Wait Memory", 0));
234         actionMemoryWait->setToolTip(QApplication::translate("MenuPC88", "Simulate waiting memory.", 0));
235 #if defined(USE_MONITOR_TYPE)
236         actionMonitorType[0]->setText(QApplication::translate("MenuPC88", "High Resolution", 0));
237         actionMonitorType[1]->setText(QApplication::translate("MenuPC88", "Standard", 0));
238 #endif
239 // End.
240    // Set Labels
241   
242 } // retranslateUi
243
244
245 void META_MainWindow::setupUI_Emu(void)
246 {
247 #if defined(USE_CPU_TYPE)
248         ConfigCPUTypes(USE_CPU_TYPE);
249 #endif
250
251 #if defined(PC8001_VARIANT)
252         ConfigCPUBootMode(3);
253 #else
254         ConfigCPUBootMode(4);
255 #endif
256         actionMemoryWait = new Action_Control_88(this, using_flags);
257         actionMemoryWait->setCheckable(true);
258         actionMemoryWait->setVisible(true);
259         actionMemoryWait->setChecked(false);
260    
261         menuMachine->addAction(actionMemoryWait);
262         if((config.dipswitch & 0x0001) != 0) actionMemoryWait->setChecked(true);
263         connect(actionMemoryWait, SIGNAL(toggled(bool)),
264                         actionMemoryWait->pc88_binds, SLOT(do_set_memory_wait(bool)));
265         connect(actionMemoryWait->pc88_binds, SIGNAL(sig_set_dipsw(int, bool)),
266                         this, SLOT(set_dipsw(int, bool)));
267
268 }
269
270
271 META_MainWindow::META_MainWindow(USING_FLAGS *p, CSP_Logger *logger, QWidget *parent) : Ui_MainWindow(p, logger, parent)
272 {
273         config_sound_device_type = 0;
274         setupUI_Emu();
275         retranslateUi();
276 }
277
278
279 META_MainWindow::~META_MainWindow()
280 {
281 }
282
283 //QT_END_NAMESPACE
284
285
286