Page 1 of 2
PCX Palette Converter to SNES (C & C#)
Posted: Sat Jan 03, 2015 7:26 pm
by nicklausw
I made a small program in C# that can convert palette data from a PCX file to SNES data. It's nothing too crazy special, and there are some improvements to be made, but I figure I get some feedback from you guys about it. Well, counting on the fact that all of you have the .NET framework or whatever.
The only real up-side about it is that it automatically puts files with .asm or .s extensions in .db format. Let's not get too pessimistic, though.
Included is a tar file with the Visual Studio solution, although as far as I'm aware the code is safe for MonoDevelop cross-platform users.
As said, feedback is appreciated, and enjoy.
UPDATE!
I learned a few techniques with C while working on a little program of mine which will not be disclosed

. Decided in the process that I'd go ahead and try a conversion of pcx_pal2snes over to C.
All that I've yet to implement is the .db feature. Other than that it seems to have worked, so try it if you like. It's under pcx_pal2snesc.tar.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 9:04 pm
by Drew Sebastino
I don't know if you want anyone posting here, (Ill delete my post if so) but I am wondering if your program supports .gpl files. (Gimp color palettes.) If not, would you consider adding them in the future? I namely use pcx2snes for palettes because it creates a palette that goes with the graphics, but I could definitely see myself using something like this for creating palette swaps. By the way, is this a command line based tool and is there any assembly required?
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 9:08 pm
by nicklausw
Espozo wrote:I don't know if you want anyone posting here, (Ill delete my post if so) but I am wondering if your program supports .gpl files. (Gimp color palettes.) If not, would you consider adding them in the future? I namely use pcx2snes for palettes because it creates a palette that goes with the graphics, but I could definitely see myself using something like this for creating palette swaps. By the way, is this a command line based tool and is there any assembly required?
Hehe, of course I want people posting here. Always want to hear what people think.
Anyway, it doesn't currently support gpl's. Guess I'll look into it. The program is run through command line, but I can make a tiny little interface for it if you want. Not sure what you mean by assembly being required. Far as I know, a SNES C compiler would probably support the palette, though exporting into C isn't implemented as of yet.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 9:34 pm
by Drew Sebastino
nicklausw wrote:The program is run through command line, but I can make a tiny little interface for it if you want.
I don't mind using the command line, as you have to use it for pcx2snes anyway. (Frankly, I'm really not sure why I asked.)
nicklausw wrote:Not sure what you mean by assembly being required.
There are some programs (like WLA DX) that have a bunch of .bin files and the like but don't have any .bat or any .exe files. I've been told you're somehow supposed to turn those files into an .exe file or something through some program, but I just didn't bother and got the program through a different website.
nicklausw wrote:Far as I know, a SNES C compiler would probably support the palette, though exporting into C isn't implemented as of yet.
I'm not sure how different C is, (I'm guessing does not accept .db?) but I really wouldn't stress about making it C compatible because most of the people use ASM on this website (and on the SNES, in general) because it is more efficient.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 10:42 pm
by nicklausw
Hm...seems I've found a bug in my own program.
The palette is converted correctly, but sprites are shown as pitch black for some reason in Neviksti's examples. Looks like I've got stuff to look into.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 10:50 pm
by Drew Sebastino
nicklausw wrote:Hm...seems I've found a bug in my own program.
The palette is converted correctly, but sprites are shown as pitch black for some reason in Neviksti's examples. Looks like I've got stuff to look into.
What examples? Also, How would the palettes be correct If they aren't? Does the program just spit out a .asm or a .s file with a blank table? It honestly sounds like there's just something wrong with Neviksti's CGRAM upload routine.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 11:03 pm
by nicklausw
Neviksti had examples for pcx2snes, and I replaced the palette file of one of the backgrounds with one made by pcx_pal2snes. The background looked the exact same but the sprites on the screen were pitch black. So I did the same to the sprite palette to no avail. There wasn't much difference in the files, though.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 11:09 pm
by Drew Sebastino
Could I possibly see the file you are trying to put the new palettes in along with the palettes? It sounds like there is a problem with the code you are using more than the program.
Re: PCX Palette Converter to SNES (C#)
Posted: Sat Jan 03, 2015 11:15 pm
by nicklausw
walker.asm is what's causing problems.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 12:07 am
by Drew Sebastino
I fixed it. I don't think there was anything wrong with the palette the program output, but I think it had to do with the way the palettes were uploaded to CGRAM. I replaced the "LoadGraphics" code with something much more usefull and changed a couple of things around to accommodate it and it works fine. Let me explain the new code. If you notice, after "LoadPallete" in Walker, there should be two new numbers; the first one saying where you want to upload the data, and the second saying how many colors you are uploading. Next, you will notice that "LoadBlockToVram" now has three words (2 bytes) instead of two. The third word controls where in the picture you have are you starting at.
Here's the download:
Give credit to bazz for making the "LoadPallete" code much more versatile and I added the small new offset feature on the "LoadBlockToVram" code.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 12:17 am
by nicklausw
Sweeeeet. So the program does work correctly, then. I have plans to make pcx_til2snes (tiles) and pcx_tlm2snes (tilemap) as well, which will probably be more difficult.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 12:37 am
by bazz
Espozo wrote:
Give credit to bazz for making the "LoadPallete" code much more versatile and I added the small new offset feature on the "LoadBlockToVram" code.
Thanks Espozo :3 And nice new offset feature
Btw, why are we still using PCX? Is there a more convenient format for us like GIF?? I understand indexed palette is the thing to go for, but PCX man.. I always had trouble with those files. Espesh on Mac OS X.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 12:41 am
by nicklausw
bazz wrote:Espozo wrote:
Give credit to bazz for making the "LoadPallete" code much more versatile and I added the small new offset feature on the "LoadBlockToVram" code.
Thanks Espozo :3 And nice new offset feature
Btw, why are we still using PCX? Is there a more convenient format for us like GIF?? I understand indexed palette is the thing to go for, but PCX man.. I always had trouble with those files. Espesh on Mac OS X.
I had been looking for a library that can convert other image types to pcx and let the program work from there but found none that weren't gigantic. It's just the easiest format to use.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 12:48 pm
by ARM9
snesgrit supports png.
Re: PCX Palette Converter to SNES (C#)
Posted: Sun Jan 04, 2015 1:42 pm
by lidnariq
GIFs internally contain the uncompressed palette (
https://en.wikipedia.org/wiki/GIF#Example_GIF_file )