gb-emu-lib/CPU.cpp
unsigned long CPU::RLr(const byte& opCode)
{
    byte* r = GetByteRegister(opCode);

    // Grab the current CarryFlag val
    bool carry = IsFlagSet(CarryFlag);

    // Grab bit 7 and store it in the carryflag
    ISBITSET(*r, 7) ? SetFlag(CarryFlag) : ClearFlag(CarryFlag);

    // Shift r left
    (*r) = *r << 1;

    // Set bit 0 of r to the old CarryFlag
    (*r) = carry ? SETBIT((*r), 0) : CLEARBIT((*r), 0);

    // Affects Z, clears N, clears H, affects C
    (*r == 0x00) ? SetFlag(ZeroFlag) : ClearFlag(ZeroFlag);
    ClearFlag(SubtractFlag);
    ClearFlag(HalfCarryFlag);

    return 8;
}
/*
    RL r
    11001011(CB) 00010rrr

    The contents of 8-bit register r are rotated left 1-bit position. The content of bit 7
    is copied to the carry flag and the previous content of the carry flag is copied to bit 0.
    Operand r identifies register: B, C, D, E, H, L, or A.

    8 Cycles

    Flags affected(znhc): z00c
*/


The contents of 8-bit register r are rotated left 1-bit position. The content of bit 7
is copied to the carry flag and the previous content of the carry flag is copied to bit 0.
Operand r identifies register: B, C, D, E, H, L, or A.

8 Cycles


The contents of 8 - bit register r are rotated left 1 - bit position . The content of bit 7 is copied to the carry flag and the previous content of the carry flag is copied to bit 0 . Operand r identifies register : B C D E H L or A . 8 Cycles
unsigned long CPU::RLr(const byte& opCode)
{
    byte* r = GetByteRegister(opCode);
    bool carry = IsFlagSet(CarryFlag);
    ISBITSET(*r, 7) ? SetFlag(CarryFlag) : ClearFlag(CarryFlag);
    (*r) = *r << 1;
    (*r) = carry ? SETBIT((*r), 0) : CLEARBIT((*r), 0);
    (*r == 0x00) ? SetFlag(ZeroFlag) : ClearFlag(ZeroFlag);
    ClearFlag(SubtractFlag);
    ClearFlag(HalfCarryFlag);
    return 8;
}
unsigned long CPU :: RLr ( const byte & opCode ) { byte * r = GetByteRegister ( opCode ) ; bool carry = IsFlagSet ( CarryFlag ) ; ISBITSET ( * r , 7 ) ? SetFlag ( CarryFlag ) : ClearFlag ( CarryFlag ) ; ( * r ) = * r << 1 ; ( * r ) = carry ? SETBIT ( ( * r ) , 0 ) : CLEARBIT ( ( * r ) , 0 ) ; ( * r == 0x00 ) ? SetFlag ( ZeroFlag ) : ClearFlag ( ZeroFlag ) ; ClearFlag ( SubtractFlag ) ; ClearFlag ( HalfCarryFlag ) ; return 8 ; }
RL r
11001011(CB) 00010rrr
RL r 11001011 ( CB ) 00010rrr
// Grab the current CarryFlag val // Grab bit 7 and store it in the carryflag // Shift r left // Set bit 0 of r to the old CarryFlag // Affects Z, clears N, clears H, affects C