use a $50 macro to stop some text scripts

This commit is contained in:
Bryan Bishop 2012-05-04 23:03:03 -05:00
parent 2489165312
commit 8a064dfb45
1 changed files with 21 additions and 5 deletions

View File

@ -385,7 +385,8 @@ def command_debug_information(command_byte=None, map_group=None, map_id=None, ad
#info1 += " long_info: " + long_info #info1 += " long_info: " + long_info
return info1 return info1
class NewTextScript: all_texts = []
class TextScript:
""" A text is a sequence of bytes (and sometimes commands). It's not the """ A text is a sequence of bytes (and sometimes commands). It's not the
same thing as a Script. The bytes are translated into characters based same thing as a Script. The bytes are translated into characters based
on the lookup table (see chars.py). The in-text commands are for including on the lookup table (see chars.py). The in-text commands are for including
@ -394,8 +395,11 @@ class NewTextScript:
see: http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText see: http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText
""" """
base_label = "UnknownText_" base_label = "UnknownText_"
def __init__(self, address, map_group=None, map_id=None, debug=False, label=None, force=False): def __init__(self, address, map_group=None, map_id=None, debug=False, label=None, force=False, show=None):
self.address = address self.address = address
# $91, $84, $82, $54, $8c
if address in [0x26f2, 0x6ee, 0x1071, 0x5ce33, 0x69523, 0x7ee98, 0x72176, 0x7a578, 0x19c09b]:
return None
self.map_group, self.map_id, self.debug = map_group, map_id, debug self.map_group, self.map_id, self.debug = map_group, map_id, debug
self.dependencies = None self.dependencies = None
self.commands = None self.commands = None
@ -487,6 +491,7 @@ class NewTextScript:
# store the script in the global table/map thing # store the script in the global table/map thing
script_parse_table[start_address:current_address] = self script_parse_table[start_address:current_address] = self
all_texts.append(self)
if self.debug: if self.debug:
asm_output = "\n".join([command.to_asm() for command in commands]) asm_output = "\n".join([command.to_asm() for command in commands])
@ -501,8 +506,7 @@ class NewTextScript:
asm_output = "\n".join([command.to_asm() for command in self.commands]) asm_output = "\n".join([command.to_asm() for command in self.commands])
return asm_output return asm_output
all_texts = [] class OldTextScript:
class TextScript:
"a text is a sequence of commands different from a script-engine script" "a text is a sequence of commands different from a script-engine script"
base_label = "UnknownText_" base_label = "UnknownText_"
def __init__(self, address, map_group=None, map_id=None, debug=True, show=True, force=False, label=None): def __init__(self, address, map_group=None, map_id=None, debug=True, show=True, force=False, label=None):
@ -1999,6 +2003,7 @@ class MainText(TextCommand):
new_line = True new_line = True
was_comma = False was_comma = False
end = True end = True
self.end = True
elif byte == 0x57: elif byte == 0x57:
# close any quotes # close any quotes
if in_quotes: if in_quotes:
@ -2074,6 +2079,8 @@ class MainText(TextCommand):
if output[-1] == "\n": if output[-1] == "\n":
output = output[:-1] output = output[:-1]
self.size = len(self.bytes)
return output return output
class WriteTextFromRAM(TextCommand): class WriteTextFromRAM(TextCommand):
@ -2266,6 +2273,15 @@ class TextJump(TextCommand):
param_types = { param_types = {
0: {"name": "text", "class": TextPointerLabelAfterBankParam}, 0: {"name": "text", "class": TextPointerLabelAfterBankParam},
} }
# this is needed because sometimes a script ends with $50 $50
class TextEndingCommand(TextCommand):
id = 0x50
macro_name = "db"
override_byte_check = False
size = 1
end = True
def to_asm(self):
return "db $50"
text_command_classes = inspect.getmembers(sys.modules[__name__], \ text_command_classes = inspect.getmembers(sys.modules[__name__], \
lambda obj: inspect.isclass(obj) and \ lambda obj: inspect.isclass(obj) and \