




|
xpm2bin
This is a spiffy little python program that turns xpm graphics into the binary format used by XGalaga (at least for the BeOS version). Below is basically the readme that is included with XGalaga: Hyperspace. My parsing algorithm works most of the time. I might make it more robust in the future, but it has served its original purpose, so I may not develop it further. We shall see.
Download
This script requires python which is also available on Bebits and lets you modify images in both XGalaga and XGalaga: Hyperspace. The below descriptions assumes xpm2bin is installed in XGalaga's images-orig directory, so put it there or make appropriate changes to the examples.
Readme -- Images for XGalaga: Hyperspace
Images of the form *.bin are found in the images directory. They are read directly by XGalaga at runtime. They must be of the correct form or strange things will happen. These images are generated from the images of the form *.xpm in the images-orig directory. Images in the images directory contain information about the number of animation frames. The aliens have 16 animation frames while the prizes, for example, are not animations and so have only one frame.
The script xpm2bin is capible of converting most of the graphics in images-orig to the format required for XGalaga. It is a work in progress be John Strickland who originally wrote it solely to create new prize graphics for the extra weapon upgrades available in XGalaga: Hyperspace. From there, it has become more flexible. It's parsing is not rigorous, but works for the majority of graphics in images-orig. The graghics that it can't convert can be fixed easily enough. etorp.xpm is a good example; it has extra data in fields after the last of the pixel data. This is not expected and causes xpm2bin to die. This is expected to be fixed before too long.
mvi moves all made up images of the form *.bin to the images directory. An example of modifying existing graphics would be to create all new prize graphics with the same names as the current ones. Then you could type this:
./xpm2bin pr*.xpm; mvi
Typing ./xpm2bin with no arguments will give a usage summary. If you happened to remake all of the alien graphics, you might type:
./xpm2bin -n 16 alien*.xpm; mvi
If you had done both of the above, you could combine the two commands:
./xpm2bin pr*.xpm -n 16 alien*.xpm; mvi
or
./xpm2bin -n 16 alien*.xpm -n 1 pr*.xpm; mvi
In the above examples, -n specifies the number of animation frames. Aliens have 16 frames while prizes have only one. Graphics with a .xpm extension are of the type X Pix Map. An image translator for this format is available on BeBits. This format is actually ASCII text and can be read and edited with an ordinary text editor. If you wanted to change the appearance or, say, alien1, you could simply type this:
vi alien1.xpm
You would find that there are fields specifying the x and y dimensions of the graphic, the number of colors used, and the number of characters pixels per. This last value must be one as far as XGalaga is concerned. Here is an example of such a field:
"20 320 7 1"
This graphic is 20 pixels wide by 320 high. Seven colors are defined, and the last value always needs to be 1. Below this, characters are mapped to specific colors. In our example, there are 7. Here they are:
"` c None",
"a c #900000",
"b c #C00000",
"c c #F0F000",
"d c #F00000",
"e c #A0A000",
"f c #606000",
None is a special value for transparency and must be capitalized, at least when using xpm2bin. The numeric values ar RGB values where one byte, or 2 Hex digits, is used for each of the three colors red, green, and blue. If you modify the number of colors defined in this list, you must change the value above representing the number of colors. For example, if you added a new definition to our example, then the 7 we talked about before would need to be changed to 8.
WARNING: There must be a color defined for each character in the ASCII graphics following the color definition. Here is an example of one frame from alien1.xpm:
"````````````````````",
"`````````fef````````",
"```````fef`fef``````",
"````````fcecf```````",
"`````````fcf````````",
"`````````fef````````",
"`````````fef````````",
"`````````fcf````````",
"`````````fcf````````",
"`````````ece````````",
"```````e`ece`e``````",
"``````fefcccfef`````",
"`````f`ceacaec`f````",
"`````ecfebebefce````",
"````fef`bbfbb`fef```",
"````fcf``ddd``fcf```",
"````ef`````````fe```",
"````f```````````f```",
"````````````````````",
"````````````````````",
If, for example, there were no definition for 'e' above, generation of the XGalaga graphics will not be successful.
Written December 6, 2001
John Strickland
I hope this information is useful, but of course, comes with no warranty; you didn't pay anything for it after all. Admittedly, the parsing of xpm graphics by xpm2bin is a hack but seems to work for the most part.
|