#!/bin/sh
# EPOC32 Emulator runner thingy

# Unix path to EPOC32 directory.
# You must make sure the parent of EPOC32 is a WINE drive.

BASE=/mnt/hdb10/EPOC32
SYSTEM=${BASE}/Wins/C/System

# I didn't install wine properly, so I need this. You probably want to set
# this to /usr or something.

WINE=/mnt/hdc1/warwick/CPPER/wine-20010326

if [ ! -d ${BASE} ] ; then
  echo "** ALERT: Not mounted: ${BASE}"
fi
if [ ! -d ${WINE} ] ; then
  echo "** ALERT: Not mounted: ${WINE}"
fi

if [ -d ${SYSTEM}/Apps/Shell ] ; then
  echo "*** Deleting Wins/C/System/Apps/Shell so the emulator will run at all"
  rm -rf ${SYSTEM}/Apps/Shell
fi 

if [ -d ${SYSTEM}/Apps ] ; then
  echo "** WARN: Deleting Wins/C/System/Apps as a possible non-exec culprit"
  rm -rf ${SYSTEM}/Apps
fi
if [ -d ${SYSTEM}/Temp ] ; then
  echo "** WARN: Deleting Wins/C/System/Temp as a possible non-exec culprit"
  rm -rf ${SYSTEM}/Temp
fi
if [ -d ${SYSTEM}/Data ] ; then
  echo "** WARN: Deleting Wins/C/System/Data as a possible non-exec culprit"
  rm -rf ${SYSTEM}/Data
fi
if [ -f ${SYSTEM}/System.ini ] ; then
  echo "** WARN: Deleting Wins/C/System/System.ini as a possible non-exec culprit"
  rm ${SYSTEM}/System.ini
fi

# Warn about possible mysterious failures
if [ -d ${SYSTEM} ] ; then
  echo "**** WARNING: Wins/C/System exists: some things may fail,"
  echo "              particularly saving things, if .ini files exist."
  echo "              Errors like Unexpected end of file, or no apps running."
fi

# Probably don't really need to be here, but...
cd ${BASE}/Release/WINS/Deb

# Start the emulator. Yay.
LD_LIBRARY_PATH=${WINE}/lib ${WINE}/bin/wine -managed EPOC.EXE "$@"

