summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-05-11 10:58:35 -0700
committerBryan Bishop <kanzure@gmail.com>2013-05-11 10:58:35 -0700
commitce187ca03f3f26610d485cd523caeb39319a2607 (patch)
treeb967cd198414e1b2ec12555df9235eac655c6ca1
parente6165edadfe5e801679305eaba8b3895f360cba7 (diff)
parentac391b7b8e52e24e6669b68471175eb033c199e0 (diff)
Merge pull request #129 from yenatch/master
preprocessor print macro + fix make lzs target
-rw-r--r--extras/gfx.py5
-rw-r--r--preprocessor.py37
2 files changed, 39 insertions, 3 deletions
diff --git a/extras/gfx.py b/extras/gfx.py
index a09e230e3..8b9a66ff1 100644
--- a/extras/gfx.py
+++ b/extras/gfx.py
@@ -1440,6 +1440,7 @@ def mass_to_colored_png(debug=False):
to_png(os.path.join(root, name), None, os.path.join(root, os.path.splitext(name)[0]+'.pal'))
else:
to_png(os.path.join(root, name))
+ os.touch(os.path.join(root, name))
# only monster and trainer pics for now
for root, dirs, files in os.walk('../gfx/pics/'):
@@ -1450,11 +1451,14 @@ def mass_to_colored_png(debug=False):
to_png(os.path.join(root, name), None, os.path.join(root, 'normal.pal'))
else:
to_png(os.path.join(root, name))
+ os.touch(os.path.join(root, name))
+
for root, dirs, files in os.walk('../gfx/trainers/'):
for name in files:
if debug: print os.path.splitext(name), os.path.join(root, name)
if os.path.splitext(name)[1] == '.2bpp':
to_png(os.path.join(root, name), None, os.path.join(root, name[:-5]+'.pal'))
+ os.touch(os.path.join(root, name))
def mass_decompress(debug=False):
@@ -1479,6 +1483,7 @@ def mass_decompress(debug=False):
else:
with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read())
to_file(os.path.join(root, os.path.splitext(name)[0]+'.2bpp'), de.output)
+ os.touch(os.path.join(root, name))
def append_terminator_to_lzs(directory):
# fix lzs that were extracted with a missing terminator
diff --git a/preprocessor.py b/preprocessor.py
index 0d68c74ba..67e4cdb9f 100644
--- a/preprocessor.py
+++ b/preprocessor.py
@@ -352,6 +352,11 @@ def quote_translator(asm):
sys.stdout.write(asm)
return
+ print_macro = False
+ if asms[0].strip() == 'print':
+ asms[0] = asms[0].replace('print','db 0,')
+ print_macro = True
+
output = ""
even = False
i = 0
@@ -359,6 +364,7 @@ def quote_translator(asm):
i = i + 1
if even:
+ characters = []
# token is a string to convert to byte values
while len(token):
# read a single UTF-8 codepoint
@@ -393,10 +399,35 @@ def quote_translator(asm):
char = char + token[0]
token = token[1:]
- output += ("${0:02X}".format(chars[char]))
+ characters += [char]
+
+ if print_macro:
+ line = 0
+ while len(characters):
+ last_char = 1
+ if len(characters) > 18 and characters[-1] != '@':
+ for i, char in enumerate(characters):
+ last_char = i + 1
+ if ' ' not in characters[i+1:18]: break
+ output += ", ".join("${0:02X}".format(chars[char]) for char in characters[:last_char-1])
+ if characters[last_char-1] != " ":
+ output += ", ${0:02X}".format(characters[last_char-1])
+ if not line & 1:
+ line_ending = 0x4f
+ else:
+ line_ending = 0x51
+ output += ", ${0:02X}".format(line_ending)
+ line += 1
+ else:
+ output += ", ".join(["${0:02X}".format(chars[char]) for char in characters[:last_char]])
+ characters = characters[last_char:]
+ if len(characters): output += ", "
+ # end text
+ line_ending = 0x57
+ output += ", ${0:02X}".format(line_ending)
+
+ output += ", ".join(["${0:02X}".format(chars[char]) for char in characters])
- if len(token):
- output += (", ")
# if not even
else:
output += (token)