Oli's old stuff

Tinkering with retro and electronics

Jul 23, 2016 - 4 minute read - oldcode

Manta-X Archaeology

Manta-X: Uncovering a relic

I’ve been digging around in my visualstudio.com projects and came across Manta-X Game. This was a real blast from the past for me - a game dev project that I was working on back in 2004.

The goal of Manta-X was to essentially recreate the Andrew Braybrook C64 classic Uridium for the PC. I remember the ambition was to have 3d graphics instead of sprites, so I was using OpenGL. 2004 is a long time ago now and technology was very different back then. I also have no idea how far along the game got - what features it has or whether it’s even playable at all.

As a bit of fun, I’m going to explore my old codebase and blog about it. I’ll dig through the past and see how my old brain went about things and ask myself whether I’d still do things the same way now. I have been programming for a long time (long before 2004) and so my knowledge and professional development experience in the intervening 12 years has shaped my skills. This will be a fun exercise - I can remember literally nothing about the code or structure of the project at this point in time, so perhaps a few surprises will crop up :)

This is not the first time I stumbled across Manta-X; in 2012 I found it on an old hard drive and threw it up to visualstudio.com. In 2014 I found and got it compiling again, swapping out GLFW for SDL 1.2 and bringing in the latest versions of PhysicsFS and TinyXml (the versions I used were no longer around).

Today I pulled down the code from the TFS repository into git using git-tf (thanks to Chris Kirby’s blog) and uploaded it to bitbucket. Now I can start exploring and changing things.

Digging in

The first thing to note is the folder structure:

root/
    build/
    deps/
    dist/
    doc/
    include/
    src/

build contains the intermediate build files deps is where the third party libraries live. Currently physfs 2.0.3, SDL 1.2.15 and tinyxml 1.2.4. dist contains the built binaries and my game assets. doc contains a bunch of random text files, ideas, todo lists and other junk that was probably useful 12 years ago, but is totally meaningless to me now. include and src is where the code lives. Back then I kept .h and .cpp files separately. The visual studio solution and project files live in the root directory.

Assets

I thought it’d be interesting to explore the dist\data folder to see what assets I had. It turns out not many - a handful of tga files, Milkshape 3d models and xml specifications for entities and GUI layouts. Interestingly, I was loading up raw, loose assets and had no packaging process. The lack of assets is very telling too - the game obviously isn’t very far along. A couple of enemy models, the player model and a handful of basic textures.

I opened up the file entities\manta.xml and found this.

<?xml version="1.0" encoding="utf-8"?>
<model id="manta" file="manta">

	<feature xpos="" ypos="" zpos="" type="WEAPONMOUNT" />
	<feature xpos="" ypos="" zpos="" type="WEAPONMOUNT" />
	<feature xpos="0.0" ypos="0.0" zpos="9.0" type="ENGINEFLARE" />

	<collisionbox>
		<point xpos="-10.0" ypos="-5.0" zpos="-8.5" type="MIN" />
		<point xpos="10.0" ypos="5.0" zpos="8.5" type="MAX" />
	</collisionbox>
	
	<motion direction="LEFT" velocity="100.0" maxtilt="15.0" />
	<motion direction="RIGHT" velocity="100.0" maxtilt="15.0" />
	
	<motion direction="THRUST" velocity="100.0" maxtilt="0" />
	<motion direction="BRAKE" velocity="100.0" maxtilt="0" />

	<setting name="AUTO_TILT_CENTER" value="1" />

</model>

Of course, it means very little to me now - especially the magic “AUTO_TILT_CENTER” setting :) I was also clearly specifying the entity as a whole, rather than using a more component based model. I bet that looking in the code I find an inheritance graph for entities that starts with a class called Entity and ends with Manta, likely with some abstraction of Ship somewhere in the middle.

There’s a scripts\startup.gm file with the contents:

// Load models for game
Game.Models.Load( "manta", "models/manta.ms3d" );

// Create a player ship using the 'manta' model
player = Game.CreatePlayerShip( "manta" );

player.y_rot = 90.0f;
player.x_pos = -50.0f;

Looks like I was using the GameMonkey Script system to implement the “game”. Quite why there’s a split between xml configuration and script for similar reasons is unknown to me - there probably isn’t a sensible reason!

The textures folder is also very telling about the state of the game. There’s a nice background texture, a particle texture, a bitmap font and… that’s it. The models have no textures at all!

The lack of an audio folder confirms that not adding audio to my projects goes back a long way :)

Currently the game compiles but doesn’t run due to missing dlls (SDL runtime and physfs.dll). In my next post I’ll focus on getting the game running and then dig into the code and start exploring.

Until next time!