mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-29 03:34:07 +00:00
Improve fixbaserom.py
(#987)
Set bytes past ROM's end to `0xFF`. Recognize the infamous ZeldaEdit-edited rom.
This commit is contained in:
parent
970513253b
commit
8e57f3bca3
1 changed files with 21 additions and 8 deletions
|
@ -17,14 +17,19 @@ if path.exists("baserom.z64"):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Determine if we have a ROM file
|
# Determine if we have a ROM file
|
||||||
romFileName = ""
|
romFileExtensions = ["z64", "n64", "v64"]
|
||||||
if path.exists("baserom_original.z64"):
|
|
||||||
romFileName = "baserom_original.z64"
|
def find_baserom_original():
|
||||||
elif path.exists("baserom_original.n64"):
|
for romFileExtLower in romFileExtensions:
|
||||||
romFileName = "baserom_original.n64"
|
for romFileExt in (romFileExtLower, romFileExtLower.upper()):
|
||||||
elif path.exists("baserom_original.v64"):
|
romFileNameCandidate = "baserom_original." + romFileExt
|
||||||
romFileName = "baserom_original.v64"
|
if path.exists(romFileNameCandidate):
|
||||||
else:
|
return romFileNameCandidate
|
||||||
|
return None
|
||||||
|
|
||||||
|
romFileName = find_baserom_original()
|
||||||
|
|
||||||
|
if romFileName is None:
|
||||||
print("Error: Could not find baserom_original.z64/baserom_original.n64/baserom_original.v64.")
|
print("Error: Could not find baserom_original.z64/baserom_original.n64/baserom_original.v64.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -68,11 +73,19 @@ elif fileContent[0] == 0x37:
|
||||||
print("Patching header...")
|
print("Patching header...")
|
||||||
fileContent[0x3E] = 0x50
|
fileContent[0x3E] = 0x50
|
||||||
|
|
||||||
|
for i in range(0x35CF000, len(fileContent)):
|
||||||
|
fileContent[i] = 0xFF
|
||||||
|
|
||||||
# Check to see if the ROM is a "vanilla" Debug ROM
|
# Check to see if the ROM is a "vanilla" Debug ROM
|
||||||
str_hash = get_str_hash(bytearray(fileContent))
|
str_hash = get_str_hash(bytearray(fileContent))
|
||||||
if str_hash != "f0b7f35375f9cc8ca1b2d59d78e35405":
|
if str_hash != "f0b7f35375f9cc8ca1b2d59d78e35405":
|
||||||
print("Error: Expected a hash of f0b7f35375f9cc8ca1b2d59d78e35405 but got " + str_hash + ". " +
|
print("Error: Expected a hash of f0b7f35375f9cc8ca1b2d59d78e35405 but got " + str_hash + ". " +
|
||||||
"The baserom has probably been tampered, find a new one")
|
"The baserom has probably been tampered, find a new one")
|
||||||
|
|
||||||
|
if str_hash == "32fe2770c0f9b1a9cd2a4d449348c1cb":
|
||||||
|
print("The provided baserom is a rom which has been edited with ZeldaEdit and is not suitable for use with decomp. " +
|
||||||
|
"Find a new one.")
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Write out our new ROM
|
# Write out our new ROM
|
||||||
|
|
Loading…
Reference in a new issue