From 43e16025daf93132a28f1cb650fcf44bb194653a Mon Sep 17 00:00:00 2001 From: Lucent Date: Thu, 12 Oct 2023 01:18:19 +0200 Subject: [PATCH] native bps creation --- Randomizer.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Randomizer.py b/Randomizer.py index 527165e..a20b929 100644 --- a/Randomizer.py +++ b/Randomizer.py @@ -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',