Emulator: Read bootrom in Emu class
This commit is contained in:
+4
-1
@@ -1,13 +1,16 @@
|
|||||||
#include <cstdint> // uint32_t
|
#include <cstdint> // uint32_t
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
#include "ruc/file.h"
|
||||||
#include "ruc/format/print.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_frequency = frequency;
|
||||||
m_timestep = 1.0 / m_frequency * 1000000;
|
m_timestep = 1.0 / m_frequency * 1000000;
|
||||||
|
m_bootrom = ruc::File(bootrom.data()).data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emu::update()
|
void Emu::update()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint> // uint32_t
|
#include <cstdint> // uint32_t
|
||||||
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ class Emu final : public ruc::Singleton<Emu> {
|
|||||||
public:
|
public:
|
||||||
Emu(s) {}
|
Emu(s) {}
|
||||||
|
|
||||||
void init(uint32_t frequency);
|
void init(uint32_t frequency, std::string_view bootrom);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
@@ -37,4 +38,6 @@ private:
|
|||||||
|
|
||||||
std::unordered_map<const char*, ProcessingUnit*> m_processing_units;
|
std::unordered_map<const char*, ProcessingUnit*> m_processing_units;
|
||||||
std::unordered_map<const char*, std::vector<uint32_t>> m_memory_spaces;
|
std::unordered_map<const char*, std::vector<uint32_t>> m_memory_spaces;
|
||||||
|
|
||||||
|
std::string_view m_bootrom;
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
print("{}ms\n", t.elapsedNanoseconds() / 1000000.0);
|
print("{}ms\n", t.elapsedNanoseconds() / 1000000.0);
|
||||||
|
|
||||||
Emu::the().init(8000000);
|
Emu::the().init(8000000, "gbc_bios.bin");
|
||||||
|
|
||||||
CPU cpu(8000000);
|
CPU cpu(8000000);
|
||||||
PPU ppu(4000000);
|
PPU ppu(4000000);
|
||||||
|
|||||||
Reference in New Issue
Block a user