PoC automatic rodata split Total split: 585 Failed / Troublesome: 61 (10,42735042735043%) Successfull rodata split: 524 (89,57264957264957%) Failed due to Script issues: 51 Failed due to object boundary issues or unreferenced .rodata: 10 Build OK?: :feelsokman: (#51)

rom_uncompressed.z64: OK
2a0a8acb61538235bc1094d297fb6556  rom.z64
rom.z64: OK

List Of Troublesome (mostly simliar edge cases, some are strings that we dont catch right / data without references):
 -    ovl_Arrow_Ice
 -    ovl_Arrow_Light
 -    ovl_Bg_Dkjail_Ivy
 -    ovl_Bg_Ikana_Mirror
 -    ovl_Boss_02
 -    ovl_Boss_07
 -    ovl_Boss_Hakugin
 -    ovl_Elf_Msg
 -    ovl_Elf_Msg2
 -    ovl_Elf_Msg3
 -    ovl_Elf_Msg4
 -    ovl_Elf_Msg5
 -    ovl_En_Az
 -    ovl_En_Bigokuta
 -    ovl_En_Bigpamet
 -    ovl_En_Bigpo
 -    ovl_En_Bigslime
 -    ovl_En_Box
 -    ovl_En_Butte
 -    ovl_En_Col_Man
 -    ovl_En_Crow
 -    ovl_En_Death
 -    ovl_En_Elf
 -    ovl_En_Elforg
 -    ovl_En_Encount3
 -    ovl_En_Encount4
 -    ovl_En_Fish
 -    ovl_En_Fish2
 -    ovl_En_Fsn
 -    ovl_En_Honotrap
 -    ovl_En_Horse
 -    ovl_En_Horse_Game
 -    ovl_En_Invadepoh
 -    ovl_En_Ishi
 -    ovl_En_Kame
 -    ovl_En_Kanban
 -    ovl_En_Kusa2
 -    ovl_En_M_Thunder
 -    ovl_En_Maruta
 -    ovl_En_Mushi2
 -    ovl_En_Okuta
 -    ovl_En_Ossan
 -    ovl_En_Pametfrog
 -    ovl_En_Peehat
 -    ovl_En_Rg
 -    ovl_En_Ruppecrow
 -    ovl_En_Slime
 -    ovl_En_Sob1
 -    ovl_En_Syateki_Man
 -    ovl_En_Test7
 -    ovl_En_Trt
 -    ovl_En_Wiz_Fire
 -    ovl_Mir_Ray
 -    ovl_Obj_Bombiwa
 -    ovl_Obj_Driftice
 -    ovl_Obj_Hariko
 -    ovl_Obj_Iceblock
 -    ovl_Obj_Mure
 -    ovl_Obj_Snowball2
 -    ovl_Obj_Toudai
 -    ovl_select

Co-authored-by: MMDecomp <MMDecomp@anon.tld>
This commit is contained in:
Kenix3 2021-02-25 19:05:33 -05:00 committed by GitHub
parent 73eed5a0b3
commit 7955a59194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 738 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -626,6 +626,7 @@
0x808A8070:"ovl_En_River_Sound_rodata",
0x808AC010:"ovl_En_Ossan_data",
0x808AC2D0:"ovl_En_Ossan_rodata",
0x808AC300:"ovl_En_Ossan_late_rodata",
0x808AE5E0:"ovl_En_Famos_data",
0x808AE6D0:"ovl_En_Famos_rodata",
0x808AFB00:"ovl_En_Bombf_data",
@ -696,6 +697,7 @@
0x808E2570:"ovl_Bg_Ctower_Rot_rodata",
0x808E3BD0:"ovl_Mir_Ray_data",
0x808E3DD0:"ovl_Mir_Ray_rodata",
0x808E3DE0:"ovl_Mir_Ray_late_rodata",
0x808E4DF0:"ovl_En_Sb_data",
0x808E4EA0:"ovl_En_Sb_rodata",
0x808ED640:"ovl_En_Bigslime_data",
@ -732,8 +734,10 @@
0x809222F0:"ovl_Arrow_Fire_rodata",
0x80922DB0:"ovl_Arrow_Ice_data",
0x80924200:"ovl_Arrow_Ice_rodata",
0x80924210:"ovl_Arrow_Ice_late_rodata",
0x80924C60:"ovl_Arrow_Light_data",
0x809260B0:"ovl_Arrow_Light_rodata",
0x809260C0:"ovl_Arrow_Light_late_rodata",
0x80927380:"ovl_Obj_Kibako_data",
0x80927400:"ovl_Obj_Kibako_rodata",
0x80929500:"ovl_Obj_Tsubo_data",
@ -746,6 +750,7 @@
0x8092DE30:"ovl_En_Dns_rodata",
0x8092E450:"ovl_Elf_Msg_data",
0x8092E480:"ovl_Elf_Msg_rodata",
0x8092E490:"ovl_Elf_Msg_late_rodata",
0x809303F0:"ovl_En_Honotrap_data",
0x80930510:"ovl_En_Honotrap_rodata",
0x80931410:"ovl_En_Tubo_Trap_data",
@ -1008,6 +1013,7 @@
0x80A0C7E0:"ovl_En_Boj_05_rodata",
0x80A10860:"ovl_En_Sob1_data",
0x80A10A50:"ovl_En_Sob1_rodata",
0x80A10A70:"ovl_En_Sob1_late_rodata",
0x80A16100:"ovl_En_Go_data",
0x80A16720:"ovl_En_Go_rodata",
0x80A18EC0:"ovl_En_Raf_data",
@ -1039,6 +1045,7 @@
0x80A2CBC0:"ovl_En_Syateki_Dekunuts_rodata",
0x80A2D1C0:"ovl_Elf_Msg3_data",
0x80A2D1F0:"ovl_Elf_Msg3_rodata",
0x80A2D200:"ovl_Elf_Msg3_late_rodata",
0x80A2E4E0:"ovl_En_Fg_data",
0x80A2E600:"ovl_En_Fg_rodata",
0x80A2E910:"ovl_Dm_Ravine_data",
@ -1162,6 +1169,7 @@
0x80A8B420:"ovl_En_Tru_rodata",
0x80A8FE10:"ovl_En_Trt_data",
0x80A8FF10:"ovl_En_Trt_rodata",
0x80A8FF30:"ovl_En_Trt_late_rodata",
0x80A906E0:"ovl_En_Test5_data",
0x80A90700:"ovl_En_Test5_rodata",
0x80A93E60:"ovl_En_Test6_data",
@ -1312,6 +1320,7 @@
0x80AFD2B0:"ovl_En_Gakufu_rodata",
0x80AFD8D0:"ovl_Elf_Msg4_data",
0x80AFD900:"ovl_Elf_Msg4_rodata",
0x80AFD910:"ovl_Elf_Msg4_late_rodata",
0x80AFDBB0:"ovl_Elf_Msg5_data",
0x80AFDBE0:"ovl_Elf_Msg5_rodata",
0x80AFE730:"ovl_En_Col_Man_data",

View File

@ -1,6 +1,167 @@
#!/usr/bin/env python3
import argparse, os
def split_asm_and_rodata():
parser = argparse.ArgumentParser()
parser.add_argument('input', help='input file')
parser.add_argument('output', help='output file path')
parser.add_argument('-c', '--c-base', help='create base c file that has GLOBAL_ASM for each function', metavar='file')
args = parser.parse_args()
os.makedirs(args.output, exist_ok=True)
file_names = []
rodata_entries = []
disableRodataConvert = False
basename = str(args.input)
if "0x" in basename:
basename = basename.split("0x")[0]
else:
basename = basename.split(".")[0]
rodataFile = basename + "late_rodata.asm"
if not os.path.exists(rodataFile):
rodataFile = basename + "rodata.asm"
rodata_lines = []
if os.path.exists(rodataFile) and not disableRodataConvert:
with open(rodataFile, 'r') as f:
rodata_lines = f.readlines()
current_rodata = None
for line in rodata_lines:
if line.startswith('glabel') and not line.startswith('glabel L80'):
current_rodata = line.split()[1]
assert(current_rodata != '')
if '.byte' in line or '.short' in line or '.word' in line:
rodata_entries.append([current_rodata, line, False])
f.close()
with open(args.input, 'r') as f:
current_file = None
relevant_rodata = []
written_rodata = []
writing = False
lines = f.readlines()
for line in lines:
if line.startswith('glabel') and not line.startswith('glabel L80'):
func_name = line.split()[1]
assert(func_name != '')
if current_file != None:
if len(relevant_rodata):
current_file.write("\n.section .late_rodata\n\n")
for entry in relevant_rodata:
writeLabel = True
for labelName in written_rodata:
if entry[0] == labelName:
writeLabel = False
break
if writeLabel:
current_file.write("glabel " + entry[0] + "\n")
written_rodata.append(entry[0])
current_file.write(entry[1])
if os.path.exists(rodataFile) and not disableRodataConvert:
with open(rodataFile, 'w+') as f:
f.truncate()
deleteLine = False
for xline in rodata_lines:
if deleteLine:
for entry in relevant_rodata:
if xline.startswith('glabel') and not xline.startswith('glabel L80'):
deleteLine = False
break
if xline.startswith('glabel') and not xline.startswith('glabel L80'):
for labelName in written_rodata:
if labelName in xline:
deleteLine = True
break
if not deleteLine:
f.writelines([xline])
f.close()
relevant_rodata = []
current_file.close()
file_name = args.output + '/' + func_name + '.asm'
current_file = open(file_name, 'w')
writing = True
file_names.append(file_name)
if '.byte' in line or '.short' in line or '.word' in line:
writing = False
for entries in rodata_entries:
entryLabel = entries[0]
addRodata = True
if not entryLabel:
print(args.input)
entryLabel = ""
for existing_entry in relevant_rodata:
if existing_entry[0] == entryLabel:
addRodata = False
break
if addRodata:
if entryLabel in line:
for xentries in rodata_entries:
if entryLabel == xentries[0]:
# Is Used
xentries[2] = True
relevant_rodata.append(xentries)
break
if writing:
current_file.write(line)
if current_file != None:
if len(relevant_rodata):
current_file.write("\n.section .late_rodata\n\n")
for entry in relevant_rodata:
writeLabel = True
for labelName in written_rodata:
if entry[0] == labelName:
writeLabel = False
break
if writeLabel:
current_file.write("glabel " + entry[0] + "\n")
written_rodata.append(entry[0])
current_file.write(entry[1])
if os.path.exists(rodataFile):
with open(rodataFile, 'w+') as f:
f.truncate()
deleteLine = False
for xline in rodata_lines:
if deleteLine:
for entry in relevant_rodata:
if xline.startswith('glabel') and not xline.startswith('glabel L80'):
deleteLine = False
break
if xline.startswith('glabel') and not xline.startswith('glabel L80'):
for labelName in written_rodata:
if labelName in xline:
deleteLine = True
break
if not deleteLine:
f.writelines([xline])
f.close()
relevant_rodata = []
written_rodata = []
current_file.close()
if args.c_base != None:
os.makedirs(os.path.dirname(args.c_base), exist_ok=True)
with open(args.c_base, 'w') as f:
f.write('#include <ultra64.h>\n#include <global.h>\n')
for name in file_names:
f.write('\n#pragma GLOBAL_ASM("{}")\n'.format(name))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
@ -13,6 +174,10 @@ if __name__ == '__main__':
file_names = []
if "ovl_" in str(args.input) and not any(ovlFile in str(args.input) for ovlFile in ["ovl_Arrow_Ice", "ovl_Arrow_Light", "ovl_Bg_Dkjail_Ivy", "ovl_Bg_Ikana_Mirror", "ovl_Boss_02", "ovl_Boss_07", "ovl_Boss_Hakugin", "ovl_Elf_Msg", "ovl_Elf_Msg2", "ovl_Elf_Msg3", "ovl_Elf_Msg4", "ovl_Elf_Msg5", "ovl_En_Az", "ovl_En_Bigokuta", "ovl_En_Bigpamet", "ovl_En_Bigpo", "ovl_En_Bigslime", "ovl_En_Box", "ovl_En_Butte", "ovl_En_Col_Man", "ovl_En_Crow", "ovl_En_Death", "ovl_En_Elf", "ovl_En_Elforg", "ovl_En_Encount3", "ovl_En_Encount4", "ovl_En_Fish", "ovl_En_Fish2", "ovl_En_Fsn", "ovl_En_Honotrap", "ovl_En_Horse", "ovl_En_Horse_Game", "ovl_En_Invadepoh", "ovl_En_Ishi", "ovl_En_Kame", "ovl_En_Kanban", "ovl_En_Kusa2", "ovl_En_M_Thunder", "ovl_En_Maruta", "ovl_En_Mushi2", "ovl_En_Okuta", "ovl_En_Ossan", "ovl_En_Pametfrog", "ovl_En_Peehat", "ovl_En_Rg", "ovl_En_Ruppecrow", "ovl_En_Slime", "ovl_En_Sob1", "ovl_En_Syateki_Man", "ovl_En_Test7", "ovl_En_Trt", "ovl_En_Wiz_Fire", "ovl_Mir_Ray", "ovl_Obj_Bombiwa", "ovl_Obj_Driftice", "ovl_Obj_Hariko", "ovl_Obj_Iceblock", "ovl_Obj_Mure", "ovl_Obj_Snowball2", "ovl_Obj_Toudai", "ovl_select"]):
split_asm_and_rodata()
exit(0)
with open(args.input, 'r') as f:
current_file = None
writing = False