2021-02-07 19:23:28 +00:00
|
|
|
#include "StdAfx.h"
|
2021-03-28 20:05:30 +01:00
|
|
|
#include "CardManager.h"
|
|
|
|
#include "Registry.h"
|
|
|
|
#include "Harddisk.h"
|
|
|
|
#include "Core.h"
|
2021-05-16 18:48:18 +01:00
|
|
|
#include "Debugger/Debug.h"
|
2021-03-28 20:05:30 +01:00
|
|
|
|
2021-05-05 15:56:10 +01:00
|
|
|
#include "Tfe/tfe.h"
|
2021-02-07 19:23:28 +00:00
|
|
|
#include "frontends/sdl/imgui/settingshelper.h"
|
|
|
|
|
2021-05-16 18:48:18 +01:00
|
|
|
#include "frontends/sdl/imgui/gles.h"
|
|
|
|
#include "imgui_internal.h"
|
|
|
|
|
|
|
|
|
2021-02-07 19:23:28 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
const std::map<SS_CARDTYPE, std::string> cards =
|
|
|
|
{
|
|
|
|
{CT_Empty, "CT_Empty"},
|
|
|
|
{CT_Disk2, "CT_Disk2"},
|
|
|
|
{CT_SSC, "CT_SSC"},
|
|
|
|
{CT_MockingboardC, "CT_MockingboardC"},
|
|
|
|
{CT_GenericPrinter, "CT_GenericPrinter"},
|
|
|
|
{CT_GenericHDD, "CT_GenericHDD"},
|
|
|
|
{CT_GenericClock, "CT_GenericClock"},
|
|
|
|
{CT_MouseInterface, "CT_MouseInterface"},
|
|
|
|
{CT_Z80, "CT_Z80"},
|
|
|
|
{CT_Phasor, "CT_Phasor"},
|
|
|
|
{CT_Echo, "CT_Echo"},
|
|
|
|
{CT_SAM, "CT_SAM"},
|
|
|
|
{CT_80Col, "CT_80Col"},
|
|
|
|
{CT_Extended80Col, "CT_Extended80Col"},
|
|
|
|
{CT_RamWorksIII, "CT_RamWorksIII"},
|
|
|
|
{CT_Uthernet, "CT_Uthernet"},
|
|
|
|
{CT_LanguageCard, "CT_LanguageCard"},
|
|
|
|
{CT_LanguageCardIIe, "CT_LanguageCardIIe"},
|
|
|
|
{CT_Saturn128K, "CT_Saturn128K"},
|
|
|
|
};
|
|
|
|
|
2021-03-28 20:05:30 +01:00
|
|
|
const std::map<eApple2Type, std::string> apple2Types =
|
2021-02-07 19:23:28 +00:00
|
|
|
{
|
|
|
|
{A2TYPE_APPLE2, "A2TYPE_APPLE2"},
|
|
|
|
{A2TYPE_APPLE2PLUS, "A2TYPE_APPLE2PLUS"},
|
|
|
|
{A2TYPE_APPLE2JPLUS, "A2TYPE_APPLE2JPLUS"},
|
|
|
|
{A2TYPE_APPLE2E, "A2TYPE_APPLE2E"},
|
|
|
|
{A2TYPE_APPLE2EENHANCED, "A2TYPE_APPLE2EENHANCED"},
|
|
|
|
{A2TYPE_PRAVETS8M, "A2TYPE_PRAVETS8M"},
|
|
|
|
{A2TYPE_PRAVETS82, "A2TYPE_PRAVETS82"},
|
|
|
|
{A2TYPE_BASE64A, "A2TYPE_BASE64A"},
|
|
|
|
{A2TYPE_PRAVETS8A, "A2TYPE_PRAVETS8A"},
|
|
|
|
{A2TYPE_TK30002E, "A2TYPE_TK30002E"},
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::map<eCpuType, std::string> cpuTypes =
|
|
|
|
{
|
|
|
|
{CPU_6502, "CPU_6502"},
|
|
|
|
{CPU_65C02, "CPU_65C02"},
|
|
|
|
{CPU_Z80, "CPU_Z80"},
|
|
|
|
};
|
2021-03-06 18:00:31 +00:00
|
|
|
|
2021-04-03 09:46:56 +01:00
|
|
|
const std::map<AppMode_e, std::string> appModes =
|
2021-03-06 18:00:31 +00:00
|
|
|
{
|
|
|
|
{MODE_LOGO, "MODE_LOGO"},
|
|
|
|
{MODE_PAUSED, "MODE_PAUSED"},
|
|
|
|
{MODE_RUNNING, "MODE_RUNNING"},
|
|
|
|
{MODE_DEBUG, "MODE_DEBUG"},
|
|
|
|
{MODE_STEPPING, "MODE_STEPPING"},
|
|
|
|
{MODE_BENCHMARK, "MODE_BENCHMARCK"},
|
|
|
|
};
|
2021-03-28 20:05:30 +01:00
|
|
|
|
2021-04-03 08:47:29 +01:00
|
|
|
const std::map<Disk_Status_e, std::string> statuses =
|
|
|
|
{
|
|
|
|
{DISK_STATUS_OFF, "OFF"},
|
|
|
|
{DISK_STATUS_READ, "READ"},
|
|
|
|
{DISK_STATUS_WRITE, "WRITE"},
|
|
|
|
{DISK_STATUS_PROT, "PROT"},
|
|
|
|
};
|
|
|
|
|
2021-04-03 09:46:56 +01:00
|
|
|
const std::map<VideoType_e, std::string> videoTypes =
|
|
|
|
{
|
|
|
|
{VT_MONO_CUSTOM, "Monochrome (Custom)"},
|
|
|
|
{VT_COLOR_IDEALIZED, "Color (Composite Idealized)"},
|
|
|
|
{VT_COLOR_VIDEOCARD_RGB, "Color (RGB Card/Monitor)"},
|
|
|
|
{VT_COLOR_MONITOR_NTSC, "Color (Composite Monitor)"},
|
|
|
|
{VT_COLOR_TV, "Color TV"},
|
|
|
|
{VT_MONO_TV, "B&W TV"},
|
|
|
|
{VT_MONO_AMBER, "Monochrome (Amber)"},
|
|
|
|
{VT_MONO_GREEN, "Monochrome (Green)"},
|
|
|
|
{VT_MONO_WHITE, "Monochrome (White)"},
|
|
|
|
};
|
|
|
|
|
2021-03-28 20:05:30 +01:00
|
|
|
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};
|
2021-02-07 19:23:28 +00:00
|
|
|
}
|
|
|
|
|
2021-02-25 16:31:24 +00:00
|
|
|
namespace sa2
|
2021-02-07 19:23:28 +00:00
|
|
|
{
|
|
|
|
|
2021-02-25 16:31:24 +00:00
|
|
|
const std::string & getCardName(SS_CARDTYPE card)
|
|
|
|
{
|
|
|
|
return cards.at(card);
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & getApple2Name(eApple2Type type)
|
|
|
|
{
|
2021-03-28 20:05:30 +01:00
|
|
|
return apple2Types.at(type);
|
2021-02-25 16:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & getCPUName(eCpuType cpu)
|
|
|
|
{
|
|
|
|
return cpuTypes.at(cpu);
|
|
|
|
}
|
2021-02-07 19:23:28 +00:00
|
|
|
|
2021-04-03 09:46:56 +01:00
|
|
|
const std::string & getAppModeName(AppMode_e mode)
|
|
|
|
{
|
|
|
|
return appModes.at(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & getVideoTypeName(VideoType_e type)
|
2021-03-06 18:00:31 +00:00
|
|
|
{
|
2021-04-03 09:46:56 +01:00
|
|
|
return videoTypes.at(type);
|
2021-03-06 18:00:31 +00:00
|
|
|
}
|
|
|
|
|
2021-03-28 20:05:30 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-04-03 08:47:29 +01:00
|
|
|
const std::string & getDiskStatusName(Disk_Status_e status)
|
|
|
|
{
|
|
|
|
return statuses.at(status);
|
|
|
|
}
|
|
|
|
|
2021-03-28 20:05:30 +01:00
|
|
|
void insertCard(size_t slot, SS_CARDTYPE card)
|
|
|
|
{
|
|
|
|
CardManager & cardManager = GetCardMgr();
|
|
|
|
|
|
|
|
switch (slot)
|
|
|
|
{
|
2021-04-18 19:01:05 +01:00
|
|
|
case 3:
|
|
|
|
{
|
2021-05-05 15:56:10 +01:00
|
|
|
const int enabled = card == CT_Uthernet ? 1 : 0;
|
2021-04-18 19:01:05 +01:00
|
|
|
REGSAVE(REGVALUE_UTHERNET_ACTIVE, enabled);
|
|
|
|
// needs a reboot anyway
|
|
|
|
break;
|
|
|
|
}
|
2021-03-28 20:05:30 +01:00
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
const bool enabled = card == CT_GenericHDD;
|
|
|
|
REGSAVE(REGVALUE_HDD_ENABLED, enabled);
|
|
|
|
HD_SetEnabled(enabled);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2021-04-18 19:01:05 +01:00
|
|
|
|
|
|
|
// 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);
|
2021-03-28 20:05:30 +01:00
|
|
|
}
|
|
|
|
|
2021-04-03 09:46:56 +01:00
|
|
|
void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled)
|
|
|
|
{
|
|
|
|
VideoStyle_e currentVideoStyle = video.GetVideoStyle();
|
|
|
|
if (enabled)
|
|
|
|
{
|
|
|
|
currentVideoStyle = VideoStyle_e(currentVideoStyle | style);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentVideoStyle = VideoStyle_e(currentVideoStyle & (~style));
|
|
|
|
}
|
|
|
|
video.SetVideoStyle(currentVideoStyle);
|
|
|
|
}
|
|
|
|
|
2021-05-05 15:56:10 +01:00
|
|
|
void saveTFEEnabled(const int enabled)
|
|
|
|
{
|
|
|
|
tfe_enabled = enabled;
|
|
|
|
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE), tfe_enabled);
|
|
|
|
}
|
|
|
|
|
2021-05-16 18:48:18 +01:00
|
|
|
void changeBreakpoint(const DWORD nAddress, const bool enableAndSet)
|
|
|
|
{
|
|
|
|
// see _BWZ_RemoveOne
|
|
|
|
for (Breakpoint_t & bp : g_aBreakpoints)
|
|
|
|
{
|
|
|
|
if (bp.bSet && bp.nLength && (nAddress >= bp.nAddress) && (nAddress < bp.nAddress + bp.nLength))
|
|
|
|
{
|
|
|
|
bp.bSet = enableAndSet;
|
|
|
|
bp.bEnabled = enableAndSet;
|
|
|
|
if (!enableAndSet)
|
|
|
|
{
|
|
|
|
bp.nLength = 0;
|
|
|
|
--g_nBreakpoints;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ImGui
|
|
|
|
{
|
|
|
|
|
|
|
|
bool CheckBoxTristate(const char* label, int* v_tristate)
|
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
if (*v_tristate == -1)
|
|
|
|
{
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_MixedValue, true);
|
|
|
|
bool b = false;
|
|
|
|
ret = ImGui::Checkbox(label, &b);
|
|
|
|
if (ret)
|
|
|
|
*v_tristate = 1;
|
|
|
|
ImGui::PopItemFlag();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool b = (*v_tristate != 0);
|
|
|
|
ret = ImGui::Checkbox(label, &b);
|
|
|
|
if (ret)
|
|
|
|
*v_tristate = (int)b;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushStyleCompact()
|
|
|
|
{
|
|
|
|
ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.60f)));
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.60f)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopStyleCompact()
|
|
|
|
{
|
|
|
|
ImGui::PopStyleVar(2);
|
|
|
|
}
|
|
|
|
|
2021-02-07 19:23:28 +00:00
|
|
|
}
|