Project VGA

project vgaVisit the Project VGA Page for an introduction and overview of the project!

Fellow geeks


Places to go

Daily WTF
Open Graphics


Questionable Content
Dresden Codak
Sore Thumbs
Penny Arcade
Perry Bible

HomeServer profile
xhtml 1.0 strict
GPL 3.0 License

Wacco Webstack

I never got the hang of Thursday

Posted on 2006/10/26 - 22:42

Well, I did manage to finish that report, so finally (I hope) I'll never see that Microwave thing again. But besides that I lost all motivation to do anything else. I guess it's time to talk about a recent project I finished, since I still haven't discussed all projects I'm busy with. The project in question is called ARchiver 2, or ar2 for short.

This little project came from the need to manage some of the resources involved in the 3D engine I discussed in an earlier entry. Part of the job of a game engine is to provide tools and methods to load scripts, models, textures, sounds, you name it into the engine without too much effort. You certainly wouldn't want to do this all by hand if you consider that you could have a total of hundreds of resources which can all be updated numerous times during development. There are ways of doing this, but some are far from simplistic, others are simply "Not Invented Here". And I thought it'd be fun to try and build my own archiver.

The requirements were simple; archive a bunch of files into one file, like the well known tar, and give it an entry table so that the file doesn't have to be completely de-archived before it's usable. Not all resources will be used at the same time, and de-archiving will only happen to memory so simply tar wouldn't be enough. Tar has some other features which I wouldn't need, like block alignment for tapes (hence the name Tape ARchiver). I found myself a spare weekend and got to work.

It turned out to be a lot easier than expected and I quickly devised a method which worked perfectly. You can read my semi-blog of back then right here. Note that I called it sar (Simple ARchiver) back then, but I changed the name due to an other tool that's called that way. I cranked out the required 200 or so lines of C code in just one Saturday, but it bit me pretty hard due to the lack of error checking. That smelled like another little requirement.

To assure that it'd work correctly in pretty much all circumstances, I figured I would do all error checking possible on each and every call in the application. And while I was at it, I wanted to make it look as representable as possible for my style of programming. That took me another day to write up, and the line count simply doubled. Unfortunately, due to all the error checking I started to like it less and less, since most of my actual code got cluttered so much with these checks. Oh well, maybe it's not so representable then. At least it works pretty good, it outperforms tar in file size (naturally, no block sizes to worry about) and is usable in the dynamic situation I wanted to use it for.

It has been online for a while now and still hasn't been implemented in the actual game engine, but it works perfectly as a stand alone application. The source code files have been split up in such a way that you can use it as a library without too much effort in your own applications, demonstration code is included as well and the license is BSD. If you want to give it a try, or simply have a look, you can download it from here (bz2) or here (zip).

And that's about it for today! Sorry for the lack of pretty pictures this time, it's kind of hard to make an interesting screenshot of a command line tool which doesn't output anything. I'll promise some eye candy for tomorrow! G'night!

[: wacco :]

Leave a comment