lib.rs: Remove crate::prelude, re-export in lib.rs

This commit is contained in:
John 2023-04-01 02:31:06 -05:00
parent bb8015f33c
commit a4c548d0ec
11 changed files with 93 additions and 95 deletions

View File

@ -1,4 +1,4 @@
use chirp::{cpu::Disassembler, error::Result, prelude::*}; use chirp::{cpu::Disassembler, error::Result, *};
use gumdrop::*; use gumdrop::*;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use std::{fs::read, path::PathBuf}; use std::{fs::read, path::PathBuf};

View File

@ -1,5 +1,5 @@
#![allow(unused_imports)] #![allow(unused_imports)]
use chirp::prelude::*; use chirp::*;
#[cfg(features = "iced")] #[cfg(features = "iced")]
use iced::{ use iced::{
executor, time, window, Alignment, Application, Command, Element, Length, Settings, executor, time, window, Alignment, Application, Command, Element, Length, Settings,

View File

@ -4,19 +4,20 @@
//! Chirp: A chip-8 interpreter in Rust //! Chirp: A chip-8 interpreter in Rust
//! Hello, world! //! Hello, world!
mod io;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
mod ui;
use chirp::{error::Result, prelude::*}; use chirp::error::Error::BreakpointHit;
use chirp::{error::Result, *};
use gumdrop::*; use gumdrop::*;
use io::*;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use std::fs::read; use std::fs::read;
use std::{ use std::{
path::PathBuf, path::PathBuf,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use ui::*;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Options, Hash)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Options, Hash)]
struct Arguments { struct Arguments {
@ -136,10 +137,10 @@ impl State {
state.ch8.bus.write(0x1feu16, options.data); state.ch8.bus.write(0x1feu16, options.data);
Ok(state) Ok(state)
} }
fn keys(&mut self) -> Result<Option<()>> { fn keys(&mut self) -> Result<bool> {
self.ui.keys(&mut self.ch8) self.ui.keys(&mut self.ch8)
} }
fn frame(&mut self) -> Option<()> { fn frame(&mut self) -> Result<bool> {
self.ui.frame(&mut self.ch8) self.ui.frame(&mut self.ch8)
} }
fn tick_cpu(&mut self) -> Result<()> { fn tick_cpu(&mut self) -> Result<()> {
@ -180,14 +181,23 @@ impl Iterator for State {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.wait_for_next_frame(); self.wait_for_next_frame();
match self.keys() { match self.keys() {
Ok(opt) => opt?, Ok(opt) if !opt => return None,
Err(e) => return Some(Err(e)), // summary Err(e) => return Some(Err(e)), // summary lol
_ => (),
} }
self.keys().unwrap_or(None)?; // Allow breakpoint hit messages
if let Err(e) = self.tick_cpu() { match self.tick_cpu() {
return Some(Err(e)); Err(BreakpointHit { addr, next }) => {
eprintln!("Breakpoint hit: {:3x} ({:4x})", addr, next);
}
Err(e) => return Some(Err(e)),
_ => (),
}
match self.frame() {
Ok(opt) if !opt => return None,
Err(e) => return Some(Err(e)),
_ => (),
} }
self.frame()?;
Some(Ok(())) Some(Ok(()))
} }
} }

View File

@ -1,7 +1,7 @@
//! Tests for chirp-minifb //! Tests for chirp-minifb
use super::io::*; use super::ui::*;
use chirp::prelude::*; use chirp::*;
use std::{collections::hash_map::DefaultHasher, hash::Hash}; use std::{collections::hash_map::DefaultHasher, hash::Hash};
mod ui_builder { mod ui_builder {

View File

@ -104,7 +104,7 @@ impl FrameBuffer {
format: Default::default(), format: Default::default(),
} }
} }
pub fn render(&mut self, window: &mut Window, bus: &Bus) { pub fn render(&mut self, window: &mut Window, bus: &Bus) -> Result<()> {
if let Some(screen) = bus.get_region(Region::Screen) { if let Some(screen) = bus.get_region(Region::Screen) {
for (idx, byte) in screen.iter().enumerate() { for (idx, byte) in screen.iter().enumerate() {
for bit in 0..8 { for bit in 0..8 {
@ -116,10 +116,8 @@ impl FrameBuffer {
} }
} }
} }
//TODO: NOT THIS window.update_with_buffer(&self.buffer, self.width, self.height)?;
window Ok(())
.update_with_buffer(&self.buffer, self.width, self.height)
.expect("The window manager should update the buffer.");
} }
} }
@ -139,8 +137,7 @@ pub struct UI {
} }
impl UI { impl UI {
pub fn frame(&mut self, ch8: &mut Chip8) -> Option<()> { pub fn frame(&mut self, ch8: &mut Chip8) -> Result<bool> {
{
if ch8.cpu.flags.pause { if ch8.cpu.flags.pause {
self.window.set_title("Chirp ⏸") self.window.set_title("Chirp ⏸")
} else { } else {
@ -150,16 +147,15 @@ impl UI {
)); ));
} }
if !self.window.is_open() { if !self.window.is_open() {
std::process::exit(0); return Ok(false);
} }
self.time = Instant::now(); self.time = Instant::now();
// update framebuffer // update framebuffer
self.fb.render(&mut self.window, &ch8.bus); self.fb.render(&mut self.window, &ch8.bus)?;
} Ok(true)
Some(())
} }
pub fn keys(&mut self, ch8: &mut Chip8) -> Result<Option<()>> { pub fn keys(&mut self, ch8: &mut Chip8) -> Result<bool> {
// TODO: Remove this hacky workaround for minifb's broken get_keys_* functions. // TODO: Remove this hacky workaround for minifb's broken get_keys_* functions.
let get_keys_pressed = || { let get_keys_pressed = || {
self.window self.window
@ -173,7 +169,7 @@ impl UI {
.into_iter() .into_iter()
.filter(|key| !self.window.get_keys().contains(key)) .filter(|key| !self.window.get_keys().contains(key))
}; };
use crate::io::Region::*; use crate::ui::Region::*;
for key in get_keys_released() { for key in get_keys_released() {
if let Some(key) = identify_key(key) { if let Some(key) = identify_key(key) {
ch8.cpu.release(key)?; ch8.cpu.release(key)?;
@ -184,10 +180,7 @@ impl UI {
use Key::*; use Key::*;
match key { match key {
F1 | Comma => ch8.cpu.dump(), F1 | Comma => ch8.cpu.dump(),
F2 | Period => ch8 F2 | Period => ch8.bus.print_screen()?,
.bus
.print_screen()
.expect("The 'screen' memory region should exist"),
F3 => { F3 => {
debug_dump_screen(ch8, &self.rom).expect("Unable to write debug screen dump"); debug_dump_screen(ch8, &self.rom).expect("Unable to write debug screen dump");
} }
@ -226,7 +219,7 @@ impl UI {
ch8.cpu.soft_reset(); ch8.cpu.soft_reset();
ch8.bus.clear_region(Screen); ch8.bus.clear_region(Screen);
} }
Escape => return Ok(None), Escape => return Ok(false),
key => { key => {
if let Some(key) = identify_key(key) { if let Some(key) = identify_key(key) {
ch8.cpu.press(key)?; ch8.cpu.press(key)?;
@ -235,7 +228,7 @@ impl UI {
} }
} }
self.keyboard = self.window.get_keys(); self.keyboard = self.window.get_keys();
Ok(Some(())) Ok(true)
} }
} }

View File

@ -1,4 +1,4 @@
use chirp::{error::Result, prelude::*}; use chirp::{error::Result, *};
use std::{env::args, fs::read}; use std::{env::args, fs::read};
fn main() -> Result<()> { fn main() -> Result<()> {

View File

@ -15,7 +15,7 @@ use std::{
/// Creates a new bus, growing the backing memory as needed /// Creates a new bus, growing the backing memory as needed
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut bus = bus! { /// let mut bus = bus! {
/// Stack [0x0000..0x0800] = b"ABCDEF", /// Stack [0x0000..0x0800] = b"ABCDEF",
/// Program [0x0800..0x1000] = include_bytes!("bus.rs"), /// Program [0x0800..0x1000] = include_bytes!("bus.rs"),
@ -92,7 +92,7 @@ impl Bus {
/// Constructs a new bus /// Constructs a new bus
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new(); /// let bus = Bus::new();
/// assert!(bus.is_empty()); /// assert!(bus.is_empty());
@ -106,7 +106,7 @@ impl Bus {
/// Gets the length of the bus' backing memory /// Gets the length of the bus' backing memory
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..1234); /// .add_region(Program, 0..1234);
@ -121,7 +121,7 @@ impl Bus {
/// Returns true if the backing memory contains no elements /// Returns true if the backing memory contains no elements
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new(); /// let bus = Bus::new();
/// assert!(bus.is_empty()); /// assert!(bus.is_empty());
@ -134,7 +134,7 @@ impl Bus {
/// Grows the Bus backing memory to at least size bytes, but does not truncate /// Grows the Bus backing memory to at least size bytes, but does not truncate
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let mut bus = Bus::new(); /// let mut bus = Bus::new();
/// bus.with_size(1234); /// bus.with_size(1234);
@ -152,7 +152,7 @@ impl Bus {
/// Adds a new named range (Region) to the bus /// Adds a new named range (Region) to the bus
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new().add_region(Program, 0..1234); /// let bus = Bus::new().add_region(Program, 0..1234);
/// assert_eq!(1234, bus.len()); /// assert_eq!(1234, bus.len());
@ -169,7 +169,7 @@ impl Bus {
/// Loads data into a named region /// Loads data into a named region
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..1234) /// .add_region(Program, 0..1234)
@ -188,7 +188,7 @@ impl Bus {
/// Fills a named region with zeroes /// Fills a named region with zeroes
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..1234) /// .add_region(Program, 0..1234)
@ -199,7 +199,7 @@ impl Bus {
/// ``` /// ```
/// If the region doesn't exist, that's okay. /// If the region doesn't exist, that's okay.
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..1234) /// .add_region(Program, 0..1234)
@ -218,7 +218,7 @@ impl Bus {
/// Gets a slice of bus memory /// Gets a slice of bus memory
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..10); /// .add_region(Program, 0..10);
@ -236,7 +236,7 @@ impl Bus {
/// Gets a mutable slice of bus memory /// Gets a mutable slice of bus memory
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let mut bus = Bus::new() /// let mut bus = Bus::new()
/// .add_region(Program, 0..10); /// .add_region(Program, 0..10);
@ -254,7 +254,7 @@ impl Bus {
/// Gets a slice of a named region of memory /// Gets a slice of a named region of memory
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Program, 0..10); /// .add_region(Program, 0..10);
@ -269,7 +269,7 @@ impl Bus {
/// Gets a mutable slice of a named region of memory /// Gets a mutable slice of a named region of memory
/// # Examples /// # Examples
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let mut bus = Bus::new() /// let mut bus = Bus::new()
/// .add_region(Program, 0..10); /// .add_region(Program, 0..10);
@ -286,7 +286,7 @@ impl Bus {
/// ///
/// [Bus::print_screen] will print the screen /// [Bus::print_screen] will print the screen
/// ```rust /// ```rust
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let bus = Bus::new() /// let bus = Bus::new()
/// .add_region(Screen, 0x000..0x100); /// .add_region(Screen, 0x000..0x100);
@ -296,7 +296,7 @@ impl Bus {
/// ``` /// ```
/// If there is no Screen region, it will return Err([MissingRegion]) /// If there is no Screen region, it will return Err([MissingRegion])
/// ```rust,should_panic /// ```rust,should_panic
///# use chirp::prelude::*; ///# use chirp::*;
///# fn main() -> Result<()> { ///# fn main() -> Result<()> {
/// let mut bus = Bus::new() /// let mut bus = Bus::new()
/// .add_region(Program, 0..10); /// .add_region(Program, 0..10);

View File

@ -95,7 +95,7 @@ impl ControlFlags {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(true, cpu.flags.debug); /// assert_eq!(true, cpu.flags.debug);
/// // Toggle debug mode /// // Toggle debug mode
@ -110,7 +110,7 @@ impl ControlFlags {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(false, cpu.flags.pause); /// assert_eq!(false, cpu.flags.pause);
/// // Pause the cpu /// // Pause the cpu
@ -169,7 +169,7 @@ impl CPU {
/// Constructs a new CPU, taking all configurable parameters /// Constructs a new CPU, taking all configurable parameters
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let cpu = CPU::new( /// let cpu = CPU::new(
/// 0xf00, // screen location /// 0xf00, // screen location
/// 0x50, // font location /// 0x50, // font location
@ -207,7 +207,7 @@ impl CPU {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// ///
/// // press key `7` /// // press key `7`
@ -238,7 +238,7 @@ impl CPU {
/// and the [ControlFlags::lastkey] is recorded. /// and the [ControlFlags::lastkey] is recorded.
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// // press key `7` /// // press key `7`
/// cpu.press(0x7).unwrap(); /// cpu.press(0x7).unwrap();
@ -269,7 +269,7 @@ impl CPU {
/// If the register doesn't exist, returns [Error::InvalidRegister] /// If the register doesn't exist, returns [Error::InvalidRegister]
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// // Create a new CPU, and set v4 to 0x41 /// // Create a new CPU, and set v4 to 0x41
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// cpu.set_v(0x4, 0x41).unwrap(); /// cpu.set_v(0x4, 0x41).unwrap();
@ -288,7 +288,7 @@ impl CPU {
/// Gets a slice of the entire general purpose registers /// Gets a slice of the entire general purpose registers
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// // Create a new CPU, and set v4 to 0x41 /// // Create a new CPU, and set v4 to 0x41
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// cpu.set_v(0x0, 0x41); /// cpu.set_v(0x0, 0x41);
@ -304,7 +304,7 @@ impl CPU {
/// Gets the program counter /// Gets the program counter
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(0x200, cpu.pc()); /// assert_eq!(0x200, cpu.pc());
/// ``` /// ```
@ -315,7 +315,7 @@ impl CPU {
/// Gets the I register /// Gets the I register
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(0, cpu.i()); /// assert_eq!(0, cpu.i());
/// ``` /// ```
@ -326,7 +326,7 @@ impl CPU {
/// Gets the value in the Sound Timer register /// Gets the value in the Sound Timer register
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(0, cpu.sound()); /// assert_eq!(0, cpu.sound());
/// ``` /// ```
@ -337,7 +337,7 @@ impl CPU {
/// Gets the value in the Delay Timer register /// Gets the value in the Delay Timer register
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(0, cpu.delay()); /// assert_eq!(0, cpu.delay());
/// ``` /// ```
@ -351,7 +351,7 @@ impl CPU {
/// updated even when the CPU is in drawpause or keypause /// updated even when the CPU is in drawpause or keypause
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(0x0, cpu.cycle()); /// assert_eq!(0x0, cpu.cycle());
/// ``` /// ```
@ -363,7 +363,7 @@ impl CPU {
/// reinitializing the program counter to 0x200 /// reinitializing the program counter to 0x200
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::new( /// let mut cpu = CPU::new(
/// 0xf00, /// 0xf00,
/// 0x50, /// 0x50,
@ -416,7 +416,7 @@ impl CPU {
/// Gets a slice of breakpoints /// Gets a slice of breakpoints
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// assert_eq!(cpu.breakpoints(), &[]); /// assert_eq!(cpu.breakpoints(), &[]);
/// ``` /// ```
@ -433,7 +433,7 @@ impl CPU {
/// NOTE: does not synchronize with delay timers /// NOTE: does not synchronize with delay timers
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// let mut bus = bus!{ /// let mut bus = bus!{
/// Program [0x0200..0x0f00] = &[ /// Program [0x0200..0x0f00] = &[
@ -459,7 +459,7 @@ impl CPU {
/// Ticks the timers every `rate` ticks /// Ticks the timers every `rate` ticks
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// let mut bus = bus!{ /// let mut bus = bus!{
/// Program [0x0200..0x0f00] = &[ /// Program [0x0200..0x0f00] = &[
@ -524,7 +524,7 @@ impl CPU {
/// Executes a single instruction /// Executes a single instruction
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// let mut bus = bus!{ /// let mut bus = bus!{
/// Program [0x0200..0x0f00] = &[ /// Program [0x0200..0x0f00] = &[
@ -540,7 +540,7 @@ impl CPU {
/// ``` /// ```
/// Returns [Error::UnimplementedInstruction] if the instruction is not implemented. /// Returns [Error::UnimplementedInstruction] if the instruction is not implemented.
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// # use chirp::error::Error; /// # use chirp::error::Error;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// # cpu.flags.debug = true; // enable live disassembly /// # cpu.flags.debug = true; // enable live disassembly
@ -610,7 +610,7 @@ impl CPU {
/// Dumps the current state of all CPU registers, and the cycle count /// Dumps the current state of all CPU registers, and the cycle count
/// # Examples /// # Examples
/// ```rust /// ```rust
/// # use chirp::prelude::*; /// # use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// cpu.dump(); /// cpu.dump();
/// ``` /// ```
@ -663,7 +663,7 @@ impl Default for CPU {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// use chirp::prelude::*; /// use chirp::*;
/// let mut cpu = CPU::default(); /// let mut cpu = CPU::default();
/// ``` /// ```
fn default() -> Self { fn default() -> Self {
@ -689,9 +689,6 @@ impl Default for CPU {
} }
} }
// Below this point, comments may be duplicated per impl' block,
// since some opcodes handle multiple instructions.
impl CPU { impl CPU {
/// Executes a single [Insn] /// Executes a single [Insn]
#[inline(always)] #[inline(always)]
@ -736,6 +733,9 @@ impl CPU {
} }
} }
// Below this point, comments may be duplicated per impl' block,
// since some opcodes handle multiple instructions.
// |`0aaa`| Issues a "System call" (ML routine) // |`0aaa`| Issues a "System call" (ML routine)
// //
// |opcode| effect | // |opcode| effect |

View File

@ -12,15 +12,10 @@ pub mod bus;
pub mod cpu; pub mod cpu;
pub mod error; pub mod error;
/// Common imports for Chirp // Common imports for Chirp
pub mod prelude {
pub use super::Chip8;
use super::*;
pub use crate::bus;
pub use bus::{Bus, Read, Region::*, Write}; pub use bus::{Bus, Read, Region::*, Write};
pub use cpu::{disassembler::Dis, ControlFlags, CPU}; pub use cpu::{disassembler::Dis, ControlFlags, CPU};
pub use error::Result; pub use error::Result;
}
/// Holds the state of a Chip-8 /// Holds the state of a Chip-8
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]

View File

@ -1,6 +1,6 @@
//! These are a series of interpreter tests using Timendus's incredible test suite //! These are a series of interpreter tests using Timendus's incredible test suite
pub use chirp::prelude::*; pub use chirp::*;
fn setup_environment() -> (CPU, Bus) { fn setup_environment() -> (CPU, Bus) {
let mut cpu = CPU::default(); let mut cpu = CPU::default();

View File

@ -1,5 +1,5 @@
//! Testing methods on Chirp's public API //! Testing methods on Chirp's public API
use chirp::prelude::*; use chirp::*;
use std::{collections::hash_map::DefaultHasher, hash::Hash}; use std::{collections::hash_map::DefaultHasher, hash::Hash};
#[test] #[test]