Files
Sprinter-SDCC/applications/Volkov/tests/run_mame_hdd.sh
T

46 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# Запускает MAME с локальным тестовым CHD как hard2 (D:) и заданным Lua.
# Скрипт не пересобирает образ и не чистит каталог кадров.
set -eu
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ]; then
echo "usage: $0 IMAGE.chd SCENARIO.lua SNAPSHOT_DIR [TIMEOUT]" >&2
exit 1
fi
PROJECT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
MAME_DIR="$PROJECT_DIR/../../mame/v306"
IMAGE=$(CDPATH= cd -- "$(dirname -- "$1")" && pwd)/$(basename -- "$1")
LUA=$(CDPATH= cd -- "$(dirname -- "$2")" && pwd)/$(basename -- "$2")
SNAPSHOT_DIR=$(mkdir -p "$3" && CDPATH= cd -- "$3" && pwd)
TIMEOUT=${4:-75}
if pgrep -fl 'mame[^ ]* sprinter( |$)' | grep . >/dev/null 2>&1; then
echo "run_mame_hdd.sh: уже запущен MAME sprinter" >&2
exit 1
fi
cd "$MAME_DIR"
# В macOS GNU timeout может отсутствовать; Python обеспечивает тот же лимит.
if command -v timeout >/dev/null 2>&1; then
set -- timeout "$TIMEOUT"
else
set -- python3 -c '
import subprocess, sys
try:
sys.exit(subprocess.run(sys.argv[2:], timeout=float(sys.argv[1])).returncode)
except subprocess.TimeoutExpired:
print("run_mame_hdd.sh: истёк лимит времени", file=sys.stderr)
sys.exit(124)
' "$TIMEOUT"
fi
exec "$@" ./mame.arm sprinter \
-skip_gameinfo -video opengl -window -nofilter \
-beta:wd179x:0 35hd -beta:wd179x:1 35hd \
-flop1 ./IMG/mc.img -flop2 ./IMG/dss171u.img \
-isa0 zxbus_adapter -isa0:zxbus_adapter:card neogs \
-hard1 ./IMG/sp_hdd_sys.chd -hard2 "$IMAGE" \
-ata2:0 cdrom -cdrom ./IMG/SprinterCD.iso -bios v3.06 \
-snapshot_directory "$SNAPSHOT_DIR" -autoboot_script "$LUA"