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
Create enum classes for EXI devices and slots #10364
Conversation
053c60a
to
eb3e188
Compare
Source/Core/Core/HW/EXI/EXI.cpp
Outdated
| else | ||
| memorycard_device = EXIDEVICE_MEMORYCARD; | ||
| memorycard_device = EXIDeviceType::MemoryCard; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you fold this like on line 61? And then the entire if block collapses into if Not IsUsingMemcard, set None, otherwise use the configured value? Or did I miss something here, logically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I think the purpose here is to force it to be a memory card (and theoretically directly using the configured value could result in something other than a memory card); the Movie/TAS code only supports indicating whether a memory card is in use, and doesn't support other devices. But if we're overriding settings for movie purposes, why bother supporting both raw memory cards and memory card folders? Someone more experienced with the movie functions would have to chime in here.
To be clear, I'm assuming you're suggesting something like this:
void AddMemoryCards(Slot slot)
{
EXIDeviceType memorycard_device;
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
{
if (Movie::IsUsingMemcard(slot))
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(slot));
// or:
// memorycard_device = EXIDeviceType::MemoryCard;
else
memorycard_device = EXIDeviceType::None;
}
else
{
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(slot));
}
g_Channels[SlotToEXIChannel(slot)]->AddDevice(memorycard_device, SlotToEXIDevice(slot));
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it further, I think the best approach would be to get rid of AddMemoryCards entirely and then handle this in MovieConfigLoader which is injected into the config system (CC @AdmiralCurtiss). That wasn't possible until recently when the EXI and other settings were moved to the new config system.
JosJuice says that there is a benefit to supporting both raw memory cards and memory card folders, since users need to manually supply the save file (it's not included in the move file). On the other hand, devices other than memory cards aren't supported and won't sync at all (at least for things like the microphone). So forcing it to be a memory card works, but I've changed it to instead stick with the user-specified device and generate a panic alert if an invalid device is selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would agree, handling this via LoadFromDTM() in MovieConfigLoader.cpp is likely the best approach here.
| return device; | ||
| } | ||
| return nullptr; | ||
| return g_Channels.at(SlotToEXIChannel(slot))->GetDevice(1 << SlotToEXIDevice(slot)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if slot for some reason is out of range? Or is slot always valid here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SlotToEXIChannel and SlotToEXIDevice will trigger a PanicAlertFmt if slot is invalid and return 0. Those functions will always return something within the valid device and channel ranges.
eb3e188
to
528a2b1
Compare
528a2b1
to
635d82f
Compare
635d82f
to
badf345
Compare
This simplifies the code in GameCubePane, and allows us to use the EXIDeviceType enum in error messages.
badf345
to
b92c5fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Largely untested (I booted up a game and switched memory cards, and that worked, but not more than that) but code looks good to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, untested.
Source/Core/Core/HW/EXI/EXI.cpp
Outdated
| for (Slot slot : MEMCARD_SLOTS) | ||
| AddMemoryCards(slot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a preexisting issue but would it make sense to move the loop inside AddMemoryCards? The function is only called from here, and as it stands it adds a single device despite the name implying otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that somewhat makes sense, but I'd rather rip out the entirety of AddMemoryCards and replace it with the new config system in a separate PR. I can rename the function to AddMemoryCard pretty easily though.
b92c5fe
to
6578829
Compare
This is something I started on a while back while working on redoing both the gamecube boot process (related to the broken AD16 implementation) and implementing support for SD geckos/the official SD adapter/SD2SP2; I haven't finished either of those, but this is a source of merge conflicts as well as a general improvement, so I might as well PR it. This PR is refactoring with no expected behavior differences, but I haven't done extensive testing on it.