예제 #1
0
파일: GameBoyCpu.cs 프로젝트: djlw78/Emux
        public GameBoyCpu(GameBoy device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            _device       = device;
            _disassembler = new Z80Disassembler(device.Memory);

            Registers        = new RegisterBank();
            Alu              = new GameBoyAlu(Registers);
            Breakpoints      = new HashSet <ushort>();
            EnableFrameLimit = true;

            new Thread(CpuLoop)
            {
                Name         = "Z80CPULOOP",
                IsBackground = true
            }.Start();

            _frameTimer = new NativeTimer((timerid, msg, user, dw1, dw2) =>
            {
                _frameStartSignal.Set();
                var time             = DateTime.Now.TimeOfDay;
                var delta            = time - _frameStartTime;
                CyclesPerSecond      = (_ticks - _frameStartTickCount) / delta.TotalSeconds;
                FramesPerSecond      = 1 / delta.TotalSeconds;
                _frameStartTime      = time;
                _frameStartTickCount = _ticks;
            }, 59);
        }
예제 #2
0
        public bool Hit(int weight)
        {
            if (weight < 0)
            {
                throw new ArgumentException("weight");
            }

            long now = NativeTimer.timeGetTime();

            if (current > 0)
            {
                current -= (int)((now - last) / rate);
                if (current < 0)
                {
                    current = 0;
                }
            }

            if (current > burst)
            {
                return(false);
            }

            current += weight;
            last     = now;

            return(true);
        }
예제 #3
0
 static CallbackResult OnWalkRequestSucceed(byte[] data, CallbackResult prevResult)
 {
     if (walkQueue.Count > 0)
     {
         latencyList.Add((int)(NativeTimer.timeGetTime() - walkQueue.Dequeue()));
         UpdateLatency();
     }
     return(CallbackResult.Normal);
 }
예제 #4
0
        static CallbackResult OnServerPing(byte[] data, CallbackResult lastResult)
        {
            if (pingQueue.Count > 0)
            {
                latencyList.Add((int)(NativeTimer.timeGetTime() - pingQueue.Dequeue()));
                UpdateLatency();
            }

            return(data[1] != 0x7F ? CallbackResult.Normal : CallbackResult.Eat);
        }
예제 #5
0
    int refrence    = 0;     // refrence num

    public CacheItem(CallBack delete, bool _forver = false)
    {
        Delete = delete;
        forver = _forver;

        if (!forver)
        {
            deleteTimer = new NativeTimer(Delete, survival, false);
            deleteTimer.Start();
        }
    }
예제 #6
0
        internal static void SendPing()
        {
            if (Core.LoggedIn)
            {
                byte[] data = new byte[2];
                data[0] = 0x73;
                data[1] = 0x7F;

                pingQueue.Enqueue(NativeTimer.timeGetTime());
                Core.SendToServer(data);
            }
        }
예제 #7
0
    public void UnLoad()
    {
        if (unloaded)
        {
            return;
        }
        if (timer != null)
        {
            return;
        }

        timer = new NativeTimer(OnUnload, 0.1f, false);
        timer.Start();
    }
예제 #8
0
 /// <summary>
 /// 该方法中不卸载AB包,只设置Null
 /// </summary>
 public void Clear()
 {
     ab       = null;
     error    = null;
     bytes    = null;
     url      = null;
     text     = null;
     texture  = null;
     unloaded = true;
     if (timer != null)
     {
         timer.Stop();
         timer = null;
     }
 }
예제 #9
0
    int refrence    = 0;     // refrence num

    public CacheItem(CallBack delete, bool _forver, float _survival)
    {
        Delete = delete;
        forver = _forver;

        if (_survival > 0)
        {
            survival = _survival;
        }

        if (!forver)
        {
            deleteTimer = new NativeTimer(Delete, survival, false);
            deleteTimer.Start();
        }
    }
예제 #10
0
    void OnUnload()
    {
        if (ab != null)
        {
            ab.Unload(false);
            ab = null;
        }
        error   = null;
        bytes   = null;
        url     = null;
        text    = null;
        texture = null;

        unloaded = true;
        timer.Stop();
        timer = null;
    }
예제 #11
0
    public LoaderContianer(int synchronize = 1)
    {
        if (synchronize < 1)
        {
            synchronize = 1;
        }

        taskList       = new List <LoaderTask>();
        loaderitemList = new List <LoaderItem>();
        for (int i = 0; i < synchronize; i++)
        {
            LoaderItem item = new LoaderItem();
            item.AddListenerIdle(LoadFinish);
            loaderitemList.Add(item);
        }

        timer = new NativeTimer(Update, 0.3f);
        timer.Start();
    }
예제 #12
0
    void UpdateLoadingUI()
    {
        #region 赋值UI进度条

        progress = (int)(operation.progress * 100);

        #endregion

        if (operation.isDone)
        {
            timer.Stop();
            timer = null;

            if (callback != null)
            {
                callback();
            }
        }
    }
예제 #13
0
    public void LoadAsync(CallBack cback = null)
    {
        callback = cback;
        if (string.IsNullOrEmpty(_sceneName))
        {
            return;
        }

        if (isCurrent())
        {
            Debug.LogError("加载场景为当前场景!!");
            return;
        }

        Resources.UnloadUnusedAssets();
        System.GC.Collect();

        operation = SceneManager.LoadSceneAsync(_sceneName, LoadSceneMode.Single);
        timer     = new NativeTimer(UpdateLoadingUI, 0.01f, true);
        timer.Start();
    }
예제 #14
0
 static CallbackResult OnWalkRequest(byte[] data, CallbackResult prevResult)
 {
     walkQueue.Enqueue(NativeTimer.timeGetTime());
     return(CallbackResult.Normal);
 }
예제 #15
0
        protected override void InitControls()
        {


            this.Text = CAPTION;
            this.Name = "Window1";
            //this.StatusBar = false;
            // this.Left = 100;
            //this.Top = 100;
            this.Width = 600;
            this.Height = 400;
            
            this._ControlTest = new ControlTest();
            this._ControlTest.Width = 200;
            this._ControlTest.Height = 30;
            this._ControlTest.Left = 300;
            this._ControlTest.Top = 80;
            this._ControlTest.Name = "TEST_CONTAINER";
            
            //this.BackColor = ColorTool.LightGray;
            this.StartUpPosition = WindowsStartupPosition.CenterScreen;
            this.BackColor = ColorTool.White;
            this._Timer = new NativeTimer();
            this._Timer.Interval = 100;
            //this._Timer.ControlId = 700;
            this._Timer.Tick += Timer_OnTick;
            this._Button = new NativeButton
            {
                Left = 10,
                Top = 10,
                Width = 100,
                Height = 30,
                Text = "Test",
                Name = "bnTest",
                BackColor = ColorTool.Blue,
                ForeColor = ColorTool.Green

            };

            this._Button1 = new NativeButton
            {
                Left = 150,
                Top = 10,
                Width = 100,
                Height = 30,
                Text = "Test",
                Name = "bnTest"//,
                //ControlId = 505
            };
            this._Button.Clicked += button_OnClicked;
            this._Button.DblClicked += button_OnDblClicked;
            this._Button1.Clicked += button1_OnClicked;
            this._Button1.DblClicked += button1_OnDblClicked;

            this._Button3 = new NativeButton
            {
                Location = new Point(300, 10),
                Width = 20,
                Height = 30,
                Name = "SelectFolder",
                Text = "…"
            };

            this._Button3.Clicked += Button3_Click;
            this._ComboBox = new NativeComboBox();
            this._ComboBox.Location = new Point(350, 10);
            
            this._ComboBox.Height = 30;
            this._ComboBox.Width = 200;
            this._ComboBox.Name = "cbbTest";
            this._ComboBox.ForeColor = ColorTool.Blue;
            this._ComboBox.BackColor = ColorTool.Green;
            this._ComboBox.Font = new Font() { Name = "Arial", Size = 10 };
            this._ComboBox.SelChange += ComboBox_SelChange;


            this._TextBox = new NativeTextBox
            {
                Left = 10,
                Top = 50,
                Width = 100,
                Height = 30,
                Text = "ATEST",
                Name = "txtTest",
                Font = new Font() { Name = "Arial", Size = 14 },
                ForeColor = ColorTool.Read
                //ControlId = 502
            };
            this._TextBox.Change += TextBox_Change;

            this._TextBox2 = new NativeTextBox
            {
                Left = 10,
                Top = 150,
                Width = 100,
                Height = 30,
                Text = "",
                Name = "txt2Test",
                //ControlId = 503,
                BackColor = ColorTool.Black,
                ForeColor = ColorTool.White

            };

            this._Label1 = new NativeLabel
            {
                Left = 10,
                Top = 200,
                Width = 100,
                Height = 30,
                Text = "Dies ist ein Label"//,
                                           //BackColor=ColorTool.Read,
                                           //ForeColor = ColorTool.Green,
                                           //ControlId = 504

            };
            this._Label1.Clicked += Label1_Click;
            this._Label1.DblClicked += Label1_DblClick;

            this._Bitmap = new NativeBitmap();
            this._Bitmap.BitMap = "Skype.bmp";
            this._Bitmap.Left = 150;
            this._Bitmap.Top = 50;
            this._Bitmap.Width = 100;
            this._Bitmap.Height = 100;

            this._CheckBox = new NativeCheckBox();
            this._CheckBox.Left = 300;
            this._CheckBox.Top = 50;
            this._CheckBox.Width = 200;
            this._CheckBox.Height = 30;
            this._CheckBox.Text = "TEST CHECKBOX";
            this._CheckBox.BackColor = ColorTool.White;
            this._CheckBox.Checked = true;

            this._ListBox = new NativeListBox();
            this._ListBox.Left = 300;
            this._ListBox.Top = 200;
            this._ListBox.Width = 400;
            this._ListBox.Height = 400;
            this._ListBox.BackColor = ColorTool.Yellow;
            this._ListBox.ForeColor = ColorTool.Read;
            this._ListBox.Font = new Font() { Name = "Arial", Size = 16 };
            this._ListBox.MultiSelect = true;
            this._ListBox.DblClicked+=ListBox_DblClicked;
            
            this._ListBox.SelChange+=ListBox_SelChange;

            this._ProgressBar = new NativeProgress
            {
                Left = 10,
                Top = 250,
                Width = 150,
                Height = 30//,
                //ControlId = 507
            };



            this._TextBox.Clicked += TextBox_Click;
            
            this.Controls.Add(this._Button);
            this.Controls.Add(this._Button1);
            this.Controls.Add(this._Button3);
            this.Controls.Add(this._ComboBox);
            this.Controls.Add(this._TextBox);
            this.Controls.Add(this._TextBox2);
            this.Controls.Add(this._Label1);
            this.Controls.Add(this._Bitmap);
            this.Controls.Add(this._CheckBox);
            this.Controls.Add(this._ListBox);
            this.Controls.Add(this._ProgressBar);
            this.Controls.Add(this._Timer);
            this.Controls.Add(this._ControlTest);
            Click += Window1_Click;
            DoubleClick += Window1_DblClick;
            Create += Window1_Create;
            this.MouseMove += Window1_MoseMove;
        }
예제 #16
0
    void resetSec()
    {
        NativeTimer timer = new NativeTimer(survtime, 0.01f, true, 300);

        timer.Start();
    }
예제 #17
0
 static CallbackResult OnClientPing(byte[] data, CallbackResult lastResult)
 {
     pingQueue.Enqueue(NativeTimer.timeGetTime());
     System.Diagnostics.Debug.WriteLine("Ping sent by client", "Information");
     return(CallbackResult.Normal);
 }