From bf95d4012fb159b569024378c7e0f6f559e50870 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 10 Mar 2023 20:16:37 +0100 Subject: [PATCH] HW/EXI: Refactor ExpansionInterface to class. --- Source/Core/Core/Core.cpp | 2 +- Source/Core/Core/HW/EXI/EXI.cpp | 134 +++++++----------- Source/Core/Core/HW/EXI/EXI.h | 76 ++++++---- Source/Core/Core/HW/EXI/EXI_Channel.cpp | 12 +- .../Core/Core/HW/EXI/EXI_DeviceEthernet.cpp | 6 +- .../Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp | 14 +- .../Core/Core/HW/EXI/EXI_DeviceMemoryCard.h | 2 +- Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp | 2 +- Source/Core/Core/HW/HW.cpp | 6 +- Source/Core/Core/HW/Memmap.cpp | 4 +- Source/Core/Core/System.cpp | 9 +- Source/Core/Core/System.h | 4 +- .../Core/DolphinQt/Settings/GameCubePane.cpp | 12 +- 13 files changed, 137 insertions(+), 146 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 4a8d37147d..b1da318c65 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -783,7 +783,7 @@ static bool PauseAndLock(Core::System& system, bool do_lock, bool unpause_on_unl was_unpaused = system.GetCPU().PauseAndLock(true); } - ExpansionInterface::PauseAndLock(do_lock, false); + system.GetExpansionInterface().PauseAndLock(do_lock, false); // audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle). system.GetDSP().GetDSPEmulator()->PauseAndLock(do_lock, false); diff --git a/Source/Core/Core/HW/EXI/EXI.cpp b/Source/Core/Core/HW/EXI/EXI.cpp index 445e989bfa..57d6ff4b7f 100644 --- a/Source/Core/Core/HW/EXI/EXI.cpp +++ b/Source/Core/Core/HW/EXI/EXI.cpp @@ -27,28 +27,13 @@ namespace ExpansionInterface { -struct ExpansionInterfaceState::Data -{ - CoreTiming::EventType* event_type_change_device = nullptr; - CoreTiming::EventType* event_type_update_interrupts = nullptr; - - std::array, MAX_EXI_CHANNELS> channels{}; - - bool using_overridden_sram = false; -}; - -ExpansionInterfaceState::ExpansionInterfaceState() : m_data(std::make_unique()) +ExpansionInterfaceManager::ExpansionInterfaceManager(Core::System& system) : m_system(system) { } -ExpansionInterfaceState::~ExpansionInterfaceState() = default; +ExpansionInterfaceManager::~ExpansionInterfaceManager() = default; -static void ChangeDeviceCallback(Core::System& system, u64 userdata, s64 cyclesLate); -static void UpdateInterruptsCallback(Core::System& system, u64 userdata, s64 cycles_late); - -namespace -{ -void AddMemoryCard(Slot slot) +void ExpansionInterfaceManager::AddMemoryCard(Slot slot) { EXIDeviceType memorycard_device; if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) @@ -76,10 +61,8 @@ void AddMemoryCard(Slot slot) memorycard_device = Config::Get(Config::GetInfoForEXIDevice(slot)); } - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - state.channels[SlotToEXIChannel(slot)]->AddDevice(memorycard_device, SlotToEXIDevice(slot)); + m_channels[SlotToEXIChannel(slot)]->AddDevice(memorycard_device, SlotToEXIDevice(slot)); } -} // namespace u8 SlotToEXIChannel(Slot slot) { @@ -113,20 +96,18 @@ u8 SlotToEXIDevice(Slot slot) } } -void Init(const Sram* override_sram) +void ExpansionInterfaceManager::Init(const Sram* override_sram) { - auto& system = Core::System::GetInstance(); - auto& state = system.GetExpansionInterfaceState().GetData(); - auto& sram = system.GetSRAM(); + auto& sram = m_system.GetSRAM(); if (override_sram) { sram = *override_sram; - state.using_overridden_sram = true; + m_using_overridden_sram = true; } else { InitSRAM(&sram, SConfig::GetInstance().m_strSRAM); - state.using_overridden_sram = false; + m_using_overridden_sram = false; } CEXIMemoryCard::Init(); @@ -149,141 +130,130 @@ void Init(const Sram* override_sram) Memcard::HeaderData header_data; Memcard::InitializeHeaderData(&header_data, flash_id, size_mbits, shift_jis, rtc_bias, sram_language, format_time + i); - state.channels[i] = std::make_unique(system, i, header_data); + m_channels[i] = std::make_unique(m_system, i, header_data); } } for (Slot slot : MEMCARD_SLOTS) AddMemoryCard(slot); - state.channels[0]->AddDevice(EXIDeviceType::MaskROM, 1); - state.channels[SlotToEXIChannel(Slot::SP1)]->AddDevice(Config::Get(Config::MAIN_SERIAL_PORT_1), - SlotToEXIDevice(Slot::SP1)); - state.channels[2]->AddDevice(EXIDeviceType::AD16, 0); + m_channels[0]->AddDevice(EXIDeviceType::MaskROM, 1); + m_channels[SlotToEXIChannel(Slot::SP1)]->AddDevice(Config::Get(Config::MAIN_SERIAL_PORT_1), + SlotToEXIDevice(Slot::SP1)); + m_channels[2]->AddDevice(EXIDeviceType::AD16, 0); - auto& core_timing = system.GetCoreTiming(); - state.event_type_change_device = - core_timing.RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback); - state.event_type_update_interrupts = + auto& core_timing = m_system.GetCoreTiming(); + m_event_type_change_device = core_timing.RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback); + m_event_type_update_interrupts = core_timing.RegisterEvent("EXIUpdateInterrupts", UpdateInterruptsCallback); } -void Shutdown() +void ExpansionInterfaceManager::Shutdown() { - auto& system = Core::System::GetInstance(); - auto& state = system.GetExpansionInterfaceState().GetData(); - - for (auto& channel : state.channels) + for (auto& channel : m_channels) channel.reset(); CEXIMemoryCard::Shutdown(); - if (!state.using_overridden_sram) + if (!m_using_overridden_sram) { File::IOFile file(SConfig::GetInstance().m_strSRAM, "wb"); - auto& sram = system.GetSRAM(); + auto& sram = m_system.GetSRAM(); file.WriteArray(&sram, 1); } } -void DoState(PointerWrap& p) +void ExpansionInterfaceManager::DoState(PointerWrap& p) { - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - for (auto& channel : state.channels) + for (auto& channel : m_channels) channel->DoState(p); } -void PauseAndLock(bool doLock, bool unpauseOnUnlock) +void ExpansionInterfaceManager::PauseAndLock(bool doLock, bool unpauseOnUnlock) { - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - for (auto& channel : state.channels) + for (auto& channel : m_channels) channel->PauseAndLock(doLock, unpauseOnUnlock); } -void RegisterMMIO(MMIO::Mapping* mmio, u32 base) +void ExpansionInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base) { - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); for (int i = 0; i < MAX_EXI_CHANNELS; ++i) { - DEBUG_ASSERT(state.channels[i] != nullptr); + DEBUG_ASSERT(m_channels[i] != nullptr); // Each channel has 5 32 bit registers assigned to it. We offset the // base that we give to each channel for registration. // // Be careful: this means the base is no longer aligned on a page // boundary and using "base | FOO" is not valid! - state.channels[i]->RegisterMMIO(mmio, base + 5 * 4 * i); + m_channels[i]->RegisterMMIO(mmio, base + 5 * 4 * i); } } -static void ChangeDeviceCallback(Core::System& system, u64 userdata, s64 cyclesLate) +void ExpansionInterfaceManager::ChangeDeviceCallback(Core::System& system, u64 userdata, + s64 cycles_late) { u8 channel = (u8)(userdata >> 32); u8 type = (u8)(userdata >> 16); u8 num = (u8)userdata; - auto& state = system.GetExpansionInterfaceState().GetData(); - state.channels.at(channel)->AddDevice(static_cast(type), num); + system.GetExpansionInterface().m_channels.at(channel)->AddDevice(static_cast(type), + num); } -void ChangeDevice(Slot slot, EXIDeviceType device_type, CoreTiming::FromThread from_thread) +void ExpansionInterfaceManager::ChangeDevice(Slot slot, EXIDeviceType device_type, + CoreTiming::FromThread from_thread) { ChangeDevice(SlotToEXIChannel(slot), SlotToEXIDevice(slot), device_type, from_thread); } -void ChangeDevice(u8 channel, u8 device_num, EXIDeviceType device_type, - CoreTiming::FromThread from_thread) +void ExpansionInterfaceManager::ChangeDevice(u8 channel, u8 device_num, EXIDeviceType device_type, + CoreTiming::FromThread from_thread) { // Let the hardware see no device for 1 second - auto& system = Core::System::GetInstance(); - auto& core_timing = system.GetCoreTiming(); - auto& state = system.GetExpansionInterfaceState().GetData(); - core_timing.ScheduleEvent(0, state.event_type_change_device, + auto& core_timing = m_system.GetCoreTiming(); + core_timing.ScheduleEvent(0, m_event_type_change_device, ((u64)channel << 32) | ((u64)EXIDeviceType::None << 16) | device_num, from_thread); - core_timing.ScheduleEvent(SystemTimers::GetTicksPerSecond(), state.event_type_change_device, + core_timing.ScheduleEvent(SystemTimers::GetTicksPerSecond(), m_event_type_change_device, ((u64)channel << 32) | ((u64)device_type << 16) | device_num, from_thread); } -CEXIChannel* GetChannel(u32 index) +CEXIChannel* ExpansionInterfaceManager::GetChannel(u32 index) { - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - return state.channels.at(index).get(); + return m_channels.at(index).get(); } -IEXIDevice* GetDevice(Slot slot) +IEXIDevice* ExpansionInterfaceManager::GetDevice(Slot slot) { - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - return state.channels.at(SlotToEXIChannel(slot))->GetDevice(1 << SlotToEXIDevice(slot)); + return m_channels.at(SlotToEXIChannel(slot))->GetDevice(1 << SlotToEXIDevice(slot)); } -void UpdateInterrupts() +void ExpansionInterfaceManager::UpdateInterrupts() { // Interrupts are mapped a bit strangely: // Channel 0 Device 0 generates interrupt on channel 0 // Channel 0 Device 2 generates interrupt on channel 2 // Channel 1 Device 0 generates interrupt on channel 1 - auto& system = Core::System::GetInstance(); - auto& state = system.GetExpansionInterfaceState().GetData(); - state.channels[2]->SetEXIINT(state.channels[0]->GetDevice(4)->IsInterruptSet()); + m_channels[2]->SetEXIINT(m_channels[0]->GetDevice(4)->IsInterruptSet()); bool causeInt = false; - for (auto& channel : state.channels) + for (auto& channel : m_channels) causeInt |= channel->IsCausingInterrupt(); - system.GetProcessorInterface().SetInterrupt(ProcessorInterface::INT_CAUSE_EXI, causeInt); + m_system.GetProcessorInterface().SetInterrupt(ProcessorInterface::INT_CAUSE_EXI, causeInt); } -static void UpdateInterruptsCallback(Core::System& system, u64 userdata, s64 cycles_late) +void ExpansionInterfaceManager::UpdateInterruptsCallback(Core::System& system, u64 userdata, + s64 cycles_late) { - UpdateInterrupts(); + system.GetExpansionInterface().UpdateInterrupts(); } -void ScheduleUpdateInterrupts(CoreTiming::FromThread from, int cycles_late) +void ExpansionInterfaceManager::ScheduleUpdateInterrupts(CoreTiming::FromThread from, + int cycles_late) { - auto& system = Core::System::GetInstance(); - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); - system.GetCoreTiming().ScheduleEvent(cycles_late, state.event_type_update_interrupts, 0, from); + m_system.GetCoreTiming().ScheduleEvent(cycles_late, m_event_type_update_interrupts, 0, from); } } // namespace ExpansionInterface diff --git a/Source/Core/Core/HW/EXI/EXI.h b/Source/Core/Core/HW/EXI/EXI.h index 815029d796..a82f8f994d 100644 --- a/Source/Core/Core/HW/EXI/EXI.h +++ b/Source/Core/Core/HW/EXI/EXI.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include @@ -13,10 +14,15 @@ class PointerWrap; struct Sram; +namespace Core +{ +class System; +} namespace CoreTiming { +struct EventType; enum class FromThread; -} +} // namespace CoreTiming namespace MMIO { class Mapping; @@ -24,23 +30,6 @@ class Mapping; namespace ExpansionInterface { -class ExpansionInterfaceState -{ -public: - ExpansionInterfaceState(); - ExpansionInterfaceState(const ExpansionInterfaceState&) = delete; - ExpansionInterfaceState(ExpansionInterfaceState&&) = delete; - ExpansionInterfaceState& operator=(const ExpansionInterfaceState&) = delete; - ExpansionInterfaceState& operator=(ExpansionInterfaceState&&) = delete; - ~ExpansionInterfaceState(); - - struct Data; - Data& GetData() { return *m_data; } - -private: - std::unique_ptr m_data; -}; - class CEXIChannel; class IEXIDevice; enum class EXIDeviceType : int; @@ -70,24 +59,49 @@ constexpr bool IsMemcardSlot(Slot slot) u8 SlotToEXIChannel(Slot slot); u8 SlotToEXIDevice(Slot slot); -void Init(const Sram* override_sram); -void Shutdown(); -void DoState(PointerWrap& p); -void PauseAndLock(bool doLock, bool unpauseOnUnlock); +class ExpansionInterfaceManager +{ +public: + explicit ExpansionInterfaceManager(Core::System& system); + ExpansionInterfaceManager(const ExpansionInterfaceManager&) = delete; + ExpansionInterfaceManager(ExpansionInterfaceManager&&) = delete; + ExpansionInterfaceManager& operator=(const ExpansionInterfaceManager&) = delete; + ExpansionInterfaceManager& operator=(ExpansionInterfaceManager&&) = delete; + ~ExpansionInterfaceManager(); -void RegisterMMIO(MMIO::Mapping* mmio, u32 base); + void Init(const Sram* override_sram); + void Shutdown(); + void DoState(PointerWrap& p); + void PauseAndLock(bool doLock, bool unpauseOnUnlock); -void UpdateInterrupts(); -void ScheduleUpdateInterrupts(CoreTiming::FromThread from, int cycles_late); + void RegisterMMIO(MMIO::Mapping* mmio, u32 base); -void ChangeDevice(Slot slot, EXIDeviceType device_type, - CoreTiming::FromThread from_thread = CoreTiming::FromThread::NON_CPU); -void ChangeDevice(u8 channel, u8 device_num, EXIDeviceType device_type, - CoreTiming::FromThread from_thread = CoreTiming::FromThread::NON_CPU); + void UpdateInterrupts(); + void ScheduleUpdateInterrupts(CoreTiming::FromThread from, int cycles_late); -CEXIChannel* GetChannel(u32 index); -IEXIDevice* GetDevice(Slot slot); + void ChangeDevice(Slot slot, EXIDeviceType device_type, + CoreTiming::FromThread from_thread = CoreTiming::FromThread::NON_CPU); + void ChangeDevice(u8 channel, u8 device_num, EXIDeviceType device_type, + CoreTiming::FromThread from_thread = CoreTiming::FromThread::NON_CPU); + CEXIChannel* GetChannel(u32 index); + IEXIDevice* GetDevice(Slot slot); + +private: + void AddMemoryCard(Slot slot); + + static void ChangeDeviceCallback(Core::System& system, u64 userdata, s64 cycles_late); + static void UpdateInterruptsCallback(Core::System& system, u64 userdata, s64 cycles_late); + + CoreTiming::EventType* m_event_type_change_device = nullptr; + CoreTiming::EventType* m_event_type_update_interrupts = nullptr; + + std::array, MAX_EXI_CHANNELS> m_channels; + + bool m_using_overridden_sram = false; + + Core::System& m_system; +}; } // namespace ExpansionInterface template <> diff --git a/Source/Core/Core/HW/EXI/EXI_Channel.cpp b/Source/Core/Core/HW/EXI/EXI_Channel.cpp index c9900febc4..1eb1bbae54 100644 --- a/Source/Core/Core/HW/EXI/EXI_Channel.cpp +++ b/Source/Core/Core/HW/EXI/EXI_Channel.cpp @@ -62,7 +62,7 @@ void CEXIChannel::RegisterMMIO(MMIO::Mapping* mmio, u32 base) return m_status.Hex; }), - MMIO::ComplexWrite([this](Core::System&, u32, u32 val) { + MMIO::ComplexWrite([this](Core::System& system, u32, u32 val) { UEXI_STATUS new_status(val); m_status.EXIINTMASK = new_status.EXIINTMASK; @@ -91,7 +91,7 @@ void CEXIChannel::RegisterMMIO(MMIO::Mapping* mmio, u32 base) if (device != nullptr) device->SetCS(m_status.CHIP_SELECT); - ExpansionInterface::UpdateInterrupts(); + system.GetExpansionInterface().UpdateInterrupts(); })); mmio->Register(base + EXI_DMA_ADDRESS, MMIO::DirectRead(&m_dma_memory_address), @@ -160,7 +160,7 @@ void CEXIChannel::RegisterMMIO(MMIO::Mapping* mmio, u32 base) void CEXIChannel::SendTransferComplete() { m_status.TCINT = 1; - ExpansionInterface::UpdateInterrupts(); + m_system.GetExpansionInterface().UpdateInterrupts(); } void CEXIChannel::RemoveDevices() @@ -195,7 +195,7 @@ void CEXIChannel::AddDevice(std::unique_ptr device, const int device if (m_channel_id != 2) { m_status.EXTINT = 1; - ExpansionInterface::UpdateInterrupts(); + m_system.GetExpansionInterface().UpdateInterrupts(); } } } @@ -280,8 +280,8 @@ void CEXIChannel::DoState(PointerWrap& p) // the new device type are identical in this case. I assume there is a reason we have this // grace period when switching in the GUI. AddDevice(EXIDeviceType::None, device_index); - ExpansionInterface::ChangeDevice(m_channel_id, device_index, EXIDeviceType::MemoryCardFolder, - CoreTiming::FromThread::CPU); + m_system.GetExpansionInterface().ChangeDevice( + m_channel_id, device_index, EXIDeviceType::MemoryCardFolder, CoreTiming::FromThread::CPU); } } } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp index 9d991b41e4..83134941dc 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp @@ -178,7 +178,7 @@ void CEXIETHERNET::ImmWrite(u32 data, u32 size) exi_status.interrupt_mask = data; break; } - ExpansionInterface::UpdateInterrupts(); + m_system.GetExpansionInterface().UpdateInterrupts(); } else { @@ -466,7 +466,7 @@ void CEXIETHERNET::SendComplete() mBbaMem[BBA_IR] |= INT_T; exi_status.interrupt |= exi_status.TRANSFER; - ExpansionInterface::ScheduleUpdateInterrupts(CoreTiming::FromThread::CPU, 0); + m_system.GetExpansionInterface().ScheduleUpdateInterrupts(CoreTiming::FromThread::CPU, 0); } mBbaMem[BBA_LTPS] = 0; @@ -637,7 +637,7 @@ bool CEXIETHERNET::RecvHandlePacket() mBbaMem[BBA_IR] |= INT_R; exi_status.interrupt |= exi_status.TRANSFER; - ExpansionInterface::ScheduleUpdateInterrupts(CoreTiming::FromThread::NON_CPU, 0); + m_system.GetExpansionInterface().ScheduleUpdateInterrupts(CoreTiming::FromThread::NON_CPU, 0); } else { diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index 043299662f..8ddb996778 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -56,11 +56,11 @@ static Common::EnumMap s_card_short_names{'A', 'B'}; // Takes care of the nasty recovery of the 'this' pointer from card_slot, // stored in the userdata parameter of the CoreTiming event. -void CEXIMemoryCard::EventCompleteFindInstance(u64 userdata, +void CEXIMemoryCard::EventCompleteFindInstance(Core::System& system, u64 userdata, std::function callback) { Slot card_slot = static_cast(userdata); - IEXIDevice* self = ExpansionInterface::GetDevice(card_slot); + IEXIDevice* self = system.GetExpansionInterface().GetDevice(card_slot); if (self != nullptr) { if (self->m_device_type == EXIDeviceType::MemoryCard || @@ -73,12 +73,13 @@ void CEXIMemoryCard::EventCompleteFindInstance(u64 userdata, void CEXIMemoryCard::CmdDoneCallback(Core::System& system, u64 userdata, s64) { - EventCompleteFindInstance(userdata, [](CEXIMemoryCard* instance) { instance->CmdDone(); }); + EventCompleteFindInstance(system, userdata, + [](CEXIMemoryCard* instance) { instance->CmdDone(); }); } void CEXIMemoryCard::TransferCompleteCallback(Core::System& system, u64 userdata, s64) { - EventCompleteFindInstance(userdata, + EventCompleteFindInstance(system, userdata, [](CEXIMemoryCard* instance) { instance->TransferComplete(); }); } @@ -256,13 +257,14 @@ void CEXIMemoryCard::CmdDone() m_status &= ~MC_STATUS_BUSY; m_interrupt_set = true; - ExpansionInterface::UpdateInterrupts(); + m_system.GetExpansionInterface().UpdateInterrupts(); } void CEXIMemoryCard::TransferComplete() { // Transfer complete, send interrupt - ExpansionInterface::GetChannel(ExpansionInterface::SlotToEXIChannel(m_card_slot)) + m_system.GetExpansionInterface() + .GetChannel(ExpansionInterface::SlotToEXIChannel(m_card_slot)) ->SendTransferComplete(); } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h index e793bfa5c0..b7772556e5 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h @@ -59,7 +59,7 @@ public: private: void SetupGciFolder(const Memcard::HeaderData& header_data); void SetupRawMemcard(u16 size_mb); - static void EventCompleteFindInstance(u64 userdata, + static void EventCompleteFindInstance(Core::System& system, u64 userdata, std::function callback); // Scheduled when a command that required delayed end signaling is done. diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp index 3e87175938..1bd3d00b35 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp @@ -266,7 +266,7 @@ void CEXIMic::UpdateNextInterruptTicks() { int diff = (SystemTimers::GetTicksPerSecond() / sample_rate) * buff_size_samples; next_int_ticks = m_system.GetCoreTiming().GetTicks() + diff; - ExpansionInterface::ScheduleUpdateInterrupts(CoreTiming::FromThread::CPU, diff); + m_system.GetExpansionInterface().ScheduleUpdateInterrupts(CoreTiming::FromThread::CPU, diff); } bool CEXIMic::IsInterruptSet() diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index f8eedc7eb1..2de2300e96 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -44,7 +44,7 @@ void Init(const Sram* override_sram) VideoInterface::Init(); SerialInterface::Init(); system.GetProcessorInterface().Init(); - ExpansionInterface::Init(override_sram); // Needs to be initialized before Memory + system.GetExpansionInterface().Init(override_sram); // Needs to be initialized before Memory system.GetHSP().Init(); system.GetMemory().Init(); // Needs to be initialized before AddressSpace AddressSpace::Init(); @@ -78,7 +78,7 @@ void Shutdown() AddressSpace::Shutdown(); system.GetMemory().Shutdown(); system.GetHSP().Shutdown(); - ExpansionInterface::Shutdown(); + system.GetExpansionInterface().Shutdown(); SerialInterface::Shutdown(); system.GetAudioInterface().Shutdown(); @@ -105,7 +105,7 @@ void DoState(PointerWrap& p) p.DoMarker("DVDInterface"); system.GetGPFifo().DoState(p); p.DoMarker("GPFifo"); - ExpansionInterface::DoState(p); + system.GetExpansionInterface().DoState(p); p.DoMarker("ExpansionInterface"); system.GetAudioInterface().DoState(p); p.DoMarker("AudioInterface"); diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 50133c76cd..3f65683227 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -57,14 +57,14 @@ void MemoryManager::InitMMIO(bool is_wii) system.GetDSP().RegisterMMIO(m_mmio_mapping.get(), 0x0C005000); system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006000, false); SerialInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C006400); - ExpansionInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C006800); + system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006800); system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006C00); if (is_wii) { IOS::RegisterMMIO(m_mmio_mapping.get(), 0x0D000000); system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006000, true); SerialInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0D006400); - ExpansionInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0D006800); + system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006800); system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006C00); } } diff --git a/Source/Core/Core/System.cpp b/Source/Core/Core/System.cpp index 40260b8b9d..58cb0628a1 100644 --- a/Source/Core/Core/System.cpp +++ b/Source/Core/Core/System.cpp @@ -37,7 +37,8 @@ struct System::Impl { explicit Impl(System& system) : m_audio_interface(system), m_core_timing(system), m_dsp(system), m_dvd_interface(system), - m_dvd_thread(system), m_gp_fifo(system), m_ppc_state(PowerPC::ppcState) + m_dvd_thread(system), m_expansion_interface(system), m_gp_fifo(system), + m_ppc_state(PowerPC::ppcState) { } @@ -52,7 +53,7 @@ struct System::Impl DSP::DSPManager m_dsp; DVD::DVDInterface m_dvd_interface; DVD::DVDThread m_dvd_thread; - ExpansionInterface::ExpansionInterfaceState m_expansion_interface_state; + ExpansionInterface::ExpansionInterfaceManager m_expansion_interface; Fifo::FifoManager m_fifo; GeometryShaderManager m_geometry_shader_manager; GPFifo::GPFifoManager m_gp_fifo; @@ -148,9 +149,9 @@ DVD::DVDThread& System::GetDVDThread() const return m_impl->m_dvd_thread; } -ExpansionInterface::ExpansionInterfaceState& System::GetExpansionInterfaceState() const +ExpansionInterface::ExpansionInterfaceManager& System::GetExpansionInterface() const { - return m_impl->m_expansion_interface_state; + return m_impl->m_expansion_interface; } Fifo::FifoManager& System::GetFifo() const diff --git a/Source/Core/Core/System.h b/Source/Core/Core/System.h index 847d108124..558c2ac7c2 100644 --- a/Source/Core/Core/System.h +++ b/Source/Core/Core/System.h @@ -38,7 +38,7 @@ class DVDThread; } // namespace DVD namespace ExpansionInterface { -class ExpansionInterfaceState; +class ExpansionInterfaceManager; }; namespace Fifo { @@ -126,7 +126,7 @@ public: DSP::DSPManager& GetDSP() const; DVD::DVDInterface& GetDVDInterface() const; DVD::DVDThread& GetDVDThread() const; - ExpansionInterface::ExpansionInterfaceState& GetExpansionInterfaceState() const; + ExpansionInterface::ExpansionInterfaceManager& GetExpansionInterface() const; Fifo::FifoManager& GetFifo() const; GeometryShaderManager& GetGeometryShaderManager() const; GPFifo::GPFifoManager& GetGPFifo() const; diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 7b7bac989d..55510fd9f9 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -32,6 +32,7 @@ #include "Core/HW/EXI/EXI.h" #include "Core/HW/GCMemcard/GCMemcard.h" #include "Core/NetPlayServer.h" +#include "Core/System.h" #include "DolphinQt/Config/Mapping/MappingWindow.h" #include "DolphinQt/GCMemcardManager.h" @@ -496,7 +497,8 @@ bool GameCubePane::SetMemcard(ExpansionInterface::Slot slot, const QString& file { // ChangeDevice unplugs the device for 1 second, which means that games should notice that // the path has changed and thus the memory card contents have changed - ExpansionInterface::ChangeDevice(slot, ExpansionInterface::EXIDeviceType::MemoryCard); + Core::System::GetInstance().GetExpansionInterface().ChangeDevice( + slot, ExpansionInterface::EXIDeviceType::MemoryCard); } } @@ -601,7 +603,8 @@ bool GameCubePane::SetGCIFolder(ExpansionInterface::Slot slot, const QString& pa { // ChangeDevice unplugs the device for 1 second, which means that games should notice that // the path has changed and thus the memory card contents have changed - ExpansionInterface::ChangeDevice(slot, ExpansionInterface::EXIDeviceType::MemoryCardFolder); + Core::System::GetInstance().GetExpansionInterface().ChangeDevice( + slot, ExpansionInterface::EXIDeviceType::MemoryCardFolder); } } @@ -637,7 +640,8 @@ void GameCubePane::SetAGPRom(ExpansionInterface::Slot slot, const QString& filen // cartridge without unplugging it, and it's not clear if the AGP software actually notices // that it's been unplugged or the cartridge has changed, but this was done for memcards so // we might as well do it for the AGP too. - ExpansionInterface::ChangeDevice(slot, ExpansionInterface::EXIDeviceType::AGP); + Core::System::GetInstance().GetExpansionInterface().ChangeDevice( + slot, ExpansionInterface::EXIDeviceType::AGP); } LoadSettings(); @@ -761,7 +765,7 @@ void GameCubePane::SaveSettings() if (Core::IsRunning() && current_exi_device != dev) { - ExpansionInterface::ChangeDevice(slot, dev); + Core::System::GetInstance().GetExpansionInterface().ChangeDevice(slot, dev); } Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(slot), dev);