add param_types to configure each text script command macro

This commit is contained in:
Bryan Bishop 2012-05-04 20:47:43 -05:00
parent 7d17027ffb
commit fde936ac46
1 changed files with 48 additions and 0 deletions

View File

@ -1579,6 +1579,23 @@ class TextPointerLabelParam(PointerLabelParam):
else: else:
return [] return []
class TextPointerLabelAfterBankParam(PointerLabelAfterBank):
text = None
def parse(self):
PointerLabelAfterBank.parse(self)
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank)
if address != None and address != 0:
self.text = parse_text_engine_script_at(address, map_group=self.map_group, map_id=self.map_id, force=self.force, debug=self.debug)
if not self.text:
self.text = script_parse_table[address]
def get_dependencies(self, recompute=False, global_dependencies=set()):
if self.text:
global_dependencies.add(self.text)
return [self.text]
else:
return []
class MovementPointerLabelParam(PointerLabelParam): class MovementPointerLabelParam(PointerLabelParam):
pass pass
@ -1777,6 +1794,7 @@ class TextCommand(Command):
# some text commands can specify this upfront but not $0 # some text commands can specify this upfront but not $0
size = None size = None
param_types = {}
params = [] params = []
# most text commands won't have any dependencies # most text commands won't have any dependencies
@ -1982,6 +2000,9 @@ class WriteTextFromRAM(TextCommand):
id = 0x1 id = 0x1
macro_name = "text_from_ram" macro_name = "text_from_ram"
size = 3 size = 3
param_types = {
0: {"name": "pointer", "class": PointerLabelParam},
}
class WriteNumberFromRAM(TextCommand): class WriteNumberFromRAM(TextCommand):
""" """
02 = Write number from ram. Structure: [02][Ram address (2byte)][Byte] 02 = Write number from ram. Structure: [02][Ram address (2byte)][Byte]
@ -2004,16 +2025,28 @@ class WriteNumberFromRAM(TextCommand):
id = 0x2 id = 0x2
macro_name = "number_from_ram" macro_name = "number_from_ram"
size = 4 size = 4
param_types = {
0: {"name": "pointer", "class": PointerLabelParam},
1: {"name": "config", "class": HexByte},
}
class SetWriteRAMLocation(TextCommand): class SetWriteRAMLocation(TextCommand):
"Define new ram address to write to. Structure: [03][Ram address (2byte)]" "Define new ram address to write to. Structure: [03][Ram address (2byte)]"
id = 0x3 id = 0x3
macro_name = "store_at" macro_name = "store_at"
size = 3 size = 3
param_types = {
0: {"name": "ram address", "class": PointerLabelParam},
}
class ShowBoxWithValueAt(TextCommand): class ShowBoxWithValueAt(TextCommand):
"04 = Write a box. Structure: [04][Ram address (2byte)][Y][X]" "04 = Write a box. Structure: [04][Ram address (2byte)][Y][X]"
id = 0x4 id = 0x4
macro_name = "text_box" macro_name = "text_box"
size = 5 size = 5
param_types = {
0: {"name": "ram address", "class": PointerLabelParam},
1: {"name": "y", "class": DecimalParam},
2: {"name": "x", "class": DecimalParam},
}
class Populate2ndLineOfTextBoxWithRAMContents(TextCommand): class Populate2ndLineOfTextBoxWithRAMContents(TextCommand):
"05 = New ram address to write to becomes 2nd line of a text box. Structure: [05]" "05 = New ram address to write to becomes 2nd line of a text box. Structure: [05]"
id = 0x5 id = 0x5
@ -2037,6 +2070,7 @@ class TextInlineAsm(TextCommand):
id = 0x8 id = 0x8
macro_name = "start_asm" macro_name = "start_asm"
end = True end = True
# TODO: parse the following asm with gbz80disasm
class WriteDecimalNumberFromRAM(TextCommand): class WriteDecimalNumberFromRAM(TextCommand):
""" """
09 = Write number from rom/ram in decimal. Structure: [09][Ram address/Pointer (2byte)][Byte] 09 = Write number from rom/ram in decimal. Structure: [09][Ram address/Pointer (2byte)][Byte]
@ -2051,6 +2085,10 @@ class WriteDecimalNumberFromRAM(TextCommand):
id = 0x9 id = 0x9
macro_name = "deciram" macro_name = "deciram"
size = 4 size = 4
param_types = {
0: {"name": "pointer?", "class": PointerLabelParam},
1: {"name": "config", "class": HexByte},
}
class InterpretDataStream(TextCommand): class InterpretDataStream(TextCommand):
""" """
0A = Interpret Data stream. Structure: [0A] 0A = Interpret Data stream. Structure: [0A]
@ -2073,6 +2111,9 @@ class LimitedIntrepretDataStream(TextCommand):
id = 0xC id = 0xC
macro_name = "limited_interpret_data" macro_name = "limited_interpret_data"
size = 2 size = 2
param_types = {
0: {"name": "number of codes to interpret", "class": DecimalParam},
}
class WaitForKeyDownDisplayArrow(ShowArrowsAndButtonWait): class WaitForKeyDownDisplayArrow(ShowArrowsAndButtonWait):
""" """
0D = Wait for key down display arrow. Structure: [0D] 0D = Wait for key down display arrow. Structure: [0D]
@ -2125,16 +2166,23 @@ class DisplayByteFromRAMAt(TextCommand):
id = 0x14 id = 0x14
macro_name = "show_byte_at" macro_name = "show_byte_at"
size = 2 size = 2
param_types = {
1: {"name": "memory byte id", "class": DecimalParam},
}
class WriteCurrentDay(TextCommand): class WriteCurrentDay(TextCommand):
"15 = Write current day. Structure: [15]" "15 = Write current day. Structure: [15]"
id = 0x15 id = 0x15
macro_name = "current_day" macro_name = "current_day"
size = 1 size = 1
class TextJump(TextCommand): class TextJump(TextCommand):
"16 = 3byte pointer to new text follows. Structure: [16][2byte pointer][bank]" "16 = 3byte pointer to new text follows. Structure: [16][2byte pointer][bank]"
id = 0x16 id = 0x16
macro_name = "text_jump" macro_name = "text_jump"
size = 4 size = 4
param_types = {
0: {"name": "text", "class": TextPointerLabelAfterBankParam},
}
#byte: [name, [param1 name, param1 type], [param2 name, param2 type], ...] #byte: [name, [param1 name, param1 type], [param2 name, param2 type], ...]
#0x9E: ["verbosegiveitem", ["item", ItemLabelByte], ["quantity", SingleByteParam]], #0x9E: ["verbosegiveitem", ["item", ItemLabelByte], ["quantity", SingleByteParam]],