public static ushort GetIndirectY(MOS6502 CPU) { intermediateAddress = CPU.ReadNextByte(); CPU.IncrementPC(); var baseAddress = intermediateAddress == 0xFF ? (ushort)(CPU.ReadByteAt(0xFF) | CPU.ReadByteAt(0x00) << 8) : CPU.ReadShortAt((ushort)intermediateAddress); var finalAddress = (ushort)(baseAddress + CPU.Registers.Y); if (AddressingMode.NotSamePage(baseAddress, CPU.Registers.Y)) { CPU.CycleFinished(); } return(finalAddress); }
public static bool WasSamePage(ushort a1, byte a2) => AddressingMode.WasSamePage(a1, (sbyte)a2);
public static ushort GetAddressedOperand(MOS6502 CPU, OpcodeContainer container) { operandValue = 0; intermediateAddress = 0; address = 0; switch (container.AddressingMode) { case AddressingModes.Implied: address = 0x0000; CPU.CycleFinished(); break; case AddressingModes.Accumulator: address = 0x0000; CPU.CycleFinished(); break; case AddressingModes.Immediate: address = AddressingMode.GetImmediate(CPU); break; case AddressingModes.Absolute: address = AddressingMode.GetAbsolute(CPU); break; case AddressingModes.AbsoluteX: address = AddressingMode.GetAbsoluteX(CPU); break; case AddressingModes.AbsoluteXWrite: address = AddressingMode.GetAbsoluteXWrite(CPU); break; case AddressingModes.AbsoluteY: address = AddressingMode.GetAbsoluteY(CPU); break; case AddressingModes.Indirect: address = AddressingMode.GetIndirect(CPU); break; case AddressingModes.IndirectX: address = AddressingMode.GetIndirectX(CPU); break; case AddressingModes.IndirectY: address = AddressingMode.GetIndirectY(CPU); break; case AddressingModes.IndirectYWrite: address = AddressingMode.GetIndirectYWrite(CPU); break; case AddressingModes.ZeroPage: address = AddressingMode.GetZeroPage(CPU); break; case AddressingModes.ZeroPageX: address = AddressingMode.GetZeroPageX(CPU); break; case AddressingModes.ZeroPageY: address = AddressingMode.GetZeroPageY(CPU); break; case AddressingModes.Relative: address = AddressingMode.GetRelative(CPU); break; default: throw new InvalidOperationException(); } if (MOS6502.IsDebug) { CPU.LastAccessedAddress = AddressingMode.GetAddressAsString(CPU, container); } return(address); }