code wiki / (root) / nx_imported_body_craft_gate_t43.nx

nx_imported_body_craft_gate_t43.nx source

↩ module page · 33 lines · 2766 B

1import "_hdl_build/nx_wasm_craft_imported_body_t42.nx" 2import "nx_nxa_bind.nx" 3static bc_checks:i64=0 4static bc_failures:i64=0 5func bc_check(ok:i64,label:*u8)->i64{bc_checks=bc_checks+1;if ok==1{nb_text("PASS " as *u8)}else{bc_failures=bc_failures+1;nb_text("FAIL " as *u8)};nb_text(label);nb_text("\n" as *u8);return 0} 6func main()->i64{ 7 let mem:*u8=sys_mmap(CRAFT_EXT_TOTAL+8);let base:i64=mem as i64 8 let fence:*i64=(base+CRAFT_EXT_TOTAL) as *i64;fence[0]=773311 9 bc_check(wc_body_init(base,2,CRAFT_EXT_TOTAL-1)==IBR_CAPACITY,"arena boundary refuses undersized memory" as *u8) 10 bc_check(wc_body_init(base,IMPORTED_BODY_CAP+1,CRAFT_EXT_TOTAL)==IBR_CAPACITY,"runtime capacity refuses reserved overflow" as *u8) 11 bc_check(wc_body_init(base,2,CRAFT_EXT_TOTAL)==0,"explicit imported registry init" as *u8) 12 let record:*i64=(base+O_IMPORTED_STAGE) as *i64 13 record[IBR_ID_HI]=7;record[IBR_ID_LO]=111;record[IBR_REV]=1;record[IBR_SHAPE_REV]=1;record[IBR_POSE_REV]=1 14 record[IBR_WORLD_X]=1000;record[IBR_WORLD_Y]=0;record[IBR_WORLD_Z]=1024 15 record[IBR_MIN_X]=0-100;record[IBR_MIN_Y]=0;record[IBR_MIN_Z]=0-100 16 record[IBR_MAX_X]=100;record[IBR_MAX_Y]=500;record[IBR_MAX_Z]=100 17 record[IBR_LAYER]=4;record[IBR_MASK]=BODY_LAYER_PLAYER|BODY_LAYER_NPC;record[IBR_ENABLED]=1;record[IBR_KIND]=1 18 let handle:i64=wc_body_bind(base) 19 bc_check(handle>0&&wc_body_bind(base)==handle,"native staging bind is idempotent" as *u8) 20 let state:*i64=wst(base);state[S_CX]=0;state[S_CY]=EYE;state[S_CZ]=1024 21 bc_check(wc_player_axis_apply(base,0,2000,0)==900&&state[S_CX]==900,"actual player movement stops at imported body" as *u8) 22 bc_check(wc_contact_state(base)[1]==1,"existing player collision audit sees imported contact" as *u8) 23 bc_check(wc_body_mob_axis(base,0,0,1024,0,2000)==900-MOB_R_Q8,"resident NPC movement clips against imported body" as *u8) 24 bc_check(wc_body_mob_axis(base,0,600,1024,0,2000)==2000,"NPC on another altitude remains free" as *u8) 25 state[S_CX]=0-4096;state[S_WOX]=16 26 bc_check(wc_player_axis_apply(base,0,2000,0)==900&&state[S_CX]==900-4096,"player owner uses same absolute body after origin shift" as *u8) 27 bc_check(ibr_find(wc_body_arena(base),7,111)==handle,"body identity survives origin and render-independent movement" as *u8) 28 state[S_CX]=1000-4096 29 bc_check(wc_player_axis_apply(base,0,100,0)==0&&state[S_CX]==1000-4096&&wc_contact_result(base).initial_overlap==1,"embedded player reports overlap without arbitrary teleport" as *u8) 30 bc_check(fence[0]==773311,"fixed imported body region preserves end canary" as *u8) 31 nb_text("BODY_CRAFT_GATE checks=" as *u8);nb_num(bc_checks);nb_text(" failures=" as *u8);nb_num(bc_failures);nb_text(" actual_wasm=UNQUALIFIED page_bind=UNWIRED save_version=UNWIRED\n" as *u8) 32 if bc_failures!=0{return 3};return 0 33}