mirror of https://github.com/pret/pokecrystal.git
starting dependencies work
This commit is contained in:
parent
a8da5fbda9
commit
c80279b98f
|
@ -1208,6 +1208,9 @@ class MultiByteParam():
|
|||
else:
|
||||
self.parsed_address = calculate_pointer_from_bytes_at(self.address, bank=None)
|
||||
|
||||
def get_dependencies(self):
|
||||
return []
|
||||
|
||||
#you won't actually use this to_asm because it's too generic
|
||||
#def to_asm(self): return ", ".join([(self.prefix+"%.2x")%x for x in self.bytes])
|
||||
def to_asm(self):
|
||||
|
@ -1243,6 +1246,11 @@ class PointerLabelParam(MultiByteParam):
|
|||
self.parsed_address = calculate_pointer_from_bytes_at(self.address, bank=self.bank)
|
||||
MultiByteParam.parse(self)
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = [script_parse_table[self.parsed_address]]
|
||||
dependencies.append(script_parse_table[self.parsed_address].get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
bank = self.bank
|
||||
#we pass bank= for whether or not to include a bank byte when reading
|
||||
|
@ -1482,6 +1490,14 @@ class Command:
|
|||
#start parsing this command's parameter bytes
|
||||
self.parse()
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = []
|
||||
for (key, param) in self.params.items():
|
||||
if hasattr("get_dependencies", param):
|
||||
deps = param.get_dependencies()
|
||||
dependencies.extend(deps)
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
#start with the rgbasm macro name for this command
|
||||
output = self.macro_name
|
||||
|
@ -1942,6 +1958,13 @@ class Script():
|
|||
self.commands = commands
|
||||
return commands
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = []
|
||||
for command in self.commands:
|
||||
deps = command.get_dependencies()
|
||||
dependencies.extend(deps)
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
asm_output = "".join([command.to_asm()+"\n" for command in self.commands])
|
||||
return asm_output
|
||||
|
@ -2438,6 +2461,13 @@ class SignpostRemoteBase:
|
|||
else: self.label = label
|
||||
self.parse()
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = []
|
||||
for p in self.params:
|
||||
deps = p.get_dependencies()
|
||||
dependencies.extend(deps)
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
"""very similar to Command.to_asm"""
|
||||
if len(self.params) == 0: return ""
|
||||
|
@ -2662,6 +2692,13 @@ class Signpost:
|
|||
self.params.append(mb)
|
||||
else:
|
||||
raise Exception, "unknown signpost type byte="+hex(func) + " signpost@"+hex(self.address)
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = []
|
||||
for p in self.params:
|
||||
dependencies.extend(p.get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
output = self.macro_name + " "
|
||||
if self.params == []: raise Exception, "signpost has no params?"
|
||||
|
@ -2776,6 +2813,11 @@ class MapHeader:
|
|||
self.time_of_day = DecimalParam(address=address+7)
|
||||
self.fishing_group = DecimalParam(address=address+8)
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = [self.second_map_header]
|
||||
dependencies.append(self.second_map_header.get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
output = "; bank, tileset, permission\n"
|
||||
output += "db " + ", ".join([self.bank.to_asm(), self.tileset.to_asm(), self.permission.to_asm()])
|
||||
|
@ -2903,6 +2945,12 @@ class SecondMapHeader:
|
|||
|
||||
return True
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = [self.script_header, self.event_header, self.blockdata]
|
||||
dependencies.append(self.script_header.get_dependencies())
|
||||
dependencies.append(self.event_header.get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
output = "; border block\n"
|
||||
output += "db " + self.border_block.to_asm() + "\n\n"
|
||||
|
@ -3071,6 +3119,12 @@ class MapEventHeader:
|
|||
self.last_address = after_signposts+1
|
||||
return True
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = self.people_events + self.signposts + self.xy_triggers + self.warps
|
||||
for p in list(dependencies):
|
||||
dependencies.extend(p.get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
xspacing = "" #was =spacing
|
||||
output = ""
|
||||
|
@ -3246,6 +3300,14 @@ class MapScriptHeader:
|
|||
print "done parsing a MapScriptHeader map_group="+str(map_group)+" map_id="+str(map_id)
|
||||
return True
|
||||
|
||||
def get_dependencies(self):
|
||||
dependencies = self.triggers
|
||||
for p in list(dependencies):
|
||||
dependencies.extend(p.get_dependencies())
|
||||
for callback in self.callbacks:
|
||||
dependencies.extend(callback["callback"].get_dependencies())
|
||||
return dependencies
|
||||
|
||||
def to_asm(self):
|
||||
output = ""
|
||||
output += "; trigger count\n"
|
||||
|
@ -4050,6 +4112,19 @@ def to_asm(some_object):
|
|||
asm += "\n; " + hex(last_address)
|
||||
return asm
|
||||
|
||||
def get_dependencies_for(some_object):
|
||||
"""
|
||||
calculates which labels need to be satisfied for an object
|
||||
to be inserted into the asm and compile successfully.
|
||||
|
||||
You could also choose to not insert labels into the asm, but
|
||||
then you're losing out on the main value of having asm in the
|
||||
first place.
|
||||
"""
|
||||
if isinstance(some_object, int):
|
||||
some_object = script_parse_table[some_object]
|
||||
return some_object.get_dependencies()
|
||||
|
||||
def isolate_incbins():
|
||||
"find each incbin line"
|
||||
global incbin_lines, asm
|
||||
|
|
Loading…
Reference in New Issue