bsnes/higan/gba/system/system.cpp

71 lines
1.5 KiB
C++

#include <gba/gba.hpp>
namespace GameBoyAdvance {
#include "bios.cpp"
#include "serialization.cpp"
BIOS bios;
System system;
auto System::init() -> void {
}
auto System::term() -> void {
}
auto System::power() -> void {
bus.power();
player.power();
cpu.power();
ppu.power();
apu.power();
cartridge.power();
scheduler.power();
}
auto System::load() -> void {
interface->loadRequest(ID::SystemManifest, "manifest.bml", true);
auto document = BML::unserialize(information.manifest);
if(auto bios = document["system/cpu/rom/name"].text()) {
interface->loadRequest(ID::BIOS, bios, true);
}
serialize_init();
}
auto System::run() -> void {
while(true) {
scheduler.enter();
if(scheduler.exit_reason() == Scheduler::ExitReason::FrameEvent) break;
}
interface->videoRefresh(video.palette, ppu.output, 4 * 240, 240, 160);
}
auto System::runtosave() -> void {
scheduler.sync = Scheduler::SynchronizeMode::CPU;
runthreadtosave();
scheduler.sync = Scheduler::SynchronizeMode::All;
scheduler.active = ppu.thread;
runthreadtosave();
scheduler.sync = Scheduler::SynchronizeMode::All;
scheduler.active = apu.thread;
runthreadtosave();
scheduler.sync = Scheduler::SynchronizeMode::None;
}
auto System::runthreadtosave() -> void {
while(true) {
scheduler.enter();
if(scheduler.exit_reason() == Scheduler::ExitReason::SynchronizeEvent) break;
if(scheduler.exit_reason() == Scheduler::ExitReason::FrameEvent) {
interface->videoRefresh(video.palette, ppu.output, 4 * 240, 240, 160);
}
}
}
}