#include "qt_emuevents.h"
+#include "qt_main.h"
+#include "qt_dialogs.h"
+#include "agar_logger.h"
extern EMU *emu;
-// Will move to other file.
-#if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || defined(USE_FD5) || defined(USE_FD6) || defined(USE_FD7) || defined(USE_FD8)
-void OpenRecentFloppy(QWidget *parent, int drv, int num)
+void Ui_MainWindow::OnReset(void)
{
- std::string path;
- int i;
- if((num < 0) || (num > 7)) return;
-
- path = config.recent_disk_path[drv][num];
- for(int i = num; i > 0; i--) {
- strcpy(config.recent_disk_path[drv][i], config.recent_disk_path[drv][i - 1]);
- }
- strcpy(config.recent_disk_path[drv][0], path.c_str());
- if(emu) {
- open_disk(drv, path, 0);
- }
+ AGAR_DebugLog(AGAR_LOG_INFO, "Reset");
+ emit sig_vm_reset();
}
-void OnCloseFD(int drive)
+void Ui_MainWindow::OnSpecialReset(void)
{
- if(emu) close_disk(drive);
-}
-// Use Dialog
-void OnOpenFD(QWidget *parent,int drive)
-{
- open_disk_dialog(parent, drive);
-}
-
-void OnSelectD88Bank(int drive, int no)
-{
- if((no < 0) || (no > 63)) return;
- if(emu && emu->d88_file[drive].cur_bank != no) {
- //DeleteD88List(drive);
- emu->open_disk(drive, emu->d88_file[drive].path, emu->d88_file[drive].bank[no].offset);
- emu->d88_file[drive].cur_bank = no;
- //BuildD88List(drive);
- }
-}
-
-void Floppy_SelectD88(int drive, int num)
-{
- OnSelectD88Bank(event);
- // AGAR_DebugLog(AGAR_LOG_DEBUG, "Selected D88 %d, %d\n", drive, num);
-}
-
-
+#ifdef USE_SPECIAL_RESET
+ AGAR_DebugLog(AGAR_LOG_INFO, "Special Reset");
+ emit sig_vm_specialreset();
#endif
-
-#ifdef USE_DIPSWITCH
-void OnToggleDipSw(int dipsw)
-{
- if((dipsw < 0) || (dipsw > 31)) return;
- config.dipswitch ^= (1 << dipsw);
}
-void OnChangeDipSw(int dipsw, int flag)
-{
-
- if((dipsw < 0) || (dipsw > 31)) return;
- if(flag == 0) {
- config.dipswitch &= ~(1 << dipsw);
- } else {
- config.dipswitch |= (1 << dipsw);
- }
-}
-#endif
-#ifdef USE_DEVICE_TYPE
-void OnSetDeviceType(int devtype)
-{
- if((devtype < 0) || (devtype > 7)) return;
- config.device_type = devtype;
-}
-#endif
-#if defined(USE_CART1) || defined(USE_CART2)
-void OnOpenCart(QWidget *parent, int drive)
+#ifdef USE_STATE
+void Ui_MainWindow::OnLoadState(void) // Final entry of load state.
{
- if(emu) open_cart_dialog(parent, drive);
+ emit sig_vm_loadstate();
}
-void OnCloseCart(int drive)
+void Ui_MainWindow::OnSaveState(void)
{
- if(emu) emu->close_cart(drive);
+ emit sig_vm_savestate();
}
-
-void OnRecentCart(int drive, int menunum)
-{
- std::string path;
- int i;
- if(drive < 0) return;
-#if !defined(USE_CART2)
- if(drive > 0) return;
-#else
- if(drive > 1) return;
#endif
- if((menunum < 0) || (menunum > 7)) return;
-
- path = config.recent_cart_path[drv][menunum];
- for(int i = menunum; i > 0; i--) {
- strcpy(config.recent_cart_path[drive][i], config.recent_cart_path[drive][i - 1]);
- }
- strcpy(config.recent_cart_path[drive][0], path.c_str());
- if(emu) {
- emu->open_cart(drive, path.c_str());
- }
-}
+#ifdef USE_BOOT_MODE
#endif
-
-#if defined(USE_QD1) || defined(USE_QD2)
-void OnOpenQD(QWidget *parent, int drive)
-{
- if(emu) open_quickdisk_dialog(AGWIDGET(hWindow), drive);
-}
-
-void OnCloseQD(int drive)
-{
- if(emu) emu->close_quickdisk(drive);
-}
-
-void OnRecentQD(int drive, int menunum)
-{
- std::string path;
- int i;
-
- if((menunum < 0) || (menunum > 7)) return;
- path = config.recent_quickdisk_path[drive][menunum];
-
- for(int i = menunum; i > 0; i--) {
- strcpy(config.recent_quickdisk_path[drive][i], config.recent_quickdisk_path[drive][i - 1]);
- }
- strcpy(config.recent_quickdisk_path[drive][0], path.c_str());
- if(emu) {
- emu->open_quickdisk(drive, path.c_str());
- }
-}
+#ifdef USE_CPU_TYPE
#endif
-#ifdef USE_TAPE
-void OnPlayTAPE(QWidget *parent)
-{
- if(emu) open_tape_dialog(parent, true);
-}
-
-void OnRecTAPE(QWidget *parent)
-{
- if(emu) open_tape_dialog(parent, false);
-}
-
-void OnCloseTAPE(void)
-{
- if(emu) emu->close_tape();
-}
-void OnUseWaveShaperTAPE(QWidget *wid)
+void Ui_MainWindow::OnCpuPower(int mode)
{
- config.wave_shaper = !config.wave_shaper;
- if(wid != NULL) {}
+ config.cpu_power = mode;
+ emit sig_emu_update_config();
}
-void OnDirectLoadMZT(QWidget *wid)
+#ifdef USE_AUTO_KEY
+#include <QClipboard>
+void Ui_MainWindow::OnStartAutoKey(void)
{
- config.direct_load_mzt = !config.direct_load_mzt;
- if(wid != NULL) {}
+ QString ctext;
+ QClipboard *clipBoard = QApplication::clipboard();
+ ctext = clipBoard->text();
+ emit sig_start_auto_key(ctext);
}
-void OnRecentTAPE(int menunum)
+void Ui_MainWindow::OnStopAutoKey(void)
{
- std::string path;
- int i;
-
- if((menunum < 0) || (menunum > 7)) return;
- path = config.recent_tape_path[menunum];
- for(int i = menunum; i > 0; i--) {
- strcpy(config.recent_tape_path[i], config.recent_tape_path[i - 1]);
- }
- strcpy(config.recent_tape_path[0], path.c_str());
- if(emu) {
- emu->play_tape(path.c_str());
- }
+ emit sig_stop_auto_key();
}
#endif
-#ifdef USE_TAPE_BUTTON
-void OnPushPlayButton(QWidget *parent)
-{
- if(emu) emu->push_play();
-}
-void OnPushStopButton(QWidget *parent)
-{
- if(emu) emu->push_stop();
+#ifdef USE_DEBUGGER
+#include <../debugger/qt_debugger.h>
+
+void Ui_MainWindow::OnOpenDebugger(int no)
+{
+ if((no < 0) || (no > 3)) return;
+ //emu->open_debugger(no);
+ VM *vm = emu->get_vm();
+
+ if(emu->now_debugging) this->OnCloseDebugger();
+ if(!(emu->now_debugging && emu->debugger_thread_param.cpu_index == no)) {
+ //emu->close_debugger();
+ if(vm->get_cpu(no) != NULL && vm->get_cpu(no)->get_debugger() != NULL) {
+
+ emu->hDebugger = new CSP_Debugger(this);
+ QString objNameStr = QString("EmuDebugThread");
+ emu->hDebugger->setObjectName(objNameStr);
+ emu->hDebugger->debugger_thread_param.osd = emu->get_osd();
+ emu->hDebugger->debugger_thread_param.vm = vm;
+ emu->hDebugger->debugger_thread_param.cpu_index = no;
+ emu->stop_rec_sound();
+ emu->stop_rec_video();
+ emu->now_debugging = true;
+ connect(this, SIGNAL(quit_debugger_thread()), emu->hDebugger, SLOT(doExit()));
+ //connect(this, SIGNAL(quit_debugger_thread()), emu->hDebugger, SLOT(close()));
+ connect(emu->hDebugger, SIGNAL(sig_finished()), this, SLOT(OnCloseDebugger()));
+ connect(emu->hDebugger, SIGNAL(sig_put_string(QString)), emu->hDebugger, SLOT(put_string(QString)));
+ emu->hDebugger->show();
+ emu->hDebugger->run();
+ }
+ }
+}
+
+void Ui_MainWindow::OnCloseDebugger(void )
+{
+
+// emu->close_debugger();
+ if(emu->now_debugging) {
+ if(emu->hDebugger->debugger_thread_param.running) {
+ emit quit_debugger_thread();
+ //emu->hDebugger->wait();
+ }
+ delete emu->hDebugger;
+ emu->hDebugger = NULL;
+ emu->now_debugging = false;
+ }
}
#endif
+
// Implement LASER-DISC, BINARY
//
void OnStartRecordScreen(int num)
{
-
- const int fps[3] = {60, 30, 15};
- if((num < 0) || (num > 2)) return;
- if(emu) {
- emu->start_rec_sound();
- if(!emu->start_rec_video(fps[num])) {
- emu->stop_rec_sound();
- }
- }
+ const int fps[3] = {60, 30, 15};
+ if((num < 0) || (num > 2)) return;
+ if(emu) {
+ //emit sig_emu_start_rec_screen();
+ emu->start_rec_sound();
+ if(!emu->start_rec_video(fps[num])) {
+ emu->stop_rec_sound();
+ }
+ }
}
void OnStopRecordScreen(void)
{
- if(emu) {
- emu->stop_rec_video();
- emu->stop_rec_sound();
- }
+ if(emu) {
+ //emit sig_emu_stop_rec_screen();
+ emu->stop_rec_video();
+ emu->stop_rec_sound();
+ }
}
void OnScreenCapture(QWidget *parent)
{
- if(emu) emu->capture_screen();
-}
-
-void OnSetScreenMode(QMainWindow *MainWindow, QWidget *drawspace, int mode)
-{
- if((mode < 0) || (mode > 7)) return;
- if(emu){
- set_window(MainWindow, drawspace, mode);
- }
+ if(emu) emu->capture_screen();
}
void OnFullScreen(QMainWindow *MainWindow, QWidget *drawspace, int mode)
{
}
-void OnSetStretchMode(int mode)
-{
- if((mode < 0) || (mode > 2)) return;
- // 0 = DOT
- // 1 = ASPECT
- // 2 = FILL
- config.stretch_type = mode;
- // On Common Sourcecode Project / Agar,
- // Scaling is done by Agar Widget.
- // So, does need below action?
- // Maybe, needs Agar's changing action.
- if(emu) {
- emu->set_display_size(-1, -1, false);
- }
-}
-