-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.cpp
50 lines (37 loc) · 1.09 KB
/
System.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "pch.h"
#include "System.h"
System::System() :
cpu(mmu),
mmu(cartridge) {
SPDLOG_INFO("System created");
}
System::~System() {
SPDLOG_INFO("System shut down");
}
void System::LoadCartridge(const char *path) {
VERIFY(!running, "Cannot load cartridge while system is running");
VERIFY(path != nullptr, "Cannot load cartridge from null path");
SPDLOG_INFO("System loading cartridge from {}", path);
cartridge.LoadFromPath(path);
}
void System::Run() {
SPDLOG_INFO("System running");
running = true;
cpu.Run();
}
void System::PowerOn() {
VERIFY(!running, "Cannot power on system while it is running");
VERIFY(cartridge.IsLoaded(), "Cannot power on system without a cartridge");
SPDLOG_INFO("System setting power on state");
cartridge.PowerOn();
mmu.PowerOn();
// Power on CPU last since it will implicitly read from the MMU
cpu.PowerOn();
SPDLOG_INFO("System powered on");
}
void System::Reset() {
cartridge.Reset();
mmu.Reset();
// Reset CPU last since it will implicitly read from the MMU
cpu.Reset();
}