cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
891 stars 114 forks source link

Decode graphics files #91

Closed cxong closed 9 years ago

cxong commented 11 years ago

The graphics in C-Dogs are paletted and stored in some custom-made binary format, detailed in grafx.c. See if a WritePics() function can be made to dump out the pictures in some convenient format (such as bmp).

The format seems to be (element / type)

ghost commented 11 years ago

Are you also planing to convert the level files into a more modern file format (like JSON)?

cxong commented 11 years ago

@sauer2 I assume you're talking about the graphics files (otherwise you asked the same question in another issue)? I plan to use plain image files in the future, which are much easier to work with.

ghost commented 11 years ago

No, I mean the cpn files. Do plan to convert them also in future?

cxong commented 11 years ago

@sauer2 Hard to say and there are no concrete plans yet.

I'd guess that it's much harder to extending the existing editor with new functions than go with a new format entirely.

cxong commented 11 years ago

Decoding the image files is easy, but making the game use normal image files is hard. The current image files use palettes, which is no problem but the game makes extensive use of palettes - menu highlights uses a red palette, flame weapon switches to a flame palette, confusion bomb uses a purple palette and so on. These would all have to be converted in one go.

cxong commented 11 years ago

Decoding the graphics files makes sense if we want to:

But neither of those are necessary. There's another option, and that's to make the graphics loading/drawing generic, and support both old and new methods. Therefore this task is not necessary. With the RGB blitting changes (#129), it is already possible to draw plain RGB images.

ghost commented 11 years ago

I know it's all easier said than done. However, what is about external level and campain editors? Wouldn't it be helpful to have the graphics as png?

cxong commented 11 years ago

@sauer2 Thanks for mentioning; I completely forgot about using graphics in editors, so I'll leave this open again.

As you said it's not as easy as it seems; the graphics files store the "textures" of walls/floors etc. but you can choose one of many colours, so it's not as easy as converting each coloured pattern to a file, because you'll get thousands of image files, and you'll need new files every time you want a different colour. It depends on the editor really; best case the graphics loading code can be included as a plugin, which means no need to convert the graphics files anyway.

ghost commented 11 years ago

Would a grayscale export be an option or is it even more than that?

cxong commented 11 years ago

@sauer2 that would be the idea yes; the graphics aren't quite greyscale though, there's a bit more work involved in reverse-engineering what it's doing right now, and to change the palette-swap code with colour mixing.

cxong commented 9 years ago

Superceded by https://github.com/cxong/RonnyWesterPics Plus some investigation in https://github.com/cxong/cdogs-sdl/issues/359