public SimpleEngine() { _enabled = false; Interval = 1; thread = new Thread(delegate() { while (true) { if (_enabled) { TickEvent.Invoke(this, 0); } Thread.Sleep((int)(Interval * 1000)); // 至少等待Interval秒 } }); var time = DateTime.Now; TickEvent += (sender, tick) => { var newtime = DateTime.Now; //Trace.WriteLine(newtime-time); // 测试函数,显示间隔 #if DEBUG Fps = (int)(1000 / (newtime - time).TotalMilliseconds); Notify("Fps"); #endif time = newtime; Trace.Flush(); }; }
public void RaiseTickEvent() { if (TickEvent != null) { TickEvent.Invoke(this, e); } }
public void JumpRelative(byte value, ref ushort pc) { sbyte signed = unchecked ((sbyte)value); pc = (ushort)(pc + signed); TickEvent?.Invoke(); }
public void Push(ref ushort pointer, byte valueHigh, byte valueLow) { pointer -= 2; TickEvent?.Invoke(); memory.WriteWord(pointer, BitUtils.BytesToUshort(valueHigh, valueLow)); TickEvent?.Invoke(); TickEvent?.Invoke(); }
public void Return(ref ushort sp, ref ushort pc) { pc = memory.ReadWord(sp); TickEvent?.Invoke(); TickEvent?.Invoke(); sp = (ushort)(sp + 2); TickEvent?.Invoke(); }
public void ReturnConditional(ref ushort sp, ref ushort pc, Flag flag, bool condition, byte flags) { TickEvent?.Invoke(); if (FlagUtils.GetFlag(flag, flags) == condition) { Return(ref sp, ref pc); } }
public void Call(ushort address, ref ushort sp, ref ushort pc) { sp = (ushort)(sp - 2); memory.WriteWord(sp, pc); TickEvent?.Invoke(); TickEvent?.Invoke(); pc = address; TickEvent?.Invoke(); }
public void DecrementWord(ref byte targetHigh, ref byte targetLow) { ushort target = BitUtils.BytesToUshort(targetHigh, targetLow); target = (ushort)(target - 1); targetHigh = BitUtils.MostSignificantByte(target); targetLow = BitUtils.LeastSignificantByte(target); TickEvent?.Invoke(); }
public void SetBit(byte addrHigh, byte addrLow, int index, bool bit) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); byte data = memory.ReadByte(address); TickEvent?.Invoke(); SetBit(ref data, index, bit); memory.WriteByte(address, data); TickEvent?.Invoke(); }
public void WriteToAddressAndIncrement(ref byte addrHigh, ref byte addrLow, byte value, short addValue) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); memory.WriteByte(address, value); TickEvent?.Invoke(); address = (ushort)(address + addValue); addrHigh = BitUtils.MostSignificantByte(address); addrLow = BitUtils.LeastSignificantByte(address); }
public void LoadFromAddressAndIncrement(ref byte dest, ref byte addrHigh, ref byte addrLow, short value) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); dest = memory.ReadByte(address); TickEvent?.Invoke(); address = (ushort)(address + value); addrHigh = BitUtils.MostSignificantByte(address); addrLow = BitUtils.LeastSignificantByte(address); }
public void Pop(ref byte valueHigh, ref byte valueLow, ref ushort pointer) { ushort value = memory.ReadWord(pointer); pointer += 2; TickEvent?.Invoke(); TickEvent?.Invoke(); valueHigh = BitUtils.MostSignificantByte(value); valueLow = BitUtils.LeastSignificantByte(value); }
public void Swap(byte addrHigh, byte addrLow, ref byte flags) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); byte data = memory.ReadByte(address); TickEvent?.Invoke(); Swap(ref data, ref flags); memory.WriteByte(address, data); TickEvent?.Invoke(); }
public void RotateLeftThroughCarry(byte addrHigh, byte addrLow, ref byte flags) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); byte data = memory.ReadByte(address); TickEvent?.Invoke(); RotateLeftThroughCarry(ref data, ref flags, false); memory.WriteByte(address, data); TickEvent?.Invoke(); }
private void OnTimerEvent(object sender, ElapsedEventArgs args) { _timeRemainingInSeconds -= 1; TickEvent?.Invoke(this, EventArgs.Empty); if (_timeRemainingInSeconds <= 0) { Expire(); } }
void ICountdownService.Reset() { if (-1 == infoPtr) { return; } base.Stop(); CurrentInfo = countdownInfos[infoPtr]; TickEvent?.Invoke(CurrentInfo); }
public TimerEngine() { _tick = 0; Elapsed += delegate(object sender, ElapsedEventArgs e) { lock (this) { TickEvent.Invoke(this, _tick++); } }; }
public void DecrementInMemory(byte addrHigh, byte addrLow, ref byte flags) { ushort address = BitUtils.BytesToUshort(addrHigh, addrLow); byte origValue = memory.ReadByte(address); TickEvent?.Invoke(); memory.WriteByte(address, (byte)(origValue - 1)); FlagUtils.SetFlag(Flag.Z, (byte)(origValue - 1) == 0, ref flags); FlagUtils.SetFlag(Flag.N, true, ref flags); FlagUtils.SetFlag(Flag.H, (origValue & 0x0F) < 1, ref flags); TickEvent?.Invoke(); }
private static void TickLoop(UInt64 times) { UInt64 i = 0; while (i != times) { GameTick++; TickEvent?.Invoke(null, GameTick); i++; } }
public void Tick() { if (!IsRunning) { return; } timeLeft = Mathf.Max(0, timeLeft - Time.deltaTime); TickEvent?.Invoke(); if (timeLeft <= 0) { IsRunning = false; } }
public void AddSigned(ref ushort to, byte value, ref byte flags) { ushort originalValue = to; sbyte valueSigned = unchecked ((sbyte)value); to = (ushort)(to + valueSigned); FlagUtils.SetFlag(Flag.Z, false, ref flags); FlagUtils.SetFlag(Flag.N, false, ref flags); FlagUtils.SetFlag(Flag.H, (originalValue & 0x0F) + (value & 0x0F) > 0x0F, ref flags); FlagUtils.SetFlag(Flag.C, (originalValue & 0xFF) + value > 0xFF, ref flags); TickEvent?.Invoke(); TickEvent?.Invoke(); }
public void Add(ref byte toHigh, ref byte toLow, byte valueHigh, byte valueLow, ref byte flags) { ushort to = BitUtils.BytesToUshort(toHigh, toLow); ushort value = BitUtils.BytesToUshort(valueHigh, valueLow); ushort result = (ushort)((to + value) & 0xFFFF); toHigh = BitUtils.MostSignificantByte(result); toLow = BitUtils.LeastSignificantByte(result); // Zero flag is not affected FlagUtils.SetFlag(Flag.N, false, ref flags); FlagUtils.SetFlag(Flag.H, (to & 0xFFF) + (value & 0xFFF) > 0xFFF, ref flags); FlagUtils.SetFlag(Flag.C, to + value > 0xFFFF, ref flags); TickEvent?.Invoke(); }
void ICountdownService.Next() { if (-1 == infoPtr) { return; } switch (currentInfo.Status) { case CountdownInfoStatus.NotStart: infoPtr = (infoPtr + countdownInfos.Count + 1) % countdownInfos.Count; CurrentInfo = countdownInfos[infoPtr]; TickEvent?.Invoke(CurrentInfo); return; case CountdownInfoStatus.Running: base.Stop(); currentInfo.Minute = 0; currentInfo.Second = 0; currentInfo.FinishTime = DateTime.Now; currentInfo.Status = CountdownInfoStatus.Completed; TickEvent?.Invoke(CurrentInfo); ReachEndEvent?.Invoke(CurrentInfo); return; case CountdownInfoStatus.Paused: base.Stop(); currentInfo.Minute = 0; currentInfo.Second = 0; currentInfo.FinishTime = DateTime.Now; currentInfo.InterruptionInfos.Last().FinishTime = DateTime.Now; currentInfo.Status = CountdownInfoStatus.Completed; TickEvent?.Invoke(CurrentInfo); ReachEndEvent?.Invoke(CurrentInfo); return; case CountdownInfoStatus.Completed: infoPtr = (infoPtr + countdownInfos.Count + 1) % countdownInfos.Count; CurrentInfo = countdownInfos[infoPtr]; TickEvent?.Invoke(CurrentInfo); return; default: return; } }
public void LoadAdjusted(ref byte destHigh, ref byte destLow, ushort value, byte addValue, ref byte flags) { ushort originalValue = value; sbyte signed = unchecked ((sbyte)addValue); FlagUtils.SetFlag(Flag.C, ((originalValue & 0xFF) + addValue) > 0xFF, ref flags); FlagUtils.SetFlag(Flag.H, (originalValue & 0x0F) + (addValue & 0x0F) > 0xF, ref flags); ushort result = (ushort)(value + signed); destHigh = BitUtils.MostSignificantByte(result); destLow = BitUtils.LeastSignificantByte(result); FlagUtils.SetFlag(Flag.Z, false, ref flags); FlagUtils.SetFlag(Flag.N, false, ref flags); TickEvent?.Invoke(); }
public bool Update() { if (ticked) { return(true); } FramesRemain--; if (FramesRemain <= 0) { TickEvent?.Invoke(); ticked = true; return(true); } return(false); }
// Setup the two Ai players private void Start() { if (OnStart != null) { OnStart(); } //Set Lane listeners foreach (LaneManager lane in lanes) { lane.OnLaneReady.AddListener(LaneReady); } P1.init(); P2.init(); IBoardState[] data = lanes.ToArray(); OnTick.Invoke(data); // LogStack.Log ("Tournament Manager initialised", LogLevel.System); }
// Update is called once per frame protected override void UpdateLate() { spanEv.Invoke(); }
public void JumpToAddress(ushort address, ref ushort pc) { pc = address; TickEvent?.Invoke(); }
private void SecondTick(object sender, WorkoutTimerChangesEventArgs e) { TickEvent?.Invoke(this, new TrainChangeEventArgs()); }
// Update is called once per frame protected override void FixedUpdateLate() { span40.Invoke(); span600.Invoke(); }