6 print: function(text
) { for(var i
=0; i
<text
.length
; i
++) document
.write(String
.fromCharCode(text
.charCodeAt(i
))); document
.write("<br />");},
7 printErr: function(text
) { console
.log("ERR: " + text
); },
9 //Execute the default em_main instead of main
10 execute: function(text
)
15 var argv
= text
.replace(/[\s]+/g," ").split(" ");
16 var argc
= argv
.length
;
18 //Allocate C stack memory for the arg pointers
19 var argv_ptr
= Runtime
.stackAlloc(argc
* PTR_BYTES
);
22 for(var i
= 0; i
< argc
; i
++)
24 //stack allocate for each argument
25 arg_ptrs
[i
] = Runtime
.stackAlloc(argv
[i
].length
+1);
26 //Add to argv's list of pointers in c-memory, then copy data
27 setValue(argv_ptr
+ i
* PTR_BYTES
, arg_ptrs
[i
], 'i32');
28 writeStringToMemory(argv
[i
], arg_ptrs
[i
]);
31 _em_main(argc
, argv_ptr
, 0);
35 function start_game(event
)
37 Module
.execute("the_march");
39 document
.getElementById("launch_game").addEventListener("click", start_game
, false);