summaryrefslogtreecommitdiff
path: root/tools/gencode.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-04-14 23:30:36 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-03 18:48:16 +0200
commit42ef73422399c6ed4e30f7538547c3cf3ef44383 (patch)
treec3150db51e79f1a4cf08298f2817f0e860e31c81 /tools/gencode.js
parentb2b8cfe7a7c130f5fd0a734188ae4a7ffd4e66c9 (diff)
downloadandean-abyss-42ef73422399c6ed4e30f7538547c3cf3ef44383.tar.gz
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.
Diffstat (limited to 'tools/gencode.js')
-rw-r--r--tools/gencode.js19
1 files changed, 14 insertions, 5 deletions
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))