Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/physics0/pd0_world_main.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / physics0 / pd0_world_main.om` 55 lines ยท 1286 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note src/physics0/pd0_world_main.om: pd0-world 3 note Reads framed requests on stdin, writes framed responses on stdout, exits at EOF. 4 5 text P0WM_USAGE "usage: pd0-world \n" 6 text P0WM_BADLVL "pd0-world: bad level\n" 7 text P0WM_NULL "null" 8 9 fn p0wm_parse_u64 buf view uchar * n ulong to ulong 10 v = ulong 0 11 for i ulong n bound 32 12 c = get buf i 13 if and ge c uchar 48 le c uchar 57 14 v = add mul v ulong 10 ulong sub c uchar 48 15 end 16 end 17 ret v 18 end 19 20 fn main to int 21 ac = argcnt 22 if ne ac long 3 23 pd0_puts 2 P0WM_USAGE 24 ret 2 25 end 26 a1 = new uchar 32 0 27 a2 = new uchar 32 0 28 n1 = argread 1 a1 0 32 29 n2 = argread 2 a2 0 32 30 if or le n1 long 0 le n2 long 0 31 pd0_puts 2 P0WM_USAGE 32 ret 2 33 end 34 level = int -1 35 if and eq n1 long 4 eq pd0_eq_bytes view a1 ulong 0 P0WM_NULL ulong 4 1 36 level = PD0_LEVEL_NULL 37 else 38 if and eq n1 long 1 and ge get a1 0 uchar 48 le get a1 0 uchar 54 39 level = int sub get a1 0 uchar 48 40 end 41 end 42 seed = p0wm_parse_u64 view a2 ulong n2 43 w = new Pd0World 0 0 0 0 0 0 0 0 0 0 0 0 0 44 d = new Pd0Desc 0 0 0 0 0 0 0 0 0 0 45 g = new Pd0Gen 0 0 0 0 0 0 0 46 if ne pd0_world_init edit w edit d edit g level seed 0 47 pd0_puts 2 P0WM_BADLVL 48 ret 2 49 end 50 rc = pd0_world_serve edit w view d view g 0 1 51 if eq rc 0 52 ret 0 53 end 54 ret 1 55 end