"""Q7: completeness check on the headline claim.

CLAIM: the displayed rating is record+0xb4 and nothing else.
The evidence so far is that the literal OVERALL_RATING has exactly 4 xrefs and all 4
functions call FUN_1801a87f0 (+0xb4). That is only airtight if OVERALL_RATING is the
ONLY key under which a rating reaches the UI. Enumerate every .rdata literal that
contains "RATING" or "OVR" and report its xrefs, so a second rating key cannot hide.

CONTROL: the enumeration must re-find OVERALL_RATING with its 4 known xrefs.
"""
import traceback
try:
    seen = {}
    for pat in (b"RATING", b"OVR", b"Rating"):
        for a in find_all(pat):
            # walk back to the start of the C string
            s = a
            while s > a - 64:
                try:
                    if mem.getByte(addr(s - 1)) & 0xFF == 0:
                        break
                except Exception:
                    break
                s -= 1
            txt = rd_str(s, 96)
            if txt:
                seen.setdefault(txt, set()).add(s)
    for txt in sorted(seen):
        for a in sorted(seen[txt]):
            xs = xrefs_to(a)
            if not xs:
                continue
            print("%-44s @%#x" % (txt[:44], a))
            for frm, typ, fn, ent in xs:
                print("     %#x %-10s %s(%#x)" % (frm, typ, fn, ent))
except Exception:
    traceback.print_exc()
