diff options
| author | LLLL Colonq <llll@colonq> | 2026-07-17 15:19:40 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-07-17 15:19:40 -0400 |
| commit | 631fbd3a6567afa5ed9c5f8bb5fe1f32480fabc6 (patch) | |
| tree | f584b775cb7832448b06cf3c222cc953d160bc91 /2026/games_submissions/liquidcake1/funge.mjs | |
| parent | 07a36f2b38a5cba402ebc5158710f5a85f443456 (diff) | |
Update
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);*/ |
