summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-04-25 20:02:40 -0500
committerBryan Bishop <kanzure@gmail.com>2012-04-25 20:02:40 -0500
commitd4f698e64d194c0b58cafb439284ce7d9db4b07d (patch)
treef3e0798f362e5ad61025e011511ace2c58460028
parentcb825e39a7e24095ad4ea4cb035012ed27d8d244 (diff)
dump scripting macros into script_macros.asm
original-commit-id: cb1a372d759a027669d8012160bc2e627ea7372b
-rw-r--r--crystal.py30
1 files changed, 29 insertions, 1 deletions
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():