Rust bindings to the dos-like framework

Overview

dos-like for Rust   Latest Version Documentation Continuous integration status dependency status

This project provides access to Mattias Gustavsson's dos-like framework, so as to write DOS-like applications in Rust.

Rotozoom example written in Rust

How to use

This crate is not a regular library. It defines a main function on its own. For the executable linking to work correctly, the main source file needs to declare no main and define an extern C function dosmain instead.

#![no_main]

#[no_mangle]
pub extern "C" fn dosmain() -> i32 {
    // your code here

    0
}

A utility macro is available as an alternative to declaring the function:

#![no_main]

dos_like_rs::dos_main! {
    // your code here
}

See the examples for a typical application structure, which are based on the original dos-like examples.

A C compiler needs to be available (uses cc). The dos-like framework is statically linked, just like in a C program.

Since the initiator is based on routines in C, this also means that panic unwinding will not work, so it is best to configure your project to abort on panic. In your Cargo.toml:

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

Check out the dos-like README for additional requirements.

Cargo features

  • disable-screen-frame compiles dos-like so that the CRT screen frame around the viewport does not appear.

Platform support

These bindings have been tested on Linux and Windows. WebAssembly and Mac OS support is currently not guaranteed (but your assistance on this would be greatly appreciated!).

Building

When working on this project, ensure that the git submodule in dos-like-sys/dos-like was populated (either by cloning with --recurse-submodules or by calling git submodule update --init). Some of the examples do not work unless with this submodule checked out.

License and attribution notice

The Rust bindings are licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

The dos-like framework remains licensed as defined in the original LICENSE file.

Comments
  • Mouse functions

    Mouse functions

    input::mouse_x() and input::mouse_y() underflow when the cursor is at the top or left edge of the virtual monitor.

    It also seems that input::mouse_rel_x() and input::mouse_rel_y() always return 0 (at least on X11), and are also unsigned, which would cause wrong values for left/up movement.

    bug 
    opened by Kapouett 2
  • Drawing functions should take signed positions

    Drawing functions should take signed positions

    Drawing functions like line or draw_poly take u16 coordinates, breaking shapes that are partially off-screen. This behavior is not present in dos-like as it uses signed integer coordinates.

    opened by Kapouett 1
  • Minor documentation improvements

    Minor documentation improvements

    • add wait_vbl() in example which is typically called inside an app loop
    • clarify certain text functions that they only work in graphics mode
    • fix documentation of center_text_xy
    opened by Enet4 0
  • Fix compilation under MacOS and make it easy to run the examples

    Fix compilation under MacOS and make it easy to run the examples

    This PR achieves two things:

    1. it fixes compilation under x86-based MacOS (tested on MacOS 12.3.1, with dependencies installed according to the dos-like installation instructions)
    2. it makes it easy to run the examples, by leveraging cargo. Simply cd examples/rotozoom && cargo run. Downside is that the example source code has been modified such that the examples search for their assets in a nested subdirectory of a parent directory (e.g. ../../dos-like-sys/dos-like/files/sound/soundcard.wav) which is arguably a little awkward.

    Note that I have not verified that this does not break anything, and neither do I know if this works on ARM Macs. But "it works on my machine"!

    opened by jorisvddonk 0
  • Use i32 in graphics coordinates

    Use i32 in graphics coordinates

    This changes all graphics functions to receive screen pixel coordinates as i32 instead of u16. Resolves #4.

    In the process, I also clarified that some parameters are width and height (rectangle and bar), and fixed the functions draw_poly and fill_poly, which were just written incorrectly.

    bug 
    opened by Enet4 0
  • Input key release support

    Input key release support

    • update dos-like to the latest revision, which has support for key release events
    • add KeyEvent type
    • change read_keys so that it returns key events
    • add keyboard demo example
    breaking change 
    opened by Enet4 0
Releases(v0.3.1)
  • v0.3.1(Jul 26, 2022)

    Fixes and Enhancements

    • Fix compilation under MacOS (#7 @jorisvddonk)
    • Minor documentation improvements (#8)

    Full Changelog: https://github.com/Enet4/dos-like-rs/compare/0.3.0...v0.3.1

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Mar 29, 2022)

    What's Changed

    • swap_buffers was changed to no longer return a slice, so that it can be used without unsafe. For the function which also returns a slice, see swap_buffers_and_get. (#6)
    • Changed pixel coordinates to use i32 instead of u16. This also fixes draw_poly and fill_poly, which never really worked. (#5)
    • Fixed mouse functions to use i32 instead of u16. (#3 @Kapouett)

    Full Changelog: https://github.com/Enet4/dos-like-rs/compare/0.2.3...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.3(Mar 17, 2022)

    Fixes

    • Added null pointer checks in create_sound, as passing invalid parameters returns a null pointer and attempting to use the Sound value could lead to undefined behavior. Instead, this function panics. try_create_sound was added, which returns an Option<_> instead.

    Enhancements

    • Memory layout of resource types Sound, Music and Image were changed to take advantage of the fact that the raw pointer is never null.

    Full Changelog: https://github.com/Enet4/dos-like-rs/compare/0.2.2...0.2.3

    Source code(tar.gz)
    Source code(zip)
  • 0.2.2(Mar 17, 2022)

    Fixes

    • Added null pointer checks in Music::create_mus. Attempting to use a Music value with a null pointer could lead to undefined behavior. Instead, this function panics if it could not load the music data from the slice.
    • Added Music::try_create_mus which does the same as above, but returns an Option<Music> instead (None if it could not load).

    Enhancements

    • [dos-like-sys] Update dos-like revision from a676ea74 to 2bceb960 (2022-03-07).

    Chores

    • Updated CI linux jobs to update packages before installing SDL2 and libGLEW (#1)

    Full Changelog: https://github.com/Enet4/dos-like-rs/compare/0.2.1...0.2.2

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Mar 17, 2022)

  • 0.2.0(Mar 8, 2022)

    New

    • All functions from the native dos-like API have now been covered in the high level crate!
      • Implementations were categorized in the following modules: video input, sound, and music.

    Fixes and Enhancements

    • Significantly improved documentation.
    • Build script was tweaked to work on Windows.
      • Mac OS is untested; WebAssembly is not yet supported.
    • Reduced package size of dos-like-sys by excluding unneeded contents.

    Full Changelog: https://github.com/Enet4/dos-like-rs/compare/0.1.0...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Mar 5, 2022)

Owner
Eduardo Pinho
Software Engineer @ BMD Software; PhD in computer science; medical imaging informatics; Rust, JavaScript, C++ enthusiast.
Eduardo Pinho
Um Web Scrapper para extrair as soluções dos exercícios do Driven HUB com seus respectivos enunciados

hub_scrapper Um Web Scrapper para extrair as soluções dos exercícios do Driven HUB com seus respectivos enunciados, convertendo-os para Markdown. ⚠️ A

Davi Feliciano 4 Oct 7, 2023
Safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework.

Introduction The dynamorio-rs crate provides safe Rust bindings to the DynamoRIO dynamic binary instrumentation framework, essentially allowing you to

S.J.R. van Schaik 17 Nov 21, 2022
A conky-like system monitor made for the sole purpose of teaching myself rust-lang.

Pomky A conky-like system monitor made for the sole purpose of teaching myself rust-lang. It is not as configurable, modular, or feature packed as con

null 3 Nov 17, 2022
A Rust-like Hardware Description Language transpiled to Verilog

Introduction This projects attempts to create a Rust-like hardware description language. Note that this has nothing to do with Rust itself, it just ha

Benjamin Stürz 4 Sep 1, 2022
Idiomatic Rust implementations for various Windows string types (like UNICODE_STRING)

nt-string by Colin Finck <[email protected]> Provides idiomatic Rust implementations for various Windows string types: NtUnicodeString (with NtUnicode

Colin Finck 5 Jun 4, 2023
A lisp-like language written in Rust

Lispy A lisp-like language with an implementation written in Rust. Usage Open a repl with: $ lispy repl Run a file with: $ lispy run ./examples/hello_

Lino Le Van 4 Oct 1, 2023
A Matrix bot which can generate "This Week in X" like blog posts

hebbot A Matrix bot which can help to generate periodic / recurrent summary blog posts (also known as "This Week in X"). The bot was inspired by twim-

Häcker Felix 43 Dec 17, 2022
Like wc, but unicode-aware, and with per-line mode

Like wc, but unicode-aware, and with per-line mode

Skyler Hawthorne 34 May 24, 2022
A cargo plugin for showing a tree-like overview of a crate's modules.

cargo-modules Synopsis A cargo plugin for showing an overview of a crate's modules. Motivation With time, as your Rust projects grow bigger and bigger

Vincent Esche 445 Jan 3, 2023
Embeddable tree-walk interpreter for a "mostly lazy" Lisp-like scripting language.

ceceio Embeddable tree-walk interpreter for a "mostly lazy" Lisp-like scripting language. Just a work-in-progress testbed for now. Sample usage us

Vinícius Miguel 7 Aug 18, 2022
An OS like a lump of mud.

slimeOS An OS like a lump of mud. Run Clone this repo, and just do make run, and then you will see: [rustsbi] RustSBI version 0.3.0-alpha.4, adapting

波门 2 Dec 15, 2022
A gitweb/cgit-like interface for the modern age

rgit See it in action! A gitweb/cgit-like interface for the modern age. Written in Rust using Axum, git2, Askama and Sled. Sled is used to store all m

jordan 14 Apr 8, 2023
Control your .env like a boss

envctl ?? Take full control over your .env environment variables usage $ envctl --help Environment Variable Control Usage: envctl <COMMAND> Commands

Yuichiro Luke Smith 4 Apr 18, 2023
Fast fail2ban-like tools for parsing nginx logs

Fast2ban This is simple fail2ban-like replacement written in Rust. Usage: ./fast2ban # reads default config.toml from current directory ./fast2ban <co

null 36 May 10, 2023
Rust bindings to the Wolfram Symbolic Transport Protocol (WSTP)

wstp Bindings to the Wolfram Symbolic Transfer Protocol (WSTP) library. This crate provides a set of safe and ergonomic bindings to the WSTP library,

Wolfram Research, Inc. 10 Nov 1, 2022
alto provides idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX).

alto alto provides idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX). WARNING Because Alto interacts with global C state via dynam

null 80 Aug 7, 2022
Safe, idiomatic bindings to cFE and OSAL APIs for Rust

n2o4 The n2o4 crate provides safe, idiomatic Rust bindings to the APIs of cFE and OSAL, the libraries of the Core Flight System (cFS). IMPORTANT NOTE

null 3 Aug 29, 2022
Safe, efficient, and ergonomic bindings to Wolfram LibraryLink and the Wolfram Language

wolfram-library-link Bindings to the Wolfram LibraryLink interface, making it possible to call Rust code from the Wolfram Language. This library is us

Wolfram Research, Inc. 28 Dec 6, 2022
Complete bindings to the raspicam C++ library

raspicam-rs Rust bindings to the amazing C++ raspicam library (with optional OpenCV utilities)! This is a followup to a Rust-based robotics project I

blusk 8 Oct 17, 2022