diff --git a/src/cheats/mod.rs b/src/cheats/mod.rs index 04bb0032dbbdf76bc29422d90caf01778d44ed5b..411161d702c796a3746040bd52581cca1162c1de 100644 --- a/src/cheats/mod.rs +++ b/src/cheats/mod.rs @@ -1,2 +1,7 @@ +//! Implementation of the cheating support for the Game Boy. +//! +//! Supports both [Game Genie](https://en.wikipedia.org/wiki/Game_Genie) +//! and [GameShark](https://en.wikipedia.org/wiki/GameShark) systems. + pub mod genie; pub mod shark; diff --git a/src/devices/printer.rs b/src/devices/printer.rs index dade2045f059a174201655d06af1322109ca3d07..bdfe76f5b26544199fe49182160f512623498854 100644 --- a/src/devices/printer.rs +++ b/src/devices/printer.rs @@ -67,6 +67,12 @@ impl Display for PrinterState { } } +impl From<u8> for PrinterState { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + #[derive(Clone, Copy, PartialEq, Eq)] enum PrinterCommand { Init = 0x01, @@ -104,6 +110,12 @@ impl Display for PrinterCommand { } } +impl From<u8> for PrinterCommand { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + pub struct PrinterDevice { state: PrinterState, command: PrinterCommand, diff --git a/src/gb.rs b/src/gb.rs index d9b512bf05f639435880f5cb71de3c623bed136b..af8e2348c827f80d161c9a3259e11f5863c9dd75 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -110,6 +110,18 @@ impl Display for GameBoyMode { } } +impl From<u8> for GameBoyMode { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + +impl From<&str> for GameBoyMode { + fn from(value: &str) -> Self { + Self::from_string(value) + } +} + #[cfg_attr(feature = "wasm", wasm_bindgen)] #[derive(Clone, Copy, PartialEq, Eq)] pub enum GameBoySpeed { @@ -154,6 +166,12 @@ impl Display for GameBoySpeed { } } +impl From<u8> for GameBoySpeed { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + #[cfg_attr(feature = "wasm", wasm_bindgen)] #[derive(Clone, Copy, PartialEq, Eq)] pub struct GameBoyConfig { diff --git a/src/pad.rs b/src/pad.rs index 37cb34fc6a7751e9e9bbd3e282825e368d1b1883..aba8acc1c741f2e8b755c899eaf626a4d899b037 100644 --- a/src/pad.rs +++ b/src/pad.rs @@ -40,6 +40,12 @@ impl PadKey { } } +impl From<u8> for PadKey { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + pub struct Pad { down: bool, up: bool, diff --git a/src/serial.rs b/src/serial.rs index 786e63ad6ba3c40e437c174befe298712a52b103..8e0b1ff6155c8134394694a48838e720db9700ae 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -1,3 +1,5 @@ +//! Serial transfer (Link Cable) functions and structures. + use crate::{mmu::BusComponent, warnln}; pub trait SerialDevice { diff --git a/src/state.rs b/src/state.rs index 8f281a68173cd4cfb99e2c1036894e8e391e294d..09d93eccd2a8b50afa8a26d0127b73bb9dfe7661 100644 --- a/src/state.rs +++ b/src/state.rs @@ -61,6 +61,12 @@ impl BosBlockKind { } } +impl From<u8> for BosBlockKind { + fn from(value: u8) -> Self { + Self::from_u8(value) + } +} + pub trait Serialize { /// Writes the data from the internal structure into the /// provided buffer.