mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-04 15:04:31 +00:00
Updated fixbaserom script
- Script now checks ROM header to determine if ROM is byte swapped. - Checks the hash of the ROM to determine if it's "vanilla".
This commit is contained in:
parent
ec37636a7a
commit
d780e6b13e
1 changed files with 23 additions and 18 deletions
|
@ -2,20 +2,19 @@ import os.path
|
||||||
from os import path
|
from os import path
|
||||||
import sys
|
import sys
|
||||||
import struct
|
import struct
|
||||||
|
import hashlib
|
||||||
|
|
||||||
# Read in the original ROM
|
# Read in the original ROM
|
||||||
if (path.exists("baserom_original.z64")):
|
if (path.exists("baserom_original.z64")):
|
||||||
print("File 'baserom_original.z64' found.")
|
print("File 'baserom_original.z64' found.")
|
||||||
with open("baserom_original.z64", mode='rb') as file:
|
with open("baserom_original.z64", mode='rb') as file:
|
||||||
fileContent = file.read()
|
|
||||||
elif (path.exists("baserom_original.n64")):
|
|
||||||
print("File 'baserom_original.n64' found.")
|
|
||||||
print("Byte swapping...")
|
|
||||||
with open("baserom_original.n64", mode='rb') as file:
|
|
||||||
fileContent = bytearray(file.read())
|
fileContent = bytearray(file.read())
|
||||||
|
|
||||||
|
# Check if ROM needs to be byte swapped
|
||||||
|
if (fileContent[0] == 0x40):
|
||||||
# Byte Swap ROM
|
# Byte Swap ROM
|
||||||
# TODO: This is pretty slow at the moment. Look into optimizing it later...
|
# TODO: This is pretty slow at the moment. Look into optimizing it later...
|
||||||
|
print("ROM needs to be byte swapped...")
|
||||||
i = 0
|
i = 0
|
||||||
while (i < len(fileContent)):
|
while (i < len(fileContent)):
|
||||||
tmp = struct.unpack_from("BBBB", fileContent, i)
|
tmp = struct.unpack_from("BBBB", fileContent, i)
|
||||||
|
@ -29,7 +28,7 @@ elif (path.exists("baserom_original.n64")):
|
||||||
|
|
||||||
print("Byte swapping done.")
|
print("Byte swapping done.")
|
||||||
else:
|
else:
|
||||||
print("Error: Could not find a baserom_original.z64 or baserom_original.n64.")
|
print("Error: Could not find baserom_original.z64.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Strip the overdump
|
# Strip the overdump
|
||||||
|
@ -40,6 +39,12 @@ strippedContent = list(fileContent[0:0x3600000])
|
||||||
print("Patching header...")
|
print("Patching header...")
|
||||||
strippedContent[0x3E] = 0x50
|
strippedContent[0x3E] = 0x50
|
||||||
|
|
||||||
|
# Check to see if the ROM is a "vanilla" Debug ROM
|
||||||
|
md5Hash = hashlib.md5(bytearray(strippedContent)).hexdigest()
|
||||||
|
|
||||||
|
if (str(md5Hash) != "f0b7f35375f9cc8ca1b2d59d78e35405"):
|
||||||
|
print("Error: Expected a hash of f0b7f35375f9cc8ca1b2d59d78e35405 but got " + str(md5Hash) + ". The baserom is probably not \"vanilla\"")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Write out our new ROM
|
# Write out our new ROM
|
||||||
print("Writing new ROM 'baserom.z64'.")
|
print("Writing new ROM 'baserom.z64'.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue