VOGONS


Ultima VII Frame Limiter Patch

Topic actions

First post, by ptrie

User metadata
Rank Newbie
Rank
Newbie

There have been discussions on this board in the past about the performance of this game [1]. I recently started playing it for the first time, but have been frustrated by the stutter that occurs every few steps when moving around, even with the "optimal" configuration of a 486 33 plus RAM drive. Thanks to the open source UltimaHacks [2], and the toggleable frame limiter in Serpent Isle, I was able to patch The Black Gate with a similar solution.

Serpent Isle has a loop that waits until 6 firings of a 60 Hz timer have passed before updating the game world, giving a maximum of 10 per second. Thankfully The Black Gate also uses a 60 Hz counter, so it wasn't too difficult to add a similar waiting loop. I'm not confident there are no bugs, but so far I'm happy with it.

I've uploaded a video of walking around the starting area in the game to show the new smooth movement that's possible [3]. It was captured with DOSBox with core=dynamic/cycles=max, but I also got good results with a Pentium in PCem. I turn the frame limiter off at the end of the video so you can see how fast the game would be running without the patch. You can compare the game speed with user Cloudschatze's video taken on a 486 33 with a RAM drive [4].

I've attached a patch file which can be applied with the UltimaHacks Applier website [5] that contains just the frame limiter, always enabled. I have a version that is toggleable and contains all the other UltimaHacks patches on my GitHub fork of the project [6].

[1] Measuring Performance in Ultima VII : The Black Gate The ultimate Ultima 7 machine
[2] https://github.com/JohnGlassmyer/UltimaHacks/
[3] https://youtu.be/rRdBOJPj--8
[4] https://youtu.be/K_YRY-nSI7Q
[5] https://johnglassmyer.github.io/UltimaHacks/
[6] https://github.com/ptrie/UltimaHacks/raw/mast … hacks/u7bg.hack

EDIT: Uploaded version 2 of the patch. Hex edit byte 19Ah to change the delay value (e.g. 06 -> 0A).

Last edited by ptrie on 2021-04-11, 14:25. Edited 1 time in total.

Reply 2 of 33, by SScorpio

User metadata
Rank Member
Rank
Member

Awesome work. I wonder how many hours have been lost over the years with people trying to tweak this into a playable state with slowdown tools and the like.

Reply 3 of 33, by shamino

User metadata
Rank l33t
Rank
l33t

This is outstanding. I remember having to finish this game on a Cyrix 6x86. Mo'slo made it passable, but I still felt like it was too fast. I had played much of the game on a very slow 386SX, then my 486 was too unstable to play the game at all. Thus still needing to finish it when the 6x86 came along, and not being happy with how fast it was. I was used to the in-game days being long, and suddenly they were zipping by.
This patch would have been perfect, and if I play the game again I'll definitely use it.

Scope creep suggestion - would it be possible to make the frame limiter adjustable to user preference?

Reply 4 of 33, by mothergoose729

User metadata
Rank Oldbie
Rank
Oldbie

This couldn't have come at a more perfect time for me! I'll give this a shot soon... I am waiting on a sound card to arrive for my slot 1 machine.

Reply 5 of 33, by ptrie

User metadata
Rank Newbie
Rank
Newbie

Thanks for the kind words everyone!

shamino wrote on 2021-04-08, 15:17:

Scope creep suggestion - would it be possible to make the frame limiter adjustable to user preference?

I thought about this too - at 10 Hz , it's possible to run around pretty quickly, and characters can die in battle before you know it - what would it be like at a slower rate? Just now I briefly tried 7.5 Hz, and it's still a good experience, maybe even superior. Going down to 5 Hz, my first impression is that movement is too slow, but some may prefer it.

I'll think about adding an in-game selector, but for now the simplest way to do this is to hex edit the patch - byte 210h is 06. This is how many ticks of the 60 Hz timer need to pass, so change it to 08 for 7.5 Hz and 0C for 5 Hz, etc. Of course the source code is available too for those comfortable with recompiling.

Reply 6 of 33, by newtmonkey

User metadata
Rank Oldbie
Rank
Oldbie

This is great work! U7 is one of most finicky games to play when it comes to speed, so this goes a long way toward resolving that. Thanks so much!

I'd be interested in an in-game selector also, but will hex edit for now to try 7.5 Hz.

Reply 7 of 33, by ptrie

User metadata
Rank Newbie
Rank
Newbie

OK I've added in-game adjustment of the frame limiter, leveraging some of the cheat menu code in the game. I'm really happy with how this turned out, thanks for suggesting it! Pull up the prompt with Alt+8. This time I've only made a version that includes all the UltimaHacks changes, since separating the key input handling would be extra work. You can experiment with different delay settings with this one, and then hex edit your final choice into the original patch if you don't want the other changes.

https://github.com/ptrie/UltimaHacks/raw/mast … hacks/u7bg.hack

Reply 8 of 33, by Dagar

User metadata
Rank Newbie
Rank
Newbie

This is excellent! Very much appreciated ptrie.

Works great in DOSBox with your settings above. Also tested it out in PCem v17 using MS-DOS Version 6.22, 486 Award SiS 496/497, Intel Pentium OverDrive/63 and it also works great.
I usually have my PCem DOS config set to use a i486/DX266 but still had hitching even with the frame limit patch so I bumped it up to Intel Pentium OverDrive/63 to fix that.

I like the value of 8 over the default of 6 - what would I hex edit to make that the default?
EDIT: seen your post above about the value to hex edit.....now sorted at 8.

Reply 9 of 33, by newtmonkey

User metadata
Rank Oldbie
Rank
Oldbie

I just tested this on my actual DOS machine (P133) and it works great! I found a setting of 10 to be just right, anything lower seemed a hair too fast to me, though that may be based on my experience playing the game back in the day on a very low spec PC haha.

Reply 10 of 33, by mothergoose729

User metadata
Rank Oldbie
Rank
Oldbie

This community is awesome. A 30 year old game patched. Major kudos to you sir!

Reply 11 of 33, by ptrie

User metadata
Rank Newbie
Rank
Newbie

I think the patch can cause a crash or hang if the overlay segment where I put the delay loop is unloaded. I've uploaded a v2 which overwrites some (I hope) unused code in a regular segment instead. I'm still getting used to this 16-bit world!

I also wanted to call attention to NewRisingSun's patch to the game's MT-32 driver ((Yet Another) Ultima 7 & MUNT issue). I noticed using MT-32 sound caused occasional stutters and long load times even on a fast machine with the frame limiter, so I looked into it and was about to post a 3 byte patch, but quickly searched and found that a fix was posted here 10 years ago! Not sure how well known it was, but with these two patches I'm able to get stutter-free gameplay.

Thanks for sharing your preferred delay values - I'm using a slower one in my playthrough now. I think I'll leave the default as it is though to match Serpent Isle.

Reply 12 of 33, by ptrie

User metadata
Rank Newbie
Rank
Newbie

I finished the game with the frame limiter. I used a setting of 10 (6 fps) most of the time, because I noticed the ticking sounds from the in-game clocks occur once per second at this speed. The only major issue I encountered was getting physically stuck and unable to move a couple of times. I had to either use the Hack Mover cheat to move an object out of the way, or reload a save. My guess is that this is a preexisting bug, but I mention it just in case.

One minor issue that remains on a fast machine is that the spellcasting "bark" disappears too quickly. Other barks, like hunger complaints and battle cries, are all slowed appropriately, but the spell incantations must go through a different code path. Even on my emulated 486 you can notice they're faster, but on a modern PC they're unreadable. Serpent Isle has this issue too (although other mages' spells show as expected).

For Serpent Isle, here are the hex edits I've made:

SI.EXE 197BF (06 -> 0A) the frame limiter's delay value, adjust to your preference
SNDDRVRS.DAT 4AF3 (E3 -> EB) to jump over the MT-32 rev. 0 delay loop which causes stutter and long load times
MT32MPU.ADV 78F (E3 -> EB) same thing but for the intro

Reply 13 of 33, by newtmonkey

User metadata
Rank Oldbie
Rank
Oldbie

That's great! Thank you for not only creating the patch, but for testing it all the way through.

Reply 14 of 33, by badmojo

User metadata
Rank l33t
Rank
l33t

This is terrific, thanks for sharing! I've been using a combination of AT-SLOW and disabling L1 cache on my 233MHz Cyrix machine but this patch looks to make that a thing of the past, which is freaking sweet. I settled on a value of 8 for Black Gate and it looks just right to me.

👍👍

Life? Don't talk to me about life.

Reply 15 of 33, by appiah4

User metadata
Rank l33t++
Rank
l33t++

This invalidates my attempts at trying to figure out a way to slow every system I own to DX2-50 speeds 😁 But I wholly appreciate it nonetheless.

EDIT: At the risk of sounding like a total idiot, how do I applly the .patch files? 🙁

Reply 16 of 33, by badmojo

User metadata
Rank l33t
Rank
l33t

Lolz don't worry it took me a few double takes to work it out too - use the website kindly provided above:

[5] https://johnglassmyer.github.io/UltimaHacks/

Select your U7.EXE, then select the patch file, then patch it. Now your .EXE is ready to go with the patch inserted (you gotta click on the link to download it).

The tricky-er part is hex editing the .patch (i.e. before you patch the .EXE) to change the speed (if you feel the need), this is the relevant comment above:

Hex edit byte 19Ah to change the delay value

Grab yourself a hex editor, open the .patch file, search to hex location 19A, and then change the default (06) to a higher number to reduce the speed - I'm using 08.

Life? Don't talk to me about life.

Reply 17 of 33, by mothergoose729

User metadata
Rank Oldbie
Rank
Oldbie

Adding to the chorus, I tried the patch with the "10" setting and it works great. 10 feels kinda sluggish but I think it is probably what the devs had intended.

I also found another patch that is compatible with this one. It removes the "real mode" dependency by modifying ENDGAME and MAINMENU executable. For my setup I found slowing down to a fast 386 with this frame limiter fixes all of the minor issues that frame limiter doesn't... like the occasional animation playing too fast.

U7DCP - Ultima VII DOS Cache Patch

It might also make it easier to play the game with memory managers too, I'm not sure. Anyway, thanks again!

Reply 18 of 33, by badmojo

User metadata
Rank l33t
Rank
l33t

Yeah '08' is a tad fast I've decided after playing a little more - NPCs zip about quite quickly. I'm going to try 9 or 10.

Life? Don't talk to me about life.

Reply 19 of 33, by static-

User metadata
Rank Member
Rank
Member

Oh my god this patch is amazing!! This + UltimaHacks is just absolute perfection!! Thank you ptrie!! I'm running this on native DOS on my Via V3 and no issues after 3hr of play so far. Prior to this I had to mess with bus and cpu clock and could never get it quite perfect. As cool as Exult is, I just love the original feel, and these patches really fix all the QoL issues and speed problems. Amazing to see new stuff like this in 2021. Time for a full playthrough. Cheers