• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 5 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Emulator of the IBM PC running DOS written in Rust

Build Status

DOS-Emulator

VGA Window and Debugger CLI

While this is inspired by DOSBox, it is not a direct port. Many features are implemented differently or not at all. The goal was just to implement enough to play one of my favorite games and learn some rust and emulation principles along the way.

Run the Example

Checkout and build the emulator or download a prebuilt binary from the releases tab.

git clone https://github.com/Lichtso/DOS-Emulator
cd DOS-Emulator
cargo build --release

Download and unpack the guest application and start the emulator.

curl -GOL https://cors.archive.org/cors/msdos_Robot_Junior_1991/Robot_Junior_1991.zip
mkdir -p DOS/TOM/ROBJUN
unzip -j Robot_Junior_1991.zip RobotJun/ROBJUN.EXE RobotJun/ROBJUN.MUC RobotJun/ROBJUN.SCN RobotJun/ITEMJE.CRN RobotJun/ITEMJG.CRN RobotJun/SASJ.CRN -d DOS/TOM/ROBJUN/
target/release/dos-emulator -C DOS/ DOS/TOM/ROBJUN/ROBJUN.EXE

Then setup your keyboard layout (press 'k' in the CLI and follow instructions below) and enjoy the game!

Command Line Interface

  • Ctrl-c: Quit
  • p: Pause (enter the debugger)
  • k: Enter the keyboard-mapping-tool

Debugger

Note: The terminal needs to be at least 80 characters wide to correctly display the debugger.

  • p: Profile instructions (and save them to a file)
  • a: Data overview to DS:SI (string source)
  • s: Data overview to SS:SP (stack pointer)
  • d: Data overview to ES:DI (string destination)
  • Page-Up / Page-Down: Scroll data overview
  • F5: Continue (leave the debugger)
  • F10: Step over / out (places a one-shot break point behind the current instruction)
  • F11: Single step

Keyboard-Mapping-Tool

Keyboard-Mapping-Tool Type in the CLI to control the keybinding process and type in the video window to register a scancode at the selection. The tool will automatically advance the selection to the next entry so you can continuously type in the keys it highlights. Note: The terminal needs to be at least 147 characters wide to correctly display the tool.

  • Escape: Leave the keyboard-mapping-tool
  • Arrows: Navigate / select
  • Backspace: Unregister the selected entry

Supported Software

Currently only the Game of ROBOT episodes 0, 1, 3 and 4 are known to be playable. As host macOS is tested and Ubuntu builds. Windows does not support ANSI escape sequences which are needed by the CLI (inside the termion dependency).

Architecture

Overview Diagram

There are the following threads (without the ones spawned by dependencies):

  • GUI: Renders the video output and handles the input events of the window
  • Audio: Synthesizes the signal of the sound blaster and beeper
  • CLI: Debugger and actual emulation

Evaluation

In release mode on a 2,6 GHz Intel Core i7 the emulation does 10 to 19 (up to 23 using PGO) million instructions per second. As this is much faster than the original hardware was, the emulation is done in batches with sleeps in between, in order to have a consistent timing behavior and not burn the host CPU unnecessarily. This way about 45% of one host CPU core and 32 MiB of RAM are used. The code base is about 5 KLoC of rust (without lookup tables and bindings). Some threads read data from others using raw pointers which is definitely not the rust way but an easy workaround.

References

These are the sources I used.

ISA / CPU

BUS

BIOS

DOS

Sound / Audio

Video / Graphics / Mouse

More Repositories

1

netLink

Socket and Networking Library using msgpack.org[C++11]
C++
214
star
2

CCWT

Complex Continuous Wavelet Transform
C
152
star
3

curve_cad

Blender Addon: Bezier Curve CAD Tools for CNC Milling & Laser Cutting
Python
119
star
4

hair_guides

Blender Addon: Particle Hair Guides
Python
66
star
5

contrast_renderer

Contrast is a WebGPU based 2D render engine written in Rust
Rust
64
star
6

splatter

Splatter is a WebGPU based gaussian splatting engine written in Rust
Rust
60
star
7

geometric_algebra

Generate(d) custom libraries for geometric algebras
Rust
44
star
8

straight_skeleton

Blender Add-On: Straight Skeleton
Python
43
star
9

JSC-Standalone

Cross platform standalone binaries and build instructions of WebKit-JavaScriptCore
C
33
star
10

VulkanFFT

Fast Fourier Transform using the Vulkan API
C
31
star
11

riscv-llvm-templates

Code templates to get started experimenting with the RISC-V LLVM toolchain
C
14
star
12

UnikernelExperiments

TCP/IPv6-enabled Pine64+ bootloader
C++
13
star
13

MacInject

Command line tool and library to inject and execute program code into another process
C
10
star
14

WebSpectrogram

Web app port of "Complex Continuous Wavelet Transform"
HTML
8
star
15

FreeFormGradients

WebGL2 based implementation of distance transform and diffusion curves
JavaScript
8
star
16

rift

C
5
star
17

RiscV

Risc-V: Dis/Assember and Emulator
C++
4
star
18

complex_continuous_wavelet_transform

Complex Continuous Wavelet Transform
Rust
4
star
19

WebGL2Experiments

Prototypes and Game Design Documents for an idea I had long ago.
Rust
3
star
20

PrismCNC

Free auto CNC software written in JS and C++
C++
2
star
21

parallel_compute_algorithms

Python
1
star
22

Olypsum

A 3D game engine I wrote back when I was in high school
C++
1
star
23

LinuxSetup

Configuration: Arch Linux + Btrfs + Sway (Wayland) on a MacBook Pro
Shell
1
star
24

Digital-Fluids

WebGL cell based fluid simulation
JavaScript
1
star
25

DramaticCountdown

Red on black background seven segment countdown to a selectable date and time
HTML
1
star
26

ngCNC

Successor of the PrismCNC
JavaScript
1
star
27

rp2040_template

rp2040 Project Template in Rust
C
1
star