update star_rod_idx_to_c.py for battle formations

This commit is contained in:
alex 2021-12-30 14:22:44 +00:00
parent 0bba296295
commit 3c2bd694e5
No known key found for this signature in database
GPG Key ID: E907B20C17C70B03
2 changed files with 20 additions and 10 deletions

View File

@ -5,7 +5,7 @@ from pathlib import Path
_script_lib = None
def script_lib(offset):
def script_lib(offset=0):
global _script_lib
if not _script_lib:
@ -476,12 +476,16 @@ def replace_constants(self, func, args):
class ScriptDisassembler:
def __init__(self, bytes, script_name = "script", symbol_map = {}, romstart = 0, INCLUDES_NEEDED = {"forward": [], "sprites": set(), "npcs": []}, INCLUDED = {"functions": set(), "includes": set()}, prelude = True, transform_symbol_name=None):
def __init__(self, bytes, script_name = "script", symbol_map = {}, romstart = 0, INCLUDES_NEEDED = {"forward": [], "sprites": set(), "npcs": []}, INCLUDED = {"functions": set(), "includes": set()}, prelude = True, transform_symbol_name=None, use_script_lib=True):
self.bytes = bytes
self.script_name = script_name
self.prelude = prelude
self.symbol_map = extend_symbol_map(symbol_map, script_lib(self.bytes.tell()))
if use_script_lib:
self.symbol_map = extend_symbol_map(symbol_map, script_lib(self.bytes.tell()))
else:
self.symbol_map = symbol_map
self.romstart = romstart
self.transform_symbol_name = transform_symbol_name
self.INCLUDES_NEEDED = INCLUDES_NEEDED

View File

@ -137,6 +137,7 @@ def disassemble(bytes, midx, symbol_map={}, comments=True, romstart=0, namespace
struct = midx.pop(0)
name = struct["name"]
print(name, file=sys.stderr)
#INCLUDED["functions"].add(name)
@ -162,6 +163,7 @@ def disassemble(bytes, midx, symbol_map={}, comments=True, romstart=0, namespace
script_text = disasm_script.ScriptDisassembler(
bytes, name, symbol_map, romstart, INCLUDES_NEEDED, INCLUDED,
transform_symbol_name=transform_symbol_name,
use_script_lib=False,
).disassemble()
if "shakeTree" in name or "searchBush" in name:
@ -821,11 +823,15 @@ def disassemble(bytes, midx, symbol_map={}, comments=True, romstart=0, namespace
sprite_id = (anim & 0x00FF0000) >> 16
palette_id = (anim & 0x0000FF00) >> 8
anim_id = (anim & 0x000000FF) >> 0
sprite = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["name"]
palette = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["palettes"][palette_id]
anim = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["anims"][anim_id]
anim = f"NPC_ANIM_{sprite}_{palette}_{anim}"
INCLUDES_NEEDED["sprites"].add(sprite)
try:
sprite = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["name"]
palette = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["palettes"][palette_id]
anim = disasm_script.CONSTANTS["NPC_SPRITE"][sprite_id]["anims"][anim_id]
anim = f"NPC_ANIM_{sprite}_{palette}_{anim}"
INCLUDES_NEEDED["sprites"].add(sprite)
except KeyError:
anim = f"{anim:06X}"
out += f" {element}, "
out += " " * (16 - len(element))
@ -1056,11 +1062,11 @@ if __name__ == "__main__":
.replace("peachdash", "peach_dash")
)
else:
segment_name = f"battle_partner_{battle_area}"
segment_name = f"battle/{battle_area}"
is_battle = True
symbol_map = {}
symbol_map = disasm_script.script_lib()
def add_to_symbol_map(addr, pair):
if addr in symbol_map:
symbol_map[addr].append(pair)