experimental/patch_diving_recovery.py

Download file

Release 2026-11-04-r2 · SHA256 1d404006e9cc5f81c37fbd9d97fbfb732e36dee46d95f3eef785833d240452c3 · Click a line number for a direct link.

1#!/usr/bin/env python32"""Apply ONLY the guarded diving-catch possession timer change to a copy.3Example: patch_diving_recovery.py input.bin output.bin4The offset is verified for the project's v5.1W base. Other ROMs are accepted5only if the exact original instruction is present; layouts are not guessed.6"""7import argparse,hashlib,struct8from pathlib import Path9p=argparse.ArgumentParser(description=__doc__);p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()10if a.input.resolve()==a.output.resolve():p.error('use a different output path')11if a.output.exists():p.error('output already exists')12d=bytearray(a.input.read_bytes());at=0x1531c;old=bytes.fromhex('357c00050048');new=bytes.fromhex('357c00b40048')13if d[at:at+6]!=old:p.error(f'expected {old.hex()} at {at:06X}; no file written')14if len(d)<0x200 or len(d)%2 or d[0x100:0x104]!=b'SEGA':p.error('expected a raw, even-sized SEGA .bin ROM')15d[at:at+6]=new;struct.pack_into('>H',d,0x18e,sum(struct.unpack(f'>{(len(d)-0x200)//2}H',d[0x200:]))&65535)16a.output.write_bytes(d);print('Only diving-catch timer 5 -> 180 ticks and ROM checksum changed. SHA256',hashlib.sha256(d).hexdigest())17