diff options
| author | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
| commit | de99c5f7636a952025ea13de02bafd25bcb6bdec (patch) | |
| tree | be359424af4f6717103e3b667b6529ae5a4b4e6a /2026/games_submissions/liquidcake1/funge.mjs | |
| parent | 4d4d1f24721f27fbf37e1070be6414de130ace61 (diff) | |
Fix broken
Diffstat (limited to '2026/games_submissions/liquidcake1/funge.mjs')
| -rw-r--r-- | 2026/games_submissions/liquidcake1/funge.mjs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/2026/games_submissions/liquidcake1/funge.mjs b/2026/games_submissions/liquidcake1/funge.mjs new file mode 100644 index 0000000..a6fb723 --- /dev/null +++ b/2026/games_submissions/liquidcake1/funge.mjs @@ -0,0 +1,42 @@ +let file_name = process.argv[2]; + +import { readFileSync } from "fs"; + +let field_s = readFileSync(file_name, "utf8"); +//console.log(field_s); + +let field = field_s.split("\n"); +field.pop(); +field = field.map( x => x.split("").map( c => c.charCodeAt(0) ) ); +//console.log(field); + +import { Interpreter } from "./interpreter.mjs"; +import { load_wasm } from "./wasm.mjs"; +import { overlay as SOCK_overlay } from "./overlays/SOCK.mjs"; +import { overlay as S_overlay } from "./overlays/S.mjs"; +import { overlay as WS_overlay } from "./overlays/WS.mjs"; + +let interpreter = new Interpreter(); + +interpreter.load_overlay("S", S_overlay); +interpreter.load_overlay("SOCK", SOCK_overlay); +interpreter.load_overlay("WS", WS_overlay); + +let instance = await load_wasm(interpreter); + +interpreter.field = field; +interpreter.input_queue.push(["set_speed", 100]); +//interpreter.input_queue.push(["set_speed", 90]); +interpreter.input_queue.push(["pause"]); +interpreter.input_queue.push(["unpause"]); +interpreter.add_handler("char_out", function(arg) { process.stdout.write(arg); }); +//interpreter.add_handler("output_field", function(lines) { lines.forEach(function(line) {process.stdout.write(line + "\n"); })}); +interpreter.add_handler("terminate", function() { process.exit(0); }); +interpreter.go(); +process.stdin.on('data', function (chunk) { + chunk.forEach(x => interpreter.input_queue.push(["stdin", x])); +}); +/*setTimeout(function () { + console.log("sending @"); + interpreter.input_queue.push(["stdin", "@".charCodeAt(0)]); +}, 2000);*/ |
