ref: c21c0d45b35ff069df9033624f319ab1f2019294
parent: eb83f10dd4d21764f86f7dc32d953fcb3c927508
author: IIMarckus <iimarckus@gmail.com>
date: Fri Dec 16 18:54:36 EST 2011
Add a text preprocessor, so that we can enter strings in db commands. Depending on how well this works, it may be removed later. Hopefully not. hg-commit-id: d244e025471f
--- a/Makefile
+++ b/Makefile
@@ -4,11 +4,14 @@
pokered.gbc
cmp baserom.gbc pokered.gbc
-pokered.o: pokered.asm constants.asm
- rgbasm -o pokered.o pokered.asm
+pokered.o: pokered1.asm constants.asm
+ rgbasm -o pokered.o pokered1.asm
+pokered1.asm: pokered.asm
+ awk -f textpre.awk < pokered.asm > pokered1.asm
+
redrle: extras/redrle.c
${CC} -o $@ $>
clean:
- rm -f pokered.o pokered.gbc redrle
+ rm -f pokered1.asm pokered.o pokered.gbc redrle
--- /dev/null
+++ b/textpre.awk
@@ -1,0 +1,102 @@
+BEGIN {
+FS = "\""
+}
+
+# skip lines that actually do use ASCII in quotes
+tolower($1) ~ /section/ ||
+tolower($1) ~ /include/ ||
+tolower($1) ~ /incbin/
+
+!(tolower($1) ~ /section/ || tolower($1) ~ /include/ || tolower($1) ~ /incbin/) {
+i = 1
+ORS = ""
+char[" "] = "$7F"
+char["A"] = "$80"
+char["B"] = "$81"
+char["C"] = "$82"
+char["D"] = "$83"
+char["E"] = "$84"
+char["F"] = "$85"
+char["G"] = "$86"
+char["H"] = "$87"
+char["I"] = "$88"
+char["J"] = "$89"
+char["K"] = "$8A"
+char["L"] = "$8B"
+char["M"] = "$8C"
+char["N"] = "$8D"
+char["O"] = "$8E"
+char["P"] = "$8F"
+char["Q"] = "$90"
+char["R"] = "$91"
+char["S"] = "$92"
+char["T"] = "$93"
+char["U"] = "$94"
+char["V"] = "$95"
+char["W"] = "$96"
+char["X"] = "$97"
+char["Y"] = "$98"
+char["Z"] = "$99"
+char[":"] = "$9C"
+char["a"] = "$A0"
+char["b"] = "$A1"
+char["c"] = "$A2"
+char["d"] = "$A3"
+char["e"] = "$A4"
+char["f"] = "$A5"
+char["g"] = "$A6"
+char["h"] = "$A7"
+char["i"] = "$A8"
+char["j"] = "$A9"
+char["k"] = "$AA"
+char["l"] = "$AB"
+char["m"] = "$AC"
+char["n"] = "$AD"
+char["o"] = "$AE"
+char["p"] = "$AF"
+char["q"] = "$B0"
+char["r"] = "$B1"
+char["s"] = "$B2"
+char["t"] = "$B3"
+char["u"] = "$B4"
+char["v"] = "$B5"
+char["w"] = "$B6"
+char["x"] = "$B7"
+char["y"] = "$B8"
+char["z"] = "$B9"
+char["'"] = "$E0"
+char["?"] = "$E6"
+char["!"] = "$E7"
+char["."] = "$E8"
+char["/"] = "$F3"
+char[","] = "$F4"
+char["0"] = "$F6"
+char["1"] = "$F7"
+char["2"] = "$F8"
+char["3"] = "$F9"
+char["4"] = "$FA"
+char["5"] = "$FB"
+char["6"] = "$FC"
+char["7"] = "$FD"
+char["8"] = "$FE"
+char["9"] = "$FF"
+
+while (i <= NF) {
+if (i % 2 == 1)
+ print $(i)
+else {
+ f = $(i)
+ while (f != "") {
+ c = substr(f,1,1)
+ f = substr(f,2,length(f) - 1)
+ print char[c]
+ if (length(f))
+ print ","
+ }
+}
+
+i = i + 1
+}
+print "\n"
+ORS = "\n"
+}