From eb93656ec0c423a0039eaecc3fa94a40dc85d74c Mon Sep 17 00:00:00 2001 From: Lucent Date: Wed, 11 Oct 2023 12:24:19 +0200 Subject: [PATCH] yo! no more FLIPS? --- .gitignore | 2 -- README.md | 6 ++++-- Randomizer.py | 15 +++++++++++++-- requirements.txt | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index ee0922e..538d7cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ __pycache__/** *.gba settings.json -flips/flips -flips/flips.exe diff --git a/README.md b/README.md index 9b1a0d9..a7716b1 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ Considering the original repository states that the software is GPL-3.0 licensed - [x] GUI - [x] CRC verification - [ ] Logic -- [ ] Patching +- [ ] Reconstructing missing parts of code +- [x] Patching +- [ ] Generating BPS patches ## Usage -Beware: stuff doesn't work as it should yet. Prerequisites are PySimpleGUI (and tkinter by proxy). A prerequisites file is going to be added in the future. +Beware: stuff doesn't work as it should yet. Prerequisites are PySimpleGUI (and tkinter by proxy) and python-bps-continued. A prerequisites file is available so you can `pip install -r requirements.txt` away. Clone the repository, install prerequisites manually via pip or your favourite package manager, `python MFOR.py`. Choose your game options (hover over a given option to see a tooltip explaining it), then click Generate. A popup will ask you to open an unmodified copy of the original game. This is not provided with the randomizer for legal reasons. diff --git a/Randomizer.py b/Randomizer.py index f0bb882..4937bff 100644 --- a/Randomizer.py +++ b/Randomizer.py @@ -13,6 +13,8 @@ import zlib import math import Fusion_Graph as Graph from Fusion_Items import * +from bps.apply import apply_to_files + version = '0.11.6' def ceiling(num, denom): @@ -4665,8 +4667,17 @@ def patch_game(): os.system('.\\armips\\armips.exe "Metroid Fusion Open Randomizer.asm" -root ".\\data\\asm" -sym ".\\temp.sym"') os.replace('.\\data\\MFOR.gba', '.\\seeds\\{}.gba'.format(FileName)) else: - # FIXME: windows? - os.system(os.path.join('.', 'flips', 'flips') + ' --apply ' + os.path.join('.', 'data', 'MFOR.bps') + ' "' + BaseName + '" "'+ os.path.join('.', 'seeds', '{}.gba'.format(FileName)) + '"') + source = open(BaseName, 'rb') + target = open(os.path.join('.', 'seeds', '{}.gba'.format(FileName), 'wb') + patch = open(os.path.join('.', 'data', 'MFOR.bps'), 'rb') + try: + apply_to_files(patch, source, target) + except: + target.close() + os.unlink(os.path.join('.', 'seeds', '{}.gba'.format(FileName)) + print('Error: failed to patch game with base patch!') + sys.exit(1) + checksum = fileHash(os.path.join('.', 'seeds', '{}.gba'.format(FileName))) if checksum != 2455114263: os.remove(os.path.join('.', 'seeds', '{}.gba'.format(FileName))) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fe3464f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +PySimpleGUI==4.60.5 +python-bps-continued==7