# Verify every seg-5 VTX offset and SETTIMG w1 target falls inside a modeled object. import struct, zlib exec(open("tools_pc/d43_sizes.py").read().split("stats = []")[0]) RSZ = {1:0x10,2:0x1C,4:0x14,8:0x10,9:0x24,10:0x1C,12:0x28,13:0x20, 15:0x1C,17:0x20,18:0x8,21:0x14,22:0x10,23:2,24:0x20} def be32(b,o): return struct.unpack_from(">I",b,o)[0] def off(p): # vma 0x05xxxxxx -> file offset; non-vma pointers are invalid return (p & 0xFFFFFF) if (p >> 24) == 5 else None def walk(out,D,NS,NT): R0n=4*NS+12*NT stack=[R0n]; seen=set(); objs=[]; gdls=[] while stack: o=stack.pop() if o in seen or o>=D-23: break seen.add(o) op=struct.unpack_from(">H",out,o)[0]&0xff data=be32(out,o+4) objs.append((o,24,"node")) rec=off(data) if rec is not None and rech",out,rec+0xC)[0] if op==24 else struct.unpack_from(">H",out,rec+0x10)[0] if nv>0 and v is not None and vh",out,rec+0xE)[0] cv=off(be32(out,rec+0x10)); pu=off(be32(out,rec+0x14)) if nc>0 and cv is not None and cv0 and pu is not None and pui",out,rec)[0]; v=off(be32(out,rec+4)) p=off(be32(out,rec+8)) if nv>0 and v is not None and v>24 w1=be32(out,o+4) top=(w1>>24)&0xff if t==4 and top==5: tot_vtx+=1 x=w1&0xffffff if not any(s<=x