#!/usr/bin/env sh set -eu repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) stage_path=${1:-"$repo_dir/GC/data/stage/ac_10pt8tion_easy.dat"} output_dir=${2:-"$repo_dir/dist/PSP/GAME/OpenRoller"} audio_path=${3:-} cmake -S "$repo_dir" -B "$repo_dir/build" cmake --build "$repo_dir/build" --target openroller-psp-pack "$repo_dir/tools/build_psp.sh" mkdir -p "$output_dir" cp "$repo_dir/psp/EBOOT.PBP" "$output_dir/EBOOT.PBP" "$repo_dir/build/openroller-psp-pack" "$stage_path" "$output_dir/stage.orps" if [ -z "$audio_path" ]; then stage_name=$(basename "$stage_path" .dat) song_token=${stage_name#ac_} song_token=${song_token%_easy} song_token=${song_token%_normal} song_token=${song_token%_hard} song_token=${song_token%_extra} audio_path=$(find "$(dirname "$stage_path")/sound" -maxdepth 1 -type f \ -iname "*_${song_token}_BGM.wav" -print -quit) fi if [ -n "$audio_path" ] && [ -f "$audio_path" ]; then ffmpeg -y -hide_banner -loglevel error -i "$audio_path" \ -map 0:a:0 -ar 44100 -ac 2 -c:a libmp3lame -b:a 128k \ -write_xing 0 -id3v2_version 0 "$output_dir/audio.mp3" else echo "Warning: BGM WAV was not found; demo will use the fallback timer" >&2 fi echo "Prepared: $output_dir"