The following is a way to create many IPS files against one original rom file.
<aside> ⚠️
I work with the .sfc archive rom from a game that I own a physical copy of, so this is completely legal tinkering on my part— I do not endorse nor advise illegal use of this software.
</aside>
Use this command to install the library that exists in the Python ecosystem to create .ips files, as the script on this page uses it (depends on it). Ensure that you open the Windows Command Prompt as an Admin user, or else this might not install correctly.
pip install ips.py
Paste this code into a new empty file and name it something like “patch-maker.py”.
Adapt the lines right below “Example usage:” to mention your rom files and the patch name that you want to create.
Run it with python patch-maker.py
import ips
# Function to generate an IPS patch
def create_ips_patch(original_rom, modified_rom, output_patch):
# Error handling logic
try:
# Load original and modified ROMs
# 'rb' = 'read as binary data'
with open(original_rom, 'rb') as orig, open(modified_rom, 'rb') as mod:
# Generate the patch using the 'ips' library
patch = ips.Patch.create(orig, mod)
# Save the IPS patch (yep, 'wb' = 'write as binary')
with open(output_patch, 'wb') as patch_file:
patch_file.write(bytes(patch)) # writes using bytes method
print(f"Patch file '{output_patch}' created successfully!")
# Error message
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
original_rom = './_orig-rom.sfc' # Replace with your original ROM path
modified_rom = './rom-w-new-colors-xJ4cks.sfc' # Replace with your modified ROM path
output_patch = './rom-w-new-colors-xJ4cks.ips' # Replace with the desired patch file path
create_ips_patch(original_rom, modified_rom, output_patch)
This is not yet optimized for bulk actions. Stay tuned for improvements that will loop through ALL the altered roms in a directory and create patches against the original rom from each one.
Here is the output of the first draft script— custom sprites for a playable character were mapped into a patch file, in the ips format. “IPS Peek” utility shows all the changes made by the script and saved as a “byte” object by the python code. (The byte object IS the patch.)
Compare this with the results of using the excellent GUI tool “Lunar IPS”. It generated an identical patch to the python script above:
Like I wrote, stay tuned for a modified python script that will feature a loop to move through a series of changed rom files, and create patch files for each one against an original rom. This is meant to be an automation tool, but it’s only 2/3 of the way there.