dump scripting macros into script_macros.asm

This commit is contained in:
Bryan Bishop 2012-04-25 20:02:40 -05:00
parent f61e028871
commit cb1a372d75
3 changed files with 888 additions and 1 deletions

View File

@ -1,3 +1,5 @@
INCLUDE "script_macros.asm"
; macro for putting a byte then a word
dbw: MACRO
db \1

View File

@ -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():

857
script_macros.asm Normal file

File diff suppressed because it is too large Load Diff