ROM patching tool

DarrenF

Well-known member
Joined
Jan 7, 2011
Messages
5,855
Reaction score
526
Location
Florida
I'm creating some modified ("hacked") code for an arcade game, and I'm looking for an easy way to distribute it. (In addition, I've got several different mods I'd like users to be able to add independantly).

Looking for a tool which will create and apply patches to binary ROM files. Patch files used/created must be simple ASCII text and look more or less like this:

; patch from 1C-0 to 1C-0
Offset $00B8: From $FF To $CB
Offset $00C0: From $FF To $21
Offset $00C1: From $FF To $70
Offset $00C2: From $FF To $08
Offset $00C3: From $FF To $06
Offset $00C4: From $FF To $34

I can deal with DOS/Windows executables or compile myself on *nix from source.
Java applets need not apply.

Thanks!
 
Last edited:
I'm creating some modified ("hacked") code for an arcade game, and I'm looking for an easy way to distribute it. (In addition, I've got several different mods I'd like users to be able to add independantly).

Looking for a tool which will create and apply patches to binary ROM binary files. Patch files used/created must be simple ASCII text and look like this:

; patch from 1C-0 to 1C-0
Offset $00B8: From $FF To $CB
Offset $00C0: From $FF To $21
Offset $00C1: From $FF To $70
Offset $00C2: From $FF To $08
Offset $00C3: From $FF To $06
Offset $00C4: From $FF To $34

I can deal with DOS/Windows executables or compile myself on *nix from source.
Java applets need not apply.

Thanks!

:Confused: If you code well enough to hack assembler, writing a C route to search/replace a binary file at defined locations should be cake. The hardest part of the job is parsing the script files...

Also, isn't this what the mame cheat function is for?
 
Last edited:
http://sites.inka.de/tesla/others.html#bsdiff

i could code something if you realllly want it., but i would use bsdiff/bspatch.

you always want to check the md5sum of the file you are patching first, as you don't want the wrong file patched.


so, i format more like this would be better:
S:MD5HASH
D:MD5HASH
O:0000,77
O:03AB,FF

You would then test the file against both hashes to see if already patched.
 
Well, there's the whole IPS system for patching ROMs. It works OK, but it *totally* fails because it doesn't to any kind of checksumming to verify that the ROM you're patching is even the right one. It just blindly patches the file, and if you applied a patch to the wrong revision of the ROM, it just produces an unusable file.

IPS patches are commonly distributed for translating game ROMs. But for whatever reason, the people that create these patches never thought to supply their patch with a checksum of the ROM it was intended to be applied to...

So, functionally, it works fine, and there exist patching utilities for all major OSes. But be sure to supply a checksum so users know what ROM to apply said patch to.

-Ian
 
:Confused: If you code well enough to hack assembler, writing a C route to search/replace a binary file at defined locations should be cake. The hardest part of the job is parsing the script files...

Also, isn't this what the mame cheat function is for?


not when you want to run the modified file in the arcade machine on real hardware.

distributing roms (modified or not) is violation of copyright laws, but distributing the "patch" to modify your source roms is not.
 
http://sites.inka.de/tesla/others.html#bsdiff
you always want to check the md5sum of the file you are patching first, as you don't want the wrong file patched.

I can slap something together that'll do it, I just figured such a tool must already exist, so I didn't want to waste time. Playing with M68000 opcodes is more fun than C anyhow :p

Actually, I don't want to check the input file or output files against a checksum. As I mentioned, I will end up with a number of different patches, which effect different parts of the code, and I want them to be usable independantly. (A la carte features; not everyone will want everything...). As a result, one user may choose to apply only one patch (for only one feature/bugfix), but another may choose to apply several of the patches. As a result, the starting and ending files may differ, and a checksum would not be of use.

I'd looked into the IPS thing Retrohacker mentioned. It sounds just "dumb" enough to work for my needs. I can supply a checksum for the INITIAL (original) file to which the patch(es) are to be applied. But once someone applys the first one, then they're on their own. My only issue with it is that the patch files are binary, not ASCII :/ (ascii would make it easier for me to seperate them out into different patch files).
 
I can supply a checksum for the INITIAL (original) file to which the patch(es) are to be applied.

That's really the important bit. I guess such a thing doesn't need to be handled within the patching utility, but there does need to be some sanity checking somewhere (even if it's manual) to verify that the input file is the correct one.

It's frustrating when attempting to apply translation patches to console game ROMs, since there are invariably two or three (or more) different versions of the file - and for the Super Nintendo, ROM files can exist both with and without headers for the emulator. Since the authors of many IPS patches never bother to tell you what version of the ROM you need to patch, it becomes an annoying experience trying to get the patch to work. I always felt that IPS should have supported a checksum, to do a sanity check before patching - so at least you know you're starting with the correct thing.

But you're right - you don't want something to prevent you from patching, such as in your case, with multiple patches to do different things. Just, a little hint that I'm starting with the right data would be nice...

-Ian
 
Then i would do something along this line:

I:C:MD5SUM:p0
I:C:MD5SUM:p1
I:C:MD5SUM:p2
I : D ::p3
P0:T:patching XYZ Version of Game....
P0:p:0010:02
P0:p:0020:02
P0:p:0030:03
P1:T:patching XYZ with Header Offset.
P1:p:0020:02
P1:p:0030:02
P1:p:0040:03
P2:T:patching Freeplay Version of Rom
P2:p:0020:02
P2:p:0030:03
P2:p:0040:03
P3:T:Unknown Input, Using Stock Patch, Results may very. Contact [email protected]
P3:p:0010:02
P3:p:0020:02
P3:p:0030:03
E:T:Thank you for using XYZ Game Hack.
 
I:C = Input Check MD5SUM, do PX
I: D = Default if Above no match
PX:T: Display a text message, X = Patch #
PX: P:Offset:NewValue, P = Patch
E:T: End, Display Message

Could add a
PX:C:0193:00:90 if, Value = 00 @ 0193, replace with 90
PX:C:0193:01:80 if, Value = 01 @ 0193, replace with 80
 
Hamster:
That all looks great, I like the patch format and control features...

...but that doesn't look at all like what bsdiff.exe generated when I ran it.
I got a binary patch file, not a text-based list like you describe.

I looked at the documentation and -help, but I didn't see any option to change it. What am I missing?
 
Hamster:
That all looks great, I like the patch format and control features...

...but that doesn't look at all like what bsdiff.exe generated when I ran it.
I got a binary patch file, not a text-based list like you describe.

I looked at the documentation and -help, but I didn't see any option to change it. What am I missing?

yeah, gonna have to write one to do what i posted...

there is no such beast...., i could write one up, as i am a C#/VB.Net/GNU C programmer, however, my free time is close to nil.
 
Back
Top Bottom