Browse Source

Emulator: Read bootrom in Emu class

master
Riyyi 2 years ago
parent
commit
3163d0cb95
  1. 5
      src/emu.cpp
  2. 5
      src/emu.h
  3. 2
      src/main.cpp

5
src/emu.cpp

@ -1,13 +1,16 @@
#include <cstdint> // uint32_t
#include <string_view>
#include "cpu.h"
#include "emu.h"
#include "ruc/file.h"
#include "ruc/format/print.h"
void Emu::init(uint32_t frequency)
void Emu::init(uint32_t frequency, std::string_view bootrom)
{
m_frequency = frequency;
m_timestep = 1.0 / m_frequency * 1000000;
m_bootrom = ruc::File(bootrom.data()).data();
}
void Emu::update()

5
src/emu.h

@ -1,6 +1,7 @@
#pragma once
#include <cstdint> // uint32_t
#include <string_view>
#include <unordered_map>
#include <vector>
@ -12,7 +13,7 @@ class Emu final : public ruc::Singleton<Emu> {
public:
Emu(s) {}
void init(uint32_t frequency);
void init(uint32_t frequency, std::string_view bootrom);
void update();
@ -37,4 +38,6 @@ private:
std::unordered_map<const char*, ProcessingUnit*> m_processing_units;
std::unordered_map<const char*, std::vector<uint32_t>> m_memory_spaces;
std::string_view m_bootrom;
};

2
src/main.cpp

@ -15,7 +15,7 @@ int main(int argc, char* argv[])
print("{}ms\n", t.elapsedNanoseconds() / 1000000.0);
Emu::the().init(8000000);
Emu::the().init(8000000, "gbc_bios.bin");
CPU cpu(8000000);
PPU ppu(4000000);

Loading…
Cancel
Save