VOGONS


SBEMU: Sound Blaster emulation on AC97

Topic actions

Reply 2060 of 2065, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
ockiller wrote on 2026-11-27, 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 2065, by ockiller

User metadata
Rank Newbie
Rank
Newbie
jmarsh wrote on 2026-11-27, 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 2065, by DarthSun

User metadata
Rank Member
Rank
Member
ockiller wrote on 2026-11-27, 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 2026-11-27, 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 2065, 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.

Reply 2064 of 2065, by crazii

User metadata
Rank Oldbie
Rank
Oldbie

I don't think it's quite possible for an “unreal monitor”

let'ssay We can hack the mode switch and setup a protected mode client(dpmi env) for it and successfully hack Its interrupt handlers. the key problem is, the unreal mode is still in real mode. the addressing is different from protected mode. there is no way to map real mode segment to protected mode selectors because real mode segment has a increment of 1 for 16bytes aka 1 paragraph. but pm selector's minimal numerical increment is 8. the left 3 bits are RPL and LDT( TI aka table indicator).
I think you can talk to AI for possible solutions but I ain't thinking of any.

it might be possible If 4 selectors in gdt and another 4 in ldt to workaround the TI bit but the 2 RPL bit cannot overcome.

Toshiba Satellite Pro 4300 - YMF744, Savage IX
Toshiba Satellite 2805-S501 - YMF754, GeForce 2Go
IBM Thinkpad A21p - CS4624, Mobility Radeon 128
main: Intel NUC11PHKi7C Phantom Canyon: i7-1165G7 RTX2060 64G 2T760PSDD

Reply 2065 of 2065, by Plombo

User metadata
Rank Newbie
Rank
Newbie
crazii wrote on Yesterday, 14:40:
I don't think it's quite possible for an “unreal monitor” […]
Show full quote

I don't think it's quite possible for an “unreal monitor”

let'ssay We can hack the mode switch and setup a protected mode client(dpmi env) for it and successfully hack Its interrupt handlers. the key problem is, the unreal mode is still in real mode. the addressing is different from protected mode. there is no way to map real mode segment to protected mode selectors because real mode segment has a increment of 1 for 16bytes aka 1 paragraph. but pm selector's minimal numerical increment is 8. the left 3 bits are RPL and LDT( TI aka table indicator).
I think you can talk to AI for possible solutions but I ain't thinking of any.

it might be possible If 4 selectors in gdt and another 4 in ldt to workaround the TI bit but the 2 RPL bit cannot overcome.

I had to do some more reading about x86 and segments, but now I understand what you’re saying, and why non-V86 protected mode can’t emulate real-mode addressing.

As an aside, I’m not taking your suggestion to ask AI about it. Whenever I’m searching for semi-obscure technical information like this, Google always pops up with an (unwanted) AI answer, and about 75% of the time, that answer is completely wrong. If none of the AI’s training data contains a solution to the problem, and it does contain someone on a forum claiming it isn’t possible, the AI will usually just claim, with unearned total confidence, that the problem can’t be solved. It has no framework for actually creating novel solutions to novel problems. So AI is really not useful at all for things like this.

I haven’t given up, though. Instead, I’ve started thinking about it from another angle: is there any real need to switch the task out of V86 mode at all?

In any mode (protected, V86, even real mode), the processor raises a general protection fault on memory accesses whose effective address is outside of the segment limit. In protected mode, the segment limit is set by the descriptor table. In real and V86 mode, the segment limit is forced to 64 KB by the CPU. “Unreal mode” works around this in real mode by tricking the CPU into thinking the segment limit is the entire size of available memory, instead of 64 KB.

The segment limit trick doesn’t work in V86 mode, so accesses above 1 MB will always cause a general protection fault. But V86 monitors work in the first place by handling general protection faults! The “unreal monitor” knows where the memory access was supposed to go, and can access whatever memory it wants, so it can just run the instruction itself, just like V86 monitors do with I/O instructions and such.

Even better, since the application’s upper memory accesses are all routed through the monitor this way, the unreal monitor can do software-based virtual memory management. If the application tries to use an upper memory block that TSRs have been loaded into, the monitor can allocate any actually free block and transparently map the application’s accesses to that.

There is, of course, a significant performance cost to running an interrupt handler every time the application tries to access upper memory. But I doubt it matters much when factoring in the vastly greater speed of 21st-century CPUs compared to the humble 386/486 that “unreal mode” games were targeting.

This approach is really a lot simpler than the previous one, so I’m feeling better about its chances of working than I did with the first version. It does still have the same problem with SMSW being unprivileged, though, and will need the same solution.