// THIS FILE HAS BEEN GENERATED BY gen_decode_switch

use crate::instr::instr_operation::BranchOperation::*;
use crate::instr::instr_operation::ImplicitOperation::*;
use crate::instr::instr_operation::MemoryModifyOperation::*;
use crate::instr::instr_operation::PullStackOperation::*;
use crate::instr::instr_operation::PushStackOperation::*;
use crate::instr::instr_operation::RegisterMemoryOperation::*;
use crate::instr::Instruction;
use crate::instr::Instruction::*;
use crate::registers::IndexRegister::X;
use crate::registers::IndexRegister::Y;

/// Decodes a raw 6502 opcode byte into the corresponding instruction
///
/// This is an alternative implementation of the instruction decoder that uses
/// a match expression instead of logical grouping. The function is auto-generated
/// by gen_decode_switch to ensure complete coverage of all possible opcodes.
///
/// # Arguments
/// * `opcode` - The raw opcode byte to decode (0x00-0xFF)
///
/// # Returns
/// A decoded `Instruction` enum value representing the instruction. Invalid or
/// undocumented opcodes are typically decoded as `FetchInstr`, which acts as a NOP,
/// unless the `undoc_opcodes` feature is enabled *(not yet implemented)*.
///
/// # Implementation Notes
/// - All 256 possible opcode values are explicitly handled
/// - Generated from the canonical decoder implementation in decode_logic.rs
/// - Provides the same behavior as decode_logic::decode
/// - The handling of undocumented opcodes depends on the `undoc_opcodes` feature
#[inline]
pub fn decode(opcode: u8) -> Instruction {
    match opcode {
        0x00 => Break,
        0x01 => ZeroPageIdxIndirect(Or, X),
        0x02 => FetchInstr,
        0x03 => FetchInstr,
        0x04 => FetchInstr,
        0x05 => ZeroPage(Or),
        0x06 => ZeroPageReadModifyWrite(ShiftLeftMemory),
        0x07 => FetchInstr,
        0x08 => Push(PushStatus),
        0x09 => Immediate(Or),
        0x0A => Implied(ShiftLeftA),
        0x0B => FetchInstr,
        0x0C => FetchInstr,
        0x0D => Absolute(Or),
        0x0E => AbsoluteReadModifyWrite(ShiftLeftMemory),
        0x0F => FetchInstr,
        0x10 => Relative(BranchPlus),
        0x11 => ZeroPageIndirectIdxRead(Or, Y),
        0x12 => FetchInstr,
        0x13 => FetchInstr,
        0x14 => FetchInstr,
        0x15 => ZeroPageIdx(Or, X),
        0x16 => ZeroPageIdxReadModifyWrite(ShiftLeftMemory, X),
        0x17 => FetchInstr,
        0x18 => Implied(ClearCarry),
        0x19 => AbsoluteIdxRead(Or, Y),
        0x1A => FetchInstr,
        0x1B => FetchInstr,
        0x1C => FetchInstr,
        0x1D => AbsoluteIdxRead(Or, X),
        0x1E => AbsoluteIdxReadModifyWrite(ShiftLeftMemory, X),
        0x1F => FetchInstr,
        0x20 => JumpSubroutine,
        0x21 => ZeroPageIdxIndirect(And, X),
        0x22 => FetchInstr,
        0x23 => FetchInstr,
        0x24 => ZeroPage(Bit),
        0x25 => ZeroPage(And),
        0x26 => ZeroPageReadModifyWrite(RotateLeftMemory),
        0x27 => FetchInstr,
        0x28 => Pull(PullStatus),
        0x29 => Immediate(And),
        0x2A => Implied(RotateLeftA),
        0x2B => FetchInstr,
        0x2C => Absolute(Bit),
        0x2D => Absolute(And),
        0x2E => AbsoluteReadModifyWrite(RotateLeftMemory),
        0x2F => FetchInstr,
        0x30 => Relative(BranchMinus),
        0x31 => ZeroPageIndirectIdxRead(And, Y),
        0x32 => FetchInstr,
        0x33 => FetchInstr,
        0x34 => FetchInstr,
        0x35 => ZeroPageIdx(And, X),
        0x36 => ZeroPageIdxReadModifyWrite(RotateLeftMemory, X),
        0x37 => FetchInstr,
        0x38 => Implied(SetCarry),
        0x39 => AbsoluteIdxRead(And, Y),
        0x3A => FetchInstr,
        0x3B => FetchInstr,
        0x3C => FetchInstr,
        0x3D => AbsoluteIdxRead(And, X),
        0x3E => AbsoluteIdxReadModifyWrite(RotateLeftMemory, X),
        0x3F => FetchInstr,
        0x40 => ReturnInterrupt,
        0x41 => ZeroPageIdxIndirect(Xor, X),
        0x42 => FetchInstr,
        0x43 => FetchInstr,
        0x44 => FetchInstr,
        0x45 => ZeroPage(Xor),
        0x46 => ZeroPageReadModifyWrite(ShiftRightMemory),
        0x47 => FetchInstr,
        0x48 => Push(PushA),
        0x49 => Immediate(Xor),
        0x4A => Implied(ShiftRightA),
        0x4B => FetchInstr,
        0x4C => AbsoluteJump,
        0x4D => Absolute(Xor),
        0x4E => AbsoluteReadModifyWrite(ShiftRightMemory),
        0x4F => FetchInstr,
        0x50 => Relative(BranchOverflowClear),
        0x51 => ZeroPageIndirectIdxRead(Xor, Y),
        0x52 => FetchInstr,
        0x53 => FetchInstr,
        0x54 => FetchInstr,
        0x55 => ZeroPageIdx(Xor, X),
        0x56 => ZeroPageIdxReadModifyWrite(ShiftRightMemory, X),
        0x57 => FetchInstr,
        0x58 => Implied(ClearInterruptDisable),
        0x59 => AbsoluteIdxRead(Xor, Y),
        0x5A => FetchInstr,
        0x5B => FetchInstr,
        0x5C => FetchInstr,
        0x5D => AbsoluteIdxRead(Xor, X),
        0x5E => AbsoluteIdxReadModifyWrite(ShiftRightMemory, X),
        0x5F => FetchInstr,
        0x60 => ReturnSubroutine,
        0x61 => ZeroPageIdxIndirect(Add, X),
        0x62 => FetchInstr,
        0x63 => FetchInstr,
        0x64 => FetchInstr,
        0x65 => ZeroPage(Add),
        0x66 => ZeroPageReadModifyWrite(RotateRightMemory),
        0x67 => FetchInstr,
        0x68 => Pull(PullA),
        0x69 => Immediate(Add),
        0x6A => Implied(RotateRightA),
        0x6B => FetchInstr,
        0x6C => AbsoluteIndirectJump,
        0x6D => Absolute(Add),
        0x6E => AbsoluteReadModifyWrite(RotateRightMemory),
        0x6F => FetchInstr,
        0x70 => Relative(BranchOverflowSet),
        0x71 => ZeroPageIndirectIdxRead(Add, Y),
        0x72 => FetchInstr,
        0x73 => FetchInstr,
        0x74 => FetchInstr,
        0x75 => ZeroPageIdx(Add, X),
        0x76 => ZeroPageIdxReadModifyWrite(RotateRightMemory, X),
        0x77 => FetchInstr,
        0x78 => Implied(SetInterruptDisable),
        0x79 => AbsoluteIdxRead(Add, Y),
        0x7A => FetchInstr,
        0x7B => FetchInstr,
        0x7C => FetchInstr,
        0x7D => AbsoluteIdxRead(Add, X),
        0x7E => AbsoluteIdxReadModifyWrite(RotateRightMemory, X),
        0x7F => FetchInstr,
        0x80 => FetchInstr,
        0x81 => ZeroPageIdxIndirect(StoreA, X),
        0x82 => FetchInstr,
        0x83 => FetchInstr,
        0x84 => ZeroPage(StoreY),
        0x85 => ZeroPage(StoreA),
        0x86 => ZeroPage(StoreX),
        0x87 => FetchInstr,
        0x88 => Implied(DecrementY),
        0x89 => FetchInstr,
        0x8A => Implied(TransferXToAccumulator),
        0x8B => FetchInstr,
        0x8C => Absolute(StoreY),
        0x8D => Absolute(StoreA),
        0x8E => Absolute(StoreX),
        0x8F => FetchInstr,
        0x90 => Relative(BranchCarryClear),
        0x91 => ZeroPageIndirectIdxWrite(StoreA, Y),
        0x92 => FetchInstr,
        0x93 => FetchInstr,
        0x94 => ZeroPageIdx(StoreY, X),
        0x95 => ZeroPageIdx(StoreA, X),
        0x96 => ZeroPageIdx(StoreX, Y),
        0x97 => FetchInstr,
        0x98 => Implied(TransferYToAccumulator),
        0x99 => AbsoluteIdxWrite(StoreA, Y),
        0x9A => Implied(TransferXToStackPtr),
        0x9B => FetchInstr,
        0x9C => FetchInstr,
        0x9D => AbsoluteIdxWrite(StoreA, X),
        0x9E => FetchInstr,
        0x9F => FetchInstr,
        0xA0 => Immediate(LoadY),
        0xA1 => ZeroPageIdxIndirect(LoadA, X),
        0xA2 => Immediate(LoadX),
        0xA3 => FetchInstr,
        0xA4 => ZeroPage(LoadY),
        0xA5 => ZeroPage(LoadA),
        0xA6 => ZeroPage(LoadX),
        0xA7 => FetchInstr,
        0xA8 => Implied(TransferAccumulatorToY),
        0xA9 => Immediate(LoadA),
        0xAA => Implied(TransferAccumulatorToX),
        0xAB => FetchInstr,
        0xAC => Absolute(LoadY),
        0xAD => Absolute(LoadA),
        0xAE => Absolute(LoadX),
        0xAF => FetchInstr,
        0xB0 => Relative(BranchCarrySet),
        0xB1 => ZeroPageIndirectIdxRead(LoadA, Y),
        0xB2 => FetchInstr,
        0xB3 => FetchInstr,
        0xB4 => ZeroPageIdx(LoadY, X),
        0xB5 => ZeroPageIdx(LoadA, X),
        0xB6 => ZeroPageIdx(LoadX, Y),
        0xB7 => FetchInstr,
        0xB8 => Implied(ClearOverflow),
        0xB9 => AbsoluteIdxRead(LoadA, Y),
        0xBA => Implied(TransferStackPtrToX),
        0xBB => FetchInstr,
        0xBC => AbsoluteIdxRead(LoadY, X),
        0xBD => AbsoluteIdxRead(LoadA, X),
        0xBE => AbsoluteIdxRead(LoadX, Y),
        0xBF => FetchInstr,
        0xC0 => Immediate(Cpy),
        0xC1 => ZeroPageIdxIndirect(Cmp, X),
        0xC2 => FetchInstr,
        0xC3 => FetchInstr,
        0xC4 => ZeroPage(Cpy),
        0xC5 => ZeroPage(Cmp),
        0xC6 => ZeroPageReadModifyWrite(DecrementMemory),
        0xC7 => FetchInstr,
        0xC8 => Implied(IncrementY),
        0xC9 => Immediate(Cmp),
        0xCA => Implied(DecrementX),
        0xCB => FetchInstr,
        0xCC => Absolute(Cpy),
        0xCD => Absolute(Cmp),
        0xCE => AbsoluteReadModifyWrite(DecrementMemory),
        0xCF => FetchInstr,
        0xD0 => Relative(BranchNotEqual),
        0xD1 => ZeroPageIndirectIdxRead(Cmp, Y),
        0xD2 => FetchInstr,
        0xD3 => FetchInstr,
        0xD4 => FetchInstr,
        0xD5 => ZeroPageIdx(Cmp, X),
        0xD6 => ZeroPageIdxReadModifyWrite(DecrementMemory, X),
        0xD7 => FetchInstr,
        0xD8 => Implied(ClearDecimal),
        0xD9 => AbsoluteIdxRead(Cmp, Y),
        0xDA => FetchInstr,
        0xDB => FetchInstr,
        0xDC => FetchInstr,
        0xDD => AbsoluteIdxRead(Cmp, X),
        0xDE => AbsoluteIdxReadModifyWrite(DecrementMemory, X),
        0xDF => FetchInstr,
        0xE0 => Immediate(Cpx),
        0xE1 => ZeroPageIdxIndirect(Sub, X),
        0xE2 => FetchInstr,
        0xE3 => FetchInstr,
        0xE4 => ZeroPage(Cpx),
        0xE5 => ZeroPage(Sub),
        0xE6 => ZeroPageReadModifyWrite(IncrementMemory),
        0xE7 => FetchInstr,
        0xE8 => Implied(IncrementX),
        0xE9 => Immediate(Sub),
        0xEA => Implied(Nop),
        0xEB => FetchInstr,
        0xEC => Absolute(Cpx),
        0xED => Absolute(Sub),
        0xEE => AbsoluteReadModifyWrite(IncrementMemory),
        0xEF => FetchInstr,
        0xF0 => Relative(BranchEqual),
        0xF1 => ZeroPageIndirectIdxRead(Sub, Y),
        0xF2 => FetchInstr,
        0xF3 => FetchInstr,
        0xF4 => FetchInstr,
        0xF5 => ZeroPageIdx(Sub, X),
        0xF6 => ZeroPageIdxReadModifyWrite(IncrementMemory, X),
        0xF7 => FetchInstr,
        0xF8 => Implied(SetDecimal),
        0xF9 => AbsoluteIdxRead(Sub, Y),
        0xFA => FetchInstr,
        0xFB => FetchInstr,
        0xFC => FetchInstr,
        0xFD => AbsoluteIdxRead(Sub, X),
        0xFE => AbsoluteIdxReadModifyWrite(IncrementMemory, X),
        0xFF => FetchInstr,
    }
}
