Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import shutil
- from pathlib import Path
- print("===============================================")
- print(" 16:9 -> 16:10 Aspect Ratio Patcher (Fast)")
- print(" Replaces float 1.7777778 with 1.6")
- print("===============================================\n")
- exe_path = Path.cwd() / "P5R.exe"
- if not exe_path.exists():
- print("ERROR: P5R.exe not found in this folder.")
- print("Put this script next to the EXE or edit exe_path.")
- input("Press ENTER to exit")
- sys.exit(1)
- print(f"Target EXE:\n {exe_path}\n")
- backup_path = Path(str(exe_path) + ".backup_before_16by10")
- if not backup_path.exists():
- print(f"Creating backup:\n {backup_path}")
- shutil.copy2(exe_path, backup_path)
- else:
- print(f"Backup already exists:\n {backup_path}")
- print()
- print("Reading EXE bytes...")
- data = bytearray(exe_path.read_bytes())
- print(f"File size: {len(data):,} bytes\n")
- FROM = bytes([0x39, 0x8E, 0xE3, 0x3F])
- TO = bytes([0xCD, 0xCC, 0xCC, 0x3F])
- print("Searching for 16:9 aspect constant (1.7777778)...")
- count = 0
- pos = 0
- while True:
- index = data.find(FROM, pos)
- if index == -1:
- break
- data[index:index + len(FROM)] = TO
- count += 1
- pos = index + len(FROM)
- print()
- print("===============================================")
- print(f" Total replacements applied: {count}")
- print("===============================================\n")
- exe_path.write_bytes(data)
- print(f"Patched EXE saved as:\n {exe_path}")
- print(f"Original backup kept as:\n {backup_path}\n")
- input("Press ENTER to exit")
Advertisement
Add Comment
Please, Sign In to add comment