use heterob::{bit_numbering::Lsb, P12};
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Command {
pub io_space: bool,
pub memory_space: bool,
pub bus_master: bool,
pub special_cycles: bool,
pub memory_write_and_invalidate_enable: bool,
pub vga_palette_snoop: bool,
pub parity_error_response: bool,
pub stepping: bool,
pub serr_enable: bool,
pub fast_back_to_back_enable: bool,
pub interrupt_disable: bool,
pub reserved: u8,
}
impl From<u16> for Command {
fn from(word: u16) -> Self {
let Lsb((
io_space,
memory_space,
bus_master,
special_cycles,
memory_write_and_invalidate_enable,
vga_palette_snoop,
parity_error_response,
stepping,
serr_enable,
fast_back_to_back_enable,
interrupt_disable,
reserved,
)) = P12::<_, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5>(word).into();
Self {
io_space,
memory_space,
bus_master,
special_cycles,
memory_write_and_invalidate_enable,
vga_palette_snoop,
parity_error_response,
stepping,
serr_enable,
fast_back_to_back_enable,
interrupt_disable,
reserved,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn from_word() {
let result = 0xAAAA.into();
let sample = Command {
io_space: false,
memory_space: true,
bus_master: false,
special_cycles: true,
memory_write_and_invalidate_enable: false,
vga_palette_snoop: true,
parity_error_response: false,
stepping: true,
serr_enable: false,
fast_back_to_back_enable: true,
interrupt_disable: false,
reserved: 0b10101,
};
assert_eq!(sample, result);
}
}