ref: 827b405f6bd01882a5374cab251b30a6212104cf
parent: 152fe629b46404df829978726417fe9fa5c7de53
author: qwx <qwx@sciops.net>
date: Sat Dec 11 19:58:10 EST 2021
add pemu: plumb script for emulator roms
--- a/bin/nesj
+++ /dev/null
@@ -1,20 +1,0 @@
-#!/bin/rc
-
-n=`{sed -n '/ep.\.0/h;${g;s/^(ep.\.0).*/\1/p;}' /dev/usb/ctl}
-while(~ $1 -?){
- switch($1){
- case -k # just make /sys/src/9/boot/nusbrc do nothing if it sees your
- # device instead
- p=`{ps | sed -n '/ kb$/h;${g;s/^[^ ]+ +([0-9]+) .*/\1/p;}'}
- echo kill >/proc/$p/note
- wait $p
- case -n
- n=ep$2.0
- shift
- }
- shift
-}
-
-echo resize -dx 776 -dy 728 >/dev/wctl
-nusb/joy /dev/usb/$n | joynes 1 | games/nes -a3 $*
-# press Kdel again to kill nusb/joy...
--- /dev/null
+++ b/bin/pemu
@@ -1,0 +1,28 @@
+#!/bin/rc
+rfork n
+if(~ $#* 0){
+ echo usage: $0 '[-j ep]' rom.ext >[1=2]
+ exit usage
+}
+if(~ $1 -j){
+ j=$1
+ shift
+}
+if not
+ j=`{sed -n '/ep.\.0/h;${g;s/^ep(.)\.0.*/\1/p;}' /dev/usb/ctl}
+ext=`{echo $1 | sed 's/.*\.([^\.]+)$/\1/'}
+switch($ext){
+case 2600 gb gbc gba md nes snes
+ e=$ext
+case smc
+ e=snes
+case bin
+ if(~ `{file $1} *SEGA*)
+ e=md
+ if not
+ e=2600
+case *
+ echo unknown rom type >[1=2]
+ exit usage
+}
+exec $e -j $j $1