mirror of
https://github.com/pmret/papermario.git
synced 2024-11-09 12:32:38 +01:00
Updates
This commit is contained in:
parent
583b109ea7
commit
41d5fd1610
@ -10,7 +10,7 @@ ApiStatus func_802BD100_3251D0(ScriptInstance* script, s32 isInitialCall) {
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
ApiStatus func_802BD1AC_3251D0(ScriptInstance* script, s32 isInitialCall) {
|
||||
ApiStatus func_802BD1AC_32527C(ScriptInstance* script, s32 isInitialCall) {
|
||||
Bytecode* args = script->ptrReadPos;
|
||||
s32 a = get_variable(script, *args++);
|
||||
s32 b = get_variable(script, *args++);
|
||||
|
@ -17,6 +17,8 @@ map_symbols = {}
|
||||
symbol_addrs = []
|
||||
elf_symbols = []
|
||||
|
||||
verbose = False
|
||||
|
||||
def scan_map():
|
||||
ram_offset = None
|
||||
cur_file = "<no file>"
|
||||
@ -61,9 +63,25 @@ def read_symbol_addrs():
|
||||
|
||||
for line in unique_lines:
|
||||
main, ext = line.rstrip().split(";")
|
||||
args = ext.split("//")[-1].strip().split(" ")
|
||||
opt = ext.split("//")[-1].strip().split(" ")
|
||||
|
||||
type = None
|
||||
rom = -1
|
||||
|
||||
args = []
|
||||
for thing in list(opt):
|
||||
if thing.strip() == "":
|
||||
opt.remove(thing)
|
||||
if "type:" in thing:
|
||||
type = thing.split(":")[1]
|
||||
opt.remove(thing)
|
||||
elif "rom:" in thing:
|
||||
rom = int(thing.split(":")[1], 16)
|
||||
opt.remove(thing)
|
||||
|
||||
name, addr = main.split(" = ")
|
||||
symbol_addrs.append((name, int(addr, 0), args))
|
||||
|
||||
symbol_addrs.append([name, int(addr, 0), type, rom, opt])
|
||||
|
||||
def read_elf():
|
||||
try:
|
||||
@ -90,61 +108,73 @@ def read_elf():
|
||||
else:
|
||||
type = "data"
|
||||
|
||||
opts = [f"type:{type}"]
|
||||
rom = None
|
||||
|
||||
if name in map_symbols:
|
||||
opts.append(f"rom:0x{map_symbols[name][0]:X}")
|
||||
rom = map_symbols[name][0]
|
||||
elif re.match(".*_[0-9A-F]{8}_[0-9A-F]{6}", name):
|
||||
rom = name.split("_")[-1]
|
||||
opts.append(f"rom:0x{rom}")
|
||||
rom = int(name.split('_')[-1], 16)
|
||||
|
||||
elf_symbols.append((name, addr, opts))
|
||||
elf_symbols.append((name, addr, type, rom))
|
||||
|
||||
def log(s):
|
||||
if verbose:
|
||||
print(s)
|
||||
|
||||
def reconcile_symbols():
|
||||
print(f"Processing {str(len(elf_symbols))} elf symbols...")
|
||||
|
||||
for i, sym in enumerate(elf_symbols):
|
||||
for i, elf_sym in enumerate(elf_symbols):
|
||||
if i % 1000 == 0:
|
||||
print(i)
|
||||
name_match = None
|
||||
rom_match = None
|
||||
|
||||
for sym2 in symbol_addrs:
|
||||
|
||||
for known_sym in symbol_addrs:
|
||||
# Name
|
||||
if not name_match:
|
||||
if sym[0] == sym2[0]:
|
||||
name_match = sym2
|
||||
if elf_sym[0] == known_sym[0]:
|
||||
name_match = known_sym
|
||||
|
||||
if sym[1] != sym2[1]:
|
||||
print(f"Address mismatch! {sym[0]} is 0x{sym[1]:X} in the elf and 0x{sym2[1]} in symbol_addrs")
|
||||
|
||||
if not rom_match:
|
||||
if sym[2] == sym2[2]:
|
||||
rom_match = sym2
|
||||
if elf_sym[1] != known_sym[1]:
|
||||
log(f"Ram mismatch! {elf_sym[0]} is 0x{elf_sym[1]:X} in the elf and 0x{known_sym[1]} in symbol_addrs")
|
||||
|
||||
# Rom
|
||||
if not rom_match:
|
||||
# Todo account for either or both syms not containing a rom addr
|
||||
if sym[2] == sym2[2]:
|
||||
rom_match = sym2
|
||||
|
||||
if not name_match:
|
||||
if sym[0] == sym2[1]:
|
||||
name_match = sym2
|
||||
if elf_sym[3]:
|
||||
if elf_sym[3] == known_sym[3]:
|
||||
rom_match = known_sym
|
||||
|
||||
if not name_match and not rom_match:
|
||||
# Todo add new symbol to symbol_addrs
|
||||
pass
|
||||
log(f"Creating new symbol {elf_sym[0]}")
|
||||
symbol_addrs.append([elf_sym[0], elf_sym[1], elf_sym[2], elf_sym[3] if elf_sym[3] else -1, []])
|
||||
elif not name_match:
|
||||
#todo rename symbol in symbol_addrs
|
||||
pass
|
||||
elif not rom_match:
|
||||
# todo add rom addr in symbol_addrs
|
||||
pass
|
||||
log(f"Renaming identical rom address symbol {rom_match[0]} to {elf_sym[0]}")
|
||||
rom_match[0] = elf_sym[0]
|
||||
elif not rom_match and elf_sym[3]:
|
||||
if name_match[3] >= 0:
|
||||
log(f"Correcting rom address {name_match[3]} to {elf_sym[3]} for symbol {name_match[0]}")
|
||||
else:
|
||||
log(f"Adding rom address {elf_sym[3]} to symbol {name_match[0]}")
|
||||
name_match[3] = elf_sym[3]
|
||||
|
||||
def write_new_symbol_addrs():
|
||||
with open(symbol_addrs_path, "w", newline="\n") as f:
|
||||
for symbol in sorted(symbol_addrs, key=lambda x: (x[3] == -1, x[3], x[1], x[0])):
|
||||
line = f"{symbol[0]} = 0x{symbol[1]:X}; //"
|
||||
if symbol[2]:
|
||||
line += f" type:{symbol[2]}"
|
||||
if symbol[3] >= 0:
|
||||
line += f" rom:0x{symbol[3]:X}"
|
||||
if len(symbol[4]) > 0:
|
||||
for thing in symbol[4]:
|
||||
line += f" {thing}"
|
||||
f.write(line + "\n")
|
||||
|
||||
|
||||
scan_map()
|
||||
read_symbol_addrs()
|
||||
read_elf()
|
||||
reconcile_symbols()
|
||||
write_new_symbol_addrs()
|
||||
|
@ -942,20 +942,20 @@ delete_player_actor = 0x80240D68; // type:func rom:0x16F648
|
||||
begin_battle = 0x80241218; // type:func rom:0x16FAF8
|
||||
update_heroes_start_turn = 0x80242024; // type:func rom:0x170904
|
||||
switch_to_player = 0x80242AC8; // type:func rom:0x1713A8
|
||||
pause_set_cursor_opacity = 0x80242BA0; // seg_rom:0x135EE0 type:func
|
||||
pause_set_cursor_opacity = 0x80242BA0; // rom:0x135EE0 type:func
|
||||
update_end_player_turn = 0x80242BB0; // type:func rom:0x171490
|
||||
pause_interp_cursor = 0x80242E6C; // type:func rom:0x1361AC
|
||||
switch_to_partner = 0x80242F00; // type:func rom:0x1717E0
|
||||
pause_interp_text_scroll = 0x80243418; // type:func rom:0x136758
|
||||
pause_interp_vertical_scroll = 0x8024346C; // type:func rom:0x1367AC
|
||||
pause_update_cursor = 0x802434DC; // seg_rom:0x135EE0 type:func
|
||||
pause_update_cursor = 0x802434DC; // rom:0x13681C type:func
|
||||
pause_textbox_draw_contents = 0x80243570; // type:func rom:0x1368B0
|
||||
pause_tutorial_draw_contents = 0x802437F4; // type:func rom:0x136B34
|
||||
switch_order = 0x80243918; // type:func rom:0x1721F8
|
||||
pause_init = 0x80244060; // type:func rom:0x1373A0
|
||||
pause_tutorial_input = 0x802442A0; // type:func rom:0x1375E0
|
||||
pause_handle_input = 0x80244424; // type:func rom:0x137764
|
||||
pause_cleanup = 0x80244708; // seg_rom:0x135EE0 type:func
|
||||
pause_cleanup = 0x80244708; // rom:0x135EE0 type:func
|
||||
pause_get_total_equipped_bp_cost = 0x802447F4; // type:func rom:0x137B34
|
||||
pause_draw_rect = 0x80244858; // type:func rom:0x137B98
|
||||
pause_sort_item_list = 0x80244A4C; // type:func rom:0x137D8C
|
||||
@ -6714,7 +6714,7 @@ func_80241508_D19CE8 = 0x80241508; // type:func rom:0xD19CE8
|
||||
func_802411D8_D511C8 = 0x802411D8; // type:func rom:0xD511C8
|
||||
func_80240B98_898178 = 0x80240B98; // type:func rom:0x898178
|
||||
func_802424CC_A3B9AC = 0x802424CC; // type:func rom:0xA3B9AC
|
||||
func_802BD1AC_3251D0 = 0x802BD1AC; // type:func rom:0x3251D0
|
||||
func_802BD1AC_3251D0 = 0x802BD1AC; // type:func rom:0x32527C
|
||||
func_802A992C_429C4C = 0x802A992C; // type:func rom:0x429C4C
|
||||
func_80240628_800EA8 = 0x80240628; // type:func rom:0x800EA8
|
||||
func_80240340_EB5470 = 0x80240340; // type:func rom:0xEB5470
|
||||
|
Loading…
Reference in New Issue
Block a user