--- /dev/null
+var Module =
+ {
+ 'noExitRuntime': true,
+ 'arguments': [],
+
+ print: function(text) { for(var i=0; i<text.length; i++) document.write(String.fromCharCode(text.charCodeAt(i))); document.write("<br />");},
+ printErr: function(text) { console.log("ERR: " + text); },
+
+ //Execute the default em_main instead of main
+ execute: function(text)
+ {
+ const PTR_BYTES = 4;
+
+ //Parse argv and argc
+ var argv = text.replace(/[\s]+/g," ").split(" ");
+ var argc = argv.length;
+
+ //Allocate C stack memory for the arg pointers
+ var argv_ptr = Runtime.stackAlloc(argc * PTR_BYTES);
+
+ var arg_ptrs = [];
+ for(var i = 0; i < argc; i++)
+ {
+ //stack allocate for each argument
+ arg_ptrs[i] = Runtime.stackAlloc(argv[i].length+1);
+ //Add to argv's list of pointers in c-memory, then copy data
+ setValue(argv_ptr + i * PTR_BYTES, arg_ptrs[i], 'i32');
+ writeStringToMemory(argv[i], arg_ptrs[i]);
+ }
+
+ _em_main(argc, argv_ptr, 0);
+ }
+ };
+
+function start_game(event)
+{
+ Module.execute("the_march");
+};
+document.getElementById("launch_game").addEventListener("click", start_game, false);
+