From 5d0fb17e7e0e88613c6bf2eec402a3f3f41ce7ce Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 10 Apr 2023 12:27:46 +0200 Subject: [PATCH 1/6] Build for Python 3.11 --- .github/workflows/python.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index dc6255b..74814ae 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -27,6 +27,7 @@ jobs: - '3.8' - '3.9' - '3.10' + - '3.11' runs-on: ${{ matrix.os }} name: Wheel for ${{ matrix.os }} (${{ matrix.python }}) @@ -68,6 +69,7 @@ jobs: - 'cp38-cp38' - 'cp39-cp39' - 'cp310-cp310' + - 'cp311-cp311' runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 @@ -118,6 +120,7 @@ jobs: - {version: '3.8', wheel: 'cp38-cp38'} - {version: '3.9', wheel: 'cp39-cp39'} - {version: '3.10', wheel: 'cp310-cp310'} + - {version: '3.11', wheel: 'cp311-cp311'} steps: - name: Checkout From 3c2d25eb74e2c4dc9f37daed1199a2e78a3ac14a Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 10 Apr 2023 19:38:02 +0300 Subject: [PATCH 2/6] Re run for new black --- src/SuperDuperMetroid/ROM_Patcher.py | 2 +- src/SuperDuperMetroid/SM_Interface.py | 2 +- test/test_rom_patcher.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SuperDuperMetroid/ROM_Patcher.py b/src/SuperDuperMetroid/ROM_Patcher.py index 3b6f644..b253f2a 100644 --- a/src/SuperDuperMetroid/ROM_Patcher.py +++ b/src/SuperDuperMetroid/ROM_Patcher.py @@ -318,6 +318,7 @@ def __init__( # class PickupEffect(Enum): + # Converts a hexadecimal string to a base 10 integer. def hex_to_int(hex_to_convert): return int(hex_to_convert, 16) @@ -644,7 +645,6 @@ def write_door_asm_routines(rom_file, door_data_list): door_routine.append(0x60) if door_routine == most_basic_door_asm: - door_data.door_asm_pointer = most_basic_door_asm_address else: door_data.door_asm_pointer = current_address diff --git a/src/SuperDuperMetroid/SM_Interface.py b/src/SuperDuperMetroid/SM_Interface.py index 17f74c2..d51cd08 100644 --- a/src/SuperDuperMetroid/SM_Interface.py +++ b/src/SuperDuperMetroid/SM_Interface.py @@ -39,6 +39,7 @@ from SuperDuperMetroid.SM_Constants import SuperMetroidConstants from websocket import create_connection + # Converts a hexadecimal string to a base 10 integer. def hex_to_int(hex_to_convert): return int(hex_to_convert, 16) @@ -81,7 +82,6 @@ def pad_hex(hex_to_pad, num_hex_characters): class SuperMetroidInterface: - # These get imported dynamically from a JSON file created by the patcher. # This is necessary because these may not always be in the same place every game. itemRoutineDict = { diff --git a/test/test_rom_patcher.py b/test/test_rom_patcher.py index 156fb0c..97d86c1 100644 --- a/test/test_rom_patcher.py +++ b/test/test_rom_patcher.py @@ -2,6 +2,7 @@ romSize = 3145728 + # endAddress is excluded def is_file_byte_range_empty(f, empty_byte, start_address, end_address): found_non_empty_byte = False From b0b3e00ea534bc48fcaae57007caef08103fbc16 Mon Sep 17 00:00:00 2001 From: SolventMercury <87032239+SolventMercury@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:10:02 -0700 Subject: [PATCH 3/6] Change version number --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 86fad24..02b9077 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = SuperDuperMetroid -version = 2.3.0 +version = 2.3.2 author = Samuel Roy description = A Super Metroid patching utility long_description = file: README.md From d1026d0ab19020126e1c5835d7b590d8cdc166f1 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:49:58 +0200 Subject: [PATCH 4/6] Replace backslashes with forward slashes --- src/SuperDuperMetroid/ROM_Patcher.py | 74 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/SuperDuperMetroid/ROM_Patcher.py b/src/SuperDuperMetroid/ROM_Patcher.py index 56e6957..dc2eae4 100644 --- a/src/SuperDuperMetroid/ROM_Patcher.py +++ b/src/SuperDuperMetroid/ROM_Patcher.py @@ -493,41 +493,41 @@ def create_item_types(pickup_data_list): def get_patch_dict(): static_patch_dict = { - "instant_g4": "QoL\\g4_skip.ips", - "max_ammo_display": "QoL\\max_ammo_display.ips", - "aim_with_any_button": "QoL\\aim_any_button.ips", - "better_decompression": "QoL\\better_decompress.ips", - "fast_doors_and_elevators": "QoL\\fast_elevators_doors.ips", - "backup_saves": "QoL\\enable_backup_saves.ips", - "enable_moonwalk_by_default": "QoL\\enable_moonwalk_by_default.ips", - "random_music": "Music\\random_music.ips", - "no_music": "Music\\no_music.ips", - "door_transitions": "Mandatory Patches\\door_transition.ips", - "varia_rng": "Mandatory Patches\\varia_rng.ips", - "varia_timer_fix": "Mandatory Patches\\varia_timer_fix.ips", - "seed_display": "Mandatory Patches\\seed_display.ips", - "respin": "Tweaks\\respin.ips", - "no_demo": "Tweaks\\no_demo.ips", - "refill_before_save": "Tweaks\\refill_before_save.ips", - "cant_use_supers_on_red_doors": "Tweaks\\no_supers_on_red_doors.ips", - "cheap_charge": "Tweaks\\cheap_charge.ips", - "nerfed_rainbow_beam": "Tweaks\\nerfed_rainbow_beam.ips", - "mother_brain_cutscene_edits": "Tweaks\\mother_brain_cutscene_edits.ips", - "infinite_space_jump": "Tweaks\\infinite_space_jump.ips", - "speedkeep": "Tweaks\\speed_keep.ips", - "no_ln_chozo_inventory_check": "Tweaks\\no_ln_chozo_inventory_check.ips", - "no_gt_code": "Fixes\\disable_gt_code.ips", - "fix_heat_echoes": "Fixes\\fix_heat_echoes.ips", - "fix_screw_attack_menu": "Fixes\\fix_screw_attack_menu.ips", - "fix_spacetime": "Fixes\\fix_spacetime_beam.ips", - "dachora_pit": "Map Changes\\dachora_pit.ips", - "early_supers_bridge": "Map Changes\\early_super_bridge.ips", - "pre_hi_jump": "Map Changes\\pre_high_jump.ips", - "moat": "Map Changes\\moat.ips", - "pre_spazer": "Map Changes\\pre_spazer.ips", - "red_tower": "Map Changes\\red_tower.ips", - "nova_boost_platform": "Map Changes\\nova_boost_platform.ips", - "colorblind_mode": "Accessibility\\colorblind.ips", + "instant_g4": "QoL/g4_skip.ips", + "max_ammo_display": "QoL/max_ammo_display.ips", + "aim_with_any_button": "QoL/aim_any_button.ips", + "better_decompression": "QoL/better_decompress.ips", + "fast_doors_and_elevators": "QoL/fast_elevators_doors.ips", + "backup_saves": "QoL/enable_backup_saves.ips", + "enable_moonwalk_by_default": "QoL/enable_moonwalk_by_default.ips", + "random_music": "Music/random_music.ips", + "no_music": "Music/no_music.ips", + "door_transitions": "Mandatory Patches/door_transition.ips", + "varia_rng": "Mandatory Patches/varia_rng.ips", + "varia_timer_fix": "Mandatory Patches/varia_timer_fix.ips", + "seed_display": "Mandatory Patches/seed_display.ips", + "respin": "Tweaks/respin.ips", + "no_demo": "Tweaks/no_demo.ips", + "refill_before_save": "Tweaks/refill_before_save.ips", + "cant_use_supers_on_red_doors": "Tweaks/no_supers_on_red_doors.ips", + "cheap_charge": "Tweaks/cheap_charge.ips", + "nerfed_rainbow_beam": "Tweaks/nerfed_rainbow_beam.ips", + "mother_brain_cutscene_edits": "Tweaks/mother_brain_cutscene_edits.ips", + "infinite_space_jump": "Tweaks/infinite_space_jump.ips", + "speedkeep": "Tweaks/speed_keep.ips", + "no_ln_chozo_inventory_check": "Tweaks/no_ln_chozo_inventory_check.ips", + "no_gt_code": "Fixes/disable_gt_code.ips", + "fix_heat_echoes": "Fixes/fix_heat_echoes.ips", + "fix_screw_attack_menu": "Fixes/fix_screw_attack_menu.ips", + "fix_spacetime": "Fixes/fix_spacetime_beam.ips", + "dachora_pit": "Map Changes/dachora_pit.ips", + "early_supers_bridge": "Map Changes/early_super_bridge.ips", + "pre_hi_jump": "Map Changes/pre_high_jump.ips", + "moat": "Map Changes/moat.ips", + "pre_spazer": "Map Changes/pre_spazer.ips", + "red_tower": "Map Changes/red_tower.ips", + "nova_boost_platform": "Map Changes/nova_boost_platform.ips", + "colorblind_mode": "Accessibility/colorblind.ips", } return static_patch_dict @@ -1379,8 +1379,8 @@ def patch_rom(rom_file, output_path, item_list=None, player_name=None, recipient if __name__ == "__main__": # Build in this to make it faster to test. # Saves me some time. - if os.path.isfile(os.getcwd() + "\\romfilepath.txt"): - rom_path_file = open(os.getcwd() + "\\romfilepath.txt", "r") + if os.path.isfile(os.getcwd() + "/romfilepath.txt"): + rom_path_file = open(os.getcwd() + "/romfilepath.txt", "r") file_path = rom_path_file.readline().rstrip() rom_path_file.close() else: From 516744d5cd697ed944eda21dd31d4d82bb997952 Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 11 Sep 2023 22:41:15 +0200 Subject: [PATCH 5/6] Add __main__ file for SDM --- README.md | 16 ++++++++-------- src/SuperDuperMetroid/__main__.py | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 src/SuperDuperMetroid/__main__.py diff --git a/README.md b/README.md index c3ebc73..32c1f05 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ Super Duper Metroid is a Super Metroid patcher and interface program, intended f # Building Requires an adequate version of python Steps: -1.) Clone this repository -2.) Open a terminal in the repository's root -3.) Create a virtual environment by running `py -3.9 -m venv venv` -4.) Open virtual environment with `venv\scripts\activate` -5.) Install requirements by running `python -m pip install -r requirements.txt` -6.) Build Cython code by running `python setup.py` -7.) Install as editable by running `py -3.9 -m pip install -e .` +1. Clone this repository +2. Open a terminal in the repository's root +3. Create a virtual environment by running `python -m venv venv` +4. Activate the virtual environment with `call venv/bin/activate` on Windows or `source venv/bin/activate` on Unix-based systems +5. Install requirements by running `python -m pip install -r requirements.txt` +6. Build Cython code by running `python setup.py`. +7. Install as editable by running `python -m pip install -e .` -You can now run scripts from the project from terminal, using the virtual environment. +You can now run scripts from the project from terminal, using the virtual environment. Or run `python -m Super-Duper-Metroid` to patch the game via a CLI interface. # Credit Credit goes to Samuel Roy for writing most of this code. diff --git a/src/SuperDuperMetroid/__main__.py b/src/SuperDuperMetroid/__main__.py new file mode 100644 index 0000000..1f8b0ed --- /dev/null +++ b/src/SuperDuperMetroid/__main__.py @@ -0,0 +1,24 @@ +import json +from SuperDuperMetroid.ROM_Patcher import patch_rom_json +from io import BytesIO +import argparse + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--input-rom-path", type=str, required=True) + parser.add_argument("--output-rom-path", type=str, required=True) + parser.add_argument("--json-path", type=str, required=True) + args = parser.parse_args() + + with open(args.input_rom_path, "rb+") as fh: + rom_file = BytesIO(fh.read()) + + with open(args.json_path) as json_contents: + patch_data = json.load(json_contents) + + patch_rom_json(rom_file, args.output_rom_path, patch_data) + + +if __name__ == "__main__": + main() From 5619f978e9fb16ead3fba5adf33d5f0bc3897cf4 Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 11 Sep 2023 23:04:31 +0200 Subject: [PATCH 6/6] Address reviews for main file --- README.md | 3 +-- src/SuperDuperMetroid/__main__.py | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 32c1f05..eb4441f 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ Steps: 3. Create a virtual environment by running `python -m venv venv` 4. Activate the virtual environment with `call venv/bin/activate` on Windows or `source venv/bin/activate` on Unix-based systems 5. Install requirements by running `python -m pip install -r requirements.txt` -6. Build Cython code by running `python setup.py`. -7. Install as editable by running `python -m pip install -e .` +6. Install as editable by running `python -m pip install -e .` You can now run scripts from the project from terminal, using the virtual environment. Or run `python -m Super-Duper-Metroid` to patch the game via a CLI interface. diff --git a/src/SuperDuperMetroid/__main__.py b/src/SuperDuperMetroid/__main__.py index 1f8b0ed..d1c06db 100644 --- a/src/SuperDuperMetroid/__main__.py +++ b/src/SuperDuperMetroid/__main__.py @@ -2,19 +2,19 @@ from SuperDuperMetroid.ROM_Patcher import patch_rom_json from io import BytesIO import argparse +from pathlib import Path def main(): parser = argparse.ArgumentParser() - parser.add_argument("--input-rom-path", type=str, required=True) - parser.add_argument("--output-rom-path", type=str, required=True) - parser.add_argument("--json-path", type=str, required=True) + parser.add_argument("--input-rom-path", type=Path, required=True) + parser.add_argument("--output-rom-path", type=Path, required=True) + parser.add_argument("--json-path", type=Path, required=True) args = parser.parse_args() - with open(args.input_rom_path, "rb+") as fh: - rom_file = BytesIO(fh.read()) + rom_file = BytesIO(args.input_rom_path.read_bytes()) - with open(args.json_path) as json_contents: + with args.json_path.open() as json_contents: patch_data = json.load(json_contents) patch_rom_json(rom_file, args.output_rom_path, patch_data)