public static int LdR16(Opcode op, GbMemory mem) { if (op.Src == 8) { mem.WriteCycle((op.Dest == 2 || op.Dest == 3) ? mem.R.Hl : mem.R.GetR16Sp(op.Dest), mem.R.A); } else { mem.R.A = mem.ReadCycle((op.Src == 2 || op.Src == 3) ? mem.R.Hl : mem.R.GetR16Sp(op.Src)); } if (op.Src == 2 || op.Dest == 2) { mem.R.Hl++; } else if (op.Src == 3 || op.Dest == 3) { mem.R.Hl--; } else { // Do nothing. } return(2); }
public static int LdH(Opcode op, GbMemory mem) { if (op.Dest == 7) { mem.R.A = mem.ReadCycle(new GbUInt16(0xFF, mem.ReadCycleI8())); } else { mem.WriteCycle(new GbUInt16(0xFF, mem.ReadCycleI8()), mem.R.A); } return(3); }
public static int LdA16(Opcode op, GbMemory mem) { byte low = mem.ReadCycleI8(); byte high = mem.ReadCycleI8(); if (op.Dest == 7) { mem.R.A = mem.ReadCycle(new GbUInt16(high, low)); } else { mem.WriteCycle(new GbUInt16(high, low), mem.R.A); } return(4); }