summarylogtreecommitdiffstats
path: root/mame.sh
blob: 0b8f2256093bf3d1728f2ba296a4930c1dcad6ef (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
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
mamelib=/usr/lib/mame/

mame_first_run() {
  echo "Creating an ini file for MAME at ~/.config/mame/mame.ini"
  echo "Config and shared files is stored into"
  echo " ~/.config/mame and  ~/.local/share/mame"
  echo "Modify this file for permanent changes to your MAME"
  echo "options and paths before running MAME again."

  cd -- ~/.config/mame || exit

  if [ -e mame.ini ]; then
    mv mame.ini mame.ini.bak || exit
    echo "Your old ini file has been renamed to mame.ini.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 \
    -homepath '$HOME/.local/share/mame/data' \
    -rompath '$HOME/.local/share/mame/roms;/usr/lib/mame/roms' \
    -hashpath '$HOME/.local/share/mame/hash;/usr/lib/mame/hash' \
    -samplepath '$HOME/.local/share/mame/samples' \
    -artpath '$HOME/.local/share/mame/artwork;/usr/lib/mame/artwork' \
    -ctrlrpath '$HOME/.local/share/mame/ctrlr;/usr/lib/mame/ctrlr' \
    -inipath '$HOME/.config/mame/ini' \
    -fontpath '$HOME/.local/share/mame/fonts;/usr/lib/mame/fonts' \
    -cheatpath '$HOME/.local/share/mame/cheat' \
    -crosshairpath '$HOME/.local/share/mame/crosshair' \
    -pluginspath '$HOME/.local/share/mame/plugins;/usr/lib/mame/plugins' \
    -languagepath '$HOME/.local/share/mame/language;/usr/lib/mame/language' \
    -swpath '$HOME/.local/share/mame/software;/usr/lib/mame/software' \
    -cfg_directory '$HOME/.config/mame/cfg' \
    -nvram_directory '$HOME/.local/share/mame/nvram' \
    -input_directory '$HOME/.local/share/mame/inp' \
    -state_directory '$HOME/.local/share/mame/sta' \
    -snapshot_directory '$HOME/.local/share/mame/snap' \
    -diff_directory '$HOME/.local/share/mame/diff' \
    -comment_directory '$HOME/.local/share/mame/comments' \
    -video opengl \
    -showconfig > ini/mame.ini
}

if [ "$1" = "--newini" ]; then
  echo "Running MAME for the first time..."
  if ! [ -e ~/.config/mame ]; then
    mkdir -- ~/.config/mame
  fi
    if ! [ -e ~/.local/share/mame ]; then
    mkdir -- ~/.local/share/mame
  fi

  (
    cd -- ~/.local/share/mame || exit
    mkdir -p data roms hash samples artwork ctrlr fonts cheat crosshair plugins language software
    cd -- ~/.config/mame || exit
    mkdir -p ini
    mame_first_run
  ) || exit
fi

cd "${mamelib}"
exec ./mame -inipath "$HOME/.config/mame/ini" "${@/--newini/}"