Skip to content

Commit

Permalink
Add __main__ file for SDM
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Sep 11, 2023
1 parent 93a027f commit 0851ca3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions src/SuperDuperMetroid/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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()

0 comments on commit 0851ca3

Please sign in to comment.