summarylogtreecommitdiffstats
path: root/mame.sh
blob: d02b93a0b191eeaa436f9f558ea054882d1c7268 (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
#!/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 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 \
    -rompath '$HOME/.local/share/mame/roms;roms' \
    -hashpath '$HOME/.local/share/mame/hash;hash' \
    -samplepath '$HOME/.local/share/mame/samples' \
    -artpath '$HOME/.local/share/mame/artwork;artwork' \
    -ctrlrpath '$HOME/.local/share/mame/ctrlr;ctrlr' \
    -inipath '$HOME/.config/mame/ini' \
    -fontpath '$HOME/.local/share/mame/fonts;fonts' \
    -cheatpath '$HOME/.local/share/mame/cheat' \
    -crosshairpath '$HOME/.local/share/mame/crosshair' \
    -pluginspath '$HOME/.local/share/mame/plugins;plugins' \
    -languagepath '$HOME/.local/share/mame/language;language' \
    -swpath '$HOME/.local/share/mame/software;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 \
    -noreadconfig -showconfig > 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 -- ~/.config/mame || exit
    mkdir -p ini
    cd -- ~/.local/share/mame || exit
    mkdir -p roms hash samples artwork ctrlr fonts cheat crosshair plugins language software
    mame_first_run
  ) || exit
fi

cd "${mamelib}"
exec ./mame "${@/--newini/}"