shithub: rc

Download patch

ref: 6b5f42d34e85c479e9c6dfeca31f78055de1727e
author: qwx <qwx@sciops.net>
date: Thu Jan 9 00:02:56 EST 2020

add emulator launchers and helper scripts

--- /dev/null
+++ b/2600
@@ -1,0 +1,15 @@
+#!/bin/rc
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/320;
+		b=$2/222;
+		c=int(b<a?b:a);
+		if(c*320 == $1 || c*222 == $2)
+			c--;
+		print "-dx", c*320+8, "-dy", c*222+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba | {games/2600 -a $*(3-) || games/2600 $*(3-)}
+if not
+	games/2600 -a $* || games/2600 $*
--- /dev/null
+++ b/gba
@@ -1,0 +1,15 @@
+#!/bin/rc
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/240;
+		b=$2/160;
+		c=int(b<a?b:a);
+		if(c*240 == $1 || c*160 == $2)
+			c--;
+		print "-dx", c*240+8, "-dy", c*160+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba | {games/gba -a $*(3-) || games/gba $*(3-)}
+if not
+	games/gba -a $* || games/gba $*
--- /dev/null
+++ b/gbc
@@ -1,0 +1,15 @@
+#!/bin/rc -e
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/160;
+		b=$2/144;
+		c=int(b<a?b:a);
+		if(c*160 == $1 || c*144 == $2)
+			c--;
+		print "-dx", c*160+8, "-dy", c*144+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba | {games/gb -a $*(3-) || games/gb $*(3-)}
+if not
+	games/gb -a $* || games/gb $*
--- /dev/null
+++ b/joygba
@@ -1,0 +1,37 @@
+#!/bin/rc
+# run as "nusb/joy epX.Y | joygba"
+
+awk -safe '
+	BEGIN { k[0] = "" }
+
+	/^axis 0 0/   { k[0] = "left " }
+	/^axis 0 255/ { k[0] = "right " }
+	/^axis 0 128/ { k[0] = "" }
+
+	/^axis 1 0/   { k[1] = "up " }
+	/^axis 1 255/ { k[1] = "down " }
+	/^axis 1 128/ { k[1] = "" }
+
+	/^down 1$/ { k[3] = "b " }
+	/^down 5$/ { k[2] = "a " }
+	/^down 6$/ { k[8] = "x " }
+	/^down 2$/ { k[9] = "y " }
+	/^down 3$/ { k[4] = "control " }
+	/^down 4$/ { k[5] = "start " }
+	/^down 7$/ { k[6] = "l1 " }
+	/^down 8$/ { k[7] = "r1 " }
+
+	/^up 1$/ { k[3] = "" }
+	/^up 5$/ { k[2] = "" }
+	/^up 6$/ { k[8] = "" }
+	/^up 2$/ { k[9] = "" }
+	/^up 3$/ { k[4] = "" }
+	/^up 4$/ { k[5] = "" }
+	/^up 7$/ { k[6] = "" }
+	/^up 8$/ { k[7] = "" }
+
+	{
+		print k[0] k[1] k[2] k[3] k[4] k[5] k[6] k[7] k[8] k[9]
+		fflush
+	}
+'
--- /dev/null
+++ b/md
@@ -1,0 +1,15 @@
+#!/bin/rc
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/320;
+		b=$2/224;
+		c=int(b<a?b:a);
+		if(c*320 == $1 || c*224 == $2)
+			c--;
+		print "-dx", c*320+8, "-dy", c*224+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba | {games/md -a $*(3-) || games/md $*(3-)}
+if not
+	games/md -a $* || games/md $*
--- /dev/null
+++ b/nes
@@ -1,0 +1,15 @@
+#!/bin/rc
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/256;
+		b=$2/240;
+		c=int(b<a?b:a);
+		if(c*256 == $1 || c*240 == $2)
+			c--;
+		print "-dx", c*256+8, "-dy", c*240+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba 1 | {games/nes -a $*(3-) || games/nes $*(3-)}
+if not
+	games/nes -a $* || games/nes $*
--- /dev/null
+++ b/snes
@@ -1,0 +1,15 @@
+#!/bin/rc
+echo resize `{echo $vgasize |\
+	awk -Fx '{
+		a=$1/256;
+		b=$2/239;
+		c=int(b<a?b:a);
+		if(c*256 == $1 || c*239 == $2)
+			c--;
+		print "-dx", c*256+8, "-dy", c*239+8
+	}'
+} >/dev/wctl
+if(~ $1 -j)
+	nusb/joy /dev/usb/ep^$2^.0 | joygba | {games/snes -a $*(3-) || games/snes $*(3-)}
+if not
+	games/snes -a $* || games/snes $*