Mission: Wireless trading on gen1 and gen2 Pokemon Games

lightninjay

Well-Known Member
OP
Member
Joined
Mar 28, 2023
Messages
560
Trophies
0
Age
31
XP
1,374
Country
United States
So i wrote a post at the libretro forums, tucked away in a tight little corner that essentially only mods get notified about, and bumped the gambatte emulator topic to bring up my current discoveries of gameboy games being played on the gambatte emulator core with netlink working.

Here is a link to those posts: https://forums.libretro.com/t/gambatte/44/12?u=lightninjay

To sum it up briefly, I have managed to compile a semi-working netlink build of gambatte on the switch. I say semi-working, because I am only able to initiate fully successful links when I use a computer or android phone as the "gambatte link server" and the nintendo switch as the "gambatte link client". If I reverse the roles, or try to set up two switches to trade together, then one switch must be in server mode. Linking breaks down in this mode.

I am posting here with proof of my one-sided netlink ability, which I think is still valuable for trading between emulator instances, but am hopeful that someone more knowledgeable than myself about some of the network protocols will be able to help me sort out the reason the switch struggles in server mode.

Just a simple trade between pokemon Red and Blue. I was trying my best to keep the controls synced for cool-ness factor (controller in my hand for switch, keyboard clickety-clackety in the background for PC)

I've also attached an nro libretro gambatte core that should be semi-netlink enabled (like the build in the above video) as well as the altered netserial.cpp and Makefile.libretro to get the gambatte libretro fork on github to build properly, they can both be found in the zip file. If anyone wants to help, I would greatly appreciate any pointers!

Otherwise, I'll just be here bashing my head against network protocols and trying to sniff network packets using wireshark and an isolated wireless router for two switches to connect to...
 

Attachments

  • gambatte_libretro_libnx.zip
    5.2 MB · Views: 28
Last edited by lightninjay,

lightninjay

Well-Known Member
OP
Member
Joined
Mar 28, 2023
Messages
560
Trophies
0
Age
31
XP
1,374
Country
United States
Guys... I did it...

I guess I should say, WE did it. In a surprising (or unsurprising if you've been keeping up with recent tech news) turn of events, I decided to see if ChatGPT could help me with my dilemma of server mode not working on the Switch.

After a series of pointed questions from me, and several iterations of attempted compiling, with ChatGPT's help (I basically just worded requests and let ChatGPT do all the code modification) I compiled a GameLink-enabled build that works on the Switch in both client AND server mode.

I tested it with current Gambatte builds on linux and android, in both server and client mode, and was able to trade and battle pokemon in the Gen 1 and Gen 2 pokemon games.

The best part about this code is that it is not pigeon-holed to only work with pokemon. It's a general Gameboy Serial Link that is being emulated over TCP, and so games like Tetris and other multiplayer games should at least be moderately functional on a local network. I have not tested this for internet play, but with reasonable ping, I don't see why it couldn't be made to work.

To be clear, this functionality has been in the Gambatte core since August 2016, when Github user "UnimatrixX01" made a single large push to the gambatte-libretro repository. Their code has worked on Android, Linux, Windows, and probably many other platforms.

As the Nintendo Switch was not released until March of 2017, this particular git push did not have the Nintendo Switch in mind, so it was no wonder when I tried to build a GameLink enabled core for the Switch using the libnx libraries from DevKitPro and it failed to compile properly. I just got lucky that the largest majority of the groundwork was lain. I needed to update some deprecated calls from "gethostbyname" to "getaddrinfo" and then make sure that the socket initialization was robust enough that it would not fail with the switch as the server.

I took a couple weeks trying to figure out exactly what I was still missing, but then thought, "How about I ask ChatGPT if it can help me out?" I described my issues to ChatGPT, copy pasted my modified net_serial.cpp file into the chat prompt, and then requested that it modify the code to allow for better debugging errors. It suggested several points in the code to allow for extra error-handling, and also made the swap from "gethostbyname" to "getaddrinfo".

After a few failed builds, I finally asked the right questions and provided the right information to the prompt, and ChatGPT spit out the code that built the fully-functioning Gambatte core for nintendo Switch. For kicks, I also compiled a Unix core, but have not attempted compiling a Windows core or Android core, because the Gamelink function from the Github build seems to work fine in both server and client modes for all existing other GameLink enabled builds.

Without further ado, I present a video of my and ChatGPT's hard work in action:

https://emalm.com/?v=hYSSk

If people are interested, I’ll upload my compiled NRO, or possibly even push my updated net_serial.cpp to the github, but I can’t imagine THAT many people are still emulating networked Gameboy games specifically on the Switch.

I did this as a project to give these two nintendo switchs to my nephews, because I wanted them to have the same original pokemon experience I had, but better. Who needs a stinkin LINK CABLE, amirite?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Att is displaying prices like it's an ingredients list now lol