From d4f698e64d194c0b58cafb439284ce7d9db4b07d Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Wed, 25 Apr 2012 20:02:40 -0500 Subject: dump scripting macros into script_macros.asm original-commit-id: cb1a372d759a027669d8012160bc2e627ea7372b --- crystal.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/crystal.py b/crystal.py index e485a2f..94fa35c 100644 --- a/crystal.py +++ b/crystal.py @@ -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(): -- cgit v1.2.3