Warhammer Dark Omen Forum

Modifications => Tools => Topic started by: jon on December 12, 2019, 11:18:28 AM



Title: New Go library for decoding SPR files
Post by: jon on December 12, 2019, 11:18:28 AM
Hey everyone, I wrote a package in Go that can decode Dark Omen's .SPR files. The package allows you to work with the frames in-memory in your program. For example, you can dump them out as PNG images. The Go package for doing SPR-related things is named encoding/spr.

Take a look and let me know what you think. I think I've got the method correct (based off http://wiki.dark-omen.org/do/DO/Updated_Sprite_Format (http://wiki.dark-omen.org/do/DO/Updated_Sprite_Format)). I'm 99% sure I've done the Zero Runs decompression correctly, but happy to hear otherwise. I mention this because there's a few sprites that end up having some frames decoded as width=0, height=0 which can't be dumped as an image. I think it checks out because these frames also have a corresponding frame type of 5 which means the frame is empty—just not sure why the frames would actually even exist if they are empty (unless it's meant to render nothing in the game for that sprite's frame).

There's probably still a bit of work to do in the encoding/spr package. For example an old version of the sprite decoding method talked about an 'action' property and I haven't revisited that after implementing the newer version. Also, the package provides the user enough information to dump out the frames as PNG, but I haven't checked that there's enough information to do other useful things with the sprite and frames.

If you look in cmd/spr-dump you can see an example program for how you should be able to download the program and run it against your Dark Omen CD to see all of the sprites being decoded and dumped to an output directory on your file system. I didn't test it on Windows but it should work...

The package will probably undergo heavy development if I'm able to keep adding things to it. I'll likely add in GitHub releases, so any binaries/executables (like cmd/spr-dump) will be released in the GitHub repo as prebuilt downloadable executable files—and because Go makes it so easy, they'll be available for Linux, macOS and Windows!

Here is the GitHub URL: https://github.com/jonathaningram/dark-omen (https://github.com/jonathaningram/dark-omen)


Title: Re: New Go library for decoding SPR files
Post by: olly on December 12, 2019, 02:17:31 PM
Hi and welcome,

Sounds great and will test it tonight and let you know.

Many thanks

:)


Title: Re: New Go library for decoding SPR files
Post by: jon on December 23, 2019, 05:40:44 AM
OK I just added decoding for .M3D files. Nothing fancy—all my work is really just porting the Python and C# source code I found on the internet to Go.

The example command in the GitHub repository is just meant to illustrate decoding the models and writing them out as JSON files—I wouldn't expect the output of this command to be useful aside from inspecting the contents of the model files.