ares-openbsd/desktop-ui/emulator/supergrafx.cpp

48 行
1.1 KiB
C++

struct SuperGrafx : PCEngine {
SuperGrafx();
auto load() -> bool override;
auto save() -> bool override;
auto pak(ares::Node::Object) -> shared_pointer<vfs::directory> override;
};
SuperGrafx::SuperGrafx() {
manufacturer = "NEC";
name = "SuperGrafx";
allocatePorts();
}
auto SuperGrafx::load() -> bool {
game = mia::Medium::create("SuperGrafx");
if(!game->load(Emulator::load(game, configuration.game))) return false;
system = mia::System::create("SuperGrafx");
if(!system->load()) return false;
ares::PCEngine::option("Pixel Accuracy", settings.video.pixelAccuracy);
if(!ares::PCEngine::load(root, "[NEC] SuperGrafx (NTSC-J)")) return false;
if(auto port = root->find<ares::Node::Port>("Cartridge Slot")) {
port->allocate();
port->connect();
}
connectPorts();
return true;
}
auto SuperGrafx::save() -> bool {
root->save();
system->save(game->location);
game->save(game->location);
return true;
}
auto SuperGrafx::pak(ares::Node::Object node) -> shared_pointer<vfs::directory> {
if(node->name() == "SuperGrafx") return system->pak;
if(node->name() == "SuperGrafx Card") return game->pak;
return {};
}