Exemple #1
0
        public virtual void Execute(Clock.Clock clock, byte cycle)
        {
            Clock.ClockEntry first = null;
            Clock.ClockEntry next  = null;

            if (_cpu.NMI.Check())
            {
                first = next = new Clock.ClockEntryRep(new InterruptOp(_cpu, 0xfffa), 7);
            }
            else if (_cpu.IRQ.IsRaised && !_cpu.State.P.IrqMask)
            {
                first = next = new Clock.ClockEntryRep(new InterruptOp(_cpu, 0xfffe), 7);
            }
            else
            {
                _cpu.Opcode = _cpu.Memory.Read(_cpu.State.PC.Value);
                _cpu.State.PC.Next();

                DecodingTable.Entry decoded = DecodingTable.Opcodes[_cpu.Opcode];
                DecodeAddressOp     addrOp  = new DecodeAddressOp(_cpu, decoded._addressing);
                ExecuteOpcodeOp     execOp  = new ExecuteOpcodeOp(_cpu, decoded._instruction, decoded._timing._prolongOnPageCross);

                byte addrTime = decoded._timing._addressingTime;
                byte execTime = decoded._timing._execTime;

                first           = addrTime < 2 ? new Clock.ClockEntry(addrOp, true) : new Clock.ClockEntryRep(addrOp, addrTime);
                first.ComboNext = execTime == 0 || addrTime == 0;

                next = first.Next = execTime < 2 ? new Clock.ClockEntry(execOp) : new Clock.ClockEntryRep(execOp, execTime);

                sbyte writeCycles = decoded._timing._writeTime;
                if (writeCycles >= 0)
                {
                    if (writeCycles < 2)
                    {
                        next.ComboNext = writeCycles == 0;
                        next           = next.Next = new Clock.ClockEntry(new WriteResultOp(_cpu));
                    }
                    else
                    {
                        next = next.Next = new Clock.ClockEntryRep(new Clock.StallOp(), (byte)(writeCycles - 1));
                        next = next.Next = new Clock.ClockEntry(new WriteResultOp(_cpu));
                    }
                }
            }

            next.Next = new Clock.ClockEntry(new DecodeOpcodeOp(_cpu));
            clock.QueueOps(first, _cpu.Phase);
        }
Exemple #2
0
        public virtual void Execute(Clock.Clock clock, byte cycle)
        {
            Clock.ClockEntry first = null;
            Clock.ClockEntry next = null;

            if (_cpu.NMI.Check())
                first = next = new Clock.ClockEntryRep(new InterruptOp(_cpu, 0xfffa), 7);
            else if (_cpu.IRQ.IsRaised && !_cpu.State.P.IrqMask)
                first = next = new Clock.ClockEntryRep(new InterruptOp(_cpu, 0xfffe), 7);
            else
            {
                _cpu.Opcode = _cpu.Memory.Read(_cpu.State.PC.Value);
                _cpu.State.PC.Next();

                DecodingTable.Entry decoded = DecodingTable.Opcodes[_cpu.Opcode];
                DecodeAddressOp addrOp = new DecodeAddressOp(_cpu, decoded._addressing);
                ExecuteOpcodeOp execOp = new ExecuteOpcodeOp(_cpu, decoded._instruction, decoded._timing._prolongOnPageCross);

                byte addrTime = decoded._timing._addressingTime;
                byte execTime = decoded._timing._execTime;

                first = addrTime < 2 ? new Clock.ClockEntry(addrOp, true) : new Clock.ClockEntryRep(addrOp, addrTime);
                first.ComboNext = execTime == 0 || addrTime == 0;

                next = first.Next = execTime < 2 ? new Clock.ClockEntry(execOp) : new Clock.ClockEntryRep(execOp, execTime);

                sbyte writeCycles = decoded._timing._writeTime;
                if (writeCycles >= 0)
                {
                    if (writeCycles < 2)
                    {
                        next.ComboNext = writeCycles == 0;
                        next = next.Next = new Clock.ClockEntry(new WriteResultOp(_cpu));
                    }
                    else
                    {
                        next = next.Next = new Clock.ClockEntryRep(new Clock.StallOp(), (byte)(writeCycles - 1));
                        next = next.Next = new Clock.ClockEntry(new WriteResultOp(_cpu));
                    }
                }
            }

            next.Next = new Clock.ClockEntry(new DecodeOpcodeOp(_cpu));
            clock.QueueOps(first, _cpu.Phase);
        }