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
|
auto Program::stateSave(u32 slot) -> bool {
if(!emulator) return false;
auto location = emulator->locate(emulator->game->location, {".bs", slot}, settings.paths.saves);
if(auto state = emulator->root->serialize()) {
if(file::write(location, {state.data(), state.size()})) {
showMessage({"Saved state to slot ", slot});
return true;
}
}
showMessage({"Failed to save state to slot ", slot});
return false;
}
auto Program::stateLoad(u32 slot) -> bool {
if(!emulator) return false;
auto location = emulator->locate(emulator->game->location, {".bs", slot}, settings.paths.saves);
if(auto memory = file::read(location)) {
serializer state{memory.data(), (u32)memory.size()};
if(emulator->root->unserialize(state)) {
showMessage({"Loaded state from slot ", slot});
return true;
}
}
showMessage({"Failed to load state from slot ", slot});
return false;
}
|