There is another bug I noticed, I think to do with the follow.ego implementation. Pretty much any character that tries to chase ego just seems to randomly move, more like a wander, but not even that. Every step seems to be randomly placed, like its doing some kind of weird dance. I hadn't noticed any follow.ego issues in other games so far. I plan to go back and confirm that its working in earlier games, and if so, then take a closer look at the KQ4 LOGIC scripts for the rooms where this happens to see what is going on.
This bug is now fixed. It turns out that my Interpreter was updating the stopped flag too often. It should only update it when the step time counter hits zero. It was correctly updating the animated object's position on the counter hitting zero, but for updates to the stopped flag, it was doing this on all values of the step time counter. The result was that it thought the animated object was stopped (i.e. hadn't moved) in the current cycle (which is true, but is of no relevance if it hasn't tried to update the animated object's position in that cycle). This lead to the seemingly random movement, because the follow ego logic chooses a random direction if the animated object is stopped by something. So my Interpreter was mistakenly thinking it had been stopped when it hadn't and therefore making it select a random direction to avoid whatever had supposedly stopped it.
I also fixed two other bugs I found in KQ4: One of these was in any room with a zombie. The whole game slowed down to a complete halt for about 10 seconds whenever the first zombie came out of the ground. Turns out this was due to the Logic script trying to start the same sound 20 times in a row. I assume that in the original AGI interpreter, this didn't have any impact on performance, e.g. perhaps it just immediately started playing the sound again from the start with no noticeable effect, but in my Interpreter, it generates the WAVE file data on the fly before playing a sound and doing this 20 times in quick succession was slowly things down to a crawl. I considered caching generated sounds, which perhaps I might still do for the current room. For now I've got a check in there that if it tries to play a sound that is already playing, it just leaves it playing and does nothing. This fixes the issue in the zombie rooms.
The other issue was in the KQ4 Help screen. It was being displayed with a black background where the original game has a white background. This was being caused by a difference in how the background colour is used when switching to the text screen. The original Interpreter sets the text attribute value using the currently set background and foreground, and then uses the background part of the text attribute when clearing the screen. I changed my Interpreter to do the same and now this issue is also resolved.
There is only one other issue I know of now that affects KQ4, and also SQ2, in fact it is possible that it affects all games but so far I have only observed it in those two games. For some reason the "Save game" option in the menu stops responding after a while. All other menu options continue to work. I had a similar issue a while back that affected a number of menu options, but this new issue seems to affect only the "Save game" option. That will be the next issue I try to track down.