#!/usr/bin/env python3 """Is this screenshot the MAIN MENU or EXTRAS? screen_id.py cannot tell them apart. Both are dark-blue `GP_TITLE` screens, so `screen_id.py` reports `menu` for either. This correlates the grab against our own build 5 / build 6 renders and reports which is closer, plus the margin -- a small margin means "cannot tell", not "the closer one". ⚠️ These are OUR renders, so this identifies a screen by agreeing with our decoding. It is a navigation aid for driving the emulator, NOT evidence about the game. Nothing measured is allowed to rest on it. which_title_screen.py [ref_dir] """ import sys import numpy as np from PIL import Image def load(p, shape=None): im = Image.open(p).convert("RGB") a = np.asarray(im, dtype=float) return a def main(): grab = load(sys.argv[1]) d = sys.argv[2] if len(sys.argv) > 2 else "/sylph-home/re/ref" # The game surface sits at y=45 ONLY in a full 1280x720 display frame; a # 1279x675 grab is the surface already. Hard-coding the 45 made this tool fail # its own control -- it called the main menu "extras" and extras "main_menu", # because two of the three reference captures are surface-sized. off = 45 if grab.shape[0] >= 716 else 0 best = [] for b, name in ((5, "main_menu"), (6, "extras")): r = load(f"{d}/build{b}.png") h = min(grab.shape[0] - off, r.shape[0]); w = min(grab.shape[1], r.shape[1]) g = grab[off:off + h, :w]; rr = r[:h, :w] best.append((float(np.sqrt(((g - rr) ** 2).mean())), name)) best.sort() margin = best[1][0] - best[0][0] print(f"{best[0][1]} rmse={best[0][0]:.2f} (other {best[1][1]} {best[1][0]:.2f}, margin {margin:.2f})") return 0 if __name__ == "__main__": raise SystemExit(main())