2016-08-17 12:31:22 +00:00
|
|
|
#include <ms/ms.hpp>
|
|
|
|
|
|
|
|
namespace MasterSystem {
|
|
|
|
|
|
|
|
System system;
|
|
|
|
Scheduler scheduler;
|
|
|
|
|
|
|
|
auto System::run() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
if(scheduler.enter() == Scheduler::Event::Frame) vdp.refresh();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
2016-08-19 14:11:26 +00:00
|
|
|
auto System::load(Model model) -> bool {
|
|
|
|
information = {};
|
|
|
|
information.model = model;
|
|
|
|
|
|
|
|
if(auto fp = interface->open(ID::System, "manifest.bml", File::Read, File::Required)) {
|
|
|
|
information.manifest = fp->reads();
|
|
|
|
} else return false;
|
|
|
|
|
|
|
|
auto document = BML::unserialize(information.manifest);
|
|
|
|
if(!cartridge.load()) return false;
|
|
|
|
|
|
|
|
information.colorburst = Emulator::Constants::Colorburst::NTSC;
|
|
|
|
return information.loaded = true;
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::save() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
cartridge.save();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::unload() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
cartridge.unload();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::power() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
cartridge.power();
|
|
|
|
cpu.power();
|
|
|
|
vdp.power();
|
|
|
|
psg.power();
|
|
|
|
reset();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::reset() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
Emulator::video.reset();
|
|
|
|
Emulator::video.setInterface(interface);
|
|
|
|
Emulator::video.setPalette();
|
|
|
|
|
|
|
|
Emulator::audio.reset();
|
|
|
|
Emulator::audio.setInterface(interface);
|
|
|
|
|
|
|
|
scheduler.reset();
|
|
|
|
cartridge.reset();
|
|
|
|
cpu.reset();
|
|
|
|
vdp.reset();
|
|
|
|
psg.reset();
|
|
|
|
scheduler.primary(cpu);
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|