From 11177b9b7d6257c1ec3118296e010e243ec5bb74 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 20 May 2012 02:15:40 -0500 Subject: [PATCH] spit out trainer id constants --- extras/crystal.py | 32 +++++++++++++++++++++++++++++++- extras/trainers.py | 5 ++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/extras/crystal.py b/extras/crystal.py index 46c3161ef..2de5e13ad 100644 --- a/extras/crystal.py +++ b/extras/crystal.py @@ -3624,6 +3624,12 @@ class TrainerHeader: seed = self.seed_constant_name else: seed = self.name + + if "?" in seed: + seed = trainer_group_names[self.trainer_group_id]["name"]+"_"+seed[-1] + elif self.trainer_group_id == 0x1f and "EXECUTIVE" in seed: + seed = "GRUNT_"+seed + return string.capwords(seed).\ replace("@", "").\ replace(" & ", "AND").\ @@ -3905,7 +3911,7 @@ def make_trainer_group_name_trainer_ids(debug=True): for header in trainer_group_table.headers: trainer_names = [] # (name, trainer_header) dupes = set() - group_id = i + group_id = i group_name = header.group_name for trainer_header in header.individual_trainer_headers: if trainer_header.name in [x[0] for x in trainer_names]: @@ -3928,6 +3934,30 @@ def make_trainer_group_name_trainer_ids(debug=True): if debug: print "done improving trainer names" +def pretty_print_trainer_id_constants(): + """ Prints out some constants for trainer ids, for "constants.asm". + + make_trainer_group_name_trainer_ids must be called prior to this. + """ + assert trainer_group_table != None, "must make trainer_group_table first" + assert trainer_group_names != None, "must have trainer_group_names available" + assert "trainer_names" in trainer_group_names[1].keys(), "trainer_names must be set in trainer_group_names" + + output = "" + for (key, value) in trainer_group_names.items(): + if "uses_numeric_trainer_ids" in trainer_group_names[key].keys(): + continue + id = key + group = value + header = group["header"] + name = group["name"] + trainer_names = group["trainer_names"] + output += "; " + name + "\n" + for (id, name) in enumerate(trainer_names): + output += name.upper() + " EQU $%.2x"%(id+1) + "\n" + output += "\n" + return output + class PeopleEvent(Command): size = people_event_byte_size macro_name = "person_event" diff --git a/extras/trainers.py b/extras/trainers.py index d5564b6d3..0a465a099 100644 --- a/extras/trainers.py +++ b/extras/trainers.py @@ -98,9 +98,8 @@ def remove_parentheticals_from_trainer_group_names(): .replace("é", "e") # and calculate the address of the first byte of this pointer - trainer_group_names[key] = {"name": newvalue, - "pointer_address": trainer_group_pointer_table_address + (i * 2), - } + trainer_group_names[key]["name"] = newvalue + trainer_group_names[key]["pointer_address"] = trainer_group_pointer_table_address + (i * 2) i += 1 return trainer_group_names