summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-10-28 20:25:01 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-10-28 20:29:12 +1300
commit1a830a3d1b9d99653322d5ae49ea8165de7ed9d0 (patch)
tree798e77b6fcf2438b1c2538a67efe856a2f7cb979 /src/lib.rs
parent03c4b069e1806af256730639cefdae115b24401a (diff)
downloadbedrock-pc-1a830a3d1b9d99653322d5ae49ea8165de7ed9d0.zip
Rewrite emulatorv1.0.0-alpha1
This is a complete rewrite and restructure of the entire emulator project, as part of the effort in locking down the Bedrock specification and in creating much better tooling for creating and using Bedrock programs. This commit adds a command-line argument scheme, an embedded assembler, a headless emulator for use in non-graphical environments, deferred window creation for programs that do not access the screen device, and new versions of phosphor and bedrock-core. The new version of phosphor supports multi-window programs, which will make it possible to implement program forking in the system device later on, and the new version of bedrock-core implements the final core specification.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..4ff35eb
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,34 @@
+#![feature(bigint_helper_methods)]
+#![feature(unchecked_shifts)]
+#![feature(seek_stream_len)]
+#![feature(io_error_more)]
+
+mod debug;
+mod devices;
+mod emulators;
+mod metadata;
+
+pub use debug::DebugState;
+pub use devices::*;
+pub use emulators::*;
+pub use metadata::*;
+
+use std::num::NonZeroU32;
+use std::time::Duration;
+pub const BATCH_SIZE: usize = 1000;
+pub const MIN_TICK_DURATION: Duration = Duration::from_millis( 4 );
+pub const MIN_FRAME_DURATION: Duration = Duration::from_millis( 14 );
+pub const MAX_FRAME_DURATION: Duration = Duration::from_millis( 500 );
+pub const DEFAULT_SCREEN_SIZE: ScreenDimensions = ScreenDimensions::new(800,600);
+pub const DEFAULT_SCREEN_SCALE: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(1) };
+
+pub type ScreenPosition = geometry::Point<u16>;
+pub type ScreenDimensions = geometry::Dimensions<u16>;
+
+#[macro_export]
+macro_rules! error {
+ ($source:expr, $($tokens:tt)*) => {{
+ eprint!("[ERROR] [{}]: ", $source);
+ eprintln!($($tokens)*);
+ }};
+}