From 4873e1f0205379eec4b24ab8e9a3cc7ced3cfbec Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Tue, 26 Sep 2017 18:03:02 +0100 Subject: [PATCH] Add and activate options for slot cards and computer type. Signed-off-by: Andrea Odetti --- source/frontends/qapple/preferences.cpp | 29 ++++- source/frontends/qapple/preferences.h | 15 ++- source/frontends/qapple/preferences.ui | 151 +++++++++++++++++++++--- source/frontends/qapple/qapple.cpp | 70 ++++++++++- 4 files changed, 236 insertions(+), 29 deletions(-) diff --git a/source/frontends/qapple/preferences.cpp b/source/frontends/qapple/preferences.cpp index 812e8dfe..7b846b80 100644 --- a/source/frontends/qapple/preferences.cpp +++ b/source/frontends/qapple/preferences.cpp @@ -90,6 +90,14 @@ void Preferences::setData(const Data & data) { initialiseDisks(myDisks, data.disks); initialiseDisks(myHDs, data.hds); + + apple2Type->setCurrentIndex(data.apple2Type); + mouse_4->setChecked(data.mouseInSlot4); + cpm_5->setChecked(data.cpmInSlot5); + hd_7->setChecked(data.hdInSlot7); + + // synchronise + on_hd_7_clicked(data.hdInSlot7); } Preferences::Data Preferences::getData() const @@ -99,6 +107,11 @@ Preferences::Data Preferences::getData() const fillData(myDisks, data.disks); fillData(myHDs, data.hds); + data.apple2Type = apple2Type->currentIndex(); + data.mouseInSlot4 = mouse_4->isChecked(); + data.cpmInSlot5 = cpm_5->isChecked(); + data.hdInSlot7 = hd_7->isChecked(); + return data; } @@ -145,22 +158,30 @@ void Preferences::on_hd2_activated(int index) checkDuplicates(myHDs, 1, index); } -void Preferences::on_pushButton_clicked() +void Preferences::on_browse_disk1_clicked() { browseDisk(myDisks, 0); } -void Preferences::on_pushButton_2_clicked() +void Preferences::on_browse_disk2_clicked() { browseDisk(myDisks, 1); } -void Preferences::on_pushButton_3_clicked() +void Preferences::on_browse_hd1_clicked() { browseDisk(myHDs, 0); } -void Preferences::on_pushButton_4_clicked() +void Preferences::on_browse_hd2_clicked() { browseDisk(myHDs, 1); } + +void Preferences::on_hd_7_clicked(bool checked) +{ + hd1->setEnabled(checked); + hd2->setEnabled(checked); + browse_hd1->setEnabled(checked); + browse_hd2->setEnabled(checked); +} diff --git a/source/frontends/qapple/preferences.h b/source/frontends/qapple/preferences.h index 2e905fdd..babba898 100644 --- a/source/frontends/qapple/preferences.h +++ b/source/frontends/qapple/preferences.h @@ -13,6 +13,10 @@ public: struct Data { + int apple2Type; + bool mouseInSlot4; + bool cpmInSlot5; + bool hdInSlot7; std::vector disks; std::vector hds; }; @@ -28,13 +32,12 @@ private slots: void on_hd1_activated(int index); void on_hd2_activated(int index); - void on_pushButton_clicked(); + void on_browse_disk1_clicked(); + void on_browse_disk2_clicked(); + void on_browse_hd1_clicked(); + void on_browse_hd2_clicked(); - void on_pushButton_2_clicked(); - - void on_pushButton_3_clicked(); - - void on_pushButton_4_clicked(); + void on_hd_7_clicked(bool checked); private: std::vector myDisks; diff --git a/source/frontends/qapple/preferences.ui b/source/frontends/qapple/preferences.ui index b6076c72..e7341580 100644 --- a/source/frontends/qapple/preferences.ui +++ b/source/frontends/qapple/preferences.ui @@ -7,18 +7,149 @@ 0 0 556 - 300 + 403 Options + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + 0 + + + Hardware + + + + + + Slots + + + + + + Slot 4 + + + + + + + Mouse + + + + + + + Slot 5 + + + + + + + CP/M + + + + + + + Slot 7 + + + + + + + Hard Disk + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Apple ][ (Original) + + + + + Apple ][+ + + + + + Apple //e + + + + + Enhanced Apple //e + + + + + Pravets 82 + + + + + Pravets 8M + + + + + Pravets 8A + + + + + TK3000 //e + + + + + + + + Computer + + + + + + + + Disks @@ -106,28 +237,28 @@ - + Browse... - + Browse... - + Browse... - + Browse... @@ -137,16 +268,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - diff --git a/source/frontends/qapple/qapple.cpp b/source/frontends/qapple/qapple.cpp index c8f2fc72..ce9ffa1c 100644 --- a/source/frontends/qapple/qapple.cpp +++ b/source/frontends/qapple/qapple.cpp @@ -12,6 +12,7 @@ #include "ParallelPrinter.h" #include "Video.h" #include "SaveState.h" +#include "Registry.h" #include "linux/data.h" #include "linux/configuration.h" @@ -41,13 +42,14 @@ namespace DiskInitialize(); } - void startEmulator() + void startEmulator(QWidget * window) { LoadConfiguration(); CheckCpu(); SetWindowTitle(); + window->setWindowTitle(g_pAppTitle); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); @@ -104,6 +106,34 @@ namespace } } + void setSlot4(const SS_CARDTYPE newCardType) + { + g_Slot4 = newCardType; + REGSAVE(TEXT(REGVALUE_SLOT4), (DWORD)g_Slot4); + } + + void setSlot5(const SS_CARDTYPE newCardType) + { + g_Slot5 = newCardType; + REGSAVE(TEXT(REGVALUE_SLOT5), (DWORD)g_Slot5); + } + + const std::vector computerTypes = {A2TYPE_APPLE2, A2TYPE_APPLE2PLUS, A2TYPE_APPLE2E, A2TYPE_APPLE2EENHANCED}; + + int getApple2ComputerType() + { + const eApple2Type type = GetApple2Type(); + const auto it = std::find(computerTypes.begin(), computerTypes.end(), type); + if (it != computerTypes.end()) + { + return std::distance(computerTypes.begin(), it); + } + else + { + // default to A2E + return 2; + } + } } void FrameDrawDiskLEDS(HDC) @@ -141,13 +171,12 @@ QApple::QApple(QWidget *parent) : myEmulator = new Emulator(mdiArea); myEmulatorWindow = mdiArea->addSubWindow(myEmulator, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); - myEmulatorWindow->setWindowTitle(g_pAppTitle); myMSGap = 5; initialiseEmulator(); - startEmulator(); + startEmulator(myEmulatorWindow); } void QApple::closeEvent(QCloseEvent *) @@ -225,7 +254,8 @@ void QApple::on_actionReboot_triggered() { emit endEmulator(); stopEmulator(); - startEmulator(); + startEmulator(myEmulatorWindow); + myEmulatorWindow->setWindowTitle(g_pAppTitle); } void QApple::on_actionBenchmark_triggered() @@ -277,12 +307,44 @@ void QApple::on_actionOptions_triggered() } } + currentOptions.mouseInSlot4 = g_Slot4 == CT_MouseInterface; + currentOptions.cpmInSlot5 = g_Slot5 == CT_Z80; + currentOptions.hdInSlot7 = HD_CardIsEnabled(); + + currentOptions.apple2Type = getApple2ComputerType(); + myPreferences.setData(currentOptions); if (myPreferences.exec()) { const Preferences::Data newOptions = myPreferences.getData(); + if (currentOptions.apple2Type != newOptions.apple2Type) + { + const eApple2Type type = computerTypes[newOptions.apple2Type]; + SetApple2Type(type); + REGSAVE(TEXT(REGVALUE_APPLE2_TYPE), type); + const eCpuType cpu = ProbeMainCpuDefault(type); + SetMainCpu(cpu); + REGSAVE(TEXT(REGVALUE_CPU_TYPE), cpu); + } + + if (currentOptions.mouseInSlot4 != newOptions.mouseInSlot4) + { + const SS_CARDTYPE card = newOptions.mouseInSlot4 ? CT_MouseInterface : CT_Empty; + setSlot4(card); + } + if (currentOptions.cpmInSlot5 != newOptions.cpmInSlot5) + { + const SS_CARDTYPE card = newOptions.cpmInSlot5 ? CT_Z80 : CT_Empty; + setSlot5(card); + } + if (currentOptions.hdInSlot7 != newOptions.hdInSlot7) + { + REGSAVE(TEXT(REGVALUE_HDD_ENABLED), newOptions.hdInSlot7 ? 1 : 0); + HD_SetEnabled(newOptions.hdInSlot7); + } + for (size_t i = 0; i < diskIDs.size(); ++i) { if (currentOptions.disks[i] != newOptions.disks[i])