"""Q25: is there a cardtype-9 sibling of FUN_180119bd0 for balls and league logos?

FUN_180119bd0 settles cardtype 7:  9 -> "FUT_UC_KITS"+TeamName_Abbr15_<teamid>
                                  10 -> "Stadium"+StadiumName_<assetId>
                                  11 -> "Badge"+TeamName_Abbr15_<teamid>
That leaves 0x1e and 0x1f (the only other cardtype-9 subtypes besides trophies
0x91..0x96 and misc 0xe7..0xec) for ball and league logo.

Dump the loc-key string neighbourhood the resolver draws from (0x1801ec700..
0x1801ed400 holds 'Stadium'/'Ball' literals) with xrefs, and xref the exact literals
"Stadium", "Badge", "FUT_UC_KITS" to find any sibling resolver. A function that
references a ball or league-logo caption is the cardtype-9 equivalent.

CONTROL: the literals "Stadium" and "Badge" must show FUN_180119bd0 as an xref. If
they do not, I am looking at different copies of those strings.
"""
import traceback

try:
    print("=== atoms 0xd1 and 0x19c (the two club-item wire strings) ===")
    for a in (0xD1, 0x19C):
        print("  %#x = %d" % (a, a))

    print()
    print("=== string dump 0x1801ec700..0x1801ed400 ===")
    p = 0x1801EC700
    while p < 0x1801ED400:
        try:
            b = mem.getByte(addr(p)) & 0xFF
        except Exception:
            p += 1
            continue
        if 0x20 <= b < 0x7F:
            s = rd_str(p, 120)
            if len(s) >= 3:
                who = ",".join(sorted({"%s(%#x)" % (fn, ent)
                                       for _f, _t, fn, ent in xrefs_to(p)}))
                print("  %#x %-46r %s" % (p, s, who))
            p += max(1, len(s)) + 1
        else:
            p += 1

    print()
    print("=== exact-literal xrefs ===")
    for lit in (b"Stadium\x00", b"Badge\x00", b"FUT_UC_KITS\x00", b"Ball\x00",
                b"BallName", b"LeagueLogo", b"leaguelogo", b"FUT_UC_"):
        for h in find_all(lit):
            s = rd_str(h, 80)
            who = ",".join(sorted({"%s(%#x)" % (fn, ent)
                                   for _f, _t, fn, ent in xrefs_to(h)}))
            print("  %-14r %#x %-30r <- %s" % (lit.rstrip(b"\x00").decode(), h, s, who or "-"))
except Exception:
    traceback.print_exc()
