make sure GeorgeEmu can't be constructed without a rom

This commit is contained in:
august kline 2024-09-26 21:13:57 -04:00
parent a621ec235a
commit 3856d81c47
1 changed files with 2 additions and 50 deletions

View File

@ -1,7 +1,7 @@
pub mod cpu; pub mod cpu;
mod instructions; mod instructions;
mod keyboard; mod keyboard;
mod memory; pub mod memory;
mod platform; mod platform;
pub mod video; pub mod video;
@ -91,35 +91,6 @@ impl GeorgeEmuBuilder<NoRom, NoWindow> {
window, window,
} }
} }
// pub fn window(self, mut window: Window) -> GeorgeEmuBuilder<NoRom, SomeWindow> {
// let Self {
// rom,
// cpu,
// ref cpu_controller,
// ref memory_handle,
// keyboard,
// ..
// } = self;
// let renderer = Renderer::new(
// self.cpu_controller.clone().unwrap(),
// self.memory_handle.clone().unwrap(),
// );
// window.set_input_callback(Box::new(Keyboard::new(
// self.memory_handle.as_ref().unwrap().clone(),
// )));
// GeorgeEmuBuilder {
// cpu,
// rom,
// keyboard,
// renderer: Some(renderer),
// cpu_controller: cpu_controller.clone(),
// memory_handle: memory_handle.clone(),
// window: SomeWindow(window),
// }
// }
} }
impl GeorgeEmuBuilder<SomeRom, NoWindow> { impl GeorgeEmuBuilder<SomeRom, NoWindow> {
@ -202,26 +173,6 @@ impl GeorgeEmuBuilder<NoRom, SomeWindow> {
self.cpu.as_mut().unwrap().debug = true; self.cpu.as_mut().unwrap().debug = true;
self self
} }
#[cfg(not(target_arch = "wasm32"))]
pub fn build(self) -> GeorgeEmu {
let keyboard = Keyboard::new(self.memory_handle.clone().unwrap());
GeorgeEmu(imp::GeorgeEmu::new(
self.cpu.unwrap(),
self.renderer.unwrap(),
Some(keyboard),
None,
))
}
#[cfg(target_arch = "wasm32")]
pub fn build(self) -> GeorgeEmu {
GeorgeEmu(imp::GeorgeEmu::new(
self.cpu.unwrap(),
self.renderer.unwrap(),
self.window.0,
))
}
} }
impl GeorgeEmuBuilder<SomeRom, SomeWindow> { impl GeorgeEmuBuilder<SomeRom, SomeWindow> {
@ -233,6 +184,7 @@ impl GeorgeEmuBuilder<SomeRom, SomeWindow> {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub fn build(self) -> GeorgeEmu { pub fn build(self) -> GeorgeEmu {
let keyboard = Keyboard::new(self.memory_handle.clone().unwrap());
GeorgeEmu(imp::GeorgeEmu::new( GeorgeEmu(imp::GeorgeEmu::new(
self.cpu.unwrap(), self.cpu.unwrap(),
self.renderer.unwrap(), self.renderer.unwrap(),