Esempio n. 1
0
        protected virtual void OnUpdate(object sender, EventArgs e)
        {
            ups_counter.Inc();
            update_watch.Start();

            model.Update(window.Keyboard);

            update_watch.Stop();
        }
Esempio n. 2
0
        private void run()
        {
            HardReset();

            while (Mode != PICControllerMode.FINISHED)
            {
                uint currCmdCycleCount = 1;

                //################
                //#     MISC     #
                //################

                Frequency.Inc();

                if (GetPC() >= CommandList.Length)                 // PC > Commandcount
                {
                    Mode = PICControllerMode.FINISHED;
                    continue;
                }

                HandleIncomingEvents();

                //################
                //#  DEBUGGING   #
                //################

                if (Mode == PICControllerMode.FINISHED)
                {
                    continue;
                }

                if (Mode == PICControllerMode.PAUSED)
                {
                    Thread.Sleep(0);                     // Release Control

                    continue;
                }

                if (Mode == PICControllerMode.CONTINUE)
                {
                    Mode = PICControllerMode.RUNNING;
                }
                else if (Mode == PICControllerMode.SKIPONE)
                {
                    Mode = PICControllerMode.PAUSED;
                }
                else
                {
                    if (breakpoints[GetPC()])
                    {
                        Mode = PICControllerMode.PAUSED;
                        continue;                         // Continue so the current Cmd is NOT executed
                    }
                }



                //################
                //#    FETCH     #
                //################

                PICCommand cmd = CommandList[GetPC()];

                UnreleasedSleep((int)SimulationSpeed);

                if (!IsInSleep)
                {
                    //################
                    //# INCREMENT PC #
                    //################

                    SetPC_13Bit(GetPC() + 1);

                    //################
                    //#   EXECUTE    #
                    //################

                    cmd.Execute(this);
                    currCmdCycleCount = cmd.GetCycleCount(this);


                    //################
                    //#   AFTERMATH  #
                    //################

                    Tmr0.Update(this, currCmdCycleCount);

                    Clocks[0].Update(this);
                    Clocks[1].Update(this);
                    Clocks[2].Update(this);
                    Clocks[3].Update(this);
                }

                //################
                //#    OTHERS    #
                //################

                Interrupt.Update();
                Cycles += currCmdCycleCount;
                WatchDog.Update(this, currCmdCycleCount);
            }

            Mode = PICControllerMode.WAITING;
        }
Esempio n. 3
0
 protected virtual void OnRender(object sender, EventArgs e)
 {
     fps_counter.Inc();
 }
        private void onIdle()
        {
            IdleCounter.Inc();

            if (controller != null)
            {
                UpdateRegister();
                UpdateStackDisplay();

                IconBar.SetPC(controller.GetSCLineForPC(controller.GetPC()));

                lblFreqModel.Text          = FormatFreq((uint)controller.Frequency.Frequency);
                lblFreqView.Text           = FormatFreq((uint)IdleCounter.Frequency);
                lblRunTime.Text            = FormatRuntime(controller.GetRunTime());
                lblRegW.Text               = "0x" + string.Format("{0:X02}", controller.GetWRegister());
                lblRegPC.Text              = "0x" + string.Format("{0:X04}", controller.GetPC());
                lblQuartzFreq.Text         = FormatFreq(controller.EmulatedFrequency);
                btnSetQuartzFreq.IsEnabled = true;
                lblWatchDogTmr.Text        = string.Format("{0:000.000} %", controller.GetWatchDogPerc() * 100);
                chkbxWatchdog.IsEnabled    = true;
                chkbxWatchdog.IsChecked    = controller.IsWatchDogEnabled();

                regClock_0.UpdateUI(controller);
                regClock_1.UpdateUI(controller);
                regClock_2.UpdateUI(controller);
                regClock_3.UpdateUI(controller);

                regClock_0.IsEnabled = controller.Mode == PICControllerMode.WAITING || controller.Mode == PICControllerMode.PAUSED;
                regClock_1.IsEnabled = controller.Mode == PICControllerMode.WAITING || controller.Mode == PICControllerMode.PAUSED;
                regClock_2.IsEnabled = controller.Mode == PICControllerMode.WAITING || controller.Mode == PICControllerMode.PAUSED;
                regClock_3.IsEnabled = controller.Mode == PICControllerMode.WAITING || controller.Mode == PICControllerMode.PAUSED;

                rs232_link.Update(controller);
            }
            else
            {
                ClearRegister();
                ClearStackDisplay();

                IconBar.SetPC(0);

                lblFreqModel.Text          = FormatFreq(0);
                lblFreqView.Text           = FormatFreq(0);
                lblRunTime.Text            = FormatRuntime(0);
                lblRegW.Text               = "0x" + string.Format("{0:X02}", 0);
                lblRegPC.Text              = "0x" + string.Format("{0:X04}", 0);
                lblQuartzFreq.Text         = FormatFreq(0);
                btnSetQuartzFreq.IsEnabled = false;
                lblWatchDogTmr.Text        = string.Format("{0:000,000} %", 0);
                chkbxWatchdog.IsEnabled    = false;

                regClock_0.ResetUI();
                regClock_1.ResetUI();
                regClock_2.ResetUI();
                regClock_3.ResetUI();

                regClock_0.IsEnabled = false;
                regClock_1.IsEnabled = false;
                regClock_2.IsEnabled = false;
                regClock_3.IsEnabled = false;

                rs232_link.Update(controller);
            }

            txtCode.IsReadOnly = controller != null && controller.Mode != PICControllerMode.WAITING;
            CommandManager.InvalidateRequerySuggested();
        }