Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wii SD Card Folder Syncing #10590

Merged
merged 15 commits into from Jul 11, 2022
Merged

Conversation

AdmiralCurtiss
Copy link
Contributor

Rebased and modified #10525. This now behaves like the melonDS variant (I think) where it will, if enabled, sync a folder into an SD Card image on emulation start, and then sync it back from the image to the folder on emulation end.

The default folder that syncs with the image is at [userdir]/Load/WiiSDSync. Be careful as this will overwrite the contents of your sd.raw if you already have one!

As-is, this is pretty barebones but works. Additional features that could be nice and can be part of either this PR or a follow up include manual pack/unpack buttons, only syncing files that have changed (right now it just packs or unpacks the entire thing every time), some safety checks, and probably more. Maybe we should also take this opportunity to change the default path of the sd.raw to not be inside the Wii NAND...

I have not extensively tested this -- in fact most of the code is just taken as-is from #10525 -- so it's entirely possible this has issues, but from a little test it worked as expected.

@iwubcode
Copy link
Contributor

iwubcode commented Apr 17, 2022

Be careful as this will overwrite the contents of your sd.raw if you already have one!

Doesn't have to be this PR but it'd be nice if the user clicks that sync checkbox and Dolphin notices there's a sd.raw that the files get unpacked to the folder. Likewise if it's unchecked but "insert SD card" is checked, we could create the sd.raw from the folder. At the very least, it might make sense to add some warning to this so users don't get a nasty surprise.

Outside of that, this sounds good. Haven't tested or looked at any code yet.

@MayImilae
Copy link
Contributor

Tested on macOS 12 and it works! And it's very convenient, super nice.

@JaredWhiteOne
Copy link

JaredWhiteOne commented Jun 15, 2022

Tested on Windows 10 and works as expected. A little slow for larger "SD cards", as expected really, but on second load there must have been some caching that occurred because it was dramatically faster.

@JMC47
Copy link
Contributor

JMC47 commented Jun 15, 2022

Does this create deterministic SD cards - would it work for netplay?

@AdmiralCurtiss
Copy link
Contributor Author

Not right now, but that should be simple to add, just sort the files in some deterministic way before packing.

@AdmiralCurtiss
Copy link
Contributor Author

We probably should also use dummy timestamps and such in the deterministic case, now that I think about it.

@JMC47
Copy link
Contributor

JMC47 commented Jun 15, 2022

Yeah, that was the issue on old netplay - even if you put together the same exact SD card, unless you shared it directly with the other person, the timestamps wouldn't line up.

@AdmiralCurtiss AdmiralCurtiss force-pushed the sdcard-folder-sync branch 3 times, most recently from c00bcc4 to 6347542 Compare June 16, 2022 12:18
@AdmiralCurtiss
Copy link
Contributor Author

AdmiralCurtiss commented Jun 16, 2022

@JMC47 I've added a deterministic packing mode that will be used when Core::WantsDeterminism() is on (ie, in Netplay and TAS). However, I've not tested if this works with Netplay in the first place, so that would be the next step here.

I've also fixed up some minor things and added some utility features to the UI. IMO this is pretty much ready now, except maybe some tooltips or warnings so users don't accidentally destroy their existing cards with this.

Oh, and I've also changed the default path for the SD card image to be at Load/WiiSD.raw instead of Wii/sd.raw. I think this is a good opportunity to do that, as placing it inside the Wii NAND is rather unfortunate, but feel free to argue with me on that point.

@JaredWhiteOne
Copy link

@AdmiralCurtiss Does this sync the whole sd card image, or just whatever is different between the raw file and the folder?

@AdmiralCurtiss
Copy link
Contributor Author

The entire thing. Trying to detect and process differences only could be added but for a first version this seems plenty already.

@JMC47
Copy link
Contributor

JMC47 commented Jun 16, 2022

Moving the SD card outside of the Wii NAND is correct. I don't think anyone will argue with that.

@JosJuice
Copy link
Member

Yeah, I agree with moving it outside of the Wii directory. I don't know about putting it in Load, since that's normally for stuff that Dolphin doesn't write to... But I'm not sure what a better place would be.

@JaredWhiteOne
Copy link

Maybe a new directory in the User folder?

@MayImilae
Copy link
Contributor

Remember how I said this PR seemed a little crashy? Testing further, I found a way to reproduce it reliably. It's pretty simple. Just start the Wii Menu through the menu bar, and click A to get past the health screen and into the Wii Menu itself (which is necessary, it doesn't crash otherwise). Once the Wii Menu is up, stop emulation, wait for it to finish stopping, then open the Wii Menu the exact same way. This should be the crash. This does not occur on master.

@AdmiralCurtiss
Copy link
Contributor Author

Cannot reproduce. Stack trace please, ideally from a debug build?

@Pokechu22
Copy link
Contributor

I tested this briefly (I wanted to use some homebrew, and setting up an SD card is a pain otherwise). "Convert Folder to File now" seems to work fine.

I was a bit confused initially because I had assumed that "Automatically sync with Folder on emulation start and end" would default to checked, but it doesn't (which is probably for the better, as otherwise it'd default to replacing the SD card with an empty folder) - the relevant options are in Config → Wii. For my purposes, "Convert Folder to File now" was what I wanted though.

@JMC47
Copy link
Contributor

JMC47 commented Jun 25, 2022

Everything works as expected on my standard SD card. But the one I converted from my actual Wii doesn't work. It loads in Dolphin fine, but it doesn't convert to folder properly. I was unable to reproduce any crashing following the provided steps.

The loadtimes are pretty excessive when not using an m2 drive, which can be a bit annoying on 2GB cards. at 128MB default card isn't that bad.

@AdmiralCurtiss AdmiralCurtiss force-pushed the sdcard-folder-sync branch 2 times, most recently from 04f5a54 to c7f466c Compare June 25, 2022 22:48
@JMC47
Copy link
Contributor

JMC47 commented Jun 25, 2022

@dolphin-emu-bot rebuild

@JMC47 JMC47 merged commit aa29433 into dolphin-emu:master Jul 11, 2022
@AdmiralCurtiss AdmiralCurtiss deleted the sdcard-folder-sync branch July 11, 2022 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants