Add few more options to the setting window.

Apple 2 Type and Slots.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-03-28 20:05:30 +01:00
parent 90cc5732f9
commit f44428352c
3 changed files with 135 additions and 39 deletions

View file

@ -206,51 +206,82 @@ namespace sa2
if (ImGui::BeginTabItem("Hardware"))
{
if (ImGui::BeginTable("Cards", 2, ImGuiTableFlags_RowBg))
ImGui::LabelText("Option", "Value");
const eApple2Type a2e = GetApple2Type();
const std::map<eApple2Type, std::string> & apple2Types = getAapple2Types();
if (ImGui::BeginCombo("Apple 2", getApple2Name(a2e).c_str()))
{
CardManager & manager = GetCardMgr();
ImGui::TableSetupColumn("Slot");
ImGui::TableSetupColumn("Card");
ImGui::TableHeadersRow();
for (size_t slot = 0; slot < 8; ++slot)
for (const auto & it : apple2Types)
{
ImGui::TableNextColumn();
ImGui::Selectable(std::to_string(slot).c_str());
ImGui::TableNextColumn();
const SS_CARDTYPE card = manager.QuerySlot(slot);;
ImGui::Selectable(getCardName(card).c_str());
const bool isSelected = it.first == a2e;
if (ImGui::Selectable(getApple2Name(it.first).c_str(), isSelected))
{
SetApple2Type(it.first);
REGSAVE(REGVALUE_APPLE2_TYPE, it.first);
}
if (isSelected)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::TableNextColumn();
ImGui::Selectable("AUX");
ImGui::TableNextColumn();
const SS_CARDTYPE card = manager.QueryAux();
ImGui::Selectable(getCardName(card).c_str());
ImGui::EndTable();
ImGui::EndCombo();
}
// is there a better way?
std::string cpuName = getCPUName(GetMainCpu());
ImGui::InputText("CPU", cpuName.data(), cpuName.size(), ImGuiInputTextFlags_ReadOnly);
std::string modeName = getModeName(g_nAppMode);
ImGui::InputText("Mode", modeName.data(), modeName.size(), ImGuiInputTextFlags_ReadOnly);
ImGui::Separator();
if (ImGui::BeginTable("Type", 2, ImGuiTableFlags_RowBg))
ImGui::LabelText("Slot", "Card");
CardManager & manager = GetCardMgr();
for (size_t slot = 1; slot < 8; ++slot)
{
ImGui::TableNextColumn();
ImGui::Selectable("Apple 2");
ImGui::TableNextColumn();
const eApple2Type a2e = GetApple2Type();
ImGui::Selectable(getApple2Name(a2e).c_str());
const SS_CARDTYPE current = manager.QuerySlot(slot);;
if (ImGui::BeginCombo(std::to_string(slot).c_str(), getCardName(current).c_str()))
{
const std::vector<SS_CARDTYPE> & cards = getCardsForSlot(slot);
for (SS_CARDTYPE card : cards)
{
const bool isSelected = card == current;
if (ImGui::Selectable(getCardName(card).c_str(), isSelected))
{
insertCard(slot, card);
}
if (isSelected)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
}
ImGui::TableNextColumn();
ImGui::Selectable("CPU");
ImGui::TableNextColumn();
const eCpuType cpu = GetMainCpu();
ImGui::Selectable(getCPUName(cpu).c_str());
ImGui::Separator();
ImGui::TableNextColumn();
ImGui::Selectable("Mode");
ImGui::TableNextColumn();
ImGui::Selectable(getModeName(g_nAppMode).c_str());
ImGui::EndTable();
{
// Expansion
const SS_CARDTYPE expansion = GetCurrentExpansionMemType();
if (ImGui::BeginCombo("Expansion", getCardName(expansion).c_str()))
{
const std::vector<SS_CARDTYPE> & cards = getExpansionCards();
for (SS_CARDTYPE card : cards)
{
const bool isSelected = card == expansion;
if (ImGui::Selectable(getCardName(card).c_str(), isSelected))
{
SetExpansionMemType(card);
}
if (isSelected)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
}
ImGui::EndTabItem();
@ -278,7 +309,7 @@ namespace sa2
ImGui::PushID(slot);
if (cardManager.QuerySlot(slot) == CT_Disk2)
{
Disk2InterfaceCard * card2 = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(SLOT6));
Disk2InterfaceCard * card2 = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(slot));
const int currentDrive = card2->GetCurrentDrive();
Disk_Status_e statuses[NUM_DRIVES] = {};

View file

@ -1,4 +1,9 @@
#include "StdAfx.h"
#include "CardManager.h"
#include "Registry.h"
#include "Harddisk.h"
#include "Core.h"
#include "frontends/sdl/imgui/settingshelper.h"
namespace
@ -26,7 +31,7 @@ namespace
{CT_Saturn128K, "CT_Saturn128K"},
};
const std::map<eApple2Type, std::string> apple2types =
const std::map<eApple2Type, std::string> apple2Types =
{
{A2TYPE_APPLE2, "A2TYPE_APPLE2"},
{A2TYPE_APPLE2PLUS, "A2TYPE_APPLE2PLUS"},
@ -56,6 +61,21 @@ namespace
{MODE_STEPPING, "MODE_STEPPING"},
{MODE_BENCHMARK, "MODE_BENCHMARCK"},
};
const std::map<size_t, std::vector<SS_CARDTYPE>> cardsForSlots =
{
{0, {CT_Empty, CT_LanguageCard, CT_Saturn128K}},
{1, {CT_Empty, CT_GenericPrinter}},
{2, {CT_Empty, CT_SSC}},
{3, {CT_Empty, CT_Uthernet}},
{4, {CT_Empty, CT_MockingboardC, CT_MouseInterface, CT_Phasor}},
{5, {CT_Empty, CT_MockingboardC, CT_Z80, CT_SAM, CT_Disk2}},
{6, {CT_Empty, CT_Disk2}},
{7, {CT_Empty, CT_GenericHDD}},
};
const std::vector<SS_CARDTYPE> expansionCards =
{CT_Empty, CT_LanguageCard, CT_Extended80Col, CT_Saturn128K, CT_RamWorksIII};
}
namespace sa2
@ -68,7 +88,7 @@ namespace sa2
const std::string & getApple2Name(eApple2Type type)
{
return apple2types.at(type);
return apple2Types.at(type);
}
const std::string & getCPUName(eCpuType cpu)
@ -81,4 +101,42 @@ namespace sa2
return modes.at(mode);
}
const std::vector<SS_CARDTYPE> & getCardsForSlot(size_t slot)
{
return cardsForSlots.at(slot);
}
const std::vector<SS_CARDTYPE> & getExpansionCards()
{
return expansionCards;
}
const std::map<eApple2Type, std::string> & getAapple2Types()
{
return apple2Types;
}
void insertCard(size_t slot, SS_CARDTYPE card)
{
CardManager & cardManager = GetCardMgr();
switch (slot)
{
case 7:
{
const bool enabled = card == CT_GenericHDD;
REGSAVE(REGVALUE_HDD_ENABLED, enabled);
HD_SetEnabled(enabled);
}
default:
{
// we do not use REGVALUE_SLOT5 as they are not "runtime friendly"
const std::string label = "Slot " + std::to_string(slot);
REGSAVE(label.c_str(), (DWORD)card);
cardManager.Insert(slot, card);
break;
}
};
}
}

View file

@ -5,6 +5,8 @@
#include "Common.h"
#include <string>
#include <vector>
#include <map>
namespace sa2
{
@ -14,4 +16,9 @@ namespace sa2
const std::string & getCPUName(eCpuType cpu);
const std::string & getModeName(AppMode_e mode);
const std::vector<SS_CARDTYPE> & getCardsForSlot(size_t slot);
const std::vector<SS_CARDTYPE> & getExpansionCards();
const std::map<eApple2Type, std::string> & getAapple2Types();
void insertCard(size_t slot, SS_CARDTYPE card);
}