The N64's Joybus protocol inherently allows for the game to request specific Extension Paks to be inserted on demand, by writing the ID of the Pak to 0x8000 on the bus, or the bank number, such as 0x00, for the Controller Pak. Writing 0xFE to it requests shutdown to the current pak, and is not just limited to the Transfer Pak.
The "proper" approach to swap paks mid-game is to just write the desired pak id via joybus in between menus, and provide a UI screen to facilitate that, if it needs to be swapped. This allows the pak itself to swap what it is, if supported on the hardware.
libdragon's approach does not currently allow for this. It instead checks to see if it can switch to a Controller Pak, if so, it's a Controller Pak. Else try to see if it can switch to a Rumble Pak. And so on. Meaning, if the pak can swap between CPak and RPak, for example, libdragon would first see it works as a CPak, stop there, and not even bother checking if it is an RPak.
Instead, if saving the game, it should attempt to swap to CPak, and do its job; if rumbling, swap to RPak if not already, and attempt to do that, etc. There is no reason to have an enum for which pak is currently inserted, and by having it, auto-swapping would be unintentionally broken.
I am currently testing auto-swapping on a modified version of Gopher64, and have tested 140+ games, 70% have worked successfully and completely, 15% are having issues potentially due to my implementation (working on fixing), and the remaining 15% have a polling system similar to libdragon's and is unfixable.
Would love to work with y'all to get this cleaned up and better support this feature :)
The N64's Joybus protocol inherently allows for the game to request specific Extension Paks to be inserted on demand, by writing the ID of the Pak to 0x8000 on the bus, or the bank number, such as 0x00, for the Controller Pak. Writing 0xFE to it requests shutdown to the current pak, and is not just limited to the Transfer Pak.
The "proper" approach to swap paks mid-game is to just write the desired pak id via joybus in between menus, and provide a UI screen to facilitate that, if it needs to be swapped. This allows the pak itself to swap what it is, if supported on the hardware.
libdragon's approach does not currently allow for this. It instead checks to see if it can switch to a Controller Pak, if so, it's a Controller Pak. Else try to see if it can switch to a Rumble Pak. And so on. Meaning, if the pak can swap between CPak and RPak, for example, libdragon would first see it works as a CPak, stop there, and not even bother checking if it is an RPak.
Instead, if saving the game, it should attempt to swap to CPak, and do its job; if rumbling, swap to RPak if not already, and attempt to do that, etc. There is no reason to have an enum for which pak is currently inserted, and by having it, auto-swapping would be unintentionally broken.
I am currently testing auto-swapping on a modified version of Gopher64, and have tested 140+ games, 70% have worked successfully and completely, 15% are having issues potentially due to my implementation (working on fixing), and the remaining 15% have a polling system similar to libdragon's and is unfixable.
Would love to work with y'all to get this cleaned up and better support this feature :)