diff options
-rw-r--r-- | crystal.py | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1526,7 +1526,10 @@ class Command: def to_asm(self): #start with the rgbasm macro name for this command - output = self.macro_name + output = "" + if self.macro_name[0].isdigit(): + output += "_" + output += self.macro_name #return if there are no params if len(self.param_types.keys()) == 0: return output #first one will have no prefixing comma @@ -1835,6 +1838,31 @@ def create_command_classes(debug=False): return klasses command_classes = create_command_classes() +def generate_macros(filename="../script_macros.asm"): + """generates all macros based on commands + this is dumped into script_macros.asm""" + output = "; This file is generated by generate_macros.\n" + for command in command_classes: + output += "\n" + if command.macro_name[0].isdigit(): + output += "_" + output += command.macro_name + ": MACRO\n" + output += spacing + "db $%.2x\n"%(command.id) + current_param = 1 + for (index, each) in command.param_types.items(): + if issubclass(each["class"], SingleByteParam): + output += spacing + "db \\" + str(current_param) + "\n" + elif issubclass(each["class"], MultiByteParam): + output += spacing + "dw \\" + str(current_param) + "\n" + current_param += 1 + output += spacing + "ENDM\n" + + fh = open(filename, "w") + fh.write(output) + fh.close() + + return output + #use this to keep track of commands without pksv names pksv_no_names = {} def pretty_print_pksv_no_names(): |