urt-rs / scripts /analyze_md3_bindings.py
nmarshall's picture
assets: original model bindings
6b4b0f9
Raw History Blame Contribute Delete
1.92 kB
#!/usr/bin/env python3
"""Actual21581 model-binding requests correlated with original stored tag names."""
from pathlib import Path
from qvm_research_support import source,execute
from analyze_md3_inventory import paths,virtual
from md3 import MD3
from analyze_qvm import write_json
LOCAL=0x79e00000
def main():
q,raw,h,ins=source();data=raw[h['data_offset']:];files={virtual(p).casefold():p for p in paths()};loads=[];attachments=[];by_node={}
def text(p):return data[p:].split(b'\0')[0].decode('ascii')
def load(i,m,a,c):
request=text(a[8]);p=files[request.casefold()];node=0x79d00000+4096*len(loads);model=MD3(p.read_bytes());r={'request':request,'path':str(p),'stored_virtual_path':virtual(p),'case_exact':virtual(p)==request,'node':node,'first_frame_tags':[model.tag(0,j)['name'] for j in range(model.tags)],'loader_body_not_executed':True};loads.append(r);by_node[node]=r;return m,c,node,r
def attach(i,m,a,c):
tag=text(a[16]);parent=by_node[a[8]];child=by_node[a[12]];r={'parent':parent['request'],'child':child['request'],'tag':tag,'tag_index':parent['first_frame_tags'].index(tag) if tag in parent['first_frame_tags'] else None,'attachment_body_not_executed':True};attachments.append(r);return m,c,1,r
m,_,e=execute(ins,21582,21728,{},(0,0,0),LOCAL,{21730:load,21770:attach});write_json(Path('docs/research/md3-bindings.json'),{'source':q['source'],'sha256':q['sha256'],'loads':loads,'attachments':attachments,'selector_slots':{str(selector):{role:m[address+16*selector] for role,address in [('lower',35023864),('upper',35023860),('head',35023868),('helmet',35023872)]} for selector in [0,1]},'execution':e,'limits':'Actual21581 initializer request ordering and global writes;21730/21770 bodies captured with explicit node pointers. Original files/tag names matched case-insensitively without renaming or proving runtime VFS precedence.'})
if __name__=='__main__':main()