diff options
Diffstat (limited to 'src/core.rs')
-rw-r--r-- | src/core.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core.rs b/src/core.rs new file mode 100644 index 0000000..b4b7520 --- /dev/null +++ b/src/core.rs @@ -0,0 +1,31 @@ +use crate::*; + + +pub struct BedrockCore { + pub mem: ProgramMemory, + pub wst: Stack, + pub rst: Stack, + pub cycle: usize, +} + +impl BedrockCore { + pub fn new() -> Self { + Self { + mem: ProgramMemory::new(), + wst: Stack::new(), + rst: Stack::new(), + cycle: 0, + } + } + + pub fn with_device_bus<DB>(self, dev: DB) -> BedrockEmulator<DB> { + BedrockEmulator { core: self, dev } + } + + pub fn reset(&mut self) { + self.cycle = 0; + self.mem.pc = 0; + self.wst.sp = 0; + self.rst.sp = 0; + } +} |