예제 #1
0
        public static ushort GetIndirectX(MOS6502 CPU)
        {
            var incompleteXAddress = CPU.ReadNextByte();

            CPU.IncrementPC();

            var intermediateAddress = (byte)(incompleteXAddress + CPU.Registers.X);

            return(intermediateAddress == 0xFF
                ? (ushort)(CPU.ReadByteAt(0xFF) | CPU.ReadByteAt(0x00) << 8)
                : CPU.ReadShortAt(intermediateAddress));
        }
예제 #2
0
        public static ushort GetIndirectYWrite(MOS6502 CPU)
        {
            intermediateAddress = CPU.ReadNextByte();
            CPU.IncrementPC();

            var baseAddress = intermediateAddress == 0xFF
                ? (ushort)(CPU.ReadByteAt(0xFF) | CPU.ReadByteAt(0x00) << 8)
                : CPU.ReadShortAt((ushort)intermediateAddress);

            CPU.CycleFinished();

            return((ushort)(baseAddress + CPU.Registers.Y));
        }
예제 #3
0
        public static ushort GetIndirect(MOS6502 CPU)
        {
            intermediateAddress = CPU.ReadNextShort();

            // 6502 bug in indirect JMP...
            if ((intermediateAddress & 0x00FF) == 0xFF)
            {
                byte lowByte  = CPU.ReadByteAt(intermediateAddress);
                byte highByte = CPU.ReadByteAt((ushort)(intermediateAddress - 0x00FF));

                return((ushort)(highByte << 8 | lowByte));
            }

            return(CPU.ReadShortAt(intermediateAddress));
        }
예제 #4
0
        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);
        }