From 42ef73422399c6ed4e30f7538547c3cf3ef44383 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 14 Apr 2023 23:30:36 +0200 Subject: Separate event code into separate procedures. So each procedure can have its own address space, and we don't break running games when one procedure is changed. --- tools/gencode.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/gencode.js b/tools/gencode.js index df8f0f1..ece66df 100644 --- a/tools/gencode.js +++ b/tools/gencode.js @@ -22,7 +22,8 @@ function emit(line) { console.log("\t[ " + line.join(", ") + " ],") } -console.log("const CODE = [") +console.log("const CODE = []") +let first = false for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { line = line.trim() @@ -33,14 +34,24 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { line = line.split(" ") switch (line[0]) { case "EVENT": - emit(["return"]) + if (first++) { + emit(["return"]) + console.log("]") + } UCODE[line[1]] = pc + console.log("") console.log("// EVENT " + line[1]) + console.log("CODE[" + line[1] + " * 2 + 0] = [") break case "SHADED": - emit(["return"]) + if (first++) { + emit(["return"]) + console.log("]") + } SCODE[line[1]] = pc + console.log("") console.log("// SHADED " + line[1]) + console.log("CODE[" + line[1] + " * 2 + 1] = [") break case "if_space": @@ -113,5 +124,3 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { emit(["return"]) console.log("]") -console.log("const UCODE = " + JSON.stringify(UCODE)) -console.log("const SCODE = " + JSON.stringify(SCODE)) -- cgit v1.2.3