native bps creation

master
Lucent 2023-10-12 01:18:19 +02:00
parent 86b344f933
commit 43e16025da
1 changed files with 15 additions and 2 deletions

View File

@ -14,6 +14,9 @@ import math
import Fusion_Graph as Graph
from Fusion_Items import *
from bps.apply import apply_to_files
from bps.diff import diff_bytearrays
from bps.io import write_bps
from bps.util import bps_progress
version = '0.11.6'
@ -4913,8 +4916,18 @@ def patch_game():
patchedGame.write(value.to_bytes(1, 'little'))
if Patch:
# FIXME: replace with internal patch creator
os.system('.\\flips\\flips.exe --create --bps "{}" ".\\seeds\\{}.gba"'.format(BaseGame, FileName))
with open(BaseGame, 'rb') as source:
sourcedata = source.read()
with open(os.path.join('.', 'seeds', '{}.gba'.format(FileName)), 'rb') as target:
targetdata = target.read()
patch = open(os.path.join('.', 'seeds', '{}.bps'.format(FileName)), 'wb')
blocksize = (len(sourcedata) + len(targetdata)) // 1000000 + 1
print("Using blocks of {0} bytes".format(blocksize))
iterable = diff_bytearrays(blocksize, sourcedata, targetdata)
write_bps(bps_progress(iterable), patch)
print('')
ItemNames = [
'Missile Data',