PC speaker issues in Ultima games

User avatar
NLeseul
Posts: 8
Joined: Tue Jan 12, 2021 3:53 pm
Has thanked: 4 times
Been thanked: 1 time

PC speaker issues in Ultima games

Unread post by NLeseul »

Just wanted to point out a strange issue I'm seeing with Ultima V on the MiSTer here and make sure I'm not crazy, before I submit a proper bug report.

Basically, Ultima V has fairly distinctive PC speaker sound effects. On the MiSTer, a lot of these effects don't play back properly, and just sound like clicking.

I was poking at the Verilog code trying to find out if something was missing in the PC speaker implementation, and I accidentally found in the process of testing that if I force the system bell to ring before I boot the game, all the PC speaker effects seem to work completely fine.

Here's a video I recorded to demonstrate the issue. Note that I'm using the modified BIOS from this thread; I don't think the system bell would ring when I fill up the DOS prompt input without that.

Another thing that happens in the video is that it takes a few seconds for the PC speaker to fade in when sound starts playing in either case. That may be related.

Any suggestions on what might be going wrong here? I suspect the PC speaker control signals are initialized to a bad value on boot somehow, and ringing the system bell gets them to settle into the state that the U5 application expects. I didn't see any obvious problem in the Verilog, though. I'm happy to attempt a fix for this, if anyone can help narrow down where I should start looking.
ExCyber
Posts: 217
Joined: Sun May 24, 2020 3:33 pm
Has thanked: 11 times
Been thanked: 66 times

Re: Ultima V has bad PC speaker effects... unless I ring the system bell first

Unread post by ExCyber »

I suspect that this might actually be a bug in Ultima V that was masked by typical BIOSes of the day. Early PCs would always beep at startup, 1 beep to indicate a successful POST. Ultima V might inadvertently rely on timer channel 2 having been initialized by that BIOS subroutine. I'm not 100% sure, but I think the BIOS used with ao486 only initializes timer channel 0. If you have a reasonably full DOS available, does doing the following before launching Ultima V produce the results you expect?

Code: Select all

C:\>debug
-o 43 B6
-q
User avatar
NLeseul
Posts: 8
Joined: Tue Jan 12, 2021 3:53 pm
Has thanked: 4 times
Been thanked: 1 time

Re: Ultima V has bad PC speaker effects... unless I ring the system bell first

Unread post by NLeseul »

Ooh, I did not think about missing initialization in the BIOS. Yes, I can confirm that poking 43h with that value gets the speaker into a good state. This works with the standard ao486 BIOS as well as the modified one.

The same issue and the same fix pertain to Ultima VI as well, fwiw.

As a workaround, is there a way to include that debug command in autoexec.bat?
ExCyber
Posts: 217
Joined: Sun May 24, 2020 3:33 pm
Has thanked: 11 times
Been thanked: 66 times

Re: Ultima V has bad PC speaker effects... unless I ring the system bell first

Unread post by ExCyber »

Redirection seems to work. For example, stick the following in a file (e.g. c:\initspk.dbg):

Code: Select all

o 43 B6
q
and then run debug like this:

Code: Select all

debug < c:\initspk.dbg > NUL
User avatar
NLeseul
Posts: 8
Joined: Tue Jan 12, 2021 3:53 pm
Has thanked: 4 times
Been thanked: 1 time

Re: PC speaker issues in Ultima games

Unread post by NLeseul »

(Editing the thread title so I can keep this in one thread.)

I'm seeing a similar issue in Ultima I. It sounds similar to what I was getting in U5, but neither forcing the speaker to beep nor poking the speaker port seems to affect the results in this case. Video is here.

Note that 2, 3, and 4 all seem to work okay as far as I've been able to tell.

Edit: I think this issue is specific to using the MOSLO.EXE utility from the Ultima Collection CD to slow the run speed of the application down. I was trying to do that so I could keep my ao486 settings consistent. It seems that if I don't use MOSLO and instead turn off the L1 cache in the core settings, I get correct speaker sounds at a more or less reasonable speed. So that approach seems fine. Doesn't even appear to be necessary to beep the speaker first for this one.
jamesfk
Posts: 7
Joined: Mon Sep 28, 2020 11:31 am

Re: PC speaker issues in Ultima games

Unread post by jamesfk »

Hi everyone,

Sorry to jump on this thread, but I have a very similar issue with Hillsfar.

I was about to reply that this debug idea has fixed it, but instead, I'm seeing very strange results:

If I load the game without the debug script, audio like riding the horse around the map, walking around Hillsfar, and exploring houses all work fine - these noises tend to be bassy or rhythmic ones. However, any more melodic noises such as opening a chest or leaving a building make a muffled scratching noise and are not at all right.

If I run the debug script first, then I no longer get any noises at all for the walking/riding - however, all the melodic noises are now absolutely fine.

I've tried using Qbasic to make some sound first, and this also has the same effect as the debug script.

Do you think this is an obscure bug in the core/bios - or is there a further initialisation I can do using debug to get the PC speaker fully initialised? At the moment I seem to have one type of sound working or the other, but never both.

As a control, the exact same copy of Hillsfar works perfectly in Dosbox, whichever type of sound.

Thanks for any ideas - I'll keep investigating and post if I find a solution.

James
Post Reply