#!/bin/bash
### BEGIN BOOT SCRIPT INFO
#Long-Name: VirtuaNESex
### END BOOT SCRIPT INFO
### BEGIN BOOT SCRIPT INSTALLATION DEFAULTS
#Launch-Mode: gui-only
### END BOOT SCRIPT INSTALLATION DEFAULTS
#
#This script uses a standard run scriptlet called RUN_VIRTUANESEX, which should
#end with a call to run_virtuanesex with the ROM or disk image as the argument.
#
#For YuXing, the emulator is hard-coded to look for YuXing.img in the
#VirtuaNESex directory. This is normally a symlink and this script can replace
#it with a link to a user-specified image in the VirtuaNESex directory by
#exporting $YUXING_FLOPPY_IMG
#


. bootscriptfunctions.sh

run_virtuanesex()
{

	cd_to_wine_config VirtuaNESex
	if [ "$YUXING_FLOPPY_IMG" ]
	then
		if [ -f "$YUXING_FLOPPY_IMG" ]
		then
			if [ -L YuXing.img ]
			then
				ln -sf "$YUXING_FLOPPY_IMG" YuXing.img
			else
				echo "YuXing.img is not a symlink" >&2
				exit 1
			fi
		else
			echo "invalid YuXing image $YUXING_FLOPPY_IMG" >&2
			exit 1
		fi
	fi
	run_wine_base "c:\VirtuaNESEx\VirtuaNESex.exe" "$1"
}

call_run_scriptlet virtuanesex
