Archive for July, 2008

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!

Operation Stealth savegames bugging

2008-07-29 (Tuesday)

Hi! Alright, now I’ve got a format for saving and loading Operation Stealth savegames. But the problem is that whilst saving seems to work and loading too, after I load an Operation Stealth savegame the game crashes in the main loop in processSeqList… something to do with all the animated stuff as I tried removing the call to processSeqList from the main loop and suddenly there were no characters on-screen at all 😀 but at least it didn’t crash then.

So to get this bug smashed next… ROAR!

Savegame format coming together

2008-07-28 (Monday)

Hi, this savegame format thing has been getting on my nerves quite a bit. Last night I thought what the hell, I’ll get this done and just hacked together code to get forward (1, 2, 3). Recently I reverse engineered Operation Stealth’s PC version’s savegame loading routine and using that information I wrote documentation of the format to ScummVM’s wiki.

My idea why I wanted to reverse engineer and use the information from the Operation Stealth’s disassembly for the savegame handling is that if I know what the original engine thought was important enough to be saved to a savegame file I can use that information to save pertinent parts of the Cine engine too. So what was good enough for the original Operation Stealth engine should be good enough for the Cine engine as well.

A word of warning about the savegames: The savegames for Operation Stealth are going to be very much a work in progress and therefore backward compatibility can be broken at practically any time and the changing formats will not be supported later. They are only a tool for development. A bit later it’d be very nice to share resources with the SCUMM & Tinsel engines so the three engines could use the same code for handling their savegames.

Savegame format changing ordeal

2008-07-25 (Friday)

HI! Tried changing the Cine engine’s savegame format from plain data without any markers to a chunked format akin to IFF. Got lots of ideas, and some code together too, but eventually gave up as making it really work would’ve required some major objectifying of the engine and it’s still very C style in many places currently.

So I’m not going to make use of a finegrained totally new chunked format now, but I’ll make a compromise and use a new chunked format but dump most of the savegame data into a single chunk. The format can be improved later.

I looked into how the SCUMM engine has implemented its savegame handling and its approach looks to be quite an interesting one. Take a look at scumm/saveload.h and scumm/saveload.cpp.

P.S. My IRC attendance on #scummvm will suffer in the near future as the server on which I ran irssi in a screen moves town starting today. I’ll try to get back on IRC during Sunday or Monday the latest.

Back to working with Operation Stealth

2008-07-22 (Tuesday)

Hi, just got the release critical Future Wars old savegame loading bug fixed (My thanks to wjp on #scummvm for his help with nailing this bug). Getting the Operation Stealth’s savegame stuff working is now next…

Bughunting season

2008-07-21 (Monday)

Hi! Last week went mostly in bughunting as the next ScummVM release is being prepared and bugs are being fixed.

  • Fixed a bug that made Amiga and Atari ST versions of Future Wars crash right in the beginning. Seems like the script writer for those Future Wars versions made a typo (He tested local variable 251 in the scripts when he meant to test *global* variable 251). So it was a bug in the original game’s scripts.
  • Worked on reducing the Cine engine’s BSS size (i.e. reducing the amount of global variables that are allocated statically and increase the size of the executable. Here’s a patch for it). Got a nice 64kB reduction in the BSS size.
  • Tried to fix a release critical bug that makes the current ScummVM code not be able to load some Future Wars savegames that were made with 0.11.0 or 0.11.1 releases of ScummVM. Haven’t yet been able to fix it completely, but I’ve got an idea what’s making it bug at the moment (Thanks to wjp for his help with this bug).

So now I’ll try to get that release critical savegame loading bug fixed first and then it’s onto fixing Operation Stealth’s savegame support (Which doesn’t look *so* intimidating anymore after all this looking into Cine engine’s savegame format).

Making Operation Stealth completable

2008-07-13 (Sunday)

Hi! With the mid-term goals done and the bathroom door crash fixed I’m now setting out to make the PC version of Operation Stealth completable. My plan is to try to play through the PC version of Operation Stealth and fix any showstopper bugs along the way (i.e. bugs that keep me from completing the game). In addition I’ll also try to fix any seriously annoying bugs like e.g. the current mouse cursor pointing problem (You can’t just point to an object onscreen to access it but you have to point a bit to the right of it).

After I get the PC version completable it’s time for all the non-crucial stuff like fixing the music, sound effects, graphic glitches etc. And then there’s also the matter of making sure that the Amiga and Atari ST versions are completable too. So all in all a lot to do! But let us not lose hope but push ever forwards ;-).

Ah, and as the saving and restoring of games in Operation Stealth is broken at the moment, that’s the first thing to be fixed before the completion journey begins.

P.S. I’ll be making blog posts along the way as I get further towards completing the game.

Mid-term goals done

2008-07-4 (Friday)

Hi! The last of my mid-term goals (The actor animation regression) got nailed this week.

Here are my recent achievements:

  • Implemented resetGfxEntityEntry function in r32848
  • Fixed addAni function in r32850
  • Fixed and implemented the rest of processSeqListElement function in r32874

And I’ve been documenting the Operation Stealth’s disassembly generally along the way a bit too.

What next?

I’ll probably try to nail the sprite related problem when trying to enter the bathroom in the airport (In the very first scene of Operation Stealth, that is). There’s a bad memory allocation happening when one walks to the bathroom door and the door should open. It happens because of trying to allocate some humongously – and very erronously so – large array.

Also saving games in Operation Stealth is broken at the moment, so that’s one quite integral thing that could use some fixing too.