Patch: update to version 4 (#312)

This commit is contained in:
Fabian Dill
2022-03-18 04:53:09 +01:00
committed by GitHub
parent b02a710bc5
commit 7394598aff
14 changed files with 334 additions and 118 deletions

View File

@@ -1,15 +1,25 @@
import hashlib
import os
import Utils
from Patch import read_rom
from Patch import read_rom, APDeltaPatch
SMJAP10HASH = '21f3e98df4780ee1c667b84e57d88675'
LTTPJAP10HASH = '03a63945398191337e896e5771f77173'
ROM_PLAYER_LIMIT = 256
import hashlib
import os
class SMZ3DeltaPatch(APDeltaPatch):
hash = "3a177ba9879e3dd04fb623a219d175b2"
game = "SMZ3"
patch_file_ending = ".smz3"
@classmethod
def get_source_data(cls) -> bytes:
return get_base_rom_bytes()
def get_base_rom_bytes(file_name: str = "") -> bytes:
def get_base_rom_bytes() -> bytes:
base_rom_bytes = getattr(get_base_rom_bytes, "base_rom_bytes", None)
if not base_rom_bytes:
sm_file_name = get_sm_base_rom_path()
@@ -18,7 +28,7 @@ def get_base_rom_bytes(file_name: str = "") -> bytes:
basemd5 = hashlib.md5()
basemd5.update(sm_base_rom_bytes)
if SMJAP10HASH != basemd5.hexdigest():
raise Exception('Supplied Base Rom does not match known MD5 for JAP(1.0) release. '
raise Exception('Supplied Base Rom does not match known MD5 for SM JAP(1.0) release. '
'Get the correct game and version, then dump it')
lttp_file_name = get_lttp_base_rom_path()
lttp_base_rom_bytes = bytes(read_rom(open(lttp_file_name, "rb")))
@@ -26,12 +36,13 @@ def get_base_rom_bytes(file_name: str = "") -> bytes:
basemd5 = hashlib.md5()
basemd5.update(lttp_base_rom_bytes)
if LTTPJAP10HASH != basemd5.hexdigest():
raise Exception('Supplied Base Rom does not match known MD5 for JAP(1.0) release. '
raise Exception('Supplied Base Rom does not match known MD5 for LttP JAP(1.0) release. '
'Get the correct game and version, then dump it')
get_base_rom_bytes.base_rom_bytes = bytes(combine_smz3_rom(sm_base_rom_bytes, lttp_base_rom_bytes))
return get_base_rom_bytes.base_rom_bytes
def get_sm_base_rom_path(file_name: str = "") -> str:
options = Utils.get_options()
if not file_name:
@@ -40,6 +51,7 @@ def get_sm_base_rom_path(file_name: str = "") -> str:
file_name = Utils.local_path(file_name)
return file_name
def get_lttp_base_rom_path(file_name: str = "") -> str:
options = Utils.get_options()
if not file_name:
@@ -48,7 +60,8 @@ def get_lttp_base_rom_path(file_name: str = "") -> str:
file_name = Utils.local_path(file_name)
return file_name
def combine_smz3_rom(sm_rom: bytes, lttp_rom: bytes):
def combine_smz3_rom(sm_rom: bytes, lttp_rom: bytes) -> bytearray:
combined = bytearray(0x600000)
# SM hi bank
pos = 0