This Working NES ROM Has A Secret ZIP File Inside It

Image: Vi Grey

When's a NES ROM not a NES ROM? When it's a ZIP file. But it doesn't have to be one or the other; you can have your ROM and uh, eat it too? Coder Vi Grey created a completely valid ROM for the Nintendo Entertainment System that you can also unzip using your archiving application of choice.

To accomplish this feat, Grey took advantage of the fact that the iNES file format, used by ROMs, includes some padding between data sections that isn't interpreted by the console.

On the ZIP side, it's possible to mark data as a comment, which is also ignored (usually). With somewhere in both formats to store information without corrupting the other type of file, all Grey had to do was blend them together:

If we find enough padding space in the PRG data, we can just replace the padding data with the ZIP file. For this NES ROM, I counted padding bytes from the end of the PRG data until I had enough space to embed the ZIP file, then I made note of how far into the NES ROM I started embedding the ZIP file.

I then updated all of the offsets of the ZIP file data by adding how far into the NES ROM the ZIP file started. After that, I set the ZIP File Comment Length to be the size of the rest of the NES ROM data, which is the end of the PRG data and all of the CHR data.

As for the contents of the ZIP, it's the source code for the ROM... which you may have guessed by looking at the lead image.

So, what are the practical implications? Well, nothing really. But it's super interesting. If you'd like to look at the source code, Grey has made it available on GitHub.

This NES ROM is Also a ZIP File [Vi Grey, via Reddit]


Comments

    I was a little confused by this at first, but as I have mainly dealt with arcade roms and not console I did some looking.
    iNes isn't a rom file, its a container file for the individual roms, so he has put a zip in the container file which then adds the zip data to spare memory on the roms.
    It would work under iNes which would put it all back together properly while ripping it.
    but if you were to try rip the roms individual you'd just get junk data or even the rom would be corrupted.
    But still interesting.

Join the discussion!

Trending Stories Right Now