rompatcher.js

repository·master·Indexed 22 days ago

https://github.com/marcrobledo/rompatcher.js

A JavaScript-based ROM patcher compatible with IPS, BPS, APS, UPS, RUP, PPF, EBP, BSDiff, VCDiff, and other formats. It can be used in modern web browsers, Node.js environments via CLI, or as a Docker container to patch ROMs and create new patches by comparing original and modified ROM files.

Tokens
1.5K
Snippets
9
Records
11
Agent score
77%

What's inside rompatcher.js

  1. Understand the Docker folder structure

    master

    The Docker setup relies on a specific directory structure to manage inputs and outputs via volumes. Files placed in input/ and output/ are visible on your host machine.

    project-root/
    └── docker/
      ├── .gitignore
      ├── .dockerignore
      ├── docker-compose.yml
      ├── Dockerfile
      ├── entrypoint.sh
      ├── input/   # Place ROMs and patches here
      └── output/  # Patched ROMs will appear here
  2. Use Rom Patcher JS via Node CLI

    master

    Rom Patcher JS can be run in a Node.js environment via the command line. This allows for automated patching and patch creation processes.

    Installation

    First, install the necessary dependencies:

    npm install

    Patching a ROM

    To apply a patch to an existing ROM file:

    node index.js patch "my_rom.bin" "my_patch.ips"

    Creating an IPS patch

    To generate a new IPS patch by comparing an original ROM with a modified version:

    node index.js create "original_rom.bin" "modified_rom.bin"

    CLI Help

    To view all available options and flags for the patch or create commands:

    node index.js patch --help
    node index.js create --help
    node index.js patch "my_rom.bin" "my_patch.ips"
    node index.js create "original_rom.bin" "modified_rom.bin"
  3. Embed Rom Patcher JS in your website

    master

    You can embed Rom Patcher JS into your own website to provide an online ROM patching service. This allows users to patch ROMs directly in their browser without downloading patch files locally.

    To get started, use the index_template.html file provided in the repository as a functional baseline for your implementation. For more complex integration requirements, refer to the project's wiki.

    <!-- Use index_template.html as a starting point for your implementation -->
  4. Set up RomPatcher.js using Docker

    master

    You can run RomPatcher.js inside a Node.js container to patch ROM files without installing Node.js on your host machine. The setup uses Docker volumes to manage files:

    • Input: Place your ROMs and patch files (*.bps or *.zip) in the docker/input folder.
    • Output: Patched ROMs are automatically saved to the docker/output folder.

    ZIP patch files are automatically extracted by the container during the process.

    # From inside the docker/ directory
    docker-compose up --build
  5. Run Rom Patcher JS via Docker Compose

    master

    You can run Rom Patcher JS using Docker Compose. The configuration defines a service named rompatcher that builds from the repository root using the Dockerfile located at docker/Dockerfile.

    To manage input and output files, the following host directories are mapped to the container:

    • ./input maps to /app/input inside the container.
    • ./output maps to /app/output inside the container.

    Ensure you have created these local directories before running the container to avoid permission issues or unexpected behavior.

    services:
      rompatcher:
        build:
          context: ..
          dockerfile: docker/Dockerfile
        container_name: rompatcher
        volumes:
          - ./input:/app/input
          - ./output:/app/output
        restart: "no"
  6. Patch ROMs with an example workflow

    master

    To patch a specific game, follow these steps:

    1. Place your ROM file (e.g., MyGame.v64) into the docker/input directory.
    2. Place your patch files (supporting *.bps or *.zip formats) into the docker/input directory.
    3. Navigate to the docker folder and run the build command.
    4. Retrieve your patched ROM from the docker/output directory.
    cd docker
    docker-compose up --build
  7. Reference: `patch` command options

    master

    The following options are available when using the patch command to control how the ROM is processed and validated.

    -v, --validate-checksum    should validate checksum
    -h1, --add-header           adds a temporary header to the provided ROM for patches that require headered ROMs
    -h0, --remove-header        removes ROM header temporarily for patches that require headerless ROMs
    -f, --fix-checksum         fixes any known ROM header checksum if possible
    -s, --output-suffix        add a (patched) suffix to output ROM file name
  8. Create a patch from two ROMs via CLI

    master

    Use the create command to generate a patch file by comparing an original ROM with a modified ROM. You can specify the desired patch format using the --format option.

    node index.js create "original_rom.bin" "modified_rom.bin"