From 9ff78a901a160eb227c21811986a3f0ab0f72f89 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 4 May 2012 17:37:08 -0500 Subject: [PATCH] adding non-byte-encoded characters into text to_asm output --- extras/crystal.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/extras/crystal.py b/extras/crystal.py index 3e1d18ea0..964348076 100644 --- a/extras/crystal.py +++ b/extras/crystal.py @@ -1846,6 +1846,14 @@ class MainText(TextCommand): if end: raise Exception, "the text ended due to a $50 or $57 but there are more bytes?" + if new_line: + if in_quotes: + raise Exception, "can't be in_quotes on a newline" + elif was_comma: + raise Exception, "last line's last character can't be a comma" + + output += "db " + # $4f, $51 and $55 can end a line if byte in [0x4f, 0x51, 0x55]: assert not new_line, "can't have $4f, $51, $55 as the first character on a newline" @@ -1880,18 +1888,31 @@ class MainText(TextCommand): was_comma = False end = True elif byte in chars.keys(): + # figure out what the character actually is char = chars[byte] if char == "\"": - pass - pass + if in_quotes: + output += "\"" + in_quotes = False + if not in_quotes: + if new_line: + output += "\"" + elif not new_line: + if not was_comma: + output += ", " + output += "\"" + in_quotes = True + else: + output += char + + new_line = False + was_comma = False + end = False else: # raise Exception, "unknown byte in text script ($%.2x)" % (byte) # just add an unknown byte directly to the text.. what's the worse that can happen? - if new_line: - output += "db " - if in_quotes: output += "\", $%.2x" % (byte)