#!/usr/bin/env python3 """Is a modal YES/NO dialog on screen? Written because `wait_screen.sh --tap A` BLIND-taps A, and on this game's "Load game?" dialog the cursor starts on **NO** — so a blind tap answers NO, drops back to the save list, and the next tap reopens the dialog. That is a stable oscillation, and it burned three consecutive 300 s boots as "NO readyroom" while d-pad and A both worked perfectly. The game dims the whole frame behind a modal, so the dialog is detectable without knowing which dialog it is: sample the band where the modal sits and compare its brightness against the undimmed screen. Measured on the LOAD GAME save list (1279x675): save list, no dialog mean 59.0 / 62.4 p95 164 / 199 "Load game?" dialog up mean 34.4 p95 113 so the threshold sits at 45. Used ONLY to decide whether tapping A is safe: with a dialog up, A is the affirmative/OK button; without one, A may mean something destructive like "open the dialog again". ⚠️ Calibrated on 1 positive and 2 negatives — thin. Widen it as runs collect more frames. Usage: dialog_up.py -> prints metrics, exit 0 if a dialog is up """ import sys import numpy as np from PIL import Image THRESHOLD = 45.0 def metric(path): im = np.asarray(Image.open(path).convert("L"), dtype=float) h, w = im.shape box = im[int(h * 0.33):int(h * 0.48), int(w * 0.28):int(w * 0.72)] return float(box.mean()), float(np.percentile(box, 95)) if __name__ == "__main__": mean, p95 = metric(sys.argv[1]) up = mean < THRESHOLD print("%s mean=%.1f p95=%.1f threshold=%.0f" % ("dialog" if up else "no-dialog", mean, p95, THRESHOLD)) sys.exit(0 if up else 1)