mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-10-05 05:41:35 +02:00
byuu says: Changelog: - int_t<bits> replaced with Integer<bits> - uint_t<bits> replaced with Natural<bits> - fixed "Synchronize Audio" menu option that broke recently - all of sfc/performance ported to "auto function() -> return;" syntax With this WIP, all of higan is finally ported over to the new function declaration syntax. Thank the gods. There's still going to be periodic disruption for diffs from porting over signed->int, unsigned->uint, and whatever we come up with for the new Natural<> and Integer<> classes. But the worst of it's behind us now.
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
auto Program::stateName(unsigned slot, bool manager) -> string {
|
|
return {
|
|
folderPaths[0], "higan/states/",
|
|
manager ? "managed/" : "quick/",
|
|
"slot-", natural(slot, 2L), ".bst"
|
|
};
|
|
}
|
|
|
|
auto Program::loadState(unsigned slot, bool manager) -> bool {
|
|
if(!emulator) return false;
|
|
auto location = stateName(slot, manager);
|
|
auto memory = file::read(location);
|
|
if(memory.size() == 0) return showMessage({"Slot ", slot, " does not exist"}), false;
|
|
serializer s(memory.data(), memory.size());
|
|
if(emulator->unserialize(s) == false) return showMessage({"Slot ", slot, " state incompatible"}), false;
|
|
return showMessage({"Loaded from slot ", slot}), true;
|
|
}
|
|
|
|
auto Program::saveState(unsigned slot, bool manager) -> bool {
|
|
if(!emulator) return false;
|
|
auto location = stateName(slot, manager);
|
|
serializer s = emulator->serialize();
|
|
if(s.size() == 0) return showMessage({"Failed to save state to slot ", slot}), false;
|
|
directory::create(pathname(location));
|
|
if(file::write(location, s.data(), s.size()) == false) {
|
|
return showMessage({"Unable to write to slot ", slot}), false;
|
|
}
|
|
return showMessage({"Saved to slot ", slot}), true;
|
|
}
|