Skip to content
sean-gugler edited this page Apr 9, 2021 · 4 revisions

Ultima IV megafix for Commodore 64

Greetings, traveler! Here you will find the most bug-free edition of Ultima IV for the Commodore 64 ever known. May you enjoy the experience such as it was always meant to be.

Download the playable disk image at https://github.com/sean-gugler/u4remastered/releases/

This release would not have been possible without the incredible work done by those who came before me. All credit to MagerValp and Genesis Project where due. My improvements are mere inches on top of their miles.

What have I done?

I never imagined I'd embark upon such a deep tour through the inner workings of this game. All I wanted to do was play it again, having fond memories from when it was new. I was thrilled to discover the fan-made Remastered edition!

Then it crashed.

I had invested dozens of hours and was more than halfway through the game ... all wasted. Every time I tried to resume my game, it crashed within a few seconds. I was crushed.

Eventually I came back to it. I figured I had run afoul of some weird bug that nobody ever noticed, or maybe some flaw in the emulator itself. So when a new version of VICE was released, I tried again. Once again made it more than halfway through the game and—you guessed it—crashed. Different place in the world, different progression, different character spec, but the same old frustration as before; can't resume because it just consistently crashes every time I try.

My eyes narrowed. Now I was determined to push through. After all, VICE comes with a built-in debugger....

Like Alice and her rabbit hole, my curiosity and naïveté propelled me to investigate whether I could hack my way around this minor hurdle, completely unaware of the Wonderland that awaited me once I embarked upon this journey. The fascination with uncovering multiple decades-old flaws—and more amazingly, finding in myself the power to repair them—sent a jolt of excitement through my every nerve. I had stumbled upon the quest behind the quest: to become the Dungeon Master himself, the Wizard of Oz, Neo from the Matrix. To solve the puzzles not planted by the maker for discovery, but by the maker's maker.

Once I found a workaround for the immediate crash issue and was able to resume my game, I hastily played it through to completion and then turned my temporarily-satisfied eye toward the larger problem of fixing not just the symptom of the crash but its very cause.

You may wonder, as I did ... how could such a bug have lingered so long? I distinctly remember completing the game on a genuine C64 back in 1986 without encountering this sort of impassable crash, nor with any patches or debuggers at my disposal. The game had not suffered any reputation loss over the years from anyone else complaining about this. Why now? Why after so many bugs had already been fixed?

It was the emulator after all.

More accurately, it was my use of an emulator. The way I was using it, to be more precise. Let me take a moment here to exonerate the VICE emulator from all blame for my troubles—it does its job all too well. In fact, the bug I had run afoul of would have been possible back in the day. It was just extremely unlikely. The culprit was a fearsome digital nuisance known all too well to programmers around the world, a type of error so irksome yet commonplace it lent its name to an entire web site dedicated to programmers helping each other overcome hurdles: the stack overflow.

In the 1980s, anyone would have hit the same crash if they'd simply left the machine on, running the game, and never shut it off.

Of course nobody did that. Or at least nobody I'd heard of. And if they had, they'd be forced to reboot the machine from scratch, resuming their game from the disk, and starting with a fresh stack, waiting for another 10,000 moves or so before it overflowed again. Hopefully they'd been following the sage advice of the day to save early and often so they didn't lose too much progress when it ultimately crashed.

Things are different with emulation. Nowadays, it's far more economical to save your game by saving the state of the entire emulation. Restoring such a state is instantaneous; much faster than rebooting the virtual machine, reloading the game program, and reloading the saved game state from an emulated disk image. From the viewpoint of the emulated machine, restoring the state this way is very much like never shutting it off. Any overflowing of the stack gets preserved right along with everything else. I was a victim of modern efficiency, ironically.

So what was causing the overflow? Ready for this?

It was the moongates.

They're sort of vital to the game. Use them more than about 100 times without rebooting and you're courting disaster.

Behind the curtain

Once I'd cracked the case on what had caused this particular stack overflow I was determined to fix it. The hours I threw into studying how the Remaster was constructed, how to rebuild it from source myself, and eventually how to successfully modify it, were extraordinarily satisfying. I was hooked. Having fixed one issue I began hunting around the code for similar issues. And while I was there, why not learn a bit about the game design itself? Like, what exactly were the situations that caused you to gain or lose virtue? By how much? How much damage does a magic sword really do, anyway?

I was surprised to discover that the 3-room inn is a total rip-off. I was delighted to find some subtle design choices that simplified the architecture without sacrificing immersion in the game, shortcuts that weren't really noticeable until they were pointed out (ever taken a really good look at the questions the NPCs ask you? Notice any patterns?) I applauded the cleverness of some subtle tricks, like using the sprite for altars as a blit mask for the campfire animation. And I learned the game had lied to me.

That's right—the game LIED to me.

If you consider the manuals part of the game—and back when they were new, most people would—there are some outright untruths in there. What a great lesson in world-building! If done carefully, setting the stage for contradiction between false early knowledge and correct late knowledge can bestow feelings of great mastery rather than disappointment. It's also a great way to mask limitations of the practical implementation and code design if you drop suggestions that there might be greater things than are actually taking place. It leaves room for the player to spin a more richly nuanced picture of the realm in their mind and turns a setback (we can't support feature X!) into an asset (let them convince themselves X is happening unseen). To avoid spoiling this experience I'll leave the rest unsaid and let you discover them for yourself.

I will say I was astonished to find that some beliefs I'd held about Britannia and its workings turned out to be the product of chance, imagination, and very coincidental timing. I was convinced the game was enforcing certain ethics rules that turned out to be purely roleplay in my mind. The game set up a framework in which certain player behaviors could be encouraged without needing to explicitly enforce them. That's an impressive feat.

Most of all, I was elated to realize I could share what I'd been doing with the rest of the world. The deeper I went, the more I studied, the more flaws I was able to uncover and eliminate. I never set myself the foolish goal of 100% defect-free, I just kept going until I had seen and comprehended nearly all of the code. And so I feel fairly comfortable stating that most if not all of the bugs have been eradicated in this edition. And I look forward to someone else proving me wrong.

Meanwhile, if you want to peek behind the curtain into the excruciating details of what I've discovered, I hope you will enjoy reading the extensive technical notes for Version 2.3.0.

Clone this wiki locally