-
Notifications
You must be signed in to change notification settings - Fork 261
/
mk8.py
50 lines (36 loc) · 1.36 KB
/
mk8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# MK8.py - by Ac_K
import edizon, zlib
saveFileBuffer = edizon.getSaveFileBuffer()
def getValueFromSaveFile():
strArgs = edizon.getStrArgs()
intArgs = edizon.getIntArgs()
indirectAddress = int(strArgs[0], 16)
address = int(strArgs[1], 16)
addressSize = intArgs[0]
valueSize = intArgs[1]
offset = 0
value = 0
if indirectAddress != 0:
for i in range(0, addressSize):
offset = offset | (saveFileBuffer[indirectAddress + i] << i * 8)
for i in range(0, valueSize):
value = value | (saveFileBuffer[offset + address + i] << i * 8)
return value
def setValueInSaveFile(value):
strArgs = edizon.getStrArgs()
intArgs = edizon.getIntArgs()
indirectAddress = int(strArgs[0], 16)
address = int(strArgs[1], 16)
addressSize = intArgs[0]
valueSize = intArgs[1]
offset = 0
if indirectAddress != 0:
for i in range(0, addressSize):
offset = offset | (saveFileBuffer[indirectAddress + i] << (i * 8))
for i in range(0, valueSize):
saveFileBuffer[offset + address + i] = (value & (0xFF << i * 8)) >> (i * 8)
def getModifiedSaveFile():
new_checksum = zlib.crc32(saveFileBuffer[0x48:])
for i in range(0, 4):
saveFileBuffer[0x38 + i] = (new_checksum & (0xFF << i * 8)) >> (i * 8)
return saveFileBuffer