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
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
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 42 Oct 23, 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 415 Dec 1, 2022
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 Nov 15, 2022
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. 27 Sep 13, 2022
Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed.

integra8 Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed. | This repo is in a "work in progress"

exceptional 3 Sep 26, 2022
A recommender systems framework for Rust

Quackin Release the quackin! ?? Quackin is a recommender systems framework written in Rust. This is a young project, which means two things: There wil

Christopher Vittal 8 Dec 8, 2021
A developer-friendly framework for building user interfaces in Rust

Reading: "Fru" as in "fruit" and "i" as in "I" (I am). What is Frui? Frui is a developer-friendly UI framework that makes building user interfaces eas

Frui Framework 1.1k Nov 26, 2022
An RPC framework developing tutorial

Mini Lust 系列教程 好奇如何从零造出来一个 RPC 框架?本教程将带你一步一步写出来一个 Rust 版 Thrift RPC 框架。 教程说明 从第二章开始每章节都会附带代码。 这个代码是在上一章节的基础上写的,文档里一般会告诉你增加了哪些东西,但是如果你想详细地对比到底哪里变动了,可以自

null 450 Dec 3, 2022
Incremental Program Analysis Framework

IncA Overview IncA is a program analysis framework. It comes with a DSL for the definition of program analyses and the runtime system evaluates progra

Tamas Szabo 70 Nov 24, 2022
A backend framework for building fast and flexible APIs rapidly.

Andromeda Andromeda is a backend framework for Rust, to simplify the development of the kinds of basic API services that we developers have to build s

Framesurge 5 Nov 21, 2022
Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Larry Fantasy 608 Nov 29, 2022