It is currently Mon Sep 25, 2017 1:36 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Sun Apr 09, 2017 10:41 pm 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 582
Location: Gothenburg/Sweden
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:
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

_________________
http://nes.goondocks.se/


Top
 Profile  
 
PostPosted: Sun Apr 09, 2017 11:08 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5650
Location: Canada
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?


Top
 Profile  
 
PostPosted: Mon Apr 10, 2017 1:22 am 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 582
Location: Gothenburg/Sweden
@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.

Quote:
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.
Quote:
Are the # prefixes necessary?

Yep at the moment.

_________________
http://nes.goondocks.se/


Top
 Profile  
 
PostPosted: Mon Apr 10, 2017 1:27 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 528
Ha, I made a similar thing when I needed to hex-edit something and couldn't be arsed to install a hex editor.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 10:51 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
I think hacking a script to run Git would be much better and efficient in every way.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 11:20 am 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6185
Location: Seattle
... git is explicitly not designed for dealing with binaries, and also deals poorly with inserting/deleting lines in a hexdumped form of a binary.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 11:48 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
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.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 12:10 pm 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6185
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 5:41 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 201
Location: Central Illinois, USA
I keep thinking it would be cool if your format could optionally "compile" into the standard IPS patch format.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Thu Apr 13, 2017 1:01 pm 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 582
Location: Gothenburg/Sweden
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 :)).

_________________
http://nes.goondocks.se/


Top
 Profile  
 
PostPosted: Thu Apr 13, 2017 1:11 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5650
Location: Canada
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.


Top
 Profile  
 
PostPosted: Sat Apr 15, 2017 12:29 pm 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 582
Location: Gothenburg/Sweden
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
patch.png [ 41.92 KiB | Viewed 943 times ]

_________________
http://nes.goondocks.se/
Top
 Profile  
 
PostPosted: Thu Apr 20, 2017 11:54 am 
Offline
User avatar

Joined: Sun Mar 19, 2006 3:06 am
Posts: 582
Location: Gothenburg/Sweden
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

_________________
http://nes.goondocks.se/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: tepples and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group