"""DIMENSION 5 SBC/Objectives -- query 3.

Find the SBC MENU gate. Established: no SBC gate byte in publisher; enableSquadBuilding
SetsFeature not read by CardsDLL. So is there ANY CardsDLL SBC gate/publish, or is it
script-layer?

- xrefs_to(0x180154990): how is the SBC stub loader dispatched (vtable slot?).
- broad string scan for SBC/squad-building surface + any xref that is a publisher emit
  (lea in .text) vs pure dictionary (DATA in .data dict region 0x1802d2xxx).
- hub tile builder FUN_1800b2680: does it feature-gate SBC?
- squadBuildingSetsClientData atom 0x2cf: is there a massinfo parser arm? what does it set?
"""
import traceback
try:
    print("=== xrefs_to(0x180154990) ===")
    for frm, typ, fn, ent in xrefs_to(0x180154990):
        print("  from %#x  %s  in %s (%#x)" % (frm, typ, fn, ent))

    print("\n=== string surface: SBC / squad-building / challenge feature ===")
    for n in (b"IS_SBC", b"SBC_ENABLED", b"SQUAD_BUILD", b"SquadBuildingSets",
              b"squadBuildingSets", b"FUT_SBC", b"futsquadbuildingchallenge",
              b"SquadBuildingChallenge", b"MANAGER_TASKS", b"IS_OBJECTIVE",
              b"OBJECTIVES_ENABLED", b"managerquest", b"ManagerQuest"):
        hits = find_all(n)
        if not hits:
            continue
        for h in hits:
            xs = xrefs_to(h)
            # classify each xref: DATA in dict region vs code lea
            tags = []
            for frm, typ, fn, ent in xs:
                where = "DICT" if 0x1802d2000 <= frm < 0x1802d4000 else ("CODE:%s(%#x)@%#x" % (fn, ent, frm))
                tags.append("%s/%s" % (typ, where))
            print("  %r @%#x  xrefs=%s" % (rd_str(h, 48), h, tags or "NONE"))

    print("\n=== hub tile builder FUN_1800b2680 (SBC feature gate?) ===")
    d = dec(0x1800b2680)
    print("LEN", len(d))
    print(d[:6000])
except Exception:
    traceback.print_exc()
