gortbot

p5r 16:10 python script

Apr 23rd, 2026
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | Gaming | 0 0
  1. import sys
  2. import shutil
  3. from pathlib import Path
  4.  
  5. print("===============================================")
  6. print(" 16:9 -> 16:10 Aspect Ratio Patcher (Fast)")
  7. print(" Replaces float 1.7777778 with 1.6")
  8. print("===============================================\n")
  9.  
  10. exe_path = Path.cwd() / "P5R.exe"
  11.  
  12. if not exe_path.exists():
  13.     print("ERROR: P5R.exe not found in this folder.")
  14.     print("Put this script next to the EXE or edit exe_path.")
  15.     input("Press ENTER to exit")
  16.     sys.exit(1)
  17.  
  18. print(f"Target EXE:\n  {exe_path}\n")
  19.  
  20. backup_path = Path(str(exe_path) + ".backup_before_16by10")
  21. if not backup_path.exists():
  22.     print(f"Creating backup:\n  {backup_path}")
  23.     shutil.copy2(exe_path, backup_path)
  24. else:
  25.     print(f"Backup already exists:\n  {backup_path}")
  26.  
  27. print()
  28. print("Reading EXE bytes...")
  29. data = bytearray(exe_path.read_bytes())
  30. print(f"File size: {len(data):,} bytes\n")
  31.  
  32. FROM = bytes([0x39, 0x8E, 0xE3, 0x3F])
  33. TO   = bytes([0xCD, 0xCC, 0xCC, 0x3F])
  34.  
  35. print("Searching for 16:9 aspect constant (1.7777778)...")
  36.  
  37. count = 0
  38. pos = 0
  39. while True:
  40.     index = data.find(FROM, pos)
  41.     if index == -1:
  42.         break
  43.     data[index:index + len(FROM)] = TO
  44.     count += 1
  45.     pos = index + len(FROM)
  46.  
  47. print()
  48. print("===============================================")
  49. print(f"  Total replacements applied: {count}")
  50. print("===============================================\n")
  51.  
  52. exe_path.write_bytes(data)
  53.  
  54. print(f"Patched EXE saved as:\n  {exe_path}")
  55. print(f"Original backup kept as:\n  {backup_path}\n")
  56. input("Press ENTER to exit")
Advertisement
Add Comment
Please, Sign In to add comment