protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { bool carry = cpuState.IsFlagSet(CpuState.Flags.Carry); cpuState.SetFlag(CpuState.Flags.Carry, arg & 0x80); arg <<= 1; if (carry) { arg |= 1; } write(arg); cpuState.SetNegativeFlag(arg); cpuState.SetZeroFlag(arg); switch (Variants[memory[cpuState.Pc]]) { case AddressingMode.Accumulator: cycles = 2; break; case AddressingMode.ZeroPage: cycles = 5; break; case AddressingMode.ZeroPageXIndexed: cycles = 6; break; case AddressingMode.Absolute: cycles = 6; break; case AddressingMode.AbsoluteX: cycles = 7; break; } }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { ushort result = arg; result <<= 1; var byteResult = (byte) (result & 0xFF); write(byteResult); cpuState.SetNegativeFlag(byteResult); cpuState.SetZeroFlag(byteResult); cpuState.SetFlag(CpuState.Flags.Carry, result & 0xFF00); switch (Variants[memory[cpuState.Pc]]) { case AddressingMode.Accumulator: cycles = 2; break; case AddressingMode.ZeroPage: cycles = 5; break; case AddressingMode.ZeroPageXIndexed: cycles = 6; break; case AddressingMode.Absolute: cycles = 6; break; case AddressingMode.AbsoluteX: cycles = 7; break; } }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, ref int cycles) { cpuState.X = arg; cpuState.SetNegativeFlag(arg); cpuState.SetZeroFlag(arg); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var res = (byte)((cpuState.X - 1) & 0xFF); cpuState.X = res; cpuState.SetNegativeFlag(res); cpuState.SetZeroFlag(res); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { cpuState.A = cpuState.PopStack(memory); cpuState.SetNegativeFlag(cpuState.A); cpuState.SetZeroFlag(cpuState.A); cycles = 4; }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var comparer = cpuState.A; var cmp = comparer - arg; cpuState.SetFlag(CpuState.Flags.Carry, cmp >= 0); cpuState.SetNegativeFlag((byte) (cmp & 0xFF)); cpuState.SetZeroFlag((byte) (cmp & 0xFF)); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var sum = (ushort) (arg + cpuState.A); if (cpuState.IsFlagSet(CpuState.Flags.Carry)) { ++sum; } var byteSum = (byte)(sum & 0xFF); cpuState.SetOverflow(cpuState.A, arg, byteSum); cpuState.A = byteSum; cpuState.SetZeroFlag(cpuState.A); cpuState.SetNegativeFlag(cpuState.A); cpuState.SetFlag(CpuState.Flags.Carry, sum & 0xFF00); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { // A - M - C -> A N Z C I D V // + + + - - + int a = cpuState.A; arg ^= 0xFF; a += arg; if (cpuState.IsFlagSet(CpuState.Flags.Carry)) { ++a; } var byteResult = (byte) (a & 0xFF); cpuState.SetOverflow(cpuState.A, arg, byteResult); cpuState.A = byteResult; cpuState.SetNegativeFlag(cpuState.A); cpuState.SetZeroFlag(cpuState.A); cpuState.SetFlag(CpuState.Flags.Carry, (byteResult & 0x80) == 0); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var res = (byte) ((arg - 1)&0xFF); write(res); cpuState.SetNegativeFlag(res); cpuState.SetZeroFlag(res); switch (Variants[memory[cpuState.Pc]]) { case AddressingMode.ZeroPage: cycles = 5; break; case AddressingMode.ZeroPageXIndexed: cycles = 6; break; case AddressingMode.Absolute: cycles = 6; break; case AddressingMode.AbsoluteX: cycles = 7; break; } }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { cpuState.Y++; cpuState.SetZeroFlag(cpuState.Y); cpuState.SetNegativeFlag(cpuState.Y); }