Exemple #1
0
        /// <summary>
        /// Executes a single frame
        /// </summary>
        public virtual void ExecuteFrame(bool render, bool renderSound)
        {
            InputRead    = false;
            _render      = render;
            _renderSound = renderSound;

            FrameCompleted = false;

            TapeDevice.StartFrame();

            if (_renderSound)
            {
                BuzzerDevice.StartFrame();
                TapeBuzzer.StartFrame();
                if (AYDevice != null)
                {
                    AYDevice.StartFrame();
                }
            }

            PollInput();

            while (CurrentFrameCycle < ULADevice.FrameLength)
            {
                // check for interrupt
                ULADevice.CheckForInterrupt(CurrentFrameCycle);

                // run a single CPU instruction
                CPU.ExecuteOne();

                // cycle the tape device
                TapeDevice.TapeCycle();
            }

            // we have reached the end of a frame
            LastFrameStartCPUTick = CPU.TotalExecutedCycles - OverFlow;

            // paint the buffer if needed
            if (ULADevice.needsPaint && _render)
            {
                ULADevice.UpdateScreenBuffer(ULADevice.FrameLength);
            }

            if (_renderSound)
            {
                BuzzerDevice.EndFrame();
                TapeBuzzer.EndFrame();
            }

            if (AYDevice != null)
            {
                AYDevice.EndFrame();
            }

            FrameCount++;

            // setup for next frame
            ULADevice.ResetInterrupt();

            TapeDevice.EndFrame();

            FrameCompleted = true;

            // is this a lag frame?
            Spectrum.IsLagFrame = !InputRead;
        }
Exemple #2
0
        /// <summary>
        /// Executes a single frame
        /// </summary>
        public virtual void ExecuteFrame(bool render, bool renderSound)
        {
            InputRead    = false;
            _render      = render;
            _renderSound = renderSound;

            FrameCompleted = false;

            if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded)
            {
                TapeDevice.StartFrame();
            }

            if (_renderSound)
            {
                BuzzerDevice.StartFrame();
                TapeBuzzer.StartFrame();

                if (AYDevice != null)
                {
                    AYDevice.StartFrame();
                }
            }

            PollInput();

            while (CurrentFrameCycle < ULADevice.FrameLength)
            {
                // check for interrupt
                ULADevice.CheckForInterrupt(CurrentFrameCycle);

                // run a single CPU instruction
                CPU.ExecuteOne();

                // cycle the tape device
                if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded)
                {
                    TapeDevice.TapeCycle();
                }
            }

            // we have reached the end of a frame
            LastFrameStartCPUTick = CPU.TotalExecutedCycles - OverFlow;

            // paint the buffer if needed
            if (ULADevice.needsPaint && _render)
            {
                ULADevice.UpdateScreenBuffer(ULADevice.FrameLength);
            }

            if (_renderSound)
            {
                BuzzerDevice.EndFrame();
                TapeBuzzer.EndFrame();
            }

            if (AYDevice != null)
            {
                AYDevice.EndFrame();
            }

            FrameCount++;

            // setup for next frame
            ULADevice.ResetInterrupt();

            if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded)
            {
                TapeDevice.EndFrame();
            }

            FrameCompleted = true;

            // is this a lag frame?
            Spectrum.IsLagFrame = !InputRead;

            // FDC debug

            if (UPDDiskDevice != null && UPDDiskDevice.writeDebug)
            {
                // only write UPD log every second
                if (FrameCount % 10 == 0)
                {
                    System.IO.File.WriteAllText(UPDDiskDevice.outputfile, UPDDiskDevice.outputString);
                }
            }
        }