Files
BT411/scratchpad/afc_dump.py
T
arcattackandClaude Fable 5 fcaea1862a Diag: BT_AF_PERIOD=<sec> autofire cadence throttle + afc_dump.py (raw RES verify)
Closes the coolant/jam investigation. BT_AF_PERIOD pulses the trigger every <sec>s so
a slower-than-max fire rate can be tested; afc_dump.py reads the AFC100 record raw from
BTL4.RES. Both confirm the QA report is FAITHFULLY reproduced (see KB).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 07:26:12 -05:00

38 lines
1.4 KiB
Python

import struct
data = open(r'C:/git/bt411/content/BTL4.RES','rb').read()
n = len(data)
def f32(o): return struct.unpack_from('<f', data, o)[0]
def i32(o): return struct.unpack_from('<i', data, o)[0]
def cstr(o, m=32):
s = data[o:o+m].split(b'\0')[0]
try: return s.decode('ascii')
except: return None
# find AFC100 subsystem records (name @+0, classID @+0x20)
hits=[]
i=0
while i < n-0x28:
if data[i:i+7]==b'AFC100\0':
cid=struct.unpack_from('<I',data,i+0x20)[0]
sz=struct.unpack_from('<I',data,i+0x24)[0]
if 0xBB0<=cid<=0xBE5 and 0xE0<=sz<=0x300:
hits.append((i,cid,sz))
i+=1
print("AFC100 records:", [(hex(p),hex(c),hex(s)) for p,c,s in hits])
if hits:
p,cid,sz=hits[0]
print(f"\n=== AFC100 @ {hex(p)} classID={hex(cid)} size={hex(sz)} ===")
# dump the offsets the loader reads (per heat.cpp / mechweap.hpp comments)
fields = {
0xE4:"startingTemp", 0xE8:"degradationTemp", 0xEC:"failureTemp",
0xF0:"thermalConductance", 0xF4:"thermalMass",
0x1A4:"heatCostToFire", 0x1CC:"minJamChance",
}
for off,name in sorted(fields.items()):
print(f" +{hex(off):>6} {name:20} f32={f32(p+off):<16g} i32={i32(p+off)}")
print("\n --- full float scan (offset: value) for plausible fields 0xE0..0x1E0 ---")
for off in range(0xE0, 0x1E0, 4):
v=f32(p+off)
if abs(v)>1e-3 and abs(v)<1e12:
print(f" +{hex(off):>6}: {v:g}")