Projects status update

Recently I had some time to work on my several ongoing projects. Unfortunatelly I have failed my exams, but I did it by my own will, so I don’t have any regrets because of it. I guess I’m still not ready to devote all my time towards studying something that’s not my primary interest right now. I like physics, but I hate theoretical basics and learning theory just for learning it. I must have practical applications of things I am learning or I’m getting bored quickly. But because of this fact I had more time to work on my projects. There are two business projects that I’m currently continuing. One of them is my CMS which is getting pretty advanced, because the deadline set by the client is coming fast. It’s been in development for almost a year now. I’m finally getting towards finishing framework. For the last two weeks I’ve been working on marker component of the plugin system. The only two things left in it is layout and article analysis for finding markers and then running function associated with each marker. That will be the end of Plugin Manager system. Then I’ll have to rewrite some static layout functions to dynamic plugins using the plugin system and perhaps write a Composing Manager, but it’s not a priority. With Plugin Manager finished I will be able to fix currently broken permission system. This will complete the functional framework upon which I’ll build a workable administration system plugin. This part would require writing functions associated with saving in the Storage Manager (virtual filesystem). I’m very happy because most of the hard work is already behind me and CMS is nearing it’s completion with basic facilities that will be able to handle critical operations. From then on I’d improve functionality by simply writing new plugins.

In the meantime I was approached by a client to create a simple website for him. He was not willing to pay much, so I’ve decided not to go my usual route to approach my friend who is the graphic artist and webdesigner, and ask him to create a layout for me. I decided to do it myself. In the past I did few sites, but I’m not really an artist so my productions are somewhat unprofessional, but they’re not very bad either. It was also good time to learn Inkscape and fully vectorised layout as opposed to earlier raster-edited ones. I have to admit that for the first play with Inkscape the website is not bad. Creating graphics was one thing, but creating XHTML and CSS code for this layout is NOT such an obvious thing. Many thanks to my friend who helped me a bit. I’m still learning CSS, so I’m not very familiar with this technology. Of course the CSS Zen Garden is quite helpful when it goes to understanding advanced styles. Besides that I have to write a PHP script that will allow to place orders. It’s quite simple and doesn’t involve any kind of shopping solution or paying via internet. This project is a little distracting, but I’m in great need for cash, so every coin counts.

You could think that I had a bit of work lately, but honestly said it wasn’t too much. 🙂 Because I’m not attending to University anymore, I have found the time to spend it doing some other things, playing and coding MOO2 Graphics Viewer. And this is the primary reason for this post. I have abandoned working on the GUI for now and went towards writing some functionality functions. Hang on your chairs ladies and gents. The Graphic class currently allows TO SAVE images! That’s right! You read it correctly. I’m currently able to save images achieving almost 100% compatibility with original graphics from Master Of Orion 2. 😀 The only thing that is left is saving internal palette within the image, which is very simple thing to do and this will be the end of fully functional graphic class. However writing this functionality wasn’t simple reverse process from loading functions. To achieve compatibility with original graphic files I had to do some additional reverse engineering on the format, because of the way frames within the image are saved. It’s linked with format reading specific that is used within Master Of Orion 2. I had to write additional python scripts to do some calculations on the offsets to see what’s going on, because this format reading specific wasn’t at all obvious to me at first. I had almost working saving function yesterday, but due to my stupid error I was stuck for a day searching for the problem. It turned out to be really simple thing that I ommited by accident. But now it works for 100%. Stay on your toes because graphically modding Master Of Orion 2 is really close right now. I don’t have any screenshots for you today, because it’s only saving functionality that doesn’t have any editing capabilities. To have a fully functional editor is not my goal.

I’ve been browsing graphic files and checking them for any anomalies and this is what I have found so far. Some of the files doesn’t use any external palettes stored within fonts.lbx and ifonts.lbx archives. However these files contain mouse cursors, besides the palette, and at least one of the files contains fonts. As for the graphic files. I have indicated earlier the council.lbx archive has internal palette of the first file that is used by most of the graphics from this archive. But that’s not all. I was able to see that most of the files doesn’t really use external palettes. For example. Planets.lbx that has planet graphics on colony screen they all have internal palettes, but not 256 colors! It’s quite obvious those palettes are merged with others. Also some external palettes have purposely left some of the colors out, i.e. they have many occurences of the same color. I’m assuming these are the “places” where merged palette goes in. It’s quite intelligent in fact, because for example ships.lbx has few graphics that are 1x1pixel size and doesn’t represent anything. But they’re interesting from the palette perspective. Those files are simply palette holders that are used to recolor the ships!

And this is one of the main purposes I’m not releasing the code now. I was working on implementing simple XML format to catalogue those dependencies that would be portable to other applications that I hope will begin to popup after releasing MOO2 Graphics Viewer code to the public. And I’ll encourage everybody to use it. The next thing I want to code in the viewer would be the Converter class. It will allow converting BMP or GIF files to native MOO2 graphics format. However the converter class would be quite hard to use alone, without knowing which palette is used for what image and that’s why I’m again delaying publishing the code to the public, before I have fully working and usable package that in fact could be used by non-programmers. Also there’s obvious need for palette export/import into a format readable by graphic programs. I’m not aiming at creating fully functional editor mind you. Main purpose of the program is still viewing Master Of Orion 2 graphics, but I want to include packing/depacking LBX archives (already done), saving/loading graphics (done) and finally importing/exporting images to/from BMP or GIF files (to be done). Before that I’m not really ready to publish it. I’ll try to get it done as fast as possible, but I’m not making any promises.

Posted in Coding, Master Of Orion 2 | 1 Comment

Various changes

Wireless sucks. Especially when the ISP doesn’t have adequate transmitters in wifi-overcrowded city. There’s always very high packet loss, the link is very unstable despite the fact that it’s fast (of course when it’s working). For a few days I had over 80% packet loss. I’m really fed up with asking my provider to fix this, playing cat&mouse all the time. For personal use I can make a sacrifice for a moment or two, but constant link failures make me sick. They cannot fix this for half a year. *VERY* professional. ;P

Anyway. This contributed to my decision to move the server out of my home to another location that is connected with Internet via landline ethernet. I’ve bought new network switch and UPS, then installed the infrastructure and the server at new location. It was supposed to be a quick switch, but as Murphy laws dictate it wasn’t. After initial server startup at a new location I’ve encountered serious problems with one of the harddrives. You can imagine what I felt when I saw that the datastorage drive was damaged. This machine is rather cheap, noname computer, constructed from various pieces of junk that I have in my home. It’s far from being professional 3k$ branded server. However it turned out to be just overheating northbridge caused by failed cooling fan. To replace this fan I had to remove half of the server components. Oh well. I’ve encountered also another problem. IDE connector cables were worn-out so I had to replace them also. From the planned one hour outage it was made few hours longer. After finally getting server to work I have plugged it to my brand new network switch and connected it’s uplink to 100Mbit/s Ethernet port going to ISP’s router. Initial bandwidth tests showed that within normal working hours the uplink averages 6Mbit/s within the Europe, 4.5Mbit/s to Washington DC, 2.5Mbit/s to Los Angeles and around 1Mbit/s to Hong Kong. Not bad. I have installed monitoring software on the server to plot graphs showing average resource and bandwidth utilisation. It seems that I have much spare bandwidth currently, because the server is very lowly utilised. And that’s good. Hopefully steps I have taken will contribute to better accessibility and there should be much less problems with it.

Besides that I’ve got some time to code MOO2 Graphics Viewer. I’ve written usable and operational ViewBox widget class for showing graphics in QT. Then I made some corrections within the graphics class itself and created preliminary user interface using QTDesigner. I’ve made a code cleanup getting rid of some deprecated functions and finally got rid of Tkinter calls. The overall result is quite nice. Also I have taken a closer look at some graphic and palette files. I’m beginning to understand that some of the palette files in fact are a little more than that, because they seem to have for example mouse cursors within themselves. Also taking a closer look at council.lbx file it seems that internal palette of the first image within the first file in the archive seems to be used in other images from this archive. This certainly needs some additional code to use this palette for other images. Because of these facts I’m not really ready to release the code now, but I’m certainly coming closer towards it. And as always. I have some eyecandy for you.

moogfxview1.png moogfxview2.png moogfxview3.png moogfxview4.png moogfxview5.png moogfxview6.png moogfxview7.png moogfxview8.png moogfxview9.png

As you can see the viewer has the beginning of the usable user interface. On the left there is a tabbed toolbox which currently has three tabs: LBX, Info and Palette. LBX currently is a browsing mechanism for files. Info tab gives you information regarding viewied graphic. It shows the size, number of frames within the image data, flags and in future will allow for some more things. The last tab which is designated Palette is used for changing palettes. It has a palettebox widget that shows the palette and the list of palettes from the files. However if the image has internal palette the palette box shows internal palette instead. Currently you can’t change the palette of the image if it has internal one. In future versions that will change. Also currently you have to depack LBX files manually. My goal is that you could specify just the directory where LBX files reside and application will take care of extracting LBX files by itself and then populate list of graphics and palettes including internal ones. There’s no way to change frame if the graphic has multiple frames. Also there’s a problem with the viewer box. I have encountered that for large graphics the loading is quite slow. When I first wrote graphic drawing routines I was aiming for showing transparency areas within the image. However I was quite disappointed by the drawing speed when resizing the widget. So I had to generate a memorized pixmap of the image and then bit blit it on the widget canvas. The drawing speed improved, but the transparency was lost because it seems that in QT version 3 QPixmap in the PyQT toolkit does not have alpha channel! I’ve been trying to get around this problem, but it seems it’s hopeless for now. So I’ve decided to leave it that way for now. I’ll try to install newer QT version 4 and PyQT4 to get this working, but for now it has to be that way.

I was thinking about releasing the code now, but I have decided not to. Why? Because the program has few bugs right now and it’s not complete. I want to finish essential functionality and fix the issues mentioned in the previous paragraph. Then I’ll be ready. It’s like with this artist that doesn’t show his painting before he finishes it. I hope you’ll understand. Also. Please do comment on the screens. Perhaps you have some ideas about usability, maybe you’d like to see some additional functionality or you’d like just to post some constructive critique. All comments regarding these things are welcome.

Posted in Coding, General, Master Of Orion 2 | 1 Comment

MOO2 Graphics Viewer development update

As I have said the last time it wouldn’t be long before I’d show some eyecandy for those of you waiting for it. But before I’ll give you some screenshots let me tell you something about development. First of all I thought this update would be sooner, but several bad things ™ have occured and I wasn’t able to do it any faster. You may have experienced several server outages trying to reach this page in the last few days. As I have said in the comment for the last post, the server is at my home and I only have wireless radio link. There were quite nasty winds here for the past few days and my microwave antenna isn’t very stable, unfortunatelly, when the wind speeds are reaching over 70 km/h with top speeds over 120 km/h. This contributed to high packet loss over my wireless link. Besides this also caused one day of network outage, because the receiver antenna at the ISP has fallen down. However the winds have passed and so did the problems with my internet link. Hopefully this will cause no more problems.

Another thing was with the development itself. I have written several helper classes in Python including… LBX decompression and COMPRESSION routines! Tada! They’re fully working. I have depacked several MOO2 LBX files and decompression is flawless. After this I have used my compression routines to create almost identical LBX archives as the originals from unpacked files. I have said almost because the difference is with the junk bytes. Normal LBX archives have junk bytes from memory dump within the file position offset space. I’m simply filling this remaining space after legitimate offsets with zeroed bytes until 800h offset where the first file resides. This shouldn’t cause any problems for MOO2 when reading such LBX archive, because those junk bytes are ignored by MOO2.

However after writing those routines and finishing the TkInter based simple viewer I’ve been investigating several GUI toolkits. As I have said previously I have found PythonGUI toolkit, but it turned out to be rather bad for creating graphical tool such as my application. So I have checked out Wix, wxWindows, PyGTK, among many others. The criteria for selection was primarily ease of use, drawing speed on Canvas objects (this is the most important, especially when using Python, because the language execution is so slow) and last but not least portability. My goal for this app was to make it portable from Linux based system to Windows and if possible to MacOS X. PythonGUI seemed to match the portability and ease of use criteria, but it turned out that it even doesn’t have decent drawing facilities. So I have disqualified it as graphical user interface (GUI) toolkit. wxWindows is too crappy and too low-level for me to play with it. I don’t have time and patience for learning such a toolkit. And it still needs GTK in Linux and Unix. PyGTK is just a wrapper over non object oriented toolkit, so the development would need significant shift in my perception and I really hate GTK. So it was disqualified also. After many trials, errors and researching I have finally decided to go with PyQT. QT is clean and fast, fully object-oriented, easy to use, it’s very portable (QT4 is natively portable to Windows also, not sure about MacOS X), you can create derivative widgets with simplicity and the development is fast. But most importantly it has PERFECT facilities for complex Canvas drawing that are FAST even in Python. QT is written in C++ and PyQT is almost identical wrapper over C++ functions, so this is great if in future Python turns out to be too slow, I’ll be able to quickly rewrite the app in C++. And there’s also one more thing. QTDesigner for rapid creation of usable GUI layouts. There’s a compiler that takes QTDesigner UI files and converts them to native Python code. PyQT is awesome. However there’s one downside. Commercial applications written with QT need paid licenses. However as I have said before I’m going down the Open Source road and going to use GPLv2 license, which is also the license for QT and PyQT when used for non-commercial applications. So this isn’t a problem in this case.
And now for the awaited eyecandy. 😉 I have to mention that this wouldn’t be possible at all if not for my russian buddy Grig de Griz, who sent me supplemental information regarding the formats. Once again. Thanks man! And here it is:

moogfxview_1.png moogfxview_2.png moogfxview_3.png moogfxview_4.png

Ok. And now a little description. The first image shows the TkInter based viewing window. It shows one of the buildings from Colony Screen in MOO2. As you can see it’s properly shown. The violet color is a special one. This file has a “functional color” flag which means this violet colour is used for drawing shadows over the Colony landscape in the game. As you can see under the window there’s part of the code used for loading and interpreting graphics. This is part of the Graphic class which is responsible for file loading. The second screenshot shows another building from BLDG0.LBX archive. As you may see under the window there’s a shell showing usage of the the viewer. Viewer currently parses arguments from the shell and handles a -p switch which is used for palette loading. Unfortunatelly TkInter toolkit is ugly and doesn’t have essential widgets, so I have decided to switch development to QT. The third screen is showing QT based palettebox widget that I have written for my application. This widget (as other classes in my app) could be used out of the box in other applications as well without need to change anything within the class. It currently handles showing, resizing, on mouse hover color highlighting, selecting colors and few really neat things that could be used in future within the to-be-done editor. 🙂 The widget takes standard hexadecimally encoded RGB color list of any size. This way it’s suitable for ANY application which needs palette selection box. The fourth picture also shows the palettebox widget with other palette from MOO2. This PaletteBox is a widget and this means it could be embed within the window frame or any other QT container. You can also create inherited class from it and make more complex widget using this PaletteBox as a base or even embed it within custom container widget to create for example palette editor widget. Hail to the power of QT! 😉

Currently the app has Palette/Graphic/LBX archive management classes, PaletteBox widget class and now I’m developing GraphicView class which will be essential component in the viewer application. I’m going to leave as much facilities within the class for future inclusion of editor routines as possible. The QT’s QPainter and QCanvas classes are really awesome and powerful toys for such things and they are perfectly fitted for this task. After writing GraphicView widget the only thing what will be left is to use QTDesigner and form compiler to create some kind of pretty user interface and polishing of the code. After this I’m going to release first version of the code into public. Program uses Psyco Just-In-Time compiler optimisation if it’s found on the host system for speeding up the app. Also I’m aware of existence of cxx_freeze and py2exe compilers for creating binary distributions of the application. I’ll try to compile it and test the app after I finish it on the machines available to me. However the time is hard on me, so the code release is a priority for me. Unfortunatelly tommorow I have the exam from Linear Algebra and I have to educate myself a little. 😉 Semestral exams session is just starting and it will last for about two weeks. I will have few days of free time, but I’m assuming I will use them for learning. There’s also another downside. Recently the client contacted me to finish my CMS system and set up website using it for him. He accepted the specified deadline so I will have to work hard on it to match the deadline. This means I won’t have time for MOO2 Viewer within a couple of weeks. However as I have said I’ll try to finish the code and release it’s first public version. The progress is steady and most of the essential program functionality has been written. My guess is that I’ll be able to release the code within a week if time allows. Most of the code I have written through todays night and this update is brought to you with help of few teas, cigarettes and totally awesome Digitally Imported radio chillout&psytrance channel. 😉 Stay tuned, I’ll try to keep you informed whenever changes occur.

Posted in Coding, Master Of Orion 2 | 1 Comment

A little update on MOO2 Graphics Viewer

Despite the fact I have semestral exams at the university (that I’ll probably f*ckup anyway) I wanted to do something else than learning thermodynamics and such stuff. So I’ve taken another look at my MOO2 graphics viewer. Recently I’ve contacted Lord Brazen, who told me to ask Grig de Griz from MOO2 Forums. Grig sent me his MOO2 Workshop program that unfortunately I haven’t been able to test, because I’m not using Windows anymore. However his documentation describing the format was quite helpful for me. There were some things I still had to decipher on my own, but some ideas that Grig had about the format were really good. So I credit him here, because if it was not he, probably I wouldn’t have will to do anything about my little program.

I thought I can rewrite my little tester app from scratch. After few hours I have written two almost complete classes for graphics and palette management. Yes, that’s right. Now the palette is loaded from MOO2 files. However when testing it with graphics from MOO2 it seems to me that either none of the palettes are useful for my test files or the conversion process from DAC RGB to 24bit RGB isn’t the same as Grig has pointed out. Further investigation definitely is needed into this matter. If you have ANY information regarding MOO2 palettes or DAC RGB to 24bit RGB conversion please do drop me a line!

Currently I have almost complete understanding of the MOO2 graphics. ALL test files are loading properly in my viewer. I haven’t checked it visually, because I wasn’t able to write GUI and drawing routines, but the format is loaded 100% properly. I have also left facilities within the class for further investigation of the “junk” bytes that seems to occur between the frames. If they are not junk from memory dump as Grig has pointed out and I have to remind you that when the game was published diskspace did count, I’m assuming that they’re either indicators of changed lines (because some frames are really small compared to others within the same graphic file) or they’re indication of color or palette shifting (ever heard of palette animation?).

For some of you waiting for some more technical details you’ll be disappointed. Tonight I’m not going to give them away. It will happen soon however when I finish rewriting the application to give it’s first beta AND THE CODE. The code and the app will be released free of charge and under GPLv2 license. So anyone who’d like to improve or take something from my app will be able to do so for as long as you will stay in compliance with this open source license. The code is written in Python 2.4. It’s primarily intended for *nix based systems (I don’t have Windows mind you), but it should be fairly simple to port it to Windows, so when I’ll release the code you should be able to run it. Also MacOS X users should be happy, because I’m currently rewriting the GUI with portable PyGUI module that is high-level GUI built over GTK2/Cocoa. So Linux/Unix/MacOSX users should be able to run it out of the box (after installing Python and PyGUI). Windows users should be able to run it after installing ActivePython, PyGUI and Windows GTK2 facilities (library). Those components are free of charge and available for download on the net.

So stay tuned, it shouldn’t be long before I’ll release the code. I’m thinking that if there will be interest in my work I could extend the program further and possibly change MOO2 Graphics Viewer to MOO2 Graphics Editor… 😉 I know that some of you would love to see it. My guess is that knowing how that format is structured it’s relatively easy to write a program that will integrate graphic editor, palette editor and LBX Decompression/Compression out of the box. And remember. If you really would like to see it, the GPL will allow you to take this basic editor and extend it more and more. 😉

No screenshots yet, but I hope that within few days I’ll be able to put some eyecandy here. 🙂 Stay tuned.

Posted in Hacking, Master Of Orion 2 | 1 Comment

MOO2 Graphics Viewer: And the struggle continues…

I’ve managed to get rid of format reading bugs. Now the image is read and interpreted properly. Only what’s left is the palette problem. Here are few shots:

moo2gfxview2.png moo2gfxview3.png moo2gfxview4.png moo3gfxview5.png moo4gfxview5.png

Hope you like it. 🙂 The first one shows the viewer that had corrupted palette (it turned out to be Gimp problem, not my program) and the second has almost correct palette (slight problems are still occuring though). I’m currently not using original palette maps from MOO2. They’re only quickly hacked with Gimp (manually). So the problems exist. I will try to decipher MOO2 palette format and then try to use it within my program. As you can see the progress made so far is neat. The last three images have some palette problems, however I’m now absolutely sure that the format used for graphics in MOO2 is the same for every graphic regardless where it’s used. That’s really nice as you can say.

I have depacked few LBX files and tested my viewer against their contents. It’s working with 90% graphic files. The files that are not opening with it have some quirks in their formats. Especially there’s junk at the end of some files, I haven’t figured out yet, but I hope I will. I can say something about the format at this point. All values are little-endian. Header at the beginning has a word (2 bytes) containing width, and a word containing height of the image. Then there is a word of junk (always 00 00). Next is probably the frame counter (also 2 byte word) followed by four byte junk. Next two bytes represents a word indicating starting offset for graphics. Two bytes junk that’s always 00 00, followed by four bytes of junk with differing values. Then there is two byte 01 00 that is probably start indicator or perhaps the frame number (I’m not sure really). Then follows two byte relative y position of line. Each line can consist of infite “line items”. That means the line can consist of infinite smaller sequences of pixels. Each pixel sequence (line item) starts with two byte length followed by relative x position of the sequence. Then follows the color sequence itself. Each pixel is represented as 8bit value (one pixel = one byte). There can be many pixel sequences within a line. If the sequence length is odd the sequence is rounded to even length by adding 00 byte. Each line terminates with what I call end-line terminator. It’s a double byte (00 00). After this the new line starts with two byte word representing relative y position and the whole thing starts again.

However when testing my viewer on some data sets from MOO2 I have spotted that some graphic files end with few bytes of junk. I’m assuming that this could be a pivot point of some kind or my LBX decompressor is not doing very good job really. Also I’m quite suspicious about line terminators, because it seems that in some files my program is getting out of sync with data stream. I’m wondering if it has something to do with rounding of line. Also it’s very likely that the junk at the end of some graphic files is associated with some kind of frame termination/additional data. It still needs further investigation.

Also. If you’ll use the information I have gathered about this graphic format please drop me a line. If you want to write an application using this information I’d be very thankful if you give me some credit for it. Thanks!

Posted in Hacking, Master Of Orion 2 | 3 Comments

Master Of Orion 2 graphics and nightly hacking session

I wonder if some of you remember very oldskool game Master Of Orion 2 by Simtex. If you don’t you were probably too young to know of it’s existence. The game was released in 1995 and it was awesome 4X turn-based strategy game. The goal was simple. Manage your civilisation so it can finally get out of it’s cradle, show it the way to the stars, meet other races, trade or fight with them and build your empire. You could either be peaceful or take your name as a violent warrior. You could develop new technologies, build fleets, spy, sabotage, make enemies or alliances, fight space creatures, gather strategic resources, expand your presence through the galaxy and much, much more. Despite it’s simple principles, the game was intense. And for me it also helped to develop my imagination. How’s that? It’s simple. The game is a space opera. Each game is unique experience. And if you began thinking of a good story based on what’s developing in the game when you’re playing, most of sci-fi movies would be ashamed. The game offers much for a demanding player. Multitude of options, very flexible management of every aspect of the empire (ok, it’s not so cool when the game is nearing it’s end – too much micromanagement), various twists and turns, unique races with very different gameplay and much more.

I’m still playing it a lot, despite the fact that it’s more than eleven years old and the graphics is a little bit inadequate today. But it doesn’t matter really. The game has enormous playability almost unseen these days. Why am I talking about this? Well… I could really loose patience waiting for FreeOrion to be completed. It’s a free reimplementation of MOO2, but loosely based on it. But FreeOrion is a new game and some of it’s aspects that the developers are pushing doesn’t suit me very well. That’s why few months ago I began writing a simple engine in Python and SDL to learn and also to make a remake of MOO2. That was my goal. However I didn’t have time to finish it, so the project stalled. I’m still thinking about creating a reimplementation of MOO2 someday.

I was wondering how the graphics in MOO2 are saved (in what format). I’ve began looking at several sites explaining LBX files. It seemed that they’re simple archives. So I asked grandpa google to help me. I got few sites explaining the format and even depacker that even compiled under linux. Wow! I’ve began reading about the format, but I couldn’t find anything regarding graphics. Even though I’ve found something regarding graphic format used by Simtex it seemed that the guy who began hacking it died sometime ago and the information was incomplete and wasn’t very useful. I immediatelly realised that it could be a fine challenge for me, and because I have holidays now (no more faculty of physics stuff for few days, yeah!) I thought… Hmm… Why not to test myself? Brain that’s not used is not worth a single cent. I had a theoretical knowledge about analysing data streams (I’m crappy self-taught admin ya know) and I know theoretical basis for cracking, so I began reverse-engineering graphics format used in MOO2. I’ve depacked few LBX files from MOO2 and began to analyse them with yer olde hexedit. But manually analysing few hundred files just to see differences in them (it wasn’t time for “what this or those byte does?”) is real pain in the ass. So I’ve written a little helper script in Python for helping me in seeing differences between the files. After few hours I wasn’t much more knowledgeable than I was before. So I’ve depacked NEWGAME.LBX, because I knew this file should have screen for new game, and I knew were to look for changes. I began bruteforcing the file with FF in hexedit. After many “oops. I screwed again” I finally began to realise the pattern. I made some assumptions of course (e.g. that the pixels are represented by the 8-bit colormap) and some of them turned out wrong, but some were actually true. It really helped me that I had theoretical basis so I knew what to look for, and if I could find something I didn’t give up, I just tried to make a new assumption. After few hours spent with hexedit and calculator I’ve finally deciphered most of the format. It wasn’t very hard really, but time consuming, I admit. So when I knew that I could make some use with this knowledge I realised that I could try to quickly hack a viewer for MOO2 graphic format. mcedit is my best friend. 😉

I’ve written few routines in Python as a basis for future program for viewing those graphic files. The result is below:

MOO2GFX Viewer

Ok. Maybe it’s not what you’ve expected, but take into account that I just wanted a proof that it’s possible to view (and possibly edit in future) graphics from MOO2. This program is quick and dirty hack written within few hours and I’m really fucked up right now (you know, nightly hacking session, etc.), it’s christmas eve and I’m doing something like this because I wanted to. It has problem with the color palette and it’s not showing the file properly, but that’s normal. Bugs are everywhere after such session and I’m not willing to hunt them down now. I don’t know why the palette is screwed. I’ve hacked the NEWGAME.LBX graphics so I’ve got whole 256 color palette which I’ve ripped with gimp, then saved as .h file, removed unneeded C header code and made palette map which my program should properly interpret. Perhaps it’s the TkInter Canvas problem or something. I’m not going to look for bugs now. Also as you can see there’s a problem with few lines. The image is cropped, but I think this is because the format has some quirks in it that I haven’t deciphered yet. Also the file reader is crappy really and because the format is using something like 00 00 00 as horizontal line terminator and also as EOF
the program doesn’t check for bugs within the format itself. Also the information I have gathered about the format is not complete. There are some mysterious bytes that doesn’t do anything visually.
I’ll try to work on this later, after I get some sleep. The proof is there. I tried to test it on other graphic files, but it seems that it’s not working with them right now. I have two guesses. Either I have deciphered graphic format for MOO2 GUI or there’s something else with those f*cking line/file terminators. I’ve seen debug from the program that showed wrongly parsed bytes on some lines. So I guess it really needs polishing and further research. When I’ll have a program that can open most graphic files from MOO2, I will release it’s code under GPL and release information about the format I have gathered. Until then enjoy the screenshot.

Posted in Hacking, Master Of Orion 2 | 2 Comments