VOGONS


SBEMU: Sound Blaster emulation on AC97

Topic actions

Reply 2060 of 2063, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
ockiller wrote on Yesterday, 09:39:

Back on topic, at those ~400 MHz, Descent is a bit too fast, but playable, but sound is already playing at irregular speed, and so does the framerate/game speed. I haven't tried this with software based slowdown utilities to get in the optimal range for Descent but I suspect that sound will get even more irregular. That's why I wondered if a software based slowing down utility could have a mechanism to slow down code on a per-program basis. And I still use SBEMU too.

Have you tried just using the -640x480 command line switch for Descent? The higher resolution (and use of VESA) makes the game's framerate much more acceptable on faster machines.

Reply 2061 of 2063, by ockiller

User metadata
Rank Newbie
Rank
Newbie
jmarsh wrote on Yesterday, 10:43:

Have you tried just using the -640x480 command line switch for Descent? The higher resolution (and use of VESA) makes the game's framerate much more acceptable on faster machines.

I just tried it, after getting the v1.5 patch, and it's almost perfect! Thank you!
I need to target ~1 GHz for the music to play mostly at full speed. But the faster the CPU, the lower the mouse sensitivity is. 1 GHz is a good compromise.

Well, I can totally live with that and my idea is much less needed, but it could still improve the situation a bit further, in case someone has an idea whether it could be possible.

Reply 2062 of 2063, by DarthSun

User metadata
Rank Member
Rank
Member
ockiller wrote on Yesterday, 17:52:
I just tried it, after getting the v1.5 patch, and it's almost perfect! Thank you! I need to target ~1 GHz for the music to play […]
Show full quote
jmarsh wrote on Yesterday, 10:43:

Have you tried just using the -640x480 command line switch for Descent? The higher resolution (and use of VESA) makes the game's framerate much more acceptable on faster machines.

I just tried it, after getting the v1.5 patch, and it's almost perfect! Thank you!
I need to target ~1 GHz for the music to play mostly at full speed. But the faster the CPU, the lower the mouse sensitivity is. 1 GHz is a good compromise.

Well, I can totally live with that and my idea is much less needed, but it could still improve the situation a bit further, in case someone has an idea whether it could be possible.

I’ll give this a try. I didn’t even know it runs at 640...

The 3 body problems cannot be solved, neither for future quantum computers, even for the remainder of the universe. The Proton 2D is circling a planet and stepping back to the quantum size in 11 dimensions.

Reply 2063 of 2063, by Plombo

User metadata
Rank Newbie
Rank
Newbie

This week, I got back to thinking about “unreal mode” (a.k.a. flat real mode) games, and whether there’s a way to make them work with SBEMU. I’ve been reading the Pentium Pro manual, and it looks like there might be? But I will need some input from someone more knowledgeable than me.

From what I understand, addressing is the only meaningful difference between a task in V86 mode and a task in "normal" ring 3 protected mode. So, just like how the V86 system virtualizes 16-bit real mode with 16-bit ring 3 protected mode, it should be possible to virtualize a 32-bit real mode task with 32-bit ring 3 protected mode.

  • When a V86 task tries to enter unreal mode, instead of terminating it with a GPF like normal, switch the task into 32-bit protected mode with the same CPL/IOPL as the V86 task had. This gives it access to 32-bit addressing without breaking the model of 386 protected mode. It’s then handed over from the V86 monitor to the unreal monitor running within the same process. “Unreal monitor” is a term that I just made up, but it should be self-explanatory.
  • Just like a V86 monitor, the unreal monitor catches GPFs, and, when appropriate, emulates the instructions that caused them. The range of instructions emulated has to be different (and probably much harder to implement), though, since unreal mode can do things that ordinary 16-bit real mode can’t.
  • Interrupt handling and port trapping can be done on the ring 3 protected-mode task just like they would on a V86 task. This means the unreal mode program can work with SBEMU and other PCI sound drivers. (If it couldn’t, this entire exercise would be pointless.)

This all sounds simple enough when explained in a high-level overview like this, but the details add some complications. For one thing, the SMSW instruction is unprivileged [*], so a separate solution is needed to defeat the V86/protected mode detection that most unreal mode games have. Maybe there are some other unprivileged instructions that would also need to be patched or trapped with breakpoints. I don’t know.

So the question is, do any of those complications actually make it impossible to do? I haven’t found any such problem yet, but as someone who only recently started learning about how x86 stuff works, I’m not exactly an expert. So hopefully someone more knowledgeable can tell me either a) that this approach can work, or b) why it can’t.

[*] This is only mostly true. There actually is a CPU flag, CR4.UMIP, that makes SMSW generate a GPF in V86 mode and unprivileged protected mode. Unfortunately, that flag was first introduced in Ice Lake and Zen 2, less than 10 years ago! So most processors will need per-game patches or breakpoint lists for these instructions. However, it should be possible to generate either one automatically by running the game in an emulator and recording the locations of the relevant instructions.