summarylogtreecommitdiffstats
path: root/mame.sh
blob: 80b7c4f4edcf8c46bde660445f53d0706e9f8d71 (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
53
54
55
#!/bin/sh
mame=/usr/lib/mame/mame

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

  cd -- ~/.mame || exit

  if [ -e mame.ini ]; then
    mv mame.ini mameini.bak || exit
    echo "Your old ini file has been renamed to mameini.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.
  "$mame" \
    -artpath '$HOME/.mame/artwork;/usr/lib/mame/artwork' \
    -bgfx_path '$HOME/.mame/bgfx;/usr/lib/mame/bgfx' \
    -ctrlrpath '$HOME/.mame/ctrlr;/usr/lib/mame/ctrlr' \
    -hashpath '$HOME/.mame/hash;/usr/lib/mame/hash' \
    -languagepath '$HOME/.mame/language;/usr/lib/mame/language' \
    -pluginspath '/usr/lib/mame/plugins' \
    -inipath '$HOME/.mame/ini' \
    -rompath '$HOME/.mame/roms' \
    -samplepath '$HOME/.mame/samples' \
    -cfg_directory '$HOME/.mame/cfg' \
    -comment_directory '$HOME/.mame/comments' \
    -diff_directory '$HOME/.mame/diff' \
    -input_directory '$HOME/.mame/inp' \
    -nvram_directory '$HOME/.mame/nvram' \
    -snapshot_directory '$HOME/.mame/snap' \
    -state_directory '$HOME/.mame/sta' \
    -video opengl \
    -createconfig
}

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

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

    mame_first_run
  ) || exit
fi

exec "$mame" "$@"