aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gbjoin
diff options
context:
space:
mode:
Diffstat (limited to '')
-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])