fix some bugs in get_dependencies and to_asm

This commit is contained in:
Bryan Bishop
2012-04-21 03:15:56 -05:00
parent 7d6af535e9
commit 3b234223c5

View File

@@ -1240,6 +1240,7 @@ class PointerLabelParam(MultiByteParam):
#default is to not parse out a bank #default is to not parse out a bank
bank = False bank = False
force = False force = False
debug = False
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
#bank can be overriden #bank can be overriden
@@ -1261,8 +1262,9 @@ class PointerLabelParam(MultiByteParam):
def get_dependencies(self): def get_dependencies(self):
dependencies = [] dependencies = []
thing = script_parse_table[self.parsed_address] thing = script_parse_table[self.parsed_address]
if thing: if thing and thing.address == self.parsed_address:
print "parsed address is: " + hex(self.parsed_address) if self.debug:
print "parsed address is: " + hex(self.parsed_address) + " with label: " + thing.label + " of type: " + str(thing.__class__)
dependencies.append(thing) dependencies.append(thing)
dependencies.extend(thing.get_dependencies()) dependencies.extend(thing.get_dependencies())
return dependencies return dependencies
@@ -1956,9 +1958,7 @@ class Script():
print "parsing script; current_address is: " + hex(current_address) print "parsing script; current_address is: " + hex(current_address)
current_address += 1 current_address += 1
#continue #continue
asm_output = "" asm_output = "\n".join([command.to_asm() for command in commands])
for command in commands:
asm_output += command.to_asm() + "\n"
end = True end = True
continue continue
#XXX maybe a bad idea to not die ? #XXX maybe a bad idea to not die ?
@@ -1971,8 +1971,9 @@ class Script():
#current_address = cls.last_address + 1 #current_address = cls.last_address + 1
current_address += cls.size current_address += cls.size
#XXX set to "self" in script_parse_table when this moves into the Script class #XXX set to "self" in script_parse_table when this moves into the Script class
self.last_address = current_address
script_parse_table[start_address:current_address] = self script_parse_table[start_address:current_address] = self
asm_output = "".join([command.to_asm()+"\n" for command in commands]) asm_output = "\n".join([command.to_asm() for command in commands])
print "--------------\n"+asm_output print "--------------\n"+asm_output
self.commands = commands self.commands = commands
return commands return commands
@@ -2105,8 +2106,6 @@ class XYTrigger(Command):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.id = kwargs["id"] self.id = kwargs["id"]
#XYTrigger shouldn't really be in the globals, should it..
script_parse_table[kwargs["address"] : kwargs["address"] + self.size] = self
Command.__init__(self, *args, **kwargs) Command.__init__(self, *args, **kwargs)
def get_dependencies(self): def get_dependencies(self):
@@ -3196,11 +3195,14 @@ class MapEventHeader:
return True return True
def get_dependencies(self): def get_dependencies(self):
dependencies = self.people_events bases = []
dependencies += self.signposts bases += self.people_events
dependencies += self.xy_triggers bases += self.signposts
dependencies += self.warps bases += self.xy_triggers
for p in list(dependencies): bases += self.warps
dependencies = []
for p in bases:
dependencies.extend(p.get_dependencies()) dependencies.extend(p.get_dependencies())
return dependencies return dependencies
@@ -3240,7 +3242,6 @@ class MapEventHeader:
return output return output
all_map_event_headers = [] all_map_event_headers = []
def parse_map_event_header_at(address, map_group=None, map_id=None, debug=True, bank=None): def parse_map_event_header_at(address, map_group=None, map_id=None, debug=True, bank=None):
"""parse crystal map event header byte structure thing""" """parse crystal map event header byte structure thing"""
@@ -3408,14 +3409,13 @@ class MapScriptHeader:
output += "\n; triggers\n" output += "\n; triggers\n"
output += "\n".join(["dw "+p.to_asm() for p in self.triggers]) + "\n" output += "\n".join(["dw "+p.to_asm() for p in self.triggers]) + "\n"
output += "\n; callback count\n" output += "\n; callback count\n"
output += "db %d\n"%self.callback_count output += "db %d"%self.callback_count
if len(self.callbacks) > 0: if len(self.callbacks) > 0:
output += "\n; callbacks\n" output += "\n\n; callbacks\n"
#not so sure about this next one #not so sure about this next one
output += "\n".join(["dbw "+str(p["hook"].byte)+", "+p["callback"].to_asm() for p in self.callbacks]) output += "\n".join(["dbw "+str(p["hook"].byte)+", "+p["callback"].to_asm() for p in self.callbacks])
return output return output
all_map_script_headers = [] all_map_script_headers = []
def parse_map_script_header_at(address, map_group=None, map_id=None, debug=True): def parse_map_script_header_at(address, map_group=None, map_id=None, debug=True):
evv = MapScriptHeader(address, map_group=map_group, map_id=map_id, debug=debug) evv = MapScriptHeader(address, map_group=map_group, map_id=map_id, debug=debug)