pub fn bit_assign(cpu: &mut CPU, opcode: u8, set_bit: bool) -> u8 {
    let bit_index = bit_index_from_opcode(opcode);

    let (mut value, duration) = match register_from_opcode(opcode) {
        Register::Reg8(r8) => (cpu.registers.read8(&r8), 8),
        Register::Reg16(r16) => (cpu.mmu.read8(cpu.registers.read16(&r16)), 16),
    };

    if set_bit {
        value |= 0x01 << bit_index;
    } else {
        value &= !(0x01 << bit_index);
    }

    match register_from_opcode(opcode) {
        Register::Reg8(r8) => cpu.registers.write8(&r8, value),
        Register::Reg16(r16) => cpu.mmu.write8(cpu.registers.read16(&r16), value),
    };

    duration
}
/// Set, or reset, an individual bit in an 8-bit value.
///
/// Takes 8 cycles unless operating on an indirectly addressed value, then 16 cycles.
///
/// # Examples
///
/// ```asm
/// SET 4, B  ; B = (B | 0x01 << 4)
/// RES 4, B  ; B = (B & 0x01 << 4)
/// ```
Set, or reset, an individual bit in an 8-bit value.
Takes 8 cycles unless operating on an indirectly addressed value, then 16 cycles.
Set or reset an individual bit in an 8 - bit value . Takes 8 cycles unless operating on an indirectly addressed value then 16 cycles .
pub fn bit_assign(cpu: &mut CPU, opcode: u8, set_bit: bool) -> u8 {
    let bit_index = bit_index_from_opcode(opcode);
    let (mut value, duration) = match register_from_opcode(opcode) {
        Register::Reg8(r8) => (cpu.registers.read8(&r8), 8),
        Register::Reg16(r16) => (cpu.mmu.read8(cpu.registers.read16(&r16)), 16),
    };
    if set_bit {
        value |= 0x01 << bit_index;
    } else {
        value &= !(0x01 << bit_index);
    }
    match register_from_opcode(opcode) {
        Register::Reg8(r8) => cpu.registers.write8(&r8, value),
        Register::Reg16(r16) => cpu.mmu.write8(cpu.registers.read16(&r16), value),
    };
    duration
}
pub fn bit_assign ( cpu : & mut CPU , opcode : u8 , set_bit : bool ) -> u8 { let bit_index = bit_index_from_opcode ( opcode ) ; let ( mut value , duration ) = match register_from_opcode ( opcode ) { Register :: Reg8 ( r8 ) => ( cpu . registers . read8 ( & r8 ) , 8 ) , Register :: Reg16 ( r16 ) => ( cpu . mmu . read8 ( cpu . registers . read16 ( & r16 ) ) , 16 ) , } ; if set_bit { value |= 0x01 << bit_index ; } else { value &= ! ( 0x01 << bit_index ) ; } match register_from_opcode ( opcode ) { Register :: Reg8 ( r8 ) => cpu . registers . write8 ( & r8 , value ) , Register :: Reg16 ( r16 ) => cpu . mmu . write8 ( cpu . registers . read16 ( & r16 ) , value ) , } ; duration }
Set, or reset, an individual bit in an 8-bit value.
Set or reset an individual bit in an 8 - bit value .
cpu
&mut CPU
opcode
u8
set_bit
bool
cpu
&mut CPU
opcode
u8
set_bit
bool
examples
None