Emulator housekeeping
This commit is contained in:
@@ -131,11 +131,13 @@ using ImGui::Text;
|
|||||||
|
|
||||||
void Emulator::Run() {
|
void Emulator::Run() {
|
||||||
if (!snes_.running() && loading_) {
|
if (!snes_.running() && loading_) {
|
||||||
|
// Setup and initialize memory
|
||||||
if (loading_ && !memory_setup_) {
|
if (loading_ && !memory_setup_) {
|
||||||
snes_.SetupMemory(*rom());
|
snes_.SetupMemory(*rom());
|
||||||
memory_setup_ = true;
|
memory_setup_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run the emulation
|
||||||
if (rom()->isLoaded() && power_) {
|
if (rom()->isLoaded() && power_) {
|
||||||
snes_.Init(*rom());
|
snes_.Init(*rom());
|
||||||
running_ = true;
|
running_ = true;
|
||||||
|
|||||||
@@ -73,6 +73,29 @@ class MockMemory : public Memory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Initialize(const std::vector<uint8_t>& romData) {
|
||||||
|
// 16 MB, simplifying the memory layout for testing
|
||||||
|
memory_.resize(0x1000000);
|
||||||
|
|
||||||
|
// Clear memory
|
||||||
|
std::fill(memory_.begin(), memory_.end(), 0);
|
||||||
|
|
||||||
|
// Load ROM data into mock memory
|
||||||
|
size_t romSize = romData.size();
|
||||||
|
size_t romAddress = 0;
|
||||||
|
const size_t ROM_CHUNK_SIZE = 0x8000; // 32 KB
|
||||||
|
for (size_t bank = 0x00; bank <= 0xBF; bank += 0x80) {
|
||||||
|
for (size_t offset = 0x8000; offset <= 0xFFFF; offset += ROM_CHUNK_SIZE) {
|
||||||
|
if (romAddress < romSize) {
|
||||||
|
std::copy(romData.begin() + romAddress,
|
||||||
|
romData.begin() + romAddress + ROM_CHUNK_SIZE,
|
||||||
|
memory_.begin() + (bank << 16) + offset);
|
||||||
|
romAddress += ROM_CHUNK_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
ON_CALL(*this, ReadByte(::testing::_))
|
ON_CALL(*this, ReadByte(::testing::_))
|
||||||
.WillByDefault(
|
.WillByDefault(
|
||||||
|
|||||||
Reference in New Issue
Block a user