#!/usr/bin/env python3 import sys # Rango del checksum desp = 0x2000 numBytes = 0x2000 firstByte = desp + 0x200 lastByte = desp + numBytes - 1 checksum1 = desp + 0x270 checksum2 = desp + 0x271 # Bloque de armarios ARM_START = 0x02930 ARM_END = 0x0293B # Armario que quieres dejar cerrado TARGET_BYTE = 0x02934 TARGET_BIT = 0x80 # bit 7 def calc_checksum(buffer): total = 0 for i in range(firstByte, lastByte + 1): if i not in (checksum1, checksum2): total += buffer[i] total += 3328 buffer[checksum1] = total % 256 buffer[checksum2] = (total >> 8) % 256 if len(sys.argv) != 3: print("Uso: python3 abrir_armarios.py save_in.srm save_out.srm") sys.exit(1) infile = sys.argv[1] outfile = sys.argv[2] with open(infile, "rb") as f: buf = bytearray(f.read()) # Abrir todos los armarios for off in range(ARM_START, ARM_END + 1): buf[off] = 0xFF # Cerrar solo el armario objetivo buf[TARGET_BYTE] &= ~TARGET_BIT # FF sin el bit 7 → 7E # Recalcular checksum calc_checksum(buf) with open(outfile, "wb") as f: f.write(buf) print("Hecho:", outfile)