SNES Gfx Tools Part I

It’s been awhile again since I haven’t posted anything. I have made nice improvement in my code and now the ennemies are running and grabing the main character, make him loose energy. The player can escape from the hands by shaking left to right. I still need to implement the collision checking process so I can kick them out of the screen. So until then non new rom or source code release.Today I had a question from a reader regarding  the fx tools available on SNES. To say everything it’s not like there that much choice. There is mainly 2 dedicated tools that I use : Pcx2Snes and MappyWin32 with custom lua script to export to snes format. The latter is mainly used for the design of the level. Pcx2Snes is a tool that exists now for a very long time and that is working pretty good. It will do the gfx transformations for basics need. Here are some usage samples taken out of my current project :

Convert full screen in 16 color mode :

tools\Pcx2Snes.exe ressource/kungfu -n -c16 -screen

The -screen flag is for specifying that we want to convert to whole screen, so it will ouput a .pic file with optimised tiles and a .map file with the mapping of the full screen.  The -c option allow to tell how many color you want to use, in our case we want to convert a 16 color image. This flag can be set to 8, 16, 128 or 256 to match the different graphical modes that the Snes is allowing. The -n is for removing border detection.

Convert Sprite in 16 color with block size of 16×16 :

tools\Pcx2Snes.exe ressource/sprite -n -c16 -s32 -o16

You can notice the introduction of two new parameters the -s and the -o. The -s is spefifying block size that you want to use. For a basic background you should forget that parameter so it will use the default of 8 (or you can specify -s8). In my case since I’m converting gfx data for sprite usage i can specify with sprite block size I will use (32×32 here). Then the -o16 parameters is to specify to only ouput the 16 colors i need in the .clr file. Without specifying this parameter it will ouput a file with 256 color entries. I think you have now have all in hands to do all your basics gfx needs. If you still have problems don’t hesitate to let me comment with your problem, and if possible send the source code used to display your gfx (80% of the time it’s the code that is faulty).In one of my next I will expose how i use mappy with customs lua script to extract data of my levels since Pcx2Snes is not good for very large data (more than a screen or two in width).

See ya,

Lint

2 Responses to “SNES Gfx Tools Part I”

  1. Honza Says:

    Hi, allow me to add some other info. This is for creating backgrounds, not sprites.
    Parameters:
    -o this parameter specifies, how big palette will be written to .clr file. It has no checks, so if your final converted image needs more colors than you specified, it will truncate the palette file (my image needs 59 colors, but I specified only 20, so only first 20 colors from 59 will be written to .clr). This can cause some color corruption, because SNES only know start of palette and if you only have 20 colors than SNES will read 39*2 bytes after end of palette as palette, but it can be anything.
    Overall, just make sure you have specified big palette to store all necessary colors.

    -r all important switch. Unless you enable this, nice BGs are just a dream. BG consists from 8×8 (in most cases) blocks, map that for every square of BG specifies block and palette. If -r is not enabled, map will say that every block uses palette 0 -> max 16 colors for whole image.

    I am not in the mood to write long articles, so few examples will do.

    Pcx2Snes.exe -r -n -c16 -s8 -o256 -screen my_bg

    take my_bg.pcx, find out closest permited size of BG (we can have variout combination of {32,64}x{32, 64} blocks, every block is 8×8 (thanks to-s8)). Disregard borders. Divide image to 8×8 blocks and for every block find out palette in the block.

    If one 8×8 block (they are aligned by 8 of course) in the my_bg have more than 16 colors (-c16), print error message and ends.

    Now we have one palette for every block. Try to consolidate (=if two blocks have same palette, they will use same palette).

    After consolidation, we have divided our image to 8×8 blocks and we have few (hopefully) 16 color palettes. That is enough to write our blocks (.pic), map (.map) and palette (.clr). Again, make sure output palette (-oXX) is big enough.

    Source and .smc file for testing and fun: http://www.mediafire.com/download.php?g4myz4gm4wz

  2. lint Says:

    Thanks a lot for the precision about the -r flag, I wasn’t aware of all that. Now it also depends witch graphic mode you are going to use, and how many colors you have. About -o I assume that you know how many colors your image have so launch pcx2snes with the right parameters.

    See ya, Lint