8 //print: function(text) { for(var i=0; i<text.length; i++) document.write(String.fromCharCode(text.charCodeAt(i))); },
9 print: function(text
) { console
.log(text
); },
10 printErr: function(text
) { console
.log("stderr| " + text
); },
12 //Execute the default em_main instead of main
13 setupArgV: function(text
)
18 var argv
= text
.replace(/[\s]+/g," ").split(" ");
21 //Allocate C stack memory for the arg pointers
22 //argv_ptr = Runtime.stackAlloc(argc * PTR_BYTES);
23 argv_ptr
= Module
._malloc(argc
* PTR_BYTES
);
26 for(var i
= 0; i
< argc
; i
++)
28 //stack allocate for each argument
29 arg_ptrs
[i
] = Module
._malloc(argv
[i
].length
+1);
30 //Add to argv's list of pointers in c-memory, then copy data
31 setValue(argv_ptr
+ i
* PTR_BYTES
, arg_ptrs
[i
], 'i32');
32 writeStringToMemory(argv
[i
], arg_ptrs
[i
]);
37 execute: function(func_name
, args
)
40 console
.log(func_name
);
41 func_name(argc
,argv_ptr
, 0);
48 FS
.mount(IDBFS
, {}, '/auth');
49 FS
.syncfs(true, function (err
) {
50 console
.log("synching failed with err:" + err
);
57 function start_game(event
)
59 Module
.execute(_em_main
, "the_march");
61 document
.getElementById("launch_game").addEventListener("click", start_game
, false);