Skip to content

Instantly share code, notes, and snippets.

@LemonBoy
Created July 27, 2011 14:44
Show Gist options
  • Save LemonBoy/1109498 to your computer and use it in GitHub Desktop.
Save LemonBoy/1109498 to your computer and use it in GitHub Desktop.
Custom Robo Arena Checksum Fixer
import sys, struct, zlib
print 'Checksum fixer for Custom Robot Arena (NDS)'
print 'The Lemon Man (c) 2011'
if len(sys.argv) < 2:
print 'Usage :\n\t%s <save name.sav>' % sys.argv[0]
sys.exit(1)
fil = open(sys.argv[1], 'r+b')
for slot in range(2):
print 'Processing slot %i' % slot
buf = fil.read(0x100)
slot_crc = struct.unpack('<I', buf[0x30:0x34])[0]
calc_crc = abs(zlib.crc32(buf[:0x30]))
print 'Slot : %x' % slot_crc
print 'Calc : %x' % calc_crc
if slot_crc != calc_crc:
print 'Fixing the checksum...'
fil.seek(0x100 * slot + 0x30)
fil.write(struct.pack('<I', calc_crc))
else:
print 'Checksum are matching...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment