Posts Tagged ‘debugging’

Getting systematic

2008-07-31 (Thursday)

Hi! These past few days have been pretty nerve wrecking. I’d eagerly want to get on with the reverse engineering but getting savegames working in Operation Stealth is 1) essential, 2) broken at the moment, 3) not looking like the straightforwardest code to fix (Or more like not knowing what to fix exactly). Not really knowing how to swiftly and proficiently squash the bug but still knowing that I got to fix it before going forward with other stuff is infernal for motivation.

Still, I have been doing some testing with the bug, not very much, but some. Now I know what data seems to not be up to date after loading. The next step is getting systematic about it. Identify the functions that manipulate the data that’s making things break currently, understand why and where they are called and see where they should be called when loading a savegame to get the needed data up to date.

Currently Operation Stealth throws an assertion in addAni function which is called from processSeqListElement which is called from processSeqList which is in turn called from the main loop (Now *that* was a nice elongated sentence if any :-)). I did some debugging to see what values addAni is called with when playing the game and the only values I saw in the beginning of game were values related to the player character’s animation:

Calls to addAni when walking around in the first room

  • param1=3, objIdx=1, var8=1, var14=0, param3=0 (Walking down)
  • param1=2, objIdx=1, var8=1, var14=0, param3=0 (Walking up)
  • param1=0, objIdx=1, var8=1, var14=1, param3=1 (Walking right)
  • param1=1, objIdx=1, var8=1, var14=2, param3=1 (Walking left)
  • param1=7, objIdx=1, var8=1, var14=0, param3=1 (Facing down)
  • param1=6, objIdx=1, var8=1, var14=0, param3=1 (Facing up)
  • param1=4, objIdx=1, var8=1, var14=0, param3=1 (Facing right)
  • param1=5, objIdx=1, var8=1, var14=0, param3=1 (Facing left)

Some clarifications:

  • E.g. facing left means that the player character is standing still and looking left.
  • var8 and var14 are actually member variables of a SeqListElement that’s given as a reference parameter to addAni.

Hypotheses made from the given addAni calls:

  • param3 is 0 when the player character is walking vertically, otherwise it’s 1.
  • element.var14 is 1 when the player character is walking right, 2 when his walking left and otherwise 0.
  • param1 identifies the used animation (Walking right, walking left, standing still and facing left etc).

So, wish me luck with the debugging and let’s hope it’ll be over in no time!