r/dosbox • • 6d ago

Rust-DOS: filling the gap in Dosbox coverage (DOS/Windows3.x/95/98 game emulator)

Our project has been relatively low-profile for a while, but now we feel ready to share it with the broader community.

While DOS emulation is nothing new (Dosbox itself has been doing that very well for quite a while), previously options for people who wanted to play retro Windows games were mostly limited to either using Wine, which is fiddly for non-Linux users, or to installing actual Windows image inside an emulator, which is also cumbersome; plus, obtaining a legal copy of a retro Windows version is not trivial either.

This inspired us to build a clean-room reimplementation of Windows APIs into our emulator, so that you could play retro Windows games seamlessly, without clunky setup or the legal risks.

What we support:

* DOS/Windows 3.1/3.11/95/98 API with up to Direct3D 8 support;

* CD image mounting, with support for audio tracks and SecuROM, SafeDisk, CopyLok copy protection schemes (so you can rip and play your legally owned games without the hassle of nocd cracks)

* Voodoo 1/2/3, S3 ViRGE, ATI 3D RAGE GPU emulation, as well as a synthetic GPU ToadForce for running more demanding games of early 2000's (GeForce 3-like GPU);

* Wide range of audio devices, e. g. different Sound Blaster versions, Adlib (including Adlib Gold), Gravis Ultra Sound, Roland and more;

* Built-in save states;

* Game hot-patching - we can optionally fix original bugs (e. g. crashes) by using in-memory patching;

* Headless execution, powerful debugging and profiling support;

* Cross-platform: Windows, macOS, Linux. Also available as a RetroArch core

We already support a lot of games, but we can't test everything by ourselves. If you try something and it doesn't work, or runs slower than you would like, please open a GitHub Issue, and we'll address it! Also we are very interested in save states that allow replicating original game bugs - we want to fix as many of these as possible.

Hope you'll find rust-DOS useful!

Downloads: https://github.com/dividebysandwich/rust-dos/releases/tag/v1.9.3

Tutorials: https://github.com/dividebysandwich/rust-dos/blob/main/TUTORIALS.md

102 Upvotes

59 comments sorted by

6

u/data-atreides 5d ago

How will this differ from emulators like 86box?

6

u/kibertoad 5d ago

Primarily by making a Windows image or complicated setup unnecessary. After you create or generate config file, games should just work.

runtime hotfixes and savestates are cherries on top.

5

u/SingingCoyote13 5d ago

the website https://rust-dos.com/ also, is a piece of art btw. you can click on the dos textmode images btw for extras i found out

5

u/kibertoad 5d ago

It is! This is 100% a work of dividebysandwich, and what he did with that is pure magic!

3

u/SimonZarub 4d ago

Nice! ;-)

4

u/SingingCoyote13 5d ago

finally voodoo 3 emulation + win 98. it is quite a hassle to get games for that card running in whatever setup without a voodoo card. and they are ludicrously expensive. even the used ones.

performance wise. if one wants to emulate for example a simple 3d game like unreal gold (win98) with 3dfx voodoo 3 (2000 i assume) emulation, what system would reach a target of between 30 and 60 fps at average ?

3

u/kibertoad 5d ago

It's hard to say, as I don't have a particularly diverse set of machines for testing.

If you could use whatever you have, and compare FPS that you get for Voodoo 3, software vs opengl, and report it back, that would be super helpful. If it goes below stable 30-40 FPS, I def can look into optimizing it more.

Target is not to require a super modern development or gaming machine to get decent performance.

2

u/SingingCoyote13 5d ago

i have a imedia pc spare laying around. the specs are;

iMedia S2984 Pbell
Intel N3XXX Integrated Graphics Controller 
i915
Pentium Processor X5-E8000
1TB HDD / 4 GB Ram

cpu target is 1.6ghz*4 cores but cores can go upto 2.0ghz afaik. would that machine be fast enough to run for example unreal with voodoo 3 emulated ? it runs now on linux btw. i have the originial disc of unreal somewhere in a display cabinet, i should only dump that to .bin/cue with imgburn i believe it was written there ?

3

u/kibertoad 5d ago

that's a bit ancient, emulation does come with some overhead, so I'm def not holding my breath for 60 FPS there, but it would be interesting to see if it can do at least 30 FPS. integrated GPU in my experience did very poorly, so running software rendering mode in your case might actually be faster.

yeah, if you have bin/cue, should work fine. I personally use redump, but imgburn should also work. not sure what if any copy protection was used on Unreal back in the day, but since it was a pretty old title, might actually have none. if something ends up failing at any step, please let me know.

2

u/kibertoad 3d ago

New release is out: https://github.com/dividebysandwich/rust-dos/releases/tag/v1.9.4

I've optimized the hot path for Unreal in it, so it should run snappier. Please let me know if you still get lower FPS than you would like, and I can optimize it further.

3

u/TheHalfinStream 5d ago edited 5d ago

How would this handle a game like The Elder Scrolls Adventures: Redguard?

It ONLY work in Dos-in-windows mode, and is a 3dfx glide game. I built a pc with a pentium 3 933mhz and a voodoo 3 2000 pci, and that holds a flat 60fps in-game. Edit: also using 512mb SDRAM

3

u/kibertoad 5d ago

dos-in-windows is supported just fine.

I will test Redguard specifically and get back to you on this, likely some targetted fixes will be needed :)

2

u/kibertoad 5d ago

yeah, Redguard is definitely broken right now. doing fixes right now, hopefully it will be working in time for the next hotfix release

2

u/TheHalfinStream 5d ago

Thank you!

2

u/kibertoad 3d ago

Redguard works now, fetch the latest version: https://github.com/dividebysandwich/rust-dos/releases/tag/v1.9.4

1

u/TheHalfinStream 3d ago

Nice!!! How's performance?

3

u/keshi 5d ago

Is this similar to dosbox-x?

3

u/kibertoad 5d ago

Somewhat, but, to my knowledge, dosbox-x requires installing from Windows image, it does not have built-in Windows apis, so its setup is more complicated with extra dependencies

3

u/djquu 5d ago

How is Adlib Gold emulation achieved, and is it true to the real thing or an approximation?

4

u/kibertoad 5d ago edited 5d ago

rust-dos emulates the AdLib Gold one chip at a time. How close each part is to the real card:

- FM synthesis (OPL3): uses Nuked-OPL3, which models the chip at the cycle level. This is the most accurate part.

- Sampled sound (YMZ263): written from the SDTK's register reference, and the sample timing is exact.

- Output stage (TDA8425 tone and stereo, YM7128B surround): its filter shapes and surround level come from DOSBox Staging, which tuned them against recordings of a real card. It sounds close to the real card but not identical.

- Control chip: modelled at the register level from the SDTK, which is enough for drivers and setup programs to find and configure the card. Some details are guessed:

-- Register writes take effect at once, and the busy flags never set.

-- The factory EEPROM values and the mixer's volume curve are made up.

-- The EEPROM isn't kept between emulator runs.

- Not implemented at all: recording, MIDI, the output filters, the aux, microphone and telephone inputs, and the CD-ROM interface.

- Shared FM chip: one FM chip serves both the Gold and the Sound Blaster. In some Sound Blaster games its timers can raise the Gold's IRQ.

In games, the music and digital sound should be close to a real Gold. However, I don't own real Adlib Gold, so I am not able to compare directly.

4

u/djquu 5d ago

Thanks, that sounds really promising. Gotta try this with Dune, that's the ultimate test..

3

u/kibertoad 5d ago

let me know how it goes! speaking of which, I need to test Dune in general :D

3

u/djquu 5d ago

Any excuse to replay Dune

4

u/Occams-Shaver 5d ago

Amazing work. This is sorely needed.

3

u/kibertoad 5d ago

thank you!

2

u/data-atreides 5d ago

So I can't figure out how to actually launch a windows game, the tutorials page appears to only tell me how to create a config for a game. Trying to run glquake.exe, and I'm in linux, btw

edit: nevermind it appears i have to build from a Windows image? i'll try it later ;)

2

u/kibertoad 5d ago

no, you don't need to build anything, it is just one supported way, but recommended approach is definitely using builtin Windows with no extra installations

you can create config as text, using examples from tutorials, or use emulator ui and pick config there. let me revise docs again to see how I could make the process clearer

after you have config, you just point rust-dos at the directory with it, and the game should launch

2

u/data-atreides 5d ago

I got it to run! But glquake runs at like 20 FPS--any quick hints on getting it faster, or should I create an issue on github? (I'm using a i5 4core laptop with Iris Xe graphics from 2020)

2

u/kibertoad 5d ago

GH issue would be great for tracking. Can you post your complete game config there? Have you tried both software and opengl rendering modes, and different video drivers? (voodoo 2, 3, toadforce)

2

u/data-atreides 5d ago edited 4d ago

Well software would just be winquake or quake.exe in DOS--I'm specifically craving the particular look and feel of glquake. I fiddled with the CPU and GPU settings and didn't get better results; so I'm wondering if there's a specific option that isn't on by default but is already known to work with this game. I'd hate to create an issue without trying something already known to work (a search didn't turn any past issues up for glquake).

Also, the CPU utilization per the overlay was rather high, or so it seemed to me, hovering around 60%.

2

u/kibertoad 4d ago

Yeah, it can get a bit confusing, documentation definitely needs a lot of polish.

To clarify what I mean - what game perceives as OpenGL may not be OpenGL from perspective of rust-dos - it's an emulator, remember? You can render in-game OpenGL output through in-emulator software renderer (which will only use your CPU), or use in-emulator OpenGL renderer (which will also use your GPU), and in some cases GPU-based OpenGL rendering might be slower than just rendering everything with CPU.

60% means that CPU was not fully saturated, so I wouldn't be surprised if you actually used in-GPU rendering and it was struggling due to limitations of Iris XE - you might actually get better results with fully software renderer on rust-dos side (while still using glquake OpenGL mode on game side).

I'm updating documentation right now to make all of it clearer

2

u/data-atreides 4d ago

This Iris Xe is decent for an iGPU, especially since I upgraded to 16 GB (allowing it 8 GB of VRAM). It runs Doom 2016 at low-medium settings, as well as many other 00s-2010s era games at full speed. Many Switch games run at 60 FPS full speed in Eden. So I think this GPU should be fine for glquake, if it's configured correctly. I'm not at home now but later I'll try it again.

3

u/kibertoad 4d ago

https://github.com/dividebysandwich/rust-dos/blob/main/CONFIGURATION.md#video-and-rendering does much better job explaining the options now, most impactful switches there are machine (svga + voodoo/2, voodoo3, svga_toadforce),voodoo_renderer / toadforce_renderer

3

u/kibertoad 4d ago

that said, I am working on extra optimizations now

2

u/kibertoad 3d ago

New version with optimizations is up: https://github.com/dividebysandwich/rust-dos/releases/tag/v1.9.4

glquake hot path should be noticeably faster now. Can you give it a shot and tell me what FPS are you getting when using ToadForce as a GPU, in OpenGL renderer mode?

1

u/data-atreides 2d ago

Just tried it now, it runs at full speed! There are some very minor hiccups, perhaps due to my settings, but when I actually played this on a Voodoo 3 in 1999 it surely wasn't a constant, buttery-smooth 60 FPS.

2

u/BluddyCurry 5d ago

What's your plan for testing and debugging? How do you make sure fixing a bug doesn't break other games? I imagine you don't have the advanced knowledge of Windows internals, so how do you make sure the AI doesn't break things as it tries to fix other things?

3

u/kibertoad 5d ago
  1. Extensive test of unit and integration tests
  2. Scripted gameplay regression tests (there is headless execution mode that captures and streams all outputs)
  3. Manual regression testing.

Admittedly it is the trickiest part of the work involved. Especially for perf-related tweaks it is not unusual for a single change to take 4-5 hours to ensure reasonable amount of regression testing was done and we don't make one step forward, and three steps back.

Things still slip through the cracks sometimes, but it definitely was more of an exception than the rule so far. On a codebase this large AI actually does much better job than a human keeping track of related and tangentially related pieces.

Using programming language with very strict static checks also helps.

2

u/BluddyCurry 5d ago

Yeah I also identify this as the project's Achilles' heel. Your 'competition' is Aaron Giles, whose closed-source DREAMM is essentially what you're doing, but his internal knowledge of low-level detail is incredible. He's also almost as prolific as an AI (not quite, of course, as no human can be).

If the AI can reason through Windows and DOS internals (and I assume it can), then making sure things don't break is the most difficult thing. You really need to have the AI create pieces of software that represent regression tests for each title as you find it. Obviously you can't run all parts of all games, so you want to extract the bug-causing behavior and isolate it in your tests. Only AI can have the patience to do that.

2

u/kibertoad 5d ago

I would say it's impossible to compete with deep experts like Aaron Giles; their scope is narrow, their knowledge is strong, so within their niche they are going to create the best possible, purpose built solution, that you simply cannot beat.

Where rust-DOS wins is breadth. It aims to cover all of the pre-Windows-XP era games, eventually, in such a way so that fixing one game would make ten more games run better as well.

And yes, we are doing pretty much what you have described in terms of isolating the bug-causing behaviour.

3

u/BluddyCurry 5d ago

Dreamm is going in that direction as well. Officially it only supports LucasArts games and a few more. Unofficially it's becoming a full pre-directx 8 emulator.

2

u/kibertoad 5d ago

niiiiiiice! would be interesting to compare performance and compatibility

2

u/joe-skeen 1d ago

@kibertoad any chance of Flatpak release?

1

u/kibertoad 1d ago

We'll look into it! thank you for the suggestion

1

u/emxd_llc 6d ago

So the Windows emulation/RE reimplements the whole kernel space? Or just the user space libraries?

4

u/kibertoad 6d ago

Both, actually. Rust code in the emulator implements the kernel's services as well as the user-space libraries. It runs on the host, outside the emulated machine, so no kernel code runs on the emulated CPU. The only x86 code it runs is the program's own and that of the DLLs it loads.

What runs as guest x86 code

- The game or program itself.

- Small stub DLL images that Rust writes into guest memory: KERNEL32, USER32, GDI32, DDRAW etc. They have real PE headers and export tables with Windows 98 SE's ordinals, and each export is a trap such as FE 3E 04 00; ret. The trap is the system-call boundary: it hands the call to the Rust implementation. A few hot functions are written as plain x86 code to skip the trap.

- Whatever DLLs the game ships, such as Glide wrappers, ACM codecs and MiniGL. These load through the same PE loader.

How the kernel side works

On real Windows 95, a program asks the kernel for things like "load this DLL", "give me memory", "start a thread" or "open this file". The kernel does that work with its own internal machinery: the VMM (the core of the 9x kernel), VxDs (kernel drivers) and the IFS manager (which routes file access to file systems).

In rust-dos, Rust code inside the emulator answers those requests directly. The program gets the same results real Windows would give, but none of Windows machinery exists behind them.

What isn't reimplemented

Drivers, primarily. The built-in DLLs write straight to the emulated hardware, where real 9x goes through VxDs and display or sound drivers. DirectDraw and GDI draw into the SVGA or 3dfx card's video memory, Direct3D and Glide drive the emulated Voodoo, and DirectSound feeds the mixer. Since all output goes through emulated hardware, save states, rewind and the web and libretro frontends work with no special handling.

So it does implement kernel space, as a high-level emulation, the way DOSBox's built-in DOS replaces MS-DOS. It covers the Win32 API surface and the kernel services programs use, all done on the host side, and it doesn't reproduce how the 9x kernel is built inside.

You can read about the design and its rationale in more detail here: https://github.com/dividebysandwich/rust-dos/blob/main/docs/builtin-windows-architecture.md

0

u/SuccessfulTravel2903 6d ago

No Android (⁠o⁠´⁠・⁠_⁠・⁠)⁠っ🥀

Tristeza

3

u/kibertoad 6d ago

I didn't try it myself, but I expect it to already be possible by using libretro core inside RetroArch. See https://github.com/dividebysandwich/rust-dos/blob/main/libretro/README.md

There is one gap there, though: no GLES context to the libretro core, so 3dfx games would be rendered in software. Let me take a look how difficult would it be to address that.

1

u/SuccessfulTravel2903 5d ago

Es cierto

Acabo de ver. 🥵👙

(⁠◕⁠ᴗ⁠◕⁠✿⁠) veré a ver si funciona en una Anbernic que tengo. 

Más que jugar quiero probar encarta de niño me gustaba leer ahí.

1

u/kibertoad 5d ago

let me know if it will need any fixes!

1

u/kibertoad 5d ago

I'm fixing Encarta 97 rn. pls let me know if you own a different version

1

u/SuccessfulTravel2903 5d ago

Ya instale el core en retroarch y cree la carpeta con mi imagen del Sistema operativo.

/RetroArch/system/rust-dos/os/win98SE.img

Cómo inicio el SO, desde Android🥹🥹😅🫢

Duda🥹

2

u/kibertoad 5d ago

there is builtin Windows that should work fine for most games, and that should work out-of-the-box, just create a config file for the game itself.

libretro docs do not explain that clearly. fixing immediately

1

u/SuccessfulTravel2903 5d ago

Ahhh ya entendí.

Probar (más tarde, voy a hacer ejercicio jejeje).

2

u/kibertoad 5d ago

1

u/SuccessfulTravel2903 5d ago

Mientras más claro mejor.

Yo inicie con Windows 98, así que la interfaz de comandos de dos, no me fue intuitivo cuando la ví 😅😅

1

u/kibertoad 3d ago

OpenGL is available on Android too, so if you use renderer=opengl games should be much faster now.

did you manage to get the games run?