-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- The IPS File Format -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- A quick and easy file format description for one of the most widely used non-binary formats in emulation. Written by Neil_ --FAQ-- o Who will benefit from this document? - The following people will benefit from this tech doc: o Programmers wishing to code an IPS patcher or add IPS patching ability to their programs. o Masochists who absolutely must know what they've been using all these years o What is required knowledge for reading this document? - Not much. It's a pretty straight forward topic. o Why did you write this FAQ for a straight forward topic? - I was wasting time waiting for my brother to get off the Internet on the downstairs computer so I could log on, and the amount of boredom overtook me. --Intro-- The IPS file format is probably the most widely used format in emulation. It's a very handy tool and basically revolutionized the way translation and graphics hacks of commercial ROM images were distributed. Up until the time of it's adoption by ROM Hackers, Hacks had been distributed with the entire ROM image zipped up in a ZIP archive. This proved to be a major waste of space as most hacks changed no more than 5% of the entire ROM image. That meant that the Hacker ended up distributing a file that contained 95% more data than it needed to. Why, in a world of limited bandwidth, make users download more than they absolutely have to? Here's where the IPS file format comes in. An IPS file contains only a list of the bytes that were changed, and what they were changed to. For the first time, hack archives that had been 3 megs suddenly became 22k. Suddenly ROM hack and translation fans could save themselves from downloading 3 megs every time a new version came out, and just download another 30k or so patch. How was this amazing feat of size reduction accomplished? --The IPS File Format-- The first 5 bytes of the IPS format are the letters 'PATCH' in ASCII format. This allows a program reading the file to verify that it is indeed an IPS patch. The next three bytes are the place in the destination file (the file to be patched) where a change is to be made. The two bytes following that are the length of the amount of data to be changed. The next string of bytes are the replacement bytes, which go on for how ever many bytes were specified in the previous two bytes. If the two bytes specifying the length of the patch are zeroes, then there is a section of code being replaced by a single character, say FF. In this case, the next byte gives the number of bytes to be replaced, and the byte after that is the data that will be filled in that area. Once the end of the patching length given is reached, you'll either reach the end of the patch file or another two bytes giving you the location of the next place in the destination file to be changed. In that case, you go through these steps again. --End-- That should just about cover it all... If I missed something, just drop me a line. -Neil_ Neil@parodius.comver it all... If I missed something, just drop me a line. -Neil_ Neil@parodius.com