summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-01-10 16:25:57 -0600
committerBryan Bishop <kanzure@gmail.com>2013-01-10 16:25:57 -0600
commit458709fc77519585aea4c9865d7325e17d6506fe (patch)
tree2c1295d14bed2ddc3ad50b23b55d3e925219f239
parent849a57c9f1583f975d3d01eacd6083493633c7df (diff)
combine multiple calls to sys.stdout.write
-rw-r--r--preprocessor.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/preprocessor.py b/preprocessor.py
index 2d3244e75..d340382fe 100644
--- a/preprocessor.py
+++ b/preprocessor.py
@@ -512,6 +512,8 @@ def macro_translator(macro, token, line):
# used for storetext
correction = 0
+ output = ""
+
index = 0
while index < len(params):
param_type = macro.param_types[index - correction]
@@ -528,24 +530,24 @@ def macro_translator(macro, token, line):
if (byte_type == "dw" and size != 2) or \
(byte_type == "db" and size != 1):
- sys.stdout.write("; " + description + "\n")
+ output += ("; " + description + "\n")
if size == 3 and issubclass(param_klass, PointerLabelBeforeBank):
# write the bank first
- sys.stdout.write("db " + params[index].strip() + "\n")
+ output += ("db " + param + "\n")
# write the pointer second
- sys.stdout.write("dw " + params[index+1].strip() + "\n")
+ output += ("dw " + params[index+1].strip() + "\n")
index += 2
correction += 1
elif size == 3 and issubclass(param_klass, PointerLabelAfterBank):
# write the pointer first
- sys.stdout.write("dw " + params[index].strip() + "\n")
+ output += ("dw " + param + "\n")
# write the bank second
- sys.stdout.write("db " + params[index+1].strip() + "\n")
+ output += ("db " + params[index+1].strip() + "\n")
index += 2
correction += 1
elif size == 3 and issubclass(param_klass, MoneyByteParam):
- sys.stdout.write("db " + MoneyByteParam.from_asm(params[index]) + "\n")
+ output += ("db " + MoneyByteParam.from_asm(param) + "\n")
index += 1
else:
raise Exception, "dunno what to do with this macro " + \
@@ -554,10 +556,12 @@ def macro_translator(macro, token, line):
# or just print out the byte
else:
- sys.stdout.write(byte_type + " " + param + " ; " + description + "\n")
+ output += (byte_type + " " + param + " ; " + description + "\n")
index += 1
+ sys.stdout.write(output)
+
def include_file(asm):
"""This is more reliable than rgbasm/rgbds including files on its own."""