This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

A tool to check free ROM space?

A tool to check free ROM space?
by on (#88127)
Is there a tool that allows to see how much of ROM space is 'non-empty' (long sequences of $00 or $cd or $ff, configurable), in a single screen graphics representation? Like set of rectangles for ROM pages filled with empty and non-empty colors.

Such a tool would be handy, because when you write in C, you don't really know how much of space is used. So far I used hex editor, but it isn't very comfortable.

I can make such a tool, of course, but maybe there is something suitable already.

by on (#88132)
Assuming the "empty" value of your rom is known, and always the same:

From available tools, my first thought would to use Beyond Compare and hex compare your rom with a file filled with your "empty" character of the same size. (Create a 40 KB file filled with FFs and compare it with your 40 KB rom) If you set alignment to none, it's actually a pretty nice color coded representation of how much space you have.

The parts that are the same in the files (they're white) is how much free space you have. You can even get the number of same and difference bytes, so it's easy to divide for a percentage.

But that's overkill, not free software. I'm sure there are free programs that compare files you could use for this method.

But I'd write a tool for it if I were you. Probably easier than trying to interpret comparisons of apples (your rom) and oranges (an FF padded file.)

by on (#88135)
I'd just look at the PRG in YY-CHR.

by on (#88136)
I thought about using a CHR editor, but that would be the same as a hex editor - you have to scroll through the file to see empty space.

by on (#88138)
Here's what my method looks like, just for the record: ... ompare.png

(The orphaned bytes, is because I made the blank file the wrong size.)

I realize I've "advertised" beyond compare a lot lately, but I just really like the program. :D

by on (#88139)
If you use CA65, this info is IIRC (kind of) available in the MAP file that can be output by the linker. You could write a very simple tool to parse that to get the available space from total space minus the size of the code segment.

by on (#88140)
Free space can be hard to determine. Some games will make it obvious usually by holding FFs. But in other cases random data values or data values from source files or other binary data is duplicated into unused areas. Ninja Gaiden has an earlier version of the script in one of the unused banks. Final Fight 3 the chinese original for Famicom has bits of source code.

Another thing to consider is some games retain data and code for features no longer in the game and that space can be reclaimed if you need it for something.

by on (#88145)
My question is not related to existing games.

by on (#88155)
If by "C" you mean cc65, I second thefox's suggestion of using the map file that ld65 produces. But that won't help with wasted space due to padding inserted by .align.

I could write a tool in Python that draws the bytes of the ROM onto a Morton Z-curve, making it easy to see where the big runs of $00 or $FF are. But as MottZilla pointed out, that still wouldn't find dummied-out elements.

Perhaps the final solution is to play the game thoroughly in FCEUX to generate a .cdl file, which tells which bytes of PRG ROM have been accessed, and then render that as a Z-curve.

by on (#88157)
I need a program to shorten 20-30 seconds long process (with hex editor) to like 5 seconds (with a tool I'm asking about), to make space check quickier through eliminating need of scrolling down to the empty space. Playing the game thoroughly certainly won't help me with this.

OK, thanks for the answers, I get the idea.