From 584b19508b31f444ae02a974b96d1a50b8e650a2 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 14:26:06 +0200 Subject: tools: gbhub --daemon + gbjoin - interactive multi-Game-Boy networking gbhub gains a --daemon mode: instead of spawning headless emulators, it just runs the switch/router/DHCP and accepts link connections, handing each a lease from a pool (10.0.0.2..) and freeing it on disconnect. The link socket is made world-connectable so unprivileged emulators can join. gbjoin (no root) launches a *windowed* Game Boy and plugs its link into the running hub, with its own ROM copy so battery saves don't clash. So you get real interactive Game Boys on one network: term 1: sudo tools/gbhub --daemon term 2: tools/gbjoin # windowed GB -> 10.0.0.2 term 3: tools/gbjoin # windowed GB -> 10.0.0.3 (on each: SELECT for the OSK, then e.g. ping 10.0.0.3) Verified two GBs join the daemon and get distinct leases; routing is the same code path as the (already-verified) spawn-mode GB<->GB ping. --- tools/gbjoin | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tools/gbjoin (limited to 'tools/gbjoin') diff --git a/tools/gbjoin b/tools/gbjoin new file mode 100755 index 0000000..a9e2b89 --- /dev/null +++ b/tools/gbjoin @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +"""gbjoin - launch a windowed Game Boy and plug its link port into a running +gbhub, so it joins the shared network (gets a DHCP lease, can talk to the other +Game Boys and the internet). Start the hub first, in its own terminal: + + sudo tools/gbhub --daemon + +Then, one per terminal: + + tools/gbjoin # sixel + Game Boy chrome (default) + tools/gbjoin --palette green # any sl0pboy display options pass through + +No root needed (the hub opens the link socket world-connectable). On the Game +Boy: SELECT toggles the on-screen keyboard, then type e.g. ping 10.0.0.3. +""" +import os, sys, subprocess, shutil + +HOME = os.path.expanduser("~") +EMU = os.path.join(HOME, "dev/gbc/build/sl0pboy") +ROM = os.path.join(HOME, "dev/gbos/gbos.gb") +SOCK = "/tmp/gbhub.sock" + +if not os.path.exists(EMU): sys.exit("gbjoin: emulator not found at " + EMU) +if not os.path.exists(SOCK): + sys.exit("gbjoin: no hub at %s - start it first: sudo tools/gbhub --daemon" % SOCK) + +opts = sys.argv[1:] or ["--sixel", "--chrome"] +rom = "/tmp/gbjoin_%d.gb" % os.getpid() # our own copy so battery saves don't clash +shutil.copyfile(ROM, rom) +os.execvp(EMU, [EMU] + opts + ["--serial-sock", SOCK, rom]) -- cgit v1.3.1-sl0p