The Ultima 4 Upgrade: Fix for Endgame Bug

Voyager Dragon has made a smallish update to the Ultima 4 Upgrade as well this week, addressing an issue that crops up during Ultima 4’s endgame sequence:

For those who’ve attempted to play through Ultima IV with the latest U4 Upgrade (v1.2 or v1.3), you may have experienced a bug that prevented you from completing the end game. The problem hits after you answer all the virtue questions and obtain the codex, but the game appears to freeze in the middle of describing the Quest of the Avatar.

The problem stems from an inaccurate file size for file LARGE.XMI…we’re reserving 1148 paragraphs and loading LARGE.XMI into this space. Since there are 16 bytes/paragraph this equates to 18,368 bytes. However LARGE.XMI is actually 21,208 bytes in size. So we might have a buffer overrun. But, that’s assuming we attempt to load the full file size into that memory space. However…We’re loading less bytes than the actual size of LARGE.XMI. So now, when the game goes to read the last entry in the file, it crashes. This last entry is of course the end-game tune.

This wasn’t a problem in the U4 Upgrade v1.0 or v1.1 as the XMI files were all separate files and loaded individually.

With this in mind, the solution that Voyager came up with is as follows:

The solution is to increase the size of both values. I used a value of 0x0800 paragraphs for the memory size and 0x8000 for the file size which equates to 32kB. That’s more than enough space to fit the LARGE.XMI file.

This particular upgrade isn’t part of the Exodus Project, but Voyager has released the fix on his BitBucket repository all the same; he has incorporated it into his alternate music patch. You can grab it from BitBucket, or from the project entry here at the Codex.