Add (better) support to select card in Slot 0.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2019-04-20 20:51:19 +01:00
parent a51118cf35
commit 224fcbce78
6 changed files with 62 additions and 25 deletions

View file

@ -21,6 +21,9 @@ namespace
const std::vector<size_t> diskIDs = {DRIVE_1, DRIVE_2};
const std::vector<size_t> hdIDs = {HARDDISK_1, HARDDISK_2};
const QString REG_SCREENSHOT_TEMPLATE = QString::fromUtf8("QApple/Screenshot Template");
const QString REG_SLOT0_CARD = QString::fromUtf8("QApple/Slot0");
void insertDisk(const QString & filename, const int disk)
{
if (filename.isEmpty())
@ -55,12 +58,6 @@ namespace
}
}
void setSlot0(const SS_CARDTYPE newCardType)
{
g_Slot0 = newCardType;
REGSAVE(TEXT(REGVALUE_SLOT0), (DWORD)g_Slot0);
}
void setSlot4(const SS_CARDTYPE newCardType)
{
g_Slot4 = newCardType;
@ -93,17 +90,28 @@ namespace
void setScreenshotTemplate(const QString & filenameTemplate)
{
QSettings().setValue("QApple/Screenshot Template", filenameTemplate);
QSettings().setValue(REG_SCREENSHOT_TEMPLATE, filenameTemplate);
}
void setSlot0Card(const int card)
{
QSettings().setValue(REG_SLOT0_CARD, card);
}
}
QString getScreenshotTemplate()
{
const QString filenameTemplate = QSettings().value("QApple/Screenshot Template", "/tmp/qapple_%1.png").toString();
const QString filenameTemplate = QSettings().value(REG_SCREENSHOT_TEMPLATE, "/tmp/qapple_%1.png").toString();
return filenameTemplate;
}
int getSlot0Card()
{
const int slot0Card = QSettings().value(REG_SLOT0_CARD, 0).toInt();
return slot0Card;
}
Preferences::Data getCurrentOptions(const std::shared_ptr<QGamepad> & gamepad)
{
Preferences::Data currentOptions;
@ -129,7 +137,7 @@ Preferences::Data getCurrentOptions(const std::shared_ptr<QGamepad> & gamepad)
}
currentOptions.enhancedSpeed = sg_Disk2Card.GetEnhanceDisk();
currentOptions.languageCardInSlot0 = g_Slot0 == CT_LanguageCard;
currentOptions.cardInSlot0 = getSlot0Card();
currentOptions.mouseInSlot4 = g_Slot4 == CT_MouseInterface;
currentOptions.cpmInSlot5 = g_Slot5 == CT_Z80;
currentOptions.hdInSlot7 = HD_CardIsEnabled();
@ -168,10 +176,9 @@ void setNewOptions(const Preferences::Data & currentOptions, const Preferences::
SetMainCpu(cpu);
REGSAVE(TEXT(REGVALUE_CPU_TYPE), cpu);
}
if (currentOptions.languageCardInSlot0 != newOptions.languageCardInSlot0)
if (currentOptions.cardInSlot0 != newOptions.cardInSlot0)
{
const SS_CARDTYPE card = newOptions.languageCardInSlot0 ? CT_LanguageCard : CT_Empty;
setSlot0(card);
setSlot0Card(newOptions.cardInSlot0);
}
if (currentOptions.mouseInSlot4 != newOptions.mouseInSlot4)
{

View file

@ -8,6 +8,8 @@
class QGamepad;
QString getScreenshotTemplate();
int getSlot0Card();
Preferences::Data getCurrentOptions(const std::shared_ptr<QGamepad> & gamepad);
void setNewOptions(const Preferences::Data & currentOptions, const Preferences::Data & newOptions,
std::shared_ptr<QGamepad> & gamepad);

View file

@ -170,7 +170,7 @@ void Preferences::setData(const Data & data)
enhanced_speed->setChecked(data.enhancedSpeed);
apple2Type->setCurrentIndex(data.apple2Type);
lc_0->setChecked(data.languageCardInSlot0);
lc_0->setCurrentIndex(data.cardInSlot0);
mouse_4->setChecked(data.mouseInSlot4);
cpm_5->setChecked(data.cpmInSlot5);
hd_7->setChecked(data.hdInSlot7);
@ -193,7 +193,7 @@ Preferences::Data Preferences::getData() const
data.enhancedSpeed = enhanced_speed->isChecked();
data.apple2Type = apple2Type->currentIndex();
data.languageCardInSlot0 = lc_0->isChecked();
data.cardInSlot0 = lc_0->currentIndex();
data.mouseInSlot4 = mouse_4->isChecked();
data.cpmInSlot5 = cpm_5->isChecked();
data.hdInSlot7 = hd_7->isChecked();

View file

@ -15,7 +15,7 @@ public:
struct Data
{
int apple2Type;
bool languageCardInSlot0;
int cardInSlot0;
bool mouseInSlot4;
bool cpmInSlot5;
bool hdInSlot7;

View file

@ -82,13 +82,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="lc_0">
<property name="text">
<string>Language Card</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
@ -96,6 +89,30 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="lc_0">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Language Card</string>
</property>
</item>
<item>
<property name="text">
<string>Saturn 64</string>
</property>
</item>
<item>
<property name="text">
<string>Saturn 128</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -9,6 +9,7 @@
#include "CPU.h"
#include "Frame.h"
#include "Memory.h"
#include "LanguageCard.h"
#include "MouseInterface.h"
#include "ParallelPrinter.h"
#include "Video.h"
@ -60,10 +61,20 @@ namespace
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
if (g_Slot0 == CT_LanguageCard)
{
SetExpansionMemType(g_Slot0);
switch (getSlot0Card()) {
case 1: // Language Card
SetExpansionMemType(CT_LanguageCard);
break;
case 2: // Saturn 64
SetSaturnMemorySize(Saturn128K::kMaxSaturnBanks / 2);
SetExpansionMemType(CT_Saturn128K);
break;
case 3: // Saturn 128
SetSaturnMemorySize(Saturn128K::kMaxSaturnBanks);
SetExpansionMemType(CT_Saturn128K);
break;
}
MemInitialize();
VideoInitialize();
sg_Disk2Card.Reset();