OSDN Git Service

[VM][PC8801][PC9801][UI][I8251][UPD765A] Merge upstream 2022-11-14 .
[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 void META_MainWindow::retranslateVolumeLabels(Ui_SoundDialog *p)
25 {
26         if(p != NULL) {
27                 p->setDeviceLabel(1, QApplication::translate("MenuPC88", "CMT", 0));
28                 switch(config_sound_device_type) {
29                 case 0:
30                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
31                         p->setSliderVisible(2, true);
32                         p->setSliderVisible(3, false);
33                         break;
34                 case 1:
35                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
36                         p->setSliderVisible(2, true);
37                         p->setSliderVisible(3, false);
38                         break;
39 #ifdef SUPPORT_PC88_SB2
40                 case 2:
41                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN", 0));
42                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA", 0));
43                         p->setSliderVisible(2, true);
44                         p->setSliderVisible(3, true);
45                         break;
46                 case 3:
47                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPN-1", 0));
48                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN-2", 0));
49                         p->setSliderVisible(2, true);
50                         p->setSliderVisible(3, true);
51                         break;
52                 case 4:
53                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA-1", 0));
54                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPNA-2", 0));
55                         p->setSliderVisible(2, true);
56                         p->setSliderVisible(3, true);
57                         break;
58                 case 5:
59                         p->setDeviceLabel(2, QApplication::translate("MenuPC88", "OPNA", 0));
60                         p->setDeviceLabel(3, QApplication::translate("MenuPC88", "OPN", 0));
61                         p->setSliderVisible(2, true);
62                         p->setSliderVisible(3, true);
63                         break;
64 #endif
65                 }
66
67         }
68 }
69
70 void META_MainWindow::retranslateUi(void)
71 {
72         const char *title="";
73         Ui_MainWindowBase::retranslateUi();
74         retranslateControlMenu(title, false);
75         retranslateOpMenuZ80(true);
76
77         config_sound_device_type = p_config->sound_type;
78
79         this->setWindowTitle(QApplication::translate("MenuPC88", "MainWindow", 0));
80
81         // PC88 Specified
82         menuCpuType->setTitle(QApplication::translate("MenuPC88", "CPU Frequency", 0));
83 #ifdef SUPPORT_PC88_HIGH_CLOCK
84         actionCpuType[0]->setText(QString::fromUtf8("8MHz"));
85         actionCpuType[1]->setText(QString::fromUtf8("4MHz"));
86         actionCpuType[2]->setText(QString::fromUtf8("8MHz (FE2/MC)"));
87 #else // _PC8001SR
88         actionCpuType[0]->setText(QString::fromUtf8("4MHz"));
89 #if defined(USE_CPU_TYPE)
90         for(int i = 1; i < USE_CPU_TYPE; i++) {
91                 actionCpuType[i]->setVisible(false);
92         }
93 #endif
94 //      menuCpuType->setVisible(false);
95 //      actionCpuType[0]->setVisible(false);
96 #endif
97
98         menuBootMode->setTitle(QApplication::translate("MenuPC88", "Machine Mode", 0));
99         menuBootMode->setToolTipsVisible(true);
100 #if defined(_PC8801)
101         actionBootMode[0]->setText(QString::fromUtf8("N88 Mode"));
102         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
103         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N88 Mode.\nYou can run softwares of PC-8801/mk2.", 0));
104         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
105         actionBootMode[1]->setVisible(false);
106         actionBootMode[2]->setVisible(false);
107 #elif defined(_PC8801MK2)
108         actionBootMode[0]->setText(QString::fromUtf8("N88 Mode"));
109         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
110         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N88 Mode.\nYou can run softwares of PC-8801/mk2.", 0));
111         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
112         actionBootMode[1]->setVisible(false);
113         actionBootMode[2]->setVisible(false);
114
115 #elif defined(_PC8801MA)
116         actionBootMode[0]->setText(QString::fromUtf8("N88-V1(S) Mode"));
117         actionBootMode[1]->setText(QString::fromUtf8("N88-V1(H) Mode"));
118         actionBootMode[2]->setText(QString::fromUtf8("N88-V2 Mode"));
119         actionBootMode[3]->setText(QString::fromUtf8("N Mode (N80 compatible)"));
120         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "V1(Standard) Mode.\nYou can run softwares of PC-8801/mk2.", 0));
121         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "V1(High Speed) Mode.\nYou can run softwares of PC-8801/mk2 faster.", 0));
122         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "V2 Mode.\nYou can run only softwares for PC-8801SR or later.", 0));
123         actionBootMode[3]->setToolTip(QApplication::translate("MenuPC88", "N Mode.\nYou can run softwares of PC-8001/mk2.", 0));
124 #elif defined(_PC8001)
125         menuBootMode->setVisible(false);
126         menuBootMode->setToolTipsVisible(false);
127         actionBootMode[0]->setVisible(false);
128         actionBootMode[1]->setVisible(false);
129         actionBootMode[2]->setVisible(false);
130 #elif defined(_PC8001MK2)
131         actionBootMode[0]->setText(QString::fromUtf8("N80     Mode"));
132         actionBootMode[2]->setText(QString::fromUtf8("N Mode"));
133         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N80 Mode.\nYou can run softwares of PC-8001/mk2.", 0));
134         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "N  Mode.\nYou can run only softwares for PC-8001.", 0));
135         actionBootMode[1]->setVisible(false);
136 #elif defined(_PC8001SR)
137         actionBootMode[0]->setText(QString::fromUtf8("N80     Mode"));
138         actionBootMode[1]->setText(QString::fromUtf8("N80-V2(SR) Mode"));
139         actionBootMode[2]->setText(QString::fromUtf8("N Mode"));
140         actionBootMode[0]->setToolTip(QApplication::translate("MenuPC88", "N80 Mode.\nYou can run softwares of PC-8001/mk2.", 0));
141         actionBootMode[1]->setToolTip(QApplication::translate("MenuPC88", "N80 V2 Mode.\nYou can run only softwares for PC-8001mk2SR or later.", 0));
142         actionBootMode[2]->setToolTip(QApplication::translate("MenuPC88", "N  Mode.\nYou can run only softwares for PC-8001.", 0));
143 #endif
144
145 #if defined(SUPPORT_PC88_OPN1) && defined(SUPPORT_PC88_OPN2)
146         #if defined(_PC8001SR)
147                 menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
148                 actionSoundDevice[0]->setText(QString::fromUtf8("OPN"));
149                 actionSoundDevice[1]->setText(QString::fromUtf8("OPN + OPN"));
150                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "Using YM2203(OPN) as FM sounder.", 0));
151                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "Using Twin YM2203(OPN) as FM sounder.", 0));
152         #else
153                 menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
154                 actionSoundDevice[0]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
155                 actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));
156                 actionSoundDevice[2]->setText(QString::fromUtf8("Sound Board 2 (OPN + OPNA)"));
157                 actionSoundDevice[3]->setText(QString::fromUtf8("Sound Board 2(OPN + OPN)"));
158                 actionSoundDevice[4]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPNA)"));
159                 actionSoundDevice[5]->setText(QString::fromUtf8("Sound Board 2 (OPNA + OPN)"));
160                 actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
161                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));
162                 actionSoundDevice[2]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPNA).", 0));
163                 actionSoundDevice[3]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPN + OPN).", 0));
164                 actionSoundDevice[4]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPNA).", 0));
165                 actionSoundDevice[5]->setToolTip(QApplication::translate("MenuPC88", "Sound Board 2 (OPNA + OPN).", 0));
166         #endif
167 #elif defined(SUPPORT_PC88_OPN1) || defined(SUPPORT_PC88_OPN2)
168         menuSoundDevice->setTitle(QApplication::translate("MenuPC88", "Sound Board", 0));
169
170         actionSoundDevice[0]->setText(QString::fromUtf8("None"));
171         actionSoundDevice[0]->setToolTip(QApplication::translate("MenuPC88", "None.", 0));
172         #if defined(SUPPORT_OPNA)
173                 actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-23 (OPNA)"));
174                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-23 (OPNA).", 0));
175         #else
176                 actionSoundDevice[1]->setText(QString::fromUtf8("PC-8801-11 (OPN)"));
177                 actionSoundDevice[1]->setToolTip(QApplication::translate("MenuPC88", "PC-8801-11 (OPN).", 0));
178         #endif
179 #endif
180 #ifdef USE_DEBUGGER
181         actionDebugger[0]->setText(QApplication::translate("MenuPC88", "Main CPU", 0));
182 #if defined(_PC8001SR)
183         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "PC-80S31K CPU", 0));
184 #else
185         actionDebugger[1]->setText(QApplication::translate("MenuPC88", "Sub CPU", 0));
186 #endif
187         actionDebugger[0]->setVisible(true);
188         actionDebugger[1]->setVisible(true);
189 #if defined(SUPPORT_PC88_16BIT)
190         actionDebugger[2]->setText(QApplication::translate("MenuPC88", "PC-8801-16", 0));
191         actionDebugger[2]->setVisible(true);
192 #else
193         actionDebugger[2]->setVisible(false);
194 #endif
195         actionDebugger[3]->setVisible(false);
196 #endif
197 #if defined(USE_JOYSTICK_TYPE)
198         actionJoystickType[0]->setText(QApplication::translate("MenuPC88", "Joystick", 0));
199         actionJoystickType[1]->setText(QApplication::translate("MenuPC88", "Bus Mouse", 0));
200         actionJoystickType[0]->setToolTip(QApplication::translate("MenuPC88", "Connect joystick to JOY PORT.", 0));
201         actionJoystickType[1]->setToolTip(QApplication::translate("MenuPC88", "Connect bus-mouse to JOY PORT.", 0));
202         menuJoystickType->setTitle(QApplication::translate("MenuPC88", "Joy Port", 0));
203 #endif
204 #if defined(USE_PRINTER)
205         actionPrintDevice[1]->setText(QString::fromUtf8("PC-PR201"));
206         actionPrintDevice[1]->setToolTip(QApplication::translate("MenuPC88", "NEC PC-PR201 kanji serial printer.", 0));
207         actionPrintDevice[1]->setEnabled(false);
208
209         #if defined(SUPPORT_PC88_JAST)
210         actionPrintDevice[2]->setText(QString::fromUtf8("JAST SOUND"));
211         actionPrintDevice[2]->setToolTip(QApplication::translate("MenuPC88", "Use JAST SOUND : PCM sound unit.", 0));
212         actionPrintDevice[2]->setEnabled(true);
213         #endif
214 #endif
215
216
217 #if defined(_PC8001SR) || defined(PC8801SR_VARIANT)
218         actionMemoryWait->setText(QApplication::translate("MenuPC88", "Wait Memory", 0));
219         actionMemoryWait->setToolTip(QApplication::translate("MenuPC88", "Simulate waiting memory.", 0));
220 #endif
221
222 #if defined(SUPPORT_QUASIS88_CMT)
223         actionQuasiS88CMT->setText(QApplication::translate("MenuPC88", "Enable QUASIS88 CMT", 0));
224         actionQuasiS88CMT->setToolTip(QApplication::translate("MenuPC88", "Enable loading QuasiS88 style CMT images.", 0));
225 #endif
226 #if defined(PC8801_VARIANT)
227         actionCMD_Sing->setText(QApplication::translate("MenuPC88", "Support CMD SING", 0));
228         actionCMD_Sing->setToolTip(QApplication::translate("MenuPC88", "Enable PCM supporting for \"CMD SING\" command.", 0));
229 #endif
230         actionPalette->setText(QApplication::translate("MenuPC88", "Change palette only within VBLANK.", 0));
231         actionPalette->setToolTip(QApplication::translate("MenuPC88", "Ignore Palette Changed Outside VBLANK.", 0));
232
233         actionFDD_5Inch->setText(QApplication::translate("MenuPC88", "5.25Inch FDD(Need to restart)", 0));
234         actionFDD_5Inch->setToolTip(QApplication::translate("MenuPC88", "Enable 5.25 inch FDDs.\nThis effects only after restarting this emulator.", 0));
235 #if defined(SUPPORT_PC88_FDD_8INCH)
236         actionFDD_8Inch->setText(QApplication::translate("MenuPC88", "8Inch FDD(Need to restart)", 0));
237         actionFDD_8Inch->setToolTip(QApplication::translate("MenuPC88", "Enable 8 inch FDDs for 3: and 4:.\nThis effects only after restarting this emulator.", 0));
238 #endif
239 #if defined(SUPPORT_PC88_16BIT)
240         action16bit->setText(QApplication::translate("MenuPC88", "PC-8801-16(Need to restart)", 0));
241         action16bit->setToolTip(QApplication::translate("MenuPC88", "Enable PC-8801-16 16bit extra CPU card.\nThis effects only after restarting this emulator.", 0));
242 #endif
243 #if defined(SUPPORT_M88_DISKDRV)
244         actionM88DRV->setText(QApplication::translate("MenuPC88", "M88 DiskDrv(Need to restart)", 0));
245         actionM88DRV->setToolTip(QApplication::translate("MenuPC88", "Enable M88 stile Disk Drives.\nThis effects only after restarting this emulator.", 0));
246 #endif
247
248 #if defined(SUPPORT_PC88_HMB20)
249         actionHMB20->setText(QApplication::translate("MenuPC88", "Use HMB20(Need RESTART)", 0));
250         actionHMB20->setToolTip(QApplication::translate("MenuPC88", "Using HMB20 OPM sound board.\nRe-start emulator when changed.", 0));
251 #endif
252
253 #if defined(SUPPORT_PC88_GSX8800)
254         actionGSX8800->setText(QApplication::translate("MenuPC88", "Use GSX8800(Need RESTART)", 0));
255         actionGSX8800->setToolTip(QApplication::translate("MenuPC88", "Using GSX8800 PSGs sound board.\nRe-start emulator when changed.", 0));
256 #endif
257 #if defined(SUPPORT_PC88_PCG8100)
258         actionPCG8100->setText(QApplication::translate("MenuPC88", "Use PCG8100(Need RESTART)", 0));
259         actionPCG8100->setToolTip(QApplication::translate("MenuPC88", "Using PCG8100 programmable character generator board.\nRe-start emulator when changed.", 0));
260 #endif
261
262
263 #if defined(USE_MONITOR_TYPE)
264         actionMonitorType[0]->setText(QApplication::translate("MenuPC88", "High Resolution", 0));
265         actionMonitorType[1]->setText(QApplication::translate("MenuPC88", "Standard", 0));
266 #endif
267 // End.
268    // Set Labels
269
270 } // retranslateUi
271
272
273 void META_MainWindow::setupUI_Emu(void)
274 {
275 #if defined(USE_CPU_TYPE)
276         ConfigCPUTypes(USE_CPU_TYPE);
277 #endif
278
279 #if defined(PC8001_VARIANT)
280         ConfigCPUBootMode(3);
281 #else
282         ConfigCPUBootMode(4);
283 #endif
284
285 #if defined(_PC8001SR) || defined(PC8801SR_VARIANT)
286         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionMemoryWait, DIPSWITCH_MEMWAIT, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
287         menuMachine->addAction(actionMemoryWait);
288 #endif
289         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionPalette, DIPSWITCH_PALETTE, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
290
291         menuMachine->addAction(actionPalette);
292         menuMachine->addSeparator();
293 #if defined(SUPPORT_PC88_16BIT)
294         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(action16bit, DIPSWITCH_16BIT, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
295         menuMachine->addAction(action16bit);
296         menuMachine->addSeparator();
297 #endif
298 #if defined(SUPPORT_M88_DISKDRV)
299         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionM88DRV, DIPSWITCH_M88_DISKDRV, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
300         menuMachine->addAction(actionM88DRV);
301 #endif
302 #if defined(SUPPORT_QUASIS88_CMT)
303         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionQuasiS88CMT, DIPSWITCH_QUASIS88_CMT, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
304         menuMachine->addAction(actionQuasiS88CMT);
305 #endif
306 #if defined(SUPPORT_QUASIS88_CMT) || defined(SUPPORT_M88_DISKDRV)
307         menuMachine->addSeparator();
308 #endif
309
310 #if defined(PC8801_VARIANT)
311         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionCMD_Sing, DIPSWITCH_CMDSING, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
312         menuMachine->addAction(actionCMD_Sing);
313         menuMachine->addSeparator();
314 #endif
315         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionFDD_5Inch, DIPSWITCH_FDD_5INCH, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
316         menuMachine->addAction(actionFDD_5Inch);
317
318 #if defined(SUPPORT_PC88_FDD_8INCH)
319         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionFDD_8Inch, DIPSWITCH_FDD_8INCH, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
320         menuMachine->addAction(actionFDD_8Inch);
321 #endif
322         menuMachine->addSeparator();
323 #ifdef SUPPORT_PC88_HMB20
324         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionHMB20, DIPSWITCH_HMB20, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
325         menuMachine->addAction(actionHMB20);
326
327 #endif
328 #ifdef SUPPORT_PC88_GSX8800
329         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionGSX8800, DIPSWITCH_GSX8800, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
330         menuMachine->addAction(actionGSX8800);
331 #endif
332 #ifdef SUPPORT_PC88_PCG8100
333         SET_ACTION_SINGLE_DIPSWITCH_CONNECT(actionPCG8100, DIPSWITCH_PCG8100, p_config->dipswitch, SIGNAL(toggled(bool)), SLOT(do_set_single_dipswitch(bool)));
334         menuMachine->addAction(actionPCG8100);
335 #endif
336 }
337
338
339 META_MainWindow::META_MainWindow(std::shared_ptr<USING_FLAGS> p, std::shared_ptr<CSP_Logger> logger, QWidget *parent) : Ui_MainWindow(p, logger, parent)
340 {
341         config_sound_device_type = 0;
342         setupUI_Emu();
343         retranslateUi();
344 }
345
346
347 META_MainWindow::~META_MainWindow()
348 {
349 }
350
351 //QT_END_NAMESPACE