Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Various DI improvements #8394
An early draft of my improved DI work. I still need to do some testing (and write automated hardware tests), but there is documentation of what I've figured out so far.
The GPIO change fixes bug 11818 (not DI related) and also implements GPIO-based ejection (which is used by the system menu when booting from the eject button in conjunction with the RTC flag; I don't think any games use it though.)
The RTC change should fix bug 8115 (including the case when a channel other than the system menu is running which I reported as bug 11803). Note that the trade-off is that currently, it always acts like the disc has changed and never uses the cache when first loading the system menu, though it should still use it when exiting from a game. To be more accurate about it dolphin would need to track the current disc in the configuration file, probably.
Most of the other changes are related to errors reported by the disc drive, or various commands that were not implemented before. I've made some attempts to organize these nicely into different commits, but it's still not the clearest yet.
I have only tested this with Wii games. Testing it with gamecube games would be appreciated (in particular, I suspect that the stricter DTK changes will cause issues when starting from emulated BS2, but I haven't tested it).
Although this is a draft, I would like feedback on the implementation, since some of the code is rather hacky and I'm not completely sure how to do it better.
BhaaLseN left a comment
Changes seem solid for the most part; thanks again for working on this!
I plan on addressing most of the TODO comments, but not all of them. I probably will not address the DTK buffer size comment in this PR (since I don't think it affects games), and I don't plan on addressing the BCA TODO either (I want to handle that in a different PR). I also don't plan on handling the GPIO
I might handle the extra read in DVDLowReadDiskID (I've ordered a gamecube game that uses DTK, so I can do some testing regarding it). I might handle the DVDLowGetCoverStatus resetting case, but that requires some hardware testing to understand what's going on with DICVR during the reset (I've done some basic testing, and it looks weird) and I don't think it affects games. DVDLowSeek is a weird case since dolphin doesn't implement it currently, but I do plan on implementing it eventually (which will also necessitate doing something about the partition). The two disc state TODOs are basically just cases where I need to do more testing and I plan on resolving them at some point.
The comment in
The rest are code things that I plan on resolving before merge (or possibly have already resolved and haven't removed the comments on).
The gamecube games I ordered arrived, and I can now see that the DTK changes I have here are a bit too restrictive — DTK isn't configured when launching with emulated BS2, and also changing discs while on the IPL rejects DTK configuration for the second disc which causes issues even if neither game uses DTK (however, everything works fine if you start the IPL and then insert a disc or boot with "skip main menu" disabled).
I know how to fix the BS2 case (just add that logic into Boot_BS2Emu, which probably will involve messily duplicating more code for the time being, which is not great but at least a solution). However, I'm less sure how to solve the IPL one — I'm not sure when the drive gets back into a state that audio can be configured. I'm currently enabling DTK configuration when the drive is reset, but I don't think that's something that happens normally on a gamecube. Maybe it's instead configurable after changing discs, and that's something that's enforced in the drive itself without software needing to do a reset?
EDIT: After thinking about it a bit more, it seems pretty likely to me that it is just changing discs and not the reset. A reset works for allowing configuring it because it puts the drive into
EDIT: Well, my brilliant idea for testing it was to, in dolphin, eject the disc while DTK audio is playing. Unfortunately, that crashes dolphin, because DVDThread has no idea what to do about that (it doesn't seem to handle read errors with DTK that well). Testing on console is going to be hard too, because I don't have a gamecube controller to actually get to a point where audio is playing (but I can probably write a test program that just calls DTK functions). I can at least decompile the game, though (and fix the crash).
I've fixed both of the DTK not getting set issues, though I still haven't hardware tested it becoming configurable again. I haven't fixed the crash, but it looks like gamecube games just react poorly in general to being ejected. I'm not sure why that's happening as there should be an interrupt that's getting sent out, but I don't know enough about gamecube interrupts to diagnose it.
I got around to doing some more hardware testing on my Wii, and can now address the earlier TODOs about drive states:
Right now I'm not enforcing
EDIT: The one thing I don't understand is that the Wii Menu seems to get stuck in an infinite loop if I set the error to
but at least as far as I can tell, only the first one of those should really be there. And of course that doesn't explain at all how the disc is spun up on the Gamecube.
The various ioctls sometimes have different arguments than the DI command registers, though they generally overlap. There are also a bunch of ioctls that don't even normally go into DVDInterface, just returning various data. Some of the implemented ioctls are new to Dolphin.
All out of bounds reads should return the appropriate DI error, but it also makes sense to have the error 001 read happen there.
Partitions are Wii-exclusive, and don't happen at the DVDInterface level in IOS. This isn't quite the cleanest fix, but it gets rid of the assumption that a partition is open on starting the game at least.