Last active
June 14, 2022 21:29
-
-
Save infval/f7bfe55d9bca4f8daea46e75ffe504cb to your computer and use it in GitHub Desktop.
Fix pirated PlayStation 1 BIN for OpenEmu, Mednafen | Исправление пиратских PlayStation 1 дисков для запуска на эмуляторах [ PSX, PS1, PSOne ]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Fix pirated PlayStation 1 BIN for OpenEmu, Mednafen | |
usage: | |
script.py Image.bin [0|1|2] | |
0 - Japan, 1 - USA, 2 - Europe. Default: 1 | |
examples: | |
script.py "Chrono Cross (USA) (Disc 1).bin" | |
script.py "Chrono Cross (USA) (Disc 1).bin" 1 | |
script.py "Sexy Parodius (Japan).bin" 0 | |
after: | |
CDmage. Action > Scan For Corruption & Action > Rebuild Sector Fields | |
""" | |
import sys | |
LIC_OFFSET = 0x24E0 | |
licenses = ( | |
b" Licensed by Sony Computer Entertainment Inc.\x0A00000", | |
b" Licensed by Sony Computer Entertainment Amer ica ", | |
b" Licensed by Sony Computer Entertainment Euro pe " | |
) | |
lic_index = 1 | |
if len(sys.argv) > 2: | |
lic_index = int(sys.argv[2]) | |
lic = licenses[lic_index] | |
with open(sys.argv[1], "r+b") as f: | |
f.seek(LIC_OFFSET) | |
prev = f.read(len(lic)) | |
print("Previous (0x{:X}): {}".format(LIC_OFFSET, prev)) | |
f.seek(LIC_OFFSET) | |
f.write(lic) | |
print("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment