summaryrefslogtreecommitdiff
path: root/extras/crystal.py
diff options
context:
space:
mode:
Diffstat (limited to 'extras/crystal.py')
-rw-r--r--extras/crystal.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/extras/crystal.py b/extras/crystal.py
index 6502fa24f..3c003cd2d 100644
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -1090,6 +1090,7 @@ class EncodedText:
if not label:
label = self.base_label + hex(address)
self.label = Label(name=label, address=address, object=self)
+ self.dependencies = None
self.parse()
script_parse_table[self.address : self.last_address] = self
@@ -1110,6 +1111,10 @@ class EncodedText:
end_address = offset + jump #we want the address before $57
text = parse_text_at2(offset, end_address-offset, debug=self.debug)
+
+ if jump == jump50:
+ text += "@"
+
self.text = text
self.last_address = self.end_address = end_address
@@ -1164,7 +1169,6 @@ class EncodedText:
commands = process_00_subcommands(address, address+count, debug=debug)
for (line_id, line) in commands.items():
output += parse_text_from_bytes(line, debug=debug, japanese=japanese)
- output += "\n"
texts.append([address, output])
return output
@@ -1716,7 +1720,8 @@ class TrainerIdParam(SingleByteParam):
trainer_group_id = self.parent.params[foundit].byte
# check the rule to see whether to use an id or not
- if "uses_numeric_trainer_ids" in trainer_group_names[trainer_group_id].keys():
+ if ("uses_numeric_trainer_ids" in trainer_group_names[trainer_group_id].keys()) or \
+ (not "trainer_names" in trainer_group_names[trainer_group_id].keys()):
return str(self.byte)
else:
return trainer_group_names[trainer_group_id]["trainer_names"][self.byte-1]
@@ -1740,6 +1745,7 @@ class MenuDataPointerParam(PointerLabelParam):
pass
+string_to_text_texts = []
class RawTextPointerLabelParam(PointerLabelParam):
#not sure if these are always to a text script or raw text?
def parse(self):
@@ -1755,6 +1761,21 @@ class RawTextPointerLabelParam(PointerLabelParam):
global_dependencies.add(self.text)
return [self.text]
+class EncodedTextLabelParam(PointerLabelParam):
+ def parse(self):
+ PointerLabelParam.parse(self)
+
+ address = calculate_pointer_from_bytes_at(self.address, bank=False)
+ self.parsed_address = address
+ self.text = EncodedText(address, map_group=self.map_group, map_id=self.map_id, debug=self.debug)
+
+ if isinstance(self.text, EncodedText):
+ string_to_text_texts.append(self.text)
+
+ def get_dependencies(self, recompute=False, global_dependencies=set()):
+ global_dependencies.add(self.text)
+ return [self.text]
+
class TextPointerLabelParam(PointerLabelParam):
"""this is a pointer to a text script"""
bank = False
@@ -2762,7 +2783,7 @@ pksv_crystal_more = {
0x41: ["itemtotext", ["item", ItemLabelByte], ["memory", SingleByteParam]],
0x42: ["mapnametotext", ["memory", SingleByteParam]], #not pksv
0x43: ["trainertotext", ["trainer_id", TrainerGroupParam], ["trainer_group", TrainerIdParam], ["memory", SingleByteParam]],
- 0x44: ["stringtotext", ["text_pointer", RawTextPointerLabelParam], ["memory", SingleByteParam]],
+ 0x44: ["stringtotext", ["text_pointer", EncodedTextLabelParam], ["memory", SingleByteParam]],
0x45: ["itemnotify"],
0x46: ["pocketisfull"],
0x47: ["loadfont"],
@@ -3436,9 +3457,11 @@ class TrainerFragment(Command):
# give this object a possibly better label
label = "Trainer"
- if "uses_numeric_trainer_ids" in trainer_group_names[trainer_group].keys():
+ if ("uses_numeric_trainer_ids" in trainer_group_names[trainer_group].keys()) \
+ or ("trainer_names" not in trainer_group_names[trainer_group].keys()):
label += string.capwords(trainer_group_names[trainer_group]["constant"])
- if len(trainer_group_names[trainer_group]["trainer_names"]) > 1:
+ if "trainer_names" in trainer_group_names[trainer_group].keys() \
+ and len(trainer_group_names[trainer_group]["trainer_names"]) > 1:
label += str(trainer_id)
else:
label += string.capwords(trainer_group_names[trainer_group]["constant"]) + \