My work for this week was mainly concentrated on the main game loop and the bytecode interpreter.
When implementing other parts of the engine, I tried following specifications and implementing the correct semantics, and not just transliterating the source code from the original engine. The main loop is much trickier 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 accommodate those). And of course, lots of bug fixes, 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 of the rough edges in the current code; some annoying, others more serious. The annoying ones are mostly minor bugs (like incorrect font colour in dialogues and incorrect placement of text), but hey, those have to be fixed too! The other, more serious, bug is that the main game loop can currently get called recursively more than two times if you click on things too many times 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 as 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!