#[derive(Debug, Clone)]
pub enum SubCommand {
    // Timers
    ReadDelayTimer,
    SetDelayTimer,
    SetSoundTimer,

    // Aux
    AddToIndexRegister,
    GetFontCharacter(FontVariant),
    DecimalConversion,

    // Memory
    StoreTo,
    LoadFrom,

    // Input
    GetKey,

    Unimplemented(u16),
}

#[derive(Debug, Clone)]
pub enum FontVariant {
    Big,
    Small,
}

impl From<u16> for SubCommand {
    fn from(value: u16) -> Self {
        match value & 0xFF {
            // Timers
            0x07 => Self::ReadDelayTimer,
            0x15 => Self::SetDelayTimer,
            0x16 => Self::SetSoundTimer,

            // Aux
            0x1E => Self::AddToIndexRegister,
            0x29 => Self::GetFontCharacter(FontVariant::Small),
            0x20 => Self::GetFontCharacter(FontVariant::Big),
            0x33 => Self::DecimalConversion,

            // Memory
            0x55 => Self::StoreTo,
            0x65 => Self::LoadFrom,

            // Input
            0x0A => Self::GetKey,

            _ => Self::Unimplemented(value),
        }
    }
}
