shithub: rc

ref: f3afdf563f784c0a5703496f48c1a72dff4617f4
dir: /emu/

View raw version
#!/bin/rc -e
# emu - a wrapper for games/^(2600 gb gba md nes snes)
# usage: emu [-j usbep] console width height [params] rom
# requires:
#	- rescale

rfork n

if(~ $*(3) ''){
	echo $0 'usage: emu [-j usbep] console width height [params] rom'
	exit usage
}

emu=$1
rescale $2 $3
shift 3
joy=()

if(~ $1 -j){
	joy=$2
	shift 2
}

if(test -d /sys/games/lib/rom/$emu){
	mkdir -p $home/lib/$emu
	bind -bc $home/lib/$emu /sys/games/lib/rom/$emu
	cd /sys/games/lib/rom/$emu
}

if(~ $#joy 1)
	nusb/joy /dev/usb/ep^$joy^.0 | joy | {eval games/$emu -a $* || eval games/$emu $*}
if not
	eval games/$emu -a $* || eval games/$emu $*