Пример #1
0
        protected internal virtual void executeInterrupts(IList <AbstractInterruptHandler> interruptHandlers, IAction afterInterruptAction, IAction afterHandlerAction)
        {
            if (interruptHandlers != null)
            {
                for (IEnumerator <AbstractInterruptHandler> it = interruptHandlers.GetEnumerator(); it.MoveNext();)
                {
                    AbstractInterruptHandler interruptHandler = it.Current;
                    if (interruptHandler != null)
                    {
                        interruptHandler.execute();
                    }
                }
            }

            if (allegrexInterruptHandlers.Count == 0)
            {
                if (afterInterruptAction != null)
                {
                    afterInterruptAction.execute();
                }
                onEndOfInterrupt();
            }
            else
            {
                InterruptState interruptState = new InterruptState();
                interruptState.save(insideInterrupt, Emulator.Processor.cpu, afterInterruptAction, afterHandlerAction);
                InsideInterrupt = true;

                IEnumerator <AbstractAllegrexInterruptHandler> allegrexInterruptHandlersIterator = allegrexInterruptHandlers.GetEnumerator();
                IAction continueAction = new AfterSubIntrAction(this, interruptState, allegrexInterruptHandlersIterator);

                continueCallAllegrexInterruptHandler(interruptState, allegrexInterruptHandlersIterator, continueAction);
            }
        }
Пример #2
0
        /// <summary>
        /// Set/clear a specific interrupt persistence
        /// This is used to have more than 1 cycle before generating an
        /// interruption.
        /// </summary>
        /// <param name="interupt">The percistence cycles</param>
        /// <param name="state">True to set the interrupt, false to clear</param>
        public void SetInterrupt(InterruptState interupt, bool state)
        {
            WriteRegister(Registers.PERS, (byte)interupt);
            var enable = I2cRead8(Registers.ENABLE);

            enable = state ? enable |= (byte)Registers.ENABLE_AIEN : enable = (byte)(enable & ~(byte)Registers.ENABLE_AIEN);
            WriteRegister(Registers.ENABLE, enable);
        }
Пример #3
0
        public void SetInterruptLine(InterruptType type, InterruptState state)
        {
            switch (type)
            {
            case InterruptType.Maskable:
                intState = state;
                break;

            case InterruptType.NonMaskable:
                nmiState = state;
                break;

            default: throw new EmulationException("Z80A: Unknown interrupt type");
            }
        }
Пример #4
0
        public virtual void Reset()
        {
            af.Word  = bc.Word = de.Word = hl.Word = 0;
            af_.Word = bc_.Word = de_.Word = hl_.Word = 0;
            ix.Word  = iy.Word = 0;
            i        = r = 0;
            pc       = 0;
            sp       = 0;

            iff1 = iff2 = eiDelay = halt = false;
            im   = 0;

            intState = nmiState = InterruptState.Clear;

            currentCycles = 0;
        }
Пример #5
0
        public virtual void continueCallAllegrexInterruptHandler(InterruptState interruptState, IEnumerator <AbstractAllegrexInterruptHandler> allegrexInterruptHandlersIterator, IAction continueAction)
        {
            bool somethingExecuted = false;

            do
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                if (allegrexInterruptHandlersIterator != null && allegrexInterruptHandlersIterator.hasNext())
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    AbstractAllegrexInterruptHandler allegrexInterruptHandler = allegrexInterruptHandlersIterator.next();
                    if (allegrexInterruptHandler != null)
                    {
                        //if (log.DebugEnabled)
                        {
                            Console.WriteLine("Calling InterruptHandler " + allegrexInterruptHandler.ToString());
                        }
                        allegrexInterruptHandler.copyArgumentsToCpu(Emulator.Processor.cpu);
                        Modules.ThreadManForUserModule.callAddress(allegrexInterruptHandler.Address, continueAction, true);
                        somethingExecuted = true;
                    }
                }
                else
                {
                    break;
                }
            } while (!somethingExecuted);

            if (!somethingExecuted)
            {
                // No more handlers, end of interrupt
                InsideInterrupt = interruptState.restore(Emulator.Processor.cpu);
                IAction afterInterruptAction = interruptState.AfterInterruptAction;
                if (afterInterruptAction != null)
                {
                    afterInterruptAction.execute();
                }
                onEndOfInterrupt();
            }
        }