Skip to content

Commit

Permalink
Merge branch 'main' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
SolventMercury authored Sep 19, 2023
2 parents 41bc793 + 41f98cf commit d2582dd
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- '3.8'
- '3.9'
- '3.10'
- '3.11'

runs-on: ${{ matrix.os }}
name: Wheel for ${{ matrix.os }} (${{ matrix.python }})
Expand Down Expand Up @@ -68,6 +69,7 @@ jobs:
- 'cp38-cp38'
- 'cp39-cp39'
- 'cp310-cp310'
- 'cp311-cp311'

runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ 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. 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.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
77 changes: 39 additions & 38 deletions src/SuperDuperMetroid/ROM_Patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,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)
Expand Down Expand Up @@ -492,42 +493,42 @@ 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",
"eye_fix": "Mandatory Patches\\eye_fix.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",
"eye_fix": "Mandatory Patches/eye_fix.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

Expand Down Expand Up @@ -1382,8 +1383,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()
print("Patching will be applied to ROM at:", file_path)
rom_path_file.close()
Expand Down
2 changes: 1 addition & 1 deletion src/SuperDuperMetroid/SM_Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down
24 changes: 24 additions & 0 deletions src/SuperDuperMetroid/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
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=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()

rom_file = BytesIO(args.input_rom_path.read_bytes())

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)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions test/test_rom_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2582dd

Please sign in to comment.