//! Back-compat shim. The full PPC disassembler now lives in
//! [`xenia_cpu::disasm`] (single source of truth, sitting on top of the
//! canonical decoder). This module preserves the legacy `Decoded { base, ext }`
//! surface so existing call sites keep compiling while the analysis crate
//! migrates to `DisasmText` directly.

use xenia_cpu::decoder::decode;
use xenia_cpu::disasm::format;

/// Decoded instruction carrying both base and (optional) extended mnemonic forms.
pub struct Decoded {
    pub base: String,
    pub ext: Option<String>,
}

impl Decoded {
    /// Returns the preferred display form (extended if available, else base).
    pub fn display(&self) -> &str {
        self.ext.as_deref().unwrap_or(&self.base)
    }
}

/// Disassemble one 32-bit big-endian PowerPC instruction.
pub fn disasm(instr: u32, addr: u32) -> Decoded {
    let d = decode(instr, addr);
    let t = format(&d);
    Decoded { base: t.disasm, ext: t.ext_disasm }
}
