Merge pull request #12440 from lioncash/memcard

Core/EXI/EXI_DeviceMemoryCard: Remove global system accessor
This commit is contained in:
Tilka 2023-12-18 18:11:02 +00:00 committed by GitHub
commit e498759d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -110,7 +110,8 @@ void ExpansionInterfaceManager::Init(const Sram* override_sram)
m_using_overridden_sram = false; m_using_overridden_sram = false;
} }
CEXIMemoryCard::Init(); auto& core_timing = m_system.GetCoreTiming();
CEXIMemoryCard::Init(core_timing);
{ {
u16 size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_2043; u16 size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_2043;
@ -142,7 +143,6 @@ void ExpansionInterfaceManager::Init(const Sram* override_sram)
SlotToEXIDevice(Slot::SP1)); SlotToEXIDevice(Slot::SP1));
m_channels[2]->AddDevice(EXIDeviceType::AD16, 0); m_channels[2]->AddDevice(EXIDeviceType::AD16, 0);
auto& core_timing = m_system.GetCoreTiming();
m_event_type_change_device = core_timing.RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback); m_event_type_change_device = core_timing.RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback);
m_event_type_update_interrupts = m_event_type_update_interrupts =
core_timing.RegisterEvent("EXIUpdateInterrupts", UpdateInterruptsCallback); core_timing.RegisterEvent("EXIUpdateInterrupts", UpdateInterruptsCallback);

View File

@ -83,12 +83,11 @@ void CEXIMemoryCard::TransferCompleteCallback(Core::System& system, u64 userdata
[](CEXIMemoryCard* instance) { instance->TransferComplete(); }); [](CEXIMemoryCard* instance) { instance->TransferComplete(); });
} }
void CEXIMemoryCard::Init() void CEXIMemoryCard::Init(CoreTiming::CoreTimingManager& core_timing)
{ {
static_assert(s_et_cmd_done.size() == s_et_transfer_complete.size(), "Event array size differs"); static_assert(s_et_cmd_done.size() == s_et_transfer_complete.size(), "Event array size differs");
static_assert(s_et_cmd_done.size() == MEMCARD_SLOTS.size(), "Event array size differs"); static_assert(s_et_cmd_done.size() == MEMCARD_SLOTS.size(), "Event array size differs");
auto& system = Core::System::GetInstance();
auto& core_timing = system.GetCoreTiming();
for (Slot slot : MEMCARD_SLOTS) for (Slot slot : MEMCARD_SLOTS)
{ {
s_et_cmd_done[slot] = core_timing.RegisterEvent( s_et_cmd_done[slot] = core_timing.RegisterEvent(

View File

@ -18,6 +18,10 @@ namespace Core
{ {
class System; class System;
} }
namespace CoreTiming
{
class CoreTimingManager;
}
namespace Memcard namespace Memcard
{ {
struct HeaderData; struct HeaderData;
@ -50,7 +54,7 @@ public:
// CoreTiming events need to be registered during boot since CoreTiming is DoState()-ed // CoreTiming events need to be registered during boot since CoreTiming is DoState()-ed
// before ExpansionInterface so we'll lose the save stated events if the callbacks are // before ExpansionInterface so we'll lose the save stated events if the callbacks are
// not already registered first. // not already registered first.
static void Init(); static void Init(CoreTiming::CoreTimingManager& core_timing);
static void Shutdown(); static void Shutdown();
static std::pair<std::string /* path */, bool /* migrate */> static std::pair<std::string /* path */, bool /* migrate */>