I am a fool when it comes to the PCXTool

hu, cd, scd, acd, supergrafx discussions.
Post Reply
HyperFighting
Posts: 6
Joined: Thu Jun 26, 2014 12:58 am

I am a fool when it comes to the PCXTool

Post by HyperFighting »

Hi Guys,

I have loved the Turbo since I was kid. I now have a flash cart and I have enjoyed the likes of Ninja Gaiden, Magical Chase, and Parasol Stars on my North American Turbo!
It's time to take it to the next level and make a game! I am not a total noob as I have some C coding experience.

I am able to compile with HuC no problem. I did however run into a major issue when loading a .pcx file generated from Adobe PhotoShop CS5.

The 32x32 .pcx appeared as a black box when testing the compiled code!
After some poking around I found the PCXTool.exe and figured hey I guess I need to use this nifty tool to get PCE graphics formatted properly for my game.

I used the pcxtool -dump GoodFile.pcx to compare against the results of using the same command on my bad file.
What I found is that on the bad file all of my palette entries where on the bottom (in the F zone like this is F----ing annoying!) and in the
good file all my palette entries where on the top starting at position $00.

I wrote this little .bat file to see what would happen when processing my lame .pcx file. that displays as a blackbox when I compile and run code that includes it.

pcxtool -swap $F0 $00 NewGraphic.pcx NewGraphic1.pcx
pcxtool -swap $F1 $01 NewGraphic1.pcx NewGraphic2.pcx
pcxtool -swap $F2 $02 NewGraphic2.pcx NewGraphic3.pcx
pcxtool -swap $F3 $03 NewGraphic3.pcx NewGraphic4.pcx
pcxtool -swap $F4 $04 NewGraphic4.pcx NewGraphic5.pcx
pcxtool -swap $F5 $05 NewGraphic5.pcx NewGraphic6.pcx
pcxtool -swap $F6 $06 NewGraphic6.pcx NewGraphic7.pcx
pcxtool -swap $F7 $07 NewGraphic7.pcx NewGraphic8.pcx
pcxtool -swap $F8 $08 NewGraphic8.pcx NewGraphic9.pcx
pcxtool -swap $F9 $09 NewGraphic9.pcx NewGraphic10.pcx
pcxtool -swap $FA $0A NewGraphic10.pcx NewGraphic11.pcx
pcxtool -swap $FB $0B NewGraphic11.pcx NewGraphic12.pcx
pcxtool -swap $FC $0C NewGraphic12.pcx NewGraphic13.pcx
pcxtool -swap $FD $0D NewGraphic13.pcx NewGraphic14.pcx
pcxtool -swap $FE $0E NewGraphic14.pcx NewGraphic15.pcx
pcxtool -swap $FF $0F NewGraphic15.pcx PceFormattedGraphic.pcx

Here's the thing upon compiling my code it was a bitter sweet victory the graphic loaded perfectly a little too perfectly! The background colour was still fully intact! Now my graphic has a pink box around it!

What I can say is that I did Index my sprite to 16 colors my knockout or background colour is the first entry in the palette. I noticed the references are still all at the bottom in the F zone (F for F--- so close yet so far)
even though my palette entries are placed correctly at the top of the file in the $00.


With the -pcepal -pcepal2 flags I haven't had any luck. I have performed tests with no positive results. Does anybody know what their purposes are in terms formatting graphics for display?

Most importantly if anybody could point in the right direction as to how to get my background colour knocked out when my image is displayed it would be much appreciated.


I have tried Gimp, Irfan View, YY-CHR and even looked for a version of Paint Brush for Win 3.1
Any useful graphics editors that export .pcx files in the right format for .PCE would also be greatly appreciated.

Thanks for your time!
HyperFighting
Posts: 6
Joined: Thu Jun 26, 2014 12:58 am

Re: I am a fool when it comes to the PCXTool

Post by HyperFighting »

Ok it all makes sense now. I was running Hugo in a very small window. When I enlarged the Hugo window I noticed there was transparency just in the wrong spot of the image.

1. If you are exporting a .pcx sprite from Photoshop CS5 (I just mention the app I used as a point of reference . I'm not sure all programs export .pcx files in the same format) Make sure it is indexed to 16 colours and that the knockout colour is the last colour in the palette.

2. Copy the graphic into the same directory as the PCXTool executable.

3. Change the name of the graphic to NewGraphic.pcx as the the .bat file is expecting it to be named this way. (Feel free to make the .bat file your own...I know it could be better for starts we could automatically get rid of all the damn files it makes all we need is the last one.)

4. Run the bat file I provided. Your new graphic should run on the PCE when compiled. Transparency and all. Just make sure the dimension of your graphics match what the HuC compiler is expecting EX: 32x32
User avatar
MooZ
Site Admin
Posts: 407
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: I am a fool when it comes to the PCXTool

Post by MooZ »

Here's what I'm doing. I open the image with Gimp. I then launch the colormap dialog (http://docs.gimp.org/en/gimp-indexed-pa ... ialog.html) and choose the "Rearrange Colormap" menu. I can drag and drop colors to the right palette entry (for example put the transparent to the first palette entry).
I've never used pcxtools.exe. Usually, I use the good old pcx2pce piece of code I wrote ages ago. It's raw and brutal and doesn't have all the nifty bits of incsprite and all.
HyperFighting
Posts: 6
Joined: Thu Jun 26, 2014 12:58 am

Re: I am a fool when it comes to the PCXTool

Post by HyperFighting »

Hey thanks a ton for the reply.... For ages I have wanted to rearrange palette entries! I never new such a tool existed!! This helps me out tremendously as these palette entries are pivotal in getting graphics formatted for old school game consoles. You don't even want to know what lame techniques I was using to get the entries in the order I wanted.

Also thanks very much for providing your app for converting PCX files to the PCE format. I tried it out but was unsure as to how to load the files into a Huc project are there any examples out there that show your Dat and Pal files loaded up in a C environment? Currently I am messing around in the vein of the obey brew tutorials. So far so good really hoping I can make a PCE game!
User avatar
MooZ
Site Admin
Posts: 407
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: I am a fool when it comes to the PCXTool

Post by MooZ »

The dat file can be included using a simple incbin. Unfortunately the pal file can't be directly used as it's not in pce format (333). Each component is 8 bits.
I'll update the code and put the binary somewhere...
Anyway if you want to convert the palette from rgb8 to brg3, you should replace the end of pcx2pce.c (line 126) to:

Code: Select all

/* Output palette */
    for(offset=0; offset<16*3; offset+=3)
    {
        uint8_t r, g, b, color[2];
        
        r = img.palette[offset  ] >> 5;
        g = img.palette[offset+1] >> 5;
        b = img.palette[offset+2] >> 5;
        
        color[0] = b | (r << 3) | (g << 6);
        color[1] = (g >> 2) & 1;
                
        fprintf( color, 1, 2, out );
    }
This way you could include the palette with a simple incbin and use raw copy to setup the palette.
HyperFighting
Posts: 6
Joined: Thu Jun 26, 2014 12:58 am

Re: I am a fool when it comes to the PCXTool

Post by HyperFighting »

I am sorry for the late reply I've been carried away with HuC and am having too much fun!

Thanks very much for the tips on how to import GFX using your app. Is the source code posted? I believe your link provides just a binary release.

Do you happen to know if #incspr inflates the graphic you are loading? I am assuming this command has more overhead than the method you suggested. I would love to know what kind of differences exist between the two methods and ultimately does your method allow for more graphics to be loaded into the finished game?

Currently I am having much success with #incspr :D but I will change my ways in the name of progress!
User avatar
MooZ
Site Admin
Posts: 407
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: I am a fool when it comes to the PCXTool

Post by MooZ »

If #incspr works for you, you'd better stick with it. You could easily end up spending all your time crafting your own tools.
#incspr does more as you specify the coordinates and size of the sprite. My tool is just a brutal "transcoder".
Post Reply