JIT optimizations and refactoring (#675)
* CPU/Recompiler: Use rel32 call where possible for no-args * JitCodeBuffer: Support using preallocated buffer * CPU/Recompiler/AArch64: Use bl instead of blr for short branches * CPU/CodeCache: Allocate recompiler buffer in program space This means we don't need 64-bit moves for every call out of the recompiler. * GTE: Don't store as u16 and load as u32 * CPU/Recompiler: Add methods to emit global load/stores * GTE: Convert class to namespace * CPU/Recompiler: Call GTE functions directly * Settings: Turn into a global variable * GPU: Replace local pointers with global * InterruptController: Turn into a global pointer * System: Replace local pointers with global * Timers: Turn into a global instance * DMA: Turn into a global instance * SPU: Turn into a global instance * CDROM: Turn into a global instance * MDEC: Turn into a global instance * Pad: Turn into a global instance * SIO: Turn into a global instance * CDROM: Move audio FIFO to the heap * CPU/Recompiler: Drop ASMFunctions No longer needed since we have code in the same 4GB window. * CPUCodeCache: Turn class into namespace * Bus: Local pointer -> global pointers * CPU: Turn class into namespace * Bus: Turn into namespace * GTE: Store registers in CPU state struct Allows relative addressing on ARM. * CPU/Recompiler: Align code storage to page size * CPU/Recompiler: Fix relative branches on A64 * HostInterface: Local references to global * System: Turn into a namespace, move events out * Add guard pages * Android: Fix build
This commit is contained in:
committed by
GitHub
parent
1f9fc6ab74
commit
b6f871d2b9
@ -8,16 +8,28 @@
|
||||
#include "system.h"
|
||||
Log_SetChannel(Pad);
|
||||
|
||||
Pad g_pad;
|
||||
|
||||
Pad::Pad() = default;
|
||||
|
||||
Pad::~Pad() = default;
|
||||
|
||||
void Pad::Initialize(System* system, InterruptController* interrupt_controller)
|
||||
void Pad::Initialize()
|
||||
{
|
||||
m_system = system;
|
||||
m_interrupt_controller = interrupt_controller;
|
||||
m_transfer_event = system->CreateTimingEvent("Pad Serial Transfer", 1, 1,
|
||||
std::bind(&Pad::TransferEvent, this, std::placeholders::_2), false);
|
||||
m_transfer_event = TimingEvents::CreateTimingEvent(
|
||||
"Pad Serial Transfer", 1, 1, std::bind(&Pad::TransferEvent, this, std::placeholders::_2), false);
|
||||
Reset();
|
||||
}
|
||||
|
||||
void Pad::Shutdown()
|
||||
{
|
||||
m_transfer_event.reset();
|
||||
|
||||
for (u32 i = 0; i < NUM_SLOTS; i++)
|
||||
{
|
||||
m_controllers[i].reset();
|
||||
m_memory_cards[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Pad::Reset()
|
||||
@ -44,27 +56,26 @@ bool Pad::DoState(StateWrapper& sw)
|
||||
|
||||
if (controller_type != state_controller_type)
|
||||
{
|
||||
if (m_system->GetSettings().load_devices_from_save_states)
|
||||
if (g_settings.load_devices_from_save_states)
|
||||
{
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
2.0f, "Save state contains controller type %s in port %u, but %s is used. Switching.",
|
||||
Settings::GetControllerTypeName(state_controller_type), i + 1u,
|
||||
Settings::GetControllerTypeName(controller_type));
|
||||
|
||||
m_controllers[i].reset();
|
||||
if (state_controller_type != ControllerType::None)
|
||||
m_controllers[i] = Controller::Create(m_system, state_controller_type, i);
|
||||
m_controllers[i] = Controller::Create(state_controller_type, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(2.0f, "Ignoring mismatched controller type %s in port %u.",
|
||||
Settings::GetControllerTypeName(state_controller_type),
|
||||
i + 1u);
|
||||
g_host_interface->AddFormattedOSDMessage(2.0f, "Ignoring mismatched controller type %s in port %u.",
|
||||
Settings::GetControllerTypeName(state_controller_type), i + 1u);
|
||||
|
||||
// we still need to read the save state controller state
|
||||
if (state_controller_type != ControllerType::None)
|
||||
{
|
||||
std::unique_ptr<Controller> dummy_controller = Controller::Create(m_system, state_controller_type, i);
|
||||
std::unique_ptr<Controller> dummy_controller = Controller::Create(state_controller_type, i);
|
||||
if (dummy_controller)
|
||||
{
|
||||
if (!sw.DoMarker("Controller") || !dummy_controller->DoState(sw))
|
||||
@ -85,11 +96,11 @@ bool Pad::DoState(StateWrapper& sw)
|
||||
bool card_present = static_cast<bool>(m_memory_cards[i]);
|
||||
sw.Do(&card_present);
|
||||
|
||||
if (sw.IsReading() && card_present && !m_system->GetSettings().load_devices_from_save_states)
|
||||
if (sw.IsReading() && card_present && !g_settings.load_devices_from_save_states)
|
||||
{
|
||||
Log_WarningPrintf("Skipping loading memory card %u from save state.", i + 1u);
|
||||
|
||||
MemoryCard dummy_card(m_system);
|
||||
MemoryCard dummy_card;
|
||||
if (!sw.DoMarker("MemoryCard") || !dummy_card.DoState(sw))
|
||||
return false;
|
||||
|
||||
@ -102,13 +113,13 @@ bool Pad::DoState(StateWrapper& sw)
|
||||
|
||||
if (card_present && !m_memory_cards[i])
|
||||
{
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
2.0f, "Memory card %u present in save state but not in system. Creating temporary card.", i + 1u);
|
||||
m_memory_cards[i] = MemoryCard::Create(m_system);
|
||||
m_memory_cards[i] = MemoryCard::Create();
|
||||
}
|
||||
else if (!card_present && m_memory_cards[i])
|
||||
{
|
||||
m_system->GetHostInterface()->AddFormattedOSDMessage(
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
2.0f, "Memory card %u present in system but not in save state. Removing card.", i + 1u);
|
||||
m_memory_cards[i].reset();
|
||||
}
|
||||
@ -411,7 +422,7 @@ void Pad::DoACK()
|
||||
{
|
||||
Log_DebugPrintf("Triggering ACK interrupt");
|
||||
m_JOY_STAT.INTR = true;
|
||||
m_interrupt_controller->InterruptRequest(InterruptController::IRQ::IRQ7);
|
||||
g_interrupt_controller.InterruptRequest(InterruptController::IRQ::IRQ7);
|
||||
}
|
||||
|
||||
EndTransfer();
|
||||
|
||||
Reference in New Issue
Block a user