Example #1
0
        /// <summary>
        /// Function added to display result of cpu exercizer test
        /// </summary>
        public void PerformMultipleStep(string fullPath, int memoryOffset)
        {
            if (MCU.LoadFileInMemoryAt(fullPath, memoryOffset))
            {
                _currentState = TCurrentState.RUNNING;
                while (_currentState != TCurrentState.STOPPED)
                {
                    if (!_cpu.Halted)
                    {
                        _cpu.Fetch();
                        _cpu.Execute();
                    }

                    // CP/M warm boot (test finished and restarted itself)
                    if (_cpu.PC == 0x00)
                    {
                        _currentState = TCurrentState.STOPPED;
                    }

                    // Call to CP/M bios emulated function to write characters on screen
                    if (_cpu.PC == 0x05)
                    {
                        _cpu.PerformBdosCall();
                    }
                }
            }
        }
Example #2
0
        private void TimerAsync_CallBack(object state)
        {
            if (_currentState != TCurrentState.STOPPED)
            {
                long currentTime = _stopWatch.ElapsedMilliseconds;
                long elapsedTimeFromLastPeriod = currentTime - _lastValue;

                long numberOfCycleToRun = 2000 * elapsedTimeFromLastPeriod;
                while (numberOfCycleToRun > 0 && _currentState != TCurrentState.STOPPED)
                {
                    if (_currentState == TCurrentState.STOPPED)
                    {
                        break;
                    }
                    else if (_currentState == TCurrentState.PAUSED)
                    {
                        _stopWatch.Stop();
                        _autoReset.WaitOne();
                        _stopWatch.Start();
                    }

                    numberOfCycleToRun -= PerformSingleStep();
                }

                _lastValue = currentTime;
                _timer.Change(0, Timeout.Infinite);
            }
            else
            {
                _timer.Change(Timeout.Infinite, Timeout.Infinite);
                OnEmulatorStateChange(_currentState = TCurrentState.STOPPED);
            }
        }
Example #3
0
 public void ResumeEmulation()
 {
     if (_currentState == TCurrentState.PAUSED)
     {
         _autoReset.Set();
         _currentState = TCurrentState.RUNNING;
     }
 }
Example #4
0
 public void Run(string[] multipleRomFiles)
 {
     if (_currentState == TCurrentState.STOPPED)
     {
         if (MCU.LoadMultipleFiles(multipleRomFiles))
         {
             _stopWatch.Start();
             _currentState = TCurrentState.RUNNING;
             _timer        = new Timer(TimerAsync_CallBack, null, 0, Timeout.Infinite);
         }
     }
 }
Example #5
0
 public void Run(String fullPath, int offset)
 {
     if (_currentState == TCurrentState.STOPPED)
     {
         if (MCU.LoadFileInMemoryAt(fullPath, offset))
         {
             _stopWatch.Start();
             _currentState = TCurrentState.RUNNING;
             _timer        = new Timer(TimerAsync_CallBack, null, 0, Timeout.Infinite);
         }
     }
 }
Example #6
0
 public void PauseEmulation()
 {
     if (_currentState == TCurrentState.RUNNING)
     {
         _currentState = TCurrentState.PAUSED;
     }
     else if (_currentState == TCurrentState.PAUSED)
     {
         _currentState = TCurrentState.RUNNING;
         _autoReset.Set();
     }
 }
Example #7
0
        public void StopEmulation()
        {
            if (_currentState != TCurrentState.STOPPED)
            {
                _currentState = TCurrentState.STOPPED;
                _stopWatch.Stop();

                _mcu.Clear();
                _cpu.Initialize();
                _gpu.Initialize();
            }
        }
Example #8
0
        private Emulator()
        {
            _currentState        = TCurrentState.STOPPED;
            _nextVblankInterrupt = GPU.END_VBLANK_OPCODE;

            _mcu = new MCUR();

            _cpu = new CPU();
            _cpu.Initialize();

            _gpu = new GPU();
            _gpu.Initialize();

            _devices   = new Devices();
            _stopWatch = new Stopwatch();

            _currentState = TCurrentState.STOPPED;
            _autoReset    = new AutoResetEvent(false);
        }