ZappR ROM-hacking utility

You can talk about almost anything that you want to on this board.

Moderator: Moderators

Post Reply
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

ZappR ROM-hacking utility

Post by oRBIT2002 »

I've decided to release my own utility to help me in my ROM-hacking efforts. It's a commandline-tool (for Windows) that parses a textfile that describes how to patch a file. It has saved me many hours of editing instead of using a hex-editor and makes life alot easier if things starts to go wrong.
An example script could look like this:

Code: Select all

poke #$20,$5a73
poke #$23,$5a74
poke #$a9,$5a75
poke #$ea,$5a76

poke #$12,$6

incbin "Mariobros.bin",$2930
All addresses are file-offsets. The incbin-at the end includes my own compiled code at that specific location.
The parser is pretty strict at the moment (mostly due to my laziness) but it'll get the job done..
There's a basic set of instructions implemented, but of course, there's always room for improvement.
The fileformat isn't really suitable for distribution (like .ips) but more for internal development.
If you're interested, it can be download from my website: http://nes.goondocks.se
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ZappR ROM-hacking utility

Post by rainwarrior »

I like this, though IPS remains pretty firmly entrenched, I'd love to see a better patch format take root. Maybe you just think of it a tool for assisting hacking, but it looks like a good patch format definition to me too.

Here's some thoughts:
  • I like that it has optional CRC validation. Is there a method for having it read/display a CRC for you during testing? (Otherwise how do we know what CRC to put in?)
  • Maybe a ranged CRC would be useful too, e.g. a CRC that ignore the header (which could have bad bytes or corruption), or only checks the CHR, or only one bank, or ignores a minor variation between otherwise compatible ROMs, etc.
  • I like that it's text for writing the patch script, but it would be nice after testing it if it could "compile" to a compact binary patch format. Sort of an interpreted vs compiled idea.
  • The documentation for INCBIN says "inserts" but I would guess from the comment that it actually overwrites?
  • I like that the COPY operation helps us move things around, so we can avoid storing extra data, but also because we can avoid the patch itself being a copyright violation if it needs to move data around.
  • A second step towards copyright avoidance might be to make POKE and INCBIN optionally operate as XOR operations instead of simply overwriting, requiring the original file to recover any data from the patch. (This could be enabled by a command line flag for the "compile" operation suggested above.)
  • Open source? Maybe not necessary since the format definition is so simple that recreating the tool is probably easy.
  • Maybe an equivalent to POKE but for longer strings of hex numbers? It seems weird that it's either 1 byte or has to be in another file.
  • Secondary to that, maybe also an ASCII that places an ASCII string at a location would be useful too? Though this might incur a need to parse escape codes for special characters too... could be annoyingly complicated.
  • Are the # prefixes necessary?
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: ZappR ROM-hacking utility

Post by oRBIT2002 »

@Rainwarrior: You have alot of interesting ideas, I've thought of a few of them aswell.

The CRC option doesn't currently makes much sense at the moment. However, I have been thinking of "compiling" the patches to a binary format (as you mentioned aswell) for distribution purposes. Then, a CRC option would make MUCH sense, since people couldn't apply patches to the wrong ROM.
The documentation for INCBIN says "inserts" but I would guess from the comment that it actually overwrites?
Yes you're right. I'll update the documentation later.
Are the # prefixes necessary?
Yep at the moment.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: ZappR ROM-hacking utility

Post by calima »

Ha, I made a similar thing when I needed to hex-edit something and couldn't be arsed to install a hex editor.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: ZappR ROM-hacking utility

Post by 3gengames »

I think hacking a script to run Git would be much better and efficient in every way.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: ZappR ROM-hacking utility

Post by lidnariq »

... git is explicitly not designed for dealing with binaries, and also deals poorly with inserting/deleting lines in a hexdumped form of a binary.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: ZappR ROM-hacking utility

Post by 3gengames »

True, didn't even think of that. But still, custom formats....the worst of all. Wasn't there something to do with git and large binaries of data? I see git lfs for binaries in bitbucket.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: ZappR ROM-hacking utility

Post by lidnariq »

Still doesn't do diffs. Git's big advantage over other things is storing things as a DAG of text diffs; neither is appropriate to this situation.

You could rebuild git to use some kind of binary diff tool on binary data, but that's really only relevant if you're trying to preserve history, which isn't necessarily useful here.
User avatar
gauauu
Posts: 779
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: ZappR ROM-hacking utility

Post by gauauu »

I keep thinking it would be cool if your format could optionally "compile" into the standard IPS patch format.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: ZappR ROM-hacking utility

Post by oRBIT2002 »

I am almost done writing a primitive compiler that compiles these "scripts" to a binary format, but it's not IPS. My format comes with a few additional features that comes with atleast a very handy feature, CRC32-checking. People can't patch the wrong ROM anymore and bother you with e-mails like "your patch doesn't work" (well, I've got a few of those anyway :)).
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ZappR ROM-hacking utility

Post by rainwarrior »

Well, if it can patch a ROM, you can make an IPS from the patched ROM anyway. That's easy to do with existing tools, would just be a convenience measure I guess.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: ZappR ROM-hacking utility

Post by oRBIT2002 »

A screenshot of my Work-in-progress. Everything in this image is embedded in the (compiled) patchfile itself (everything is optional of course). Time will tell if it gets finished and people will find it interesting enough to use it. :)
Attachments
patch.png
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: ZappR ROM-hacking utility

Post by oRBIT2002 »

I've finally released my "ZappR Toolkit" on my website. It can compile your patches to a binary format (.ZPC) but also, of course, load & apply patches. This is a work-in-progress alpha-version but if you're a Windows-user (with .NET 3.5 installed) feel free to check it out.
There's also another tool available on my website, simply named "ZappR" that is preferable used during patch-development. It's a commandline-tool for reading a patchfile (.ZRC) and apply it to your target.
My latest patch ("Mario Bros classic highscore savepatch v1.5") also comes with a .ZPC file if you guys want to check it out how it works.
It's all on http://nes.goondocks.se
Post Reply