Skip to content

Instantly share code, notes, and snippets.

@SomeKitten
Last active May 19, 2023 02:10
Show Gist options
  • Select an option

  • Save SomeKitten/220bd78e12af705cefa93fccf48be81d to your computer and use it in GitHub Desktop.

Select an option

Save SomeKitten/220bd78e12af705cefa93fccf48be81d to your computer and use it in GitHub Desktop.
Extract files from archives found in Mario & Luigi: Dream Team. Likely SUPER finecky!!!
import os
# <MAKE SURE THIS SCRIPT ISNT EXTRACTING TOO MANY FILES, IT DOESNT CHECK TO SEE IF THE DATA IT IS READING IS VALID OR NOT>
# EDIT THESE THREE PATHS AS NEEDED
code_bin_path = "./code.bin"
archive_path = "./BMap/BMap.dat"
extract_dir = "./BMap/extract"
# EDIT THESE THREE PATHS AS NEEDED
# HEX OFFSET
# FROM https://www.tapatalk.com/groups/lighthouse_of_yoshi/hexadecimals-t618.html
hex = "00552748"
# HEX OFFSET
tbl_offset = int(hex, 16)
os.makedirs(extract_dir, exist_ok=True)
code_bin = open(code_bin_path, "rb")
code_bin.seek(tbl_offset + 0x2, 1)
file_count = int.from_bytes(code_bin.read(2), "little")
code_bin.seek(0xC, 1)
print("File count: " + str(file_count))
archive = open(archive_path, "rb")
for i in range(file_count):
start = int.from_bytes(code_bin.read(4), "little")
length_raw = code_bin.read(4)
while start == 0x00000000 and length_raw == 0x3FFFFFFF:
start = int.from_bytes(code_bin.read(4), "little")
length_raw = code_bin.read(4)
length = int.from_bytes(length_raw, "little")
length = length % 0x40000000
archive.seek(start)
with open(extract_dir + "/" + str(f"{i:04d}") + ".bin", "wb") as f:
f.write(archive.read(length))
archive.close()
code_bin.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment