mirror of
https://github.com/HarbourMasters/Starship
synced 2026-05-23 06:54:39 -04:00
Initial JAP REV0 extraction for function exploring (#241)
* progress so far * no v * root yamls ignored * gitignore jap version src extraction for now * wipe this * separate yamls
This commit is contained in:
committed by
GitHub
parent
cd3444b727
commit
1dec9db413
+18
-20
@@ -106,8 +106,9 @@ def find_file_table(ROM):
|
||||
|
||||
return file_table_start
|
||||
|
||||
decomp_inds = [0, 1, 2, 3, 4, 5, 15, 16, 21, 22, 23, 24, 48]
|
||||
|
||||
def compress(baserom, comprom, mio0, extract_dest=None):
|
||||
decomp_inds = [0, 1, 2, 3, 4, 5, 15, 16, 21, 22, 23, 24, 48]
|
||||
file_table = find_file_table(baserom)
|
||||
|
||||
# comp_const = 0xFFFEFFFFFE1E7FC0
|
||||
@@ -185,22 +186,14 @@ def compress(baserom, comprom, mio0, extract_dest=None):
|
||||
|
||||
def decompress(baserom, decomprom, mio0, extract_dest=None, print_inds=False):
|
||||
file_table = find_file_table(baserom)
|
||||
|
||||
if file_table_dict.get(file_table) == "US1.0":
|
||||
ext = "rev0.z64"
|
||||
elif file_table_dict.get(file_table) == "US1.1":
|
||||
ext = "z64"
|
||||
else:
|
||||
ext = ('%X' % file_table) + ".z64"
|
||||
|
||||
|
||||
print("File table found at 0x%X" % file_table)
|
||||
print("Detected ROM version is " + file_table_dict.get(file_table, "Unknown"))
|
||||
|
||||
outrom = decomprom.replace("z64", ext)
|
||||
|
||||
with open(outrom, 'w+b') as decompfile, open(baserom, 'rb') as basefile:
|
||||
with open(decomprom, 'w+b') as decompfile, open(baserom, 'rb') as basefile:
|
||||
file_count = 0
|
||||
decomp_inds = []
|
||||
decomp_file_inds = []
|
||||
|
||||
while True:
|
||||
file_entry = file_table + 0x10 * file_count
|
||||
@@ -226,7 +219,7 @@ def decompress(baserom, decomprom, mio0, extract_dest=None, print_inds=False):
|
||||
|
||||
if comp_flag == 0:
|
||||
v_file_size = p_file_size
|
||||
decomp_inds += [file_count]
|
||||
decomp_file_inds += [file_count]
|
||||
dec_msg = 'uncompressed'
|
||||
elif comp_flag == 1:
|
||||
file_bytes = mio0_dec_bytes(file_bytes, mio0)
|
||||
@@ -242,15 +235,18 @@ def decompress(baserom, decomprom, mio0, extract_dest=None, print_inds=False):
|
||||
|
||||
v_file_end = v_file_begin + v_file_size
|
||||
|
||||
file_name = file_names[file_count] + '.bin'
|
||||
|
||||
print("name: " + file_name)
|
||||
print("start: 0x%X" % v_file_begin)
|
||||
|
||||
if extract_dest is not None:
|
||||
if not os.path.exists(extract_dest):
|
||||
os.mkdir(extract_dest)
|
||||
|
||||
file_name = file_names[file_count] + '.bin'
|
||||
|
||||
with open(extract_dest + os.sep + file_name, 'wb') as extract_file:
|
||||
extract_file.write(file_bytes)
|
||||
|
||||
|
||||
decompfile.seek(file_entry + 4)
|
||||
decompfile.write(v_file_begin.to_bytes(4,'big'))
|
||||
decompfile.write(v_file_end.to_bytes(4,'big'))
|
||||
@@ -265,10 +261,12 @@ def decompress(baserom, decomprom, mio0, extract_dest=None, print_inds=False):
|
||||
decompfile.write(crc1.to_bytes(4, 'big'))
|
||||
decompfile.write(crc2.to_bytes(4, 'big'))
|
||||
print("Decompressed %d files." % file_count)
|
||||
if(print_inds) :
|
||||
if print_inds:
|
||||
print("These file numbers were not compressed:")
|
||||
print(decomp_inds)
|
||||
|
||||
print(decomp_file_inds)
|
||||
elif decomp_file_inds != decomp_inds:
|
||||
print("Warning: Unusual compression scheme. These files were uncompressed:")
|
||||
print(decomp_file_inds)
|
||||
return
|
||||
|
||||
parser = argparse.ArgumentParser(description='Compress or decompress a Star Fox 64 ROM')
|
||||
@@ -280,6 +278,7 @@ parser.add_argument('-d', action='store_true',help='decompress provided ROM')
|
||||
parser.add_argument('-m', metavar='mio0',dest='mio0',help='Path to mio0 tool if not in same directory')
|
||||
parser.add_argument('-r', action="store_true",help='Fix crc without compressing or decompressing')
|
||||
parser.add_argument('-i', action='store_true',help='Print indices of uncompressed files during decompression.')
|
||||
parser.add_argument('-v', action='store_true',help='Print file names and offsets of decompressed files.')
|
||||
# parser.add_argument('-v', action='store_true',help='show what changes are made')
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -299,4 +298,3 @@ if __name__ == '__main__':
|
||||
else:
|
||||
print("Something went wrong.")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user