Wednesday, July 21, 2010

24 years of MGT

So, what about taking a look inside the code of the DOS version of the game MGT (a short for MaGnetik Tank it seems).
Let's wrap this blog in mystery by giving only the main (or what it may have looked):
main() {
if(LORI_init()) {
exit();
}
loadResources();
for(;;) {
splashScreen();
C_284D(); /* init MGT */
C_2759(); /* init MGT 2*/
commandMode = COMMAND_NORMAL;
C_2669(); /* restore rooms info */
C_1B13(); /* init doors state tab */
initializeRoom((unsigned char)0);
gameState = GS_OK;
/*************/
/* Game loop */
/*************/
while(gameState == GS_OK) {
LORI_playFreq(0);
shootSoundSeq = 0;
noKeyPressed = 0;
gameObjects[1]._spriteIndex = 0; /* reset shadow */
gameObjects[0]._spriteIndex = 0; /* reset MGT */
LORI_updateSprites(&mGameObjectsD);
LORI_castSprites(&mGameObjectsD);
LORI_sortSprites(&mGameObjectsD);
C_300D();
LORI_dummy();
LORI_displaySprites(0, DISP_W - 1, 0, DISP_H - 1, &mGameObjectsD, &D_0086);
/*************/
/* Room Loop */
/*************/
roomLoop();
}
gameOver();
}
}


All the LORI_ prefixed functions (as a reminder of Loriciel(s), the original maker company, RIP) are external functions, coded in assembly language (or let's say, the probability that they are is quite high).
The C_ prefixed functions, are named by there offset in the code segment. So yes, their purpose is far for being obvious... in fact, it's not obvious at all.
Let's say that I didn't find a well suited name yet (or maybe I didn't what they were doing).

As for the compiler used, given the loading code and the presence of the LC 3.00 string in the data section, I would sayd that it is Lattice C compiler , version 3.00.

That's all for this time. I hope I can give more information very soon.

No comments: