////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// public override ushort Exec(ushort instructionAdress) { byte opcode = GameBoy.Ram.ReadByteAt(instructionAdress); switch (opcode) { case 0x07: { GameBoy.Cpu.rA = RotateOperations.RotateLeft(GameBoy.Cpu.rA); GameBoy.Cpu.ZValue = false; return(++instructionAdress); } case 0x17: { GameBoy.Cpu.rA = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rA); GameBoy.Cpu.ZValue = false; return(++instructionAdress); } case 0x0F: { GameBoy.Cpu.rA = RotateOperations.RotateRight(GameBoy.Cpu.rA); GameBoy.Cpu.ZValue = false; return(++instructionAdress); } case 0x1F: { GameBoy.Cpu.rA = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rA); GameBoy.Cpu.ZValue = false; return(++instructionAdress); } default: { return(++instructionAdress); } } }
////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// public override ushort Exec(ushort instructionAdress) { byte opcode = GameBoy.Ram.ReadByteAt(instructionAdress); switch (opcode) { case 0x07: { GameBoy.Cpu.rA = RotateOperations.RotateLeft(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x00: { GameBoy.Cpu.rB = RotateOperations.RotateLeft(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x01: { GameBoy.Cpu.rC = RotateOperations.RotateLeft(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x02: { GameBoy.Cpu.rD = RotateOperations.RotateLeft(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x03: { GameBoy.Cpu.rE = RotateOperations.RotateLeft(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x04: { GameBoy.Cpu.rH = RotateOperations.RotateLeft(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x05: { GameBoy.Cpu.rL = RotateOperations.RotateLeft(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x06: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.RotateLeft(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x17: { GameBoy.Cpu.rA = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x10: { GameBoy.Cpu.rB = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x11: { GameBoy.Cpu.rC = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x12: { GameBoy.Cpu.rD = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x13: { GameBoy.Cpu.rE = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x14: { GameBoy.Cpu.rH = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x15: { GameBoy.Cpu.rL = RotateOperations.RotateLeftThroughCarry(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x16: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.RotateLeftThroughCarry(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x0F: { GameBoy.Cpu.rA = RotateOperations.RotateRight(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x08: { GameBoy.Cpu.rB = RotateOperations.RotateRight(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x09: { GameBoy.Cpu.rC = RotateOperations.RotateRight(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x0A: { GameBoy.Cpu.rD = RotateOperations.RotateRight(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x0B: { GameBoy.Cpu.rE = RotateOperations.RotateRight(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x0C: { GameBoy.Cpu.rH = RotateOperations.RotateRight(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x0D: { GameBoy.Cpu.rL = RotateOperations.RotateRight(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x0E: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.RotateRight(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x1F: { GameBoy.Cpu.rA = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x18: { GameBoy.Cpu.rB = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x19: { GameBoy.Cpu.rC = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x1A: { GameBoy.Cpu.rD = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x1B: { GameBoy.Cpu.rE = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x1C: { GameBoy.Cpu.rH = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x1D: { GameBoy.Cpu.rL = RotateOperations.RotateRightThroughCarry(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x1E: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.RotateRightThroughCarry(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x27: { GameBoy.Cpu.rA = RotateOperations.ShiftLeft(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x20: { GameBoy.Cpu.rB = RotateOperations.ShiftLeft(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x21: { GameBoy.Cpu.rC = RotateOperations.ShiftLeft(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x22: { GameBoy.Cpu.rD = RotateOperations.ShiftLeft(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x23: { GameBoy.Cpu.rE = RotateOperations.ShiftLeft(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x24: { GameBoy.Cpu.rH = RotateOperations.ShiftLeft(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x25: { GameBoy.Cpu.rL = RotateOperations.ShiftLeft(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x26: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.ShiftLeft(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x2F: { GameBoy.Cpu.rA = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x28: { GameBoy.Cpu.rB = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x29: { GameBoy.Cpu.rC = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x2A: { GameBoy.Cpu.rD = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x2B: { GameBoy.Cpu.rE = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x2C: { GameBoy.Cpu.rH = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x2D: { GameBoy.Cpu.rL = RotateOperations.ShiftRightSetMSB(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x2E: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.ShiftRightSetMSB(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // case 0x3F: { GameBoy.Cpu.rA = RotateOperations.ShiftRight(GameBoy.Cpu.rA); return(++instructionAdress); } case 0x38: { GameBoy.Cpu.rB = RotateOperations.ShiftRight(GameBoy.Cpu.rB); return(++instructionAdress); } case 0x39: { GameBoy.Cpu.rC = RotateOperations.ShiftRight(GameBoy.Cpu.rC); return(++instructionAdress); } case 0x3A: { GameBoy.Cpu.rD = RotateOperations.ShiftRight(GameBoy.Cpu.rD); return(++instructionAdress); } case 0x3B: { GameBoy.Cpu.rE = RotateOperations.ShiftRight(GameBoy.Cpu.rE); return(++instructionAdress); } case 0x3C: { GameBoy.Cpu.rH = RotateOperations.ShiftRight(GameBoy.Cpu.rH); return(++instructionAdress); } case 0x3D: { GameBoy.Cpu.rL = RotateOperations.ShiftRight(GameBoy.Cpu.rL); return(++instructionAdress); } case 0x3E: { byte b = GameBoy.Ram.ReadByteAt(GameBoy.Cpu.rHL); b = RotateOperations.ShiftRight(b); GameBoy.Ram.WriteAt(GameBoy.Cpu.rHL, b); return(++instructionAdress); } // default: { return(++instructionAdress); } } }