code wiki / (root) / nx_wasmfit.nx

nx_wasmfit.nx

buildroot/runtime/nx_wasmfit.nx

6510 B109 linesdepth 3pulls 4 transitivereach 217 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_wasmfit.nx -- THE ONE RULER FOR "CAN THIS MODULE'S FRAMEBUFFER EXIST IN THE MEMORY IT DECLARES". WHY IT IS A LIBRARY AND NOT A CHECK INSIDE AN EMITTER. On 2026-08-14 /craft shipped BLACK TWICE: its framebuffer had outgrown the module's own declared linear memory (needed 22,022,528 bytes against 192 pages = 12,582,912), so every browser frame trapped with "index out of bounds". The guard that now refuses that was written INSIDE nx_game_page_emit's gpe_build_s, whose header claimed "every wasm page in the estate is built through this function -- one guard here covers all of them". THAT CLAIM WAS FALSE, AND MEASURED SO ON 2026-08-15. nx_wasmpage_census walked all 62,906 shipped html pages: 25 carry an embedded wasm module, and only 9 come from gpe_build_s. The other 16 -- pong, racing, td, city, shmup, explorer, adventure, voxelworld, sudoku and the rest -- are emitted by organs that each hand-pasted their own copy of the same blit shim and none of the guard. ★★★★★★A GUARD PLACED IN "THE" SHARED PATH IS ONLY AS BROAD AS THE CLAIM THAT THE PATH IS SHARED, AND THAT CLAIM IS A MEASUREMENT NOBODY TOOK. The census took it and the answer was 9 of 25. So the ruler moves DOWN here, where any emitter can reach it, and gpe_build_s becomes one of its callers rather than its owner. ★EXTEND THE INCUMBENT, NEVER ADD A SECOND RULER: the arithmetic below is gpe_build_s's, moved rather than re-typed, so there is exactly one definition of "fits" in the estate and no opportunity for two of them to drift. It asks the ARTIFACT, never a constant typed in another file: wm_parse reads the module's own memory section, and fb_off/ww/hh are the module's own accessors. With no init() the quality slot is zero, which clamps to the FINEST setting, so ww/hh report the worst case the adaptive controller can ever reach -- exactly the case that has to fit. Cheap by construction: three accessor calls and no render, so it costs nothing per emit and there is no reason for any caller to skip it. license_tier: ORIGINAL

dependencies 2 imports · 83 importers

nx_syscalls.nx nx_wasm_vm.nx nx_wasmfit.nx nx_game_page_affine_candidate_t361 nx_game_page_authored_material_t54 nx_game_page_body_t138.nx nx_game_page_canonical_t135.nx nx_game_page_catwalk_lighting_cand nx_game_page_emit.nx nx_game_page_emit_sand_review.nx nx_game_page_eye_t138.nx nx_game_page_gait_candidate_t139.n nx_game_page_garment_t132.nx

diagram shows first 10 each side; +0 more imports, +73 more importers in the complete lists below.

imports: nx_syscalls.nxnx_wasm_vm.nx

imported by: nx_game_page_affine_candidate_t361.nxnx_game_page_authored_material_t54.nxnx_game_page_body_t138.nxnx_game_page_canonical_t135.nxnx_game_page_catwalk_lighting_candidate_t316.nxnx_game_page_emit.nxnx_game_page_emit_sand_review.nxnx_game_page_eye_t138.nxnx_game_page_gait_candidate_t139.nxnx_game_page_garment_t132.nxnx_game_page_gpu_timing_current_candidate.nxnx_game_page_gpu_timing_pool_candidate.nxnx_game_page_hair_attachment_candidate_t263.nxnx_game_page_hair_attachment_t283.nxnx_game_page_hair_guides_candidate_t263.nxnx_game_page_hair_t138.nxnx_game_page_host_candidate_t341.nxnx_game_page_identity_candidate.nxnx_game_page_imported_body_t45.nxnx_game_page_imported_t262.nxnx_game_page_inspection_distance_t235.nxnx_game_page_inspection_t142.nxnx_game_page_integrated_t73.nxnx_game_page_knight_bind_t25.nxnx_game_page_knight_feedback_t28.nxnx_game_page_knight_feedback_t29.nxnx_game_page_knight_support_t31.nxnx_game_page_knight_support_t31_before_t44.nxnx_game_page_length_diag_t140.nxnx_game_page_lit_candidate_t181.nxnx_game_page_material_body_t61.nxnx_game_page_material_candidate_t181.nxnx_game_page_material_compose_t55.nxnx_game_page_material_schema_candidate_t181.nxnx_game_page_metadata_candidate_t220.nxnx_game_page_mip_candidate_t241.nxnx_game_page_motion_candidate_t328.nxnx_game_page_motion_inventory_candidate_t330.nxnx_game_page_move_t72.nxnx_game_page_owned_candidate_t181.nxnx_game_page_pipeline_t64.nxnx_game_page_pre_inspection_t142.nxnx_game_page_pre_toon_region_t143.nxnx_game_page_procedural_review_candidate_t333.nxnx_game_page_recovery_feedback_t28.nxnx_game_page_recovery_t23.nxnx_game_page_rig_comparison_t332.nxnx_game_page_rig_inspection_t230.nxnx_game_page_rig_observation_candidate_t331.nxnx_game_page_scene_light_candidate_t364.nxnx_game_page_search_t53.nxnx_game_page_shared_candidate_t340.nxnx_game_page_skin_t138.nxnx_game_page_static_candidate_t338.nxnx_game_page_toon_region_candidate_t143.nxnx_game_page_visitors_inspection_t142.nxnx_game_page_visitors_t140.nxnx_game_page_workbench_candidate_t342.nxnx_game_page_workspace_body_t49.nxnx_game_page_workspace_body_t59.nxnx_game_page_workspace_t48.nxnx_movement_base_page_t139.nxnx_sim_page.nxnx_simlab_html.nxnx_solarsim_html.nxnx_sudoku_html.nxnx_wasm_adventure_html.nxnx_wasm_arcade_html.nxnx_wasm_charlab_html.nxnx_wasm_city_html.nxnx_wasm_diablo_html.nxnx_wasm_explodelab_html.nxnx_wasm_html.nxnx_wasm_html_fps.nxnx_wasm_html_vox3d.nxnx_wasm_mineworld_html.nxnx_wasm_mineworld_mp_html.nxnx_wasm_physlab_html.nxnx_wasm_pong_html.nxnx_wasm_racing_html.nxnx_wasm_shmup_html.nxnx_wasm_td_html.nxnx_wasm_thirdperson_html.nx

structs

none

consts

30const WF_PROCEED: i64 = 0
31const WF_REFUSE: i64 = 1
43const WF_NUMBUF: i64 = 32

functions

44func wf_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
46func wf_num_b() -> *u8 { if WF_NUM_B == 0 { WF_NUM_B = sys_mmap(WF_NUMBUF) as i64 } return WF_NUM_B as *u8 }
48func wf_num_t() -> *u8 { if WF_NUM_T == 0 { WF_NUM_T = sys_mmap(WF_NUMBUF) as i64 } return WF_NUM_T as *u8 }
49func wf_num(v: i64) -> i64
70func wf_guard(wasm: *u8, wn: i64, who: *u8) -> i64
105func wf_nosurface(who: *u8) -> i64