My work for this week was mainly concentrated on the main game loop and the bytecode interpreter.
While I was implementing other parts of the engine, I tried to only follow the specifications and semantics, and not just transliterate the source code from the original engine. The main loop is much more tricky to get right, however, as it is supposed to be re-entrant (luckily, only two levels deep) since some GPL commands expect to be able to call it to provide for interactivity while they execute (for instance, when playing animations). The original engine uses two loop status variables to distinguish between the various states of the loop and whether the current instance is a top-level loop or a nested one. It was my decision to mirror the original code for the loop much more closely because of that. (After GSOC, I’ll look into writing some unit tests for the engine and then try to refactor away some of the nastiness in the design without completely breaking everything. Wish me luck on that.)
Besides loop statuses, I also had to implement animation callbacks because the engine relies on the animations themselves to signal the nested loop to exit after they had played to the end. Several crucial GPL commands were also implemented (along with some library/API refactoring to accomodate those). And of course, lots of bugfixes, some of them crucial for correct game logic.
The result of this work is that the game now starts “naturally” after the intro has played, characters can talk, rooms can be switched by clicking on exits and the game is interactive during animations. It also made headway for the things I’m going to do this week, which leads us to…
This week I’ll be concentrating my efforts on smoothing out some rough edges with what I’ve done; some annoying, some more serious. The annoying ones are mostly minor bugs (like incorrect font colour when characters talk and incorrect placement of text), but hey, those have to be fixed too! The other, more serious bug is that, currently, the loop can be called recursively more than two times if you click on things too much before the animations have played through. This is the primary thing I have to fix before moving on so I can properly debug new problems when they arise.
After I’m done with that, I’ll have some fun with two other major gameplay features — item handling and dialogues. After that, we’ll have something that’s dangerously close to playable *gasp*!
Also, now that I’ve proofread the post, I can see that I’ve neglected to mention one thing: Robert and I agreed that I should probably leave proper walking with the dragon alone for now as it’s not critical for the game to work and the original implementation is a bit convoluted. I’ll get back to it once I’m done with the more important stuff listed above.
Stay tuned!