/// <summary> /// Sets the dest bit of the src byte to true /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="memory">The memory.</param> /// <returns>The number of ticks the operation took to complete.</returns> /// <remarks>Affected Flags: None.</remarks> public static int Set(Opcode opcode, GbMemory memory) { if (opcode.Src != 6) { memory.R.SetR8(opcode.Src, (byte)(memory.R.GetR8(opcode.Src) | (1 << opcode.Dest))); return(1); } memory.WriteCycleHl((byte)(memory.ReadCycleHl() | (1 << opcode.Dest))); return(3); }
/// <summary> /// Resources the specified code. /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="memory">The memory.</param> /// <returns>The number of ticks the operation took to complete.</returns> public static int Res(Opcode opcode, GbMemory memory) { if (opcode.Src != 6) { memory.R.SetR8(opcode.Src, memory.R.GetR8(opcode.Src).Res(opcode.Dest)); return(1); } memory.WriteCycleHl(memory.ReadCycleHl().Res(opcode.Dest)); return(3); }
/// <summary> /// A framework for calling bitwise operation instructions. /// </summary> /// <param name="op">The op.</param> /// <param name="memory">The memory.</param> /// <param name="operation">The operation.</param> /// <exception cref="ArgumentNullException"><paramref name="operation"/> is null</exception> internal static int BitOpFunc(Opcode op, GbMemory memory, BitOp operation) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } if (op.Src != 6) { memory.R.SetR8(op.Src, operation(memory, memory.R.GetR8(op.Src))); return(1); } memory.WriteCycleHl(operation(memory, memory.ReadCycleHl())); return(3); }