1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//! Rust high level bindings to [`dos-like`][1],
//! the library/framework for writing applications that look
//! like MS-DOS programs from the 1990's.
//!
//! [1]: https://github.com/mattiasgustavsson/dos-like
//!
//! This API was designed to expose the original C API
//! while maintaining Rust's idiomatic naming and safety guarantees.
//! Note however, that some functions in the framework
//! cannot be made completely memory safe
//! without introducing runtime overhead.
//! In any case, should you find it useful,
//! the low level unsafe bindings are available in [`dos_like_sys`].
//!
//! ## Using
//!
//! **This crate does not function as a regular library,**
//! because it already defines a `main` function by itself.
//! Attempting to create your own executable with its own `main` function
//! will result in a linker error.
//! For the building process to work,
//! the main source file needs the `no_main` attribute
//! and to define an extern C function `dosmain` instead.
//!
//! ```no_run
//! #![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_run
//! #![no_main]
//!
//! dos_like::dos_main! {
//! // your code here
//! }
//! ```
//!
//! Moreover, 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.
//! Add this to your Cargo.toml and any other custom profile:
//!
//! ```toml
//! [profile.dev]
//! panic = "abort"
//!
//! [profile.release]
//! panic = "abort"
//! ```
//!
//! ## Cargo features
//!
//! - **`disable-screen-frame`**:
//! when enabled, compiles `dos-like` so that
//! the CRT screen frame around the viewport does not appear.
//! The other CRT screen effects will remain.
pub use *;
pub use *;
pub use *;
pub use *;
pub use dos_like_sys;
/// Calls `waitvbl`, which waits for a vertical blanking signal.
///
/// This should usually be called once per frame.
/// Checks whether the application should shut down.
///
/// # Example
///
/// A typical application loop inside `dosmain` would look like this:
///
/// ```no_run
/// # use dos_like::shutting_down;
/// while !shutting_down() {
/// // your code here
/// }
/// ```
/// General error type for file loading functions which can fail
/// Declares and defines the main application function.
///
/// This macro can be used as an alternative to declaring `dosmain` manually.
///
/// # Example
///
/// This:
///
/// ```no_run
/// #![no_main]
///
/// dos_like::dos_main! {
/// println!("Hello")
/// }
/// ```
///
/// Expands to this:
///
/// ```no_run
/// #![no_main]
/// # use std::os::raw::{c_char, c_int};
///
/// #[no_mangle]
/// pub extern "C" fn dosmain(_argc: c_int, _argv: *const *const c_char) -> c_int {
/// println!("Hello");
/// 0
/// }
/// ```