mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-04 20:06:41 +01:00
SI_Device: Remove global system accessors
We can pass the system timer instance through to avoid needing the global accessor.
This commit is contained in:
parent
7398d0b6ef
commit
409d2ecad3
@ -112,7 +112,8 @@ void ISIDevice::OnEvent(u64 userdata, s64 cycles_late)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int SIDevice_GetGBATransferTime(EBufferCommands cmd)
|
int SIDevice_GetGBATransferTime(const SystemTimers::SystemTimersManager& timers,
|
||||||
|
EBufferCommands cmd)
|
||||||
{
|
{
|
||||||
u64 gc_bytes_transferred = 1;
|
u64 gc_bytes_transferred = 1;
|
||||||
u64 gba_bytes_transferred = 1;
|
u64 gba_bytes_transferred = 1;
|
||||||
@ -143,7 +144,7 @@ int SIDevice_GetGBATransferTime(EBufferCommands cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 ticks_per_second = Core::System::GetInstance().GetSystemTimers().GetTicksPerSecond();
|
const u32 ticks_per_second = timers.GetTicksPerSecond();
|
||||||
const u64 cycles = (gba_bytes_transferred * 8 * ticks_per_second / GBA_BITS_PER_SECOND) +
|
const u64 cycles = (gba_bytes_transferred * 8 * ticks_per_second / GBA_BITS_PER_SECOND) +
|
||||||
(gc_bytes_transferred * 8 * ticks_per_second / GC_BITS_PER_SECOND) +
|
(gc_bytes_transferred * 8 * ticks_per_second / GC_BITS_PER_SECOND) +
|
||||||
(stop_bits_ns * ticks_per_second / 1000000000LL);
|
(stop_bits_ns * ticks_per_second / 1000000000LL);
|
||||||
|
@ -12,6 +12,10 @@ namespace Core
|
|||||||
{
|
{
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
namespace SystemTimers
|
||||||
|
{
|
||||||
|
class SystemTimersManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace SerialInterface
|
namespace SerialInterface
|
||||||
{
|
{
|
||||||
@ -138,7 +142,8 @@ protected:
|
|||||||
SIDevices m_device_type;
|
SIDevices m_device_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
int SIDevice_GetGBATransferTime(EBufferCommands cmd);
|
int SIDevice_GetGBATransferTime(const SystemTimers::SystemTimersManager& timers,
|
||||||
|
EBufferCommands cmd);
|
||||||
bool SIDevice_IsGCController(SIDevices type);
|
bool SIDevice_IsGCController(SIDevices type);
|
||||||
|
|
||||||
std::unique_ptr<ISIDevice> SIDevice_Create(Core::System& system, SIDevices device, int port_number);
|
std::unique_ptr<ISIDevice> SIDevice_Create(Core::System& system, SIDevices device, int port_number);
|
||||||
|
@ -298,7 +298,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
|||||||
{
|
{
|
||||||
int elapsed_time = static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
int elapsed_time = static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
||||||
// Tell SI to ask again after TransferInterval() cycles
|
// Tell SI to ask again after TransferInterval() cycles
|
||||||
if (SIDevice_GetGBATransferTime(m_last_cmd) > elapsed_time)
|
if (SIDevice_GetGBATransferTime(m_system.GetSystemTimers(), m_last_cmd) > elapsed_time)
|
||||||
return 0;
|
return 0;
|
||||||
m_next_action = NextAction::ReceiveResponse;
|
m_next_action = NextAction::ReceiveResponse;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
@ -345,7 +345,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
|||||||
|
|
||||||
int CSIDevice_GBA::TransferInterval()
|
int CSIDevice_GBA::TransferInterval()
|
||||||
{
|
{
|
||||||
return SIDevice_GetGBATransferTime(m_last_cmd);
|
return SIDevice_GetGBATransferTime(m_system.GetSystemTimers(), m_last_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSIDevice_GBA::GetData(u32& hi, u32& low)
|
bool CSIDevice_GBA::GetData(u32& hi, u32& low)
|
||||||
|
@ -117,7 +117,7 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
|
|||||||
|
|
||||||
int CSIDevice_GBAEmu::TransferInterval()
|
int CSIDevice_GBAEmu::TransferInterval()
|
||||||
{
|
{
|
||||||
return SIDevice_GetGBATransferTime(m_last_cmd);
|
return SIDevice_GetGBATransferTime(m_system.GetSystemTimers(), m_last_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSIDevice_GBAEmu::GetData(u32& hi, u32& low)
|
bool CSIDevice_GBAEmu::GetData(u32& hi, u32& low)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user