Advertisement
Visual_Studio

Resident Evil 4 HD Switch Save Converter

May 22nd, 2019
1,746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from io import BytesIO
  4. from os.path import isfile
  5. from argparse import ArgumentParser
  6.  
  7. SWITCH_SETTINGS_OFFSET = 0x1E40
  8. SWITCH_DEFAULT_SETTINGS = bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x40, 0x02, 0x02, 0x00, 0x5F, 0x00])
  9.  
  10.  
  11. def read_file(filename: str) -> bytes:
  12.     with open(filename, "rb") as f:
  13.         data = f.read()
  14.     return data
  15.  
  16. def write_file(filename: str, data: (bytes, bytearray)) -> None:
  17.     with open(filename, "wb") as f:
  18.         f.write(data)
  19.  
  20. if __name__ == "__main__":
  21.     parser = ArgumentParser(description="A script to port RE:4 HD (Xbox 360, PS3, PS4, and PC) saves to Switch")
  22.     parser.add_argument("input", type=str, help="The input filename")
  23.     parser.add_argument("output", type=str, help="The output filename")
  24.     args = parser.parse_args()
  25.  
  26.     assert isfile(args.input), "The specified input file doesn't exist"
  27.  
  28.     save_data = read_file(args.input)
  29.     with BytesIO(save_data) as bio:
  30.         bio.seek(SWITCH_SETTINGS_OFFSET)
  31.         bio.write(SWITCH_DEFAULT_SETTINGS)
  32.         bio.flush()
  33.         write_file(args.output, bio.getvalue())
  34.     print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement