From 5d89883d1553d16b9ca093b7362966dc24e54d31 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 21 Aug 2022 22:13:41 +0200 Subject: [PATCH] Emulator: Fix Emu memory writing --- src/emu.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/emu.cpp b/src/emu.cpp index f32f475..a850623 100644 --- a/src/emu.cpp +++ b/src/emu.cpp @@ -7,6 +7,8 @@ #include // uint32_t #include +#include // std::move +#include #include "cpu.h" #include "emu.h" @@ -50,13 +52,13 @@ void Emu::addMemorySpace(std::string_view name, uint32_t start_address, uint32_t .end_address = end_adress, }; - m_memory_spaces.emplace(name, memory_space); + m_memory_spaces.emplace(name, std::move(memory_space)); } void Emu::writeMemory(uint32_t address, uint32_t value) { for (auto& memory_space : m_memory_spaces) { - auto memory = memory_space.second; + auto& memory = memory_space.second; if (address >= memory.start_address && address <= memory.end_address) { // Note: ECHO RAM hack if (address >= 0xc000 && address <= 0xddff) { @@ -74,7 +76,7 @@ void Emu::writeMemory(uint32_t address, uint32_t value) uint32_t Emu::readMemory(uint32_t address) const { for (const auto& memory_space : m_memory_spaces) { - auto memory = memory_space.second; + const auto& memory = memory_space.second; if (address >= memory.start_address && address <= memory.end_address) { return memory.memory[memory.active_bank][address]; }