mirror of
https://github.com/zeldaret/oot.git
synced 2025-06-08 01:21:52 +00:00
checksums for ntsc 1.2 JP and US, accept both as baserom (#2030)
This commit is contained in:
parent
eaf955ad22
commit
c8ec6042e1
8 changed files with 37 additions and 14 deletions
12
Makefile
12
Makefile
|
@ -27,7 +27,7 @@ COMPILER ?= ido
|
||||||
# gc-eu-mq GameCube Europe/PAL Master Quest
|
# gc-eu-mq GameCube Europe/PAL Master Quest
|
||||||
# gc-eu-mq-dbg GameCube Europe/PAL Master Quest Debug (default)
|
# gc-eu-mq-dbg GameCube Europe/PAL Master Quest Debug (default)
|
||||||
# The following versions are work-in-progress and not yet matching:
|
# The following versions are work-in-progress and not yet matching:
|
||||||
# ntsc-1.2 N64 NTSC 1.2 (Japan)
|
# ntsc-1.2 N64 NTSC 1.2 (Japan/US depending on REGION)
|
||||||
VERSION ?= gc-eu-mq-dbg
|
VERSION ?= gc-eu-mq-dbg
|
||||||
# Number of threads to extract and compress with
|
# Number of threads to extract and compress with
|
||||||
N_THREADS ?= $(shell nproc)
|
N_THREADS ?= $(shell nproc)
|
||||||
|
@ -45,8 +45,10 @@ CFLAGS ?=
|
||||||
CPPFLAGS ?=
|
CPPFLAGS ?=
|
||||||
CPP_DEFINES ?=
|
CPP_DEFINES ?=
|
||||||
|
|
||||||
|
REGIONAL_CHECKSUM := 0
|
||||||
# Version-specific settings
|
# Version-specific settings
|
||||||
ifeq ($(VERSION),ntsc-1.2)
|
ifeq ($(VERSION),ntsc-1.2)
|
||||||
|
REGIONAL_CHECKSUM := 1
|
||||||
REGION ?= JP
|
REGION ?= JP
|
||||||
PLATFORM := N64
|
PLATFORM := N64
|
||||||
PAL := 0
|
PAL := 0
|
||||||
|
@ -470,13 +472,21 @@ all: rom compress
|
||||||
rom: $(ROM)
|
rom: $(ROM)
|
||||||
ifneq ($(COMPARE),0)
|
ifneq ($(COMPARE),0)
|
||||||
@md5sum $(ROM)
|
@md5sum $(ROM)
|
||||||
|
ifneq ($(REGIONAL_CHECKSUM),0)
|
||||||
|
@md5sum -c $(BASEROM_DIR)/checksum-$(REGION).md5
|
||||||
|
else
|
||||||
@md5sum -c $(BASEROM_DIR)/checksum.md5
|
@md5sum -c $(BASEROM_DIR)/checksum.md5
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
compress: $(ROMC)
|
compress: $(ROMC)
|
||||||
ifneq ($(COMPARE),0)
|
ifneq ($(COMPARE),0)
|
||||||
@md5sum $(ROMC)
|
@md5sum $(ROMC)
|
||||||
|
ifneq ($(REGIONAL_CHECKSUM),0)
|
||||||
|
@md5sum -c $(BASEROM_DIR)/checksum-$(REGION)-compressed.md5
|
||||||
|
else
|
||||||
@md5sum -c $(BASEROM_DIR)/checksum-compressed.md5
|
@md5sum -c $(BASEROM_DIR)/checksum-compressed.md5
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
1
baseroms/ntsc-1.2/checksum-US-compressed.md5
Normal file
1
baseroms/ntsc-1.2/checksum-US-compressed.md5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
57a9719ad547c516342e1a15d5c28c3d build/ntsc-1.2/oot-ntsc-1.2-compressed.z64
|
1
baseroms/ntsc-1.2/checksum-US.md5
Normal file
1
baseroms/ntsc-1.2/checksum-US.md5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
12fcafeba93992facaf65c2ba00f3089 build/ntsc-1.2/oot-ntsc-1.2.z64
|
|
@ -1,3 +1,6 @@
|
||||||
|
checksums:
|
||||||
|
- checksum-JP
|
||||||
|
- checksum-US
|
||||||
dmadata_start: 0x7960
|
dmadata_start: 0x7960
|
||||||
text_lang_pal: false
|
text_lang_pal: false
|
||||||
incbins:
|
incbins:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import hashlib
|
||||||
import io
|
import io
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import struct
|
import struct
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
import crunch64
|
import crunch64
|
||||||
import ipl3checksum
|
import ipl3checksum
|
||||||
|
@ -101,10 +102,10 @@ def get_str_hash(byte_array):
|
||||||
return str(hashlib.md5(byte_array).hexdigest())
|
return str(hashlib.md5(byte_array).hexdigest())
|
||||||
|
|
||||||
|
|
||||||
def check_existing_rom(rom_path: Path, correct_str_hash: str):
|
def check_existing_rom(rom_path: Path, correct_str_hashes: Iterable[str]):
|
||||||
# If the baserom exists and is correct, we don't need to change anything
|
# If the baserom exists and is correct, we don't need to change anything
|
||||||
if rom_path.exists():
|
if rom_path.exists():
|
||||||
if get_str_hash(rom_path.read_bytes()) == correct_str_hash:
|
if get_str_hash(rom_path.read_bytes()) in correct_str_hashes:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -176,12 +177,17 @@ def main():
|
||||||
config = version_config.load_version_config(version)
|
config = version_config.load_version_config(version)
|
||||||
dmadata_start = config.dmadata_start
|
dmadata_start = config.dmadata_start
|
||||||
|
|
||||||
compressed_str_hash = (
|
compressed_str_hashes = []
|
||||||
(baserom_dir / "checksum-compressed.md5").read_text().split()[0]
|
decompressed_str_hashes = []
|
||||||
)
|
for checksum_stem in config.checksums:
|
||||||
decompressed_str_hash = (baserom_dir / "checksum.md5").read_text().split()[0]
|
compressed_str_hashes.append(
|
||||||
|
(baserom_dir / f"{checksum_stem}-compressed.md5").read_text().split()[0]
|
||||||
|
)
|
||||||
|
decompressed_str_hashes.append(
|
||||||
|
(baserom_dir / f"{checksum_stem}.md5").read_text().split()[0]
|
||||||
|
)
|
||||||
|
|
||||||
if check_existing_rom(uncompressed_path, decompressed_str_hash):
|
if check_existing_rom(uncompressed_path, decompressed_str_hashes):
|
||||||
print("Found valid baserom - exiting early")
|
print("Found valid baserom - exiting early")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -220,12 +226,12 @@ def main():
|
||||||
# Check to see if the ROM is a "vanilla" ROM
|
# Check to see if the ROM is a "vanilla" ROM
|
||||||
str_hash = get_str_hash(file_content)
|
str_hash = get_str_hash(file_content)
|
||||||
if version == "gc-eu-mq-dbg":
|
if version == "gc-eu-mq-dbg":
|
||||||
correct_str_hash = decompressed_str_hash
|
correct_str_hashes = decompressed_str_hashes
|
||||||
else:
|
else:
|
||||||
correct_str_hash = compressed_str_hash
|
correct_str_hashes = compressed_str_hashes
|
||||||
if str_hash != correct_str_hash:
|
if str_hash not in correct_str_hashes:
|
||||||
print(
|
print(
|
||||||
f"Error: Expected a hash of {correct_str_hash} but got {str_hash}. The baserom has probably been tampered, find a new one"
|
f"Error: Expected a hash of {' or '.join(correct_str_hashes)} but got {str_hash}. The baserom has probably been tampered, find a new one"
|
||||||
)
|
)
|
||||||
|
|
||||||
if version == "gc-eu-mq-dbg":
|
if version == "gc-eu-mq-dbg":
|
||||||
|
@ -247,9 +253,9 @@ def main():
|
||||||
|
|
||||||
# Double check the hash
|
# Double check the hash
|
||||||
str_hash = get_str_hash(file_content)
|
str_hash = get_str_hash(file_content)
|
||||||
if str_hash != decompressed_str_hash:
|
if str_hash not in decompressed_str_hashes:
|
||||||
print(
|
print(
|
||||||
f"Error: Expected a hash of {decompressed_str_hash} after decompression but got {str_hash}!"
|
f"Error: Expected a hash of {' or '.join(decompressed_str_hashes)} after decompression but got {str_hash}!"
|
||||||
)
|
)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ PROJECT_ROOT = Path(__file__).parent.parent
|
||||||
class VersionConfig:
|
class VersionConfig:
|
||||||
# Version name
|
# Version name
|
||||||
version: str
|
version: str
|
||||||
|
checksums: list[str]
|
||||||
# ROM offset to start of DMA table
|
# ROM offset to start of DMA table
|
||||||
dmadata_start: int
|
dmadata_start: int
|
||||||
# Whether the languages are PAL (EN/DE/FR) or not (JP/EN)
|
# Whether the languages are PAL (EN/DE/FR) or not (JP/EN)
|
||||||
|
@ -89,6 +90,7 @@ def load_version_config(version: str) -> VersionConfig:
|
||||||
|
|
||||||
return VersionConfig(
|
return VersionConfig(
|
||||||
version=version,
|
version=version,
|
||||||
|
checksums=config.get("checksums", ["checksum"]),
|
||||||
dmadata_start=config["dmadata_start"],
|
dmadata_start=config["dmadata_start"],
|
||||||
text_lang_pal=config["text_lang_pal"],
|
text_lang_pal=config["text_lang_pal"],
|
||||||
dmadata_segments=load_dmadata_segments(version),
|
dmadata_segments=load_dmadata_segments(version),
|
||||||
|
|
Loading…
Add table
Reference in a new issue