diff --git a/src/common/Settings.cpp b/src/common/Settings.cpp index 0a36f8662..0faa84d7f 100644 --- a/src/common/Settings.cpp +++ b/src/common/Settings.cpp @@ -148,6 +148,8 @@ static struct { const char* type = "Type"; const char* device = "DeviceName"; const char* config = "ProfileName"; + const char *top_slot = "TopSlot"; + const char *bottom_slot = "BottomSlot"; } sect_input_port; static const char* section_input_profiles = "input-profile-"; @@ -465,15 +467,25 @@ bool Settings::LoadConfig() // ==== Input Port Begin ==== for (int port_num = 0; port_num < 4; port_num++) { + m_input_port[port_num].Type = to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID); + m_input_port[port_num].TopSlotType = to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID); + m_input_port[port_num].BottomSlotType = to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID); + std::string current_section = std::string(section_input_port) + std::to_string(port_num); int ret = m_si.GetLongValue(current_section.c_str(), sect_input_port.type, -2); if (ret == -2) { - m_input_port[port_num].Type = to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID); continue; } m_input_port[port_num].Type = ret; m_input_port[port_num].DeviceName = m_si.GetValue(current_section.c_str(), sect_input_port.device); m_input_port[port_num].ProfileName = TrimQuoteFromString(m_si.GetValue(current_section.c_str(), sect_input_port.config)); + ret = m_si.GetLongValue(current_section.c_str(), sect_input_port.top_slot, -2); + if (ret == -2) { + continue; + } + m_input_port[port_num].TopSlotType = ret; + m_input_port[port_num].BottomSlotType = m_si.GetLongValue(current_section.c_str(), sect_input_port.bottom_slot, -2); + assert(m_input_port[port_num].BottomSlotType != -2); } // ==== Input Port End ============== @@ -644,6 +656,8 @@ bool Settings::Save(std::string file_path) m_si.SetLongValue(current_section.c_str(), sect_input_port.type, m_input_port[port_num].Type, nullptr, false, true); m_si.SetValue(current_section.c_str(), sect_input_port.device, m_input_port[port_num].DeviceName.c_str(), nullptr, true); m_si.SetValue(current_section.c_str(), sect_input_port.config, quoted_prf_str.c_str(), nullptr, true); + m_si.SetLongValue(current_section.c_str(), sect_input_port.top_slot, m_input_port[port_num].TopSlotType, nullptr, false, true); + m_si.SetLongValue(current_section.c_str(), sect_input_port.bottom_slot, m_input_port[port_num].BottomSlotType, nullptr, false, true); } // ==== Input Port End ============== diff --git a/src/common/Settings.hpp b/src/common/Settings.hpp index 000ff615d..0d3da1b73 100644 --- a/src/common/Settings.hpp +++ b/src/common/Settings.hpp @@ -149,6 +149,8 @@ public: int Type; std::string DeviceName; std::string ProfileName; + int TopSlotType; + int BottomSlotType; }; std::array m_input_port; diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index 6babf23c0..00111d56a 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -96,6 +96,7 @@ char szFilePath_EEPROM_bin[MAX_PATH] = { 0 }; char szFilePath_Xbe[xbox::max_path*2] = { 0 }; // NOTE: LAUNCH_DATA_HEADER's szLaunchPath is xbox::max_path*2 = 520 std::string CxbxBasePath; +std::string MuBasePath; HANDLE CxbxBasePathHandle; Xbe* CxbxKrnl_Xbe = NULL; bool g_bIsChihiro = false; @@ -1433,11 +1434,14 @@ __declspec(noreturn) void CxbxKrnlInit char szBuffer[sizeof(szFilePath_Xbe)]; g_EmuShared->GetStorageLocation(szBuffer); + MuBasePath = std::string(szBuffer) + "\\EmuMu"; CxbxBasePath = std::string(szBuffer) + "\\EmuDisk"; CxbxResolveHostToFullPath(CxbxBasePath, "Cxbx-Reloaded's EmuDisk directory"); + CxbxResolveHostToFullPath(MuBasePath, "Cxbx-Reloaded's EmuMu directory"); // Since canonical always remove the extra slash, we need to manually add it back. // TODO: Once CxbxBasePath is filesystem::path, replace CxbxBasePath's + operators to / for include path separator internally. CxbxBasePath = std::filesystem::path(CxbxBasePath).append("").string(); + MuBasePath = std::filesystem::path(MuBasePath).append("").string(); } // Determine xbe path @@ -1505,6 +1509,17 @@ __declspec(noreturn) void CxbxKrnlInit CxbxRegisterDeviceHostPath(DeviceHarddisk0Partition7, CxbxBasePath + "Partition7"); CxbxRegisterDeviceHostPath(DevicePrefix + "\\Chihiro", CxbxBasePath + "Chihiro"); + // Create MU directories + for (unsigned i = 0; i < 8; ++i) { + std::error_code error; + static char mu_letter = 'F'; + std::string mu_path = MuBasePath + mu_letter; + if (!(std::filesystem::exists(mu_path) || std::filesystem::create_directory(mu_path, error))) { + CxbxKrnlCleanup("Failed to create memory unit directories"); + } + ++mu_letter; + } + // Create default symbolic links : EmuLogInit(LOG_LEVEL::DEBUG, "Creating default symbolic links."); { @@ -1747,6 +1762,13 @@ void CxbxInitFilePaths() CxbxKrnlCleanup("%s : Couldn't create Cxbx-Reloaded EmuDisk folder!", __func__); } + // Make sure the EmuDMu folder exists + std::string emuMu = std::string(szFolder_CxbxReloadedData) + std::string("\\EmuMu"); + result = std::filesystem::exists(emuMu); + if (!result && !std::filesystem::create_directory(emuMu)) { + CxbxKrnlCleanup("%s : Couldn't create Cxbx-Reloaded EmuMu folder!", __func__); + } + snprintf(szFilePath_EEPROM_bin, MAX_PATH, "%s\\EEPROM.bin", szFolder_CxbxReloadedData); GetModuleFileName(GetModuleHandle(nullptr), szFilePath_CxbxReloaded_Exe, MAX_PATH); diff --git a/src/core/kernel/support/EmuFile.cpp b/src/core/kernel/support/EmuFile.cpp index 682a0fd4f..c10e0cbb3 100644 --- a/src/core/kernel/support/EmuFile.cpp +++ b/src/core/kernel/support/EmuFile.cpp @@ -248,7 +248,14 @@ const std::string DriveA = DrivePrefix + "A:"; // A: could be CDROM const std::string DriveC = DrivePrefix + "C:"; // C: is HDD0 const std::string DriveD = DrivePrefix + "D:"; // D: is DVD Player const std::string DriveE = DrivePrefix + "E:"; -const std::string DriveF = DrivePrefix + "F:"; +const std::string DriveF = DrivePrefix + "F:"; // MU port 0, slot top +const std::string DriveG = DrivePrefix + "G:"; // MU port 0, slot bottom +const std::string DriveH = DrivePrefix + "H:"; // MU port 1, slot top +const std::string DriveI = DrivePrefix + "I:"; // MU port 1, slot bottom +const std::string DriveJ = DrivePrefix + "J:"; // MU port 2, slot top +const std::string DriveK = DrivePrefix + "K:"; // MU port 2, slot bottom +const std::string DriveL = DrivePrefix + "L:"; // MU port 3, slot top +const std::string DriveM = DrivePrefix + "M:"; // MU port 3, slot bottom const std::string DriveS = DrivePrefix + "S:"; const std::string DriveT = DrivePrefix + "T:"; // T: is Title persistent data region const std::string DriveU = DrivePrefix + "U:"; // U: is User persistent data region diff --git a/src/core/kernel/support/EmuFile.h b/src/core/kernel/support/EmuFile.h index 81d86d6dd..33c11bf3e 100644 --- a/src/core/kernel/support/EmuFile.h +++ b/src/core/kernel/support/EmuFile.h @@ -62,13 +62,13 @@ extern const std::string DriveC; extern const std::string DriveD; extern const std::string DriveE; extern const std::string DriveF; -extern const std::string DriveS; -extern const std::string DriveT; -extern const std::string DriveU; -extern const std::string DriveV; -extern const std::string DriveW; -extern const std::string DriveX; -extern const std::string DriveY; +extern const std::string DriveG; +extern const std::string DriveH; +extern const std::string DriveI; +extern const std::string DriveJ; +extern const std::string DriveK; +extern const std::string DriveL; +extern const std::string DriveM; extern const std::string DriveZ; extern const std::string DevicePrefix; extern const std::string DeviceCdrom0;