What is it?
Raw2CHR is a small program that creates NES Character-ROM data from a raw binary picture. This is useful for NES demo or game coders on the Amiga (or other computers) who wish to convert their graphics
into a format usable in their NES program. Before making this program, if I wanted to import a graphic into an NES CHR-ROM, I would have to copy the image over to my Macintosh, save it as a PICT, then load it up in a buggy and slow program on the Mac, bring it back over to the Amiga, then chop off the CHR data from my NES demo. What a pain in the butt, I can tell you! I won't even get into what I had to do to convert my images into a 128x256-pixel image which that Mac "program" required of me.
I made this program because I wanted to speed up the time spent making graphics for the NES, and because Lennart still hasn't gotten around to implementing IFF importation into GoldNESt!! Hey, Lennart!!
Now all I have to do to make CHR-roms is save my graphics as a brush in my favourite Amiga program, convert it to a raw binary format, then run it through Raw2CHR. It really saves time!
At the command line, type in Raw2CHR infile outfile [-w]
The infile is the raw binary graphic that you want to convert to a CHR-ROM format. Several programs on different platforms can create this type of file for you. On the Amiga, a program called ArtPro is good. Here's how you should go about the process:
- Draw (or import) your graphics in a paint program. Make sure the graphics are 4 colours only (as that is the bit depth of the NES!!) and 256 or fewer pixels in width (as the NES' horizontal resolution is 256 pixels).
- Pick up a brush (or selection) of the entire image having a width of either 128 or 256 pixels, depending on whether the entire image will fit at most into 128 or 256 pixels. Don't worry if you're picking up a bunch
of empty space; you can compress that later. The height of the region that you pick up should be a multiple of 8. You should note that the size of one NES CHR-ROM bank is 8192 bytes, which translates into either a 256x128 or 128x256-pixel image. Any greater than that, and the remaining graphics will spill over into another bank.
- Save the image to disk, and load the image into a graphics conversion program. (I'll use ArtPro.) Now, save the image as a RAW file in BINARY format (ie, not as source or anything). The bitplanes must be chosen as being INTERLEAVED, not planar.
- Run Raw2CHR, specifying the raw data as the infile, and the CHR-ROM as the outfile. If you saved image as a 128-pixel-wide file, then you don't need to specify anything else. If your saved image is a full 256 pixels wide, then you need to specify the "-w" switch.
Raw2CHR should now have created a CHR-ROM file from your image. If your image was bigger than what would have fit into one CHR bank and you would like to compress the data, you can use my program, "CHARlie" to do so. Use the "-c" switch in CHARlie, and make several passes with it over the output files. The graphics data should then be compressed as much as possible into your CHR-ROM.
Here is an example of what Raw2CHR can do. The leftmost image is a brush that I saved in Deluxe Paint. It looks exactly the same after Raw2CHR converts it. The second image shows what the CHR-ROM would look like after CHARlie replaces redundant tiles with markers. Finally, the third image is the CHR-ROM after CHARlie has compressed the graphics, using the [-c] option. You can see that what was once an image spanning two CHR banks can now fit into half of one.
This program is just a small little utility, so I didn't spend (much) of a time (at all) coding it. As such, it is again in my favourite flavour of spaghetti-code. The C source code is included, if you want to improve on it at all.
Download Raw2CHR Amiga executable and C source code.
Download Raw2CHR MS-DOS executable. (Kindly provided by Fractal)