adding non-byte-encoded characters into text to_asm output

This commit is contained in:
Bryan Bishop 2012-05-04 17:37:08 -05:00
parent 55e40b520e
commit 9ff78a901a
1 changed files with 26 additions and 5 deletions

View File

@ -1846,6 +1846,14 @@ class MainText(TextCommand):
if end: if end:
raise Exception, "the text ended due to a $50 or $57 but there are more bytes?" 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 # $4f, $51 and $55 can end a line
if byte in [0x4f, 0x51, 0x55]: if byte in [0x4f, 0x51, 0x55]:
assert not new_line, "can't have $4f, $51, $55 as the first character on a newline" 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 was_comma = False
end = True end = True
elif byte in chars.keys(): elif byte in chars.keys():
# figure out what the character actually is
char = chars[byte] char = chars[byte]
if char == "\"": if char == "\"":
pass if in_quotes:
pass 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: else:
# raise Exception, "unknown byte in text script ($%.2x)" % (byte) # 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? # just add an unknown byte directly to the text.. what's the worse that can happen?
if new_line:
output += "db "
if in_quotes: if in_quotes:
output += "\", $%.2x" % (byte) output += "\", $%.2x" % (byte)