aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gbjoin
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-17 14:26:06 +0200
committeruser <user@clank>2026-07-17 14:26:06 +0200
commit584b19508b31f444ae02a974b96d1a50b8e650a2 (patch)
treeff8698446e6337b235482b5dcb9f19ae2fb5091d /tools/gbjoin
parenttools: gbhub - many Game Boys on one network (DHCP pool + inter-GB routing) (diff)
downloadgbos-584b19508b31f444ae02a974b96d1a50b8e650a2.tar.gz
gbos-584b19508b31f444ae02a974b96d1a50b8e650a2.tar.xz
gbos-584b19508b31f444ae02a974b96d1a50b8e650a2.zip
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.
Diffstat (limited to 'tools/gbjoin')
-rwxr-xr-xtools/gbjoin30
1 files changed, 30 insertions, 0 deletions
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])