gb-emu-lib/CPU.cpp
unsigned long CPU::BITbr(const byte& opCode)
{
    byte bit = (opCode >> 3) & 0x07;
    byte* r = GetByteRegister(opCode);

    // Test bit b in r
    (!ISBITSET(*r, bit)) ? SetFlag(ZeroFlag) : ClearFlag(ZeroFlag);

    SetFlag(HalfCarryFlag); // H is set
    ClearFlag(SubtractFlag); // N is reset

    return 8;
}
/*
    BIT b, r
    11001011 01bbbrrr

    This instruction tests bit b in register r and sets the Z flag accordingly.

    8 Cycles

    Flags affected(znhc): z01-
*/


This instruction tests bit b in register r and sets the Z flag accordingly.

8 Cycles


This instruction tests bit b in register r and sets the Z flag accordingly . 8 Cycles
unsigned long CPU::BITbr(const byte& opCode)
{
    byte bit = (opCode >> 3) & 0x07;
    byte* r = GetByteRegister(opCode);
    (!ISBITSET(*r, bit)) ? SetFlag(ZeroFlag) : ClearFlag(ZeroFlag);
    SetFlag(HalfCarryFlag); 
    ClearFlag(SubtractFlag); 
    return 8;
}
unsigned long CPU :: BITbr ( const byte & opCode ) { byte bit = ( opCode >> 3 ) & 0x07 ; byte * r = GetByteRegister ( opCode ) ; ( ! ISBITSET ( * r , bit ) ) ? SetFlag ( ZeroFlag ) : ClearFlag ( ZeroFlag ) ; SetFlag ( HalfCarryFlag ) ; ClearFlag ( SubtractFlag ) ; return 8 ; }
BIT b, r
11001011 01bbbrrr
BIT b r 11001011 01bbbrrr
// Test bit b in r // H is set // N is reset