#!/usr/bin/env bash # Capture the LOADING screen's draw order. No navigation and no pad input at all: # the loading screen appears on its own during the boot, which matters because # (A) at the title only works about half the time. # # Why this screen: GP_TITLE's 10-element loading build declares its FULL-SCREEN # element (`pgloading_baseeff`, 640x360 at 200%) SEVENTH of ten, behind the # spinner and the "NOW LOADING" text. So it can tell "declaration order" apart # from "background first" — which the main menu could not, because its # background sits at index 1. # # F10 arms the capture (unconditionally, since 2026-08-19) and also opens the # emulator's menu bar, so each press is followed by a click on the game surface. set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 SD="$(cd "$(dirname "$0")" && pwd)" OUT="${1:-/sylph-home/re/loadcap}" mkdir -p "$OUT"; rm -f "$OUT"/xenia_re_ui_draws_*.log shot(){ screenshot "$1" >/dev/null 2>&1; } alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; } ( cd "$OUT" && nohup run-canary --mem_watch=false \ --ui_draw_capture_frames=4 --ui_draw_capture_max=6000 \ --logged_profile_slot_0_xuid=B13EBABEBABEBABE \ >"$OUT/canary.stdout" 2>"$OUT/canary.stderr" & ) sleep 8 until xdotool search --name "Xenia-canary" >/dev/null 2>&1; do [ -n "$(alive)" ] || { echo "EMULATOR GONE"; exit 4; }; sleep 1 done win="$(xdotool search --name "Xenia-canary" | tail -1)" xdotool windowactivate --sync "$win"; sleep 1 for i in $(seq 1 "${PRESSES:-28}"); do shot "$OUT/frame-$(printf '%02d' "$i").png" xdotool key F10; sleep 1 xdotool mousemove 900 400 click 1 s=$(python3 "$SD/screen_id.py" "$OUT/frame-$(printf '%02d' "$i").png" | awk '{print $1}') echo "press $i at ${SECONDS}s (screen=$s)" [ "$s" = "title" ] && { echo "title reached; stopping"; break; } sleep 5 done ls "$OUT"/xenia_re_ui_draws_*.log 2>/dev/null | wc -l echo "LOADING CAPTURE DONE (emulator left running)"