Need help editing an existing IPS patch...

Started by aleckermit, February 09, 2020, 06:36:18 PM

Previous topic - Next topic


I recently learned about "Perfect Pokemon Crystal", a hack that attempts to purely improve the original game. The hack is excellent but does have some issues that people have asked to be fixed. I downloaded the source code for the patch supplied at the creator's github and was able to easily edit the ASM files with notepad that contained pkmn encounter rates and trainer data.

My question is: How do I now recompile this folder of sourcecode into an IPS patch?

Thank you.


Your best bet would be to Google around and see if someone has compiled this patch before.  No one here is likely to know.

You see, there is no standard means of recompiling source code into an IPS patch. You just have to look at the github and hope that adequate instructions are provided.  And in this case, there isn't.

To take my best guess: it looks like you might need a Linux development environment.  If you're not already running Linux, in this case you could probably just run a "live" distribution from a USB drive, or run a version in a virtual machine like VMware or VirtualBox.  Download the entire Git repository, change the relevant files, and then run "make" from the root directory of the downloaded repository.  Except there's that "extract this to make it" and I'm not at all clear what you might have to do with that.
This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!


Another alternate to using Linux if you're on Windows is MSYS2 - it's a terminal that you run like a regular program, so you don't have to download a separate OS. I used it to build the standard Pokemon Crystal distribution when I made my own simple patch for the game.


You could search the patched ROM in a hex editor for the entry point(s) where you have subsequently changed the code, then insert/overwrite your new compiled code. It's potentially tedious, depending on how extensive your changes are, how much space there is in memory, and to what degree you have to manage that space. But it may be a more reliable approach than trying to build a patch from source.


Pokemon usually sits somewhat aside from hacking everything else, even more so in the case of some of the older games, and tends to have its own techniques. As others mentioned if the code you downloaded has a readme/guide/nfo/forum post explaining it, or other hacks do then find what they did and replicate it.


Source code to hacks is an odd one. It can be done in the more traditional sense and added on with an assembler if you like -- landing in a location and handling any kind of relative jumps ( ). I don't know what we have for Z80/GBC these days to do that but the principle is simple enough -- telling your assembler your intended memory location for your new code is often doable in a flag for the code, or some kind of comment/command within it. Some might be length aware or have macros as well.

Some pokemon games are also noted as having complete disassemblies done of them. These differ from a typical disassembly by having each and every aspect of the game accounted for (and likely memory labels as well) such that you can easily assemble them again where your basic one likely won't be able to do that. I don't know of crystal has one, or has a complete one, these days offhand. These would be more amenable towards modern text based source code handling techniques wherein you can essentially create text diffs.

Or you can do more traditional tweaks wherein you find the location of what you want and create tweaks accordingly, manually overwriting where necessary.


I can't vouch for an easy or efficient method, but as a few before me have mentioned, when all else fails, manual hex edits of a copy of the ROM with the hack you're changing, use base for Lunar IPS Create Patch function, your new version of the ROM as the modified, and boom, you have an Addendum patch. Then if you want you can compare your new patch to the completely unmodified vanilla ROM if you want to make your own separate patch that can be applied to a fresh ROM.

Tedious yes, but it works when a more efficient method can't be found. And I've done some pretty extensive changes that way, mind-numbing as it is.  :)