#!/bin/dash

### configuration
MEM=${MEM:-1024}
VGA_TYPE=${VGA_TYPE:-cirrus} # or std, or vmware (broken)

### helpers ###
run_in_my_dir() {
        mydir=$(readlink -f "$0")
        mydir=${mydir%/*}
        cd $mydir
}

###
run_in_my_dir
case $1 in
	uefi) UEFI="-bios uefi-bios.bin"; shift ;;
esac
[ -e fd64-nls.sfs ]  && HDA="-hdb fd64-nls.sfs"
[ -e fd64-devx.sfs ] && HDB="-hdd fd64-devx.sfs"
[ -e disk.ext3 ]     && HDD="-hda disk.ext3"

exec qemu-system-x86_64 -sdl -enable-kvm -m $MEM -vga $VGA_TYPE -soundhw hda \
$UEFI -redir tcp:2222::22 \
-cdrom fatdog.iso $HDA $HDB $HDD -boot d "$@"
