#!/usr/bin/env bash
set -euo pipefail
here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
export MAME_BIN="$here/bin/mpc"
export MAME_ROM_DIR="$here/roms"
export MAME_RUNTIME_DIR="$here/runtime"
# The repo launcher defaults to this workstation's 12 performance cores; a
# bundle must not assume any particular host, so default to everything.
export MAME_CPUSET="${MAME_CPUSET:-0-$(( $(nproc) - 1 ))}"
# The full panel, maximized: the fast preset's LCD-only 1240x300 view is a
# diagnostic shape, not what a player wants to look at.
export MPC_VIEW_NAME="${MPC_VIEW_NAME:-Default Layout}"
export MPC_WINDOW_RESOLUTION="${MPC_WINDOW_RESOLUTION:-auto}"
export MPC_MAXIMIZE="${MPC_MAXIMIZE:-1}"
# The preset's event-driven panel UART ghosts button presses on the desktop -
# presses revert or are skipped. The accurate panel path (real panel CPU,
# stock UART timing) behaves; a desktop has the CPU headroom for it. The
# appliance is unaffected: it runs the panel HLE, a different path.
export MPC_PANEL_MODE="${MPC_PANEL_MODE:-accurate}"
export MPC_PANEL_TIMER_MODE="${MPC_PANEL_TIMER_MODE:-accurate}"
exec "$here/scripts/run-mpc2000xl-fast.sh" \
    -pluginspath "$here/plugins" -plugin layout "$@"
