Create Slot enum class for EXI slots
This commit is contained in:
parent
fefde0481d
commit
3f0b23ed2b
|
@ -10,11 +10,13 @@
|
|||
#include "AudioCommon/AudioCommon.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/EnumMap.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Core/Config/DefaultLocale.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/HW/SI/SI_Device.h"
|
||||
|
@ -62,14 +64,16 @@ const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_B{{System::Main, "Core",
|
|||
const Info<ExpansionInterface::EXIDeviceType> MAIN_SERIAL_PORT_1{
|
||||
{System::Main, "Core", "SerialPort1"}, ExpansionInterface::EXIDeviceType::None};
|
||||
|
||||
const Info<ExpansionInterface::EXIDeviceType>& GetInfoForEXIDevice(int channel)
|
||||
const Info<ExpansionInterface::EXIDeviceType>& GetInfoForEXIDevice(ExpansionInterface::Slot slot)
|
||||
{
|
||||
static constexpr std::array<const Info<ExpansionInterface::EXIDeviceType>*, 3> infos{
|
||||
static constexpr Common::EnumMap<const Info<ExpansionInterface::EXIDeviceType>*,
|
||||
ExpansionInterface::MAX_SLOT>
|
||||
infos{
|
||||
&MAIN_SLOT_A,
|
||||
&MAIN_SLOT_B,
|
||||
&MAIN_SERIAL_PORT_1,
|
||||
};
|
||||
return *infos[channel];
|
||||
return *infos[slot];
|
||||
}
|
||||
|
||||
const Info<std::string> MAIN_BBA_MAC{{System::Main, "Core", "BBA_MAC"}, ""};
|
||||
|
|
|
@ -34,7 +34,8 @@ enum class DPL2Quality;
|
|||
namespace ExpansionInterface
|
||||
{
|
||||
enum class EXIDeviceType : int;
|
||||
}
|
||||
enum class Slot : int;
|
||||
} // namespace ExpansionInterface
|
||||
|
||||
namespace SerialInterface
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ extern const Info<std::string> MAIN_GCI_FOLDER_B_PATH_OVERRIDE;
|
|||
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_A;
|
||||
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_B;
|
||||
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SERIAL_PORT_1;
|
||||
const Info<ExpansionInterface::EXIDeviceType>& GetInfoForEXIDevice(int channel);
|
||||
const Info<ExpansionInterface::EXIDeviceType>& GetInfoForEXIDevice(ExpansionInterface::Slot slot);
|
||||
extern const Info<std::string> MAIN_BBA_MAC;
|
||||
extern const Info<std::string> MAIN_BBA_XLINK_IP;
|
||||
extern const Info<bool> MAIN_BBA_XLINK_CHAT_OSD;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/Config/SessionSettings.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
namespace ConfigLoaders
|
||||
|
@ -37,9 +38,8 @@ public:
|
|||
layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE);
|
||||
layer->Set(Config::MAIN_OVERCLOCK_ENABLE, m_settings.m_OCEnable);
|
||||
layer->Set(Config::MAIN_OVERCLOCK, m_settings.m_OCFactor);
|
||||
layer->Set(Config::MAIN_SLOT_A, m_settings.m_EXIDevice[0]);
|
||||
layer->Set(Config::MAIN_SLOT_B, m_settings.m_EXIDevice[1]);
|
||||
layer->Set(Config::MAIN_SERIAL_PORT_1, m_settings.m_EXIDevice[2]);
|
||||
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
||||
layer->Set(Config::GetInfoForEXIDevice(slot), m_settings.m_EXIDevice[slot]);
|
||||
layer->Set(Config::SESSION_SAVE_DATA_WRITABLE, m_settings.m_WriteToMemcard);
|
||||
layer->Set(Config::MAIN_RAM_OVERRIDE_ENABLE, m_settings.m_RAMOverrideEnable);
|
||||
layer->Set(Config::MAIN_MEM1_SIZE, m_settings.m_Mem1Size);
|
||||
|
|
|
@ -46,7 +46,8 @@ void AddMemoryCards(int i)
|
|||
{
|
||||
if (Movie::IsUsingMemcard(i))
|
||||
{
|
||||
if (Config::Get(Config::GetInfoForEXIDevice(i)) == EXIDeviceType::MemoryCardFolder)
|
||||
if (Config::Get(Config::GetInfoForEXIDevice(static_cast<Slot>(i))) ==
|
||||
EXIDeviceType::MemoryCardFolder)
|
||||
memorycard_device = EXIDeviceType::MemoryCardFolder;
|
||||
else
|
||||
memorycard_device = EXIDeviceType::MemoryCard;
|
||||
|
@ -58,13 +59,45 @@ void AddMemoryCards(int i)
|
|||
}
|
||||
else
|
||||
{
|
||||
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(i));
|
||||
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(static_cast<Slot>(i)));
|
||||
}
|
||||
|
||||
g_Channels[i]->AddDevice(memorycard_device, 0);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
u8 SlotToEXIChannel(Slot slot)
|
||||
{
|
||||
switch (slot)
|
||||
{
|
||||
case Slot::A:
|
||||
return 0;
|
||||
case Slot::B:
|
||||
return 1;
|
||||
case Slot::SP1:
|
||||
return 0;
|
||||
default:
|
||||
PanicAlertFmt("Unhandled slot {}", slot);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
u8 SlotToEXIDevice(Slot slot)
|
||||
{
|
||||
switch (slot)
|
||||
{
|
||||
case Slot::A:
|
||||
return 0;
|
||||
case Slot::B:
|
||||
return 0;
|
||||
case Slot::SP1:
|
||||
return 2;
|
||||
default:
|
||||
PanicAlertFmt("Unhandled slot {}", slot);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
if (!g_SRAM_netplay_initialized)
|
||||
|
@ -98,11 +131,12 @@ void Init()
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_MEMORYCARD_SLOTS; i++)
|
||||
AddMemoryCards(i);
|
||||
for (Slot slot : MEMCARD_SLOTS)
|
||||
AddMemoryCards(static_cast<int>(slot));
|
||||
|
||||
g_Channels[0]->AddDevice(EXIDeviceType::MaskROM, 1);
|
||||
g_Channels[0]->AddDevice(Config::Get(Config::MAIN_SERIAL_PORT_1), 2);
|
||||
g_Channels[SlotToEXIChannel(Slot::SP1)]->AddDevice(Config::Get(Config::MAIN_SERIAL_PORT_1),
|
||||
SlotToEXIDevice(Slot::SP1));
|
||||
g_Channels[2]->AddDevice(EXIDeviceType::AD16, 0);
|
||||
|
||||
changeDevice = CoreTiming::RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback);
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/EnumFormatter.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
|
||||
class PointerWrap;
|
||||
|
@ -25,10 +28,22 @@ enum class EXIDeviceType : int;
|
|||
|
||||
enum
|
||||
{
|
||||
MAX_MEMORYCARD_SLOTS = 2,
|
||||
MAX_EXI_CHANNELS = 3
|
||||
};
|
||||
|
||||
enum class Slot : int
|
||||
{
|
||||
A,
|
||||
B,
|
||||
SP1,
|
||||
};
|
||||
static constexpr auto SLOTS = {Slot::A, Slot::B, Slot::SP1};
|
||||
static constexpr auto MAX_SLOT = Slot::SP1;
|
||||
static constexpr auto MEMCARD_SLOTS = {Slot::A, Slot::B};
|
||||
|
||||
u8 SlotToEXIChannel(Slot slot);
|
||||
u8 SlotToEXIDevice(Slot slot);
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
void DoState(PointerWrap& p);
|
||||
|
@ -47,3 +62,9 @@ CEXIChannel* GetChannel(u32 index);
|
|||
IEXIDevice* FindDevice(EXIDeviceType device_type, int customIndex = -1);
|
||||
|
||||
} // namespace ExpansionInterface
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<ExpansionInterface::Slot> : EnumFormatter<ExpansionInterface::MAX_SLOT>
|
||||
{
|
||||
constexpr formatter() : EnumFormatter({"Slot A", "Slot B", "Serial Port 1"}) {}
|
||||
};
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "Core/Config/SessionSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/GeckoCode.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_DeviceIPL.h"
|
||||
#ifdef HAS_LIBMGBA
|
||||
#include "Core/HW/GBACore.h"
|
||||
|
@ -818,8 +819,8 @@ void NetPlayClient::OnStartGame(sf::Packet& packet)
|
|||
packet >> m_net_settings.m_OCEnable;
|
||||
packet >> m_net_settings.m_OCFactor;
|
||||
|
||||
for (auto& device : m_net_settings.m_EXIDevice)
|
||||
packet >> device;
|
||||
for (auto slot : ExpansionInterface::SLOTS)
|
||||
packet >> m_net_settings.m_EXIDevice[slot];
|
||||
|
||||
for (u32& value : m_net_settings.m_SYSCONFSettings)
|
||||
packet >> value;
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/EnumMap.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
|
||||
namespace DiscIO
|
||||
|
@ -44,7 +46,7 @@ struct NetSettings
|
|||
bool m_CopyWiiSave = false;
|
||||
bool m_OCEnable = false;
|
||||
float m_OCFactor = 0;
|
||||
std::array<ExpansionInterface::EXIDeviceType, 3> m_EXIDevice{};
|
||||
Common::EnumMap<ExpansionInterface::EXIDeviceType, ExpansionInterface::MAX_SLOT> m_EXIDevice{};
|
||||
|
||||
std::array<u32, Config::SYSCONF_SETTINGS.size()> m_SYSCONFSettings{};
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "Core/ConfigManager.h"
|
||||
#include "Core/GeckoCode.h"
|
||||
#include "Core/GeckoCodeConfig.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
#ifdef HAS_LIBMGBA
|
||||
#include "Core/HW/GBACore.h"
|
||||
#endif
|
||||
|
@ -1306,10 +1308,21 @@ bool NetPlayServer::SetupNetSettings()
|
|||
settings.m_CopyWiiSave = Config::Get(Config::NETPLAY_LOAD_WII_SAVE);
|
||||
settings.m_OCEnable = Config::Get(Config::MAIN_OVERCLOCK_ENABLE);
|
||||
settings.m_OCFactor = Config::Get(Config::MAIN_OVERCLOCK);
|
||||
settings.m_EXIDevice[0] = Config::Get(Config::MAIN_SLOT_A);
|
||||
settings.m_EXIDevice[1] = Config::Get(Config::MAIN_SLOT_B);
|
||||
|
||||
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
||||
{
|
||||
ExpansionInterface::EXIDeviceType device;
|
||||
if (slot == ExpansionInterface::Slot::SP1)
|
||||
{
|
||||
// There's no way the BBA is going to sync, disable it
|
||||
settings.m_EXIDevice[2] = ExpansionInterface::EXIDeviceType::None;
|
||||
device = ExpansionInterface::EXIDeviceType::None;
|
||||
}
|
||||
else
|
||||
{
|
||||
device = Config::Get(Config::GetInfoForEXIDevice(slot));
|
||||
}
|
||||
settings.m_EXIDevice[slot] = device;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < Config::SYSCONF_SETTINGS.size(); ++i)
|
||||
{
|
||||
|
@ -1494,8 +1507,8 @@ bool NetPlayServer::StartGame()
|
|||
spac << m_settings.m_OCEnable;
|
||||
spac << m_settings.m_OCFactor;
|
||||
|
||||
for (auto& device : m_settings.m_EXIDevice)
|
||||
spac << static_cast<int>(device);
|
||||
for (auto slot : ExpansionInterface::SLOTS)
|
||||
spac << static_cast<int>(m_settings.m_EXIDevice[slot]);
|
||||
|
||||
for (u32 value : m_settings.m_SYSCONFSettings)
|
||||
spac << value;
|
||||
|
@ -1592,11 +1605,10 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
u8 save_count = 0;
|
||||
|
||||
constexpr int exi_device_count = 2;
|
||||
for (int i = 0; i < exi_device_count; ++i)
|
||||
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
||||
{
|
||||
if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDeviceType::MemoryCard ||
|
||||
Config::Get(Config::GetInfoForEXIDevice(i)) ==
|
||||
if (m_settings.m_EXIDevice[slot] == ExpansionInterface::EXIDeviceType::MemoryCard ||
|
||||
Config::Get(Config::GetInfoForEXIDevice(slot)) ==
|
||||
ExpansionInterface::EXIDeviceType::MemoryCardFolder)
|
||||
{
|
||||
save_count++;
|
||||
|
@ -1652,11 +1664,11 @@ bool NetPlayServer::SyncSaveData()
|
|||
const std::string region =
|
||||
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion()));
|
||||
|
||||
for (int i = 0; i < exi_device_count; ++i)
|
||||
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
||||
{
|
||||
const bool is_slot_a = i == 0;
|
||||
const bool is_slot_a = slot == ExpansionInterface::Slot::A;
|
||||
|
||||
if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDeviceType::MemoryCard)
|
||||
if (m_settings.m_EXIDevice[slot] == ExpansionInterface::EXIDeviceType::MemoryCard)
|
||||
{
|
||||
std::string path = is_slot_a ? Config::Get(Config::MAIN_MEMCARD_A_PATH) :
|
||||
Config::Get(Config::MAIN_MEMCARD_B_PATH);
|
||||
|
@ -1693,7 +1705,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
SendChunkedToClients(std::move(pac), 1,
|
||||
fmt::format("Memory Card {} Synchronization", is_slot_a ? 'A' : 'B'));
|
||||
}
|
||||
else if (Config::Get(Config::GetInfoForEXIDevice(i)) ==
|
||||
else if (Config::Get(Config::GetInfoForEXIDevice(slot)) ==
|
||||
ExpansionInterface::EXIDeviceType::MemoryCardFolder)
|
||||
{
|
||||
const std::string path = File::GetUserPath(D_GCUSER_IDX) + region + DIR_SEP +
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/DVD/DVDInterface.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
#include "Core/HW/WiiSave.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
@ -661,20 +662,23 @@ void GameList::OpenGCSaveFolder()
|
|||
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
using ExpansionInterface::Slot;
|
||||
|
||||
for (Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
||||
{
|
||||
QUrl url;
|
||||
const ExpansionInterface::EXIDeviceType current_exi_device =
|
||||
Config::Get(Config::GetInfoForEXIDevice(i));
|
||||
Config::Get(Config::GetInfoForEXIDevice(slot));
|
||||
switch (current_exi_device)
|
||||
{
|
||||
case ExpansionInterface::EXIDeviceType::MemoryCardFolder:
|
||||
{
|
||||
std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(),
|
||||
SConfig::GetDirectoryForRegion(game->GetRegion()),
|
||||
i == 0 ? "Card A" : "Card B");
|
||||
slot == Slot::A ? "Card A" : "Card B");
|
||||
|
||||
std::string override_path = i == 0 ? Config::Get(Config::MAIN_GCI_FOLDER_A_PATH_OVERRIDE) :
|
||||
std::string override_path = slot == Slot::A ?
|
||||
Config::Get(Config::MAIN_GCI_FOLDER_A_PATH_OVERRIDE) :
|
||||
Config::Get(Config::MAIN_GCI_FOLDER_B_PATH_OVERRIDE);
|
||||
|
||||
if (!override_path.empty())
|
||||
|
@ -693,7 +697,7 @@ void GameList::OpenGCSaveFolder()
|
|||
}
|
||||
case ExpansionInterface::EXIDeviceType::MemoryCard:
|
||||
{
|
||||
std::string memcard_path = i == 0 ? Config::Get(Config::MAIN_MEMCARD_A_PATH) :
|
||||
std::string memcard_path = slot == Slot::A ? Config::Get(Config::MAIN_MEMCARD_A_PATH) :
|
||||
Config::Get(Config::MAIN_MEMCARD_B_PATH);
|
||||
|
||||
std::string memcard_dir;
|
||||
|
|
|
@ -464,7 +464,7 @@ void GameCubePane::LoadSettings()
|
|||
{
|
||||
QSignalBlocker blocker(m_slot_combos[i]);
|
||||
const ExpansionInterface::EXIDeviceType exi_device =
|
||||
Config::Get(Config::GetInfoForEXIDevice(i));
|
||||
Config::Get(Config::GetInfoForEXIDevice(static_cast<ExpansionInterface::Slot>(i)));
|
||||
m_slot_combos[i]->setCurrentIndex(m_slot_combos[i]->findData(static_cast<int>(exi_device)));
|
||||
UpdateButton(i);
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ void GameCubePane::SaveSettings()
|
|||
const auto dev =
|
||||
static_cast<ExpansionInterface::EXIDeviceType>(m_slot_combos[i]->currentData().toInt());
|
||||
const ExpansionInterface::EXIDeviceType current_exi_device =
|
||||
Config::Get(Config::GetInfoForEXIDevice(i));
|
||||
Config::Get(Config::GetInfoForEXIDevice(static_cast<ExpansionInterface::Slot>(i)));
|
||||
|
||||
if (Core::IsRunning() && current_exi_device != dev)
|
||||
{
|
||||
|
@ -507,7 +507,8 @@ void GameCubePane::SaveSettings()
|
|||
(i == 2) ? 2 : 0);
|
||||
}
|
||||
|
||||
Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(i), dev);
|
||||
Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(static_cast<ExpansionInterface::Slot>(i)),
|
||||
dev);
|
||||
}
|
||||
|
||||
#ifdef HAS_LIBMGBA
|
||||
|
|
Loading…
Reference in New Issue