HCl's Wing Commander Editing Site
Webmaster: Mario Brito - mariobrito2@gmail.com
Kindly hosted by

November 29th 2013

I've been making a few tweaks here and there to a few of my projects since the last update. A quick summary:

- WCP DVD Patch: due to the release of the WCP on GOG, i decided to revisit my WCP DVD patch and make a few improvements. Basically, i changed the DirectShow interface being used by the patch in order to improve compatibility with Wine, which means the patch now works correctly on Linux. The subtitle code ended up being reworked as well, and should hopefully work better in the more recent versions of Windows. You can get it here and follow the CIC thread here.

- Privateer 2 Patch: Since the first release, I managed to make a few tweaks to the MIDI code and added a very simple setup utility which allows selecting a specific MIDI device for use with P2. Third party MIDI software synths are a great alternative to Microsoft's default synth, but unfortunately might now work well together with P2 as of yet. It becomes necessary to coerce P2 to use one specific MIDI device, which can be problematic, especially in Windows 8. Hopefully this option should help with that. Other tweaks are in progress. This new version of the Privateer 2 patch can be downloaded here, feel free to join into the ongoing CIC thread here

- WC3 3DO Movies: ok, so I thought I had the movie decoder fully documented, but recently discovered the script I put together perfectly uncompresses one file sample I had, but apparently doesn't decompress the movie files I am ripping from the CD images i dumped into my hard drive. Looking into it, it seems there are *two* variants of the WC3 3DO codec, which is very interesting. Part of the CEL chunk structure is different, and the VGA chunk corresponding to the Huffman stage seems to be encoded differently. Naturally, i have a research stream were I'm exploring this.

- WC2 Ship Importing: last but not least. Began exploring the possibility of making a COM file for dynamically patching SO2 into supporting full-angled ships and started tweaking the Dralthi stats. As an aside, I also began thinking about a way to use the new COM file to expand the WC1/WC2 mission environment and hook a new scripting system. Looks like it could be fun! But first things first: finish that Dralthi...
November 6th 2013

Quick update: I improved the ship importer in order to handle Armada and Prophecy ships, so I'll be able to import the WCP Dralthi instead of the WC4 one. The WCP Dralthi is a bit more detailed than the WC3 or WC4 versions, and the quality difference is noticeable even in the low-resolution sprites used by WC2:

As an aside: since the importer can now read WCP meshes, I couldn't resist trying to import one of the Nephilim ships into WC2 :-) Here are a few WCA screenshots showcasing the Manta. I gotta say, I'm surprised how well it looks in the WC2 palette!

Next: time to work on the Dralthi stats!

October 28th 2013

There's been a lot going on on the WC2 ship conversion front. On one hand, i managed to figure out how the game handles the various types of ship encodings. The game handles every ship internally as having 62 sprites, with 12 sprites per rotation set around the Y axis (30 degree increments), and with every rotation set having a 30 degree angle increment around the X axis. Still, there's only one ship file that actually has the full set of 62 sprites: Ayer's Rock. All other ship files encode a more reduced set of sprites, 37 for fighters, 17 for starbases and 22 for missiles, exploring various types of symmetry. The game then uses a set of 4 lookup tables to map the 62 angles into the more reduced set of sprites. I made an overview of this scheme at the CIC thread here.

Unfortunately, it turns out that Ayer's Rock is coded as a special case on the SO2 EXE, which means that some EXE editing will be necessary in order to get the game to support asymmetric ships. As I prepare for tweaking the SO2 EXE a bit, I decided to begin importing the WC4 Dralthi into WCA as a test subject. The Dralthi is asymmetric, which means it will be a nice test subject for the SO2 hacking I have in mind, but at the same time, it's asymmetry is subtle enough that it won't spoil the fun as a WCA ship, even before adding symmetry support.

Additionally, it is the perfect opportunity to explore something else: increased sprite resolution. I doubled the sprite resolution of the Dralthi on both axes compared to the Hellcat, which means that the ship scales a lot better on close-ups. The current file is around 400kb (with RLE optimizations off and no LZW compression), but the game seems to handle it well. As expected, having a larger sprite means that the scale factor needs to be adjusted. I haven't done this yet, which means that the Dralthi on the screenshots below is actually larger than it should be.

Also made some progress on engine placing, so once i fix the Hellcat engines i will post a new version (maybe re-encoding it with higher-resolution sprites while i'm at it!)

October 13th 2013

A couple updates for today:

The WCA Hellcat project continues! I'm currently working on documenting the engine exhaust chunks and am making good progress gathering data. In the meantime, I managed to implement proper ship stats based on suggestions of Quarto and Capi3101, which makes the ship now fun to play!

Although the engine exhausts still need to be fixed, i'm releasing a test version of the Hellcat for WCA. Download this file and unzip it into the WCA Gamedat directory, then launch the game. The Hellcat replaces the Wraith in WCA for now. Give it a try, and leave feedback on the discussion thread at the CIC!

Also, regarding Privateer 1: I made a quick patch which fixes the issue of the MIDI music slowing down during space-flight if you don't have a joystick connected. This can be annoying if you want to play with the mouse or keyboard. You can get it here(GOG / CD version EXE) or here (BSDiff patch file). This really was a quick patch, the ideal solution would be to change the P1 joystick routine and improve it in order to make it timed... but that's something for next version.

PS: Yes, you can configure the joystick settings in DOSBox to overcome this problem, but it's still a problem in real machines. I am currently putting together a new dedicated WC-machine, so i will, over time, be revisiting a number of issues that the older games still have (eg. WC1 speed issues in fast DOS machines)

October 7th 2013

A quick update on our WCA Hellcat project!

I have since solved the various issues when converting the Hellcat to WC2 format. The slowdown that I experienced on the first few imports was due to the lack of a terminator code on the RLE stream, which caused the game to process garbage... but since the image is rect-limited, it ended up being very difficult to get any image corruption (and therefore many clues about what was wrong).

After fixing the issues with ship import, it was time to import a new cockpit! Fortunately, i was able to count with the help of CIC-regular Howard Day, who made a fabulous cockpit in full WC2 palette. After he sent me the PNGs with two versions of the cockpit (with every component "on" and "off"), I was able to improve my scripts in order to cut the cockpit in small pieces and code the animations for the various parts. Check out the images below!

Next up, time to come up with decent stats for the Hellcat!

September 16th 2013

Although it's been a while since I focused on the earlier WC games, the earlier sprite-based WC games are still among my favorites. Back when I was 16, I started my WC-editing days digging through the WC1 and WC2 files, hacking weapon stats and mission files in order to create new battles and stories in the WC universe, and for years i've been promising myself that i would do a small mod for WC1. The idea ended up changing a bit during the years, and although it remains on my To-Do list of WC-related tasks, it's been pushed down for years in favour of other tweaks for the more recent games.

Recently however, the WCA GOG release, coupled with my research digging through the SWC data a while back back, ended up motivating me to revisit something that I always wanted to do, and that in a way would play a part in my small WC1-mod that never was: i decided to try my luck at building a ship importer. Since the formats are so similar (and the RLE encoding is the same for both games), I can kill two birds with one stone and support both WC1 and WC2/WCA, with only a change of palette and a small change on the file packaging logic.

Since I am not an artist, i decided to make a parser for WC4 RealSpace models and use a WC4 Hellcat V as my test subject. For the first step, I needed images to encode: 37 of them, in 30 degree increments. A quick Matlab script allowed me to generate these images from the WC4 model, generating a set of 160x120 "tiles" which would later be encoded to the Origin FX format. After quantization to the WCA palette, it looked like this:

This resolution was chosen in order to get image sizes similar to the original WCA ships, so I can develop my importer without worrying about scale or memory issues at first. This "guesstimate" ended up being pretty acurate, as the produced file ended up being around 130kb, which is not much larger than the size of most WCA ships once they have gone through LZW decompression.

The second step involved encoding the set of 37 images with the Origin RLE algorithm, and generating a number of placeholders. Again, i'm not an artist, so i'm going to reuse the VDU and debris of the Wraith for the first few tries. Stats ended up being reused as well, which means that weapons and engine flames are not correctly placed. Still, watching the Hellcat V show up in WCA for the first time was really exciting!

Still need to solve a few problems with file generation, as the game tends to slow down a bit when the ship is rendered at some angles. This was surprising to see, as it has no good reason to be happening... My guess is that it could be related to engine exhaust placement (not quite matching this ship anymore), which tends to be rendered a bit differently when the slowdown occurs. In any case, not too bad for a first attempt! Once this issue is solved, it's time to give our Hellcat some real game stats and VDU.
September 9th 2013

I have linked below the source of the patches used on the GOG release of WC4 DVD. These are, basically, modified versions of Gulikoza's DXMCI and Jari Komppa's DDHack, tweaked in order to make the two patches play along with each other. Some of the changes I introduced involved adding a few game specific DLL-patches, in order to directly interface with the EXE at points that were useful, such as hack subtitle text coordinates or accessing the game Bitmap objects directly.

These changes were hacked together in a bit of a time constraint at the time, so no effort was made in order to maintain compatibility with other games (and there are a few warnings in there that have no place to be there...). Still, it compiles and works fine for WC4DVD, as long as you patch the DLL reference DDRAW.DLL to DWRAP.DLL on the game EXE (this was done on the GOG EXE). The purpose of this change was to allow the DD wrapper and real DirectDraw to work side by side, therefore allowing DirectShow to work without further wrapping DirectDraw interfaces.

And here are the sources, i hope they are useful to the community!

Thanks go out to Gulikoza and Jari Komppa for the original patches!

Adventures extracting Wing Commander game data

The Wing Commander games are just fascinating. Studying the technical aspects of these gems has always been an exciting endeavor, and ended up motivating me to get familiar with compression techniques and algorithms on my spare time over the years. The console game ports are also unique, and it's really rewarding to study them and see how the programmers used the available hardware in order to put together the game.

So, when i was able to get a copy of the 3DO version of Super Wing Commander, I was pretty excited and I started to take a look at the game files. Sure enough, most of the game assets are coded in CEL format, in order to take advantage of the specialized CEL processor. The CEL format supports a number of pixel-formats, as well coded and uncoded modes, packed and unpacked... although, for all intents and purposes it can be thought of as an RLE-based format. The chunks used by these files pretty much match the ones created by the official 3DO SDK apps, so anyone familiar with these will feel pretty much at home when looking at SWC data.

With my hands on some reference documentation available on the net, i decided to make a script in order to extract SWC CELs. After a bit of hacking, i had what i needed to unpack CELs generated by the 3DO SDK as well as SWC data. Watching the first ship CELs show up was really exciting!

Then i turned my attention to the movies. Given the specs of the 3DO, it made sense that the game's FMV was also based on the CEL format so, since i already had a basic CEL extractor in place, i decided to go the extra mile and see if FMV sequences could also be extracted. As it turns out, they can! SWC movies basically use 16-bit CELs in order to code the differences between consecutive frames, each of them further compressed with an LZ77-based algorithm (with variable-bit encoding for lengths and offsets).

The FMV digital audio chunks are also compressed with this LZ77-based algorithm... which results in expansion more often than not, but works really well on silent areas of the audio track (all-zero values, which are really not as difficult to occur as all that, since the movies usually are played alongside with a MIDI track, triggered somewhere on the executable).

By the way, this is not very different from the way Wing Commander 2 sequences are encoded, with WC2's base RLE algorithm being used to encode image segments corresponding to frame differences. WC2 animation frames, by the way, are grouped together into ~64k-long blocks which are preferentially loaded into EMS memory, and optionally compressed with a form of LZW. As a curiosity, most WC2 assets are LZW-compressed, but can be decompressed at install-time optionally (the "Save Time or Save Space" option available on the floppy install).

This approach ended up being used by Academy, and all the way up to Armada, for coding the various cut-scenes.

As for the console ports of WC3, the PSX movie compression is pretty much hardware-based (MDEC) with a small software-based decompression step based on a set of variable-length codes. WC3 3DO, on the other hand was a clear adaptation of the WC3 PC algorithm, with a few changes here and there, mostly in order to take into account the 3DO CEL engine and frame-buffer memory layout. Interestingly, it supports some pixels coded in 16-bit precision and others in 24-bit precision (although the color components of these 24-bit values come from a limited set of 8-bit values).

I still need to look at the audio track of WC3 3DO videos before I start extracting those. As soon as the day job allows it, i hope to put some more time into it. I expect these to be compressed with a form of ADPCM, probably running on the 3DO DSP... but we'll see what shows up once i further disassemble the 3DO binary.

As for the SWC audio and movies: I managed to rip these into a couple of zip files. With some luck, these will be integrated on the CIC's excellent Holovids archive at some point (Happy Birthday guys!). In the meantime, here are the links for the files on my GDrive:


Quick links:

Wing Commander Movie Player v1.2a

WCP High-res patch (~730kb) (fix, 76kb)

WCSO High-res patch v3 (8.39mb)

WCSO key generator: Java, Javascript.

Standoff DLL source (April 11th 2004).

WCP Video Skip Patch: standalone, highres addon, modding info.

WCSO Scatter Gun DLL source.

Prophecy Audio Tool v1.1a.

Armada & PG - DosBox Patch (IPX & Joystick), Armpatch version,
Modified DosBox 0.65.

WCP Enhancement Pack Test Release (release 0) - Includes Multiplayer Patch
WCP Enhancement Pack Release 1 - Includes Multiplayer Patch

Tai2Wav converter (for WC3 PSX audio)

WC3/4 PSX Video Extraction Tools

Wing Commander Sega CD Speech Extractor

Wing Commander Prophecy DVD Patch - Build 16-Nov-2013

Privateer 2 Patch Test Version 2 - Fixes a number of problems and deinterlaces video (run DARKFIX.EXE)

Privateer 2 Huffman Decompressor (source included)

WC4 DVD GOG Patches - Source code

Hellcat V for Wing Commander Academy - Test version

Privateer CD EXE no-joystick patch - Fixes MIDI slowdown if no joystick connected (BSPDiff here)

Choose your destination: