Skip to content

Commit

Permalink
fc: Save FDS disk when saving Famicom system (#1725)
Browse files Browse the repository at this point in the history
This commit ensures that changes to the FDS disk get saved when the
Famicom system saves (similar to how the 64DD works already). Without
this, changes to the FDS disk were only written back to the pak in
FDS::disconnect, _after_ the save on unloading/exit or any periodic
autosaves.
  • Loading branch information
2b7q8 authored Dec 18, 2024
1 parent 7d327a2 commit 3b18a3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ares/fc/fds/fds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ auto FDS::connect() -> void {
auto FDS::disconnect() -> void {
if(!node) return;

save();
pak.reset();
node.reset();
}

auto FDS::save() -> void {
if(disk1.sideA)
if(auto fp = pak->write("disk1.sideA")) {
disk1.sideA.save(fp);
Expand All @@ -100,9 +106,6 @@ auto FDS::disconnect() -> void {
if(auto fp = pak->write("disk2.sideB")) {
disk2.sideB.save(fp);
}

pak.reset();
node.reset();
}

auto FDS::change(string value) -> void {
Expand Down
1 change: 1 addition & 0 deletions ares/fc/fds/fds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct FDS {
auto change(string value) -> void;
auto change() -> void;

auto save() -> void;
auto poll() -> void;
auto main() -> void;
auto power() -> void;
Expand Down
1 change: 1 addition & 0 deletions ares/fc/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ auto System::load(Node::System& root, string name) -> bool {
auto System::save() -> void {
if(!node) return;
cartridge.save();
if(fds.present) fds.save();
}

auto System::unload() -> void {
Expand Down

0 comments on commit 3b18a3f

Please sign in to comment.