diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-05-04 17:37:08 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-05-04 17:37:08 -0500 |
commit | 9ff78a901a160eb227c21811986a3f0ab0f72f89 (patch) | |
tree | 62a05b0b0048bf5feda8f9a37870d2be591aefff /extras/crystal.py | |
parent | 55e40b520ec498630398ad302085868df870cf49 (diff) |
adding non-byte-encoded characters into text to_asm output
Diffstat (limited to 'extras/crystal.py')
-rw-r--r-- | extras/crystal.py | 31 |
1 files 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) |