1mod frame_buffer;
2mod io;
3
4pub use core::time::Duration;
5pub use frame_buffer::{FrameBuffer, FrameBufferSource};
6pub use io::{BufferCursor, DataRecorder, LoadableAsset, SeekFrom, SeekableAsset};
7
8pub trait Stopwatch {
9 fn new() -> Self;
10 fn measure(&self) -> Duration;
11}
12
13pub enum Snapshot<LoadableAssetImpl: LoadableAsset> {
14 Sna(LoadableAssetImpl),
15 }
17
18pub enum SnapshotRecorder<DataRecorderImpl: DataRecorder> {
19 Sna(DataRecorderImpl),
20}
21
22pub enum Tape<LoadableAssetImpl: LoadableAsset> {
23 Tap(LoadableAssetImpl),
24 }
26
27pub enum Screen<LoadableAssetImpl: LoadableAsset> {
28 Scr(LoadableAssetImpl),
29}
30
31pub enum RomFormat {
32 Binary16KPages,
33}
34
35pub trait RomSet {
36 type Asset: LoadableAsset;
37
38 fn format(&self) -> RomFormat;
39 fn next_asset(&mut self) -> Option<Self::Asset>;
40}
41
42pub trait HostContext<H: Host + ?Sized>: Sized {
43 fn frame_buffer_context(&self) -> <H::FrameBuffer as FrameBuffer>::Context;
44}
45
46pub trait ScreenAsset: LoadableAsset + SeekableAsset {}
47impl<T> ScreenAsset for T where T: LoadableAsset + SeekableAsset {}
48
49pub trait SnapshotAsset: LoadableAsset + SeekableAsset {}
50impl<T> SnapshotAsset for T where T: LoadableAsset + SeekableAsset {}
51
52pub trait IoExtender {
55 fn write(&mut self, port: u16, data: u8);
57 fn read(&mut self, port: u16) -> u8;
59 fn extends_port(&self, port: u16) -> bool;
63}
64
65pub struct StubIoExtender;
67
68impl IoExtender for StubIoExtender {
69 fn write(&mut self, _: u16, _: u8) {}
70
71 fn read(&mut self, _: u16) -> u8 {
72 0
73 }
74
75 fn extends_port(&self, _: u16) -> bool {
76 false
77 }
78}
79
80pub trait DebugInterface {
82 fn check_pc_breakpoint(&mut self, addr: u16) -> bool;
84}
85
86pub struct StubDebugInterface;
88
89impl DebugInterface for StubDebugInterface {
90 fn check_pc_breakpoint(&mut self, _addr: u16) -> bool {
91 false
92 }
93}
94
95pub trait Host {
98 type Context: HostContext<Self>;
101 type TapeAsset: LoadableAsset + SeekableAsset;
103 type FrameBuffer: FrameBuffer;
105 type EmulationStopwatch: Stopwatch;
107 type IoExtender: IoExtender;
109 type DebugInterface: DebugInterface;
111}