summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-10-28 20:11:15 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-10-28 20:11:15 +1300
commit4738b8581e932174f9ab99d21c6a24024fb6414d (patch)
tree7e0f53318a1292bb283518c80dec647bf17946a5 /src/lib.rs
parentb0d04c9b28efc90bc6f1cfcc6d2c4d3e646099fb (diff)
downloadbedrock-core-4738b8581e932174f9ab99d21c6a24024fb6414d.zip
Restructure the library
The main type of the library is now the BedrockEmulator type, which contains a new BedrockCore type and an instance of a user-implemented DeviceBus trait. This new structure makes it possible to hot-swap a device bus while a BedrockEmulator is running, which keeps the core and the device bus well separated. This was important when bedrock-pc was going to have two graphical emulator types and upgrade from one to the other once the screen device was accessed. The new structure also vastly simplifies the code previously required with the old Bedrock type, which was parametric over 16 device types and so needed each device type to be enumerated in every place the Bedrock type was stored. The new BedrockEmulator type is only parametric over the particular DeviceBus implementation.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8fd363e..f8fa3d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,21 +1,31 @@
-mod bedrock;
-mod device_bus;
mod processor;
mod program_memory;
mod stack;
-pub use bedrock::Bedrock;
-pub use device_bus::{Device, DeviceBus};
-pub use processor::Signal;
pub use program_memory::ProgramMemory;
pub use stack::Stack;
+mod core;
+mod device_bus;
+mod signal;
+mod emulator;
+
+pub use core::BedrockCore;
+pub use device_bus::{Device, DeviceBus};
+pub use signal::Signal;
+pub use emulator::BedrockEmulator;
+
+
pub mod macros {
#[macro_export]
macro_rules! read_hh { ($v:expr) => { ($v>>24) as u8 }; }
#[macro_export]
macro_rules! read_hl { ($v:expr) => { ($v>>16) as u8 }; }
#[macro_export]
+ macro_rules! read_lh { ($v:expr) => { ($v>>8) as u8 }; }
+ #[macro_export]
+ macro_rules! read_ll { ($v:expr) => { $v as u8 }; }
+ #[macro_export]
macro_rules! read_h { ($v:expr) => { ($v>>8) as u8 }; }
#[macro_export]
macro_rules! read_l { ($v:expr) => { $v as u8 }; }
@@ -27,6 +37,10 @@ pub mod macros {
#[macro_export]
macro_rules! write_hl { ($v:expr, $low:expr) => { $v = $v & 0xff00ffff | (($low as u32) << 16) }; }
#[macro_export]
+ macro_rules! write_lh { ($v:expr, $high:expr) => { $v = $v & 0xffff00ff | (($high as u32) << 8) }; }
+ #[macro_export]
+ macro_rules! write_ll { ($v:expr, $low:expr) => { $v = $v & 0xffffff00 | ($low as u32) }; }
+ #[macro_export]
macro_rules! write_h { ($v:expr, $high:expr) => { $v = $v & 0x00ff | (($high as u16) << 8) }; }
#[macro_export]
macro_rules! write_l { ($v:expr, $low:expr) => { $v = $v & 0xff00 | ($low as u16) }; }