Add joybus support and boot to bios#319
Conversation
|
Oh man, this is a welcome addition! I'll see if I can get some eyes on it. |
No one had reported this issue to me previously. I should take a look. |
|
Thanks for the warm reception! Let me know how I can help :) @endrift Here's a quick 30 second example of that issue: |
|
if the non-libretro-specific bits are also needed and accepted upstream, that would be an ideal place to start, so we don't run into more problems down the line maintaining downstream changes to the codebase. |
|
Thankfully the only thing that's non-libretro in this PR is pretty simple, it's just this: diff --git a/src/gba/sio/dolphin.c b/src/gba/sio/dolphin.c
index 0bb783e76..4cce68b2f 100644
--- a/src/gba/sio/dolphin.c
+++ b/src/gba/sio/dolphin.c
@@ -203,7 +203,14 @@ int32_t _processCommand(struct GBASIODolphin* dol, uint32_t cyclesLate) {
}
if (!dol->active) {
- return 0;
+ /* GBA BIOS: respond so Dolphin doesn't kill the connection */
+ if (buffer[0] == JOY_RESET || buffer[0] == JOY_POLL) {
+ buffer[1] = 0x00;
+ buffer[2] = 0x04;
+ buffer[3] = 0x00;
+ SocketSend(dol->data, &buffer[1], 3);
+ }
+ return bitsOnLine * CYCLES_PER_BIT - cyclesLate;
}
int sent = GBASIOJOYSendCommand(&dol->d, buffer[0], &buffer[1]);I thought it'd be kinda rude to silently PR it to mgba at the same time as this PR, so I wanted to get some feedback here first from people more familiar with the protocol. It seems fine, it's taken partially from But if you want to get the discussion started over there, I can go PR just this bit now, let me know! |
This PR was motivated by me really wanting to use the AYN Thor's second screen to play GBA games and connect them to Dolphin. Dolphin Android doesn't support the integrated mGBA, but it secretly supports the GBA (TCP) controller type via an .ini setting. So I figured, the JoyBus code is there in this core, and it already works on Dolphin Android - why not make it usable?
So I did! I think it speaks for itself:
https://youtu.be/ovBZBhBkX_4
Technical notes about this PR:
When the setting is enabled, the core will try connecting to Dolphin every 60 frames. This doesn't require a core restart, it can be enabled/disabled at any time even with a game running.
A previous draft of this had no platform-specific macros, and builds for PS2 and Wii would fail. I could have fixed them, but I wanted to avoid accidental platform-specific networking quirks on platforms that can't even use this feature. So now this feature is off by default and enabled for platforms where it makes sense.
src/platform/libretro/libretro.cRETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME. I left the TODO as-is, since I'm not sure what the intent behind the TODO was, and I only conditionally set this totrueanyway. Booting to BIOS works fine now, so if it would be cleaner to set this for all platforms, I can change the PR to do that.core_initlabel so the "boot to bios" branch can jump to it without needing a ROM loaded.src/gba/sio/dolphin.c_processCommandwould previously return0if there was no active connection. This doesn't matter for full ROMs, but on the GBA BIOS,dol->activeseems to usually or always befalse, so this return makes Dolphin kill the connection immediately.JOY_RESETandJOY_POLLrespond like they do insio.c'sGBASIOJOYSendCommandmakes the connection stable and multiboot games work fine.Usage notes about this feature: