Browse Source

Emulator: Read bootrom into memory space

master
Riyyi 2 years ago
parent
commit
077ba70a16
  1. 12
      src/main.cpp

12
src/main.cpp

@ -8,6 +8,7 @@
#include "cpu.h"
#include "emu.h"
#include "ppu.h"
#include "ruc/file.h"
#include "ruc/format/print.h"
#include "ruc/timer.h"
@ -40,6 +41,17 @@ int main(int argc, char* argv[])
Emu::the().addMemorySpace("OAM", 0xfe00, 0xfe9f, 1); // 160B, Object Attribute Memory (VRAM Sprite Attribute Table)
Emu::the().addMemorySpace("HRAM", 0xff80, 0xfffe, 1); // 127B, High RAM (CPU cache)
// Load bootrom
auto bootrom = ruc::File("gbc_bios.bin").data();
for (size_t i = 0; i < bootrom.length(); ++i) {
// Skip cartridge header memory range
if (i >= 0x0100 && i <= 0x01ff) {
continue;
}
Emu::the().writeMemory(i, bootrom[i]);
}
// Get shared register
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a"));
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("b"));

Loading…
Cancel
Save