Writing bindings to `dos-like` for Rust: some lessons learned

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • rusty-dos

    A Rust skeleton for an MS-DOS program for IBM compatibles and the PC-98, including some PC-98-specific functionality

  • Now, being both a Rust enthusiast and MS-DOS nostalgic, I have, multiple times, tried closing the gap on writing applications for real DOS systems in Rust. Unfortunately, this is not without issues, and there is not a clear path on how to go with this yet. More on existing efforts here.

  • dos-like

    Engine for making things with a MS-DOS feel, but for modern platforms

  • So when I had some spare time the past weekend, I decided to do something a bit different: bring to Rust an existing framework that lets you write applications which look like they are DOS applications. dos-like, made by Mattias Gustavsson, is like a small engine for writing modern applications with the look & feel of MS-DOS programs. So basically, when using this framework, we end up with applications that run on modern hardware and operating systems all the same, but with deliberate video effects and audio that bring us back to that era, including large pixels, CRT distortion, text and graphics video modes, and synthesized (Sound Blaster 16) or MIDI (Sound Blaster AWE32) music. It was written in C, mostly as a single file with some other statically linked dependencies. The project also comprises a few fun examples, such as a proof-of-concept FPS inspired by Wolfenstein 3D, a point-and-click adventure, a voxel renderer, and even a music tracker.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • dos-like-rs

    Rust bindings to the dos-like framework

  • By creating direct bindings to the C interface (dos-like-sys), followed by a more high-level abstraction, it becomes possible and (hopefully) intuitive to write applications of this sort in Rust! So I did that! In this post, I will now share a small collection of technical topics that I felt worth sharing about the conception of these bindings.

  • wajic

    WebAssembly JavaScript Interface Creator

  • Alas, although there is WebAssembly support in the original dos-like, it is still not supported in the bindings for Rust. It would require a Rust toolchain to integrate with WAjic, which I am pretty much unfamiliar with. If you have any idea on how to achieve this, I would love to know.

  • rust-bindgen

    Automatically generates Rust FFI bindings to C (and some C++) libraries.

  • The majority of functions in the framework were pretty easy to translate to Rust. With the low-level bindings already built automatically from the C declarations via bindgen, all that was left was to encapsulate them in non-unsafe functions with idiomatic parameter types. A great deal of these functions received plain C ints as parameters. Instead of those, the parameter types were chosen based on what they represented:

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts