This commit is contained in:
Tygyh 2025-04-26 15:40:48 -04:00 committed by GitHub
commit 9a21db5edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 111 additions and 108 deletions

View file

@ -125,8 +125,8 @@ struct EffectiveAddressSpaceAccessors : Accessors
bool Matches(const Core::CPUThreadGuard& guard, u32 haystack_start, const u8* needle_start,
std::size_t needle_size) const
{
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
const auto& system = guard.GetSystem();
const auto& memory = system.GetMemory();
auto& mmu = system.GetMMU();
u32 page_base = haystack_start & 0xfffff000;
@ -150,8 +150,8 @@ struct EffectiveAddressSpaceAccessors : Accessors
return false;
}
std::size_t chunk_size = std::min<std::size_t>(0x1000 - offset, needle_size);
u8* page_ptr = memory.GetPointerForRange(*page_physical_address + offset, chunk_size);
const std::size_t chunk_size = std::min<std::size_t>(0x1000 - offset, needle_size);
const u8* page_ptr = memory.GetPointerForRange(*page_physical_address + offset, chunk_size);
if (page_ptr == nullptr)
{
return false;
@ -248,8 +248,9 @@ struct AuxiliaryAddressSpaceAccessors : Accessors
else
{
// using reverse iterator will also search the element in reverse
auto reverse_end = std::make_reverse_iterator(begin() + needle_size - 1);
auto it = std::search(std::make_reverse_iterator(begin() + haystack_offset + needle_size - 1),
const auto reverse_end = std::make_reverse_iterator(begin() + needle_size - 1);
const auto it =
std::search(std::make_reverse_iterator(begin() + haystack_offset + needle_size - 1),
reverse_end, std::make_reverse_iterator(needle_start + needle_size),
std::make_reverse_iterator(needle_start));
result = (it == reverse_end) ? end() : (&(*it) - needle_size + 1);
@ -287,7 +288,7 @@ struct CompositeAddressSpaceAccessors : Accessors
u8 ReadU8(const Core::CPUThreadGuard& guard, u32 address) const override
{
auto mapping = FindAppropriateAccessor(guard, address);
const auto mapping = FindAppropriateAccessor(guard, address);
if (mapping == m_accessor_mappings.end())
{
return 0;
@ -297,7 +298,7 @@ struct CompositeAddressSpaceAccessors : Accessors
void WriteU8(const Core::CPUThreadGuard& guard, u32 address, u8 value) override
{
auto mapping = FindAppropriateAccessor(guard, address);
const auto mapping = FindAppropriateAccessor(guard, address);
if (mapping == m_accessor_mappings.end())
{
return;
@ -311,7 +312,7 @@ struct CompositeAddressSpaceAccessors : Accessors
{
for (const AccessorMapping& mapping : m_accessor_mappings)
{
u32 mapping_offset = haystack_offset - mapping.base;
const u32 mapping_offset = haystack_offset - mapping.base;
if (!mapping.accessors->IsValidAddress(guard, mapping_offset))
{
continue;
@ -389,8 +390,9 @@ struct SmallBlockAccessors : Accessors
else
{
// using reverse iterator will also search the element in reverse
auto reverse_end = std::make_reverse_iterator(begin() + needle_size - 1);
auto it = std::search(std::make_reverse_iterator(begin() + haystack_offset + needle_size - 1),
const auto reverse_end = std::make_reverse_iterator(begin() + needle_size - 1);
const auto it =
std::search(std::make_reverse_iterator(begin() + haystack_offset + needle_size - 1),
reverse_end, std::make_reverse_iterator(needle_start + needle_size),
std::make_reverse_iterator(needle_start));
result = (it == reverse_end) ? end() : (&(*it) - needle_size + 1);
@ -470,7 +472,7 @@ Accessors* GetAccessors(Type address_space)
void Init()
{
auto& system = Core::System::GetInstance();
const auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory();
s_mem1_address_space_accessors = {&memory.GetRAM(), memory.GetRamSizeReal()};

View file

@ -89,7 +89,7 @@ void AudioInterfaceManager::DoState(PointerWrap& p)
p.Do(m_aid_sample_rate_divisor);
p.Do(m_cpu_cycles_per_sample);
SoundStream* sound_stream = m_system.GetSoundStream();
const SoundStream* sound_stream = m_system.GetSoundStream();
sound_stream->GetMixer()->DoState(p);
}
@ -124,8 +124,8 @@ void AudioInterfaceManager::IncreaseSampleCount(const u32 amount)
int AudioInterfaceManager::GetAIPeriod() const
{
u64 period = m_cpu_cycles_per_sample * (m_interrupt_timing - m_sample_counter);
u64 s_period =
const u64 period = m_cpu_cycles_per_sample * (m_interrupt_timing - m_sample_counter);
const u64 s_period =
m_cpu_cycles_per_sample * Mixer::FIXED_SAMPLE_RATE_DIVIDEND / m_ais_sample_rate_divisor;
if (period == 0)
return static_cast<int>(s_period);
@ -167,7 +167,7 @@ void AudioInterfaceManager::SetAIDSampleRate(SampleRate sample_rate)
m_aid_sample_rate_divisor = Get48KHzSampleRateDivisor();
}
SoundStream* sound_stream = m_system.GetSoundStream();
const SoundStream* sound_stream = m_system.GetSoundStream();
sound_stream->GetMixer()->SetDMAInputSampleRateDivisor(m_aid_sample_rate_divisor);
}
@ -186,7 +186,7 @@ void AudioInterfaceManager::SetAISSampleRate(SampleRate sample_rate)
m_cpu_cycles_per_sample = static_cast<u64>(m_system.GetSystemTimers().GetTicksPerSecond()) *
m_ais_sample_rate_divisor / Mixer::FIXED_SAMPLE_RATE_DIVIDEND;
SoundStream* sound_stream = m_system.GetSoundStream();
const SoundStream* sound_stream = m_system.GetSoundStream();
sound_stream->GetMixer()->SetStreamInputSampleRateDivisor(m_ais_sample_rate_divisor);
}
@ -281,15 +281,15 @@ void AudioInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& ai = system.GetAudioInterface();
ai.m_volume.hex = val;
SoundStream* sound_stream = system.GetSoundStream();
const SoundStream* sound_stream = system.GetSoundStream();
sound_stream->GetMixer()->SetStreamingVolume(ai.m_volume.left,
ai.m_volume.right);
}));
mmio->Register(base | AI_SAMPLE_COUNTER, MMIO::ComplexRead<u32>([](Core::System& system, u32) {
auto& ai = system.GetAudioInterface();
const auto& ai = system.GetAudioInterface();
const u64 cycles_streamed =
ai.IsPlaying() ? (system.GetCoreTiming().GetTicks() - ai.m_last_cpu_time) :
ai.IsPlaying() ? system.GetCoreTiming().GetTicks() - ai.m_last_cpu_time :
ai.m_last_cpu_time;
return ai.m_sample_counter +
static_cast<u32>(cycles_streamed / ai.m_cpu_cycles_per_sample);

View file

@ -143,7 +143,7 @@ void CPUManager::Run()
power_pc.GetMemChecks().HasAny())
{
m_state = State::Stepping;
PowerPC::CoreMode old_mode = power_pc.GetMode();
const PowerPC::CoreMode old_mode = power_pc.GetMode();
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
power_pc.SingleStep();
power_pc.SetMode(old_mode);

View file

@ -202,7 +202,7 @@ void DSPManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// AUDIO_DMA_START_HI requires a complex write handler
{AUDIO_DMA_START_LO, MMIO::Utils::LowPart(&m_audio_dma.SourceAddress), WMASK_LO_ALIGN_32BIT},
};
for (auto& mapped_var : directly_mapped_vars)
for (const auto& mapped_var : directly_mapped_vars)
{
mmio->Register(base | mapped_var.addr, MMIO::DirectRead<u16>(mapped_var.ptr),
mapped_var.wmask != WMASK_NONE ?
@ -221,15 +221,15 @@ void DSPManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
return dsp.m_dsp_emulator->DSP_ReadMailBoxHigh(true);
}),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
dsp.m_dsp_emulator->DSP_WriteMailBoxHigh(true, val);
}));
mmio->Register(base | DSP_MAIL_TO_DSP_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
return dsp.m_dsp_emulator->DSP_ReadMailBoxLow(true);
}),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
dsp.m_dsp_emulator->DSP_WriteMailBoxLow(true, val);
}));
mmio->Register(base | DSP_MAIL_FROM_DSP_HI, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
@ -243,14 +243,14 @@ void DSPManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}),
MMIO::InvalidWrite<u16>());
mmio->Register(base | DSP_MAIL_FROM_DSP_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
return dsp.m_dsp_emulator->DSP_ReadMailBoxLow(false);
}),
MMIO::InvalidWrite<u16>());
mmio->Register(
base | DSP_CONTROL, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
return (dsp.m_dsp_control.Hex & ~DSP_CONTROL_MASK) |
(dsp.m_dsp_emulator->DSP_ReadControlRegister() & DSP_CONTROL_MASK);
}),
@ -325,7 +325,7 @@ void DSPManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
base | AUDIO_DMA_CONTROL_LEN, MMIO::DirectRead<u16>(&m_audio_dma.AudioDMAControl.Hex),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& dsp = system.GetDSP();
bool already_enabled = dsp.m_audio_dma.AudioDMAControl.Enable;
const bool already_enabled = dsp.m_audio_dma.AudioDMAControl.Enable;
dsp.m_audio_dma.AudioDMAControl.Hex = val;
// Only load new values if we're not already doing a DMA transfer,
@ -353,7 +353,7 @@ void DSPManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::ComplexRead<u16>([](Core::System& system, u32) {
// remaining_blocks_count is zero-based. DreamMix World Fighters will hang if it
// never reaches zero.
auto& dsp = system.GetDSP();
const auto& dsp = system.GetDSP();
return (dsp.m_audio_dma.remaining_blocks_count > 0 ?
dsp.m_audio_dma.remaining_blocks_count - 1 :
0);
@ -375,7 +375,7 @@ void DSPManager::UpdateInterrupts()
// to the left of it. By doing:
// (DSP_CONTROL>>1) & DSP_CONTROL & MASK_OF_ALL_INTERRUPT_BITS
// We can check if any of the interrupts are enabled and active, all at once.
bool ints_set =
const bool ints_set =
(((m_dsp_control.Hex >> 1) & m_dsp_control.Hex & (INT_DSP | INT_ARAM | INT_AID)) != 0);
m_system.GetProcessorInterface().SetInterrupt(ProcessorInterface::INT_CAUSE_DSP, ints_set);
@ -429,7 +429,7 @@ void DSPManager::UpdateAudioDMA()
// Read audio at g_audioDMA.current_source_address in RAM and push onto an
// external audio fifo in the emulator, to be mixed with the disc
// streaming output.
auto& memory = m_system.GetMemory();
const auto& memory = m_system.GetMemory();
void* address = memory.GetPointerForRange(m_audio_dma.current_source_address, 32);
AudioCommon::SendAIBuffer(m_system, static_cast<short*>(address), 8);
@ -461,7 +461,7 @@ void DSPManager::Do_ARAM_DMA()
m_dsp_control.DMAState = 1;
// ARAM DMA transfer rate has been measured on real hw
int ticksToTransfer = (m_aram_dma.Cnt.count / 32) * 246;
const int ticksToTransfer = (m_aram_dma.Cnt.count / 32) * 246;
core_timing.ScheduleEvent(ticksToTransfer, m_event_type_complete_aram);
// Real hardware DMAs in 32byte chunks, but we can get by with 8byte chunks
@ -582,7 +582,7 @@ u8 DSPManager::ReadARAM(u32 address) const
}
else
{
auto& memory = m_system.GetMemory();
const auto& memory = m_system.GetMemory();
return memory.Read_U8(address & memory.GetRamMask());
}
}

View file

@ -72,7 +72,7 @@ static VFile* OpenROM_Archive(const char* path)
VDirFindFirst(archive, [](VFile* vf_) { return mCoreIsCompatible(vf_) != mPLATFORM_NONE; });
if (vf_archive)
{
size_t size = static_cast<size_t>(vf_archive->size(vf_archive));
const size_t size = static_cast<size_t>(vf_archive->size(vf_archive));
std::vector<u8> buffer(size);
vf_archive->seek(vf_archive, 0, SEEK_SET);
@ -88,7 +88,7 @@ static VFile* OpenROM_Archive(const char* path)
static VFile* OpenROM_Zip(const char* path)
{
VFile* vf{};
unzFile zip = unzOpen(path);
const unzFile zip = unzOpen(path);
if (!zip)
return nullptr;
do
@ -140,7 +140,7 @@ static VFile* OpenROM(const char* rom_path)
static std::array<u8, 20> GetROMHash(VFile* rom)
{
size_t size = rom->size(rom);
const size_t size = rom->size(rom);
u8* buffer = static_cast<u8*>(rom->map(rom, size, MAP_READ));
const auto digest = Common::SHA1::CalculateDigest(buffer, size);
@ -396,7 +396,7 @@ void Core::SetVideoBuffer()
m_core->currentVideoSize(m_core, &width, &height);
m_video_buffer.resize(width * height);
m_core->setVideoBuffer(m_core, m_video_buffer.data(), width);
if (auto host = m_host.lock())
if (const auto host = m_host.lock())
host->GameChanged();
}
@ -406,7 +406,7 @@ void Core::SetSampleRates()
blip_set_rates(m_core->getAudioChannel(m_core, 0), m_core->frequency(m_core), SAMPLE_RATE);
blip_set_rates(m_core->getAudioChannel(m_core, 1), m_core->frequency(m_core), SAMPLE_RATE);
SoundStream* sound_stream = m_system.GetSoundStream();
const SoundStream* sound_stream = m_system.GetSoundStream();
sound_stream->GetMixer()->SetGBAInputSampleRateDivisors(
m_device_number, Mixer::FIXED_SAMPLE_RATE_DIVIDEND / SAMPLE_RATE);
}
@ -416,12 +416,12 @@ void Core::AddCallbacks()
mCoreCallbacks callbacks{};
callbacks.context = this;
callbacks.keysRead = [](void* context) {
auto core = static_cast<Core*>(context);
const auto core = static_cast<Core*>(context);
core->m_core->setKeys(core->m_core, core->m_keys);
};
callbacks.videoFrameEnded = [](void* context) {
auto core = static_cast<Core*>(context);
if (auto host = core->m_host.lock())
const auto core = static_cast<Core*>(context);
if (const auto host = core->m_host.lock())
host->FrameEnded(core->m_video_buffer);
};
m_core->addCoreCallbacks(m_core, &callbacks);
@ -432,16 +432,16 @@ void Core::SetAVStream()
m_stream = {};
m_stream.core = this;
m_stream.videoDimensionsChanged = [](mAVStream* stream, unsigned width, unsigned height) {
auto core = static_cast<AVStream*>(stream)->core;
const auto core = static_cast<AVStream*>(stream)->core;
core->SetVideoBuffer();
};
m_stream.postAudioBuffer = [](mAVStream* stream, blip_t* left, blip_t* right) {
auto core = static_cast<AVStream*>(stream)->core;
const auto core = static_cast<AVStream*>(stream)->core;
std::vector<s16> buffer(SAMPLES * 2);
blip_read_samples(left, &buffer[0], SAMPLES, 1);
blip_read_samples(right, &buffer[1], SAMPLES, 1);
SoundStream* sound_stream = core->m_system.GetSoundStream();
const SoundStream* sound_stream = core->m_system.GetSoundStream();
sound_stream->GetMixer()->PushGBASamples(core->m_device_number, &buffer[0], SAMPLES);
};
m_core->setAVStream(m_core, &m_stream);
@ -541,7 +541,7 @@ void Core::RunCommand(Command& command)
m_response.clear();
if (m_link_enabled && !m_force_disconnect)
{
int recvd = GBASIOJOYSendCommand(
const int recvd = GBASIOJOYSendCommand(
&m_sio_driver, static_cast<GBASIOJOYCommand>(command.buffer[0]), &command.buffer[1]);
std::copy_n(command.buffer.begin() + 1, recvd, std::back_inserter(m_response));
}
@ -573,12 +573,12 @@ void Core::RunUntil(u64 gc_ticks)
static_cast<s32>((gc_ticks - m_last_gc_ticks) * core_frequency / gc_frequency));
m_waiting_for_event = true;
s32 begin_time = mTimingCurrentTime(m_core->timing);
const s32 begin_time = mTimingCurrentTime(m_core->timing);
while (m_waiting_for_event)
m_core->runLoop(m_core);
s32 end_time = mTimingCurrentTime(m_core->timing);
const s32 end_time = mTimingCurrentTime(m_core->timing);
u64 d = (static_cast<u64>(end_time - begin_time) * gc_frequency) + m_gc_ticks_remainder;
const u64 d = (static_cast<u64>(end_time - begin_time) * gc_frequency) + m_gc_ticks_remainder;
m_last_gc_ticks += d / core_frequency;
m_gc_ticks_remainder = d % core_frequency;
}
@ -640,7 +640,7 @@ void Core::ExportSave(std::string_view save_path)
File::IOFile file(std::string(save_path), "wb");
void* sram = nullptr;
size_t size = m_core->savedataClone(m_core, &sram);
const size_t size = m_core->savedataClone(m_core, &sram);
if (!sram)
return;
@ -661,9 +661,9 @@ void Core::DoState(PointerWrap& p)
bool has_rom = !m_rom_path.empty();
p.Do(has_rom);
auto old_hash = m_rom_hash;
const auto old_hash = m_rom_hash;
p.Do(m_rom_hash);
auto old_title = m_game_title;
const auto old_title = m_game_title;
p.Do(m_game_title);
if (p.IsReadMode() && (has_rom != !m_rom_path.empty() ||
@ -697,7 +697,7 @@ void Core::DoState(PointerWrap& p)
if (p.IsReadMode() && m_core->stateSize(m_core) == core_state.size())
{
m_core->loadState(m_core, core_state.data());
if (auto host = m_host.lock())
if (const auto host = m_host.lock())
host->FrameEnded(m_video_buffer);
}
}

View file

@ -84,7 +84,7 @@ void GPFifoManager::ResetGatherPipe()
void GPFifoManager::UpdateGatherPipe()
{
auto& system = m_system;
const auto& system = m_system;
auto& memory = system.GetMemory();
auto& processor_interface = system.GetProcessorInterface();

View file

@ -217,7 +217,7 @@ bool MemoryManager::InitFastmemArena()
continue;
u8* base = m_physical_base + region.physical_address;
u8* view = (u8*)m_arena.MapInMemoryRegion(region.shm_position, region.size, base);
const u8* view = (u8*)m_arena.MapInMemoryRegion(region.shm_position, region.size, base);
if (base != view)
{
@ -235,7 +235,7 @@ bool MemoryManager::InitFastmemArena()
void MemoryManager::UpdateLogicalMemory(const PowerPC::BatTable& dbat_table)
{
for (auto& entry : m_logical_mapped_entries)
for (const auto& entry : m_logical_mapped_entries)
{
m_arena.UnmapFromMemoryRegion(entry.mapped_pointer, entry.mapped_size);
}
@ -247,9 +247,9 @@ void MemoryManager::UpdateLogicalMemory(const PowerPC::BatTable& dbat_table)
{
if (dbat_table[i] & PowerPC::BAT_PHYSICAL_BIT)
{
u32 logical_address = i << PowerPC::BAT_INDEX_SHIFT;
const u32 logical_address = i << PowerPC::BAT_INDEX_SHIFT;
// TODO: Merge adjacent mappings to make this faster.
u32 logical_size = PowerPC::BAT_PAGE_SIZE;
const u32 logical_size = PowerPC::BAT_PAGE_SIZE;
u32 translated_address = dbat_table[i] & PowerPC::BAT_RESULT_MASK;
for (const auto& physical_region : m_physical_regions)
{
@ -258,17 +258,18 @@ void MemoryManager::UpdateLogicalMemory(const PowerPC::BatTable& dbat_table)
u32 mapping_address = physical_region.physical_address;
u32 mapping_end = mapping_address + physical_region.size;
u32 intersection_start = std::max(mapping_address, translated_address);
u32 intersection_end = std::min(mapping_end, translated_address + logical_size);
const u32 intersection_start = std::max(mapping_address, translated_address);
const u32 intersection_end = std::min(mapping_end, translated_address + logical_size);
if (intersection_start < intersection_end)
{
// Found an overlapping region; map it.
if (m_is_fastmem_arena_initialized)
{
u32 position = physical_region.shm_position + intersection_start - mapping_address;
const u32 position =
physical_region.shm_position + intersection_start - mapping_address;
u8* base = m_logical_base + logical_address + intersection_start - translated_address;
u32 mapped_size = intersection_end - intersection_start;
const u32 mapped_size = intersection_end - intersection_start;
void* mapped_pointer = m_arena.MapInMemoryRegion(position, mapped_size, base);
if (!mapped_pointer)
@ -371,7 +372,7 @@ void MemoryManager::ShutdownFastmemArena()
m_arena.UnmapFromMemoryRegion(base, region.size);
}
for (auto& entry : m_logical_mapped_entries)
for (const auto& entry : m_logical_mapped_entries)
{
m_arena.UnmapFromMemoryRegion(entry.mapped_pointer, entry.mapped_size);
}
@ -425,7 +426,7 @@ void MemoryManager::CopyFromEmu(void* data, u32 address, size_t size) const
if (size == 0)
return;
void* pointer = GetPointerForRange(address, size);
const void* pointer = GetPointerForRange(address, size);
if (!pointer)
{
PanicAlertFmt("Invalid range in CopyFromEmu. {:x} bytes from {:#010x}", size, address);
@ -483,7 +484,7 @@ std::string MemoryManager::GetString(u32 em_address, size_t size)
{
result.resize(size);
CopyFromEmu(result.data(), em_address, size);
size_t length = strnlen(result.data(), size);
const size_t length = strnlen(result.data(), size);
result.resize(length);
return result;
}
@ -506,7 +507,7 @@ std::span<u8> MemoryManager::GetSpanForAddress(u32 address) const
}
}
auto& ppc_state = m_system.GetPPCState();
const auto& ppc_state = m_system.GetPPCState();
PanicAlertFmt("Unknown Pointer {:#010x} PC {:#010x} LR {:#010x}", address, ppc_state.pc,
LR(ppc_state));
return {};
@ -547,19 +548,19 @@ void MemoryManager::Write_U8(u8 value, u32 address)
void MemoryManager::Write_U16(u16 value, u32 address)
{
u16 swapped_value = Common::swap16(value);
const u16 swapped_value = Common::swap16(value);
CopyToEmu(address, &swapped_value, sizeof(swapped_value));
}
void MemoryManager::Write_U32(u32 value, u32 address)
{
u32 swapped_value = Common::swap32(value);
const u32 swapped_value = Common::swap32(value);
CopyToEmu(address, &swapped_value, sizeof(swapped_value));
}
void MemoryManager::Write_U64(u64 value, u32 address)
{
u64 swapped_value = Common::swap64(value);
const u64 swapped_value = Common::swap64(value);
CopyToEmu(address, &swapped_value, sizeof(swapped_value));
}

View file

@ -117,7 +117,7 @@ void ProcessorInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}));
mmio->Register(base | PI_RESET_CODE, MMIO::ComplexRead<u32>([](Core::System& system, u32) {
auto& processor_interface = system.GetProcessorInterface();
const auto& processor_interface = system.GetProcessorInterface();
DEBUG_LOG_FMT(PROCESSORINTERFACE, "Read PI_RESET_CODE: {:08x}",
processor_interface.m_reset_code);
return processor_interface.m_reset_code;
@ -239,7 +239,7 @@ void ProcessorInterfaceManager::IOSNotifyResetButtonCallback(Core::System& syste
if (!ios)
return;
auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
const auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->ResetButton();
}
@ -251,7 +251,7 @@ void ProcessorInterfaceManager::IOSNotifyPowerButtonCallback(Core::System& syste
if (!ios)
return;
auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
const auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->PowerButton();
}

View file

@ -83,7 +83,7 @@ void FixSRAMChecksums(Sram* sram)
for (auto p = reinterpret_cast<u16*>(&sram->settings.rtc_bias);
p != reinterpret_cast<u16*>(&sram->settings_ex); p++)
{
u16 value = Common::FromBigEndian(*p);
const u16 value = Common::FromBigEndian(*p);
checksum += value;
checksum_inv += ~value;
}

View file

@ -89,7 +89,7 @@ static int GetAudioDMACallbackPeriod(u32 cpu_core_clock, u32 aid_sample_rate_div
void SystemTimersManager::AudioDMACallback(Core::System& system, u64 userdata, s64 cycles_late)
{
system.GetDSP().UpdateAudioDMA(); // Push audio to speakers.
auto& system_timers = system.GetSystemTimers();
const auto& system_timers = system.GetSystemTimers();
const int callback_period = GetAudioDMACallbackPeriod(
system_timers.m_cpu_core_clock, system.GetAudioInterface().GetAIDSampleRateDivisor());
system.GetCoreTiming().ScheduleEvent(callback_period - cycles_late,
@ -102,7 +102,7 @@ void SystemTimersManager::IPC_HLE_UpdateCallback(Core::System& system, u64 userd
if (system.IsWii())
{
system.GetIOS()->UpdateDevices();
auto& system_timers = system.GetSystemTimers();
const auto& system_timers = system.GetSystemTimers();
system.GetCoreTiming().ScheduleEvent(system_timers.m_ipc_hle_period - cycles_late,
system_timers.m_event_type_ipc_hle);
}
@ -115,7 +115,7 @@ void SystemTimersManager::GPUSleepCallback(Core::System& system, u64 userdata, s
// We want to call GpuMaySleep at about 1000hz so
// that the thread can sleep while not doing anything.
auto& system_timers = system.GetSystemTimers();
const auto& system_timers = system.GetSystemTimers();
core_timing.ScheduleEvent(system_timers.GetTicksPerSecond() / 1000 - cycles_late,
system_timers.m_event_type_gpu_sleeper);
}
@ -140,7 +140,7 @@ void SystemTimersManager::PatchEngineCallback(Core::System& system, u64 userdata
{
// We have 2 periods, a 1000 cycle error period and the VI period.
// We have to carefully combine these together so that we stay on the VI period without drifting.
u32 vi_interval = system.GetVideoInterface().GetTicksPerField();
const u32 vi_interval = system.GetVideoInterface().GetTicksPerField();
s64 cycles_pruned = (userdata + cycles_late) % vi_interval;
s64 next_schedule = 0;
@ -176,9 +176,9 @@ u32 SystemTimersManager::GetTicksPerSecond() const
void SystemTimersManager::DecrementerSet()
{
auto& core_timing = m_system.GetCoreTiming();
auto& ppc_state = m_system.GetPPCState();
const auto& ppc_state = m_system.GetPPCState();
u32 decValue = ppc_state.spr[SPR_DEC];
const u32 decValue = ppc_state.spr[SPR_DEC];
core_timing.RemoveEvent(m_event_type_decrementer);
if ((decValue & 0x80000000) == 0)
@ -258,7 +258,7 @@ void SystemTimersManager::Init()
}
auto& core_timing = m_system.GetCoreTiming();
auto& vi = m_system.GetVideoInterface();
const auto& vi = m_system.GetVideoInterface();
core_timing.SetFakeTBStartValue(static_cast<u64>(m_cpu_core_clock / TIMER_RATIO) *
static_cast<u64>(ExpansionInterface::CEXIIPL::GetEmulatedTime(

View file

@ -151,7 +151,7 @@ void VideoInterfaceManager::Preset(bool _bNTSC)
m_filter_coef_tables = {};
m_unknown_aa_register = 0;
DiscIO::Region region = SConfig::GetInstance().m_region;
const DiscIO::Region region = SConfig::GetInstance().m_region;
// 54MHz, capable of progressive scan
m_clock = DiscIO::IsNTSC(region);
@ -183,7 +183,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
u16* ptr;
};
std::array<MappedVar, 46> directly_mapped_vars{{
const std::array<MappedVar, 46> directly_mapped_vars{{
{VI_VERTICAL_TIMING, &m_vertical_timing_register.Hex},
{VI_HORIZONTAL_TIMING_0_HI, &m_h_timing_0.Hi},
{VI_HORIZONTAL_TIMING_0_LO, &m_h_timing_0.Lo},
@ -233,7 +233,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}};
// Declare all the boilerplate direct MMIOs.
for (auto& mapped_var : directly_mapped_vars)
for (const auto& mapped_var : directly_mapped_vars)
{
mmio->Register(base | mapped_var.addr, MMIO::DirectRead<u16>(mapped_var.ptr),
MMIO::DirectWrite<u16>(mapped_var.ptr));
@ -293,7 +293,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// MMIOs with unimplemented writes that trigger warnings.
mmio->Register(
base | VI_VERTICAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& vi = system.GetVideoInterface();
const auto& vi = system.GetVideoInterface();
return 1 + (vi.m_half_line_count) / 2;
}),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
@ -303,8 +303,8 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}));
mmio->Register(
base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& vi = system.GetVideoInterface();
u16 value = static_cast<u16>(
const auto& vi = system.GetVideoInterface();
const u16 value = static_cast<u16>(
1 + vi.m_h_timing_0.HLW *
(system.GetCoreTiming().GetTicks() - vi.m_ticks_last_line_start) /
(vi.GetTicksPerHalfLine()));
@ -349,7 +349,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// Unknown anti-aliasing related MMIO register: puts a warning on log and
// needs to shift/mask when reading/writing.
mmio->Register(base | VI_UNK_AA_REG_HI, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& vi = system.GetVideoInterface();
const auto& vi = system.GetVideoInterface();
return vi.m_unknown_aa_register >> 16;
}),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
@ -359,7 +359,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (hi)");
}));
mmio->Register(base | VI_UNK_AA_REG_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
auto& vi = system.GetVideoInterface();
const auto& vi = system.GetVideoInterface();
return vi.m_unknown_aa_register & 0xFFFF;
}),
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
@ -374,7 +374,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
auto& vi = system.GetVideoInterface();
UVIDisplayControlRegister tmpConfig(val);
const UVIDisplayControlRegister tmpConfig(val);
vi.m_display_control_register.ENB = tmpConfig.ENB;
vi.m_display_control_register.NIN = tmpConfig.NIN;
vi.m_display_control_register.DLR = tmpConfig.DLR;
@ -480,15 +480,15 @@ float VideoInterfaceManager::GetAspectRatio() const
// multiply the result by 1.33333... (the ratio between 16:9 and 4:3)
// 1. Get our active area in BT.601 samples (more or less pixels)
int active_lines = m_vertical_timing_register.ACV;
int active_width_samples = (m_h_timing_0.HLW + m_h_timing_1.HBS640 - m_h_timing_1.HBE640);
const int active_lines = m_vertical_timing_register.ACV;
const int active_width_samples = (m_h_timing_0.HLW + m_h_timing_1.HBS640 - m_h_timing_1.HBE640);
// 2. TVs are analog and don't have pixels. So we convert to seconds.
float tick_length = (1.0f / m_system.GetSystemTimers().GetTicksPerSecond());
float vertical_period = tick_length * GetTicksPerField();
float horizontal_period = tick_length * GetTicksPerHalfLine() * 2;
float vertical_active_area = active_lines * horizontal_period;
float horizontal_active_area = tick_length * GetTicksPerSample() * active_width_samples;
const float tick_length = (1.0f / m_system.GetSystemTimers().GetTicksPerSecond());
const float vertical_period = tick_length * GetTicksPerField();
const float horizontal_period = tick_length * GetTicksPerHalfLine() * 2;
const float vertical_active_area = active_lines * horizontal_period;
const float horizontal_active_area = tick_length * GetTicksPerSample() * active_width_samples;
// We are approximating the horizontal/vertical flyback transformers that control the
// position of the electron beam on the screen. Our flyback transformers create a
@ -544,7 +544,7 @@ float VideoInterfaceManager::GetAspectRatio() const
}
// 5. Calculate the final ratio and scale to 4:3
float ratio = horizontal_active_ratio / vertical_active_ratio;
const float ratio = horizontal_active_ratio / vertical_active_ratio;
const bool running_fifo_log = m_system.GetFifoPlayer().IsRunningWithFakeVideoInterfaceUpdates();
if (std::isnormal(ratio) && // Check we have a sane ratio without any infs/nans/zeros
!running_fifo_log) // we don't know the correct ratio for fifos
@ -772,14 +772,14 @@ void VideoInterfaceManager::OutputField(FieldType field, u64 ticks)
{
// Could we fit a second line of data in the stride?
// (Datel's Wii FreeLoaders are the only titles known to set WPL to 0)
bool potentially_interlaced_xfb =
const bool potentially_interlaced_xfb =
m_picture_configuration.WPL != 0 &&
((m_picture_configuration.STD / m_picture_configuration.WPL) == 2);
// Are there an odd number of half-lines per field (definition of interlaced video)
bool interlaced_video_mode = (GetHalfLinesPerEvenField() & 1) == 1;
const bool interlaced_video_mode = (GetHalfLinesPerEvenField() & 1) == 1;
u32 fbStride = m_picture_configuration.STD * 16;
u32 fbWidth = m_picture_configuration.WPL * 16;
const u32 fbWidth = m_picture_configuration.WPL * 16;
u32 fbHeight = m_vertical_timing_register.ACV;
u32 xfbAddr;
@ -961,7 +961,7 @@ void VideoInterfaceManager::Update(u64 ticks)
for (UVIInterruptRegister& reg : m_interrupt_register)
{
u32 target_halfline = (reg.HCT > m_h_timing_0.HLW) ? 1 : 0;
const u32 target_halfline = (reg.HCT > m_h_timing_0.HLW) ? 1 : 0;
if ((1 + (m_half_line_count) / 2 == reg.VCT) && ((m_half_line_count & 1) == target_halfline))
{
reg.IR_INT = 1;
@ -975,7 +975,7 @@ void VideoInterfaceManager::Update(u64 ticks)
void VideoInterfaceManager::FakeVIUpdate(u32 xfb_address, u32 fb_width, u32 fb_stride,
u32 fb_height)
{
bool interlaced = fb_height > 480 / 2;
const bool interlaced = fb_height > 480 / 2;
if (interlaced)
{
fb_height = fb_height / 2;
@ -995,7 +995,7 @@ void VideoInterfaceManager::FakeVIUpdate(u32 xfb_address, u32 fb_width, u32 fb_s
UpdateParameters();
u32 total_halflines = GetHalfLinesPerEvenField() + GetHalfLinesPerOddField();
const u32 total_halflines = GetHalfLinesPerEvenField() + GetHalfLinesPerOddField();
if ((m_half_line_count - m_even_field_first_hl) % total_halflines <
(m_half_line_count - m_odd_field_first_hl) % total_halflines)

View file

@ -300,7 +300,7 @@ public:
return {};
}
Md5 md5_file = header.md5;
const Md5 md5_file = header.md5;
header.md5 = s_md5_blanker;
Md5 md5_calc;
mbedtls_md5_ret(reinterpret_cast<const u8*>(&header), sizeof(Header), md5_calc.data());
@ -449,7 +449,7 @@ private:
Common::SHA1::Digest data_sha1;
{
const u32 data_size = bk_header->size_of_files + sizeof(BkHeader);
auto data = std::make_unique<u8[]>(data_size);
const auto data = std::make_unique<u8[]>(data_size);
m_file.Seek(sizeof(Header), File::SeekOrigin::Begin);
if (!m_file.ReadBytes(data.get(), data_size))
return false;