code wiki / (root) / nx_body_head_profile_gate_t366.nx

nx_body_head_profile_gate_t366.nx source

↩ module page · 28 lines · 1705 B

1import "nx_syscalls.nx" 2import "nx_gate_verdict.nx" 3func hpg_u32(b:*u8,o:i64)->i64{return (b[o] as i64)|((b[o+1] as i64)<<8)|((b[o+2] as i64)<<16)|((b[o+3] as i64)<<24)} 4func main(argc:i64,argv:*i64)->i64{ 5 if argc!=3{return 2};var an:i64=0;var bn:i64=0 6 let a:*u8=sys_read_file(argv[1] as *u8,&an);let b:*u8=sys_read_file(argv[2] as *u8,&bn) 7 if (a as i64)<=0||(b as i64)<=0||an<16||bn<16{return 3} 8 let c:*i64=gv_ctr();gv_head("HEAD-PROFILE-SOURCE-PRESERVATION") 9 let nl:i64=hpg_u32(a,8);let nt:i64=hpg_u32(a,12);let hdr:i64=16+nl*24 10 // Exact pinned recipe t345: these counts bind this fixture, not a generic parser policy. 11 gv_check("actual three-layer fixture extent",nl==3&&nt==103824&&an==hdr+nt*88&&bn==an,c) 12 if nl!=3||nt!=103824||an!=hdr+nt*88||bn!=an{return 4} 13 var header:i64=1;var i:i64=0;while i<hdr{if a[i]!=b[i]{header=0};i=i+1} 14 var untouched:i64=1;var attrs:i64=1;var changed:i64=0;var t:i64=0 15 while t<nt{ 16 let local:i64=t%34608;let ishead:i64=local>=19768&&local<21840 17 var different:i64=0;i=0 18 while i<84{if a[hdr+t*84+i]!=b[hdr+t*84+i]{if i<72{different=1;if ishead==0{untouched=0}}else{attrs=0}};i=i+1} 19 if different==1{changed=changed+1};t=t+1 20 } 21 i=hdr+nt*84;while i<an{if a[i]!=b[i]{attrs=0};i=i+1} 22 gv_check("headers and ranges preserved",header==1,c) 23 gv_check("all nonhead positions and normals byte-identical",untouched==1,c) 24 gv_check("all triangle colors and layer IDs byte-identical",attrs==1,c) 25 gv_check("mapped head geometry actually changed",changed>0&&changed<=2072*3,c) 26 gv_kv("changed_head_triangles_all_layers",changed) 27 return gv_verdict("HEAD-PROFILE-SOURCE-PRESERVATION",c,"identity preservation only; shape quality and source correspondence unaccepted") 28}