Browse Source

Emulator: Add checks for undefined memory spaces

master
Riyyi 2 years ago
parent
commit
e38e35ba81
  1. 7
      src/emu.cpp

7
src/emu.cpp

@ -12,6 +12,7 @@
#include "emu.h" #include "emu.h"
#include "ruc/file.h" #include "ruc/file.h"
#include "ruc/format/print.h" #include "ruc/format/print.h"
#include "ruc/meta/assert.h"
void Emu::init(uint32_t frequency, std::string_view bootrom) void Emu::init(uint32_t frequency, std::string_view bootrom)
{ {
@ -65,9 +66,11 @@ void Emu::writeMemory(uint32_t address, uint32_t value)
} }
memory.memory[memory.active_bank][address] = value; memory.memory[memory.active_bank][address] = value;
break; return;
} }
} }
VERIFY_NOT_REACHED();
} }
uint32_t Emu::readMemory(uint32_t address) const uint32_t Emu::readMemory(uint32_t address) const
@ -76,9 +79,9 @@ uint32_t Emu::readMemory(uint32_t address) const
auto memory = memory_space.second; auto memory = memory_space.second;
if (address >= memory.start_address && address <= memory.end_address) { if (address >= memory.start_address && address <= memory.end_address) {
return memory.memory[memory.active_bank][address]; return memory.memory[memory.active_bank][address];
break;
} }
} }
VERIFY_NOT_REACHED();
return 0; return 0;
} }

Loading…
Cancel
Save