summarylogtreecommitdiffstats
path: root/hbmame.sh
blob: 73b2c2ef4190764db898affc651cb839c47975d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
hbmamelib=/usr/lib/hbmame/

mame_first_run() {
  echo "Creating an ini file for HBMAME at $HOME/.hbmame/hbmame.ini"
  echo "Modify this file for permanent changes to your MAME"
  echo "options and paths before running MAME again."

  cd -- ~/.hbmame || exit

  if [ -e hbmame.ini ]; then
    mv hbmame.ini hbmameini.bak || exit
    echo "Your old ini file has been renamed to hbmameini.bak"
  fi

  # Note: the single quotes here are not a mistake; MAME will save these
  # strings verbatim into its configuration file, and expand the variables when
  # it is run in future.
  "$hbmame" \
    -artpath '$HOME/.hbmame/artwork;artwork' \
    -ctrlrpath '$HOME/.hbmame/ctrlr;ctrlr' \
    -inipath '$HOME/.hbmame/ini' \
    -rompath '$HOME/.hbmame/roms' \
    -samplepath '$HOME/.hbmame/samples' \
    -cfg_directory '$HOME/.hbmame/cfg' \
    -comment_directory '$HOME/.hbmame/comments' \
    -diff_directory '$HOME/.hbmame/diff' \
    -input_directory '$HOME/.hbmame/inp' \
    -nvram_directory '$HOME/.hbmame/nvram' \
    -snapshot_directory '$HOME/.hbmame/snap' \
    -state_directory '$HOME/.hbmame/sta' \
    -video opengl \
    -createconfig
}

if [ "$1" = "--newini" ]; then
  mame_first_run
  exit
elif ! [ -e ~/.hbmame ]; then
  echo "Running MAME for the first time..."

  mkdir -- ~/.hbmame
  (
    cd -- ~/.hbmame || exit
    mkdir artwork cfg comments ctrlr diff ini inp nvram samples snap sta roms

    mame_first_run
  ) || exit
fi

cd "$hbmamelib"
exec ./hbmame "$@"