"""DIM4 Q1/Q2/Q3/Q4. Decompile the 12 market RESPONSE deserializers to confirm/extend
their atom sets, plus the error-envelope mapper FUN_1801844c0 (reached when the
ISOfferTrade code is NOT 0x1cd) and the two URL builders Ghidra left undefined.

CONTROL: FutISSearch 0x180163420 and FutGetTradePile 0x180170810 are documented HIGH
in ENDPOINT_MAP as tail-delegating to the shared IS-list body 0x18013e7f0. If the
decompile of those two shows the call to 0x18013e7f0, the deser VAs in ENDPOINT_MAP
are right and the same list can be trusted for the MED ones (RelistAll, ISWatchTrade,
ISRemoveTrade, ISRemoveWatch) whose bodies were only partially read.
"""
import traceback
try:
    DESER = [
        ("FutISSearch(CONTROL)",       0x180163420),
        ("FutGetTradePile(CONTROL)",   0x180170810),
        ("FutISStart",                 0x180165d70),
        ("FutISViewTrade",             0x1801644d0),
        ("FutISWatchList",             0x180166130),
        ("FutISWatchTrade",            0x180164cd0),
        ("FutISOfferTrade",            0x180165410),
        ("FutISRemoveTrade",           0x1801648d0),
        ("FutISRemoveWatch",           0x1801659f0),
        ("FutRelistAll",               0x180164210),
        ("FutGetAuctionCount",         0x180163670),
        ("FutGetSuggestedPricing",     0x180163bb0),
        ("errenvelope_generic",        0x1801844c0),
        ("dupItemIdList elem",         0x180138e10),
    ]
    for nm, a in DESER:
        print("\n########## %s @ %#x ##########" % (nm, a))
        f = func(a)
        print("fn=%s @ %#x" % (f.getName() if f else "NONE",
              int(f.getEntryPoint().getOffset()) if f else 0))
        s = dec(a)
        print("len(src)=%d" % len(s)); print(s)
    # who READS the per-action enable byte at actiontable row+0x21?
    print("\n########## xrefs to action table 0x1802caa20 and row0 flag 0x1802caa41 ##########")
    for a in (0x1802caa20, 0x1802caa40, 0x1802caa41):
        print(" -- %#x" % a)
        for frm, typ, fn, ent in xrefs_to(a):
            print("    from %#x %s in %s @ %#x" % (frm, typ, fn, ent))
except Exception:
    traceback.print_exc()
